fix a regression in tlexerex

This commit is contained in:
Zahary Karadjov
2017-04-10 13:06:06 +03:00
parent 8cb11aac4f
commit 8b63b84924
2 changed files with 14 additions and 14 deletions

View File

@@ -1168,19 +1168,20 @@ proc postExprBlocks(p: var TParser, x: PNode): PNode =
result = makeCall(result)
getTok(p)
skipComment(p, result)
var stmtList = newNodeP(nkStmtList, p)
let body = parseStmt(p)
stmtList.add body
if p.tok.tokType notin {tkOf, tkElif, tkElse, tkExcept}:
var stmtList = newNodeP(nkStmtList, p)
let body = parseStmt(p)
stmtList.add body
if stmtList.len == 1 and stmtList[0].kind == nkStmtList:
# to keep backwards compatibility (see tests/vm/tstringnil)
stmtList = stmtList[0]
if stmtList.len == 1 and stmtList[0].kind == nkStmtList:
# to keep backwards compatibility (see tests/vm/tstringnil)
stmtList = stmtList[0]
if openingParams.kind != nkEmpty:
result.add newProcNode(nkDo, stmtList.info, stmtList,
params = openingParams, pragmas = openingPragmas)
else:
result.add stmtList
if openingParams.kind != nkEmpty:
result.add newProcNode(nkDo, stmtList.info, stmtList,
params = openingParams, pragmas = openingPragmas)
else:
result.add stmtList
while sameInd(p):
var nextBlock: PNode

View File

@@ -1,8 +1,7 @@
import macros
macro match*(s: cstring|string; pos: int; sections: untyped): untyped =
for sec in sections.children:
macro match*(s: cstring|string; pos: int; sections: varargs[untyped]): untyped =
for sec in sections:
expectKind sec, nnkOfBranch
expectLen sec, 2
result = newStmtList()