fix a regression in tlexerex

This commit is contained in:
Zahary Karadjov 2017-04-10 13:06:06 +03:00
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) result = makeCall(result)
getTok(p) getTok(p)
skipComment(p, result) skipComment(p, result)
var stmtList = newNodeP(nkStmtList, p) if p.tok.tokType notin {tkOf, tkElif, tkElse, tkExcept}:
let body = parseStmt(p) var stmtList = newNodeP(nkStmtList, p)
stmtList.add body let body = parseStmt(p)
stmtList.add body
if stmtList.len == 1 and stmtList[0].kind == nkStmtList: if stmtList.len == 1 and stmtList[0].kind == nkStmtList:
# to keep backwards compatibility (see tests/vm/tstringnil) # to keep backwards compatibility (see tests/vm/tstringnil)
stmtList = stmtList[0] stmtList = stmtList[0]
if openingParams.kind != nkEmpty: if openingParams.kind != nkEmpty:
result.add newProcNode(nkDo, stmtList.info, stmtList, result.add newProcNode(nkDo, stmtList.info, stmtList,
params = openingParams, pragmas = openingPragmas) params = openingParams, pragmas = openingPragmas)
else: else:
result.add stmtList result.add stmtList
while sameInd(p): while sameInd(p):
var nextBlock: PNode var nextBlock: PNode

View file

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