diff options
| author | Joey Yakimowich-Payne <jyapayne@gmail.com> | 2020-04-23 20:59:21 -0600 |
|---|---|---|
| committer | Joey Yakimowich-Payne <jyapayne@gmail.com> | 2020-04-26 09:12:17 -0600 |
| commit | 3e28501826f5d655ad3797cbf29009082be126e1 (patch) | |
| tree | 303e7b105376fac9e28273c0a64f4eb55f019d1e | |
| parent | cc460b2779fc8b2035c19e0ba8f460cf124d474f (diff) | |
| download | nimterop-3e28501826f5d655ad3797cbf29009082be126e1.tar.gz nimterop-3e28501826f5d655ad3797cbf29009082be126e1.zip | |
Fix comments breaking code
| -rw-r--r-- | nimterop/exprparser.nim | 14 | ||||
| -rw-r--r-- | tests/include/tast2.h | 4 | ||||
| -rw-r--r-- | tests/tpcre.nim | 1 |
3 files changed, 14 insertions, 5 deletions
diff --git a/nimterop/exprparser.nim b/nimterop/exprparser.nim index 1f6decc..e9ee502 100644 --- a/nimterop/exprparser.nim +++ b/nimterop/exprparser.nim @@ -486,9 +486,17 @@ proc processTSNode(gState: State, node: TSNode, typeofNode: var PNode): PNode = if node.len == 1: result = gState.processTSNode(node[0], typeofNode) elif node.len > 1: - result = newNode(nkStmtListExpr) + let res = newNode(nkStmtListExpr) for i in 0 ..< node.len: - result.add gState.processTSNode(node[i], typeofNode) + let node = gState.processTSNode(node[i], typeofNode) + if node.kind != nkNone: + res.add node + if res.len == 1: + result = res[0] + elif res.len > 1: + result = res + else: + result = newNode(nkNone) else: raise newException(ExprParseError, &"Node type \"{nodeName}\" has no children") of "parenthesized_expression": @@ -543,6 +551,8 @@ proc processTSNode(gState: State, node: TSNode, typeofNode: var PNode): PNode = result = gState.getExprIdent(node, parent=node.getName()) if result.kind == nkNone: raise newException(ExprParseError, &"Missing identifier \"{node.val}\"") + of "comment": + discard else: raise newException(ExprParseError, &"Unsupported node type \"{nodeName}\" for node \"{node.val}\"") diff --git a/tests/include/tast2.h b/tests/include/tast2.h index 815791f..42c852f 100644 --- a/tests/include/tast2.h +++ b/tests/include/tast2.h @@ -35,8 +35,8 @@ extern "C" { #define SIZEOF sizeof(char) -#define NULLCHAR '\0' -#define OCTCHAR '\012' +#define NULLCHAR '\0'/* comments should not break things*/ +#define OCTCHAR '\012' // nor should this comment #define HEXCHAR '\xFE' #define TRICKYSTR "\x4E\034\nfoo\0\'\"\r\v\a\b\e\f\t\\\?bar" diff --git a/tests/tpcre.nim b/tests/tpcre.nim index 3bbd1ba..c8e8059 100644 --- a/tests/tpcre.nim +++ b/tests/tpcre.nim @@ -7,7 +7,6 @@ const pcreH = baseDir/"pcre.h.in" static: - cSkipSymbol @["PCRE_UCHAR16", "PCRE_UCHAR32"] if not pcreH.fileExists(): downloadUrl("https://github.com/svn2github/pcre/raw/master/pcre.h.in", baseDir) cDebug() |
