This project aims to create a compiler for the game Human Resource Machine using a custom language called "Human Resource Machine LazyCoder Language" (HRML). The language simplifies the game's coding challenges by abstracting some of its assembly-like constructs, allowing you to write code more efficiently.
In addition, the project provides a VSCode extension for HRML language support, allowing syntax highlighting and language-specific configuration.
Ensure you have the following dependencies installed before building the project. The exact dependencies vary based on the platform you are using.
- CMake (version 3.25 or higher)
- A modern C++ compiler with C++20 support
- Flex and Bison (for lexical analysis and parsing)
- spdlog (for logging)
- Boost (for various utilities)
- YAML-CPP (for writing yaml in intermediate steps)
- Google Test (for testing)
The project is located in the compiler/ directory. You can build it using CMake.
-
Clone the Repository:
git clone https://github.com/sakamoto-poteko/HumanResourceCompiler.git cd HumanResourceCompiler/compiler -
Create a Build Directory:
mkdir build
-
Install Dependencies:
Debian/Ubuntu
To install dependencies on Debian and derivations, use the following commands:
sudo apt-get install -y cmake ninja-build flex bison libspdlog-dev libboost-dev libboost-graph-dev libboost-program-options-dev libgtest-dev
macOS
To install dependencies on macOS:
brew update brew install cmake ninja boost spdlog flex bison googletest
Windows
On Windows, dependencies are installed using
vcpkg. You can follow these steps:git clone https://github.com/microsoft/vcpkg.git .\vcpkg\bootstrap-vcpkg.bat
-
Configure the Build:
# *nix cmake -B build -S . -DCMAKE_BUILD_TYPE=Release # Or with Ninja cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -G Ninja
# Windows w/ vcpkg cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=vcpkg\scripts\buildsystems\vcpkg.cmake
Replace
ReleasewithDebugor other build types if needed. -
Build the Project:
cmake --build build --config Release -- -j$(nproc || sysctl -n hw.ncpu || 2) -
Run Tests:
cd build ctest -C Release --output-on-failure
This project also includes a VSCode extension for Human Resource Machine LazyCoder (HRML) language support, which provides syntax highlighting and configuration.
-
Install Dependencies:
-
Install Node.js and npm if not already installed.
sudo apt-get install nodejs npm
-
Install vsce (Visual Studio Code Extension Manager).
npm install -g @vscode/vsce
-
-
Navigate to the Extension Directory:
cd human-resource-lazycoder-vscode -
Package the Extension: Run the following command to package the extension into a
.vsixfile:vsce package
Once installed, the extension will provide:
- Syntax highlighting for
.hrmlfiles.
The Human Resource Machine LazyCoder Language (HRML) is designed to simplify the process of solving levels in Human Resource Machine. Key features include:
- Simple Arithmetic Operations:
+,-,*,/,% - Logical Operations:
&&,||,>,<,==,!=, etc. - Control Structures:
if,while,for - Memory Access: Direct access to "floor" slots with the
floor[]syntax. - Basic Subprograms: Supports simplified
functionandsubconstructs.
This project is licensed under the MIT License. See the LICENSE file for more details.
For more details on the project, including the design process and language features, check out the following articles:
- Building a Human Resource Machine Compiler - Preface
- Building a Human Resource Machine Compiler - Language Design
- Building a Human Resource Machine Compiler - Lexical Analysis
- Building a Human Resource Machine Compiler - Syntax Parser (1)
More on the way.