Skip to content

A simple imperative language compiler. INA, PWr, 2023/24

License

Notifications You must be signed in to change notification settings

Spiryd/gembalang

Repository files navigation

GEMBALANG

A simple imperative language compiler. INA, PWr, 2023/24

Author

Maksymilian Neumann

Requirements

Compilation requires the rust toolchain and an internet connection.

Usage

if using ubuntu

$ make
$ ./kompilator <input_file> <output_file>

or universal

$ cargo run -r -- <input_file> <output_file>

or you can build it and use the binary.

$ cargo build -r

it outputs the binary in "path_to_project/target/relese" it should be called kompilator.
usage:

$ ./target/relese/kompilator <input_file> <output_file>

File Description

All important source files are in the src directory

main.rs

Just an entry point to the program. Uses all the other source files. Handles Errors.

lexparse.lalrpop

This is our lexer/parser. Made using LALRPOP crate wich is an rust alternative to lex/bison. It lexes and parses our input and outputs an AST.

ast.rs

Defines the structure of the AST.

assembler.rs

This is where the magic happens. This defines a struct that is first used to build the AST into pseudo-assembly and than into the final file.

Cargo.toml

Configuration file for cargo.

build.rs

Custom build script for cargo to complie our lexer/parser.

Makefile

For Ubuntu. Compiles the program and moves to project folder.