summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2018-11-08 09:15:07 +0100
committerAndreas Rumpf <rumpf_a@web.de>2018-11-08 09:15:15 +0100
commit5845716df8c96157a047c2bd6bcdd795a7a2b9b1 (patch)
tree66cfa82840b65899586f4a29bac0afe2ede5c2d6 /compiler
parent05683e3aab430abdaeefba144a07f468d33aa8ee (diff)
downloadNim-5845716df8c96157a047c2bd6bcdd795a7a2b9b1.tar.gz
fixes parsing regressions; binary 'not' for 'not nil' must stay
Diffstat (limited to 'compiler')
-rw-r--r--compiler/parser.nim19
1 files changed, 17 insertions, 2 deletions
diff --git a/compiler/parser.nim b/compiler/parser.nim
index a48b2d41e..dab10ae00 100644
--- a/compiler/parser.nim
+++ b/compiler/parser.nim
@@ -1254,14 +1254,29 @@ proc primary(p: var TParser, mode: TPrimaryMode): PNode =
     if mode != pmSkipSuffix:
       result = primarySuffix(p, result, baseInd, mode)
 
+proc binaryNot(p: var TParser; a: PNode): PNode =
+  if p.tok.tokType == tkNot:
+    let notOpr = newIdentNodeP(p.tok.ident, p)
+    getTok(p)
+    optInd(p, notOpr)
+    let b = parseExpr(p)
+    result = newNodeP(nkCommand, p)
+    result.add notOpr
+    result.add a
+    result.add b
+  else:
+    result = a
+
 proc parseTypeDesc(p: var TParser): PNode =
-  #| typeDesc = simpleExpr
+  #| typeDesc = simpleExpr ('not' expr)?
   result = simpleExpr(p, pmTypeDesc)
+  result = binaryNot(p, result)
 
 proc parseTypeDefAux(p: var TParser): PNode =
-  #| typeDefAux = simpleExpr
+  #| typeDefAux = simpleExpr ('not' expr)?
   #|            | 'concept' typeClass
   result = simpleExpr(p, pmTypeDef)
+  result = binaryNot(p, result)
 
 proc makeCall(n: PNode): PNode =
   ## Creates a call if the given node isn't already a call.