✓
Passing This code compiles and runs correctly.
Code
// Test 052: Lenient parsing with multiple errors
// Parser should continue past errors and create parse-error nodes
~tor valid-before {
x: i32
}
// This event has an unclosed brace - should create parse-error node
~tor broken-event {
value: i32
// This event is valid - should still be parsed
~tor valid-after {
y: i32
}
// Another broken event - unclosed annotation
~[unclosed annotation event another_broken {
z: i32
}
// A valid event past the annotation; that recovery is pinned by 210_159
~tor final-valid {
data: string
}
Must fail at frontend compile:
Parsing or type-checking must reject the program.
Expected AST
{
"module_annotations": [],
"items": [
{
"type": "import_decl",
"path": "std/compiler",
"location": {
"file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/052_lenient_multiple_errors/input.kz",
"line": 2,
"col": 0
}
},
{
"type": "host_line",
"module": "input",
"location": {
"file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/052_lenient_multiple_errors/input.kz",
"line": 2,
"col": 0
}
},
{
"type": "host_line",
"module": "input",
"location": {
"file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/052_lenient_multiple_errors/input.kz",
"line": 3,
"col": 0
}
},
{
"type": "event_decl",
"name": "valid-before",
"path": [
"valid-before"
],
"module": "input",
"input": {
"fields": [
{
"name": "x",
"type": "i32",
"is_source": false,
"is_file": false,
"is_embed_file": false,
"is_expression": false,
"is_invocation_meta": false,
"phantom": null
}
]
},
"branches": [],
"location": {
"file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/052_lenient_multiple_errors/input.kz",
"line": 8,
"col": 0
}
},
{
"type": "host_line",
"module": "input",
"location": {
"file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/052_lenient_multiple_errors/input.kz",
"line": 9,
"col": 0
}
},
{
"type": "parse_error",
"code": "PARSE004",
"message": "unmatched '{' in tor shape",
"location": {
"file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/052_lenient_multiple_errors/input.kz",
"line": 9,
"col": 1
},
"raw_text": "~tor broken-event {\n value: i32\n\n// This event is valid - should still be parsed\n"
},
{
"type": "event_decl",
"name": "valid-after",
"path": [
"valid-after"
],
"module": "input",
"input": {
"fields": [
{
"name": "y",
"type": "i32",
"is_source": false,
"is_file": false,
"is_embed_file": false,
"is_expression": false,
"is_invocation_meta": false,
"phantom": null
}
]
},
"branches": [],
"location": {
"file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/052_lenient_multiple_errors/input.kz",
"line": 17,
"col": 0
}
},
{
"type": "host_line",
"module": "input",
"location": {
"file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/052_lenient_multiple_errors/input.kz",
"line": 18,
"col": 0
}
},
{
"type": "parse_error",
"code": "PARSE003",
"message": "unclosed annotation bracket",
"location": {
"file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/052_lenient_multiple_errors/input.kz",
"line": 18,
"col": 1
},
"raw_text": "~[unclosed annotation event another_broken {\n z: i32\n}\n\n// A valid event past the annotation; that recovery is pinned by 210_159\n"
},
{
"type": "event_decl",
"name": "final-valid",
"path": [
"final-valid"
],
"module": "input",
"input": {
"fields": [
{
"name": "data",
"type": "string",
"is_source": false,
"is_file": false,
"is_embed_file": false,
"is_expression": false,
"is_invocation_meta": false,
"phantom": null
}
]
},
"branches": [],
"location": {
"file": "tests/regression/200_COMPILER_FEATURES/210_PARSER/052_lenient_multiple_errors/input.kz",
"line": 27,
"col": 0
}
}
]
}Test Configuration
PARSER_TEST