|newbie grammar/parser/interpreter questions email@example.com (1992-05-07)|
|Re: newbie grammar/parser/interpreter questions firstname.lastname@example.org (1992-05-08)|
|From:||email@example.com (Terence J Parr)|
|Date:||Fri, 8 May 1992 19:22:00 GMT|
firstname.lastname@example.org (Craig Heilman) writes:
> 2. Considering my hardware constraints, would it be prudent to hard-code
> the parser as I have done to date, or should I rely on yacc or bison
> generated code. (I played with yacc a bit and the output was pretty
> unreadable...). I'm somewhat worried about future maintenance.
o Under normal circumstances, parser generators should be used for all but
the simplest grammars (I never write *any* language recognizer by hand
if I can help it).
o If you don't like yacc and bison, try PCCTS--The Purdue Compiler-
Construction Tool Set. It generates human-readable C code that
can easily be dbx'ed. PCCTS has many features that you might find
useful including its ability to automatically construct abstract-
syntax-trees (AST's). Send mail with an empty or bogus Subject:
line to email@example.com and a mail server will tell you how
to get the software.
o Recursive descent parsers like you have currently are considered
LL(1); i.e. they read input from left to right, make parsing decisions
on the left edge of productions (they're predictive), and use 1
token of lookahead. PCCTS generates LL(k) parsers where k is some
finite integer and, hence, can generate recursive descent parsers
with much more recognition power than the parsers you could be generate
> 1. Can this grammar be modified to include the precedence of messages
> as outlined in section E above, or would it be better to just rewrite
> the grammar from scratch?
o Precedence is implicitly defined in an LL (top-down) grammar. You
will have to modify your grammar to encode the correct precendence.
Terence Parr firstname.lastname@example.org
Purdue University Electrical Engineering
[On that third bullet, I thought anything that was LL(k) was also LL(1),
albeit perhaps requiring ugly rewrites of the grammar. -John]
Return to the
Search the comp.compilers archives again.