'discard' can be used instead of 'nil' for empty case object branches

This commit is contained in:
Araq 2015-01-12 01:41:53 +01:00
commit c87f1eb581
3 changed files with 24 additions and 4 deletions

View file

@ -1683,14 +1683,14 @@ proc parseObjectCase(p: var TParser): PNode =
proc parseObjectPart(p: var TParser): PNode =
#| objectPart = IND{>} objectPart^+IND{=} DED
#| / objectWhen / objectCase / 'nil' / declColonEquals
#| / objectWhen / objectCase / 'nil' / 'discard' / declColonEquals
if realInd(p):
result = newNodeP(nkRecList, p)
withInd(p):
rawSkipComment(p, result)
while sameInd(p):
case p.tok.tokType
of tkCase, tkWhen, tkSymbol, tkAccent, tkNil:
of tkCase, tkWhen, tkSymbol, tkAccent, tkNil, tkDiscard:
addSon(result, parseObjectPart(p))
else:
parMessage(p, errIdentifierExpected, p.tok)
@ -1704,7 +1704,7 @@ proc parseObjectPart(p: var TParser): PNode =
of tkSymbol, tkAccent:
result = parseIdentColonEquals(p, {withPragma})
skipComment(p, result)
of tkNil:
of tkNil, tkDiscard:
result = newNodeP(nkNilLit, p)
getTok(p)
else: