syntax compatibility between do blocks and stmt blocks
See the section `do notation` in the manual for more info. * nkMacroStmt has been removed Macro statements are now mapped to regular nkCall nodes. The support for additional clauses (such as else, except, of, etc) have been restored - they will now appear as additional arguments for the nkCall node (as nkElse, nkExcept, etc nodes) * fixed some regressions in the `is` operator and semCompiles
This commit is contained in:
parent
a6d5707faf
commit
d9d82fb0af
21 changed files with 142 additions and 168 deletions
|
|
@ -53,6 +53,7 @@ proc semGenericStmtSymbol(c: PContext, n: PNode, s: PSym): PNode =
|
|||
result = symChoice(c, n, s, scOpen)
|
||||
of skTemplate:
|
||||
if macroToExpand(s):
|
||||
let n = fixImmediateParams(n)
|
||||
result = semTemplateExpr(c, n, s, false)
|
||||
else:
|
||||
result = symChoice(c, n, s, scOpen)
|
||||
|
|
@ -123,6 +124,7 @@ proc semGenericStmt(c: PContext, n: PNode,
|
|||
result = n
|
||||
of skTemplate:
|
||||
if macroToExpand(s):
|
||||
let n = fixImmediateParams(n)
|
||||
result = semTemplateExpr(c, n, s, false)
|
||||
else:
|
||||
n.sons[0] = symChoice(c, n.sons[0], s, scOpen)
|
||||
|
|
@ -151,17 +153,6 @@ proc semGenericStmt(c: PContext, n: PNode,
|
|||
let flags = if isDefinedMagic: flags+{withinMixin} else: flags
|
||||
for i in countup(first, sonsLen(result) - 1):
|
||||
result.sons[i] = semGenericStmt(c, result.sons[i], flags, toBind)
|
||||
of nkMacroStmt:
|
||||
checkMinSonsLen(n, 2)
|
||||
var a: PNode
|
||||
if isCallExpr(n.sons[0]): a = n.sons[0].sons[0]
|
||||
else: a = n.sons[0]
|
||||
let luf = if withinMixin notin flags: {checkUndeclared} else: {}
|
||||
var s = qualifiedLookup(c, a, luf)
|
||||
if s != nil and macroToExpand(s):
|
||||
result = semMacroStmt(c, n, {}, false)
|
||||
for i in countup(0, sonsLen(result)-1):
|
||||
result.sons[i] = semGenericStmt(c, result.sons[i], flags, toBind)
|
||||
of nkIfStmt:
|
||||
for i in countup(0, sonsLen(n)-1):
|
||||
n.sons[i] = semGenericStmtScope(c, n.sons[i], flags, toBind)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue