- Timestamp:
- 11/11/08 01:51:06 (2 months ago)
- Files:
-
- 1 modified
-
src/perl6/Cursor.pmc (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/perl6/Cursor.pmc
r22934 r22971 13 13 our $DEPTH = 0; 14 14 our %LEXERS; # per language, the cache of lexers, keyed by rule name 15 16 my %HIST; 15 17 16 18 sub ::init_globals { … … 141 143 } 142 144 $class->new($text)->$rule(); 145 # for my $key (sort {$HIST{$a} <=> $HIST{$b}} keys(%HIST)) { 146 # warn "$HIST{$key}\t$key\n"; 147 # } 143 148 } 144 149 … … 591 596 my $retree = shift; 592 597 # $_[0] is now ref to a $trystate; 598 # $HIST{$name}++; 593 599 594 600 $self->deb("cursor_fate $pkg $name") if $DEBUG & DEBUG::cursors; … … 613 619 return sub {}; 614 620 } 621 622 # A rudimentary trie walker, unused so far. It assumes a prebuilt trie; 623 # it will need some revisions to build it on the fly. Also, it's currently 624 # written for clarity rather than speed, and that will also change later. 625 # There is an arbitrary cutoff between characters we look up by array 626 # vs characters we look up by hash. ->{T}[0] is the array, [1] is the hash. 627 # and [2] contains actual results generator closure. At the moment we just 628 # drop through if we don't get a result, which is always. 629 630 if (my $state = $lexer->{T}) { 631 my $p = $P; 632 my $ch = $::ORIG[$p]; 633 my $next; 634 while ($next = $state->[0][$ch] // $state->[1]{chr $ch}) { 635 $ch = $::ORIG[++$p]; 636 $state = $next; 637 } 638 if ($state->[2]) { 639 return $state->[2]; 640 } 641 } 642 615 643 pos($::ORIG) = $P; 616 644 $::ORIG =~ m/\G(\[[\\<>«»]*..|[<>][<>]..|[$@%]?\w+|['"]|[ -~].|.)/smgc; … … 1242 1270 1243 1271 local $CTX = $self->callm if $DEBUG & DEBUG::trace_call; 1244 my @all = $block->($self );1272 my @all = $block->($self->cursor_fresh); 1245 1273 return () if @all; # XXX loses continuation 1246 1274 return $self->cursor($self->{_pos})->retm();
