Lex/parse support for ->?, :?, and form literals (#6695)

See #5389 (pending) for the language design.
This commit is contained in:
Geoff Romer
2026-02-07 02:41:22 +00:00
committed by GitHub
parent 1382a8645a
commit 7938d9a8d0
31 changed files with 758 additions and 195 deletions
+10
View File
@@ -25,6 +25,10 @@ auto HandleFunctionAfterParams(Context& context) -> void {
context.PushState(StateKind::FunctionReturnTypeFinish);
context.ConsumeAndDiscard();
context.PushStateForExpr(PrecedenceGroup::ForType());
} else if (context.PositionIs(Lex::TokenKind::MinusGreaterQuestion)) {
context.PushState(StateKind::FunctionReturnFormFinish);
context.ConsumeAndDiscard();
context.PushStateForExpr(PrecedenceGroup::ForType());
}
}
@@ -34,6 +38,12 @@ auto HandleFunctionReturnTypeFinish(Context& context) -> void {
context.AddNode(NodeKind::ReturnType, state.token, state.has_error);
}
auto HandleFunctionReturnFormFinish(Context& context) -> void {
auto state = context.PopState();
context.AddNode(NodeKind::ReturnForm, state.token, state.has_error);
}
auto HandleFunctionSignatureFinish(Context& context) -> void {
auto state = context.PopState();