[antlr-interest] Re: Preprocessors - academic question

John Allen Green greenj at ix.netcom.com
Thu Jun 27 01:43:22 PDT 2002



--On 26/06/2002 6:22 PM +0000 jsrs701 wrote:

> --- In antlr-interest at y..., John Allen Green <greenj at i...> wrote:
>> 
>> Here's one for you educated folks...
>> 
>> Given a preprocessor which allows branching and unrestricted code
>> substitutions, is it impossible to work with the semantics of the
>> preprocessing itself?
>> 
>> It would seem to me that since you could have code substitution 
> doing code
>> substitution, it would be impossible to build a parse tree of the
>> preprocessing.
> 
> Okay, but you could build a tree of the *operations* to be performed, 
> right?  And then apply the operations to the original source file?
> 
> Or am I completely not understanding the question?
> 
> JSRS

I'm not even worried about applying the operations to the original source -
the preprocessing itself is easy (it's already built). It's the graphing of
the preprocessing operations that I was wondering about, so your first
question is the right one. I don't want to use the graph in order to apply
the preprocessing, I only want to use the graph in order to analyze the
preprocessing.

Monty suggested a tree for each phase of the preprocessing, which may not
be practical (unless I misunderstand his idea), but it does make me wonder
if each phase of the operations in a preprocess graph could be made into
nodes on a tree.

I never grok these things without examples, so here's one. The language is
a 4GL called Progress. It's idea of #define looks like this:
  &GLOBAL-DEFINE HI Hello World
And then the following displays "Hello World":
  DISPLAY "{&HI}".
It gets ugly, because you can have a macro expand into another macro which
in turn gets expanded. Adding to the previous code:
  &GLOBAL-DEFINE ARGH {&HI}
And the "Hello World":
  DISPLAY "{&ARGH}".

Perhaps each application of code substitution could be another node on the
graph? That would be a weird looking tree. Like Monty said, it's a headache.

John


 

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



More information about the antlr-interest mailing list