diff options
| author | Joey Yakimowich-Payne <jyapayne@gmail.com> | 2020-04-20 17:09:08 -0600 |
|---|---|---|
| committer | Joey Yakimowich-Payne <jyapayne@gmail.com> | 2020-04-26 09:11:56 -0600 |
| commit | 1576127a6e1b5f429d3fb91cf924fc41e43346cf (patch) | |
| tree | 71b99216a6dd12a8770ce319b851b541b23b3bad | |
| parent | 208098b3eb959e477a3625a8a48305ddaa1cec4f (diff) | |
| download | nimterop-1576127a6e1b5f429d3fb91cf924fc41e43346cf.tar.gz nimterop-1576127a6e1b5f429d3fb91cf924fc41e43346cf.zip | |
Use tsNodeChild
| -rw-r--r-- | nimterop/exprparser.nim | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/nimterop/exprparser.nim b/nimterop/exprparser.nim index 207d7fd..610c0cb 100644 --- a/nimterop/exprparser.nim +++ b/nimterop/exprparser.nim @@ -223,7 +223,8 @@ proc processShiftExpression(exprParser: ExprParser, node: TSNode, typeofNode: va let left = node[0] right = node[1] - var shiftSym = exprParser.code[left.tsNodeEndByte() ..< right.tsNodeStartByte()].strip() + + let shiftSym = node.tsNodeChild(1).val.strip() case shiftSym of "<<": @@ -268,7 +269,7 @@ proc processLogicalExpression(exprParser: ExprParser, node: TSNode, typeofNode: let child = node[0] var nimSym = "" - var binarySym = exprParser.code[node.tsNodeStartByte() ..< child.tsNodeStartByte()].strip() + let binarySym = node.tsNodeChild(0).val.strip() techo "LOG SYM: ", binarySym case binarySym @@ -292,7 +293,7 @@ proc processMathExpression(exprParser: ExprParser, node: TSNode, typeofNode: var left = node[0] right = node[1] - let mathSym = exprParser.code[left.tsNodeEndByte() ..< right.tsNodeStartByte()].strip() + let mathSym = node.tsNodeChild(1).val.strip() techo "MATH SYM: ", mathSym res.add exprParser.state.getIdent(mathSym) @@ -329,7 +330,7 @@ proc processMathExpression(exprParser: ExprParser, node: TSNode, typeofNode: var let child = node[0] var nimSym = "" - let unarySym = exprParser.code[node.tsNodeStartByte() ..< child.tsNodeStartByte()].strip() + let unarySym = node.tsNodeChild(0).val.strip() techo "MATH SYM: ", unarySym case unarySym @@ -372,7 +373,7 @@ proc processBitwiseExpression(exprParser: ExprParser, node: TSNode, typeofNode: var nimSym = "" - var binarySym = exprParser.code[left.tsNodeEndByte() ..< right.tsNodeStartByte()].strip() + let binarySym = node.tsNodeChild(1).val.strip() techo "BIN SYM: ", binarySym case binarySym @@ -409,7 +410,7 @@ proc processBitwiseExpression(exprParser: ExprParser, node: TSNode, typeofNode: let child = node[0] var nimSym = "" - var unarySym = exprParser.code[node.tsNodeStartByte() ..< child.tsNodeStartByte()].strip() + let unarySym = node.tsNodeChild(0).val.strip() techo "BIN SYM: ", unarySym # TODO: Support more symbols here @@ -437,7 +438,9 @@ proc processTSNode(exprParser: ExprParser, node: TSNode, typeofNode: var PNode): ## in the processX procs and will drill down to sub nodes. result = newNode(nkNone) let nodeName = node.getName() + techo "NODE: ", nodeName, ", VAL: ", node.val + case nodeName of "number_literal": result = exprParser.processNumberLiteral(node) |
