0% found this document useful (0 votes)
7 views2 pages

Grammarforparsing

The document discusses top-down parsing techniques, including backtracking and left factoring, for handling recursive grammars. It outlines the process of eliminating left recursion to create a modified left-factored grammar suitable for LL1 parsing. Additionally, it presents operator precedence parsing as a bottom-up approach for grammar evaluation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Grammarforparsing

The document discusses top-down parsing techniques, including backtracking and left factoring, for handling recursive grammars. It outlines the process of eliminating left recursion to create a modified left-factored grammar suitable for LL1 parsing. Additionally, it presents operator precedence parsing as a bottom-up approach for grammar evaluation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Consider the right recursive Top-down Parsing with Back tracking

grammar
E ☛T + E | T
T ☛V * T | V
V ☛<id>

Left Factoring Top-down parsing without back tracking


Common prefix requires
applying left factoring
E ☞T + E | T
T ☞V * T | V
Left factor E
E ☞T + E | T
E ☞ TE”
E” ☞ + E |ɛ
Left factor T
T☞V*T|V
T☞ VT”
T”☞ * T | ɛ
Modified Left Factored RD parser
Grammar
E ::= T { +T}*
T ::= V{* V}*
V ::= <id>
Consider the Left Recursive Not Used as it is for Top-Down Parsing
Grammar
E☛E+T|T
T☛T*V|V
V☛<id>
Eliminating left-recursion LL1 / Table driven / Top-down Parsing
Apply left recursion elimination
E ☞E+T|T
T☞T*V|V

Eliminate left recursion of E


E☞TE’
E’☞ ɛ | + TE’
Eliminating left recursion of T
T☞VT’
T’☞ ɛ | + VT’
Operator Grammar using Operator Precedence Parser (Bottom Up Parser)
(OPM)

id + * $
id ·> ·> ·>
+ <· ·> <· ·>
* <· ·> ·> ·>
$ <· <· <· ·>

You might also like