Re: Writing a recursive descent parser in C

"Joachim Durchholz" <joachim_d@gmx.de>
7 Dec 2001 23:35:28 -0500

          From comp.compilers

Related articles
Writing a recursive descent parser in C bilbo@volcanomail.com (2001-11-29)
Re: Writing a recursive descent parser in C spinoza1111@yahoo.com (2001-12-03)
Re: Writing a recursive descent parser in C joachim_d@gmx.de (Joachim Durchholz) (2001-12-07)
Re: Writing a recursive descent parser in C lingolanguage@hotmail.com (Bill Rayer) (2001-12-07)
Re: Writing a recursive descent parser in C dr_feriozi@prodigy.net (SLK Parsing) (2001-12-07)
Re: Writing a recursive descent parser in C alexc@world.std.com (2001-12-11)
Re: Writing a recursive descent parser in C spinoza1111@yahoo.com (2001-12-11)
| List of all articles for this month |
From: "Joachim Durchholz" <joachim_d@gmx.de>
Newsgroups: comp.compilers
Date: 7 Dec 2001 23:35:28 -0500
Organization: Compilers Central
References: 01-11-146 01-12-008
Keywords: parse, comment
Posted-Date: 07 Dec 2001 23:35:28 EST

Edward G. Nilges <spinoza1111@yahoo.com> wrote:
>
> [Good explanation of handcoded recursive descent parsing snipped]
>
> Effective implementations of transactioning support it with an
> unlimited stack inside the data base engine, which makes it an obvious
> choice in a recursive descent parser, which is using the runtime stack
> (of C or other runtime) to track its position in the grammar.
>
> If you do not have a data base, then you need to think about what the
> "output" routines of your compiler do. Your symbol table should be
> able to checkpoint and rollback, as should your machine code
> generator.


"Transactions with a stack" are named "nested transactions" in the
glossies.


Note that using a database to make the data structures undoable can
become a bit heavyweigth.
Also, mapping database data structures to in-memory data and back can be
a PITA (though it's less problematic for C than for languages that make
heavy use of polymorphism).


> In my usual scenario I am generating a stream of code to a reverse
> Polish machine, and at any time, checkpointing is merely noticing
> the size of the generating code, and rollback is re-allocating the
> Polish array back to the saved size.


Much cheaper than writing to a database and rolling back :)


> But as my technically adept and aware boss at Bell-Northern Research
> pointed out to me some time ago, if you have a modern editor, the
> economics of code generation change. You can use cutting and
> pasting more effectively than running some mainframe batch-oriented
> tool which yacc unfortunately is these days.


Oh no.
And if you have a bug, you cut-and-paste it a dozen times, leaving it to
be fixed another dozen times, if you find all the instances again?
C&P is OK for one-shot projects. It's not OK if the code has to be
maintained, no matter what the editor economics is.
Besides, it was *never* difficult to cut and paste. Not even in
mainframe days. Not even in the days of punched cards. So nothing has
changed, even if that boss said so.


Regards,
Joachim
[I agree, copying buggy code is hardly a new technique. -John]


Post a followup to this message

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