[antlr-interest] Re: Antlr grammar to parse Java classfile?
Ric Klaren
klaren at cs.utwente.nl
Thu Dec 6 01:46:31 PST 2001
Hi,
On Wed, Dec 05, 2001 at 02:53:56PM -0800, mzukowski at bco.com wrote:
> > rule
> > {int counter=0}
> > : counter=blockCount
> > ( {counter>0}? blockEntry {counter--;} )*
> > ;
> > =======================================
> > Do you think it would work? So that block entry is matched
> > <counter> times?
>
> That generates this code:
>
> int counter=0
>
> try { // for error handling
> counter=blockCount();
> {
> _loop3:
> do {
> if (((LA(1)==LITERAL_A))&&(counter>0)) {
> blockEntry();
> counter--;
> }
> else {
> break _loop3;
> }
>
> } while (true);
> }
> }
> ...
>
> Looks like it will work to me.
Not 100% sure so of the top of my head... but if the rule is invoked
somewhere in the path of a syntactic predicate will it work as well? E.g.
if guessing > 0 ?
I have some vague recollection of these things biting in some cases.
Ric
--
-----+++++*****************************************************+++++++++-------
---- Ric Klaren ----- klaren at cs.utwente.nl ----- +31 53 4893722 ----
-----+++++*****************************************************+++++++++-------
Wit is cultured insolence. --- Aristotle
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list