viv


The 'viv' utility is a Perl 5 based way to experiment with STD.pm, the still evolving "official" Perl 6 grammar, written in Perl 6. STD.pm can parse Perl 6 source code, check it for correct syntax and semantics, and convert it to an abstract syntax tree.

The chicken-or-egg bootstrap problem is how to use STD.pm on a computer that does not have a Perl 6 to run it. None of the current (March 2010) Perl 6 implementations (Rakudo, Pugs etc) can handle STD.pm, because amongst other things it uses Longest Token Matching (LTM), a feature of Perl 6 grammars that is particularly difficult to implement in a general purpose parser.

A utility called 'gimme5' http://svn.pugscode.org/pugs/src/perl6/gimme5 comes to the rescue. Larry wrote 'gimme5' in Perl 5 to translate a subset of Perl 6 grammars into Perl 5 language. The STD.pm 'make' command uses 'gimme5' to translate STD.pm into 'STD.pm5'. Another step then converts 'STD.pm5' to 'STD.pmc'. Larry ensures that STD.pm is written in just a translatable subset of Perl 6, so that 'gimme5' can handle it. He also causes 'viv' to emulate Longest Token Matching, by carefully arranging the sequence of tokens where they occur as alternatives in STD.pm. The result is that longer tokens occur and match before shorter ones.

Unfortunately, 'viv' is not equipped to execute the code. Other language tools such as Mildew extend 'viv' further and may be able to do that.