hi,

today I finished the heredoc pre-processor for PIRC/new. PIRC/new is
now a three-pass compiler for PIR:

1. the heredoc pre-processor converts all heredoc strings into normal
strings by "flattening" them. All comments (POD, line) are removed in
this phase.
2. the macro pre-processor handles all macro definitions and
expansions. THe include directive is handled here too.
3. the PIR parser then takes that output and processes that.

It's important to note at this point that everything needs more
testing, and that memory handling (free'ing) is incomplete and not
optimal.

Obviously, a three-pass compiler must be slower than a 1-pass
compiler. However, the current approach has the following advantages:

1. Simplicity. Each of the separate phases is conceptually very
simple. Heredoc scanning (even nested ones) is
rather simple, so is macro parsing, but when trying to combine them,
things get ugly very soon. Reading the current implementation is not
too difficult. (it could use some cleanups maybe)

2. Heredocs strings can now be used in macro expansions (and, but this
was already possible in pirc/new, you can use more than 1 heredoc
argument in a function call).

3. Maintainability, Adding/changing syntax features is much easier,
because several difficult things are isolated in different phases.


The idea is to 'pipe' the several phases, so that there is no need for
temporary intermediate files. THis might improve efficiency a bit.
Feedback is always welcome.
kjs

Reply via email to