mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 20:11:12 +01:00
Avoid speculatively pushing a pattern block in impl handling (#4943)
To do this, we restructure the parse tree to make `forall` a leaf node that comes before the parameter list. --------- Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
This commit is contained in:
co-authored by
Jon Ross-Perkins
parent
95f2140a04
commit
f502e8d6ff
@@ -27,7 +27,7 @@ auto HandleImplAfterIntroducer(Context& context) -> void {
|
||||
if (context.PositionIs(Lex::TokenKind::Forall)) {
|
||||
// forall [<implicit parameter list>] ...
|
||||
context.PushState(State::ImplAfterForall);
|
||||
context.ConsumeAndDiscard();
|
||||
context.AddLeafNode(NodeKind::Forall, context.Consume());
|
||||
if (context.PositionIs(Lex::TokenKind::OpenSquareBracket)) {
|
||||
context.PushState(State::PatternListAsImplicit);
|
||||
} else {
|
||||
@@ -53,7 +53,6 @@ auto HandleImplAfterForall(Context& context) -> void {
|
||||
if (state.has_error) {
|
||||
context.ReturnErrorOnState();
|
||||
}
|
||||
context.AddNode(NodeKind::ImplForall, state.token, state.has_error);
|
||||
// One of:
|
||||
// as <expression> ...
|
||||
// <expression> as <expression>...
|
||||
|
||||
Reference in New Issue
Block a user