summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorClyybber <darkmine956@gmail.com>2020-09-09 07:36:31 +0200
committerGitHub <noreply@github.com>2020-09-09 07:36:31 +0200
commitf3552b86c15ea487910c71f75f31d0a25d0e5890 (patch)
treec3630606ba49bb5193bb18c4c99ca0d0d6e4bb87 /tests
parent10988d48407e96b707b28c5900fcb0e59354e00a (diff)
downloadNim-f3552b86c15ea487910c71f75f31d0a25d0e5890.tar.gz
Better semiStmtList parsing (#15123)
* Better semiStmtList parsing
* Add examples from forums and wiki
* Move parseIfExpr near parseIfOrWhen
* Update grammar
Diffstat (limited to 'tests')
-rw-r--r--tests/parser/tstmtlists.nim165
1 files changed, 165 insertions, 0 deletions
diff --git a/tests/parser/tstmtlists.nim b/tests/parser/tstmtlists.nim
new file mode 100644
index 000000000..b6c7e4a94
--- /dev/null
+++ b/tests/parser/tstmtlists.nim
@@ -0,0 +1,165 @@
+discard """
+  output: '''
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+hello
+1
+hello
+2
+hello
+3
+hello
+4
+hello
+5
+hello
+6
+hello
+7
+hello
+8
+hello
+9
+hello
+10
+hello
+1
+hello
+2
+hello
+3
+hello
+4
+hello
+5
+hello
+6
+hello
+7
+hello
+8
+hello
+9
+hello
+10
+'''
+"""
+
+block: (
+  discard;
+  echo 1 + 1;
+  )
+
+block: (
+  discard; #Haha
+    #haha
+  echo 1 + 1;
+)
+
+block: (
+  discard;
+  #Hmm
+  echo 1 +
+    1;
+)
+
+block: (
+  discard
+  echo "2"
+)
+
+block: (
+  discard;
+  echo 1 +
+    1
+)
+
+block: (
+  discard
+  echo 1 +
+    1
+)
+
+block: (
+  discard;
+  discard
+)
+
+block: (
+  discard
+  echo 1 + 1;
+  )
+
+block: (
+  discard
+  echo 1 + 1;
+)
+
+block: (
+  discard
+  echo 1 +
+    1;
+)
+
+block: (
+  discard;
+    )
+
+block: ( discard; echo 1 + #heh
+                         1;
+)
+
+for i in 1..10:
+    echo "hello"
+    echo i
+
+for i in 1..10: (
+    echo "hello";
+    echo i;
+)
+
+proc square(inSeq: seq[float]): seq[float] = (
+  result = newSeq[float](len(inSeq));
+  for i, v in inSeq: (
+    result[i] = v * v;
+  )
+)
+
+proc square2(inSeq: seq[float]): seq[float] =
+  result = newSeq[float](len(inSeq));
+  for i, v in inSeq: (
+    result[i] = v * v;
+  )
+
+proc cstringCheck(tracked: int; n: int) =
+  if true == false and (let a = high(int); let b = high(int);
+      a.int8 == 8 and a.int8 notin {3..9}):
+    echo(tracked, n)
+
+template dim: int =
+  (if int.high == 0:
+    int.high
+  else:
+    int.high)
+
+template dim2: int =
+  (if int.high == 0:
+    int.high
+   else:
+    int.high)
+
+template dim: int =
+  (
+   if int.high == 0:
+     int.high
+   else:
+     int.high)
+