On Tue, Jul 10, 2007 at 04:37:13PM -0700, Dave Whipp wrote:
: One approach would simply be to edit Perl-6.0.0-STD.pm and add some 
: markup. To pick a token at random:
: =p6explain *
: An asterix in a version expression matches any version
: =end
: token whatever { '*' {*} }

Indeed, the example you picked indicates how important context
will be.  There are many different uses of '*', and a p6explain that
simply lists all the possible meanings will be very nearly useless.
You really need to parse the surrounding text to have any idea what
the * means.  And a big reason to make the grammar available (including
all the user-defined bits) is so that nobody ever has to reinvent PPI
for Perl 6.  A p6 explainer that is sensitive to grammar mutations
really needs to do its work by annotating an entire compilation unit
and then making that information available to something resembling
an IDE.  I realize that's a long term goal.  A short term explainer
for standard p6 should at least expect to be fed a complete parsable
expression starting with a noun phrase, since starting with an infix
when the parser is expecting a term will just be completely befuddling
to the user.  Similar considerations end up driving you to parse larger
and larger pieces till you parse the whole file.  (In theory that should
always be enough context, assuming everything you use is available on
your machine, because Perl 6 outlaws magical action at a distance,
particularly across file boundaries.)


Reply via email to