[antlr-interest] Testing lexer grammars with gunit

Leon Su leon.antlr at mac.com
Mon Nov 23 23:54:22 PST 2009


Yes, the current version of gUnit only accepts a composite grammar,  
i.e. you can only test lexical rules within a composite grammar.  What  
Jim suggested is a good way for testing your lexer grammar for now.   
Assuming that you have a lexer grammar L, and another grammar P which  
imports L and has only one dummy parser rule is created.  Then you can  
test all lexical rules as below.

gUnit P;
lexical-rule-name:
"input" OK
...

By the way, the next release of gUnit will allow you to test a lexer  
grammar individually with the syntax: gUnit lexer L;

Leon

On Nov 23, 2009, at 1:48 PM, Jim Idle wrote:

> Not sure myself – it might be coded for composite grammars I  
> suppose. What you could do though is create a small grammar that  
> imports your lexer and has a dummy parse rule, then test that  
> grammar. This would be a workaround of course.
>
> Jim
>
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org 
> ] On Behalf Of Cameron Ross
> Sent: Monday, November 23, 2009 6:06 AM
> To: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] Testing lexer grammars with gunit
>
> Anyone?
>
> On Wed, Nov 18, 2009 at 4:03 PM, Cameron Ross <cross at kojeware.com>  
> wrote:
> Hi,
>
> I have a lexer grammar that I'd like to test using gunit.  However,  
> the way I have things configured, gunit assumes a composite  
> grammar.  Is there a way that I can tell gunit that the grammar  
> being tested is a lexer grammar?
>
> Thanks,
> Cameron.
>
>
>
> -- 
> Cameron Ross
> Director of Technology
> Kojeware Corporation
> 705-929-1492
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20091123/38ac2ca2/attachment.html 


More information about the antlr-interest mailing list