the parser finally parses 'echo {1,2}' as it should

This commit is contained in:
Andreas Rumpf 2017-09-30 21:35:30 +02:00
commit ddc131cf07
18 changed files with 26 additions and 38 deletions

View file

@ -255,13 +255,6 @@ proc isUnary(p: TParser): bool =
p.tok.strongSpaceB == 0 and p.tok.strongSpaceB == 0 and
p.tok.strongSpaceA > 0: p.tok.strongSpaceA > 0:
result = true 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.} = proc checkBinary(p: TParser) {.inline.} =
## Check if the current parser token is a binary operator. ## 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 result = r
template somePar() = template somePar() =
if p.tok.strongSpaceA > 0: if p.tok.strongSpaceA > 0: break
if p.strongSpaces:
break
else:
parMessage(p, warnDeprecated,
"a [b] will be parsed as command syntax; spacing")
# progress guaranteed # progress guaranteed
while p.tok.indent < 0 or while p.tok.indent < 0 or
(p.tok.tokType == tkDot and p.tok.indent >= baseIndent): (p.tok.tokType == tkDot and p.tok.indent >= baseIndent):

View file

@ -18,7 +18,7 @@ type
enumA, enumB, enumC, enumD, enumE, enumLast enumA, enumB, enumC, enumD, enumE, enumLast
proc vm() = proc vm() =
var instructions: array [0..100, MyEnum] var instructions: array[0..100, MyEnum]
instructions[2] = enumC instructions[2] = enumC
instructions[3] = enumD instructions[3] = enumD
instructions[4] = enumA instructions[4] = enumA

View file

@ -14,13 +14,13 @@ type
proc testSem = proc testSem =
var 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: 0.0, chars: {'a', 'b', 'c'}),
(s: "hi", x: 69, y: 45, z: 1.0, chars: {'a', 'b', 'c'})] (s: "hi", x: 69, y: 45, z: 1.0, chars: {'a', 'b', 'c'})]
write(stdout, things[0].x) write(stdout, things[0].x)
const 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: 0.0, chars: {'a', 'b', 'c'}),
(s: "hi", x: 69, y: 45, z: 1.0)] #ERROR (s: "hi", x: 69, y: 45, z: 1.0)] #ERROR
otherThings = [ # the same otherThings = [ # the same

View file

@ -12,7 +12,7 @@ type
chars: set[char]] chars: set[char]]
const 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: 0.0, chars: {'a', 'b', 'c'}),
(s: "hi", x: 69, y: 45, z: 1.0, chars: {})] (s: "hi", x: 69, y: 45, z: 1.0, chars: {})]
otherThings = [ # the same otherThings = [ # the same

View file

@ -21,7 +21,7 @@ macro debug(n: varargs[untyped]): untyped =
add(result, newCall("writeLine", newIdentNode("stdout"), n[i])) add(result, newCall("writeLine", newIdentNode("stdout"), n[i]))
var var
a: array [0..10, int] a: array[0..10, int]
x = "some string" x = "some string"
a[0] = 42 a[0] = 42
a[1] = 45 a[1] = 45

View file

@ -8,7 +8,7 @@ type
myEnum = enum e1, e2, e3, e4, e5 myEnum = enum e1, e2, e3, e4, e5
var var
a: array [myEnum, int] a: array[myEnum, int]
for i in low(a) .. high(a): for i in low(a) .. high(a):
a[i] = 0 a[i] = 0

View file

@ -1,6 +1,6 @@
# Test a submodule # Test a submodule
#type #type
# TStringArr = array [0.. *] of string # TStringArr = array[0.. *] of string
proc exportme* = discard proc exportme* = discard

View file

@ -9,7 +9,7 @@ type
str: string str: string
le, ri: PNode 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) = proc finalizer(n: PNode) =
write(stdout, n.data) write(stdout, n.data)

View file

@ -13,16 +13,16 @@ type
kind: TRadixNodeKind kind: TRadixNodeKind
TRadixNodeLinear = object of TRadixNode TRadixNodeLinear = object of TRadixNode
len: int8 len: int8
keys: array [0..31, int8] keys: array[0..31, int8]
vals: array [0..31, PRadixNode] vals: array[0..31, PRadixNode]
TRadixNodeFull = object of TRadixNode TRadixNodeFull = object of TRadixNode
b: array [0..255, PRadixNode] b: array[0..255, PRadixNode]
TRadixNodeLeafBits = object of TRadixNode TRadixNodeLeafBits = object of TRadixNode
b: array [0..7, int] b: array[0..7, int]
TRadixNodeLeafLinear = object of TRadixNode TRadixNodeLeafLinear = object of TRadixNode
len: int8 len: int8
keys: array [0..31, int8] keys: array[0..31, int8]
var var
root: PRadixNode root: PRadixNode

View file

@ -1,12 +1,12 @@
var var
x: array [0..2, int] x: array[0..2, int]
x = [0, 1, 2] x = [0, 1, 2]
type type
TStringDesc {.final.} = object TStringDesc {.final.} = object
len, space: int # len and space without counting the terminating zero 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 var
emptyString {.exportc: "emptyString".}: TStringDesc emptyString {.exportc: "emptyString".}: TStringDesc

View file

@ -8,7 +8,7 @@ import
strutils strutils
type type
TBuffer = array [0..10, int8] TBuffer = array[0..10, int8]
proc toVarNum(x: int32, b: var TBuffer) = proc toVarNum(x: int32, b: var TBuffer) =
# encoding: first bit indicates end of number (0 if at end) # encoding: first bit indicates end of number (0 if at end)

View file

@ -64,7 +64,7 @@ proc TestLoops() =
var var
glob: int glob: int
a: array [0..5, int] a: array[0..5, int]
proc main() = proc main() =
#glob = 0 #glob = 0

View file

@ -6,7 +6,7 @@ type
TPoint {.final.} = object TPoint {.final.} = object
x, y, z: int x, y, z: int
s: array [0..1, string] s: array[0..1, string]
e: TEnum e: TEnum
var var

View file

@ -7,10 +7,10 @@ type
kind: TRadixNodeKind kind: TRadixNodeKind
TRadixNodeLinear = object of TRadixNode TRadixNodeLinear = object of TRadixNode
len: int8 len: int8
keys: array [0..31, char] keys: array[0..31, char]
vals: array [0..31, PRadixNode] vals: array[0..31, PRadixNode]
TRadixNodeFull = object of TRadixNode TRadixNodeFull = object of TRadixNode
b: array [char, PRadixNode] b: array[char, PRadixNode]
TRadixNodeLeaf = object of TRadixNode TRadixNodeLeaf = object of TRadixNode
s: string s: string
PRadixNodeLinear = ref TRadixNodeLinear PRadixNodeLinear = ref TRadixNodeLinear

View file

@ -9,7 +9,7 @@ discard """
import os import os
var var
thr: array [0..5, Thread[tuple[a, b: int]]] thr: array[0..5, Thread[tuple[a, b: int]]]
proc doNothing() = discard proc doNothing() = discard

View file

@ -8,7 +8,7 @@ discard """
import os import os
var var
thr: array [0..5, Thread[tuple[a, b: int]]] thr: array[0..5, Thread[tuple[a, b: int]]]
proc doNothing() = discard proc doNothing() = discard

View file

@ -6,7 +6,7 @@ var
g = 5 g = 5
proc p(): var int = proc p(): var int =
var bla = addr(g) #: array [0..7, int] var bla = addr(g) #: array[0..7, int]
result = bla[] result = bla[]
p() = 45 p() = 45

View file

@ -25,7 +25,7 @@ echo myconst, " ", int((KeyMax + 31) / 32)
#bug 1304 or something: #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] echo constArray[-2]