Skip to content

Commit

Permalink
Pass on NFA from wrapper, fixing LTM issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Feb 2, 2017
1 parent 833ebe2 commit 51c3ca2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
11 changes: 10 additions & 1 deletion lib/Grammar/Debugger/WrapCache.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@ role Grammar::Debugger::WrapCache {
unwrapped
}

method !cache-wrapped(Str $name, \wrapped) {
method !cache-wrapped(Str $name, Mu \orig, \wrapped) {
my role Forward {
has Mu $.NFA;
method SET-ORIG(Mu \orig --> Nil) {
my Mu $raw-meth = orig.^lookup('NFA');
$!NFA := $raw-meth(orig);
}
}
wrapped does Forward;
wrapped.SET-ORIG(orig);
%!cache{$name} := wrapped;
wrapped
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Grammar/Tracer.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ my class TracedGrammarHOW is Metamodel::GrammarHOW does Grammar::Debugger::WrapC
self!cache-unwrapped: $name, $meth;
}
else {
self!cache-wrapped: $name, -> $c, |args {
self!cache-wrapped: $name, $meth, -> $c, |args {
# Method name.
say ('| ' x $indent) ~ BOLD() ~ $name ~ RESET();

Expand Down
1 change: 0 additions & 1 deletion t/ltm.t
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ my $outcome = do {
my $*OUT = class { method say(*@x) { }; method print(*@x) { }; method flush(*@x) { } }
MyGrammar.parse('aa', :rule<test>, :actions(MyActions)).made
}
todo 'Grammar::Tracer busts LTM';
is $outcome, 'correct', 'Picked longest token';

0 comments on commit 51c3ca2

Please sign in to comment.