mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-23 07:22:41 +00:00
Also does `if` support, discussed refactorings, like PopState/PushState instead of edits. With these changes, I'm to where I can start talking about what's still missing: ``` //toolchain/parser/testdata:basics/fail_invalid_designators.carbon.test FAILED in 0.7s //toolchain/parser/testdata:basics/fail_paren_match_regression.carbon.test FAILED in 0.6s //toolchain/parser/testdata:basics/function_call.carbon.test FAILED in 0.7s //toolchain/parser/testdata:basics/package.carbon.test FAILED in 0.7s //toolchain/parser/testdata:basics/structs.carbon.test FAILED in 0.7s //toolchain/parser/testdata:basics/tuples.carbon.test FAILED in 0.6s //toolchain/parser/testdata:basics/var.carbon.test FAILED in 0.7s //toolchain/parser/testdata:for/fail_colon_instead_of_in.carbon.test FAILED in 0.6s //toolchain/parser/testdata:for/fail_missing_in.carbon.test FAILED in 0.6s //toolchain/parser/testdata:for/fail_missing_var.carbon.test FAILED in 0.7s //toolchain/parser/testdata:for/nested.carbon.test FAILED in 0.6s //toolchain/parser/testdata:for/simple.carbon.test FAILED in 0.6s //toolchain/parser/testdata:function/definition/with_params.carbon.test FAILED in 0.7s //toolchain/parser/testdata:operators/associative.carbon.test FAILED in 0.6s //toolchain/parser/testdata:operators/fail_missing_precedence_and_or.carbon.test FAILED in 0.6s //toolchain/parser/testdata:operators/fail_missing_precedence_or_and.carbon.test FAILED in 0.6s //toolchain/parser/testdata:operators/fail_variety.carbon.test FAILED in 0.6s //toolchain/parser/testdata:operators/fixity.carbon.test FAILED in 0.9s //toolchain/parser/testdata:operators/missing_precedence_not.carbon.test FAILED in 0.6s //toolchain/parser/testdata:operators/postfix_unary.carbon.test FAILED in 0.7s //toolchain/parser/testdata:operators/prefix_unary.carbon.test FAILED in 0.7s //toolchain/parser/testdata:while/basic.carbon.test FAILED in 0.6s //toolchain/parser/testdata:while/fail_unbraced.carbon.test FAILED in 0.6s ``` This does modify a couple `if` tests to not test so much expression syntax -- that just seems like unrelated syntax.
88 lines
3.2 KiB
Modula-2
88 lines
3.2 KiB
Modula-2
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
// Note that this is an X-macro header.
|
|
//
|
|
// It does not use `#include` guards, and instead is designed to be `#include`ed
|
|
// after the x-macro is defined in order for its inclusion to expand to the
|
|
// desired output. The x-macro for this header is `CARBON_PARSE_NODE_KIND`. The
|
|
// definition provided will be removed at the end of this file to clean up.
|
|
|
|
#ifndef CARBON_PARSER_STATE
|
|
#error "Must define the x-macro to use this file."
|
|
#endif
|
|
|
|
// Handles processing at the `}` on a typical code block, after a statement
|
|
// scope is done.
|
|
CARBON_PARSER_STATE(CodeBlockFinish)
|
|
|
|
// Handles processing of a declaration scope. Things like fn, class, interface,
|
|
// and so on.
|
|
CARBON_PARSER_STATE(Declaration)
|
|
|
|
// Handles processing of an expression.
|
|
CARBON_PARSER_STATE(Expression)
|
|
|
|
// As with Expression, but specifically uses the Type precedence grouping.
|
|
CARBON_PARSER_STATE(ExpressionForType)
|
|
|
|
// Handles the `;` for an expression statement, which is different from most
|
|
// keyword statements.
|
|
CARBON_PARSER_STATE(ExpressionStatementFinish)
|
|
|
|
// Handles processing of a function's `fn <name>(`, and enqueues parameter list
|
|
// handling.
|
|
CARBON_PARSER_STATE(FunctionIntroducer)
|
|
|
|
// Handles processing of a function's parameter list `)`.
|
|
CARBON_PARSER_STATE(FunctionParameterListFinish)
|
|
|
|
// Handles processing of a function's syntax after `)`, primarily the
|
|
// possibility a `->` return type is there. Always enqueues signature finish
|
|
// handling.
|
|
CARBON_PARSER_STATE(FunctionAfterParameterList)
|
|
|
|
// Finishes a function return type.
|
|
CARBON_PARSER_STATE(FunctionReturnTypeFinish)
|
|
|
|
// Finishes a function signature. If it's a declaration, the function is done;
|
|
// otherwise, this also starts definition processing.
|
|
CARBON_PARSER_STATE(FunctionSignatureFinish)
|
|
|
|
// Finishes a function definition.
|
|
CARBON_PARSER_STATE(FunctionDefinitionFinish)
|
|
|
|
// StatementFinish variants are just handling the `;` expectation.
|
|
CARBON_PARSER_STATE(KeywordStatementFinishForReturn)
|
|
|
|
// Handles the processing of a `(condition)` up through the expression.
|
|
CARBON_PARSER_STATE(ParenCondition)
|
|
|
|
// Finishes the processing of a `(condition)` after the expression.
|
|
CARBON_PARSER_STATE(ParenConditionFinish)
|
|
|
|
// Handles `if` processing between the condition and start of the first code
|
|
// block.
|
|
CARBON_PARSER_STATE(StatementIfConditionFinish)
|
|
|
|
// Handles `if` processing after the end of the first code block, with the
|
|
// optional `else`.
|
|
CARBON_PARSER_STATE(StatementIfThenBlockFinish)
|
|
|
|
// Handles `if` processing after a provided `else` code block.
|
|
CARBON_PARSER_STATE(StatementIfElseBlockFinish)
|
|
|
|
// Handles pattern parsing for a function parameter, enqueuing type expression
|
|
// processing. Proceeds to the matching Finish state when done.
|
|
CARBON_PARSER_STATE(PatternForFunctionParameter)
|
|
|
|
// Finishes function parameter processing, including `,`. If there are more
|
|
// parameters, enqueues another parameter processing state.
|
|
CARBON_PARSER_STATE(PatternForFunctionParameterFinish)
|
|
|
|
// Handles processing of statements within a scope.
|
|
CARBON_PARSER_STATE(StatementScope)
|
|
|
|
#undef CARBON_PARSER_STATE
|