On Thu, Apr 21, 2005 at 12:50:56AM +0800, Autrijus Tang wrote:
: I see.  Do you think preserving the /span/ (i.e. the character offset ranges)
: of each AST element is enough to do that?  That effectively means each
: node points to a substring inside the original source string.

Yes, though making a copy isn't bad if it's not the default behavior.
It mostly just needs a "spot".

: That way, p6-to-p6 translators in the future can, at worst, trigger a
: reparse under the appropriate subrules level, and obtain the information
: we optimized away.

Except that you've probably thrown away the definition of "appropriate"
by then as well.  :-)

p5-to-p5 actually intercepts the op_free() calls and has a place
for all the optimized trees.  But that's not the default behavior.
By default it only costs one empty "madprops" pointer per op node.
(MAD stands for miscellaneous attribute decorations.)  Only if we
set the "madskills" option do we generate a linked list of madprops.
Then you don't have to worry about the overhead in the general case,
and you also don't have to worry about your two parses getting out
of sync in the specific case.  You just have to know in advance when
you want to remember the details, which I think is not too much of
a constraint.

If you don't want to worry about this in the Haskell version of the
compiler, that's okay, as long as we think about it more when we
bootstrap the Perl 6 version.  Certainly if you're remembering
parens in some optional data structure, you can't depend on it
for ordinary disambiguation.

Larry

Reply via email to