[antlr-interest] Non-LL(*) with option backtrack=true
Guntis Ozols
guntiso at latnet.lv
Mon Mar 17 09:43:08 PDT 2008
> ANTLR says that the rule pathExpr is non-LL(*). The rule goes like this:
> pathExpr : ('/' relativePathExpr?) | ('//' relativePathExpr) |
> relativePathExpr;
> The problem is that the following statement is valid XQuery but
> ambiguous:
> / * foo
> Which could mean (/*) foo (as in RootNode->AllChildElements followed
> by foo) or, alternatively, (/) * foo, as in RootNode TIMES foo. The
> specification says to treat this as in the earlier case, i.e. /* foo.
Do some left factoring and maybe predicate.
I use something like this for xpath 1.0 (no option backtrack):
absoluteLocationPath
: ('/' relativeLocationPath) => '/' relativeLocationPath
| '/'
| '//' relativeLocationPath;
Maybe predicate ('/' '*') can help with xpath 2.0? Please post your solution.
Guntis
More information about the antlr-interest
mailing list