mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-15 16:28:10 +00:00
Lex and parse support for ... statements and expand. (#7832)
No support for `each` yet, but this should be enough that we can try out an implementation approach supporting expanding a statement across elements of a tuple without building "real" variadics. Assisted-by: Claude via Antigravity
This commit is contained in:
1 parent
ae5d1efd13
commit
2ec4bab59b
12 files changed
+958
-430
No files matched your search
@@ -51,6 +51,12 @@ auto HandleStatement(Context& context) -> void {
|
||||
context.PushState(StateKind::MatchIntroducer);
|
||||
break;
|
||||
}
|
||||
case Lex::TokenKind::PeriodPeriodPeriod: {
|
||||
context.PushState(StateKind::StatementPackExpansionFinish);
|
||||
context.AddLeafNode(NodeKind::PackExpansionStart, context.Consume());
|
||||
context.PushState(StateKind::Statement);
|
||||
break;
|
||||
}
|
||||
#define CARBON_PARSE_NODE_KIND(Name)
|
||||
#define CARBON_PARSE_NODE_KIND_TOKEN_MODIFIER(Name) case Lex::TokenKind::Name:
|
||||
#include "toolchain/parse/node_kind.def"
|
||||
@@ -228,6 +234,13 @@ auto HandleStatementReturnFinish(Context& context) -> void {
|
||||
HandleStatementKeywordFinish(context, NodeKind::ReturnStatement);
|
||||
}
|
||||
|
||||
auto HandleStatementPackExpansionFinish(Context& context) -> void {
|
||||
auto state = context.PopState();
|
||||
|
||||
context.AddNode(NodeKind::PackExpansionStatement, state.token,
|
||||
state.has_error);
|
||||
}
|
||||
|
||||
auto HandleStatementScopeLoop(Context& context) -> void {
|
||||
// This maintains the current state until we're at the end of the scope.
|
||||
|
||||
|
||||
Reference in new issue
Block a user