Categories

Posts in this category

Tue, 28 Oct 2008

A Syntax Highlighter for Perl 6


Permanent link

Ahmed Zawawi implemented my idea from June 2008 and wrote a STD.pm based syntax highlighter for Perl 6.

It doesn't work very well for comments and POD (because they are parsed as whitespaces by STD.pm and thus don't appear in the parse tree at all), but apart from that it works very nicely (example here).

(The current heuristic for comments is that most of them happen at the statement_list level, so that is coloured blue, and everything else has different colours).

And it's more than a syntax highlighter: If you have javascript enabled, you can click on the "Show syntax tree" button. Then when you move the mouse over the text you'll see the length of current token and the path through the parse tree that led to it. That already helped to identify at least two mis-parses in STD.pm.

There's also a directory of syntax-highlighted test files where you can see some more output of the syntax highlighter.

[/perl-6] Permanent link