Compiler Phases Buffering DFA Detailed
Compiler Phases Buffering DFA Detailed
a) Lexical Analysis:
- Input: a := b + c * 50
b) Syntax Analysis:
:=
/ \
a +
/\
b *
/\
c 50
c) Semantic Analysis:
- Output: Annotated syntax tree with symbol types and semantic errors (if any).
- Output:
t1 = c * 50
t2 = b + t1
a = t2
e) Code Optimization:
- Output:
t1 = 50 * c
t2 = b + t1
a = t2
MOV R1, c
MUL R1, 50
MOV R2, b
ADD R2, R1
MOV a, R2
Benefits:
- Enhances maintainability
3. Input Buffering
Advantages:
- Efficient scanning
NFA Construction:
- Loop for (a|b)*
Final DFA:
- Transitions:
q0 --a/b--> q0
q0 --a--> q1
q1 --b--> q2
q2 --b--> q3 (accepting)
Phases:
Scheme:
Benefits: