Dan Sugalski wrote:
> At 10:01 PM 8/9/00 -0600, Nathan Torkington wrote:
> >Would it make sense for the parsing of a Perl program to be done as:
> > - tokenize without rewriting (e.g., use stays as it is)
> > - structure without rewriting (e.g., constant subs are unfolded)
> > - rewrite for optimizations and actual ops
> The structure I've been thinking of looks like:
I basically like this structure, but I have a few comments.
> Program Text
> |
> |
> |
> V
> +--------------+
> | Lex/parse |
> +--------------+
> |
> Syntax tree
Three notes on the Syntax tree (which I would probably call Intermediate
Representation, or IR, but the name is irrelevant :).
First, I believe that it is completely reasonable and probably useful to
consider allowing an optimization step that operates directly on the IR.
Bytecodes are often harder to optimize than the IR.
Second, I think that it is terribly important that they format of the IR be
well described in a document separate from the code. I am willing to help
maintain this document, but I think it is imperative that we don't let the
"implementation be the reference". If the code changes, the document much
change to reflect it.
Third, I am very glad that Dan has placed the execution engine very far from
the IR. Whether or not we want to have an execution engine (which I tend to
call a VM :) that works directly on the IR or one that always goes through
bytecode, or both, I think we must keep a high wall of abstraction between
the IR and the VM.
--
Bradley M. Kuhn - http://www.ebb.org/bkuhn
PGP signature