From 7f72696207af4aab18744f65b3bf671d3465cb7b Mon Sep 17 00:00:00 2001 From: mitchell Date: Sat, 4 Jan 2020 22:08:11 -0500 Subject: Backport: Added Raku lexer and style properties and example files Backport of changeset 7900:bcb95162cd06. --- lexilla/test/examples/raku/x.p6 | 54 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 lexilla/test/examples/raku/x.p6 (limited to 'lexilla/test/examples/raku/x.p6') diff --git a/lexilla/test/examples/raku/x.p6 b/lexilla/test/examples/raku/x.p6 new file mode 100644 index 000000000..0cbdb6a57 --- /dev/null +++ b/lexilla/test/examples/raku/x.p6 @@ -0,0 +1,54 @@ +use v6; + +# Normal single line comment +my Int $i = 0; +my Rat $r = 3.142; +my Str $s = "Hello, world! \$i == $i and \$r == $r"; +say $s; + +#`{{ +*** This is a multi-line comment *** +}} + +my @array = #`[[ inline comment ]] ; +my %hash = ( AAA => 1, BBB => 2 ); + +say q[This back\slash stays]; +say q[This back\\slash stays]; # Identical output +say Q:q!Just a literal "\n" here!; + +=begin pod +POD Documentation... +=end pod + +say qq:to/END/; +A multi-line +string with interpolated vars: $i, $r +END + +sub function { + return q:to/END/; +Here is +some multi-line +string +END +} + +my $func = &function; +say $func(); + +grammar Calculator { + token TOP { } + proto rule calc-op {*} + rule calc-op:sym { '+' } + rule calc-op:sym { '-' } + token num { \d+ } +} + +class Calculations { + method TOP ($/) { make $.made; } + method calc-op:sym ($/) { make [+] $; } + method calc-op:sym ($/) { make [-] $; } +} + +say Calculator.parse('2 + 3', actions => Calculations).made; -- cgit v1.2.3