From 2f2beee271483198335d7f31fd1c5c0c8f6c1c7f Mon Sep 17 00:00:00 2001 From: mingodad Date: Sat, 12 Jun 2021 12:54:47 +0200 Subject: [PATCH] Fix SynTree.dump2 that is supposed to show a pruned tree --- src/Parser.cpp | 8 +++++--- src/Parser.frame | 10 ++++++---- src/Parser.h | 2 +- src/TestSuite/TestAlts_Parser.cpp | 8 +++++--- src/TestSuite/TestAny1_Parser.cpp | 8 +++++--- src/TestSuite/TestAny_Parser.cpp | 8 +++++--- src/TestSuite/TestCasing_Parser.cpp | 8 +++++--- src/TestSuite/TestChars_Parser.cpp | 8 +++++--- src/TestSuite/TestComments_Parser.cpp | 8 +++++--- src/TestSuite/TestDel_Parser.cpp | 8 +++++--- src/TestSuite/TestEps_Parser.cpp | 8 +++++--- src/TestSuite/TestIters_Parser.cpp | 8 +++++--- src/TestSuite/TestLL1_Parser.cpp | 8 +++++--- src/TestSuite/TestOpts1_Parser.cpp | 8 +++++--- src/TestSuite/TestOpts_Parser.cpp | 8 +++++--- src/TestSuite/TestResOK_Parser.cpp | 8 +++++--- src/TestSuite/TestSem_Parser.cpp | 8 +++++--- src/TestSuite/TestSync_Parser.cpp | 8 +++++--- src/TestSuite/TestTokens_Parser.cpp | 8 +++++--- src/TestSuite/TestWeak_Parser.cpp | 8 +++++--- 20 files changed, 97 insertions(+), 59 deletions(-) diff --git a/src/Parser.cpp b/src/Parser.cpp index 90ed8d6..e1aa88a 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -1333,18 +1333,20 @@ void SynTree::dump(int indent, bool isLast) { } } -void SynTree::dump2(int maxT, int indent, bool isLast) { +void SynTree::dump2(int indent, bool isLast) { int last_idx = children.Count; + int indentPlus = 4; if(tok->col) { printIndent(indent); wprintf(_SC("%s\t%d\t%d\t%d\t%") _SFMT _SC("\n"), ((isLast || (last_idx == 0)) ? "= " : " "), tok->line, tok->col, tok->kind, tok->val); } else { if(last_idx == 1) { - if(((SynTree*)children[0])->tok->kind < maxT) { + if(((SynTree*)children[0])->children.Count == 0) { printIndent(indent); wprintf(_SC("%d\t%d\t%d\t%") _SFMT _SC("\n"), children.Count, tok->line, tok->kind, tok->val); } + else indentPlus = 0; } else { printIndent(indent); @@ -1352,7 +1354,7 @@ void SynTree::dump2(int maxT, int indent, bool isLast) { } } if(last_idx) { - for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(maxT, indent+4, idx == last_idx); + for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(indent+indentPlus, idx == last_idx); } } diff --git a/src/Parser.frame b/src/Parser.frame index 72a5fe1..952554b 100644 --- a/src/Parser.frame +++ b/src/Parser.frame @@ -51,7 +51,7 @@ struct SynTree { TArrayList children; void dump(int indent=0, bool isLast=false); - void dump2(int maxT, int indent=0, bool isLast=false); + void dump2(int indent=0, bool isLast=false); }; #endif @@ -406,18 +406,20 @@ void SynTree::dump(int indent, bool isLast) { } } -void SynTree::dump2(int maxT, int indent, bool isLast) { +void SynTree::dump2(int indent, bool isLast) { int last_idx = children.Count; + int indentPlus = 4; if(tok->col) { printIndent(indent); wprintf(_SC("%s\t%d\t%d\t%d\t%") _SFMT _SC("\n"), ((isLast || (last_idx == 0)) ? "= " : " "), tok->line, tok->col, tok->kind, tok->val); } else { if(last_idx == 1) { - if(((SynTree*)children[0])->tok->kind < maxT) { + if(((SynTree*)children[0])->children.Count == 0) { printIndent(indent); wprintf(_SC("%d\t%d\t%d\t%") _SFMT _SC("\n"), children.Count, tok->line, tok->kind, tok->val); } + else indentPlus = 0; } else { printIndent(indent); @@ -425,7 +427,7 @@ void SynTree::dump2(int maxT, int indent, bool isLast) { } } if(last_idx) { - for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(maxT, indent+4, idx == last_idx); + for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(indent+indentPlus, idx == last_idx); } } diff --git a/src/Parser.h b/src/Parser.h index 5d3ca7c..4178ae7 100644 --- a/src/Parser.h +++ b/src/Parser.h @@ -51,7 +51,7 @@ struct SynTree { TArrayList children; void dump(int indent=0, bool isLast=false); - void dump2(int maxT, int indent=0, bool isLast=false); + void dump2(int indent=0, bool isLast=false); }; #endif diff --git a/src/TestSuite/TestAlts_Parser.cpp b/src/TestSuite/TestAlts_Parser.cpp index 0e887ae..8938a54 100644 --- a/src/TestSuite/TestAlts_Parser.cpp +++ b/src/TestSuite/TestAlts_Parser.cpp @@ -381,18 +381,20 @@ void SynTree::dump(int indent, bool isLast) { } } -void SynTree::dump2(int maxT, int indent, bool isLast) { +void SynTree::dump2(int indent, bool isLast) { int last_idx = children.Count; + int indentPlus = 4; if(tok->col) { printIndent(indent); wprintf(_SC("%s\t%d\t%d\t%d\t%") _SFMT _SC("\n"), ((isLast || (last_idx == 0)) ? "= " : " "), tok->line, tok->col, tok->kind, tok->val); } else { if(last_idx == 1) { - if(((SynTree*)children[0])->tok->kind < maxT) { + if(((SynTree*)children[0])->children.Count == 0) { printIndent(indent); wprintf(_SC("%d\t%d\t%d\t%") _SFMT _SC("\n"), children.Count, tok->line, tok->kind, tok->val); } + else indentPlus = 0; } else { printIndent(indent); @@ -400,7 +402,7 @@ void SynTree::dump2(int maxT, int indent, bool isLast) { } } if(last_idx) { - for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(maxT, indent+4, idx == last_idx); + for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(indent+indentPlus, idx == last_idx); } } diff --git a/src/TestSuite/TestAny1_Parser.cpp b/src/TestSuite/TestAny1_Parser.cpp index c907bc3..c276806 100644 --- a/src/TestSuite/TestAny1_Parser.cpp +++ b/src/TestSuite/TestAny1_Parser.cpp @@ -402,18 +402,20 @@ void SynTree::dump(int indent, bool isLast) { } } -void SynTree::dump2(int maxT, int indent, bool isLast) { +void SynTree::dump2(int indent, bool isLast) { int last_idx = children.Count; + int indentPlus = 4; if(tok->col) { printIndent(indent); wprintf(_SC("%s\t%d\t%d\t%d\t%") _SFMT _SC("\n"), ((isLast || (last_idx == 0)) ? "= " : " "), tok->line, tok->col, tok->kind, tok->val); } else { if(last_idx == 1) { - if(((SynTree*)children[0])->tok->kind < maxT) { + if(((SynTree*)children[0])->children.Count == 0) { printIndent(indent); wprintf(_SC("%d\t%d\t%d\t%") _SFMT _SC("\n"), children.Count, tok->line, tok->kind, tok->val); } + else indentPlus = 0; } else { printIndent(indent); @@ -421,7 +423,7 @@ void SynTree::dump2(int maxT, int indent, bool isLast) { } } if(last_idx) { - for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(maxT, indent+4, idx == last_idx); + for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(indent+indentPlus, idx == last_idx); } } diff --git a/src/TestSuite/TestAny_Parser.cpp b/src/TestSuite/TestAny_Parser.cpp index 22a1bca..a4bae57 100644 --- a/src/TestSuite/TestAny_Parser.cpp +++ b/src/TestSuite/TestAny_Parser.cpp @@ -439,18 +439,20 @@ void SynTree::dump(int indent, bool isLast) { } } -void SynTree::dump2(int maxT, int indent, bool isLast) { +void SynTree::dump2(int indent, bool isLast) { int last_idx = children.Count; + int indentPlus = 4; if(tok->col) { printIndent(indent); wprintf(_SC("%s\t%d\t%d\t%d\t%") _SFMT _SC("\n"), ((isLast || (last_idx == 0)) ? "= " : " "), tok->line, tok->col, tok->kind, tok->val); } else { if(last_idx == 1) { - if(((SynTree*)children[0])->tok->kind < maxT) { + if(((SynTree*)children[0])->children.Count == 0) { printIndent(indent); wprintf(_SC("%d\t%d\t%d\t%") _SFMT _SC("\n"), children.Count, tok->line, tok->kind, tok->val); } + else indentPlus = 0; } else { printIndent(indent); @@ -458,7 +460,7 @@ void SynTree::dump2(int maxT, int indent, bool isLast) { } } if(last_idx) { - for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(maxT, indent+4, idx == last_idx); + for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(indent+indentPlus, idx == last_idx); } } diff --git a/src/TestSuite/TestCasing_Parser.cpp b/src/TestSuite/TestCasing_Parser.cpp index 1d28add..b571c95 100644 --- a/src/TestSuite/TestCasing_Parser.cpp +++ b/src/TestSuite/TestCasing_Parser.cpp @@ -377,18 +377,20 @@ void SynTree::dump(int indent, bool isLast) { } } -void SynTree::dump2(int maxT, int indent, bool isLast) { +void SynTree::dump2(int indent, bool isLast) { int last_idx = children.Count; + int indentPlus = 4; if(tok->col) { printIndent(indent); wprintf(_SC("%s\t%d\t%d\t%d\t%") _SFMT _SC("\n"), ((isLast || (last_idx == 0)) ? "= " : " "), tok->line, tok->col, tok->kind, tok->val); } else { if(last_idx == 1) { - if(((SynTree*)children[0])->tok->kind < maxT) { + if(((SynTree*)children[0])->children.Count == 0) { printIndent(indent); wprintf(_SC("%d\t%d\t%d\t%") _SFMT _SC("\n"), children.Count, tok->line, tok->kind, tok->val); } + else indentPlus = 0; } else { printIndent(indent); @@ -396,7 +398,7 @@ void SynTree::dump2(int maxT, int indent, bool isLast) { } } if(last_idx) { - for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(maxT, indent+4, idx == last_idx); + for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(indent+indentPlus, idx == last_idx); } } diff --git a/src/TestSuite/TestChars_Parser.cpp b/src/TestSuite/TestChars_Parser.cpp index 8bafa1e..8fa27c6 100644 --- a/src/TestSuite/TestChars_Parser.cpp +++ b/src/TestSuite/TestChars_Parser.cpp @@ -333,18 +333,20 @@ void SynTree::dump(int indent, bool isLast) { } } -void SynTree::dump2(int maxT, int indent, bool isLast) { +void SynTree::dump2(int indent, bool isLast) { int last_idx = children.Count; + int indentPlus = 4; if(tok->col) { printIndent(indent); wprintf(_SC("%s\t%d\t%d\t%d\t%") _SFMT _SC("\n"), ((isLast || (last_idx == 0)) ? "= " : " "), tok->line, tok->col, tok->kind, tok->val); } else { if(last_idx == 1) { - if(((SynTree*)children[0])->tok->kind < maxT) { + if(((SynTree*)children[0])->children.Count == 0) { printIndent(indent); wprintf(_SC("%d\t%d\t%d\t%") _SFMT _SC("\n"), children.Count, tok->line, tok->kind, tok->val); } + else indentPlus = 0; } else { printIndent(indent); @@ -352,7 +354,7 @@ void SynTree::dump2(int maxT, int indent, bool isLast) { } } if(last_idx) { - for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(maxT, indent+4, idx == last_idx); + for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(indent+indentPlus, idx == last_idx); } } diff --git a/src/TestSuite/TestComments_Parser.cpp b/src/TestSuite/TestComments_Parser.cpp index 8bafa1e..8fa27c6 100644 --- a/src/TestSuite/TestComments_Parser.cpp +++ b/src/TestSuite/TestComments_Parser.cpp @@ -333,18 +333,20 @@ void SynTree::dump(int indent, bool isLast) { } } -void SynTree::dump2(int maxT, int indent, bool isLast) { +void SynTree::dump2(int indent, bool isLast) { int last_idx = children.Count; + int indentPlus = 4; if(tok->col) { printIndent(indent); wprintf(_SC("%s\t%d\t%d\t%d\t%") _SFMT _SC("\n"), ((isLast || (last_idx == 0)) ? "= " : " "), tok->line, tok->col, tok->kind, tok->val); } else { if(last_idx == 1) { - if(((SynTree*)children[0])->tok->kind < maxT) { + if(((SynTree*)children[0])->children.Count == 0) { printIndent(indent); wprintf(_SC("%d\t%d\t%d\t%") _SFMT _SC("\n"), children.Count, tok->line, tok->kind, tok->val); } + else indentPlus = 0; } else { printIndent(indent); @@ -352,7 +354,7 @@ void SynTree::dump2(int maxT, int indent, bool isLast) { } } if(last_idx) { - for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(maxT, indent+4, idx == last_idx); + for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(indent+indentPlus, idx == last_idx); } } diff --git a/src/TestSuite/TestDel_Parser.cpp b/src/TestSuite/TestDel_Parser.cpp index 5cc35c3..661fad8 100644 --- a/src/TestSuite/TestDel_Parser.cpp +++ b/src/TestSuite/TestDel_Parser.cpp @@ -438,18 +438,20 @@ void SynTree::dump(int indent, bool isLast) { } } -void SynTree::dump2(int maxT, int indent, bool isLast) { +void SynTree::dump2(int indent, bool isLast) { int last_idx = children.Count; + int indentPlus = 4; if(tok->col) { printIndent(indent); wprintf(_SC("%s\t%d\t%d\t%d\t%") _SFMT _SC("\n"), ((isLast || (last_idx == 0)) ? "= " : " "), tok->line, tok->col, tok->kind, tok->val); } else { if(last_idx == 1) { - if(((SynTree*)children[0])->tok->kind < maxT) { + if(((SynTree*)children[0])->children.Count == 0) { printIndent(indent); wprintf(_SC("%d\t%d\t%d\t%") _SFMT _SC("\n"), children.Count, tok->line, tok->kind, tok->val); } + else indentPlus = 0; } else { printIndent(indent); @@ -457,7 +459,7 @@ void SynTree::dump2(int maxT, int indent, bool isLast) { } } if(last_idx) { - for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(maxT, indent+4, idx == last_idx); + for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(indent+indentPlus, idx == last_idx); } } diff --git a/src/TestSuite/TestEps_Parser.cpp b/src/TestSuite/TestEps_Parser.cpp index 393e9c6..f883388 100644 --- a/src/TestSuite/TestEps_Parser.cpp +++ b/src/TestSuite/TestEps_Parser.cpp @@ -366,18 +366,20 @@ void SynTree::dump(int indent, bool isLast) { } } -void SynTree::dump2(int maxT, int indent, bool isLast) { +void SynTree::dump2(int indent, bool isLast) { int last_idx = children.Count; + int indentPlus = 4; if(tok->col) { printIndent(indent); wprintf(_SC("%s\t%d\t%d\t%d\t%") _SFMT _SC("\n"), ((isLast || (last_idx == 0)) ? "= " : " "), tok->line, tok->col, tok->kind, tok->val); } else { if(last_idx == 1) { - if(((SynTree*)children[0])->tok->kind < maxT) { + if(((SynTree*)children[0])->children.Count == 0) { printIndent(indent); wprintf(_SC("%d\t%d\t%d\t%") _SFMT _SC("\n"), children.Count, tok->line, tok->kind, tok->val); } + else indentPlus = 0; } else { printIndent(indent); @@ -385,7 +387,7 @@ void SynTree::dump2(int maxT, int indent, bool isLast) { } } if(last_idx) { - for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(maxT, indent+4, idx == last_idx); + for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(indent+indentPlus, idx == last_idx); } } diff --git a/src/TestSuite/TestIters_Parser.cpp b/src/TestSuite/TestIters_Parser.cpp index 2666079..2630096 100644 --- a/src/TestSuite/TestIters_Parser.cpp +++ b/src/TestSuite/TestIters_Parser.cpp @@ -389,18 +389,20 @@ void SynTree::dump(int indent, bool isLast) { } } -void SynTree::dump2(int maxT, int indent, bool isLast) { +void SynTree::dump2(int indent, bool isLast) { int last_idx = children.Count; + int indentPlus = 4; if(tok->col) { printIndent(indent); wprintf(_SC("%s\t%d\t%d\t%d\t%") _SFMT _SC("\n"), ((isLast || (last_idx == 0)) ? "= " : " "), tok->line, tok->col, tok->kind, tok->val); } else { if(last_idx == 1) { - if(((SynTree*)children[0])->tok->kind < maxT) { + if(((SynTree*)children[0])->children.Count == 0) { printIndent(indent); wprintf(_SC("%d\t%d\t%d\t%") _SFMT _SC("\n"), children.Count, tok->line, tok->kind, tok->val); } + else indentPlus = 0; } else { printIndent(indent); @@ -408,7 +410,7 @@ void SynTree::dump2(int maxT, int indent, bool isLast) { } } if(last_idx) { - for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(maxT, indent+4, idx == last_idx); + for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(indent+indentPlus, idx == last_idx); } } diff --git a/src/TestSuite/TestLL1_Parser.cpp b/src/TestSuite/TestLL1_Parser.cpp index 5dba9a5..f1f5ce0 100644 --- a/src/TestSuite/TestLL1_Parser.cpp +++ b/src/TestSuite/TestLL1_Parser.cpp @@ -600,18 +600,20 @@ void SynTree::dump(int indent, bool isLast) { } } -void SynTree::dump2(int maxT, int indent, bool isLast) { +void SynTree::dump2(int indent, bool isLast) { int last_idx = children.Count; + int indentPlus = 4; if(tok->col) { printIndent(indent); wprintf(_SC("%s\t%d\t%d\t%d\t%") _SFMT _SC("\n"), ((isLast || (last_idx == 0)) ? "= " : " "), tok->line, tok->col, tok->kind, tok->val); } else { if(last_idx == 1) { - if(((SynTree*)children[0])->tok->kind < maxT) { + if(((SynTree*)children[0])->children.Count == 0) { printIndent(indent); wprintf(_SC("%d\t%d\t%d\t%") _SFMT _SC("\n"), children.Count, tok->line, tok->kind, tok->val); } + else indentPlus = 0; } else { printIndent(indent); @@ -619,7 +621,7 @@ void SynTree::dump2(int maxT, int indent, bool isLast) { } } if(last_idx) { - for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(maxT, indent+4, idx == last_idx); + for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(indent+indentPlus, idx == last_idx); } } diff --git a/src/TestSuite/TestOpts1_Parser.cpp b/src/TestSuite/TestOpts1_Parser.cpp index 99e1329..4b326d9 100644 --- a/src/TestSuite/TestOpts1_Parser.cpp +++ b/src/TestSuite/TestOpts1_Parser.cpp @@ -342,18 +342,20 @@ void SynTree::dump(int indent, bool isLast) { } } -void SynTree::dump2(int maxT, int indent, bool isLast) { +void SynTree::dump2(int indent, bool isLast) { int last_idx = children.Count; + int indentPlus = 4; if(tok->col) { printIndent(indent); wprintf(_SC("%s\t%d\t%d\t%d\t%") _SFMT _SC("\n"), ((isLast || (last_idx == 0)) ? "= " : " "), tok->line, tok->col, tok->kind, tok->val); } else { if(last_idx == 1) { - if(((SynTree*)children[0])->tok->kind < maxT) { + if(((SynTree*)children[0])->children.Count == 0) { printIndent(indent); wprintf(_SC("%d\t%d\t%d\t%") _SFMT _SC("\n"), children.Count, tok->line, tok->kind, tok->val); } + else indentPlus = 0; } else { printIndent(indent); @@ -361,7 +363,7 @@ void SynTree::dump2(int maxT, int indent, bool isLast) { } } if(last_idx) { - for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(maxT, indent+4, idx == last_idx); + for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(indent+indentPlus, idx == last_idx); } } diff --git a/src/TestSuite/TestOpts_Parser.cpp b/src/TestSuite/TestOpts_Parser.cpp index 5a934ee..6554d4d 100644 --- a/src/TestSuite/TestOpts_Parser.cpp +++ b/src/TestSuite/TestOpts_Parser.cpp @@ -394,18 +394,20 @@ void SynTree::dump(int indent, bool isLast) { } } -void SynTree::dump2(int maxT, int indent, bool isLast) { +void SynTree::dump2(int indent, bool isLast) { int last_idx = children.Count; + int indentPlus = 4; if(tok->col) { printIndent(indent); wprintf(_SC("%s\t%d\t%d\t%d\t%") _SFMT _SC("\n"), ((isLast || (last_idx == 0)) ? "= " : " "), tok->line, tok->col, tok->kind, tok->val); } else { if(last_idx == 1) { - if(((SynTree*)children[0])->tok->kind < maxT) { + if(((SynTree*)children[0])->children.Count == 0) { printIndent(indent); wprintf(_SC("%d\t%d\t%d\t%") _SFMT _SC("\n"), children.Count, tok->line, tok->kind, tok->val); } + else indentPlus = 0; } else { printIndent(indent); @@ -413,7 +415,7 @@ void SynTree::dump2(int maxT, int indent, bool isLast) { } } if(last_idx) { - for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(maxT, indent+4, idx == last_idx); + for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(indent+indentPlus, idx == last_idx); } } diff --git a/src/TestSuite/TestResOK_Parser.cpp b/src/TestSuite/TestResOK_Parser.cpp index 4ea4454..d1a30cb 100644 --- a/src/TestSuite/TestResOK_Parser.cpp +++ b/src/TestSuite/TestResOK_Parser.cpp @@ -643,18 +643,20 @@ void SynTree::dump(int indent, bool isLast) { } } -void SynTree::dump2(int maxT, int indent, bool isLast) { +void SynTree::dump2(int indent, bool isLast) { int last_idx = children.Count; + int indentPlus = 4; if(tok->col) { printIndent(indent); wprintf(_SC("%s\t%d\t%d\t%d\t%") _SFMT _SC("\n"), ((isLast || (last_idx == 0)) ? "= " : " "), tok->line, tok->col, tok->kind, tok->val); } else { if(last_idx == 1) { - if(((SynTree*)children[0])->tok->kind < maxT) { + if(((SynTree*)children[0])->children.Count == 0) { printIndent(indent); wprintf(_SC("%d\t%d\t%d\t%") _SFMT _SC("\n"), children.Count, tok->line, tok->kind, tok->val); } + else indentPlus = 0; } else { printIndent(indent); @@ -662,7 +664,7 @@ void SynTree::dump2(int maxT, int indent, bool isLast) { } } if(last_idx) { - for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(maxT, indent+4, idx == last_idx); + for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(indent+indentPlus, idx == last_idx); } } diff --git a/src/TestSuite/TestSem_Parser.cpp b/src/TestSuite/TestSem_Parser.cpp index f9ff002..a672510 100644 --- a/src/TestSuite/TestSem_Parser.cpp +++ b/src/TestSuite/TestSem_Parser.cpp @@ -419,18 +419,20 @@ void SynTree::dump(int indent, bool isLast) { } } -void SynTree::dump2(int maxT, int indent, bool isLast) { +void SynTree::dump2(int indent, bool isLast) { int last_idx = children.Count; + int indentPlus = 4; if(tok->col) { printIndent(indent); wprintf(_SC("%s\t%d\t%d\t%d\t%") _SFMT _SC("\n"), ((isLast || (last_idx == 0)) ? "= " : " "), tok->line, tok->col, tok->kind, tok->val); } else { if(last_idx == 1) { - if(((SynTree*)children[0])->tok->kind < maxT) { + if(((SynTree*)children[0])->children.Count == 0) { printIndent(indent); wprintf(_SC("%d\t%d\t%d\t%") _SFMT _SC("\n"), children.Count, tok->line, tok->kind, tok->val); } + else indentPlus = 0; } else { printIndent(indent); @@ -438,7 +440,7 @@ void SynTree::dump2(int maxT, int indent, bool isLast) { } } if(last_idx) { - for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(maxT, indent+4, idx == last_idx); + for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(indent+indentPlus, idx == last_idx); } } diff --git a/src/TestSuite/TestSync_Parser.cpp b/src/TestSuite/TestSync_Parser.cpp index f46d2a5..bfc42f1 100644 --- a/src/TestSuite/TestSync_Parser.cpp +++ b/src/TestSuite/TestSync_Parser.cpp @@ -387,18 +387,20 @@ void SynTree::dump(int indent, bool isLast) { } } -void SynTree::dump2(int maxT, int indent, bool isLast) { +void SynTree::dump2(int indent, bool isLast) { int last_idx = children.Count; + int indentPlus = 4; if(tok->col) { printIndent(indent); wprintf(_SC("%s\t%d\t%d\t%d\t%") _SFMT _SC("\n"), ((isLast || (last_idx == 0)) ? "= " : " "), tok->line, tok->col, tok->kind, tok->val); } else { if(last_idx == 1) { - if(((SynTree*)children[0])->tok->kind < maxT) { + if(((SynTree*)children[0])->children.Count == 0) { printIndent(indent); wprintf(_SC("%d\t%d\t%d\t%") _SFMT _SC("\n"), children.Count, tok->line, tok->kind, tok->val); } + else indentPlus = 0; } else { printIndent(indent); @@ -406,7 +408,7 @@ void SynTree::dump2(int maxT, int indent, bool isLast) { } } if(last_idx) { - for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(maxT, indent+4, idx == last_idx); + for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(indent+indentPlus, idx == last_idx); } } diff --git a/src/TestSuite/TestTokens_Parser.cpp b/src/TestSuite/TestTokens_Parser.cpp index b7be964..b2e4b06 100644 --- a/src/TestSuite/TestTokens_Parser.cpp +++ b/src/TestSuite/TestTokens_Parser.cpp @@ -375,18 +375,20 @@ void SynTree::dump(int indent, bool isLast) { } } -void SynTree::dump2(int maxT, int indent, bool isLast) { +void SynTree::dump2(int indent, bool isLast) { int last_idx = children.Count; + int indentPlus = 4; if(tok->col) { printIndent(indent); wprintf(_SC("%s\t%d\t%d\t%d\t%") _SFMT _SC("\n"), ((isLast || (last_idx == 0)) ? "= " : " "), tok->line, tok->col, tok->kind, tok->val); } else { if(last_idx == 1) { - if(((SynTree*)children[0])->tok->kind < maxT) { + if(((SynTree*)children[0])->children.Count == 0) { printIndent(indent); wprintf(_SC("%d\t%d\t%d\t%") _SFMT _SC("\n"), children.Count, tok->line, tok->kind, tok->val); } + else indentPlus = 0; } else { printIndent(indent); @@ -394,7 +396,7 @@ void SynTree::dump2(int maxT, int indent, bool isLast) { } } if(last_idx) { - for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(maxT, indent+4, idx == last_idx); + for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(indent+indentPlus, idx == last_idx); } } diff --git a/src/TestSuite/TestWeak_Parser.cpp b/src/TestSuite/TestWeak_Parser.cpp index 183f0f4..613b634 100644 --- a/src/TestSuite/TestWeak_Parser.cpp +++ b/src/TestSuite/TestWeak_Parser.cpp @@ -404,18 +404,20 @@ void SynTree::dump(int indent, bool isLast) { } } -void SynTree::dump2(int maxT, int indent, bool isLast) { +void SynTree::dump2(int indent, bool isLast) { int last_idx = children.Count; + int indentPlus = 4; if(tok->col) { printIndent(indent); wprintf(_SC("%s\t%d\t%d\t%d\t%") _SFMT _SC("\n"), ((isLast || (last_idx == 0)) ? "= " : " "), tok->line, tok->col, tok->kind, tok->val); } else { if(last_idx == 1) { - if(((SynTree*)children[0])->tok->kind < maxT) { + if(((SynTree*)children[0])->children.Count == 0) { printIndent(indent); wprintf(_SC("%d\t%d\t%d\t%") _SFMT _SC("\n"), children.Count, tok->line, tok->kind, tok->val); } + else indentPlus = 0; } else { printIndent(indent); @@ -423,7 +425,7 @@ void SynTree::dump2(int maxT, int indent, bool isLast) { } } if(last_idx) { - for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(maxT, indent+4, idx == last_idx); + for(int idx=0; idx < last_idx; ++idx) ((SynTree*)children[idx])->dump2(indent+indentPlus, idx == last_idx); } }