Change ParameterList to use a Start that brackets params (#2403)

The code change is small here. I'm breaking this out because it has a lot of test churn, and semantics doesn't have significant logic around it yet.
This commit is contained in:
Jon Ross-Perkins
2022-11-17 08:57:22 -08:00
committed by GitHub
parent 5da32bd560
commit fbed1398fe
48 changed files with 98 additions and 103 deletions
+3 -8
View File
@@ -987,11 +987,8 @@ auto Parser::HandleFunctionIntroducerState() -> void {
// function parsing.
state.state = ParserState::FunctionAfterParameterList();
PushState(state);
// TODO: When swapping () start/end, this should AddLeafNode the open before
// continuing.
PushState(ParserState::FunctionParameterListFinish());
// Advance past the open paren.
++position_;
AddLeafNode(ParseNodeKind::ParameterListStart(), Consume());
if (!PositionIs(TokenKind::CloseParen())) {
PushState(ParserState::FunctionParameter());
}
@@ -1021,10 +1018,8 @@ auto Parser::HandleFunctionParameterFinishState() -> void {
auto Parser::HandleFunctionParameterListFinishState() -> void {
auto state = PopState();
CARBON_CHECK(ConsumeAndAddLeafNodeIf(TokenKind::CloseParen(),
ParseNodeKind::ParameterListEnd()))
<< PositionKind().Name();
AddNode(ParseNodeKind::ParameterList(), state.token, state.subtree_start,
CARBON_CHECK(PositionIs(TokenKind::CloseParen())) << PositionKind().Name();
AddNode(ParseNodeKind::ParameterList(), Consume(), state.subtree_start,
state.has_error);
}