This project implements only the frontend of a compiler.
The original plan included a second phase focused on optimization and backend development. However, due to the digital blackout in Iran in 2026, development of the second phase was canceled and could not be completed. As a result, the project was finalized at the frontend stage.
The existing implementation remains complete and functional within its intended scope.
This compiler frontend includes the core components required to analyze and validate source programs, from lexical analysis through semantic checking. It is designed with a clear architecture and strong observability to support debugging, analysis, and future extensibility.
- Lexical analysis with line and column tracking\
- Syntax analysis and AST construction\
- Visitor-based AST design\
- Semantic analysis (type checking, symbol validation, initialization checks)\
- Detailed error reporting with precise source locations\
- Execution tracing and observability support
.
├── code
│ ├── AST.h
│ ├── CodeGen.cpp
│ ├── CodeGen.h
│ ├── error.cpp
│ ├── error.h
│ ├── lexer.cpp
│ ├── lexer.h
│ ├── main.cpp
│ ├── Makefile
│ ├── observability.cpp
│ ├── observability.h
│ ├── parser.cpp
│ ├── parser.h
│ ├── semantic.cpp
│ ├── semantic.h
│ └── tests
│ ├── example.src
│ └── input.src
└── README.md
Write your program in a .src file, following the same syntax as the
examples in:
code/tests/
You may copy or modify:
code/tests/input.src
From the code directory, run:
makeThis builds the compiler executable:
mycompiler
To compile and analyze a source file:
./mycompiler tests/input.srcThis runs: - lexical analysis\
- parsing\
- semantic analysis\
- frontend validation
and prints any errors with precise source locations.
To generate detailed observability and execution reports:
./mycompiler tests/input.src --observability --output-dir=./obs_output 2>&1This enables internal tracing and writes observability data to
./obs_output.
make
./mycompiler tests/input.src
./mycompiler tests/input.src --observability --output-dir=./obs_output 2>&1- Frontend: Complete\
- Optimization: Not implemented\
- Backend: Not implemented