Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[v6] Fix :$foo parsing
  • Loading branch information
sorear committed Jan 12, 2011
1 parent dc92b63 commit 7905557
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions v6/harness
Expand Up @@ -466,6 +466,40 @@ method nibbler($/) {
make self.process_nibble($/, $<nibbles>);
}
}
sub qpvalue($ast) {
if $ast.^isa(::Op::SimpleParcel) {
join " ", map &qpvalue, @( $ast.items )
} elsif $ast.^isa(::Op::StringLiteral) {
$ast.text;
} else {
"XXX"
}
}
method colonpair($/) {
my $n;
if !$<v>.^isa(Match) {
$n = ":" ~ ($<v> ?? '' !! '!') ~ $<k>;
} else {
$n = ":" ~ $<k> ~ "<" ~ qpvalue($<v>.ast) ~ ">";
}
my $tv = $<v>.^isa(Match) ?? $<v>.ast !!
::Op::Lexical.new(name => $<v> ?? 'True' !! 'False');

if $tv ~~ Str {
if substr($<v>,1,1) eq '<' {
$tv = ::Op::CallMethod.new(name => 'at-key',
receiver => ::Op::ContextVar.new(name => '$*/'),
args => [::Op::StringLiteral.new(text => ~$<k>)]);
} else {
$tv = self.do_variable_reference($/,
{ sigil => ~$<v><sigil>,
twigil => ($<v><twigil> ?? ~$<v><twigil>[0] !! ''),
name => $<k> });
}
}

make { ext => $n, term => ::Op::SimplePair.new(key => $<k>, value => $tv) };
}
method POSTFIX($/) {
my ($st, $arg) = self.whatever_precheck('', $<arg>.ast);
if $<op><colonpair> {
Expand Down

0 comments on commit 7905557

Please sign in to comment.