handle_index_expr.cpp 864 B

1234567891011121314151617181920212223242526
  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. state.state = State::IndexExprFinish;
  10. context.PushState(state);
  11. context.AddNode(NodeKind::IndexExprStart,
  12. context.ConsumeChecked(Lex::TokenKind::OpenSquareBracket),
  13. state.subtree_start, state.has_error);
  14. context.PushState(State::Expr);
  15. }
  16. auto HandleIndexExprFinish(Context& context) -> void {
  17. auto state = context.PopState();
  18. context.ConsumeAndAddCloseSymbol(state.token, state, NodeKind::IndexExpr);
  19. }
  20. } // namespace Carbon::Parse