Noob parser question

imissfloppydisks@gmail.com
Wed, 27 Feb 2008 21:05:19 -0800 (PST)

          From comp.compilers

Related articles
Noob parser question imissfloppydisks@gmail.com (2008-02-27)
Re: Noob parser question DrDiettrich1@aol.com (Hans-Peter Diettrich) (2008-02-28)
Re: Noob parser question max@gustavus.edu (Max Hailperin) (2008-02-28)
Re: Noob parser question gene.ressler@gmail.com (Gene) (2008-02-28)
Re: Noob parser question imissfloppydisks@gmail.com (2008-02-28)
| List of all articles for this month |
From: imissfloppydisks@gmail.com
Newsgroups: comp.compilers
Date: Wed, 27 Feb 2008 21:05:19 -0800 (PST)
Organization: Compilers Central
Keywords: parse, question
Posted-Date: 28 Feb 2008 10:43:08 EST

This is a CFG listed in the Aho (dragon) compiler text:


expr -> expr + term | expr - term | term
term -> term * factor | term / factor | factor
factor -> digit | (expr)
digit -> 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9


It is intended to parse simple arithmetic expressions taking into
account the precedence of operators. What I don't understand is why
you parse the operators with lower precedence first. I have worked
through several examples by hand and it works but I don't understand
why it works. Perhaps I should be content with that but I am a
perfectionist.


Thanks ...



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.