|
|
4 år sedan | |
|---|---|---|
| .. | ||
| BUILD | 1b4c81fa69 Add script for generating missing C++ deps (#1012) | 4 år sedan |
| README.md | 6c3e1f6d7c Revise README and add subdir READMEs (#1023) | 4 år sedan |
| ast.h | f75b4d322f Handle use-before-declare in static name lookup (#967) | 4 år sedan |
| ast_node.cpp | 7a5b8434c8 Define a base class for all AST nodes. (#947) | 4 år sedan |
| ast_node.h | 8e6c209a28 Use resolved names in typechecker (#974) | 4 år sedan |
| ast_rtti.txt | 8e6c209a28 Use resolved names in typechecker (#974) | 4 år sedan |
| ast_test_matchers.h | dc5e62fc7a Support parsing and testing unimplemented expressions (#957) | 4 år sedan |
| ast_test_matchers_internal.cpp | 92903afbd5 clang-tidy pass on executable_semantics (#963) | 4 år sedan |
| ast_test_matchers_internal.h | 92903afbd5 clang-tidy pass on executable_semantics (#963) | 4 år sedan |
| ast_test_matchers_test.cpp | eda43faa5a Note namespace and static recommendations in C++ style guide (#1041) | 4 år sedan |
| declaration.cpp | dc5e62fc7a Support parsing and testing unimplemented expressions (#957) | 4 år sedan |
| declaration.h | 461e178273 Store named constant values in the AST (#1011) | 4 år sedan |
| expression.cpp | dc5e62fc7a Support parsing and testing unimplemented expressions (#957) | 4 år sedan |
| expression.h | c311c8849c Use static name resolution in Interpreter (#1022) | 4 år sedan |
| expression_test.cpp | eda43faa5a Note namespace and static recommendations in C++ style guide (#1041) | 4 år sedan |
| library_name.h | a03536a196 Add syntax for package and library (#792) | 4 år sedan |
| member.cpp | 7a5b8434c8 Define a base class for all AST nodes. (#947) | 4 år sedan |
| member.h | 50263483d8 Add name accessor to NamedEntityView (#994) | 4 år sedan |
| paren_contents.h | bb28d37eed Drop support for named tuple fields (#886) | 4 år sedan |
| pattern.cpp | 50263483d8 Add name accessor to NamedEntityView (#994) | 4 år sedan |
| pattern.h | 461e178273 Store named constant values in the AST (#1011) | 4 år sedan |
| pattern_test.cpp | eda43faa5a Note namespace and static recommendations in C++ style guide (#1041) | 4 år sedan |
| source_location.h | 6ae85bd13a Initial batch of AST matchers. (#953) | 4 år sedan |
| statement.cpp | 50263483d8 Add name accessor to NamedEntityView (#994) | 4 år sedan |
| statement.h | 461e178273 Store named constant values in the AST (#1011) | 4 år sedan |
| static_scope.cpp | 8e6c209a28 Use resolved names in typechecker (#974) | 4 år sedan |
| static_scope.h | 461e178273 Store named constant values in the AST (#1011) | 4 år sedan |
| value_category.h | c89ce1d570 Handle identifier value category properly. (#986) | 4 år sedan |
The code in this directory defines the AST that represents Carbon code in the
rest of executable-semantics.
All node types in the AST are derived from AstNode, and use
LLVM-style RTTI to support
safe down-casting and similar operations. Each abstract class Foo in the
hierarchy has a kind method which returns a enum FooKind that identifies the
concrete type of the object, and a FooKind value can be safely static_casted
to BarKind if that value represents a type that's derived from both Foo and
Bar.
We rely on code generation to help enforce those invariants, so every node type
must be described in ast_rtti.txt. See the documentation in
(gen_rtti.py)[../gen_rtti.py], the code generation script, for details about
the file format and generated code.
The AST class hierarchy is structured in a fairly unsurprising way, with
abstract classes such as Statement and Expression, and concrete classes
representing individual syntactic constructs, such as If for if-statements.
Sometimes it is useful to work with a subset of node types that "cuts across"
the primary class hierarchy. Rather than deal with the pitfalls of multiple
inheritance, we handle these cases using a form of type erasure: we specify a
notional interface that those types conform to, and then define a "view" class
that behaves like a pointer to an instance of that interface. Types declare that
they model an interface Foo by defining a public static member named
ImplementsCarbonFoo. See NamedEntityView for an example of
this pattern.