Re: newbie grammar/parser/interpreter questions

parrt@ecn.purdue.edu (Terence J Parr)
Fri, 8 May 1992 19:22:00 GMT

          From comp.compilers

Related articles
newbie grammar/parser/interpreter questions craigh@cserver.plexus.com (1992-05-07)
Re: newbie grammar/parser/interpreter questions parrt@ecn.purdue.edu (1992-05-08)
| List of all articles for this month |
Newsgroups: comp.compilers
From: parrt@ecn.purdue.edu (Terence J Parr)
Organization: Compilers Central
Date: Fri, 8 May 1992 19:22:00 GMT

craigh@cserver.plexus.com (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 pccts@ecn.purdue.edu 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
        hand.


> 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


---
Terence Parr parrt@ecn.purdue.edu
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]
--


Post a followup to this message

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