[antlr-interest] newbie faces unexpected tokens
Scott Amort
jsamort at gmail.com
Tue Jul 11 12:45:16 PDT 2006
Hi Mo,
Mo wrote:
> Hi all,
> i'm an antlr newbie and realise it has probably been posted before,
> but i cant find much
>
> i'm trying to read strings in the form of: foo.bar.foo and parse
> them into a tree structure for later and have the following simple
> grammar definitions
>
The following successfully parsed (ignoring whitespace):
on foo{foo.bar.foo;}
Lexer:
IDENT
options {
testLiterals = true;
}
: ('a'..'z'|'A'..'Z') ('a'..'z'|'A'..'Z'|'0'..'9')*
;
DOT
: '.'
;
LBRACE
: '{'
;
RBRACE
: '}'
;
SEMI
: ';'
;
Parser:
event
: "on"^ IDENT LBRACE! symbol SEMI! RBRACE!
;
symbol
: IDENT (DOT^ IDENT)*
;
Perhaps if you post your full grammar file it may be easier to see what
is happening.
Best,
Scott
More information about the antlr-interest
mailing list