Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
68 lines (49 sloc) 2.71 KB
One of the really cool things about Perl 6 is that it contains the means
of parsing its own source code into an abstract syntax tree, which can
then be inspected and modified in various ways from inside the language
runtime.
That dream still hasn't come true, though. GGE is being built with the
explicit purpose of showing what can be done when Perl 6 can read and
modify Perl 6 on the syntax tree level. Like proto, GGE's more of a
proof-of-concept than a long-term solution. Specifically, the feature
provided by GGE (matching on text and returning a reliable AST)
should be provided by any sufficiently advanced Perl 6 implementation,
since "grammatical introspection" is one of the big selling-points of
Perl 6. Until that day, though, GGE helps us probe ahead.
The purpose of this file is to share a bit of the enthusiasm, by listing
the set of possible applications that become possible with a fully
functioning GGE.
In order of increasing ambitiousness:
= A CLI grammar debugger
Basically, a clone of the debugging feature in Damian Conway's
Regexp::Grammars. This is possible because GGE can easily be made to contain
hooks in the right places for debug output.
= A Web.pm grammar debugger
An interactive web form where people modify their grammar and get feedback
on a given input in real time, seeing what happens when the grammar tries
to match the input text. Specifically, the user will see where the match
*fails*, which is something that is missing from the current set of tools.
The applications below also require that we have a fully operational Perl
6 parser atop GGE.
= A Perl 6 macro preprocessor
A simple filter which parses macros and applies them to the source code,
generating a new source code with the macros applied -- and which even a
Rakudo not implementing macros can run. A sort of a 'have the cake and
eat it' scenario.
= A static code analyzer
This is one of my favorites. I have a list of things I'd like to check
statically in Perl 6 code, such as mis-use of some features, possible
(or certain!) value errors, unreachable code etc. Sort of a Perl::Critic
for Perl 6.
= A runtime
Running Perl 6 on top of Perl 6? The thought is too attainable to resist.
= A coverage tool
As long as we have a runtime, we might as well construct it so that it
keeps track of coverage information.
= A time-travelling debugger
As long as we have a runtime, we might as well construct it so that it
can be rewinded and fast-forwarded at will. This is a goal only reached
a few times in computer history. Wondering why that variable got the
value it did? No need to re-run the program; just rewind it to its last
assignment. Changed a value at some past point in the running history? No
prob; we'll just re-run things from that point onwards.