mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01: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:
@@ -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