Reorganize interface parsing to be more consistent with other declarations. (#2646)

The comments in parse_node_kind.def capture the change being made here.

Before:

```
//   _external_: DeclaredName
//     InterfaceBodyStart
//     _external_: statements
//   InterfaceBodyEnd
// InterfaceDefinition
```

After:

```
//     InterfaceIntroducer
//     DeclaredName
//   InterfaceDefinitionStart
//   _external_: declarations
// InterfaceDefinition
```

Really I just want to treat introduced things consistently. `var` defines my philosophy here: it doesn't always have a `DeclaredName`, so the `VarIntroducer` _must_ be the bounding node. By being consistent with that, I believe that overall the structure becomes easier to understand (that is, there are fewer inconsistencies to understand).

This also adds InterfaceDeclaration, since I think it can be predicted we'll have that, and it's helpful for making recover consistent with HandleDeclarationError.

Similarly, I'm also trying to standardize the loop processing a little with HandleDeclarationLoop. In the current approach, InterfaceDefinitionFinish isn't a necessary state, so I'm removing it.
This commit is contained in:
Jon Ross-Perkins
2023-03-06 16:31:01 -08:00
committed by GitHub
parent bfe5c36bfc
commit 4083d7f5b9
12 changed files with 266 additions and 252 deletions
@@ -576,15 +576,9 @@ auto SemanticsParseTreeHandler::HandleInfixOperator(ParseTree::Node parse_node)
return true;
}
auto SemanticsParseTreeHandler::HandleInterfaceBody(ParseTree::Node parse_node)
-> bool {
emitter_->Emit(parse_node, SemanticsTodo, "HandleInterfaceBody");
return false;
}
auto SemanticsParseTreeHandler::HandleInterfaceBodyStart(
auto SemanticsParseTreeHandler::HandleInterfaceDeclaration(
ParseTree::Node parse_node) -> bool {
emitter_->Emit(parse_node, SemanticsTodo, "HandleInterfaceBodyStart");
emitter_->Emit(parse_node, SemanticsTodo, "HandleInterfaceDeclaration");
return false;
}
@@ -594,6 +588,18 @@ auto SemanticsParseTreeHandler::HandleInterfaceDefinition(
return false;
}
auto SemanticsParseTreeHandler::HandleInterfaceDefinitionStart(
ParseTree::Node parse_node) -> bool {
emitter_->Emit(parse_node, SemanticsTodo, "HandleInterfaceDefinitionStart");
return false;
}
auto SemanticsParseTreeHandler::HandleInterfaceIntroducer(
ParseTree::Node parse_node) -> bool {
emitter_->Emit(parse_node, SemanticsTodo, "HandleInterfaceIntroducer");
return false;
}
auto SemanticsParseTreeHandler::HandleLiteral(ParseTree::Node parse_node)
-> bool {
auto token = parse_tree_->node_token(parse_node);