CBFalconer wrote:
Frank Heckenbach wrote:
GPC currently uses a stand-alone preprocessor (gpcpp) that is derived from the C preprocessor and shares many of its features.
I plan to integrate it into the compiler which would follow gcc's example (not so important, though), maybe make it a little faster (not very much, I guess, since preprocessing in general doesn't take very long), solve some problems (e.g., the `--needed-option' ugliness, mostly on MIPS) and allow for further improvements.
... snip ...
Since preprocessing has nothing to do with Pascal per se, I would recommend keeping any such firmly separated. I am not familiar with the operation of m4, but between that and what you already evidently have, I suspect any complex games could be performed.
I've used m4 sometimes. My main problem with it is that its philosophy seems to be, do everything that I don't explicitly tell you not to do; i.e. I often ended up quoting things, often multiple times, to *prevent* some unwanted expansions (and I wasn't always sure how many levels of quoting I needed in some situations until I experimented ;-).
Also, it's purely text based (not token oriented), so the following example:
define(Count, `for i := 1 to $1 do $2 end') begin Count(10, WriteLn (i))end;
would yield:
begin for i := 1 to 10 do WriteLn (i) endend; ^space missing
That's a somewhat silly example, of course, but it shows that m4 doesn't really fit the Pascal (or C) lexing.
You can always go further by integrating things with the symbol table, etc., but is it worth it? The resultant input language is neither fish nor fowl.
I don't think so. It should still be possible to see the preprocessed source (with `-E'), and of course, no-one is forced to use the preprocessor.
My own view is that there are already too many exceptions and extensions in gpc, and once something is added it is hard to remove, because there is always a group that uses everything.
That's already the case with the current preprocessor. Actually, I'm trying to make it simpler, not more complex.
Frank