[antlr-interest] check validity of single rule
Federico Di Gregorio
fog at initd.org
Mon Dec 31 03:56:15 PST 2007
Il giorno mar, 01/01/2008 alle 00.31 +1300, Gavin Lambert ha scritto:
> At 23:55 31/12/2007, Philippe Faes wrote:
> > I am indeed checking rules buried deep in the grammar, and I want to
> > test individual generation rules.
> > I have a very large grammar, and it would be painful to create at
> > foobarTest rule for each existing rule foobar. It's great that antlr
> > does graceful recovery after errors, but there must be a way to
> > check if a string confoms to a rule, right?
>
> Well, the strings do conform to the rule. The junk afterwards are
> just presumed to be matched by some (later) rule that you haven't
> called yet.
I do my tests exactly this way and I explicitly check for EOL using the
lexer to make sure the rule consumed all the input (as it is supposed to
do). Something like:
Assert.AreEqual(YourLexerClass.EOF, lexer.Input.LA(1))
works for me. (Beware of trailing spaces!)
federico
--
Federico Di Gregorio http://people.initd.org/fog
Debian GNU/Linux Developer fog at debian.org
INIT.D Developer fog at initd.org
La felicità è una tazza di cioccolata calda. Sempre. -- Io
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Questa =?ISO-8859-1?Q?=E8?= una parte del messaggio
firmata digitalmente
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20071231/4e1d803e/attachment.bin
More information about the antlr-interest
mailing list