[antlr-interest] (unknown)

mzukowski at yci.com mzukowski at yci.com
Thu May 15 08:17:13 PDT 2003


Yes, a token stream should work.  You can see my filtering example for some
ideas.  http://www.codetransform.com/filterexample.html.  This problem will
be a great deal harder if you have to preserve all the source code.  In
other words if you have to keep both the #ifdef and #else parts in the same
tree then you've made things pretty interesting.

Monty
ANTLR consultant
www.codetransform.com

-----Original Message-----
From: franck_antibes_fr [mailto:caronfranck at yahoo.fr]
Sent: Thursday, May 15, 2003 7:59 AM
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] (unknown)


Hi,




I am writing a verilog parser based on the grammar found on antlr.org.


but I have to handle in my parser `define macros and `ifdef `else 
`endif compiler directive. ( I do not want to preprocess the file).




for the people that know nothing about verilog, the problem is the 
same as #define and #ifdef #else #endif preprocessor directive in 
C/C++ so I will transpose the problem in C++ instead of verilog.






a litle example








#ifdef CAN_DERIVE


#include "base.h"




class toto : public base {


public: 


   toto(int a):base(a){}


#else 


class toto {


protected:


   int a_;


public: 


   toto(int a):a_(a){}


#endif


   virtual get_a() {return a_;}


};






because #ifdef ... can be everywhere in the code, it is not feasable 


to put everywhere in the grammar rules to handle this. I thought to 
use a king of tokenstream filter or multiplexer with several parsers.




Do any one have an idea to solve this ?




thanks 




Franck









 

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