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.
This commit is contained in:
Jon Ross-Perkins
2022-06-15 12:40:07 -07:00
committed by GitHub
parent 9512a9fcc1
commit 4113ec8a67
31 changed files with 1532 additions and 143 deletions
+5
View File
@@ -75,6 +75,11 @@ auto ParseTree::node_token(Node n) const -> TokenizedBuffer::Token {
return node_impls_[n.index_].token;
}
auto ParseTree::node_subtree_size(Node n) const -> int32_t {
CARBON_CHECK(n.is_valid());
return node_impls_[n.index_].subtree_size;
}
auto ParseTree::GetNodeText(Node n) const -> llvm::StringRef {
CARBON_CHECK(n.is_valid());
return tokens_->GetTokenText(node_impls_[n.index_].token);