LL1 Parsing a b $ S 1 A 4 B 3 2 a b b b 1. S --> a B Input 2. B --> “” 3. B --> A S 4. A --> b B Parse Stack Compare Input and Stacktop 1
LL1 Parsing a b $ S 1 A 4 B 3 2 a b b b 1. S --> a B Input 2. B --> “” 3. B --> A S 4. A --> b B Parse Stack Get Predicted Production 2
LL1 Parsing a b $ S 1 A 4 B 3 2 a b b b 1. S --> a B Input 2. B --> “” 3. B --> A S 4. A --> b B Parse Stack Replace Top with RHS 3
LL1 Parsing a b $ S 1 A 4 B 3 2 a b b b 1. S --> a B Input 2. B --> “” a 3. B --> A B 4. A --> b B Parse Stack New Stack Contents 4
LL1 Parsing a b $ S 1 A 4 B 3 2 a b b b 1. S --> a B Input 2. B --> “” a 3. B --> A B 4. A --> b B Parse Stack Discard Matching Tokens 5
LL1 Parsing a b $ S 1 A 4 B 3 2 b b b 1. S --> a B Input 2. B --> “” 3. B --> A B 4. A --> b B Parse Stack Compare Input and Stacktop 6
LL1 Parsing a b $ S 1 A 4 B 3 2 b b b 1. S --> a B Input 2. B --> “” 3. B --> A A 4. A --> b B Parse Stack Compare Input and Stacktop 7
LL1 Parsing a b $ S 1 A 4 B 3 2 b b b 1. S --> a B Input 2. B --> “” b 3. B --> A B 4. A --> b B Parse Stack Discard Matching Tokens 8
LL1 Parsing a b $ S 1 A 4 B 3 2 b b 1. S --> a B Input 2. B --> “” 3. B --> A B 4. A --> b B Parse Stack Compare Input and Stacktop 9
LL1 Parsing a b $ S 1 A 4 B 3 2 b b 1. S --> a B Input 2. B --> “” 3. B --> A A 4. A --> b B Parse Stack Compare Input and Stacktop 10
LL1 Parsing a b $ S 1 A 4 B 3 2 b b 1. S --> a B Input 2. B --> “” b 3. B --> A B 4. A --> b B Parse Stack Discard Matching Tokens 11
LL1 Parsing a b $ S 1 A 4 B 3 2 b 1. S --> a B Input 2. B --> “” 3. B --> A B 4. A --> b B Parse Stack Compare Input and Stacktop 12
LL1 Parsing a b $ S 1 A 4 B 3 2 b 1. S --> a B Input 2. B --> “” 3. B --> A A 4. A --> b B Parse Stack Compare Input and Stacktop 13
LL1 Parsing a b $ S 1 A 4 B 3 2 b 1. S --> a B Input 2. B --> “” b 3. B --> A B 4. A --> b B Parse Stack Discard Matching Tokens 14
LL1 Parsing a b $ S 1 A 4 B 3 2 1. S --> a B Input 2. B --> “” 3. B --> A B 4. A --> b B Parse Stack Compare Input and Stacktop 15
LL1 Parsing a b $ S 1 A 4 B 3 2 1. S --> a B Input 2. B --> “” 3. B --> A 4. A --> b B Parse Stack DONE 16
If Tokens don’t match you have an ERROR If Stacktop and Input have nothing predicted -- ERROR If you have a Semantic Action at Stacktop, EXECUTE IT 17
Recommend
More recommend