[antlr-interest] Re: Skipping grammar

Arnar Birgisson arnarb at oddi.is
Wed Oct 8 11:28:02 PDT 2003


This was meant to be a pseudo-code. Initializing member variables
depends on the semantics of the target language. You might need to
create an "initialize" method and call it excplicitly, or tell ANTLR not
to generate class constructors and define them yourself.

The stack in this example is also fictional, you would need
std::stack<int> in C++, java.util.Stack with all it's type-casts and
something completely different in C#.

Arnar

> -----Original Message-----
> From: jagad [mailto:jagad at enciety.com] 
> Sent: 8. október 2003 17:48
> To: ANTLR Milis
> Subject: RE: [antlr-interest] Re: Skipping grammar
> 
> 
> I'm just wondering,
> 
> > class MyLexer extends Lexer;
> > 
> > tokens { OPEN_PACKET; CLOSE_PACKET; OPEN_MODEL; CLOSE_MODEL;
> > OPEN_METHOD; CLOSE_METHOD; }
> > 
> > {
> > 	stack braces = new stack();
> > 	int nextBrace = OPEN_PACKET;
> > 	bool readingMethodBody = false;
> > 
> > 	int getMatchingToken(int open) {
> > 		if (open == OPEN_PACKET) return CLOSE_PACKET;
> > 		if (open == OPEN_MODEL) reutrn CLOSE_MODE;
> > 		// etc.
> > 	}
> > }
> 
> ANTLR should be generate the declaration above at class 
> declaration and
> that's not allowed to initialize the class member, right?
> 
> Cheers
> 
> jagad
> 
> 
> 
>  
> 
> Your use of Yahoo! Groups is subject to 
> http://docs.yahoo.com/info/terms/ 
> 
> 


 

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




More information about the antlr-interest mailing list