Parser question

"Mike \(News\)" <>
Fri, 11 Jul 2008 19:21:05 +0800

          From comp.compilers

Related articles
Parser question (Mike \(News\)) (2008-07-11)
Re: Parser question (Aeran) (2008-07-13)
Re: Parser question (Max Hailperin) (2008-07-13)
Re: Parser question (Hans-Peter Diettrich) (2008-07-15)
Re: Parser question (Mikael =?ISO-8859-1?Q?Str=F6m?=) (2008-07-17)
Re: Parser question (Max Hailperin) (2008-07-19)
| List of all articles for this month |

From: "Mike \(News\)" <>
Newsgroups: comp.compilers
Date: Fri, 11 Jul 2008 19:21:05 +0800
Organization: Compilers Central
Keywords: parse, question
Posted-Date: 12 Jul 2008 23:54:02 EDT

I blow the dust of my old Dragon book and started to read. I got some
inspiration to make a very simple (read subset of a) C compiler.

The implementation is a predictive parser that construct a syntax tree
holding both expression and statements. As the grammar is recursive,
so is the implementation. However, i wish to find some shortcuts to
rewrite (at least some of) the recursive functions to be
iterative. Are there any well known algorithms of doing this? I could
not find much info on this topic in the dragon book.

For instance the grammar for:

expr -> term moreterms

moreterms -> + term | - term | N5

Is inherently recursive. How would I write iterative code for this using
my tree function makenode_op(operand, left, right)?

An example in pseudo code would be most helpful to get me started.

Thanks in advance!


Post a followup to this message

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