diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2017-05-16 17:32:18 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-05-16 17:32:18 +0200 |
commit | 503f7806765f0cc6f072f578e272d12d3f9cce56 (patch) | |
tree | f6ad4a0cdf637ae9335f73cae482b3deb36fb353 /tests/parser | |
parent | 224eec595a6112c7aa3a4c06afacc99167580464 (diff) | |
parent | 3e52bb6535a70339cf4a15123be09916ef0c31f6 (diff) | |
download | Nim-503f7806765f0cc6f072f578e272d12d3f9cce56.tar.gz |
Merge branch 'zahary' into araq2
Diffstat (limited to 'tests/parser')
-rw-r--r-- | tests/parser/tpostexprblocks.nim | 513 |
1 files changed, 513 insertions, 0 deletions
diff --git a/tests/parser/tpostexprblocks.nim b/tests/parser/tpostexprblocks.nim new file mode 100644 index 000000000..85f2628bf --- /dev/null +++ b/tests/parser/tpostexprblocks.nim @@ -0,0 +1,513 @@ +discard """ +nimout: ''' +StmtList + Ident !"foo" + Call + Ident !"foo" + Call + Ident !"foo" + Ident !"x" + Command + Ident !"foo" + Ident !"x" + Call + Ident !"foo" + StmtList + DiscardStmt + Empty + Call + Ident !"foo" + StmtList + DiscardStmt + Empty + Call + Ident !"foo" + StrLit test + StmtList + DiscardStmt + Empty + Call + Ident !"foo" + StrLit test + StmtList + DiscardStmt + Empty + Command + Ident !"foo" + StrLit test + StmtList + DiscardStmt + Empty + Command + Ident !"foo" + StrLit test + StmtList + DiscardStmt + Empty + Command + Ident !"foo" + IntLit 1 + Par + Infix + Ident !"+" + IntLit 2 + IntLit 3 + StmtList + DiscardStmt + Empty + Command + Ident !"foo" + IntLit 1 + Par + Infix + Ident !"+" + IntLit 2 + IntLit 3 + StmtList + DiscardStmt + Empty + Call + Ident !"foo" + Do + Empty + Empty + Empty + FormalParams + Empty + IdentDefs + Ident !"x" + Empty + Empty + Empty + Empty + StmtList + DiscardStmt + Empty + Call + Ident !"foo" + Do + Empty + Empty + Empty + FormalParams + Empty + IdentDefs + Ident !"x" + Ident !"int" + Empty + Empty + Empty + StmtList + DiscardStmt + Empty + Call + Ident !"foo" + Do + Empty + Empty + Empty + FormalParams + Ident !"int" + IdentDefs + Ident !"x" + Ident !"int" + Empty + Empty + Empty + StmtList + DiscardStmt + Empty + Command + Ident !"foo" + Ident !"x" + Do + Empty + Empty + Empty + FormalParams + Empty + IdentDefs + Ident !"y" + Empty + Empty + Empty + Empty + StmtList + DiscardStmt + Empty + Call + Ident !"foo" + StmtList + DiscardStmt + Empty + Else + StmtList + DiscardStmt + Empty + Call + Ident !"foo" + StmtList + DiscardStmt + Empty + StmtList + DiscardStmt + Empty + Else + StmtList + DiscardStmt + Empty + Command + Ident !"foo" + Ident !"x" + Do + Empty + Empty + Empty + FormalParams + Empty + IdentDefs + Ident !"y" + Empty + Empty + Empty + Empty + StmtList + DiscardStmt + Empty + Do + Empty + Empty + Empty + FormalParams + Ident !"int" + IdentDefs + Ident !"z" + Empty + Empty + Empty + Empty + StmtList + DiscardStmt + Empty + Do + Empty + Empty + Empty + FormalParams + Ident !"int" + IdentDefs + Ident !"w" + Ident !"int" + Empty + Empty + Empty + StmtList + DiscardStmt + Empty + StmtList + DiscardStmt + Empty + Else + StmtList + DiscardStmt + Empty + Call + Ident !"foo" + Ident !"x" + Call + Ident !"bar" + StmtList + DiscardStmt + Empty + Else + StmtList + DiscardStmt + Empty + VarSection + IdentDefs + Ident !"a" + Empty + Ident !"foo" + VarSection + IdentDefs + Ident !"a" + Empty + Call + Ident !"foo" + VarSection + IdentDefs + Ident !"a" + Empty + Call + Ident !"foo" + Ident !"x" + VarSection + IdentDefs + Ident !"a" + Empty + Command + Ident !"foo" + Ident !"x" + VarSection + IdentDefs + Ident !"a" + Empty + Call + Ident !"foo" + StmtList + DiscardStmt + Empty + VarSection + IdentDefs + Ident !"a" + Empty + Call + Ident !"foo" + StmtList + DiscardStmt + Empty + VarSection + IdentDefs + Ident !"a" + Empty + Call + Ident !"foo" + StmtList + DiscardStmt + Empty + Else + StmtList + DiscardStmt + Empty + VarSection + IdentDefs + Ident !"a" + Empty + Command + Ident !"foo" + Ident !"x" + Do + Empty + Empty + Empty + FormalParams + Empty + IdentDefs + Ident !"y" + Empty + Empty + Empty + Empty + StmtList + DiscardStmt + Empty + Else + StmtList + DiscardStmt + Empty + Asgn + Ident !"a" + Ident !"foo" + Asgn + Ident !"a" + Call + Ident !"foo" + Asgn + Ident !"a" + Call + Ident !"foo" + Ident !"x" + Asgn + Ident !"a" + Command + Ident !"foo" + Ident !"x" + Asgn + Ident !"a" + Call + Ident !"foo" + StmtList + DiscardStmt + Empty + Asgn + Ident !"a" + Call + Ident !"foo" + StmtList + DiscardStmt + Empty + Asgn + Ident !"a" + Call + Ident !"foo" + StmtList + DiscardStmt + Empty + Else + StmtList + DiscardStmt + Empty + Asgn + Ident !"a" + Command + Ident !"foo" + Ident !"x" + Do + Empty + Empty + Empty + FormalParams + Empty + IdentDefs + Ident !"y" + Empty + Empty + Empty + Empty + StmtList + DiscardStmt + Empty + Else + StmtList + DiscardStmt + Empty + Call + DotExpr + Ident !"result" + Ident !"add" + BracketExpr + Call + Ident !"quote" + StmtList + DiscardStmt + Empty + IntLit 0 +''' +""" + +import macros + +dumpTree: + # simple calls + foo + foo() + foo(x) + foo x + + foo: + discard + + foo do: + discard + + foo("test"): + discard + + foo("test") do: + discard + + foo "test": + discard + + foo "test" do: + discard + + # more complicated calls + foo 1, (2+3): + discard + + foo 1, (2+3) do: + discard + + foo do (x): + discard + + foo do (x: int): + discard + + foo do (x: int) -> int: + discard + + foo x do (y): + discard + + # extra blocks + foo: + discard + else: + discard + + foo do: + discard + do: + discard + else: + discard + + foo x do (y): + discard + do (z) -> int: + discard + do (w: int) -> int: + discard + do: + discard + else: + discard + + # call with blocks as a param + foo(x, bar do: + discard + else: + discard + ) + + # introduce a variable + var a = foo + var a = foo() + var a = foo(x) + var a = foo x + + var a = foo: + discard + + var a = foo do: + discard + + var a = foo do: + discard + else: + discard + + var a = foo x do (y): + discard + else: + discard + + # assignments + a = foo + a = foo() + a = foo(x) + a = foo x + + a = foo: + discard + + a = foo do: + discard + + a = foo do: + discard + else: + discard + + a = foo x do (y): + discard + else: + discard + + # some edge cases + result.add((quote do: + discard + )[0]) + |