[antlr-interest] Re: Antlr grammar to parse Java classfile?

Terence Parr parrt at jguru.com
Thu Dec 6 12:38:47 PST 2001

On Thursday, December 6, 2001, at 01:09  AM, Andreas Rueckert wrote:
>> Let's see.  Well, it's close, but it wouldn't give you an error if you
>> have less than blockCount.  You need that "did I get enough" check at
>> the end of the loop.  Could do with a simple "validating" sem pred 
>> after
>> loop.
> So I should add a { if{counter>0) {throw new 
> RecognitionException(...);} }, or
> so? Since I'm only reading bytes, the only case, where we 'didn't get 
> enough',
> is simply EOF.

{counter!=4}? ought to do it :)  As a validating predicate, it will 
throw an exception if it fails...you could use the {...} action though.

Chief Scientist & Co-founder, http://www.jguru.com
Creator, ANTLR Parser Generator: http://www.antlr.org


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

More information about the antlr-interest mailing list