Change struct literal parsing to use placeholders. (#3850)

This is achieving a similar goal as #3849, using placeholders instead of
an ambiguous start node to clarify structure and incrementally simplify
checking. The benefit isn't quite as big here because both paths are
structs, and so checking is more consistent than paren exprs versus
tuples. But I think this removes the only other multi-purpose parse
node.

This uses StructLiteral/StructTypeLiteral naming, reflecting equivalent
SemIR naming. Note, I would lean towards renaming StructLiteral to
StructValueLiteral, but I think consistency in naming takes precedence.
Any renames of StructLiteral might be better in a separate PR.

StructFieldType/StructFieldValue -> StructTypeField/StructField is
trying to making the reading more consistent with
StructTypeLiteral/StructLiteral. SemIR has StructTypeField but not a
value equivalent.
This commit is contained in:
Jon Ross-Perkins
2024-04-03 20:36:49 +00:00
committed by GitHub
parent b42612bcec
commit a034f86272
31 changed files with 129 additions and 130 deletions
+2 -2
View File
@@ -30,7 +30,7 @@ class ParamAndArgRefsStack {
// On a comma, pushes the most recent instruction, becoming param or arg ref.
// This also pops the NodeStack, meaning its top will remain start_kind.
auto ApplyComma() -> void {
// Support expressions, parameters, and other nodes like `StructFieldValue`
// Support expressions, parameters, and other nodes like `StructField`
// that produce InstIds.
stack_.AddInstId(node_stack_->Pop<SemIR::InstId>());
}
@@ -43,7 +43,7 @@ class ParamAndArgRefsStack {
auto EndNoPop(Parse::NodeKind start_kind) -> void {
if (!node_stack_->PeekIs(start_kind)) {
// Support expressions, parameters, and other nodes like
// `StructFieldValue` that produce InstIds.
// `StructField` that produce InstIds.
stack_.AddInstId(node_stack_->Pop<SemIR::InstId>());
}
}