parser.nim: minor refactorings (#14540)
This commit is contained in:
parent
3698f197f1
commit
75e579ff8e
1 changed files with 6 additions and 9 deletions
|
|
@ -740,10 +740,6 @@ proc commandParam(p: var TParser, isFirstParam: var bool; mode: TPrimaryMode): P
|
||||||
result.add(parseExpr(p))
|
result.add(parseExpr(p))
|
||||||
isFirstParam = false
|
isFirstParam = false
|
||||||
|
|
||||||
const
|
|
||||||
tkTypeClasses = {tkRef, tkPtr, tkVar, tkStatic, tkType,
|
|
||||||
tkEnum, tkTuple, tkObject, tkProc}
|
|
||||||
|
|
||||||
proc commandExpr(p: var TParser; r: PNode; mode: TPrimaryMode): PNode =
|
proc commandExpr(p: var TParser; r: PNode; mode: TPrimaryMode): PNode =
|
||||||
result = newNodeP(nkCommand, p)
|
result = newNodeP(nkCommand, p)
|
||||||
result.add(r)
|
result.add(r)
|
||||||
|
|
@ -797,7 +793,8 @@ proc primarySuffix(p: var TParser, r: PNode,
|
||||||
break
|
break
|
||||||
result = namedParams(p, result, nkCurlyExpr, tkCurlyRi)
|
result = namedParams(p, result, nkCurlyExpr, tkCurlyRi)
|
||||||
of tkSymbol, tkAccent, tkIntLit..tkCharLit, tkNil, tkCast,
|
of tkSymbol, tkAccent, tkIntLit..tkCharLit, tkNil, tkCast,
|
||||||
tkOpr, tkDotDot, tkTypeClasses - {tkRef, tkPtr}:
|
tkOpr, tkDotDot, tkVar, tkStatic, tkType, tkEnum, tkTuple,
|
||||||
|
tkObject, tkProc:
|
||||||
# XXX: In type sections we allow the free application of the
|
# XXX: In type sections we allow the free application of the
|
||||||
# command syntax, with the exception of expressions such as
|
# command syntax, with the exception of expressions such as
|
||||||
# `foo ref` or `foo ptr`. Unfortunately, these two are also
|
# `foo ref` or `foo ptr`. Unfortunately, these two are also
|
||||||
|
|
@ -1270,7 +1267,7 @@ proc primary(p: var TParser, mode: TPrimaryMode): PNode =
|
||||||
result.add(primary(p, pmNormal))
|
result.add(primary(p, pmNormal))
|
||||||
return
|
return
|
||||||
|
|
||||||
case p.tok.tokType:
|
case p.tok.tokType
|
||||||
of tkTuple: result = parseTuple(p, mode == pmTypeDef)
|
of tkTuple: result = parseTuple(p, mode == pmTypeDef)
|
||||||
of tkProc: result = parseProcExpr(p, mode notin {pmTypeDesc, pmTypeDef}, nkLambda)
|
of tkProc: result = parseProcExpr(p, mode notin {pmTypeDesc, pmTypeDef}, nkLambda)
|
||||||
of tkFunc: result = parseProcExpr(p, mode notin {pmTypeDesc, pmTypeDef}, nkFuncDef)
|
of tkFunc: result = parseProcExpr(p, mode notin {pmTypeDesc, pmTypeDef}, nkFuncDef)
|
||||||
|
|
@ -1392,7 +1389,7 @@ proc postExprBlocks(p: var TParser, x: PNode): PNode =
|
||||||
getTok(p)
|
getTok(p)
|
||||||
nextBlock = parseDoBlock(p, info)
|
nextBlock = parseDoBlock(p, info)
|
||||||
else:
|
else:
|
||||||
case nextToken:
|
case nextToken
|
||||||
of tkOf:
|
of tkOf:
|
||||||
nextBlock = newNodeP(nkOfBranch, p)
|
nextBlock = newNodeP(nkOfBranch, p)
|
||||||
exprList(p, tkColon, nextBlock)
|
exprList(p, tkColon, nextBlock)
|
||||||
|
|
@ -1990,7 +1987,7 @@ proc parseObject(p: var TParser): PNode =
|
||||||
# an initial IND{>} HAS to follow:
|
# an initial IND{>} HAS to follow:
|
||||||
if not realInd(p):
|
if not realInd(p):
|
||||||
result.add(p.emptyNode)
|
result.add(p.emptyNode)
|
||||||
return
|
else:
|
||||||
result.add(parseObjectPart(p))
|
result.add(parseObjectPart(p))
|
||||||
|
|
||||||
proc parseTypeClassParam(p: var TParser): PNode =
|
proc parseTypeClassParam(p: var TParser): PNode =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue