doh! thanks...

http://www.antlr.org/jira/browse/ANTLR-385

Ter
On Feb 16, 2009, at 6:47 AM, George S. Cowan wrote:

> First, I want to thank you again for ANTLR. I can't imagine going  
> back to hand-coding or using other parser generators. Unfortunately,  
> I have found another bug in the composite grammar code.
>
> I modified the final example at 
> http://www.antlr.org/wiki/display/ANTLR3/Composite+Grammars 
>  slightly to add an additional level of grammar import. The  
> generated CParser.java does not initialize the delegate for the  
> lowest level correctly.
>
> --------- Grammar and Lexer files ------------
> lexer grammar L ;
>
> LETTER : 'a'..'z' ;
> SPACE : ' ' ;
> ----------------------------------------------
> parser grammar P0 ;
>
> letter : LETTER ;
> ----------------------------------------------
> parser grammar P1 ;
> import P0 ;
>
> // letter : LETTER ;
> spaces : SPACE+ ;
> ----------------------------------------------
> parser grammar P2 ;
> import P1 ;
>
> letters : letter+ ;
> ----------------------------------------------
> grammar C ;
> import L, P2 ;
>
> stuff : ( letters spaces )+ ;
>
> LETTER: 'a'..'z' | 'A'..'Z' ;
> ------- End of Grammar and Lexer files -------
>
> Here is the delegation code generated for the CParser.java. Note  
> that in the CParser constructor gP0 and gP1 are initialized in the  
> wrong order. If those last two lines are swapped, my tests work fine.
>
> --------------- CParser.java -----------------
>     // delegates
>     public C_P2_P1_P0 gP0;
>     public C_P2_P1 gP1;
>     public C_P2 gP2;
>     // delegators
>
>
>         public CParser(TokenStream input) {
>             this(input, new RecognizerSharedState());
>         }
>         public CParser(TokenStream input, RecognizerSharedState  
> state) {
>             super(input, state);
>             gP2 = new C_P2(input, state, this);
>             gP0 = gP1.gP0;
>             gP1 = gP2.gP1;
>         }
> ------- End extract from CParser.java --------
>
> Regards,
> George
>
>
>
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: 
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to