mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-17 10:18:13 +00:00
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:
1 parent
7824e9618c
commit
a905cdea30
8 files changed
+74
-13
No files matched your search
@@ -959,6 +959,9 @@ auto Parser::HandleExpressionInPostfixState() -> void {
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
// Add a node to keep the parse tree balanced.
|
||||
AddLeafNode(ParseNodeKind::InvalidExpression, *position_,
|
||||
/*has_error=*/true);
|
||||
CARBON_DIAGNOSTIC(ExpectedExpression, Error, "Expected expression.");
|
||||
emitter_->Emit(*position_, ExpectedExpression);
|
||||
ReturnErrorOnState();
|
||||
|
||||
Reference in new issue
Block a user