sinhayash
sinhayash

Reputation: 2803

Explain Parsing Table at http://hackingoff.com/compilers/ll-1-parser-generator

I am using the following grammar at http://hackingoff.com/compilers/ll-1-parser-generator :

E ->  T E'
E' ->  + T E' 
E' -> EPSILON
T ->  F T'
T' -> * F T'
T' -> EPSILON 
F -> ( E ) 
F ->  id

The output Parsing Table is

[
        [0, "+", "*", "(", ")", "id", "$"],
        [0, 0, 0, 0, 0, 0, 0],
        [0, 10, 10, 1, 9, 1, 9],
        [0, 2, 10, 10, 3, 10, 3],
        [0, 9, 10, 4, 9, 4, 9],
        [0, 6, 5, 10, 6, 10, 6],
        [0, 9, 9, 7, 9, 8, 9]
]

Can somebody explain the parsing table? In particular, what is the meaning of 9 and 10 given that there are only 8 lines in the production rules

Upvotes: 1

Views: 912

Answers (1)

rici
rici

Reputation: 241721

It's explained in the page itself, just above the table:

If a terminal is absent from a non-terminal's predict set, an error code is placed in the table. If that terminal is in follow(that non-terminal), the error is a POP error. Else, it's a SCAN error.

POP error code = # of predict table productions + 1

SCAN error code = # of predict table productions + 2

So in the case of a grammar with eight production rules, the values 9 and 10 are POP error and SCAN error, respectively.

Upvotes: 1

Related Questions