Skip to content

Commit

Permalink
Perlito5 - grammar - resolve ambiguous sigil
Browse files Browse the repository at this point in the history
  • Loading branch information
fglock committed Oct 11, 2013
1 parent 94824b8 commit 83ff358
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 19 deletions.
20 changes: 15 additions & 5 deletions html/perlito5.js
Expand Up @@ -7104,11 +7104,21 @@ return (p5call(p5pkg["Perlito5::AST::Val::Buf"], "new", ['buf', p5pkg["Perlito5:
})();
};
if ( (p5str(v_c1) == '$') ) {
v_m = (p5call(v_self, "term_sigil", [v_str, v_p], 0));
if ( p5bool(v_m) ) {
(v_m || (v_m = new p5HashRef({})))._hash_.p5hset('capture', ((new p5ArrayRef(p5list_to_a('term', p5call(p5pkg["Perlito5::AST::Apply"], "new", p5list_to_a('arguments', (new p5ArrayRef(p5list_to_a((v_m || (v_m = new p5HashRef({})))._hash_.p5hget_array('capture')._array_.p5aget(1)))), 'code', ('prefix:<' + p5str(v_sigil) + '>'), 'namespace', ''), 1))))));
(function () { throw(p5context([v_m], p5want)) })();
};
(function () {
var v_m2;
v_m2 = (p5call(p5pkg["Perlito5::Grammar::Space"], "opt_ws", [v_str, (p5num(v_p) + 1)], 0));
var v_p2;
v_p2 = ((v_m2 || (v_m2 = new p5HashRef({})))._hash_.p5hget('to'));
var v_c2;
v_c2 = (p5pkg["Perlito5::Grammar::Sigil"].substr([v_str, v_p2, 1], 0));
if ( ((p5str(v_c2) != ',') && (p5str(v_c2) != ';')) ) {
v_m = (p5call(v_self, "term_sigil", [v_str, v_p], 0));
if ( p5bool(v_m) ) {
(v_m || (v_m = new p5HashRef({})))._hash_.p5hset('capture', ((new p5ArrayRef(p5list_to_a('term', p5call(p5pkg["Perlito5::AST::Apply"], "new", p5list_to_a('arguments', (new p5ArrayRef(p5list_to_a((v_m || (v_m = new p5HashRef({})))._hash_.p5hget_array('capture')._array_.p5aget(1)))), 'code', ('prefix:<' + p5str(v_sigil) + '>'), 'namespace', ''), 1))))));
(function () { throw(p5context([v_m], p5want)) })();
};
};
})();
};
v_m = (p5call(p5pkg["Perlito5::Grammar"], "optional_namespace_before_ident", [v_str, v_p], 0));
if ( p5bool(v_m) ) {
Expand Down
13 changes: 9 additions & 4 deletions perlito5.pl
Expand Up @@ -4890,10 +4890,15 @@ sub Perlito5::Grammar::Sigil::term_sigil {
return($caret)
}
if ($c1 eq '$') {
$m = $self->term_sigil($str, $p);
if ($m) {
$m->{'capture'} = ['term', Perlito5::AST::Apply->new('arguments' => [$m->{'capture'}->[1]], 'code' => 'prefix:<' . $sigil . '>', 'namespace' => '')];
return($m)
my $m2 = Perlito5::Grammar::Space->opt_ws($str, $p + 1);
my $p2 = $m2->{'to'};
my $c2 = substr($str, $p2, 1);
if ($c2 ne ',' && $c2 ne ';') {
$m = $self->term_sigil($str, $p);
if ($m) {
$m->{'capture'} = ['term', Perlito5::AST::Apply->new('arguments' => [$m->{'capture'}->[1]], 'code' => 'prefix:<' . $sigil . '>', 'namespace' => '')];
return($m)
}
}
}
$m = Perlito5::Grammar->optional_namespace_before_ident($str, $p);
Expand Down
26 changes: 16 additions & 10 deletions src5/lib/Perlito5/Grammar/Sigil.pm
Expand Up @@ -290,16 +290,22 @@ sub term_sigil {
}
if ( $c1 eq '$' ) {
# $$ ...
$m = $self->term_sigil( $str, $p );
if ($m) {
$m->{capture} = [ 'term',
Perlito5::AST::Apply->new(
'arguments' => [ $m->{capture}[1] ],
'code' => 'prefix:<' . $sigil . '>',
'namespace' => ''
)
];
return $m;
my $m2 = Perlito5::Grammar::Space->opt_ws($str, $p + 1);
my $p2 = $m2->{to};
my $c2 = substr($str, $p2, 1);
if ($c2 ne ',' && $c2 ne ';') {
# not $$; not $$,
$m = $self->term_sigil( $str, $p );
if ($m) {
$m->{capture} = [ 'term',
Perlito5::AST::Apply->new(
'arguments' => [ $m->{capture}[1] ],
'code' => 'prefix:<' . $sigil . '>',
'namespace' => ''
)
];
return $m;
}
}
}

Expand Down

0 comments on commit 83ff358

Please sign in to comment.