flex tma3.l
bison -y -d tma3.y
gcc -c .\lex.yy.c .\y.tab.c
gcc .\lex.yy.c .\y.tab.c .\symbols.c .\symbol_table.c .\semantic.c .\parser.c .\ast.c .\stack.c .\codegen.c .\isa2.c -o .\tma3.exe
- Register Allocation/Deallocation
- Memory Usage
- Code Generation Phases
- Intermediate Code Generator
- Symbol Table Integration
- Target Code Generator (ISA2)
The main objective of the design project is the create the intermediate code generator and the target code generator for accumulator based ISA
┌────────────────────────────────────────────────────────────┐
│ INPUT: Verified AST │
│ (from Semantic Analysis Phase) │
└────────────────────┬───────────────────────────────────────┘
│
▼
┌────────────────────────────────────────────────────────────┐
│ PHASE 1: AST Traversal & 3AC Generation │
│ ─────────────────────────────────────── │
│ Module: codegen.c │
│ Entry: generate_ir(ASTNode* root) │
│ │
│ Actions: │
│ • Traverse AST recursively (traverse_all) │
│ • Generate quadruples for each construct │
│ • Manage temporary variables & labels │
│ • Build intermediate representation │
└────────────────────┬───────────────────────────────────────┘
│
▼
The intermediate code generator operates on a semantically verified AST with an annotated symbol table.
From Semantic Analysis Phase:
- Verified AST: No semantic errors
- Populated Symbol Table: All symbols declared, types resolved
- Offset Information: Local/parameter offsets calculated
- Type Information: Expression types determined
Preconditions Verified (semantic.c):
- All identifiers declared before use
- Type compatibility in assignments
- Function signatures match calls
- Return types correct
- Array bounds are constant
5a5a9478e54e9e8d0647340a58c191508bd6706a 6126eaf1e3f0503570b925582e1bfc4ac2c04636



