diff options
author | Araq <rumpf_a@web.de> | 2014-01-20 20:07:44 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2014-01-20 20:07:44 +0100 |
commit | 4a0aadef4d1eef2920bd84cbc532b607741a239a (patch) | |
tree | 0202cba6e947e3afb66d4093de0c71214d625c0c /compiler | |
parent | d18f40b4e2ea594d10c654616b95b038f808b8ed (diff) | |
download | Nim-4a0aadef4d1eef2920bd84cbc532b607741a239a.tar.gz |
parser support anon iterators
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/parser.nim | 5 | ||||
-rw-r--r-- | compiler/semstmts.nim | 8 |
2 files changed, 9 insertions, 4 deletions
diff --git a/compiler/parser.nim b/compiler/parser.nim index dd683eb19..d255949a4 100644 --- a/compiler/parser.nim +++ b/compiler/parser.nim @@ -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) diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 1aa6a793c..fc1706200 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -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 |