Compilation Techniques Notes

Mid Exam

RE to DFARE to DFAExample Kenny Jingga CT UTS Quiz kennydfa1.png kennydfa2.png kennydfa3.png Example Ivan Sebastian CT UTS Quiz Status: #idea Tags: compilation-techniques > Mid Exam References

RE to E-NFA to DFARE to E-NFA to DFAExample Kenny Jingga CT UTS Quiz kenny1.png Example Ivan Sebastian CT UTS Quiz ivan2.png WRONGGGG Status: #idea Tags: compilation-techniques > Mid Exam References

Context Free GrammarContext Free GrammarOrder as Follows 1. Left Factoring 1. Left Recursive Only when A is the leftmost in A -> Aα | β Status: #idea Tags: compilation-techniques > Mid Exam References

Top down parsingTop down parsingsteps 1. no left recursive and left factoring 1. find First values (as many grammars that we have) 1. find Follow value (as many grammars that we have) 1. make Parsing Table 1. search through the parsing Example Alvina Aulia Top Down Parsing 1. E -> TE' 1. E' -> +TE' | ε 1. T -> FT' 1. T' -> \FT'* | ε 1. F -> (E) | id First Values: 1. First E = (, id (this is from E -> T -> F) 1. First E' = +, ε 1. First T = (, id 1. First T' = \*, ε 1. First F = (, id Follow Values: 1. Follow E = $, )

Final Exam

Bottom Up ParsingBottom Up Parsingsteps 1. Perform Go To operation 1. Find Follow value 1. Create SLR Table 1. Search through parsing no need to remove Left Recursive Example Alvina Aulia Bottom Up Parsing 1. E -> E + T | T 1. T -> T * F | F 1. F -> (E) | id Perform Go To operation: i0: E' -> .E 1. E -> .E + T 1. E -> .T 1. T -> .T * F 1. T -> .F 1. F -> .(E) 1. F -> .id (Input E to i0) i1: E' -> E. 1. E -> E. + T (Input T to i0) i2: 2. E -> T. 3. T -> T. * F (Input F to i0) i3: 4. T -> F. Screenshot 2024-11-17

Directed Acyclic GraphDirected Acyclic Graphsteps 1. Look for Three Address Code (TAC) 1. Create DAG based on TAC From left to right Don't repeat any nodes Example Alvina Aulia Directed Acyclic Graph 1. x = a + a \* (b - c) + (b - c) \* d T1 T1 1. x = a + a * T1 +T1 \* d T2 1. x = a + T2 + T1 * d T3 1. x = a + T2 + T3 T4 1. x = T4 + T3 T5 1. x = T5 T1 = b - c T2 = a \* T1 T3 = T1 \* d T4 = a + T2 T5 = T4 + T3 x = T5 Screenshot 2024-12-09 at 1.06.21 PM.png Status: #idea Tags: compilation-techniques > Fi

TAC, Triples, Quadriples

Intermediate Code GeneratorIntermediate Code GeneratorExpressed as quadruples: Opr Arg1, Arg2, Store/result If there is a while, add jmpf right away only jmpf always come first Intermediate Code Generator Operators Example Alvina Aulia Intermediate Code Generator x := 1; y := x + 10; while (x Final Exam](../compilation-techniques.md#final-exam) References

Annotated Parse Tree

Three Address Statement

https://www.youtube.com/watch?v=\_Jng5xgLxkI&list=PLB2GiO0mMjw9J_OwnDMAqtsANzWsIylQz&index=9&ab_channel=HIMTIBINUS

Status: #MOC
Tags: