lex_helper.h 1.0 KB

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. #ifndef CARBON_EXPLORER_SYNTAX_LEX_HELPER_H_
  5. #define CARBON_EXPLORER_SYNTAX_LEX_HELPER_H_
  6. // Flex expands this macro immediately before each action.
  7. //
  8. // Advances the current token position by yyleng columns without changing
  9. // the line number, and takes us out of the after-whitespace / after-operand
  10. // state.
  11. #define YY_USER_ACTION \
  12. context.current_token_position.columns(yyleng); \
  13. if (YY_START == AFTER_WHITESPACE || YY_START == AFTER_OPERAND) { \
  14. BEGIN(INITIAL); \
  15. }
  16. #define CARBON_SIMPLE_TOKEN(name) \
  17. Carbon::Parser::make_##name(context.current_token_position);
  18. #define CARBON_ARG_TOKEN(name, arg) \
  19. Carbon::Parser::make_##name(arg, context.current_token_position);
  20. #endif // CARBON_EXPLORER_SYNTAX_LEX_HELPER_H_