'discard' can be used instead of 'nil' for empty case object branches
This commit is contained in:
parent
95fe697afe
commit
c87f1eb581
3 changed files with 24 additions and 4 deletions
|
|
@ -1683,14 +1683,14 @@ proc parseObjectCase(p: var TParser): PNode =
|
||||||
|
|
||||||
proc parseObjectPart(p: var TParser): PNode =
|
proc parseObjectPart(p: var TParser): PNode =
|
||||||
#| objectPart = IND{>} objectPart^+IND{=} DED
|
#| objectPart = IND{>} objectPart^+IND{=} DED
|
||||||
#| / objectWhen / objectCase / 'nil' / declColonEquals
|
#| / objectWhen / objectCase / 'nil' / 'discard' / declColonEquals
|
||||||
if realInd(p):
|
if realInd(p):
|
||||||
result = newNodeP(nkRecList, p)
|
result = newNodeP(nkRecList, p)
|
||||||
withInd(p):
|
withInd(p):
|
||||||
rawSkipComment(p, result)
|
rawSkipComment(p, result)
|
||||||
while sameInd(p):
|
while sameInd(p):
|
||||||
case p.tok.tokType
|
case p.tok.tokType
|
||||||
of tkCase, tkWhen, tkSymbol, tkAccent, tkNil:
|
of tkCase, tkWhen, tkSymbol, tkAccent, tkNil, tkDiscard:
|
||||||
addSon(result, parseObjectPart(p))
|
addSon(result, parseObjectPart(p))
|
||||||
else:
|
else:
|
||||||
parMessage(p, errIdentifierExpected, p.tok)
|
parMessage(p, errIdentifierExpected, p.tok)
|
||||||
|
|
@ -1704,7 +1704,7 @@ proc parseObjectPart(p: var TParser): PNode =
|
||||||
of tkSymbol, tkAccent:
|
of tkSymbol, tkAccent:
|
||||||
result = parseIdentColonEquals(p, {withPragma})
|
result = parseIdentColonEquals(p, {withPragma})
|
||||||
skipComment(p, result)
|
skipComment(p, result)
|
||||||
of tkNil:
|
of tkNil, tkDiscard:
|
||||||
result = newNodeP(nkNilLit, p)
|
result = newNodeP(nkNilLit, p)
|
||||||
getTok(p)
|
getTok(p)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,7 @@ objectCase = 'case' identWithPragma ':' typeDesc ':'? COMMENT?
|
||||||
(IND{>} objectBranches DED
|
(IND{>} objectBranches DED
|
||||||
| IND{=} objectBranches)
|
| IND{=} objectBranches)
|
||||||
objectPart = IND{>} objectPart^+IND{=} DED
|
objectPart = IND{>} objectPart^+IND{=} DED
|
||||||
/ objectWhen / objectCase / 'nil' / 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')? symbol
|
||||||
typeClass = typeClassParam ^* ',' (pragma)? ('of' typeDesc ^* ',')?
|
typeClass = typeClassParam ^* ',' (pragma)? ('of' typeDesc ^* ',')?
|
||||||
|
|
|
||||||
20
web/news.txt
20
web/news.txt
|
|
@ -2,6 +2,26 @@
|
||||||
News
|
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
|
2014-12-29 Version 0.10.2 released
|
||||||
==================================
|
==================================
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue