My lexical grammar (I use antlr v3.2):
lexer grammar Lex;
options
{ language=Java; }
WS: ( ' ' | '\t' | '\n' )+ { $channel=HIDDEN; } ;
FIN : '-FIN-' ;
Moins : '-' ;
// Identifiers:
Idf : ('A'..'Z')+ ;
I want to enumerate the tokens for the following example (Main.java is
in the archive):
VLEG-XLEG-FCINFZU
And the output is:
~/Soft/Antlr/LexJava: java Main test
--> [...@-1,0:3='VLEG',<7>,1:0]
--> [...@-1,4:4='-',<6>,1:4]
--> [...@-1,5:8='XLEG',<7>,1:5]
line 1:11 mismatched character 'C' expecting 'I'
--> [...@-1,12:16='INFZU',<7>,1:12]
--> [...@-1,17:36=' ',<4>,channel=99,1:17]
~/Soft/Antlr/LexJava:
The lexer is looking for the keyword -FIN- and not for minus sign
followed by an identifier (which begins with an F).
Thanks a lot for your help.
Jean-Claude Durand
LIG, équipe GETALP
385, rue de la Bibliothèque
BP 53
38041 Grenoble cedex 9
[email protected]
tél: +33 (0)4 76 51 43 81
fax: +33 (0)4 76 63 56 86
--
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.
List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
Thanks a lot for your help. Jean-Claude Durand LIG, équipe GETALP 385, rue de la Bibliothèque BP 53 38041 Grenoble cedex 9 tél: +33 (0)4 76 51 43 81 fax: +33 (0)4 76 63 56 86 |
TestLexer.tar.gz
Description: GNU Zip compressed data
