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

mzukowski at bco.com mzukowski at bco.com
Wed Dec 5 14:53:56 PST 2001


> 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.

Monty

 

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



More information about the antlr-interest mailing list