[antlr-interest] I'm stuck

Kevin Boyle kevintboyle at yahoo.com
Mon Aug 16 18:50:51 PDT 2010


I hope you can help.  I started with the mdx.g from the antlr website and
have build a tree grammar in order to use the string templates.  I'm also
generating the parser and lex code in c#.

These 2 statements below are equivalent in the MDX grammar but the in the
tree-grammar when output=template, I get complaints about 'compound_id'.
Its strange because it seems to generate the code sometimes after a I 'check
grammar' but sometimes it generates an error.  

However if I use 'compound_id2' then the template does not capture the
complete text (only the token before 'DOT') when I reference
$member_name.text (see line below).  However If I use the 'coupound_id' it
works but generates a runtime error in the tree-grammar saying
"mdx_parametric.g: node from after line 3:21 no viable alternative at input
'.'"

What I seem to be missing is a way to create the tree using the ^ tree
operator but still be able to use string-templates in the tree-grammar
without generating errors.

Thanks 

Kevin 

 

------------- MDX Grammar  ---------- 

 

compound_id 
        :       identifier (DOT^ identifier)*   

compound_id2 : (identifier)=>(identifier (DOT identifier)*) 
                        | 
                        ; 

 

---------------- Tree Grammar -------------- 

member_name : compound_id  -> template (id={$member_name.text})
"GOTIT_MName_1#<id>#" 
                        ; 



More information about the antlr-interest mailing list