Re: Parser ambiguity

Max Hailperin <max@gustavus.edu>
Sun, 15 Mar 2009 19:34:44 -0500

          From comp.compilers

Related articles
Parser ambiguity m.helvensteijn@gmail.com (2009-03-15)
Re: Parser ambiguity cfc@shell01.TheWorld.com (Chris F Clark) (2009-03-15)
Re: Parser ambiguity max@gustavus.edu (Max Hailperin) (2009-03-15)
Re: Parser ambiguity m.helvensteijn@gmail.com (2009-03-16)
Re: Parser ambiguity m.helvensteijn@gmail.com (2009-03-16)
| List of all articles for this month |
From: Max Hailperin <max@gustavus.edu>
Newsgroups: comp.compilers
Date: Sun, 15 Mar 2009 19:34:44 -0500
Organization: Compilers Central
References: 09-03-066
Keywords: parse, design
Posted-Date: 15 Mar 2009 21:56:52 EDT

m.helvensteijn@gmail.com writes:


> I'm trying to solve this ambiguity in my Bison GLR parser. I would
> appreciate any insights. The relevant rules are these:
> ...
> function_declaration:
> type identifier '(' formal_parameter_list
> ')' |
> type identifier '(' formal_parameter_list ')' '{' statement_sequence
> '}' |
> function_declaration "body" '{' statement_sequence
> '}' |
> function_declaration "pre" '{' statement_sequence
> '}' |
> function_declaration "post" '{' statement_sequence
> '}' ;
>...


How about


function_declaration:
    type identifier '(' formal_parameter_list ')' fundec_tail
    ;


fundec_tail:
    '{' statement_sequence '}' opt_explicit_tail
    |
    explicit_tail
    ;


opt_explicit_tail:
    explicit_tail
    |
    /* empty */
    ;


explicit_tail:
    explicit_tail_element
    |
    explicit_tail explicit_tail_element
    ;


excplicit_tail_element:
      "body" '{' statement_sequence '}'
      |
      "pre" '{' statement_sequence '}'
      |
      "post" '{' statement_sequence '}'
      ;


Post a followup to this message

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