Fix comments breaking code

This commit is contained in:
Joey Yakimowich-Payne 2020-04-23 20:59:21 -06:00
commit c55e77e547
3 changed files with 14 additions and 5 deletions

View file

@ -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}\"")

View file

@ -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"

View file

@ -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()