From ddc131cf07972decc206e033b2dd85a42eb1c98d Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Sat, 30 Sep 2017 21:35:30 +0200 Subject: [PATCH] the parser finally parses 'echo {1,2}' as it should --- compiler/parser.nim | 14 +------------- tests/casestmt/tcomputedgoto.nim | 2 +- tests/constr/tconstr1.nim | 4 ++-- tests/constr/tconstr2.nim | 2 +- tests/macros/tdebugstmt.nim | 2 +- tests/magics/tlowhigh.nim | 2 +- tests/misc/mvarious.nim | 2 +- tests/misc/tnew.nim | 2 +- tests/misc/tradix.nim | 10 +++++----- tests/misc/tstrdesc.nim | 4 ++-- tests/misc/tvarnums.nim | 2 +- tests/stdlib/tmath2.nim | 2 +- tests/stdlib/trepr2.nim | 2 +- tests/stdlib/tstrset.nim | 6 +++--- tests/threads/tthreadanalysis.nim | 2 +- tests/threads/tthreadanalysis2.nim | 2 +- tests/varres/tvarres3.nim | 2 +- tests/vm/tarrayboundeval.nim | 2 +- 18 files changed, 26 insertions(+), 38 deletions(-) diff --git a/compiler/parser.nim b/compiler/parser.nim index 924f7f26c8..e14a8fbdf5 100644 --- a/compiler/parser.nim +++ b/compiler/parser.nim @@ -255,13 +255,6 @@ proc isUnary(p: TParser): bool = p.tok.strongSpaceB == 0 and p.tok.strongSpaceA > 0: result = true - # versions prior to 0.13.0 used to do this: - when false: - if p.strongSpaces: - result = true - else: - parMessage(p, warnDeprecated, - "will be parsed as unary operator; inconsistent spacing") proc checkBinary(p: TParser) {.inline.} = ## Check if the current parser token is a binary operator. @@ -700,12 +693,7 @@ proc primarySuffix(p: var TParser, r: PNode, baseIndent: int): PNode = result = r template somePar() = - if p.tok.strongSpaceA > 0: - if p.strongSpaces: - break - else: - parMessage(p, warnDeprecated, - "a [b] will be parsed as command syntax; spacing") + if p.tok.strongSpaceA > 0: break # progress guaranteed while p.tok.indent < 0 or (p.tok.tokType == tkDot and p.tok.indent >= baseIndent): diff --git a/tests/casestmt/tcomputedgoto.nim b/tests/casestmt/tcomputedgoto.nim index f567174af1..1490729645 100644 --- a/tests/casestmt/tcomputedgoto.nim +++ b/tests/casestmt/tcomputedgoto.nim @@ -18,7 +18,7 @@ type enumA, enumB, enumC, enumD, enumE, enumLast proc vm() = - var instructions: array [0..100, MyEnum] + var instructions: array[0..100, MyEnum] instructions[2] = enumC instructions[3] = enumD instructions[4] = enumA diff --git a/tests/constr/tconstr1.nim b/tests/constr/tconstr1.nim index 28431287c1..b9cf5d00be 100644 --- a/tests/constr/tconstr1.nim +++ b/tests/constr/tconstr1.nim @@ -14,13 +14,13 @@ type proc testSem = var - things: array [0..1, TComplexRecord] = [ + things: array[0..1, TComplexRecord] = [ (s: "hi", x: 69, y: 45, z: 0.0, chars: {'a', 'b', 'c'}), (s: "hi", x: 69, y: 45, z: 1.0, chars: {'a', 'b', 'c'})] write(stdout, things[0].x) const - things: array [0..1, TComplexRecord] = [ + things: array[0..1, TComplexRecord] = [ (s: "hi", x: 69, y: 45, z: 0.0, chars: {'a', 'b', 'c'}), (s: "hi", x: 69, y: 45, z: 1.0)] #ERROR otherThings = [ # the same diff --git a/tests/constr/tconstr2.nim b/tests/constr/tconstr2.nim index cd00681b88..b16be6c507 100644 --- a/tests/constr/tconstr2.nim +++ b/tests/constr/tconstr2.nim @@ -12,7 +12,7 @@ type chars: set[char]] const - things: array [0..1, TComplexRecord] = [ + things: array[0..1, TComplexRecord] = [ (s: "hi", x: 69, y: 45, z: 0.0, chars: {'a', 'b', 'c'}), (s: "hi", x: 69, y: 45, z: 1.0, chars: {})] otherThings = [ # the same diff --git a/tests/macros/tdebugstmt.nim b/tests/macros/tdebugstmt.nim index 740ae7b059..69e6100757 100644 --- a/tests/macros/tdebugstmt.nim +++ b/tests/macros/tdebugstmt.nim @@ -21,7 +21,7 @@ macro debug(n: varargs[untyped]): untyped = add(result, newCall("writeLine", newIdentNode("stdout"), n[i])) var - a: array [0..10, int] + a: array[0..10, int] x = "some string" a[0] = 42 a[1] = 45 diff --git a/tests/magics/tlowhigh.nim b/tests/magics/tlowhigh.nim index 4998b73dc8..60ed13c993 100644 --- a/tests/magics/tlowhigh.nim +++ b/tests/magics/tlowhigh.nim @@ -8,7 +8,7 @@ type myEnum = enum e1, e2, e3, e4, e5 var - a: array [myEnum, int] + a: array[myEnum, int] for i in low(a) .. high(a): a[i] = 0 diff --git a/tests/misc/mvarious.nim b/tests/misc/mvarious.nim index d1587faecf..8efe7c92fd 100644 --- a/tests/misc/mvarious.nim +++ b/tests/misc/mvarious.nim @@ -1,6 +1,6 @@ # Test a submodule #type -# TStringArr = array [0.. *] of string +# TStringArr = array[0.. *] of string proc exportme* = discard diff --git a/tests/misc/tnew.nim b/tests/misc/tnew.nim index 88e8bd02c8..89f34a6213 100644 --- a/tests/misc/tnew.nim +++ b/tests/misc/tnew.nim @@ -9,7 +9,7 @@ type str: string le, ri: PNode - TStressTest = ref array [0..45, array [1..45, TNode]] + TStressTest = ref array[0..45, array[1..45, TNode]] proc finalizer(n: PNode) = write(stdout, n.data) diff --git a/tests/misc/tradix.nim b/tests/misc/tradix.nim index 36a4f39f6a..07674af188 100644 --- a/tests/misc/tradix.nim +++ b/tests/misc/tradix.nim @@ -13,16 +13,16 @@ type kind: TRadixNodeKind TRadixNodeLinear = object of TRadixNode len: int8 - keys: array [0..31, int8] - vals: array [0..31, PRadixNode] + keys: array[0..31, int8] + vals: array[0..31, PRadixNode] TRadixNodeFull = object of TRadixNode - b: array [0..255, PRadixNode] + b: array[0..255, PRadixNode] TRadixNodeLeafBits = object of TRadixNode - b: array [0..7, int] + b: array[0..7, int] TRadixNodeLeafLinear = object of TRadixNode len: int8 - keys: array [0..31, int8] + keys: array[0..31, int8] var root: PRadixNode diff --git a/tests/misc/tstrdesc.nim b/tests/misc/tstrdesc.nim index d231603158..1479fcda83 100644 --- a/tests/misc/tstrdesc.nim +++ b/tests/misc/tstrdesc.nim @@ -1,12 +1,12 @@ var - x: array [0..2, int] + x: array[0..2, int] x = [0, 1, 2] type TStringDesc {.final.} = object len, space: int # len and space without counting the terminating zero - data: array [0..0, char] # for the '\0' character + data: array[0..0, char] # for the '\0' character var emptyString {.exportc: "emptyString".}: TStringDesc diff --git a/tests/misc/tvarnums.nim b/tests/misc/tvarnums.nim index 04a1ef53b4..a5c30c7ebf 100644 --- a/tests/misc/tvarnums.nim +++ b/tests/misc/tvarnums.nim @@ -8,7 +8,7 @@ import strutils type - TBuffer = array [0..10, int8] + TBuffer = array[0..10, int8] proc toVarNum(x: int32, b: var TBuffer) = # encoding: first bit indicates end of number (0 if at end) diff --git a/tests/stdlib/tmath2.nim b/tests/stdlib/tmath2.nim index 84a49efa92..eb0506f5f3 100644 --- a/tests/stdlib/tmath2.nim +++ b/tests/stdlib/tmath2.nim @@ -64,7 +64,7 @@ proc TestLoops() = var glob: int - a: array [0..5, int] + a: array[0..5, int] proc main() = #glob = 0 diff --git a/tests/stdlib/trepr2.nim b/tests/stdlib/trepr2.nim index a920248515..300df565d7 100644 --- a/tests/stdlib/trepr2.nim +++ b/tests/stdlib/trepr2.nim @@ -6,7 +6,7 @@ type TPoint {.final.} = object x, y, z: int - s: array [0..1, string] + s: array[0..1, string] e: TEnum var diff --git a/tests/stdlib/tstrset.nim b/tests/stdlib/tstrset.nim index 15024c3f1c..1b253f8625 100644 --- a/tests/stdlib/tstrset.nim +++ b/tests/stdlib/tstrset.nim @@ -7,10 +7,10 @@ type kind: TRadixNodeKind TRadixNodeLinear = object of TRadixNode len: int8 - keys: array [0..31, char] - vals: array [0..31, PRadixNode] + keys: array[0..31, char] + vals: array[0..31, PRadixNode] TRadixNodeFull = object of TRadixNode - b: array [char, PRadixNode] + b: array[char, PRadixNode] TRadixNodeLeaf = object of TRadixNode s: string PRadixNodeLinear = ref TRadixNodeLinear diff --git a/tests/threads/tthreadanalysis.nim b/tests/threads/tthreadanalysis.nim index 5b0b666ac7..8aacc71d1e 100644 --- a/tests/threads/tthreadanalysis.nim +++ b/tests/threads/tthreadanalysis.nim @@ -9,7 +9,7 @@ discard """ import os var - thr: array [0..5, Thread[tuple[a, b: int]]] + thr: array[0..5, Thread[tuple[a, b: int]]] proc doNothing() = discard diff --git a/tests/threads/tthreadanalysis2.nim b/tests/threads/tthreadanalysis2.nim index 93d169f0bb..c1ec3ae39b 100644 --- a/tests/threads/tthreadanalysis2.nim +++ b/tests/threads/tthreadanalysis2.nim @@ -8,7 +8,7 @@ discard """ import os var - thr: array [0..5, Thread[tuple[a, b: int]]] + thr: array[0..5, Thread[tuple[a, b: int]]] proc doNothing() = discard diff --git a/tests/varres/tvarres3.nim b/tests/varres/tvarres3.nim index 9fcd79bfcd..9a46bfb4e0 100644 --- a/tests/varres/tvarres3.nim +++ b/tests/varres/tvarres3.nim @@ -6,7 +6,7 @@ var g = 5 proc p(): var int = - var bla = addr(g) #: array [0..7, int] + var bla = addr(g) #: array[0..7, int] result = bla[] p() = 45 diff --git a/tests/vm/tarrayboundeval.nim b/tests/vm/tarrayboundeval.nim index af9e33339c..dc8c7ebdc9 100644 --- a/tests/vm/tarrayboundeval.nim +++ b/tests/vm/tarrayboundeval.nim @@ -25,7 +25,7 @@ echo myconst, " ", int((KeyMax + 31) / 32) #bug 1304 or something: -const constArray: array [-3..2, int] = [-3, -2, -1, 0, 1, 2] +const constArray: array[-3..2, int] = [-3, -2, -1, 0, 1, 2] echo constArray[-2]