Related articles |
---|
Parser question mike@sesamgames.com (Mike \(News\)) (2008-07-11) |
Re: Parser question avron2006b@yahoo.com (Aeran) (2008-07-13) |
Re: Parser question max@gustavus.edu (Max Hailperin) (2008-07-13) |
Re: Parser question DrDiettrich1@aol.com (Hans-Peter Diettrich) (2008-07-15) |
Re: Parser question mikael@sesamgames.com (Mikael =?ISO-8859-1?Q?Str=F6m?=) (2008-07-17) |
Re: Parser question max@gustavus.edu (Max Hailperin) (2008-07-19) |
From: | "Mike \(News\)" <mike@sesamgames.com> |
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!
/Mike
Return to the
comp.compilers page.
Search the
comp.compilers archives again.