mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
the parser finally parses 'echo {1,2}' as it should
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Test a submodule
|
||||
|
||||
#type
|
||||
# TStringArr = array [0.. *] of string
|
||||
# TStringArr = array[0.. *] of string
|
||||
|
||||
proc exportme* = discard
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -64,7 +64,7 @@ proc TestLoops() =
|
||||
|
||||
var
|
||||
glob: int
|
||||
a: array [0..5, int]
|
||||
a: array[0..5, int]
|
||||
|
||||
proc main() =
|
||||
#glob = 0
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user