Permalink
Browse files

reduction method simplifications

  • Loading branch information...
1 parent 682039b commit 107a11c0b4f181c130a9ff0433e8939c730d3f53 @moritz committed Nov 2, 2009
Showing with 5 additions and 17 deletions.
  1. +5 −17 lib/JSON/Tiny/Actions.pm
@@ -4,37 +4,25 @@ method TOP($/, $what) {
make $/{$what}.ast;
};
method object($/) {
- make $<pairlist>.ast ?? hash ( $<pairlist>.ast ) !! {};
+ make %( $<pairlist>.ast );
}
method pairlist($/) {
if $<pair> {
- my %r;
- for $<pair>.map(*.ast) -> $m {
- %r{$m<key>} = $m<value>;
- }
- make %r;
+ make $<pair>».ast;
}
else {
- make undef;
+ make ();
}
}
method pair($/) {
- make {
- key => $<string>.ast,
- value => $<value>.ast,
- };
+ make ( $<string>.ast => $<value>.ast );
}
method array($/) {
if $<value> {
- my @r = ();
- for $<value>>>.ast {
- when Hash { @r.push: \$_ }
- default { @r.push: $_ }
- }
- make @r
+ make $<value>».ast;
} else {
make [];
}

0 comments on commit 107a11c

Please sign in to comment.