handle_index_expr.cpp 848 B

12345678910111213141516171819202122232425
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #include "toolchain/lex/token_kind.h"
  5. #include "toolchain/parse/context.h"
  6. namespace Carbon::Parse {
  7. auto HandleIndexExpr(Context& context) -> void {
  8. auto state = context.PopState();
  9. context.PushState(state, State::IndexExprFinish);
  10. context.AddNode(NodeKind::IndexExprStart,
  11. context.ConsumeChecked(Lex::TokenKind::OpenSquareBracket),
  12. state.subtree_start, state.has_error);
  13. context.PushState(State::Expr);
  14. }
  15. auto HandleIndexExprFinish(Context& context) -> void {
  16. auto state = context.PopState();
  17. context.ConsumeAndAddCloseSymbol(state.token, state, NodeKind::IndexExpr);
  18. }
  19. } // namespace Carbon::Parse