'iterator' as type description
This commit is contained in:
parent
476f6fc8ee
commit
f610d2d221
2 changed files with 9 additions and 3 deletions
|
|
@ -731,7 +731,8 @@ proc parseProcExpr(p: var TParser, isExpr: bool): PNode =
|
||||||
|
|
||||||
proc isExprStart(p: TParser): bool =
|
proc isExprStart(p: TParser): bool =
|
||||||
case p.tok.tokType
|
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,
|
tkParLe, tkBracketLe, tkCurlyLe, tkIntLit..tkCharLit, tkVar, tkRef, tkPtr,
|
||||||
tkTuple, tkType, tkWhen, tkCase:
|
tkTuple, tkType, tkWhen, tkCase:
|
||||||
result = true
|
result = true
|
||||||
|
|
@ -811,6 +812,9 @@ proc primary(p: var TParser, skipSuffix = false): PNode =
|
||||||
|
|
||||||
proc parseTypeDesc(p: var TParser): PNode =
|
proc parseTypeDesc(p: var TParser): PNode =
|
||||||
if p.tok.toktype == tkProc: result = parseProcExpr(p, false)
|
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)
|
else: result = parseExpr(p)
|
||||||
|
|
||||||
proc parseExprStmt(p: var TParser): PNode =
|
proc parseExprStmt(p: var TParser): PNode =
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,8 @@ exprOrType ::= lowestExpr
|
||||||
| 'tuple' tupleDesc
|
| 'tuple' tupleDesc
|
||||||
|
|
||||||
expr ::= exprOrType
|
expr ::= exprOrType
|
||||||
| 'proc' paramList [pragma] ['=' stmt]
|
| 'proc' paramList [pragma] ['=' stmt]
|
||||||
|
| 'iterator' paramList [pragma] ['=' stmt]
|
||||||
|
|
||||||
exprList ::= [expr (comma expr)* [comma]]
|
exprList ::= [expr (comma expr)* [comma]]
|
||||||
|
|
||||||
|
|
@ -79,6 +80,7 @@ qualifiedIdent ::= symbol ['.' symbol]
|
||||||
|
|
||||||
typeDesc ::= exprOrType
|
typeDesc ::= exprOrType
|
||||||
| 'proc' paramList [pragma]
|
| 'proc' paramList [pragma]
|
||||||
|
| 'iterator' paramList [pragma]
|
||||||
|
|
||||||
macroStmt ::= ':' [stmt] ('of' [exprList] ':' stmt
|
macroStmt ::= ':' [stmt] ('of' [exprList] ':' stmt
|
||||||
|'elif' expr ':' stmt
|
|'elif' expr ':' stmt
|
||||||
|
|
@ -146,7 +148,7 @@ param ::= symbol (comma symbol)* (':' typeDesc ['=' expr] | '=' expr)
|
||||||
paramList ::= ['(' [param (comma|semicolon param)*] optPar ')'] [':' typeDesc]
|
paramList ::= ['(' [param (comma|semicolon param)*] optPar ')'] [':' typeDesc]
|
||||||
|
|
||||||
genericConstraint ::= 'object' | 'tuple' | 'enum' | 'proc' | 'ref' | 'ptr'
|
genericConstraint ::= 'object' | 'tuple' | 'enum' | 'proc' | 'ref' | 'ptr'
|
||||||
| 'var' | 'distinct' | primary
|
| 'var' | 'distinct' | 'iterator' | primary
|
||||||
genericConstraints ::= genericConstraint ( '|' optInd genericConstraint )*
|
genericConstraints ::= genericConstraint ( '|' optInd genericConstraint )*
|
||||||
|
|
||||||
genericParam ::= symbol [':' genericConstraints] ['=' expr]
|
genericParam ::= symbol [':' genericConstraints] ['=' expr]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue