Re: ITE bison grammar problem

Carl Barron <cbarron413@adelphia.net>
5 Jun 2005 11:23:49 -0400

          From comp.compilers

Related articles
ITE bison grammar problem pocm@sat.inesc-id.pt (pmatos) (2005-06-04)
Re: ITE bison grammar problem pocm@sat.inesc-id.pt (pmatos) (2005-06-04)
Re: ITE bison grammar problem cbarron413@adelphia.net (Carl Barron) (2005-06-05)
Re: ITE bison grammar problem bluemalov_NOSPAM_@hotmail.com (Andrew Wilson) (2005-06-05)
| List of all articles for this month |
From: Carl Barron <cbarron413@adelphia.net>
Newsgroups: comp.compilers
Date: 5 Jun 2005 11:23:49 -0400
Organization: Compilers Central
References: 05-06-028
Keywords: parse, yacc
Posted-Date: 05 Jun 2005 11:23:49 EDT

pmatos <pocm@sat.inesc-id.pt> wrote:


> [ this has a reduce / reduce conflict ]
>
> %left '&' '+'
>
> %token id
>
> %start F
> %%
>
> F: "ite" '(' F ',' F ',' F ')'
> | E '&' E
> | M
> | id
> ;
>
> M: E "==" E;
>
> E: "ite" '(' E ',' E ',' E ')'
> | E '+' E
> | id
> ;
>
> %%
>
> (F is formula which represents a boolean value and E is an expression
> which represents a numerical value, id is an identifier that can
> represent a numerical value or a boolean value but that depends on its
> definition, right now, it's a sequecene of chars)


if the vars are declared before use
[explicitly or as a lhs of an assignment] before use then a symbol table
used in the lexer could return different tokens depending on the type of
the existing variable then change id to f_id and e_id and then
modify F and E to use the appropriate f_id or e_id.


  %token e_id
  %token f_id
....


F : ...
    | f_id
    ;
E : ...
    | e_id
    ;
  simple ???



Post a followup to this message

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