Skip to content

Instantly share code, notes, and snippets.

@ekiru
Created May 30, 2010 06:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ekiru/418828 to your computer and use it in GitHub Desktop.
Save ekiru/418828 to your computer and use it in GitHub Desktop.
role FoldArithmetic::Actions does PAST::Optimization::Actions {
method foldAdd($/) {
my ($left, $right) := $<PAST::Val>;
my $result := PAST::Val.new(:value(pir::add($left.value(), $right.value())));
make $result;
}
}
grammar FoldArithmetic::Optimization does PAST::Optimization {
rule foldAdd {
<PAST::Op(<PAST::Val>, <PAST::Val>)>
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment