Re: regular LALR parsers

norman@flaubert.bellcore.com (Norman Ramsey)
Mon, 16 Aug 1993 17:47:28 GMT

          From comp.compilers

Related articles
regular LALR parsers simonh@swidev.demon.co.uk (1993-08-13)
Re: regular LALR parsers norman@flaubert.bellcore.com (1993-08-16)
Re: regular LALR parsers clark@zk3.dec.com (1993-08-30)
| List of all articles for this month |
Newsgroups: comp.compilers
From: norman@flaubert.bellcore.com (Norman Ramsey)
Summary: rewrite EBNF to BNF
Keywords: parse, LALR, EBNF
Organization: Bellcore
References: 93-08-073
Date: Mon, 16 Aug 1993 17:47:28 GMT

simonh@swidev.demon.co.uk writes:
>How does an LALR parser with regular expressions (eg. *, +, []) handle the
>attribute stack? Obviously, the attributes on the stack depend on the number
>of iterations of constructs such as *, +.


I take closure to mean a list of attributes and optional to mean an
attribute or null. It's pretty easy in my application since I'm
generating Icon code, which has built-in list and null types.


For the implementation, I avoid all your questions about shift
conflicts by rewriting all the extended BNF to ordinary
BNF. For example, I rewrite closure `(a b c {semantics})*' to


    foo: { $$ = [] } # empty list
          | foo foo_1 { $$ = put($1, $2) } # append element to list
          ;
    foo_1 : a b c {semantics};


When I get around to generating C code, I'll probably define a
simple list type using cons cells.
--


Post a followup to this message

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