I have changed the AT rule a little bit and it's working now (I think):
In the AT rule the type of the token is changed dependent on the following
text ("int("), note the empty fragment INTTOKEN:
lexer grammar TestLexer;
fragment DIGIT : ('0'..'9');
fragment ALPHA : ('a'..'z'|'A'..'Z'|'_');
fragment INTTOKEN : ;
OB : '(';
AT : ('@' 'int' OB) => '@int(' { $type=INTTOKEN;}
| '@' ;
NAME : ALPHA (ALPHA | DIGIT)*;
WS: (' ' |'\t' |'\n' |'\r' )+ {skip();} ;
and the parser:
parser grammar TestParser;
options {
tokenVocab = TestLexer;
}
start: go+ EOF;
go: OB { System.err.println("OB!"); }
| INTTOKEN {System.err.println("INTTOKEN"); }
| AT {System.err.println("AT"); }
| NAME {System.err.println("NAME" + $NAME); }
;
the output for this input:
@ name @foo @integer @int( @int4
is:
AT
na...@1,2:5='name',<9>,1:2]
AT
na...@3,8:10='foo',<9>,1:8]
AT
na...@5,14:20='integer',<9>,1:14]
INTTOKEN
AT
na...@8,29:32='int4',<9>,1:29]
cheers,
Michael
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.