mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Refactor struct literal parse nodes. (#4470)
Split StructComma into StructLiteralComma and StructTypeLiteralComma in order to easily differentiate handling (remains the same in this PR). Add "Literal" to StructField and StructTypeField because it feels inconsistent versus the other non-shared things. StructFieldDesignator remains shared between value literals and type literals. Note I probably would've made StructFieldDesignator non-shared too, but that'd require either a lookahead of 2 (to see the separator`) or a writeback after parsing the separator, neither of which felt especially crucial for this, when what I'm really trying to do is split type literal handling a little further.
This commit is contained in:
@@ -34,13 +34,20 @@ auto HandleParseNode(Context& context,
|
||||
return true;
|
||||
}
|
||||
|
||||
auto HandleParseNode(Context& context, Parse::StructCommaId /*node_id*/)
|
||||
auto HandleParseNode(Context& context, Parse::StructLiteralCommaId /*node_id*/)
|
||||
-> bool {
|
||||
context.param_and_arg_refs_stack().ApplyComma();
|
||||
return true;
|
||||
}
|
||||
|
||||
auto HandleParseNode(Context& context, Parse::StructFieldId node_id) -> bool {
|
||||
auto HandleParseNode(Context& context,
|
||||
Parse::StructTypeLiteralCommaId /*node_id*/) -> bool {
|
||||
context.param_and_arg_refs_stack().ApplyComma();
|
||||
return true;
|
||||
}
|
||||
|
||||
auto HandleParseNode(Context& context, Parse::StructLiteralFieldId node_id)
|
||||
-> bool {
|
||||
auto value_inst_id = context.node_stack().PopExpr();
|
||||
auto [name_node, name_id] = context.node_stack().PopNameWithNodeId();
|
||||
|
||||
@@ -56,7 +63,7 @@ auto HandleParseNode(Context& context, Parse::StructFieldId node_id) -> bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto HandleParseNode(Context& context, Parse::StructTypeFieldId node_id)
|
||||
auto HandleParseNode(Context& context, Parse::StructTypeLiteralFieldId node_id)
|
||||
-> bool {
|
||||
auto [type_node, type_id] = context.node_stack().PopExprWithNodeId();
|
||||
SemIR::TypeId cast_type_id = ExprAsType(context, type_node, type_id).type_id;
|
||||
|
||||
Reference in New Issue
Block a user