mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-17 20:00:28 +00:00
Working on toolchain semantics: - SemanticsIR is set up as a container for the semantic tree. - SemanticsIRFactory builds the tree, with separate transformations for each ParseNodeKind. - ParseSubtreeConsumer is a helper for transforming a ParseTree::Node's children, managing size/nodes to prevent errors. - The nodes subdirectory contains SemanticIR nodes. - MetaNode is used to represent nodes which have "sub-classes": Statements, Declarations, and Expressions. - MetaNodeBlock is used to represent nodes which exist together in a block with name lookup: Statements and Declarations (not Expressions). This is traversing children first in order to address the RPO format of ParseTree. This means that when lists are formed, they're reversed to be in code-order (`FixReverseOrdering`). This is still very much incomplete -- the main intent at present is to demonstrate structure.
32 lines
966 B
C++
32 lines
966 B
C++
// 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
|
|
|
|
#ifndef CARBON_TOOLCHAIN_SEMANTICS_NODES_EXPRESSION_STATEMENT_H_
|
|
#define CARBON_TOOLCHAIN_SEMANTICS_NODES_EXPRESSION_STATEMENT_H_
|
|
|
|
#include "common/ostream.h"
|
|
#include "toolchain/parser/parse_tree.h"
|
|
#include "toolchain/semantics/meta_node.h"
|
|
|
|
namespace Carbon::Semantics {
|
|
|
|
// Represents a statement that is only an expression, such as `Call()`.
|
|
class ExpressionStatement {
|
|
public:
|
|
static constexpr StatementKind MetaNodeKind =
|
|
StatementKind::ExpressionStatement;
|
|
|
|
explicit ExpressionStatement(Expression expression)
|
|
: expression_(expression) {}
|
|
|
|
auto expression() const -> Expression { return expression_; }
|
|
|
|
private:
|
|
Expression expression_;
|
|
};
|
|
|
|
} // namespace Carbon::Semantics
|
|
|
|
#endif // CARBON_TOOLCHAIN_SEMANTICS_NODES_EXPRESSION_STATEMENT_H_
|