[antlr-interest] gated semantic predicate usage

Mark Volkmann r.mark.volkmann at gmail.com
Tue Jan 22 12:21:54 PST 2008


I'm using the antlr-2008-01-14.10 version now. I no longer get the
NullPointerException which is good, but it also doesn't throw an
exception when the predicate fails. Maybe it's not supposed to. I just
get a message that says "

line 11:0 mismatched input 'list' expecting EOF
MathTree.g: node from line 0:0 mismatched tree node: <mismatched
token: [@55,354:357='list',<12>,11:0], resync=a = 3.14".

I'd like to figure out a way to detect that some input (in this case a
statement that starts with "list") wasn't processed due to the gated
semantic predicate and output a better error message. Do you know how
to detect this?

On Jan 22, 2008 10:46 AM, Jim Idle <jimi at temporal-wave.com> wrote:
> I have found that certain DFA decisions involving gated predicates do
> not generate quite the correct code, in that they work correctly when
> the gate is passed but give NVA errors when they do not. However, if you
> switch to the latest daily build (see downloads page) you will find that
> they (and som other DFA stuff) work perfectly as Ter has fixed 'em.
>
> Jim
>
>
> > -----Original Message-----
> > From: Mark Volkmann [mailto:r.mark.volkmann at gmail.com]
> > Sent: Tuesday, January 22, 2008 6:52 AM
> > To: antlr-interest Interest
> > Subject: [antlr-interest] gated semantic predicate usage
> >
> > In the book in section 13.2 there is an example of using a gated
> > semantic predicate to conditionally disable assert statements. When
> > using this pattern in a parser grammar the result seems to be an error
> > message like "mismatched input 'assert' expecting EOF" followed by a
> > stack trace for a NullPointerException from the tree parser. I tried
> > adding a catch at the end of the parser rule that contains the gated
> > semantic predicate, but no exception is thrown. I'm confused about how
> > to use this mechanism to disable certain statements and output a
> > reasonable error message when they appear in input.
> >
> > --
> > R. Mark Volkmann
> > Object Computing, Inc.
>
>
>



-- 
R. Mark Volkmann
Object Computing, Inc.


More information about the antlr-interest mailing list