Parse support for where operator (#4275)

Includes support for the `impls`, `=`, and `==` requirement operators to
the right of a `where`, but `and` to allow multiple requirements is
still a TODO.

---------

Co-authored-by: Josh L <josh11b@users.noreply.github.com>
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
josh11b
2024-09-11 03:17:07 +00:00
committed by GitHub
co-authored by Josh L Richard Smith
parent 8fa173b58a
commit c33c9a02f6
19 changed files with 784 additions and 38 deletions
+9
View File
@@ -323,6 +323,15 @@ auto HandleExprLoop(Context& context) -> void {
state.state = State::ExprLoopForShortCircuitOperatorAsOr;
break;
// `where` also needs a virtual parse tree node, and parses its right
// argument in a mode where it can handle requirement operators like
// `impls` and `=`.
case Lex::TokenKind::Where:
context.AddNode(NodeKind::WhereOperand, state.token, state.has_error);
context.PushState(state, State::WhereFinish);
context.PushState(State::RequirementBegin);
return;
default:
state.state = State::ExprLoopForInfixOperator;
break;