LLK and LRK
LLK and LRK
First L of LL is for left to right and second L is L of LR is for left to right and R is for rightmost
for leftmost derivation. derivation
It follows the left most derivation. It follows reverse of right most derivation.
Ends when stack used becomes empty. Starts with an empty stack.
Pre-order traversal of the parse tree. Post-order traversal of the parser tree.
Terminal is read after popping out of stack. Terminal is read before pushing into the stack.
• In this grammar:
• S represents statements.
• E represents expressions.
• If , then, else, id, and =are terminals.
• Consider the input string: if id = id then if id then id else id.
Bottom-up parsing is a technique used in
compiler construction to build the parse tree
of the input string by reducing it to the start
symbol. The parser starts with the input string
and repeatedly applies reduction (or
reduction) operations and shift operations
until the parse tree is constructed. One
commonly used bottom-up parsing method is
the Shift-Reduce Parsing technique.
Reduce with the grammar:
E→E+E
E→E*E
E → (E)
E → id
Let's parse the input string id + id * id using
bottom-up parsing.
• Let's parse the input string "id + id * id" using
bottom-up parsing.
Bottom-Up Parsing Top-Down Parsing