EPS FIRST FOLLOW PREDUCT
- epsilon, cant be in first, follow, or predict!
- EPS(a), if a = ? true || false (Boolean operation)
- First(a) all possible first outcomes for some a. Eg. First(stmt) = until | id
- Follow:
- What can come after on the right hand side of the expr? Eg. FOLLOW(a) = ; $
- If a is in possible child, put \epsilon$
- Set of non terminals
- Predict: (requires some )
- if a can result in →
- Union means all unique elements in both sets (basically no elements shared but combine both)
- if a = → just take FIRST(A)
- if a can result in →
p. 121 of textbook
parse stack
What is the content of the parse stack, if we run the table-driven top down parser algorithm on
until (s1, s2, s3; cond)
and “s1” appears for the first time in the top of the stack?
Using the parse tree at the top, start for the Program, replace program with Stmts, and keep expanding eg. Program, \ \rightarrow Stmts, Stmts_Tail$$, then one would expand Both Stmts and Stmts_tail until s_1 is reached. When until is reached use whatever inside until argument (basically each stack item is just some command to follow with the given grammer)