A simple compiler that takes arithmetic expressions as input and generates assembly-like code. This project demonstrates the basics of compiler construction with lexical analysis, parsing, and code generation.
- Tokenizes arithmetic expressions
- Parses and evaluates expressions
- Generates assembly code representation
- Supports basic arithmetic operations (addition, subtraction, etc.)
The project uses CMake for building:
cd arithmetic-compiler
mkdir build
cd build
cmake ..
makeAfter building, run the compiler:
./ArithmeticCompilerEnter an arithmetic expression when prompted, for example:
3 + 4 - 2
The program will display the result of the expression and generate corresponding assembly code.
src/- Source code filesmain.c- Entry pointtokenizer.c- Lexical analysisparser.c- Syntax analysisassembly.c- Code generation
include/- Header filesCMakeLists.txt- CMake build configuration
See the LICENSE file in the root directory for details.