Skip to content

Instantly share code, notes, and snippets.

View FROGGS's full-sized avatar

Tobias Leich FROGGS

  • Germany (near Berlin)
View GitHub Profile
v6;
grammar BUU {
token TOP { <abc>+ };
token abc { ('a') <bc>* };
token bc { [ ('b') <c>* ]+ }
token c { 'c' };
};
class BuuAbc {
my %h = 1 => [ [<what what>], [<how how>] ], 2 => [ [<this this>] ];
my $i = 0;
%h.values».map({"{++$i} " Z~ @($^a)}).say;
# 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 )
),
# 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 {*}
@FROGGS
FROGGS / p003.pl
Last active December 12, 2015 01:28 — forked from gerdr/p003.pl
use v6;
sub largest-prime-factor($n is copy) {
for 2, 3, *+2 ... * {
while $n %% $_ {
$n div= $_;
return $_ if $_ > $n;
}
};
1