[antlr-interest] How can a syntactic predicate not be satisfied if the input matches it?

Gavin King gavin.king at gmail.com
Fri Dec 16 16:54:22 PST 2011


Hi folks,

I have a large grammar with a rule like this:

   z: (x)=>x | y

And I have some input that I know matches x. I know this for sure,
because when I change z to read:

   z: x

Then ANTLR parses that input successfully with no errors.

To my surprise, the input does not match z, and the errors generated
come from attempting to match y. So apparently the syntactic predicate
(x)=> failed to match the input, even though I'm quite certain that x
does match it. I even tried changing z to:

    z options { backtrack=true; } : x | y

which, unsurprisingly, failed to help.

What could possibly be the cause of this?

Thanks,
Gavin

-- 
Gavin King
gavin.king at gmail.com
http://in.relation.to/Bloggers/Gavin
http://ceylon-lang.org
http://hibernate.org
http://seamframework.org


More information about the antlr-interest mailing list