
















































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

















































1
Nonrecursive Predictive Parsing
It is possible to build a nonrecursive predictive parser This is done by maintaining an explicit stack
2
Nonrecursive Predictive Parsing
It is possible to build a nonrecursive predictive parser This is done by maintaining an explicit stack
4
LL(1) table: One dimension for current non-terminal to expand One dimension for next token Table entry contains one production
5
LL(1) table: One dimension for current non-terminal to expand One dimension for next token Table entry contains one production
7
Consider the expression grammar
1 E → T E' 2 E' → + T E' 3 | ε 4 T → F T' 5 T' → (^) * F T' 6 | ε 7 F → ( E ) 8 | id
8
Predictive Parsing Table id (^) + * ( ) $ E E → TE' E → TE' E' E' →
E' → ε E' → ε T T → FT' T → FT' T' T' → ε (^) T → * FT' (^) T' → ε T' → ε F F → id F → ( E ) Columns for next token^ Rows for current non-terminal to expand
10
The predictive parser uses an explicit stack to keep track of pending non- terminals
It can thus be implemented without recursion.
11
The predictive parser uses an explicit stack to keep track of pending non- terminals
It can thus be implemented without recursion.
13
The input buffer contains the string to be parsed; $ is the end-of-input marker The stack contains a sequence of grammar symbols
14
Initially, the stack contains the start symbol of the grammar on the top of $.
16
The program considers X , the symbol on top of the stack, and a, the current input symbol.
17
These two symbols, X and a determine the action of the parser.
There are three possibilities.
19
20