'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
parent 95fe697afe
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:

View File

@@ -167,7 +167,7 @@ objectCase = 'case' identWithPragma ':' typeDesc ':'? COMMENT?
(IND{>} objectBranches DED
| IND{=} objectBranches)
objectPart = IND{>} objectPart^+IND{=} DED
/ objectWhen / objectCase / 'nil' / declColonEquals
/ objectWhen / objectCase / 'nil' / 'discard' / declColonEquals
object = 'object' pragma? ('of' typeDesc)? COMMENT? objectPart
typeClassParam = ('var')? symbol
typeClass = typeClassParam ^* ',' (pragma)? ('of' typeDesc ^* ',')?

View File

@@ -2,6 +2,26 @@
News
====
..
2015-03-01 Version 1.0.0 released
=================================
Changes affecting backwards compatibility
-----------------------------------------
- Parameter names are finally properly ``gensym``'ed. This can break
templates though that used to rely on the fact that they are not. However
we found none such beast in the wild. (Bug #1915.)
Language Additions
------------------
- For empty ``case object`` branches ``discard`` can finally be used instead
of ``nil``.
2014-12-29 Version 0.10.2 released
==================================