mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 07:24:42 +01:00
Add parse support for multiple requirements after where separated by and (#4298)
Follow on to #4275 that added `where` parse support. --------- Co-authored-by: Josh L <josh11b@users.noreply.github.com> Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
co-authored by
Josh L
Richard Smith
parent
6bfaa888e8
commit
d6b2fb1736
@@ -10,6 +10,7 @@ namespace Carbon::Parse {
|
||||
|
||||
auto HandleRequirementBegin(Context& context) -> void {
|
||||
context.PopAndDiscardState();
|
||||
// TODO: Peek ahead for `.designator = ...`, and give it special handling.
|
||||
context.PushState(State::RequirementOperator);
|
||||
context.PushStateForExpr(PrecedenceGroup::ForRequirements());
|
||||
}
|
||||
@@ -69,7 +70,13 @@ auto HandleRequirementOperatorFinish(Context& context) -> void {
|
||||
<< token_kind;
|
||||
return;
|
||||
}
|
||||
// TODO: Handle `and` token.
|
||||
if (state.has_error) {
|
||||
context.ReturnErrorOnState();
|
||||
}
|
||||
if (auto token = context.ConsumeIf(Lex::TokenKind::And)) {
|
||||
context.AddNode(NodeKind::RequirementAnd, *token, /*has_error=*/false);
|
||||
context.PushState(State::RequirementBegin);
|
||||
}
|
||||
}
|
||||
|
||||
auto HandleWhereFinish(Context& context) -> void {
|
||||
|
||||
Reference in New Issue
Block a user