[antlr-interest] Puzzled by leading dot
Juergen Weber
weberjn at yahoo.com
Tue Mar 15 07:58:00 PST 2005
Hi,
I want to parse lines of the form
.SE DATE = '03.02.2005';.SE TIME = '20:17'
(basically a key value format, the .SE is to be
ignored).
If I parse the input with the grammar below, I got
this error message:
Exception in thread "main" line 1:1: unexpected char:
'.'
How could I specify a keyword with a leading dot?
Thanks for your help,
Juergen
class MyParser extends Parser;
line
: item (SEMI item)*
;
item
: DOTSE IDENT "=" STRING_LITERAL
;
class MyLexer extends Lexer;
tokens {
DOTSE=".SE";
}
IDENT
: ('a'..'z'|'A'..'Z'|'_')
('a'..'z'|'A'..'Z'|'_'|'0'..'9')*
;
STRING_LITERAL
:
'\''
(~'\'')*
'\''
;
SEMI: ';'
;
__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/
More information about the antlr-interest
mailing list