From c87f1eb5813cca9ce5c1f251d9b3af3a2d47be71 Mon Sep 17 00:00:00 2001 From: Araq Date: Mon, 12 Jan 2015 01:41:53 +0100 Subject: [PATCH] 'discard' can be used instead of 'nil' for empty case object branches --- compiler/parser.nim | 6 +++--- doc/grammar.txt | 2 +- web/news.txt | 20 ++++++++++++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/compiler/parser.nim b/compiler/parser.nim index ff06287e3a..76285b7ec9 100644 --- a/compiler/parser.nim +++ b/compiler/parser.nim @@ -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: diff --git a/doc/grammar.txt b/doc/grammar.txt index e751c2d8dd..2b04e6ca8f 100644 --- a/doc/grammar.txt +++ b/doc/grammar.txt @@ -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 ^* ',')? diff --git a/web/news.txt b/web/news.txt index ee9ad8837a..e077fb53a5 100644 --- a/web/news.txt +++ b/web/news.txt @@ -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 ==================================