summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2012-11-22 08:31:40 +0100
committerAraq <rumpf_a@web.de>2012-11-22 08:31:40 +0100
commitf610d2d2217b757901929ed92725a1b682e1165c (patch)
treec3f684991eda6ba26613c44e190be3b0e20d382a
parent476f6fc8ee6b7a26c2ac04cb356837d35a6cb929 (diff)
downloadNim-f610d2d2217b757901929ed92725a1b682e1165c.tar.gz
'iterator' as type description
-rwxr-xr-xcompiler/parser.nim6
-rwxr-xr-xdoc/grammar.txt6
2 files changed, 9 insertions, 3 deletions
diff --git a/compiler/parser.nim b/compiler/parser.nim
index 680279bcf..59f7934e0 100755
--- a/compiler/parser.nim
+++ b/compiler/parser.nim
@@ -731,7 +731,8 @@ proc parseProcExpr(p: var TParser, isExpr: bool): PNode =
 
 proc isExprStart(p: TParser): bool = 
   case p.tok.tokType
-  of tkSymbol, tkAccent, tkOpr, tkNot, tkNil, tkCast, tkIf, tkProc, tkBind, 
+  of tkSymbol, tkAccent, tkOpr, tkNot, tkNil, tkCast, tkIf, 
+     tkProc, tkIterator, tkBind, 
      tkParLe, tkBracketLe, tkCurlyLe, tkIntLit..tkCharLit, tkVar, tkRef, tkPtr, 
      tkTuple, tkType, tkWhen, tkCase:
     result = true
@@ -811,6 +812,9 @@ proc primary(p: var TParser, skipSuffix = false): PNode =
   
 proc parseTypeDesc(p: var TParser): PNode = 
   if p.tok.toktype == tkProc: result = parseProcExpr(p, false)
+  elif p.tok.toktype == tkIterator: 
+    result = parseProcExpr(p, false)
+    result.kind = nkIteratorTy
   else: result = parseExpr(p)
 
 proc parseExprStmt(p: var TParser): PNode = 
diff --git a/doc/grammar.txt b/doc/grammar.txt
index 1e54d1116..2474b584e 100755
--- a/doc/grammar.txt
+++ b/doc/grammar.txt
@@ -70,7 +70,8 @@ exprOrType ::= lowestExpr
             | 'tuple' tupleDesc
 
 expr ::= exprOrType
-     | 'proc' paramList [pragma] ['=' stmt] 
+     | 'proc' paramList [pragma] ['=' stmt]
+     | 'iterator' paramList [pragma] ['=' stmt]
 
 exprList ::= [expr (comma expr)* [comma]]
 
@@ -79,6 +80,7 @@ qualifiedIdent ::= symbol ['.' symbol]
 
 typeDesc ::= exprOrType
          | 'proc' paramList [pragma]
+         | 'iterator' paramList [pragma]
 
 macroStmt ::= ':' [stmt] ('of' [exprList] ':' stmt
                          |'elif' expr ':' stmt
@@ -146,7 +148,7 @@ param ::= symbol (comma symbol)* (':' typeDesc ['=' expr] | '=' expr)
 paramList ::= ['(' [param (comma|semicolon param)*] optPar ')'] [':' typeDesc]
 
 genericConstraint ::= 'object' | 'tuple' | 'enum' | 'proc' | 'ref' | 'ptr' 
-                    | 'var' | 'distinct' | primary
+                    | 'var' | 'distinct' | 'iterator' | primary
 genericConstraints ::= genericConstraint ( '|' optInd genericConstraint )*
 
 genericParam ::= symbol [':' genericConstraints] ['=' expr]
20'>220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315