Improve parsing of invalid expressions. (#2726)

This addresses crashes for infix operator expressions, but the approach should more generally yield balanced parsed trees.
This commit is contained in:
Jon Ross-Perkins authored and GitHub committed 2023-03-31 20:51:59 -07:00
1 parent 7824e9618c
commit a905cdea30
8 files changed
+74 -13

No files matched your search

+7 -5
View File
@@ -17,10 +17,11 @@
// CHECK:STDOUT: {kind: 'CodeBlock', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 6},
// CHECK:STDOUT: {kind: 'IfConditionStart', text: '('},
// CHECK:STDOUT: {kind: 'IfCondition', text: ')', has_error: yes, subtree_size: 2},
// CHECK:STDOUT: {kind: 'InvalidExpression', text: ')', has_error: yes},
// CHECK:STDOUT: {kind: 'IfCondition', text: ')', has_error: yes, subtree_size: 3},
// CHECK:STDOUT: {kind: 'CodeBlockStart', text: '{'},
// CHECK:STDOUT: {kind: 'CodeBlock', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 5},
// CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 6},
// CHECK:STDOUT: {kind: 'IfConditionStart', text: '('},
// CHECK:STDOUT: {kind: 'NameReference', text: 'b'},
// CHECK:STDOUT: {kind: 'IfCondition', text: ')', has_error: yes, subtree_size: 3},
@@ -31,9 +32,10 @@
// CHECK:STDOUT: {kind: 'NameReference', text: 'd'},
// CHECK:STDOUT: {kind: 'IfCondition', text: ')', subtree_size: 3},
// CHECK:STDOUT: {kind: 'CodeBlockStart', text: '}', has_error: yes},
// CHECK:STDOUT: {kind: 'CodeBlock', text: '}', has_error: yes, subtree_size: 2},
// CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 6},
// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 29},
// CHECK:STDOUT: {kind: 'InvalidExpression', text: '}', has_error: yes},
// CHECK:STDOUT: {kind: 'CodeBlock', text: '}', has_error: yes, subtree_size: 3},
// CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 7},
// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 31},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]