feat: improved parsing and regression test suite

This commit is contained in:
Brett Broadhurst 2026-02-27 18:07:02 -07:00
parent 4ebdd3c66e
commit 619eb3b338
Failed to generate hash of commit
39 changed files with 1116 additions and 339 deletions

View file

@ -0,0 +1,9 @@
set(LIT_CFG_DIR ${CMAKE_CURRENT_SOURCE_DIR})
configure_file(lit.site.cfg.py.in ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py @ONLY)
find_program(LLVM_LIT_EXECUTABLE NAMES llvm-lit lit)
add_custom_target(check
COMMAND ${LLVM_LIT_EXECUTABLE} -v "${CMAKE_CURRENT_BINARY_DIR}"
)

View file

@ -0,0 +1,14 @@
#!/usr/bin/env python3
import os
import lit.formats
config.name = "Ink Compiler Regression Tests"
config.suffixes = [".ink"]
config.tools = ["FileCheck"]
config.test_format = lit.formats.ShTest(execute_external=True)
config.test_source_root = os.path.dirname(__file__)
config.test_exec_root = os.path.join(config.project_build_root, "testing", "regression")
exe_path = os.path.join(config.project_zig_root, "bin", "inkc")
config.substitutions.append(("%ink-compiler", exe_path))

View file

@ -0,0 +1,8 @@
import os
config.project_source_root = r"@CMAKE_SOURCE_DIR@"
config.project_build_root = r"@CMAKE_BINARY_DIR@"
config.project_zig_root = os.path.join(r"@CMAKE_SOURCE_DIR@", "zig-out")
lit_config.load_config(
config, os.path.join(config.project_source_root, "testing", "regression", "lit.cfg.py"))

View file

@ -0,0 +1,11 @@
// RUN: %ink-compiler --stdin --compile-only --dump-ast < %s | FileCheck %s
// CHECK: File "<STDIN>"
// CHECK-NEXT: `--BlockStmt <line:11, line:11>
// CHECK-NEXT: `--ChoiceStmt <line:11, line:11>
// CHECK-NEXT: `--ChoiceStarStmt <line:11, col:1:7>
// CHECK-NEXT: `--ChoiceContentExpr <col:3, col:7>
// CHECK-NEXT: |--ChoiceStartContentExpr `A` <col:3, col:4>
// CHECK-NEXT: `--ChoiceInnerContentExpr `B` <col:6, col:7>
* A[]B

View file

@ -0,0 +1,26 @@
// RUN: %ink-compiler --stdin --compile-only --dump-ast < %s | FileCheck %s
// CHECK: File "<STDIN>"
// CHECK-NEXT: `--BlockStmt <line:22, line:26>
// CHECK-NEXT: `--ChoiceStmt <line:22, line:26>
// CHECK-NEXT: |--ChoiceStarStmt <line:22, col:1:8>
// CHECK-NEXT: | `--ChoiceContentExpr <col:7, col:8>
// CHECK-NEXT: | `--ChoiceStartContentExpr `A` <col:7, col:8>
// CHECK-NEXT: |--ChoiceStarStmt <line:23, col:1:7>
// CHECK-NEXT: | `--ChoiceContentExpr <col:6, col:7>
// CHECK-NEXT: | `--ChoiceStartContentExpr `B` <col:6, col:7>
// CHECK-NEXT: |--ChoiceStarStmt <line:24, col:1:6>
// CHECK-NEXT: | `--ChoiceContentExpr <col:5, col:6>
// CHECK-NEXT: | `--ChoiceStartContentExpr `C` <col:5, col:6>
// CHECK-NEXT: |--ChoiceStarStmt <line:25, col:1:5>
// CHECK-NEXT: | `--ChoiceContentExpr <col:4, col:5>
// CHECK-NEXT: | `--ChoiceStartContentExpr `D` <col:4, col:5>
// CHECK-NEXT: `--ChoiceStarStmt <line:26, col:1:4>
// CHECK-NEXT: `--ChoiceContentExpr <col:3, col:4>
// CHECK-NEXT: `--ChoiceStartContentExpr `E` <col:3, col:4>
***** A
**** B
*** C
** D
* E

View file

@ -0,0 +1,27 @@
// RUN: %ink-compiler --stdin --compile-only --dump-ast < %s | FileCheck %s
// CHECK: File "<STDIN>"
// CHECK-NEXT: `--BlockStmt <line:23, line:27>
// CHECK-NEXT: |--TempDecl <line:23, col:3:13>
// CHECK-NEXT: | |--Identifier `x` <col:8, col:9>
// CHECK-NEXT: | `--NumberLiteral `2` <col:12, col:13>
// CHECK-NEXT: `--ContentStmt <line:25, col:1:48>
// CHECK-NEXT: `--Content <col:1, col:48>
// CHECK-NEXT: `--IfStmt <line:25, line:27>
// CHECK-NEXT: |--LogicalAndExpr <col:2, col:20>
// CHECK-NEXT: | |--LogicalGreaterThanOrEqualExpr <col:2, col:8>
// CHECK-NEXT: | | |--Identifier `x` <col:2, col:3>
// CHECK-NEXT: | | `--NumberLiteral `1` <col:7, col:8>
// CHECK-NEXT: | `--LogicalLesserThanOrEqualExpr <col:13, col:20>
// CHECK-NEXT: | |--Identifier `x` <col:13, col:14>
// CHECK-NEXT: | `--NumberLiteral `10` <col:18, col:20>
// CHECK-NEXT: `--BlockStmt <line:26, line:26>
// CHECK-NEXT: `--ContentStmt <line:26, col:5:25>
// CHECK-NEXT: `--Content <col:5, col:25>
// CHECK-NEXT: `--StringLiteral `Between one and ten!` <col:5, col:25>
~ temp x = 2
{x >= 1 and x <= 10:
Between one and ten!
}

View file

@ -0,0 +1,27 @@
// RUN: %ink-compiler --stdin --compile-only --dump-ast < %s | FileCheck %s
// CHECK: File "<STDIN>"
// CHECK-NEXT: `--BlockStmt <line:23, line:27>
// CHECK-NEXT: |--TempDecl <line:23, col:3:13>
// CHECK-NEXT: | |--Identifier `x` <col:8, col:9>
// CHECK-NEXT: | `--NumberLiteral `2` <col:12, col:13>
// CHECK-NEXT: `--ContentStmt <line:25, col:1:56>
// CHECK-NEXT: `--Content <col:1, col:56>
// CHECK-NEXT: `--IfStmt <line:25, line:27>
// CHECK-NEXT: |--LogicalOrExpr <col:2, col:22>
// CHECK-NEXT: | |--LogicalGreaterThanOrEqualExpr <col:2, col:8>
// CHECK-NEXT: | | |--Identifier `x` <col:2, col:3>
// CHECK-NEXT: | | `--NumberLiteral `1` <col:7, col:8>
// CHECK-NEXT: | `--LogicalEqualityExpr <col:12, col:22>
// CHECK-NEXT: | |--Identifier `x` <col:12, col:13>
// CHECK-NEXT: | `--FalseLiteral <col:17, col:22>
// CHECK-NEXT: `--BlockStmt <line:26, line:26>
// CHECK-NEXT: `--ContentStmt <line:26, col:5:31>
// CHECK-NEXT: `--Content <col:5, col:31>
// CHECK-NEXT: `--StringLiteral `Greater than one or false!` <col:5, col:31>
~ temp x = 2
{x >= 1 or x == false:
Greater than one or false!
}

View file

@ -0,0 +1,23 @@
// RUN: %ink-compiler --stdin --compile-only --dump-ast < %s | FileCheck %s
// CHECK: File "<STDIN>"
// CHECK-NEXT: `--BlockStmt <line:19, line:23>
// CHECK-NEXT: `--ContentStmt <line:19, col:1:52>
// CHECK-NEXT: `--Content <col:1, col:52>
// CHECK-NEXT: `--IfStmt <line:19, line:23>
// CHECK-NEXT: |--TrueLiteral <col:2, col:6>
// CHECK-NEXT: |--BlockStmt <line:20, line:20>
// CHECK-NEXT: | `--ContentStmt <line:20, col:5:18>
// CHECK-NEXT: | `--Content <col:5, col:18>
// CHECK-NEXT: | `--StringLiteral `Hello, world!` <col:5, col:18>
// CHECK-NEXT: `--ElseBranch <col:3, col:13>
// CHECK-NEXT: `--BlockStmt <line:22, line:22>
// CHECK-NEXT: `--ContentStmt <line:22, col:5:17>
// CHECK-NEXT: `--Content <col:5, col:17>
// CHECK-NEXT: `--StringLiteral `Unreachable!` <col:5, col:17>
{true:
Hello, world!
- else:
Unreachable!
}

View file

@ -0,0 +1,16 @@
// RUN: %ink-compiler --stdin --compile-only --dump-ast < %s | FileCheck %s
// CHECK: File "<STDIN>"
// CHECK-NEXT: `--BlockStmt <line:14, line:16>
// CHECK-NEXT: `--ContentStmt <line:14, col:1:27>
// CHECK-NEXT: `--Content <col:1, col:27>
// CHECK-NEXT: `--IfStmt <line:14, line:16>
// CHECK-NEXT: |--TrueLiteral <col:2, col:6>
// CHECK-NEXT: `--BlockStmt <line:15, line:15>
// CHECK-NEXT: `--ContentStmt <line:15, col:5:18>
// CHECK-NEXT: `--Content <col:5, col:18>
// CHECK-NEXT: `--StringLiteral `Hello, world!` <col:5, col:18>
{true:
Hello, world!
}

View file

@ -0,0 +1,43 @@
// RUN: %ink-compiler --stdin --compile-only --dump-ast < %s | FileCheck %s
// CHECK: File "<STDIN>"
// CHECK-NEXT: `--BlockStmt <line:36, line:43>
// CHECK-NEXT: |--TempDecl <line:36, col:3:13>
// CHECK-NEXT: | |--Identifier `x` <col:8, col:9>
// CHECK-NEXT: | `--NumberLiteral `3` <col:12, col:13>
// CHECK-NEXT: `--ContentStmt <line:38, col:1:51>
// CHECK-NEXT: `--Content <col:1, col:51>
// CHECK-NEXT: `--SwitchStmt <line:38, line:43>
// CHECK-NEXT: |--Identifier `x` <col:3, col:4>
// CHECK-NEXT: |--SwitchCase <col:3, col:7>
// CHECK-NEXT: | |--NumberLiteral `0` <col:3, col:4>
// CHECK-NEXT: | `--BlockStmt <line:39, line:39>
// CHECK-NEXT: | `--ContentStmt <line:39, col:7:11>
// CHECK-NEXT: | `--Content <col:7, col:11>
// CHECK-NEXT: | `--StringLiteral `zero` <col:7, col:11>
// CHECK-NEXT: |--SwitchCase <col:3, col:7>
// CHECK-NEXT: | |--NumberLiteral `1` <col:3, col:4>
// CHECK-NEXT: | `--BlockStmt <line:40, line:40>
// CHECK-NEXT: | `--ContentStmt <line:40, col:7:10>
// CHECK-NEXT: | `--Content <col:7, col:10>
// CHECK-NEXT: | `--StringLiteral `one` <col:7, col:10>
// CHECK-NEXT: |--SwitchCase <col:3, col:7>
// CHECK-NEXT: | |--NumberLiteral `2` <col:3, col:4>
// CHECK-NEXT: | `--BlockStmt <line:41, line:41>
// CHECK-NEXT: | `--ContentStmt <line:41, col:7:10>
// CHECK-NEXT: | `--Content <col:7, col:10>
// CHECK-NEXT: | `--StringLiteral `two` <col:7, col:10>
// CHECK-NEXT: `--ElseBranch <col:3, col:9>
// CHECK-NEXT: `--BlockStmt <line:42, line:42>
// CHECK-NEXT: `--ContentStmt <line:42, col:9:13>
// CHECK-NEXT: `--Content <col:9, col:13>
// CHECK-NEXT: `--StringLiteral `lots` <col:9, col:13>
~ temp x = 3
{ x:
- 0: zero
- 1: one
- 2: two
- else: lots
}

View file

@ -0,0 +1 @@
{true: Hello world!}

View file

@ -0,0 +1 @@
CONST foo =

View file

@ -0,0 +1,23 @@
// RUN: %ink-compiler --stdin --compile-only --dump-ast < %s | FileCheck %s
// CHECK: File "<STDIN>"
// CHECK-NEXT: `--BlockStmt <line:21, line:23>
// CHECK-NEXT: |--VarDecl <line:21, col:1:24>
// CHECK-NEXT: | |--Identifier `x` <col:5, col:6>
// CHECK-NEXT: | `--StringExpr `"Hello world 1"` <col:9, col:24>
// CHECK-NEXT: | `--StringLiteral `Hello world 1` <col:10, col:23>
// CHECK-NEXT: |--ContentStmt <line:22, col:1:4>
// CHECK-NEXT: | `--Content <col:1, col:4>
// CHECK-NEXT: | `--InlineLogicExpr <col:1, col:4>
// CHECK-NEXT: | `--Identifier `x` <col:2, col:3>
// CHECK-NEXT: `--ContentStmt <line:23, col:1:19>
// CHECK-NEXT: `--Content <col:1, col:19>
// CHECK-NEXT: |--StringLiteral `Hello ` <col:1, col:7>
// CHECK-NEXT: |--InlineLogicExpr <col:7, col:16>
// CHECK-NEXT: | `--StringExpr `"world"` <col:8, col:15>
// CHECK-NEXT: | `--StringLiteral `world` <col:9, col:14>
// CHECK-NEXT: `--StringLiteral ` 2.` <col:16, col:19>
VAR x = "Hello world 1"
{x}
Hello {"world"} 2.

View file

@ -0,0 +1,9 @@
// RUN: %ink-compiler --stdin --compile-only --dump-ast < %s | FileCheck %s
// CHECK: File "<STDIN>"
// CHECK-NEXT: `--BlockStmt <line:9, line:9>
// CHECK-NEXT: `--ChoiceStmt <line:9, line:9>
// CHECK-NEXT: `--ChoiceStarStmt <line:9, col:1:2>
// CHECK-NEXT: `--ChoiceContentExpr <col:2, col:2>
*

View file

@ -0,0 +1,3 @@
// RUN: %ink-compiler --stdin --compile-only --dump-ast < %s | FileCheck %s
// CHECK: File "<STDIN>"

View file

@ -0,0 +1,12 @@
// RUN: %ink-compiler --stdin --compile-only --dump-ast < %s | FileCheck %s
// CHECK: File "<STDIN>"
// CHECK-NEXT: |--KnotDecl <line:11, line:11>
// CHECK-NEXT: | `--KnotProto <col:1, col:5>
// CHECK-NEXT: | `--Identifier `a` <col:4, col:5>
// CHECK-NEXT: `--KnotDecl <line:12, line:12>
// CHECK-NEXT: `--KnotProto <col:1, col:5>
// CHECK-NEXT: `--Identifier `b` <col:4, col:5>
== a
== b

View file

@ -0,0 +1 @@
~

View file

@ -0,0 +1,16 @@
// RUN: %ink-compiler --stdin --compile-only --dump-ast < %s | FileCheck %s
// CHECK: File "<STDIN>"
// CHECK-NEXT: `--BlockStmt <line:16, line:16>
// CHECK-NEXT: `--ExprStmt <line:16, col:3:20>
// CHECK-NEXT: `--SubtractExpr <col:4, col:20>
// CHECK-NEXT: |--MultiplyExpr <col:4, col:15>
// CHECK-NEXT: | |--AddExpr <col:4, col:10>
// CHECK-NEXT: | | |--NegateExpr <col:4, col:6>
// CHECK-NEXT: | | | `--NumberLiteral `1` <col:5, col:6>
// CHECK-NEXT: | | `--NumberLiteral `2` <col:9, col:10>
// CHECK-NEXT: | `--NumberLiteral `3` <col:14, col:15>
// CHECK-NEXT: `--NegateExpr <col:18, col:20>
// CHECK-NEXT: `--NumberLiteral `4` <col:19, col:20>
~ (-1 + 2) * 3 - -4

View file

@ -0,0 +1,46 @@
// RUN: %ink-compiler --stdin --compile-only --dump-ast < %s | FileCheck %s
// CHECK: File "<STDIN>"
// CHECK-NEXT: |--BlockStmt <line:39, line:39>
// CHECK-NEXT: | `--ContentStmt <line:39, col:1:18>
// CHECK-NEXT: | `--Content <col:1, col:18>
// CHECK-NEXT: | `--InlineLogicExpr <col:1, col:18>
// CHECK-NEXT: | `--CallExpr <col:3, col:17>
// CHECK-NEXT: | |--Identifier `factorial` <col:3, col:12>
// CHECK-NEXT: | `--ArgumentList <col:12, col:17>
// CHECK-NEXT: | `--NumberLiteral `10` <col:13, col:15>
// CHECK-NEXT: `--FunctionDecl <line:41, line:46>
// CHECK-NEXT: |--FunctionProto <col:1, col:25>
// CHECK-NEXT: | |--Identifier `factorial` <col:13, col:22>
// CHECK-NEXT: | `--ParamList <col:22, col:25>
// CHECK-NEXT: | `--ParamDecl `n` <col:23, col:24>
// CHECK-NEXT: `--BlockStmt <line:42, line:46>
// CHECK-NEXT: `--ContentStmt <line:42, col:3:83>
// CHECK-NEXT: `--Content <col:3, col:83>
// CHECK-NEXT: `--IfStmt <line:42, line:46>
// CHECK-NEXT: |--LogicalEqualityExpr <col:5, col:11>
// CHECK-NEXT: | |--Identifier `n` <col:5, col:6>
// CHECK-NEXT: | `--NumberLiteral `1` <col:10, col:11>
// CHECK-NEXT: |--BlockStmt <line:43, line:43>
// CHECK-NEXT: | `--ReturnStmt <line:43, col:9:17>
// CHECK-NEXT: | `--NumberLiteral `1` <col:16, col:17>
// CHECK-NEXT: `--ElseBranch <col:7, col:19>
// CHECK-NEXT: `--BlockStmt <line:45, line:45>
// CHECK-NEXT: `--ReturnStmt <line:45, col:9:38>
// CHECK-NEXT: `--MultiplyExpr <col:17, col:37>
// CHECK-NEXT: |--Identifier `n` <col:17, col:18>
// CHECK-NEXT: `--CallExpr <col:21, col:37>
// CHECK-NEXT: |--Identifier `factorial` <col:21, col:30>
// CHECK-NEXT: `--ArgumentList <col:30, col:37>
// CHECK-NEXT: `--SubtractExpr <col:31, col:36>
// CHECK-NEXT: |--Identifier `n` <col:31, col:32>
// CHECK-NEXT: `--NumberLiteral `1` <col:35, col:36>
{ factorial(10) }
== function factorial(n)
{ n == 1:
~ return 1
- else:
~ return (n * factorial(n - 1))
}

View file

@ -0,0 +1,62 @@
// RUN: %ink-compiler --stdin --compile-only --dump-ast < %s | FileCheck %s
// CHECK: File "<STDIN>"
// CHECK-NEXT: |--BlockStmt <line:52, line:52>
// CHECK-NEXT: | `--ContentStmt <line:52, col:1:12>
// CHECK-NEXT: | `--Content <col:1, col:12>
// CHECK-NEXT: | `--InlineLogicExpr <col:1, col:12>
// CHECK-NEXT: | `--CallExpr <col:3, col:11>
// CHECK-NEXT: | |--Identifier `fib` <col:3, col:6>
// CHECK-NEXT: | `--ArgumentList <col:6, col:11>
// CHECK-NEXT: | `--NumberLiteral `10` <col:7, col:9>
// CHECK-NEXT: `--FunctionDecl <line:54, line:62>
// CHECK-NEXT: |--FunctionProto <col:1, col:19>
// CHECK-NEXT: | |--Identifier `fib` <col:13, col:16>
// CHECK-NEXT: | `--ParamList <col:16, col:19>
// CHECK-NEXT: | `--ParamDecl `n` <col:17, col:18>
// CHECK-NEXT: `--BlockStmt <line:55, line:62>
// CHECK-NEXT: `--ContentStmt <line:55, col:3:121>
// CHECK-NEXT: `--Content <col:3, col:121>
// CHECK-NEXT: `--MultiIfStmt <line:55, line:62>
// CHECK-NEXT: |--IfBranch <col:7, col:21>
// CHECK-NEXT: | |--LogicalEqualityExpr <col:7, col:13>
// CHECK-NEXT: | | |--Identifier `n` <col:7, col:8>
// CHECK-NEXT: | | `--NumberLiteral `0` <col:12, col:13>
// CHECK-NEXT: | `--BlockStmt <line:57, line:57>
// CHECK-NEXT: | `--ReturnStmt <line:57, col:9:17>
// CHECK-NEXT: | `--NumberLiteral `0` <col:16, col:17>
// CHECK-NEXT: |--IfBranch <col:7, col:21>
// CHECK-NEXT: | |--LogicalEqualityExpr <col:7, col:13>
// CHECK-NEXT: | | |--Identifier `n` <col:7, col:8>
// CHECK-NEXT: | | `--NumberLiteral `1` <col:12, col:13>
// CHECK-NEXT: | `--BlockStmt <line:59, line:59>
// CHECK-NEXT: | `--ReturnStmt <line:59, col:9:17>
// CHECK-NEXT: | `--NumberLiteral `1` <col:16, col:17>
// CHECK-NEXT: `--ElseBranch <col:7, col:19>
// CHECK-NEXT: `--BlockStmt <line:61, line:61>
// CHECK-NEXT: `--ReturnStmt <line:61, col:9:39>
// CHECK-NEXT: `--AddExpr <col:16, col:39>
// CHECK-NEXT: |--CallExpr <col:16, col:27>
// CHECK-NEXT: | |--Identifier `fib` <col:16, col:19>
// CHECK-NEXT: | `--ArgumentList <col:19, col:27>
// CHECK-NEXT: | `--SubtractExpr <col:20, col:25>
// CHECK-NEXT: | |--Identifier `n` <col:20, col:21>
// CHECK-NEXT: | `--NumberLiteral `1` <col:24, col:25>
// CHECK-NEXT: `--CallExpr <col:29, col:39>
// CHECK-NEXT: |--Identifier `fib` <col:29, col:32>
// CHECK-NEXT: `--ArgumentList <col:32, col:39>
// CHECK-NEXT: `--SubtractExpr <col:33, col:38>
// CHECK-NEXT: |--Identifier `n` <col:33, col:34>
// CHECK-NEXT: `--NumberLiteral `2` <col:37, col:38>
{ fib(10) }
== function fib(n)
{
- n == 0:
~ return 0
- n == 1:
~ return 1
- else:
~ return fib(n - 1) + fib(n - 2)
}

View file

@ -0,0 +1,28 @@
// RUN: %ink-compiler --stdin --compile-only --dump-ast < %s | FileCheck %s
// CHECK: File "<STDIN>"
// CHECK-NEXT: |--BlockStmt <line:25, line:25>
// CHECK-NEXT: | `--ContentStmt <line:25, col:1:13>
// CHECK-NEXT: | `--Content <col:1, col:13>
// CHECK-NEXT: | `--InlineLogicExpr <col:1, col:13>
// CHECK-NEXT: | `--CallExpr <col:2, col:12>
// CHECK-NEXT: | |--Identifier `func` <col:2, col:6>
// CHECK-NEXT: | `--ArgumentList <col:6, col:12>
// CHECK-NEXT: | |--NumberLiteral `1` <col:7, col:8>
// CHECK-NEXT: | `--NumberLiteral `2` <col:10, col:11>
// CHECK-NEXT: `--FunctionDecl <line:27, line:28>
// CHECK-NEXT: |--FunctionProto <col:1, col:23>
// CHECK-NEXT: | |--Identifier `func` <col:13, col:17>
// CHECK-NEXT: | `--ParamList <col:17, col:23>
// CHECK-NEXT: | |--ParamDecl `a` <col:18, col:19>
// CHECK-NEXT: | `--ParamDecl `b` <col:21, col:22>
// CHECK-NEXT: `--BlockStmt <line:28, line:28>
// CHECK-NEXT: `--ReturnStmt <line:28, col:3:15>
// CHECK-NEXT: `--AddExpr <col:10, col:15>
// CHECK-NEXT: |--Identifier `a` <col:10, col:11>
// CHECK-NEXT: `--Identifier `b` <col:14, col:15>
{func(1, 2)}
== function func(a, b)
~ return a + b

View file

@ -0,0 +1,9 @@
// RUN: %ink-compiler --stdin --compile-only --dump-ast < %s | FileCheck %s
// CHECK: File "<STDIN>"
// CHECK-NEXT: `--BlockStmt <line:9, line:9>
// CHECK-NEXT: `--ContentStmt <line:9, col:1:14>
// CHECK-NEXT: `--Content <col:1, col:14>
// CHECK-NEXT: `--StringLiteral `Hello, world!` <col:1, col:14>
Hello, world!

View file

@ -0,0 +1,2 @@
===
Hello, world!

View file

@ -0,0 +1,34 @@
// RUN: %ink-compiler --stdin --compile-only --dump-ast < %s | FileCheck %s
// CHECK: File "<STDIN>"
// CHECK-NEXT: |--BlockStmt <line:30, line:30>
// CHECK-NEXT: | `--DivertStmt <line:30, col:1:16>
// CHECK-NEXT: | `--Divert <col:1, col:16>
// CHECK-NEXT: | `--CallExpr <col:4, col:16>
// CHECK-NEXT: | |--SelectorExpr <col:4, col:7>
// CHECK-NEXT: | | |--Identifier `a` <col:4, col:5>
// CHECK-NEXT: | | `--Identifier `b` <col:6, col:7>
// CHECK-NEXT: | `--ArgumentList <col:7, col:16>
// CHECK-NEXT: | `--StringExpr `"Brett"` <col:8, col:15>
// CHECK-NEXT: | `--StringLiteral `Brett` <col:9, col:14>
// CHECK-NEXT: `--KnotDecl <line:32, line:34>
// CHECK-NEXT: |--KnotProto <col:1, col:5>
// CHECK-NEXT: | `--Identifier `a` <col:4, col:5>
// CHECK-NEXT: `--StitchDecl <line:33, line:34>
// CHECK-NEXT: |--StitchProto <col:1, col:10>
// CHECK-NEXT: | |--Identifier `b` <col:3, col:4>
// CHECK-NEXT: | `--ParamList <col:4, col:10>
// CHECK-NEXT: | `--ParamDecl `name` <col:5, col:9>
// CHECK-NEXT: `--BlockStmt <line:34, line:34>
// CHECK-NEXT: `--ContentStmt <line:34, col:1:15>
// CHECK-NEXT: `--Content <col:1, col:15>
// CHECK-NEXT: |--StringLiteral `Hello, ` <col:1, col:8>
// CHECK-NEXT: |--InlineLogicExpr <col:8, col:14>
// CHECK-NEXT: | `--Identifier `name` <col:9, col:13>
// CHECK-NEXT: `--StringLiteral `!` <col:14, col:15>
-> a.b("Brett")
== a
= b(name)
Hello, {name}!

View file

@ -0,0 +1,31 @@
// RUN: %ink-compiler --stdin --compile-only --dump-ast < %s | FileCheck %s
// CHECK: File "<STDIN>"
// CHECK-NEXT: `--KnotDecl <line:26, line:31>
// CHECK-NEXT: |--KnotProto <col:1, col:13>
// CHECK-NEXT: | `--Identifier `knot` <col:5, col:9>
// CHECK-NEXT: |--BlockStmt <line:27, line:27>
// CHECK-NEXT: | `--ContentStmt <line:27, col:1:19>
// CHECK-NEXT: | `--Content <col:1, col:19>
// CHECK-NEXT: | `--StringLiteral `Hello from `knot`!` <col:1, col:19>
// CHECK-NEXT: |--StitchDecl <line:28, line:29>
// CHECK-NEXT: | |--StitchProto <col:1, col:4>
// CHECK-NEXT: | | `--Identifier `a` <col:3, col:4>
// CHECK-NEXT: | `--BlockStmt <line:29, line:29>
// CHECK-NEXT: | `--ContentStmt <line:29, col:1:21>
// CHECK-NEXT: | `--Content <col:1, col:21>
// CHECK-NEXT: | `--StringLiteral `Hello from `knot.a`!` <col:1, col:21>
// CHECK-NEXT: `--StitchDecl <line:30, line:31>
// CHECK-NEXT: |--StitchProto <col:1, col:4>
// CHECK-NEXT: | `--Identifier `b` <col:3, col:4>
// CHECK-NEXT: `--BlockStmt <line:31, line:31>
// CHECK-NEXT: `--ContentStmt <line:31, col:1:21>
// CHECK-NEXT: `--Content <col:1, col:21>
// CHECK-NEXT: `--StringLiteral `Hello from `knot.b`!` <col:1, col:21>
=== knot ===
Hello from `knot`!
= a
Hello from `knot.a`!
= b
Hello from `knot.b`!

View file

@ -0,0 +1,17 @@
// RUN: %ink-compiler --stdin --compile-only --dump-ast < %s | FileCheck %s
// CHECK: File "<STDIN>"
// CHECK-NEXT: `--KnotDecl <line:15, line:17>
// CHECK-NEXT: |--KnotProto <col:1, col:13>
// CHECK-NEXT: | `--Identifier `knot` <col:5, col:9>
// CHECK-NEXT: `--StitchDecl <line:16, line:17>
// CHECK-NEXT: |--StitchProto <col:1, col:9>
// CHECK-NEXT: | `--Identifier `stitch` <col:3, col:9>
// CHECK-NEXT: `--BlockStmt <line:17, line:17>
// CHECK-NEXT: `--ContentStmt <line:17, col:1:14>
// CHECK-NEXT: `--Content <col:1, col:14>
// CHECK-NEXT: `--StringLiteral `Hello, world!` <col:1, col:14>
=== knot ===
= stitch
Hello, world!

View file

@ -0,0 +1,13 @@
// RUN: %ink-compiler --stdin --compile-only --dump-ast < %s | FileCheck %s
// CHECK: File "<STDIN>"
// CHECK-NEXT: `--BlockStmt <line:12, line:13>
// CHECK-NEXT: |--TempDecl <line:12, col:3:15>
// CHECK-NEXT: | |--Identifier `a` <col:8, col:9>
// CHECK-NEXT: | `--NumberLiteral `123` <col:12, col:15>
// CHECK-NEXT: `--AssignStmt <line:13, col:3:10>
// CHECK-NEXT: |--Identifier `a` <col:3, col:4>
// CHECK-NEXT: `--NumberLiteral `321` <col:7, col:10>
~ temp a = 123
~ a = 321

View file

@ -0,0 +1,18 @@
// RUN: %ink-compiler --stdin --compile-only --dump-ast < %s | FileCheck %s
// CHECK: File "<STDIN>"
// CHECK-NEXT: `--BlockStmt <line:16, line:18>
// CHECK-NEXT: `--ChoiceStmt <line:16, line:18>
// CHECK-NEXT: |--ChoiceStarStmt <line:16, col:1:4>
// CHECK-NEXT: | `--ChoiceContentExpr <col:3, col:4>
// CHECK-NEXT: | `--ChoiceStartContentExpr `A` <col:3, col:4>
// CHECK-NEXT: |--ChoiceStarStmt <line:17, col:1:4>
// CHECK-NEXT: | `--ChoiceContentExpr <col:3, col:4>
// CHECK-NEXT: | `--ChoiceStartContentExpr `B` <col:3, col:4>
// CHECK-NEXT: `--ChoiceStarStmt <line:18, col:1:4>
// CHECK-NEXT: `--ChoiceContentExpr <col:3, col:4>
// CHECK-NEXT: `--ChoiceStartContentExpr `C` <col:3, col:4>
* A
* B
* C

View file

@ -0,0 +1,13 @@
// RUN: %ink-compiler --stdin --compile-only --dump-ast < %s | FileCheck %s
// CHECK: File "<STDIN>"
// CHECK-NEXT: `--KnotDecl <line:12, line:13>
// CHECK-NEXT: |--KnotProto <col:1, col:13>
// CHECK-NEXT: | `--Identifier `knot` <col:5, col:9>
// CHECK-NEXT: `--BlockStmt <line:13, line:13>
// CHECK-NEXT: `--ContentStmt <line:13, col:1:14>
// CHECK-NEXT: `--Content <col:1, col:14>
// CHECK-NEXT: `--StringLiteral `Hello, world!` <col:1, col:14>
=== knot ===
Hello, world!

View file

@ -0,0 +1,13 @@
// RUN: %ink-compiler --stdin --compile-only --dump-ast < %s | FileCheck %s
// CHECK: File "<STDIN>"
// CHECK-NEXT: `--StitchDecl <line:12, line:13>
// CHECK-NEXT: |--StitchProto <col:1, col:9>
// CHECK-NEXT: | `--Identifier `stitch` <col:3, col:9>
// CHECK-NEXT: `--BlockStmt <line:13, line:13>
// CHECK-NEXT: `--ContentStmt <line:13, col:1:14>
// CHECK-NEXT: `--Content <col:1, col:14>
// CHECK-NEXT: `--StringLiteral `Hello, world!` <col:1, col:14>
= stitch
Hello, world!

View file

@ -0,0 +1 @@
VAR foo =