Skip to content

sakamoto-poteko/HumanResourceCompiler

Repository files navigation

Human Resource Machine Compiler

Compiler VSCode Extension

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.

Getting Started

Prerequisites

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)

Build Instructions

The project is located in the compiler/ directory. You can build it using CMake.

Manual Build Steps

  1. Clone the Repository:

    git clone https://github.com/sakamoto-poteko/HumanResourceCompiler.git
    cd HumanResourceCompiler/compiler
  2. Create a Build Directory:

    mkdir build
  3. 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
  4. 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 Release with Debug or other build types if needed.

  5. Build the Project:

    cmake --build build --config Release -- -j$(nproc || sysctl -n hw.ncpu || 2)
  6. Run Tests:

    cd build
    ctest -C Release --output-on-failure

VSCode Extension Setup

This project also includes a VSCode extension for Human Resource Machine LazyCoder (HRML) language support, which provides syntax highlighting and configuration.

Development Instructions

  1. 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
  2. Navigate to the Extension Directory:

    cd human-resource-lazycoder-vscode
  3. Package the Extension: Run the following command to package the extension into a .vsix file:

    vsce package

Once installed, the extension will provide:

  • Syntax highlighting for .hrml files.

Language Overview

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 function and sub constructs.

License

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:

  1. Building a Human Resource Machine Compiler - Preface
  2. Building a Human Resource Machine Compiler - Language Design
  3. Building a Human Resource Machine Compiler - Lexical Analysis
  4. Building a Human Resource Machine Compiler - Syntax Parser (1)

More on the way.

About

Human Resource Machine Compiler (WIP)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages