'out T' is an alias for 'var T'
This commit is contained in:
parent
25e2e3faec
commit
5fe71db6d9
2 changed files with 14 additions and 10 deletions
|
|
@ -991,7 +991,7 @@ proc isExprStart(p: TParser): bool =
|
||||||
of tkSymbol, tkAccent, tkOpr, tkNot, tkNil, tkCast, tkIf,
|
of tkSymbol, tkAccent, tkOpr, tkNot, tkNil, tkCast, tkIf,
|
||||||
tkProc, tkIterator, tkBind, tkAddr,
|
tkProc, tkIterator, tkBind, tkAddr,
|
||||||
tkParLe, tkBracketLe, tkCurlyLe, tkIntLit..tkCharLit, tkVar, tkRef, tkPtr,
|
tkParLe, tkBracketLe, tkCurlyLe, tkIntLit..tkCharLit, tkVar, tkRef, tkPtr,
|
||||||
tkTuple, tkObject, tkType, tkWhen, tkCase:
|
tkTuple, tkObject, tkType, tkWhen, tkCase, tkOut:
|
||||||
result = true
|
result = true
|
||||||
else: result = false
|
else: result = false
|
||||||
|
|
||||||
|
|
@ -1038,7 +1038,7 @@ proc parseObject(p: var TParser): PNode
|
||||||
proc parseTypeClass(p: var TParser): PNode
|
proc parseTypeClass(p: var TParser): PNode
|
||||||
|
|
||||||
proc primary(p: var TParser, mode: TPrimaryMode): PNode =
|
proc primary(p: var TParser, mode: TPrimaryMode): PNode =
|
||||||
#| typeKeyw = 'var' | 'ref' | 'ptr' | 'shared' | 'tuple'
|
#| typeKeyw = 'var' | 'out' | 'ref' | 'ptr' | 'shared' | 'tuple'
|
||||||
#| | 'proc' | 'iterator' | 'distinct' | 'object' | 'enum'
|
#| | 'proc' | 'iterator' | 'distinct' | 'object' | 'enum'
|
||||||
#| primary = typeKeyw typeDescK
|
#| primary = typeKeyw typeDescK
|
||||||
#| / prefixOperator* identOrLiteral primarySuffix*
|
#| / prefixOperator* identOrLiteral primarySuffix*
|
||||||
|
|
@ -1112,6 +1112,7 @@ proc primary(p: var TParser, mode: TPrimaryMode): PNode =
|
||||||
optInd(p, result)
|
optInd(p, result)
|
||||||
addSon(result, primary(p, pmNormal))
|
addSon(result, primary(p, pmNormal))
|
||||||
of tkVar: result = parseTypeDescKAux(p, nkVarTy, mode)
|
of tkVar: result = parseTypeDescKAux(p, nkVarTy, mode)
|
||||||
|
of tkOut: result = parseTypeDescKAux(p, nkVarTy, mode)
|
||||||
of tkRef: result = parseTypeDescKAux(p, nkRefTy, mode)
|
of tkRef: result = parseTypeDescKAux(p, nkRefTy, mode)
|
||||||
of tkPtr: result = parseTypeDescKAux(p, nkPtrTy, mode)
|
of tkPtr: result = parseTypeDescKAux(p, nkPtrTy, mode)
|
||||||
of tkDistinct: result = parseTypeDescKAux(p, nkDistinctTy, mode)
|
of tkDistinct: result = parseTypeDescKAux(p, nkDistinctTy, mode)
|
||||||
|
|
@ -1763,7 +1764,7 @@ proc parseObject(p: var TParser): PNode =
|
||||||
addSon(result, parseObjectPart(p))
|
addSon(result, parseObjectPart(p))
|
||||||
|
|
||||||
proc parseTypeClassParam(p: var TParser): PNode =
|
proc parseTypeClassParam(p: var TParser): PNode =
|
||||||
if p.tok.tokType == tkVar:
|
if p.tok.tokType in {tkOut, tkVar}:
|
||||||
result = newNodeP(nkVarTy, p)
|
result = newNodeP(nkVarTy, p)
|
||||||
getTok(p)
|
getTok(p)
|
||||||
result.addSon(p.parseSymbol)
|
result.addSon(p.parseSymbol)
|
||||||
|
|
@ -1771,7 +1772,7 @@ proc parseTypeClassParam(p: var TParser): PNode =
|
||||||
result = p.parseSymbol
|
result = p.parseSymbol
|
||||||
|
|
||||||
proc parseTypeClass(p: var TParser): PNode =
|
proc parseTypeClass(p: var TParser): PNode =
|
||||||
#| typeClassParam = ('var')? symbol
|
#| typeClassParam = ('var' | 'out')? symbol
|
||||||
#| typeClass = typeClassParam ^* ',' (pragma)? ('of' typeDesc ^* ',')?
|
#| typeClass = typeClassParam ^* ',' (pragma)? ('of' typeDesc ^* ',')?
|
||||||
#| &IND{>} stmt
|
#| &IND{>} stmt
|
||||||
result = newNodeP(nkTypeClassTy, p)
|
result = newNodeP(nkTypeClassTy, p)
|
||||||
|
|
|
||||||
|
|
@ -35,9 +35,12 @@ castExpr = 'cast' '[' optInd typeDesc optPar ']' '(' optInd expr optPar ')'
|
||||||
parKeyw = 'discard' | 'include' | 'if' | 'while' | 'case' | 'try'
|
parKeyw = 'discard' | 'include' | 'if' | 'while' | 'case' | 'try'
|
||||||
| 'finally' | 'except' | 'for' | 'block' | 'const' | 'let'
|
| 'finally' | 'except' | 'for' | 'block' | 'const' | 'let'
|
||||||
| 'when' | 'var' | 'mixin'
|
| 'when' | 'var' | 'mixin'
|
||||||
par = '(' optInd (&parKeyw complexOrSimpleStmt ^+ ';'
|
par = '(' optInd
|
||||||
| simpleExpr ('=' expr (';' complexOrSimpleStmt ^+ ';' )? )?
|
( &parKeyw complexOrSimpleStmt ^+ ';'
|
||||||
| (':' expr)? (',' (exprColonEqExpr comma?)*)? )?
|
| ';' complexOrSimpleStmt ^+ ';'
|
||||||
|
| pragmaStmt
|
||||||
|
| simpleExpr ( ('=' expr (';' complexOrSimpleStmt ^+ ';' )? )
|
||||||
|
| (':' expr (',' exprColonEqExpr ^+ ',' )? ) ) )
|
||||||
optPar ')'
|
optPar ')'
|
||||||
literal = | INT_LIT | INT8_LIT | INT16_LIT | INT32_LIT | INT64_LIT
|
literal = | INT_LIT | INT8_LIT | INT16_LIT | INT32_LIT | INT64_LIT
|
||||||
| UINT_LIT | UINT8_LIT | UINT16_LIT | UINT32_LIT | UINT64_LIT
|
| UINT_LIT | UINT8_LIT | UINT16_LIT | UINT32_LIT | UINT64_LIT
|
||||||
|
|
@ -86,7 +89,7 @@ expr = (ifExpr
|
||||||
| caseExpr
|
| caseExpr
|
||||||
| tryExpr)
|
| tryExpr)
|
||||||
/ simpleExpr
|
/ simpleExpr
|
||||||
typeKeyw = 'var' | 'ref' | 'ptr' | 'shared' | 'tuple'
|
typeKeyw = 'var' | 'out' | 'ref' | 'ptr' | 'shared' | 'tuple'
|
||||||
| 'proc' | 'iterator' | 'distinct' | 'object' | 'enum'
|
| 'proc' | 'iterator' | 'distinct' | 'object' | 'enum'
|
||||||
primary = typeKeyw typeDescK
|
primary = typeKeyw typeDescK
|
||||||
/ prefixOperator* identOrLiteral primarySuffix*
|
/ prefixOperator* identOrLiteral primarySuffix*
|
||||||
|
|
@ -165,7 +168,7 @@ objectCase = 'case' identWithPragma ':' typeDesc ':'? COMMENT?
|
||||||
objectPart = IND{>} objectPart^+IND{=} DED
|
objectPart = IND{>} objectPart^+IND{=} DED
|
||||||
/ objectWhen / objectCase / 'nil' / 'discard' / declColonEquals
|
/ objectWhen / objectCase / 'nil' / 'discard' / declColonEquals
|
||||||
object = 'object' pragma? ('of' typeDesc)? COMMENT? objectPart
|
object = 'object' pragma? ('of' typeDesc)? COMMENT? objectPart
|
||||||
typeClassParam = ('var')? symbol
|
typeClassParam = ('var' | 'out')? symbol
|
||||||
typeClass = typeClassParam ^* ',' (pragma)? ('of' typeDesc ^* ',')?
|
typeClass = typeClassParam ^* ',' (pragma)? ('of' typeDesc ^* ',')?
|
||||||
&IND{>} stmt
|
&IND{>} stmt
|
||||||
typeDef = identWithPragma genericParamList? '=' optInd typeDefAux
|
typeDef = identWithPragma genericParamList? '=' optInd typeDefAux
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue