13 Jan 2002 22:54:49 -0500

Related articles |
---|

LL(1) parser table hyperarien@yahoo.com (2002-01-05) |

Re: LL(1) parser table gsc@zip.com.au (Sean Case) (2002-01-07) |

Re: LL(1) parser table dr_feriozi@prodigy.net (SLK Parsing) (2002-01-13) |

Re: LL(1) parser table kaarthik@cisco.com (Kaarthik) (2002-01-13) |

Re: LL(1) parser table kaarthik@cisco.com (Kaarthik) (2002-01-13) |

Re: LL(1) parser table hyperarien@yahoo.com (2002-01-14) |

From: | Kaarthik <kaarthik@cisco.com> |

Newsgroups: | comp.compilers |

Date: | 13 Jan 2002 22:54:49 -0500 |

Organization: | cisco |

References: | 02-01-026 |

Keywords: | parse, LL(1) |

Posted-Date: | 13 Jan 2002 22:54:48 EST |

Hi,

I beleive, it is not a LL(1) grammar. LR is a better parsing technique

b'cos it is stateful, meaning the decision about which branch to take

for such a situation (wether to use first or follow) is decided based on

the state of the parser, how much of the parsing is done. It is not at

all difficult to create an LR parser for the same grammar.

Need any help in creating a LR parser, do get back.

Kaarthik

lee wrote:

*> Hi all,*

*>*

*> I am trying construct a LL1 parser table for the following grammar.*

*>*

*> S -> E*

*> E -> ++E | E++ | E-E | E/E | id*

*>*

*> where symbols have usual meanings.*

*>*

*> However in the final table this grammar seems to be ambiguous. I*

*> actually first transformed the above into this disambiguous form.*

*>*

*> S -> E*

*> E -> E-T | T*

*> T -> T/F | F*

*> F -> F++ | G*

*> G -> ++E | id*

*>*

*> And after that I removed all left-recursions.*

*>*

*> S -> E*

*> E -> TE'*

*> E'-> -TE'*

*> E'-> epsilon*

*> T -> FT'*

*> T'-> /FT'*

*> T'-> epsilon*

*> F -> GF'*

*> F'-> ++F'*

*> F'-> epsilon*

*> G -> ++E*

*> G -> id*

*>*

*> Still after all this grammar is ambiguous. Because F' FOLLOW set is*

*> {/,-,++,$} and there are two entries for [F',++] comination.*

*>*

*> Does this means the above grammar is not suitable for LL1 parsing?*

Post a followup to this message

Return to the
comp.compilers page.

Search the
comp.compilers archives again.