Re: Usefulness of automatic parse tree generation

"Paul B Mann" <paulbmann@yahoo.com>
28 Jul 2004 12:06:12 -0400

          From comp.compilers

Related articles
Usefulness of automatic parse tree generation better_cs_now@yahoo.com (2004-07-13)
Re: Usefulness of automatic parse tree generation idbaxter@semdesigns.com (Ira Baxter) (2004-07-13)
Re: Usefulness of automatic parse tree generation cdc@maxnet.co.nz (Carl Cerecke) (2004-07-13)
Re: Usefulness of automatic parse tree generation better_cs_now@yahoo.com (Dave) (2004-07-17)
Re: Usefulness of automatic parse tree generation paulbmann@yahoo.com (Paul B Mann) (2004-07-28)
| List of all articles for this month |
From: "Paul B Mann" <paulbmann@yahoo.com>
Newsgroups: comp.compilers
Date: 28 Jul 2004 12:06:12 -0400
Organization: Compilers Central
References: 04-07-009 04-07-035 04-07-048
Keywords: parse, tools
Posted-Date: 28 Jul 2004 12:06:12 EDT

> How difficult is it to upgrade an SLR table generator to an LALR
> table generator?


Difficult. There are pitfalls such as the NQLALR (not quite LALR)
problem.


> It may be that the user of the library needs to provide rules for
> the transformation.


Yes, the user provides node names, at least.


> If so, what would these rules look like? I'd love to hear from
> anybody that has experience in doing this and can offer sound
> guidance! >


I did it this way in a commercial PG I wrote. The AST turns out to be
what you want.


// Operator precedence goes here


// Grammar:


      Goal -> Stmt... <eof>


      Stmt -> Exp ';'
                            -> Target '=' Exp ';' +> assign


      Target -> <identifier> +> target


      Exp -> Primary
                            -> Exp '+' Exp +> add
                            -> Exp '-' Exp +> sub
                            -> Exp '*' Exp +> mul
                            -> Exp '/' Exp +> div


      Primary -> <identifier> +> ident
                                -> '(' Exp ')'
                                -> '+' Primary
                                -> '-' Primary +> neg
                                -> '@' Primary +> addr


// End.


Paul B Mann
paulbmann@yahoo.com


Post a followup to this message

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