parser support anon iterators
This commit is contained in:
parent
d18f40b4e2
commit
4a0aadef4d
8 changed files with 61 additions and 13 deletions
|
|
@ -990,7 +990,7 @@ proc primary(p: var TParser, mode: TPrimaryMode): PNode =
|
|||
of tkTuple: result = parseTuple(p, mode == pmTypeDef)
|
||||
of tkProc: result = parseProcExpr(p, mode notin {pmTypeDesc, pmTypeDef})
|
||||
of tkIterator:
|
||||
when true:
|
||||
when false:
|
||||
if mode in {pmTypeDesc, pmTypeDef}:
|
||||
result = parseProcExpr(p, false)
|
||||
result.kind = nkIteratorTy
|
||||
|
|
@ -1001,7 +1001,8 @@ proc primary(p: var TParser, mode: TPrimaryMode): PNode =
|
|||
result = ast.emptyNode
|
||||
else:
|
||||
result = parseProcExpr(p, mode notin {pmTypeDesc, pmTypeDef})
|
||||
result.kind = nkIteratorTy
|
||||
if result.kind == nkLambda: result.kind = nkIteratorDef
|
||||
else: result.kind = nkIteratorTy
|
||||
of tkEnum:
|
||||
if mode == pmTypeDef:
|
||||
result = parseEnum(p)
|
||||
|
|
|
|||
|
|
@ -922,7 +922,7 @@ proc activate(c: PContext, n: PNode) =
|
|||
of nkCallKinds:
|
||||
for i in 1 .. <n.len: activate(c, n[i])
|
||||
else:
|
||||
nil
|
||||
discard
|
||||
|
||||
proc maybeAddResult(c: PContext, s: PSym, n: PNode) =
|
||||
if s.typ.sons[0] != nil and
|
||||
|
|
@ -951,7 +951,11 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
|
|||
var typeIsDetermined = false
|
||||
if n[namePos].kind != nkSym:
|
||||
assert phase == stepRegisterSymbol
|
||||
s = semIdentDef(c, n.sons[0], kind)
|
||||
|
||||
if n[namePos].kind == nkEmpty:
|
||||
s = newSym(kind, idAnon, getCurrOwner(), n.info)
|
||||
else:
|
||||
s = semIdentDef(c, n.sons[0], kind)
|
||||
n.sons[namePos] = newSymNode(s)
|
||||
s.ast = n
|
||||
s.scope = c.currentScope
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue