[antlr-interest] Problem with a Tree Grammar: MismatchedTokenException
wirving at beats.hu
wirving at beats.hu
Fri May 8 02:48:23 PDT 2009
Helo,
I'm trying to create a Tree Grammar to walk my ASTs, and I encountered a
problem:
I have these tree grammar rules (which are relevant, I guess):
query_specification
: ^(selectClause (^(INTO intoClause))? (^(FROM fromClause))? (^(WHERE
whereClause))? (^(GROUP groupbyClause))? (^(HAVING havingClause))?)
;
selectClause
:
^(SELECT ALL? DISTINCT? (^(TOP INT (PERCENT)? (WITH TIES)?))?
^(SELECTLIST selectList))
;
selectList
: selectItem+
| selectAssignment+
;
And for an AST like:
(SELECT (SELECTLIST (CONSTANT 1) (CONSTANT 2)) (FROM myTab)))
I got MismatchedTokenException for the FROM clause. But if I put (^(FROM
fromClause))? into the selectClause rule:
selectClause
:
^(SELECT ALL? DISTINCT? (^(TOP INT (PERCENT)? (WITH TIES)?))?
^(SELECTLIST selectList) (^(FROM fromClause))?)
;
It can walk the tree. Why?
Thanks,
Zoli
More information about the antlr-interest
mailing list