mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
Closes #3063 --------- Co-authored-by: Richard Smith <richard@metafoo.co.uk>
28 lines
972 B
C++
28 lines
972 B
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#include "toolchain/lexer/token_kind.h"
|
|
#include "toolchain/parser/parser_context.h"
|
|
|
|
namespace Carbon {
|
|
|
|
auto ParserHandleIndexExpression(ParserContext& context) -> void {
|
|
auto state = context.PopState();
|
|
state.state = ParserState::IndexExpressionFinish;
|
|
context.PushState(state);
|
|
context.AddNode(ParseNodeKind::IndexExpressionStart,
|
|
context.ConsumeChecked(TokenKind::OpenSquareBracket),
|
|
state.subtree_start, state.has_error);
|
|
context.PushState(ParserState::Expression);
|
|
}
|
|
|
|
auto ParserHandleIndexExpressionFinish(ParserContext& context) -> void {
|
|
auto state = context.PopState();
|
|
|
|
context.ConsumeAndAddCloseSymbol(state.token, state,
|
|
ParseNodeKind::IndexExpression);
|
|
}
|
|
|
|
} // namespace Carbon
|