forked from kcl-lang/kcl
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: list and config if expr error recovery in the parser
Signed-off-by: peefy <[email protected]>
- Loading branch information
Showing
8 changed files
with
705 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__list_recovery_13.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
--- | ||
source: parser/src/tests/error_recovery.rs | ||
expression: "crate::tests::parsing_expr_string(r#\"[\n if True:\n b = []\n]\n\"#)" | ||
--- | ||
Node { | ||
node: List( | ||
ListExpr { | ||
elts: [ | ||
Node { | ||
node: ListIfItem( | ||
ListIfItemExpr { | ||
if_cond: Node { | ||
node: NameConstantLit( | ||
NameConstantLit { | ||
value: True, | ||
}, | ||
), | ||
filename: "", | ||
line: 2, | ||
column: 7, | ||
end_line: 2, | ||
end_column: 11, | ||
}, | ||
exprs: [ | ||
Node { | ||
node: Identifier( | ||
Identifier { | ||
names: [ | ||
Node { | ||
node: "b", | ||
filename: "", | ||
line: 3, | ||
column: 8, | ||
end_line: 3, | ||
end_column: 9, | ||
}, | ||
], | ||
pkgpath: "", | ||
ctx: Load, | ||
}, | ||
), | ||
filename: "", | ||
line: 3, | ||
column: 8, | ||
end_line: 3, | ||
end_column: 9, | ||
}, | ||
Node { | ||
node: Missing( | ||
MissingExpr, | ||
), | ||
filename: "", | ||
line: 3, | ||
column: 10, | ||
end_line: 3, | ||
end_column: 11, | ||
}, | ||
Node { | ||
node: List( | ||
ListExpr { | ||
elts: [], | ||
ctx: Load, | ||
}, | ||
), | ||
filename: "", | ||
line: 3, | ||
column: 12, | ||
end_line: 3, | ||
end_column: 14, | ||
}, | ||
], | ||
orelse: None, | ||
}, | ||
), | ||
filename: "", | ||
line: 2, | ||
column: 4, | ||
end_line: 4, | ||
end_column: 0, | ||
}, | ||
], | ||
ctx: Load, | ||
}, | ||
), | ||
filename: "", | ||
line: 1, | ||
column: 0, | ||
end_line: 4, | ||
end_column: 1, | ||
} |
87 changes: 87 additions & 0 deletions
87
kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__list_recovery_14.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
--- | ||
source: parser/src/tests/error_recovery.rs | ||
expression: "crate::tests::parsing_expr_string(r#\"[\n if True:\n b = \n]\n\"#)" | ||
--- | ||
Node { | ||
node: List( | ||
ListExpr { | ||
elts: [ | ||
Node { | ||
node: ListIfItem( | ||
ListIfItemExpr { | ||
if_cond: Node { | ||
node: NameConstantLit( | ||
NameConstantLit { | ||
value: True, | ||
}, | ||
), | ||
filename: "", | ||
line: 2, | ||
column: 7, | ||
end_line: 2, | ||
end_column: 11, | ||
}, | ||
exprs: [ | ||
Node { | ||
node: Identifier( | ||
Identifier { | ||
names: [ | ||
Node { | ||
node: "b", | ||
filename: "", | ||
line: 3, | ||
column: 8, | ||
end_line: 3, | ||
end_column: 9, | ||
}, | ||
], | ||
pkgpath: "", | ||
ctx: Load, | ||
}, | ||
), | ||
filename: "", | ||
line: 3, | ||
column: 8, | ||
end_line: 3, | ||
end_column: 9, | ||
}, | ||
Node { | ||
node: Missing( | ||
MissingExpr, | ||
), | ||
filename: "", | ||
line: 3, | ||
column: 10, | ||
end_line: 3, | ||
end_column: 11, | ||
}, | ||
Node { | ||
node: Missing( | ||
MissingExpr, | ||
), | ||
filename: "", | ||
line: 3, | ||
column: 12, | ||
end_line: 4, | ||
end_column: 0, | ||
}, | ||
], | ||
orelse: None, | ||
}, | ||
), | ||
filename: "", | ||
line: 2, | ||
column: 4, | ||
end_line: 4, | ||
end_column: 0, | ||
}, | ||
], | ||
ctx: Load, | ||
}, | ||
), | ||
filename: "", | ||
line: 1, | ||
column: 0, | ||
end_line: 4, | ||
end_column: 1, | ||
} |
89 changes: 89 additions & 0 deletions
89
kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__list_recovery_15.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
--- | ||
source: parser/src/tests/error_recovery.rs | ||
expression: "crate::tests::parsing_expr_string(r#\"[\n if True:\n b -\n]\n\"#)" | ||
--- | ||
Node { | ||
node: List( | ||
ListExpr { | ||
elts: [ | ||
Node { | ||
node: ListIfItem( | ||
ListIfItemExpr { | ||
if_cond: Node { | ||
node: NameConstantLit( | ||
NameConstantLit { | ||
value: True, | ||
}, | ||
), | ||
filename: "", | ||
line: 2, | ||
column: 7, | ||
end_line: 2, | ||
end_column: 11, | ||
}, | ||
exprs: [ | ||
Node { | ||
node: Binary( | ||
BinaryExpr { | ||
left: Node { | ||
node: Identifier( | ||
Identifier { | ||
names: [ | ||
Node { | ||
node: "b", | ||
filename: "", | ||
line: 3, | ||
column: 8, | ||
end_line: 3, | ||
end_column: 9, | ||
}, | ||
], | ||
pkgpath: "", | ||
ctx: Load, | ||
}, | ||
), | ||
filename: "", | ||
line: 3, | ||
column: 8, | ||
end_line: 3, | ||
end_column: 9, | ||
}, | ||
op: Sub, | ||
right: Node { | ||
node: Missing( | ||
MissingExpr, | ||
), | ||
filename: "", | ||
line: 3, | ||
column: 11, | ||
end_line: 4, | ||
end_column: 0, | ||
}, | ||
}, | ||
), | ||
filename: "", | ||
line: 3, | ||
column: 8, | ||
end_line: 3, | ||
end_column: 11, | ||
}, | ||
], | ||
orelse: None, | ||
}, | ||
), | ||
filename: "", | ||
line: 2, | ||
column: 4, | ||
end_line: 4, | ||
end_column: 0, | ||
}, | ||
], | ||
ctx: Load, | ||
}, | ||
), | ||
filename: "", | ||
line: 1, | ||
column: 0, | ||
end_line: 4, | ||
end_column: 1, | ||
} |
Oops, something went wrong.