[antlr-interest] Re: (unknown)

mzukowski at yci.com mzukowski at yci.com
Thu May 15 10:08:46 PDT 2003


What kind of tool are you writing?

Monty

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


my goal is to keep both the #ifdef and #else parts in the same tree 
(not an AST but a Data Object Model). an other hard stuff is dealing 
with macro without expanding them. 




I will have a look to your example. 


thanks 




Franck 




--- In antlr-interest at yahoogroups.com, mzukowski at y... wrote:


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


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


 

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




More information about the antlr-interest mailing list