[antlr-interest] Re: include files

rradh rradh at yahoo.com
Tue Aug 13 10:43:24 PDT 2002


Hi,

I can't quite get what you mean. You can whatever behavior you want 
in the lexer based on the token:

example/cpp/includeFile:
-----------------------
INCLUDE
        :       "#include" (WS_)? f:STRING
                { .... }

In a similar fashion, in your lexer try the following
PRAGMA_PACK_1:  
                "#pragma" (WS_)? "pack" (WS_)? "(" 
                (WS_)? INTEGER (WS_)? ")"
                { ... }

and so on for all your pre-processor commands.
You also have to keep in mind the error handling/reporting in the 
lexer for providing pre-processing directives in your language.
 
Hope this helped!

Regards
Rajesh

                
--- In antlr-interest at y..., QinPeng <qinpeng at h...> wrote:
> 
> But if using the method in the example, I can't distinguish 
the "#include" and other predefinede directive such as
> "#pragma pack(1)", "#if", etc.
> thanks!
> 
> ----- Original Message ----- 
> From: rradh <rradh at y...>
> To: <antlr-interest at y...>
> Sent: Monday, March 04, 2002 3:04 AM
> Subject: [antlr-interest] Re: include files
> 
> 
> > --- In antlr-interest at y..., "marc_schellens" <m_schellens at h...> 
wrote:
> > > What is the best way to realize include files
> > > in ANTLR?
> > > thanks,
> > > marc
> > 
> > a good place to start would be:
> > 
> > antlr-2.7.1/examples/cpp(or java)/includeFile/
> > 
> > regards
> > rajesh
> > 
> > 
> >  
> > 
> > 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