[antlr-interest] Re: Questions about learning ANTLR

Hensley, Richard richard.hensley at mckesson.com
Mon Oct 7 08:51:44 PDT 2002


No, I had not tried the tester. I'm examining it now to see how I could
integrate it. 

I found it very interesting. I especially liked the part that allows me
to specify which rule to test because I have a tendancy to test my
grammars from the ground up, starting with the simplest rules. Testing
the simplest rules first is how my testing currently works.


-----Original Message----- 
From: Bogdan Mitu [ mailto:bogdan_mt at yahoo.com
<mailto:bogdan_mt at yahoo.com> ] 
Sent: Sunday, October 06, 2002 8:24 AM 
To: antlr-interest at yahoogroups.com 
Subject: RE: [antlr-interest] Re: Questions about learning ANTLR 

--- "Hensley, Richard" <richard.hensley at mckesson.com> wrote: 
> I use junit by creating a number of files that have both valid and 
> invalid input. For the invalid input ones, I examine the returned 
> exception to make sure the right one happened, and that it happened in

> the right place. For the valid ones, I always have a big file that 
> contains most cases from my grammar. If the big file throws an 
> exception, I print out the antlr exception, and fail the test. I also 
> have some smaller files, after they parse I programmatically examine
> AST to make sure that it is structured the way I expect. 

Hi Richard, 

Have you tried this? 

You may find it useful. 

Best regards, 

> One thing I do for my test data files is that I use the following Java

> statement: 
>         InputStream in = 
> getClass().getClassLoader().getResourceAsStream( 
>                                "testdata/viewstest1"); 
> This allows me to place my test data in the class path, instead of
> absolute or relative file path. Just my preferece, but it works for
> By the way, this only works if the directory where testdata/ is
> is part of the classpath. 
> Here is the testing target from my ant file: 
>     <target name="test-java" depends="env,check-resources,build-java">

>         <delete> 
>                 <fileset dir="${test.output}" includes="*" /> 
>         </delete> 
>         <junit printsummary="yes"> 
>             <classpath> 
>                 <path refid="classpath" /> 
>                 <pathelement path="${testdata.classpath}" /> 
>             </classpath> 
>             <formatter type="plain" /> 
>             <batchtest todir="${test.output}"> 
>                 <fileset dir="${source.dir}"> 
>                     <include name="**/test/*Test.java" /> 
>                 </fileset> 
>             </batchtest> 
>         </junit> 
>     </target> 
> Notice that I always package my tests as a subpackage to the one being

> tested. I also name my tests according to the standard of <class being

> tested>Test.java. I also added the testdata/ to my classpath so the 
> getResourceAsStream() routines work. 
> -----Original Message----- 
> From: micheal_jor [ mailto:open.zone at virgin.net
<mailto:open.zone at virgin.net>  
> < mailto:open.zone at virgin.net <mailto:open.zone at virgin.net> > ] 
> Sent: Friday, October 04, 2002 4:14 PM 
> To: antlr-interest at yahoogroups.com 
> Subject: [antlr-interest] Re: Questions about learning ANTLR 
> Sorry to butt in Richard but I had a few questions once I read your 
> post..... 
> > In general, the tokens { } section is for literal 
> > strings that occur in the stream exactly as specified, or for 
> imagninary 
> > tokens required to construct a abstract syntax tree (AST). 
> What about keywords?. I wondered why the java.g for example didn't 
> define keywords like "class", "final" etc as tokens. 
> > When I was developing my parser, I would make one simple change at a

> > time, build the parser, execute a my junit test suite. I created an 
> ant 
> > build.xml script that made this simple. 
> How do you use junit to test a parser?. Care to share more details on 
> this please?. 
> Cheers! 
> Micheal 
> Your use of Yahoo! Groups is subject to 
> http://docs.yahoo.com/info/terms/ <http://docs.yahoo.com/info/terms/>
< http://docs.yahoo.com/info/terms/ <http://docs.yahoo.com/info/terms/>

Do you Yahoo!? 
Faith Hill - Exclusive Performances, Videos & More 
http://faith.yahoo.com <http://faith.yahoo.com>  


Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/ <http://docs.yahoo.com/info/terms/>  

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20021007/617bc2f6/attachment.html

More information about the antlr-interest mailing list