Skip to content

Commit

Permalink
Revert "simplify action methods"
Browse files Browse the repository at this point in the history
This reverts commit 43a90e3.

It broke everything, and testing didn't catch it because the modules installed
in ~/.perl6/lib/ where preferred. Ouch.
  • Loading branch information
moritz committed Nov 1, 2009
1 parent 43a90e3 commit 8b0cab6
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions lib/JSON/Tiny/Actions.pm
Expand Up @@ -4,19 +4,40 @@ method TOP($/, $what) {
make $/{$what}.ast;
};
method object($/) {
make %($<pairlist>.ast)
make $<pairlist>.ast ?? hash ( $<pairlist>.ast ) !! {};
}

method pairlist($/) {
make = $<pair>».ast;
if $<pair> {
my %r;
for $<pair>.map(*.ast) -> $m {
%r{$m<key>} = $m<value>;
}
make %r;
}
else {
make undef;
}
}

method pair($/) {
make ( $<string>.ast => $<value>.ast );
make {
key => $<string>.ast,
value => $<value>.ast,
};
}

method array($/) {
make $<value>».ast;
if $<value> {
my @r = ();
for $<value>>>.ast {
when Hash { @r.push: \$_ }
default { @r.push: $_ }
}
make @r
} else {
make [];
}
}

method value($/, $what) {
Expand Down

0 comments on commit 8b0cab6

Please sign in to comment.