[fpc-devel] Pre-processing to Post-processed

Peter Vreman peter at freepascal.org
Wed Jun 22 11:14:24 CEST 2005

> I will be working on a feature or a program that outputs post-processed
> code
> when using macros.
> Just to verify that this feature hasn't already been implemented or a
> program
> hasn't already been created by someone?
> My ideas for a compiler feature or program:
>  -If the -Sm option is on, and a user specifies some define macros
>  -and if a macro dump compiler option is set,
> the compiler or program runs through the code, replaces all macros, and
> dumps
> the processed source code into files into some directory for the user. The
> source code that is dumped for him, is the post-processed code. i.e. the
> user
> will now get to see source code after his macros were dropped in place.
> Basically, a feature to create unit files with macros shown directly in
> place.
> Is there already a feature or program that does this? I don't want to
> reinvent
> the wheel.

I started something in the past, see parser.pas and search for
PREPROCWRITE. But the problem is that already too much information is lost
in the scanner.

It is easier to write an external preprocessor writer instead of extending
the compiler. The scanner in the compiler is focussed on speed for
reading. Not to keep information like comments and layouts.

More information about the fpc-devel mailing list