[antlr-interest] How to deal with languages with preprocessors?

Ric Klaren klaren at cs.utwente.nl
Fri Apr 5 01:06:42 PST 2002


Hi,

On Thu, Apr 04, 2002 at 10:40:45PM -0000, micheal_jor wrote:
> Any ideas please?. How to deal with the preprocessor directives in
> C/C++ and C#.
>
> Is this handled in the Lexer or in the Parser. Any [simple-ish or
> clear] examples please?

Look at /antlr/action/cpp/action.g. It has quite some ugliness
for preprocessor stuff in C++ mode. If C# has C/C++ style includes starting
with the '#' then let me give you one piece of 'good advice'(tm)

Use a different character for the tree building stuff, saves you many
kludges and ugliness in action.g, If I had the choice I'd change it in C++
mode as well. Make it percent signs or so or maybe dollar signs. 

Cheers,

Ric
--
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- klaren at cs.utwente.nl ----- +31 53 4893722  ----
-----+++++*****************************************************+++++++++-------
  "I don't have anything against Java - it's the best damn implementation
				  of UCSD Pascal ever released..." --- Larry Smith


 

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



More information about the antlr-interest mailing list