This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
v6; | |
grammar BUU { | |
token TOP { <abc>+ }; | |
token abc { ('a') <bc>* }; | |
token bc { [ ('b') <c>* ]+ } | |
token c { 'c' }; | |
}; | |
class BuuAbc { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my %h = 1 => [ [<what what>], [<how how>] ], 2 => [ [<this this>] ]; | |
my $i = 0; | |
%h.values».map({"{++$i} " Z~ @($^a)}).say; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# generate code that runs the block only once | |
make QAST::Stmts.new( | |
QAST::Op.new( | |
:op('if'), | |
QAST::Op.new( :op('p6stateinit') ), | |
QAST::Op.new( | |
:op('p6store'), | |
QAST::Var.new( :name($sym), :scope('lexical') ), | |
QAST::Op.new( :op('call'), $<blorst>.ast ) | |
), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# References ISO/IEC 9899:1990 "Information technology - Programming Language C" (C89 for short) | |
grammar C::StdC89Lexer; | |
#rule TOP { | |
# ^ <c-token>+ $ | |
#} | |
# SS 6.4 | |
proto token c-token {*} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v6; | |
sub largest-prime-factor($n is copy) { | |
for 2, 3, *+2 ... * { | |
while $n %% $_ { | |
$n div= $_; | |
return $_ if $_ > $n; | |
} | |
}; | |
1 |