help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shift reduce errors due to embedded actions


From: Axel Kittenberger
Subject: Re: Shift reduce errors due to embedded actions
Date: Wed, 10 Oct 2001 20:20:06 +0200

> LR(n) grammars can be rewritten as LR(1) grammars, but I do not know how
> that works when out when having to take actios into account.

Oh, this is possible?

I had the problem with normal class declarations:
cork[5] = 3;

Set the 5th element of the array cork to 3.

against having the decleration:
cork[5] a;

which means create an array of the -type- cork which is 5 elements in size.

I thought this could not be expressen in LR(1), as when I'm having (variable 
| type) '[', the bracket is the one look ahead, I don't yet know if the token 
'cork' should be should be evaluated as type or as variable, while a LR(n) 
parser could theoretically do this.

Well I solved that problem as I simply don't allow variables and types to 
share a name, (which theoretically would be possible by the grammar), and 
transform the types directly to another token type in the parser..

I'll try to write the reduced grammar as it was befor the types in lexer 
changes.

--
statement:
     IDENT arrray '=' expr;   { this is an set }
  |
     type array IDENT; {  this is a local variable decleration; }
;

array:
     /* nothing */
  |
     array '[' expr ']'   { ....}
;

type :
  IDENT  { ... }
 |
   INT32 { .... }
 |
   UINT32 {....}
  | 
  ....
;

exprt :  
  ....... 
;
----

I did not manage to fit that grammar into an LR(1) parser. :(

- Axel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]