[antlr-interest] Re: Antlr grammar to parse Java classfile?
Andreas Rueckert
a_rueckert at gmx.net
Thu Dec 6 05:05:50 PST 2001
Hi!
On Mit, 05 Dez 2001 Terence Parr wrote:
--<snip>--
> 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.
Thanks a lot for your help. I'd also like to thank Monty for his posting of the
sources. When I saw them, I realized that the counter decrement could
(hopefully) also be done in the predicate itself. When I add your validating
predicate, my current rule to read the constant pool of a classfile looks like:
=======================================
// The constant pool.
constant_pool
{ int poolSize=0; }
: poolSize=constant_pool_count // Parse the size of the constant pool + 1
( {--poolSize > 0}? cp_info )* {poolSize==0}? // Parse (poolSize-1) cp_info structures.
;
=======================================
It should hopefully read counter/poolSize-1(!) cp_info structures, if the pred
decrement works as I expect. And I think it really doesn't look like a nasty
hack, or so.
Thanks to all those, who commented and helped me.
BTW: You asked for my target language, but I was in a hurry and overlooked your
question at that time (sorry!). I'm working on a ArgoUML module and Argo is
written in Java, so I'm interested in a Java parser for classfiles.
Ciao,
Andreas
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list