[antlr-interest] Problems with syntactic predicates(?)
Christian Gudrian
gn at fluidon.dyndns.info
Sun Jan 27 02:03:49 PST 2008
Hello, Jim!
Thanks for your answer.
> Look at the example grammars for how to set up for parsing expressions
> with precedence, you don't need those predicates but you do need to
> chain your rules correctly.
My example was only a subset of the original grammar I am working on.
Since that grammar is significantly larger (and works most of the time
as expected) I would be glad if I didn't have to restructure it.
I'm particularly interested in why the parser fails to correctly parse
the given input. If I step through the debugger of ANTLRWorks I can
see that the parser not even tries to match the syntactic predicate.
Why would it do so?
What's also strange: if I allow at most one expression as the function
arguments, i.e.
function_call : IDENT '(' expression? ')' ;
everything works as expected. Why?
> You are trying to construct context/semantics in the parser, but it's
> job is to parse correct syntactical constructs only.
Is there a definite line between what's already context/semantics and
what's still syntax? Don't you define a language's syntax by
specifying the context a given symbol or token is allowed to show up?
Christian
More information about the antlr-interest
mailing list