Human Resource Machine (HRM) is a computer game that introduces a simple assembly-like visual programming language to solve logical problems.
HRM Interpreter is a simple HRM assembly-like language interpreter built with FLEX and BISON.
Building the project requires cmake, flex and bison.
To build on Windows execute the build script utils\build.bat
. The built binary will be located at build\hrmi.exe
.
A Dev-C++ project is located at src\HRM.dev
.
To build on Linux execute the build script utils/build.sh
. The built binary will be located at build/hrmi
.
A installation script for Debian dependencies is located at utils/install.sh
.
The interpreted file has two parts: header and body.
input
is a required section that specifies the program's inbox. Each input must be separated by a colon. It is possible to execute the program with one or more input sets, separated by a semicolon.
Example:
input 1, 2, 3, 4, 5
inputs 1, 2, 3, 4, 5; 1, 2, 3, 4, 6
output
is an optional section that specifies the program's expected output. Each output must be separated by a colon. If supplied, the amount of output sets must be the same of input sets.
Example:
output 0, 1, 2, 3, 4
outputs 0, 1, 2, 3, 4; 0, 1, 2, 3, 5
var
is an optional section that specifies the program's starting variable values. Each variable declaration must be separated by a colon.
Example:
var 0 = 1
vars a = 1, b = 2
The body is composed by one or more commands. Each command may or may not contain parameters. Each parameter must be separated by a colon.
- INBOX
- OUTBOX
- COPYFROM
- COPYTO
- ADD
- SUB
- BUMPUP
- BUMPDN
- JUMP
- JUMPZ
- JUMPN
- COMMENT
At the moment pointers are not implemented.
For testing porpouses, some custom commands were added. They can be removed by undefining the USE_CUSTOM_COMMANDS
definition on src/interp.h
.
- MUL
- DIV
- MOD
- JUMPP
- JUMPNZ
- JUMPEQ
- JUMPNEQ
- JUMPLT
- JUMPLTEQ
- JUMPGT
- JUMPGTEQ
-- Header
inputs
1, 2, 3, 4, 5;
1, 2, 3, 4, 6
outputs
0, 1, 2, 3, 4;
0, 1, 2, 3, 5
vars
one = 1
-- Body
start:
INBOX
SUB one
OUTBOX
JUMP start
- Parser
- AST
- Vars
- Labels
- Interpreter
- Pointers
- Text values
The source code for this project is licensed under the MIT license, which you can find in the LICENSE
file.