aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGanesh Viswanathan <dev@genotrance.com>2019-10-17 12:01:37 -0500
committerGanesh Viswanathan <dev@genotrance.com>2019-10-17 12:01:37 -0500
commit8c57fbf6020e8da698076fd0cb72d3a49ea6cefc (patch)
treec015ff9e5c75183a05984a458264b0e4d41723c5
parentf7bc37f2b3345f5e04a4a7ba733751bf5ce41c6e (diff)
downloadnimterop-8c57fbf6020e8da698076fd0cb72d3a49ea6cefc.tar.gz
nimterop-8c57fbf6020e8da698076fd0cb72d3a49ea6cefc.zip
Fix debug output
-rw-r--r--nimterop/ast.nim33
1 files changed, 16 insertions, 17 deletions
diff --git a/nimterop/ast.nim b/nimterop/ast.nim
index 128a7e6..c4294dc 100644
--- a/nimterop/ast.nim
+++ b/nimterop/ast.nim
@@ -74,11 +74,16 @@ proc searchAstForNode(ast: ref Ast, node: TSNode, nimState: NimState): bool =
if ast.isNil:
return
+ if nimState.gState.debug:
+ nimState.nodeBranch.add $node.tsNodeType()
+ echo "#" & spaces(nimState.nodeBranch.len * 2) & nimState.nodeBranch[^1]
+
if ast.children.len != 0:
if childNames.contains(ast.regex) or
(childNames.len == 0 and ast.recursive):
if node.getTSNodeNamedChildCountSansComments() != 0:
var flag = true
+
for i in 0 .. node.tsNodeNamedChildCount()-1:
if $node.tsNodeNamedChild(i).tsNodeType() != "comment":
let
@@ -89,30 +94,24 @@ proc searchAstForNode(ast: ref Ast, node: TSNode, nimState: NimState): bool =
else:
ast
- if nimState.gState.debug:
- nimState.nodeBranch.add $node.tsNodeType()
- echo "#" & spaces(nimState.nodeBranch.len) & nimState.nodeBranch[^1]
-
if not searchAstForNode(astChild, nodeChild, nimState):
- if nimState.gState.debug:
- echo "#" & spaces(nimState.nodeBranch.len) & &" {$nodeChild.tsNodeType()} unexpected"
- discard nimState.nodeBranch.pop()
flag = false
break
- if nimState.gState.debug:
- discard nimState.nodeBranch.pop()
- if nimState.nodeBranch.len == 0:
- echo ""
-
if flag:
- return node.saveNodeData(nimState)
+ result = node.saveNodeData(nimState)
else:
- echo "#" & spaces(nimState.nodeBranch.len+1) & $node.tsNodeType()
- return node.saveNodeData(nimState)
+ result = node.saveNodeData(nimState)
+ else:
+ if nimState.gState.debug:
+ echo "#" & spaces(nimState.nodeBranch.len * 2) & &" {ast.getRegexForAstChildren()} !=~ {childNames}"
elif node.getTSNodeNamedChildCountSansComments() == 0:
- echo "#" & spaces(nimState.nodeBranch.len+1) & $node.tsNodeType()
- return node.saveNodeData(nimState)
+ result = node.saveNodeData(nimState)
+
+ if nimState.gState.debug:
+ discard nimState.nodeBranch.pop()
+ if nimstate.nodeBranch.len == 0:
+ echo ""
proc searchAst(root: TSNode, astTable: AstTable, nimState: NimState) =
var