Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Restore special treatment for negated character classes; add NIECZA_L…
…TM_PROF for less-verbose tracing
  • Loading branch information
sorear committed Dec 21, 2011
1 parent b353fb6 commit 6533fc0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/Cursor.cs
Expand Up @@ -1836,6 +1836,8 @@ public class Lexer {

public static readonly bool LtmTrace =
Environment.GetEnvironmentVariable("NIECZA_LTM_TRACE") != null;
public static readonly bool LtmProf =
Environment.GetEnvironmentVariable("NIECZA_LTM_PROF") != null;

public static Lexer GetLexer(Frame fromf, STable kl, LAD[] lads, string title) {
LexerCache lc = kl.GetLexerCache();
Expand Down Expand Up @@ -1981,6 +1983,7 @@ public class Lexer {

public int[] Run(string from, int pos) {
LexerState state = start;
int spos = pos;
// clear out any old fates
for (int i = fatebuffer[0]; i != 0; ) {
int j = fatebuffer[2*i];
Expand Down Expand Up @@ -2016,11 +2019,14 @@ public class Lexer {

int[] uniqfates = new int[usedfates];

if (LtmProf)
Console.WriteLine("Ran {0} from {1} to length {2}", tag, spos,
pos - spos);
int cursor = 0;
for (int i = 0; i < usedfates; i++) {
cursor = fatebuffer[cursor * 2];
uniqfates[i] = cursor - 1;
if (LtmTrace)
if (LtmTrace || LtmProf)
Console.WriteLine("+ Useful fate: {0}", cursor - 1);
}
return uniqfates;
Expand Down
3 changes: 3 additions & 0 deletions src/NieczaActions.pm6
Expand Up @@ -811,6 +811,9 @@ method or_cc($lhs, $rhs) {

method cc_to_rxop($z) {
say "do_cc $z[1].typename()" if $CCTrace;
if $z[0] && $z[1] ~~ ::RxOp::CClassElem {
return ::RxOp::CClassElem.new(cc => $z[1].cc.negate);
}
return $z[0] ?? ::RxOp::Sequence.new(zyg => [
::RxOp::NotBefore.new(zyg => [$z[1]]), ::RxOp::Any.new]) !! $z[1];
}
Expand Down

0 comments on commit 6533fc0

Please sign in to comment.