handle_index_expr.cpp 871 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. #include "toolchain/parse/handle.h"
  7. namespace Carbon::Parse {
  8. auto HandleIndexExpr(Context& context) -> void {
  9. auto state = context.PopState();
  10. context.PushState(state, StateKind::IndexExprFinish);
  11. context.AddNode(NodeKind::IndexExprStart,
  12. context.ConsumeChecked(Lex::TokenKind::OpenSquareBracket),
  13. state.has_error);
  14. context.PushState(StateKind::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