Am 13.11.2010 um 01:14 schrieb Etienne M. Gagnon:
> 
> 
> The set of languages that can be described by LR(1) grammars is 
> effectively identical to the set of languages that can be described by 
> LR(2) grammars. If I remember correctly, there exists an algorithm to 
> transform an LR(K) grammar (where K>1) to an LR(1) grammar, but it could 
> grow your grammar exponentially. In practical terms, the equivalent 
> LR(1) grammar is unlikely to be attractive to work with. :(

In this case it's ok:

===================================================
Productions                                                                     
          
                                                                                
          
start = stmt+;                                                                  
          
                                                                                
          
stmt =                                                                          
          
  {assign} [lhs]:identifier assign [rhs]:identifier semi                        
          
| {case}   case_stmt semi                                                       
          
;                                                                               
          
                                                                                
          
case_stmt =                                                                     
        
  {case}                                                                        
          
  case [pivot]:identifier                                                       
          
   identifier colon                                                             
          
   case_elem*                                                                   
          
   stmt+                                                                        
          
  endcase                                                                       
          
;                                                                               
          
                                                                                
          
case_elem =  stmt+ identifier colon;      
===================================================

Unfortunately this results in an ugly AST. Do you have any idea to get this 
right?

Best wishes,
Sebastian


_______________________________________________
SableCC-Discussion mailing list
[email protected]
http://lists.sablecc.org/listinfo/sablecc-discussion

Reply via email to