Rainbow

Raku source code lexer

NAME

Rainbow

Raku source code lexer

Synopsis

use Rainbow;

my %mapping =
    TEXT     => '#ffffff',
    KEYWORD  => "#e04c86",
    OPERATOR => "#e04c86",
    TYPE     => "#00ffff",
    ROUTINE  => "#978deb",
    STRING   => "#68f3ca",
    # ...
;

my $code = 'my $greet = "hello"; say "Oh $greet there!";';

my @tokens = Rainbow::tokenize($code);

my @fragments = @tokens.map: -> $t {
    my $color = %mapping{$t.type.key} // %mapping<TEXT>;
    say "$color: {$t.text}";
}

Description

This module can turn a piece of Raku code into a list of tokens. Assign each token a color and you have made yourself a Raku syntax highlighter.

See lib/Rainbow/Token.rakumod for the complete list of tokens.

AUTHOR

Patrick Böker [email protected]

THANKS

Thanks to Siavash Askari Nasr (CIAvash) for the Chroma Raku lexer which this module took as inspiration.

License

This module is distributed under the terms of the Artistic License 2.0.

Rainbow v0.1.0

Raku source code lexer

Authors

  • Patrick Böker

License

Artistic-2.0

Dependencies

Test Dependencies

Provides

  • Rainbow
  • Rainbow::RakuGrammar
  • Rainbow::RakuGrammarActions
  • Rainbow::Token

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.