adapt quote to the new parsing rules
This commit is contained in:
parent
e7eb01ed48
commit
8cb11aac4f
1 changed files with 11 additions and 8 deletions
|
|
@ -1715,7 +1715,7 @@ proc semQuoteAst(c: PContext, n: PNode): PNode =
|
||||||
# We transform the do block into a template with a param for
|
# We transform the do block into a template with a param for
|
||||||
# each interpolation. We'll pass this template to getAst.
|
# each interpolation. We'll pass this template to getAst.
|
||||||
var
|
var
|
||||||
doBlk = n{-1}
|
quotedBlock = n{-1}
|
||||||
op = if n.len == 3: expectString(c, n[1]) else: "``"
|
op = if n.len == 3: expectString(c, n[1]) else: "``"
|
||||||
quotes = newSeq[PNode](1)
|
quotes = newSeq[PNode](1)
|
||||||
# the quotes will be added to a nkCall statement
|
# the quotes will be added to a nkCall statement
|
||||||
|
|
@ -1723,20 +1723,23 @@ proc semQuoteAst(c: PContext, n: PNode): PNode =
|
||||||
ids = newSeq[PNode]()
|
ids = newSeq[PNode]()
|
||||||
# this will store the generated param names
|
# this will store the generated param names
|
||||||
|
|
||||||
if doBlk.kind != nkDo:
|
if quotedBlock.kind != nkStmtList:
|
||||||
localError(n.info, errXExpected, "block")
|
localError(n.info, errXExpected, "block")
|
||||||
|
|
||||||
processQuotations(doBlk.sons[bodyPos], op, quotes, ids)
|
processQuotations(quotedBlock, op, quotes, ids)
|
||||||
|
|
||||||
|
var dummyTemplate = newProcNode(
|
||||||
|
nkTemplateDef, quotedBlock.info, quotedBlock,
|
||||||
|
name = newAnonSym(c, skTemplate, n.info).newSymNode)
|
||||||
|
|
||||||
doBlk.sons[namePos] = newAnonSym(c, skTemplate, n.info).newSymNode
|
|
||||||
if ids.len > 0:
|
if ids.len > 0:
|
||||||
doBlk.sons[paramsPos] = newNodeI(nkFormalParams, n.info)
|
dummyTemplate.sons[paramsPos] = newNodeI(nkFormalParams, n.info)
|
||||||
doBlk[paramsPos].add getSysSym("typed").newSymNode # return type
|
dummyTemplate[paramsPos].add getSysSym("typed").newSymNode # return type
|
||||||
ids.add getSysSym("untyped").newSymNode # params type
|
ids.add getSysSym("untyped").newSymNode # params type
|
||||||
ids.add emptyNode # no default value
|
ids.add emptyNode # no default value
|
||||||
doBlk[paramsPos].add newNode(nkIdentDefs, n.info, ids)
|
dummyTemplate[paramsPos].add newNode(nkIdentDefs, n.info, ids)
|
||||||
|
|
||||||
var tmpl = semTemplateDef(c, doBlk)
|
var tmpl = semTemplateDef(c, dummyTemplate)
|
||||||
quotes[0] = tmpl[namePos]
|
quotes[0] = tmpl[namePos]
|
||||||
result = newNode(nkCall, n.info, @[
|
result = newNode(nkCall, n.info, @[
|
||||||
getMagicSym(mExpandToAst).newSymNode,
|
getMagicSym(mExpandToAst).newSymNode,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue