Parsing table
After the construction of the parsing table, if for any non-terminal symbol in the table we have more than one production rule for any terminal symbol in the table column the grammar is not LL(1). Otherwise, then grammar is considered as LL(1).
Rules for construction of parsing table:
Step 1: For each production A → α , of the given grammar perform Step 2 and Step 3.
Step 2: For each terminal symbol ‘a’ in FIRST(α), ADD A → α in table T[A,a], where ‘A’ determines row & ‘a’ determines column.
Step 3: If ε is present in FIRST(α) then find FOLLOW(A), ADD A → ε, at all columns ‘b’, where ‘b’ is FOLLOW(A). (T[A,b])
Step 4: If ε is in FIRST(α) and $ is the FOLLOW(A), ADD A → α to T[A,$].
The assumption made in code:
a) LHS symbol of First rule is considered as start symbol.
b) ‘#’ represents epsilon symbol.
Compiler Design LL(1) Parser in Python
Prerequisite: Construction of LL(1) Parsing Table, Classification of top-down parsers, FIRST Set, FOLLOW Set
In this article, we are going to see how to design LL(1) Parser compiler using Python.
Contact Us