- Timestamp:
- 11/07/08 05:20:25 (2 months ago)
- Location:
- src/perl6
- Files:
-
- 2 modified
-
Cursor.pmc (modified) (7 diffs)
-
gimme5 (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/perl6/Cursor.pmc
r22901 r22909 292 292 for my $method (sort $class->meta->get_method_list) { 293 293 if (substr($method,0,$protolen) eq $protopat) { 294 my $callname = $class . '::' . $method; 294 next if substr($method,-6,6) eq '__PEEK'; 295 my $callname = $class . '::' . $method . '__PEEK'; 295 296 my $peeklex = $peek->$callname(); 296 297 if ($peeklex and $peeklex->{PATS}) { … … 918 919 }; 919 920 921 sub ${mangle}__PEEK { \$_[0]->_AUTOLEXpeek('$mangle',\$retree) } 920 922 sub $mangle { 921 923 my \$self = shift; 922 924 local \$CTX = \$self->callm() if \$::DEBUG & DEBUG::trace_call; 923 if (\$self->{_peek}) {924 return \$self->_AUTOLEXpeek('$mangle',\$retree)925 }926 925 my %args = \@_; 927 926 my \$sym = \$args{sym} // q$sym; … … 1285 1284 } 1286 1285 1286 sub ws__PEEK { ''; } 1287 1287 sub ws { 1288 1288 my $self = shift; 1289 1289 1290 if ($self->{_peek}) {1291 return;1292 }1293 1290 local $CTX = $self->callm() if $DEBUG & DEBUG::trace_call; 1294 1291 my @stub = return $self if exists $::MEMOS[$self->{_pos}]{ws}; … … 1356 1353 local $CTX = $self->callm($names ? "@$names" : "") if $DEBUG & DEBUG::trace_call; 1357 1354 lazymap(sub { $self->cursor_bind($names, $_[0])->retm() }, 1358 $block->($self ));1355 $block->($self->cursor_fresh())); 1359 1356 } 1360 1357 … … 1364 1361 1365 1362 local $CTX = $self->callm($names ? "@$names" : "") if $DEBUG & DEBUG::trace_call; 1366 my ($var) = $block->($self ) or return ();1363 my ($var) = $block->($self->cursor_fresh()) or return (); 1367 1364 $self->cursor_bind($names, $var)->retm(); 1368 1365 } … … 2108 2105 { 2109 2106 local $PREFIX = ""; 2107 $name .= '__PEEK'; 2110 2108 $lexer = eval { $C->cursor_peek->$name() }; 2111 2109 } … … 2147 2145 } 2148 2146 else { 2147 $name .= '__PEEK'; 2149 2148 my $lexer = $C->cursor_peek->$name($re); 2150 2149 my @pat = @{$lexer->{PATS}}; -
src/perl6/gimme5
r22891 r22909 90 90 $f =~ s!^(".*?")!! and $t .= $1, next; 91 91 $f =~ s!^ self\.WHAT!! and $t .= ' (ref($self)||$self)', next; 92 $f =~ s!^ self\.pos!! and $t .= '$self->{_pos}', next;93 $f =~ s!^\$¢\.pos !! and $t .= '$C->{_pos}', next;92 $f =~ s!^ self\.pos\b!! and $t .= ' $self->{_pos}', next; 93 $f =~ s!^\$¢\.pos\b!! and $t .= '$C->{_pos}', next; 94 94 $f =~ s!^//!! and $t .= "//", next; # default operator 95 95 $f =~ s!^m:p5(\W)(.+?)\1/!! and $t .= "m$1$2$1", next; … … 138 138 $f =~ s/^\.pos\b// and $t .= qq/->{_pos}/, next; 139 139 $f =~ s/^self\.orig\b// and $t .= qq/\$::ORIG/, next; 140 $f =~ s!^\.pos\b!! and $t .= '->{_pos}', next; 141 $f =~ s/^(\$\w+)\.pos// and $t .= $1 . '->{_pos}', next; 140 142 $f =~ s/^(\$\w+)\.// and $t .= qq/$1->/, next; 141 143 $f =~ s/^(\$\w+)\(/(/ and $t .= qq/$1->/, next; … … 169 171 $f =~ s/^\bTrue\b// and $t .= qq/1/, next; 170 172 $f =~ s/^\bFalse\b// and $t .= qq/0/, next; 171 $f =~ s/^([^\$])self\.// and $t .= qq/$1\$self->/, next; 172 $f =~ s/^([^\$])self\b// and $t .= qq/$1\$self/, next; 173 $f =~ s/^\$?self\.pos\b// and $t .= qq/\$self->{_pos}/, next; 174 $f =~ s/^\$?self\.// and $t .= qq/\$self->/, next; 175 $f =~ s/^\$?self\b// and $t .= qq/\$self/, next; 173 176 $f =~ s/^\.panic// and $t .= qq/->panic/, next; 174 177 $f =~ s/^(\s)\+&(\s)/$2/ and $t .= qq/$1&/, next; … … 317 320 $protosig{$name} = $5; 318 321 $out .= <<"END"; 322 sub ${name}__PEEK { \$_[0]->_AUTOLEXpeek('$name:*',\$retree); } 319 323 sub $name { 320 324 my \$self = shift; … … 322 326 323 327 local \$CTX = \$self->callm() if \$::DEBUG & DEBUG::trace_call; 324 if (\$self->{_peek}) {325 return \$self->_AUTOLEXpeek('$name:*',\$retree);326 }327 328 328 329 my \$C = \$self; … … 586 587 $re->remember_alts(); 587 588 588 $out .= <<"END"; 589 my $body = <<"END"; 590 sub$ws${NAME}__PEEK { <<PEEK>> } 589 591 sub$ws$NAME { 590 592 my \$self = shift; 591 593 END 592 594 if ($NEEDORIGARGS) { 593 $ out.= " my \@origargs = \@_;\n";594 } 595 my $body= <<'END';595 $body .= " my \@origargs = \@_;\n"; 596 } 597 $body .= <<'END'; 596 598 local $CTX = $self->callm() if $::DEBUG & DEBUG::trace_call; 597 if ($self->{_peek}) {598 return <<PEEK>>599 }600 599 <<DECL>> 601 600 … … 646 645 } 647 646 else { 648 $body =~ s/<<PEEK>>/\$ self->_AUTOLEXpeek('<<NAME>>',\$retree)/;647 $body =~ s/<<PEEK>>/\$_[0]->_AUTOLEXpeek('<<NAME>>',\$retree)/; 649 648 } 650 649 $body =~ s/<<PKG>>/$PKG/g; … … 1557 1556 $re = "\$C->_SUBSUME$ratchet([" . 1558 1557 join(',', map {"'$_'"} @BINDINGS) . 1559 "], sub {\n" . ::indent("my \$C = shift ()->cursor_fresh;\n" . $re) . "\n})";1558 "], sub {\n" . ::indent("my \$C = shift;\n" . $re) . "\n})"; 1560 1559 @BINDINGS = (); 1561 1560 $re; … … 1929 1928 sub walk { 1930 1929 my $self = shift; 1930 local $NEEDMATCH = 0; 1931 1931 my $rest = ::un6($$self{rest}) // ''; 1932 1932 my $name = $$self{name};
