[antlr-interest] Automated testing of lexer/parser rules
Bharath S
payasam79 at yahoo.com
Mon Apr 5 16:17:50 PDT 2004
Hi Grp,
Can somebody provide information on how to automate
the testing of lexer/parser rules? I usually put my
test cases in a text file and feed it to my main
program using the direction operator. I am using Antlr
in Eclipse IDE and would like to automate testing
using JUnit. Can someone shed some light on this?
Thanks!
B.
--- micheal_jor <open.zone at virgin.net> wrote:
> --- In antlr-interest at yahoogroups.com, Bharath S
> <payasam79 at y...> wrote:
> > Hi Grp,
> >
> > If I have lexer rules of this form:
> > -----------------
> > R1: A|B;
> > R2: C|D;
> >
> > A: INT 'a';
> > B: REAL 'a';
> >
> > C: INT 'c';
> > D: REAL 'd';
> > -----------------
> >
> > Here, I have to resolve nondeterminism betwee A
> and C
> > and also between B and D. I tried to have two
> separate
> > rules to handle both but it doesnt work. I can
> only
> > handle one of them at a time but not both. Any
> ideas
> > on how ANTLR handles this?
> >
> > My determinism resolving rules:
> > --------------------------------
> > R1: (INT 'c') => R2 {$setType(R2);}
> > | (INT 'a') => R1 {$setType(R1);}
> >
> > R2: (REAL 'a') => R1 {$setType(R1);}
> > | (REAL 'd') => R2 {$setType(R2);}
> >
> > ---------------------------------------------
>
> You should merge those rules into a single one like
> this:
>
> R1 : INT
> ( 'c' { $setType(R2); }
> | 'a'
> )
> | REAL
> ( 'a'
> | 'd' { $setType(R2); }
> )
> ;
>
> Cheers,
>
> Micheal
> ANTLR/C#
>
>
>
>
> Yahoo! Groups Links
>
>
> antlr-interest-unsubscribe at yahoogroups.com
>
>
>
__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list