[antlr-interest] [BUG] 3.0b4 no complaint on parser reference to lexical fragment

John B. Brodie jbb at acm.org
Sun Nov 12 17:44:07 PST 2006


>I didn't mean the "token C" but the "token type C". I could do the  
>following:
>
>fragment
>C	: 'c'
>	;
>B	: 'b' ('a' { $type = C;})?
>
>and it would be perfectly legal (and maybe even sensible...;))

i must be really stupid (but hopefully we can fix that ;-)

in the above rules, i see that the lexer will recognize a 'c' in the input
stream ---- but never pass that fact up to the parser! is that real?

perhaps you meant something like:

FOO : 'x' C 'y' ;
fragment C : 'c' ; // reference to C in parser is legal
B : 'b' ( 'a' { $type = C; } )? ;

and i am suggesting:

tokens { C; } // reference to C in parser is legal
FOO : 'x' X 'y' ;
fragment X : 'c' ; // reference to X in parser is illegal
B : 'b' ( 'a' { $type = C; } )? ;



More information about the antlr-interest mailing list