mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 12:41:06 +01:00
Adds `while` and most of the expression support. Splits apart the fixity test to demonstrate more closely which bits are still failing. ``` //toolchain/parser/testdata:basics/fail_paren_match_regression.carbon.test FAILED in 0.8s //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.7s //toolchain/parser/testdata:for/fail_missing_in.carbon.test FAILED in 0.7s //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.8s //toolchain/parser/testdata:function/definition/with_params.carbon.test FAILED in 0.8s //toolchain/parser/testdata:operators/fixity_in_call.carbon.test FAILED in 0.7s //toolchain/parser/testdata:operators/fixity_in_var.carbon.test FAILED in 0.8s ``` Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
113 lines
4.1 KiB
Modula-2
113 lines
4.1 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 a designator expression, such as `.z` in `x.(y.z)`.
|
|
CARBON_PARSER_STATE(DesignatorExpression)
|
|
|
|
// Handles processing of an expression.
|
|
CARBON_PARSER_STATE(Expression)
|
|
|
|
// Handles processing of an expression.
|
|
CARBON_PARSER_STATE(ExpressionLoop)
|
|
CARBON_PARSER_STATE(ExpressionLoopForBinary)
|
|
CARBON_PARSER_STATE(ExpressionLoopForPrefix)
|
|
|
|
// Handles the initial part of postfix expressions, such as an identifier or
|
|
// literal value, then proceeds to the loop.
|
|
CARBON_PARSER_STATE(ExpressionInPostfix)
|
|
|
|
// Handles looping through elements following the initial postfix expression,
|
|
// such as designators or parenthesized parameters.
|
|
CARBON_PARSER_STATE(ExpressionInPostfixLoop)
|
|
|
|
// 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)
|
|
|
|
// 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 `break` processing at the `;`.
|
|
CARBON_PARSER_STATE(StatementBreakFinish)
|
|
|
|
// Handles `continue` processing at the `;`.
|
|
CARBON_PARSER_STATE(StatementContinueFinish)
|
|
|
|
// 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 `return` processing at the `;`.
|
|
CARBON_PARSER_STATE(StatementReturnFinish)
|
|
|
|
// Handles `while` processing between the condition and start of the code block.
|
|
CARBON_PARSER_STATE(StatementWhileConditionFinish)
|
|
|
|
// Handles `while` processing after the end of the code block.
|
|
CARBON_PARSER_STATE(StatementWhileBlockFinish)
|
|
|
|
// 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(StatementScopeLoop)
|
|
|
|
#undef CARBON_PARSER_STATE
|