This project implements a complete custom compiler and virtual machine developed in GNU C/C++ for the Arion programming language. The pipeline includes a lexical analyzer, a Recursive Descent syntax parser, a semantic analyzer, an Intermediate Code (IC) generator, and a custom Stack-based Virtual Machine (Interpreter).
This project is part of the IF2224 - Formal Language and Automata Theory course at STEI ITB.
| NIM | Name | GitHub |
| 13524024 | Billie Bhaskara Wibawa | @billie-bytes |
| 13524050 | Raysha Erviandika Putra | @Arbane557 |
| 13524058 | Muhammad Naufal Romi Annafi | @naufalromi |
| 13524084 | Dzaki Ahmad Al Hussainy | @HussainDzaki |
- Tokenization (Lexer): Converts source text into token streams using a manual DFA-based scanner.
- Recursive Descent Parsing: Builds Parse Tree structures from Arion grammar rules.
- Semantic Validation: Performs scope resolution, type compatibility checks, and constructs TAB, ATAB, and BTAB symbol tables.
- Intermediate Code Generation: Traverses the Decorated AST to synthesize flat, Three-Address Code (TAC) instructions (e.g.,
LOD,STO,JMP,JPC,OPR). - Stack-Based Virtual Machine (Interpreter): A custom execution engine featuring a Program Counter, Stack Pointer, and Base Pointer to manage memory, variable scopes (Static/Dynamic links), and subroutine calls.
- File-Based Execution: Includes an
ICParsercapable of loading and executing standalone.icbytecode files. - Runtime Error Handling: Active VM protection against stack overflow, stack underflow, invalid jump targets, and division by zero.
- Interactive I/O: Full support for
readln,read,writeln, andwritestandard procedures. - No External Generators: Implemented entirely from scratch in C++ without tools like Lex or Yacc.
.
├── README.md
├── src
│ ├── codegen
│ │ ├── CodeGenerator.cpp
│ │ └── CodeGenerator.hpp
│ ├── common
│ │ ├── DataType.hpp
│ │ ├── Error.cpp
│ │ ├── Error.hpp
│ │ ├── Instruction.cpp
│ │ ├── Instruction.hpp
│ │ ├── NodeType.hpp
│ │ ├── ObjectType.hpp
│ │ ├── Reader.cpp
│ │ ├── Reader.hpp
│ │ ├── RuntimeValue.cpp
│ │ ├── RuntimeValue.hpp
│ │ ├── Token.cpp
│ │ ├── Token.hpp
│ │ ├── Tree.cpp
│ │ ├── Tree.hpp
│ │ ├── Writer.cpp
│ │ └── Writer.hpp
│ ├── interpreter
│ │ ├── ICParser.cpp
│ │ ├── ICParser.hpp
│ │ ├── Interpreter.cpp
│ │ └── Interpreter.hpp
│ ├── lexer
│ │ ├── Lexer.cpp
│ │ ├── Lexer.hpp
│ │ ├── LexerState.hpp
│ │ ├── SpecificScanners.cpp
│ │ └── SpecificScanners.hpp
│ ├── semantic
│ │ ├── ASTBuilder.cpp
│ │ ├── ASTBuilder.hpp
│ │ ├── ASTNode.hpp
│ │ ├── ASTPrinter.cpp
│ │ ├── ASTPrinter.hpp
│ │ ├── ASTVisitor.hpp
│ │ ├── SemanticAnalyzer.cpp
│ │ ├── SemanticAnalyzer.hpp
│ │ ├── SemanticVisitor.cpp
│ │ ├── SemanticVisitor.hpp
│ │ ├── SymbolTable.cpp
│ │ └── SymbolTable.hpp
│ ├── syntax
│ │ ├── Parser.cpp
│ │ └── Parser.hpp
│ └── main.cpp
└── test
├── lexer
├── parser
└── semantic
- GNU C/C++ Compiler (GCC/G++)
- Make
- Download and install MinGW-w64 from an official distributor
- Ensure
gcc,g++, andmake(ormingw32-make) are added to your system PATH - Verify:
g++ --version
make --version- Open your terminal
- Install build essentials:
sudo apt update
sudo apt install build-essential- Verify:
g++ --version && make --version- Clone the repository
git clone https://github.com/naufalromi/JEE-Tubes-IF2224-2026.git- Navigate to the repository and build
cd JEE-Tubes-IF2224-2026
make clean
make all- Run the compiler
make run- Choose analysis mode in the interactive menu:
1Lexical Analyzer2Syntax Analyzer3Semantic Analyzer4Intermediate Code Generator5Interpreter (Run Program)
- Choose testcase number based on the selected mode folder.
Semantic mode will:
- Build and analyze the decorated AST
- Print semantic errors when present
- Allow semantic display options (Decorated AST, TAB, ATAB, BTAB, or all)
| Name | NIM | Workload | Percentage |
| Billie Bhaskara Wibawa | 13524024 | Report and Coding | 25% |
| Raysha Erviandika Putra | 13524050 | Report and Coding | 25% |
| Muhammad Naufal Romi Annafi | 13524058 | Report and Coding | 25% |
| Dzaki Ahmad Al Hussainy | 13524084 | Report and Coding | 25% |