parser_state.def 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. //
  5. // Note that this is an X-macro header.
  6. //
  7. // It does not use `#include` guards, and instead is designed to be `#include`ed
  8. // after the x-macro is defined in order for its inclusion to expand to the
  9. // desired output. The x-macro for this header is `CARBON_PARSE_NODE_KIND`. The
  10. // definition provided will be removed at the end of this file to clean up.
  11. #ifndef CARBON_PARSER_STATE
  12. #error "Must define the x-macro to use this file."
  13. #endif
  14. // Handles processing at the `}` on a typical code block, after a statement
  15. // scope is done.
  16. CARBON_PARSER_STATE(CodeBlockFinish)
  17. // Handles processing of a declaration scope. Things like fn, class, interface,
  18. // and so on.
  19. CARBON_PARSER_STATE(Declaration)
  20. // Handles processing of an expression.
  21. CARBON_PARSER_STATE(Expression)
  22. // As with Expression, but specifically uses the Type precedence grouping.
  23. CARBON_PARSER_STATE(ExpressionForType)
  24. // Handles the `;` for an expression statement, which is different from most
  25. // keyword statements.
  26. CARBON_PARSER_STATE(ExpressionStatementFinish)
  27. // Handles processing of a function's `fn <name>(`, and enqueues parameter list
  28. // handling.
  29. CARBON_PARSER_STATE(FunctionIntroducer)
  30. // Handles processing of a function's parameter list `)`.
  31. CARBON_PARSER_STATE(FunctionParameterListFinish)
  32. // Handles processing of a function's syntax after `)`, primarily the
  33. // possibility a `->` return type is there. Always enqueues signature finish
  34. // handling.
  35. CARBON_PARSER_STATE(FunctionAfterParameterList)
  36. // Finishes a function return type.
  37. CARBON_PARSER_STATE(FunctionReturnTypeFinish)
  38. // Finishes a function signature. If it's a declaration, the function is done;
  39. // otherwise, this also starts definition processing.
  40. CARBON_PARSER_STATE(FunctionSignatureFinish)
  41. // Finishes a function definition.
  42. CARBON_PARSER_STATE(FunctionDefinitionFinish)
  43. // StatementFinish variants are just handling the `;` expectation.
  44. CARBON_PARSER_STATE(KeywordStatementFinishForReturn)
  45. // Handles the processing of a `(condition)` up through the expression.
  46. CARBON_PARSER_STATE(ParenCondition)
  47. // Finishes the processing of a `(condition)` after the expression.
  48. CARBON_PARSER_STATE(ParenConditionFinish)
  49. // Handles `if` processing between the condition and start of the first code
  50. // block.
  51. CARBON_PARSER_STATE(StatementIfConditionFinish)
  52. // Handles `if` processing after the end of the first code block, with the
  53. // optional `else`.
  54. CARBON_PARSER_STATE(StatementIfThenBlockFinish)
  55. // Handles `if` processing after a provided `else` code block.
  56. CARBON_PARSER_STATE(StatementIfElseBlockFinish)
  57. // Handles pattern parsing for a function parameter, enqueuing type expression
  58. // processing. Proceeds to the matching Finish state when done.
  59. CARBON_PARSER_STATE(PatternForFunctionParameter)
  60. // Finishes function parameter processing, including `,`. If there are more
  61. // parameters, enqueues another parameter processing state.
  62. CARBON_PARSER_STATE(PatternForFunctionParameterFinish)
  63. // Handles processing of statements within a scope.
  64. CARBON_PARSER_STATE(StatementScope)
  65. #undef CARBON_PARSER_STATE