## Navigation [Top](../Readme.md) <- [docs - General](Readme.md) # AST Types Documentation While the Readme for docs covers the data layout per AST, this will focus on the AST types avaialble, and their nuances. ## Body These are containers representing a scope body of a definition that can be of the following `CodeType` type: * Class_Body * Enum_Body * Export_Body * Extern_Linkage_Body * Function_Body * Global_Body * Namespace_Body * Struct_Body * Union_Body Fields: ```cpp Code Front; Code Back; parser::Token* Tok; Code Parent; StringCached Name; CodeT Type; s32 NumEntries; ``` The `Front` member represents the start of the link list and `Back` the end. NumEntries is the number of entries in the body. Parent should have a compatible ECode type for the type of defintion used. Serialization: Will output only the entries, the braces are handled by the parent. ```cpp ... ``` ## Attributes Represent standard or vendor specific C/C++ attributes. Fields: ```cpp StringCached Content; Code Prev; Code Next; parser::Token* Tok; Code Parent; StringCached Name; CodeT Type; ``` Serialization: ```cpp ``` While the parser supports the `__declspec` and `__attribute__` syntax, the upfront constructor ( def_attributes ) must have the user specify the entire attribute, including the `[[]]`, `__declspec` or `__attribute__` parts. ## Comment Stores a comment. Fields: ```cpp StringCached Content; Code Prev; Code Next; parser::Token* Tok; Code Parent; StringCached Name; CodeT Type; ``` Serialization: ```cpp ``` The parser will perserve comments found if residing with a body or in accepted inline-to-definition locations. Otherwise they will be skipped by the TokArray::__eat and TokArray::current( skip foramtting enabled ) functions. The upfront constructor: `def_comment` expects to recieve a comment without the `//` or `/* */` parts. It will add them during construction. ## Class & Struct Fields: ```cpp CodeComment InlineCmt; // Only supported by forward declarations CodeAttributes Attributes; CodeType ParentType; CodeBody Body; CodeType Prev; // Used to store references to interfaces CodeType Next; // Used to store references to interfaces parser::Token* Tok; Code Parent; StringCached Name; CodeT Type; ModuleFlag ModuleFlags; AccessSpec ParentAccess; ``` Serialization: ```cpp // Class_Fwd ; // Class : , public Next>, ... { }; ``` You'll notice that only one parent type is supported only with parent access. This library only supports single inheritance, the rest must be done through interfaces. ## Constructor Fields: ```cpp CodeComment InlineCmt; // Only supported by forward declarations Code InitializerList; CodeParam Params; Code Body; Code Prev; Code Next; parser::Token* Tok; Code Parent; StringCached Name; CodeT Type; ``` Serialization: ```cpp // Constructor_Fwd Name>( ); // Constructor Name>( ) : { } // Constructor Source Implementation ::~Name>( ) { } ``` ## Define Represents a preprocessor define Fields: ```cpp StringCached Content; Code Prev; Code Next; parser::Token* Tok; Code Parent; StringCached Name; CodeT Type; ``` Serialization: ```cpp #define ``` ## Destructor Fields: ```cpp CodeComment InlineCmt; CodeSpecifiers Specs; Code Body; Code Prev; Code Next; parser::Token* Tok; Code Parent; StringCached Name; CodeT Type; ``` Serialization: ```cpp // Destructor_Fwd ~Name>( ) ; // Destructor ~Name>( ) { } // Destructor Source Implementation ::~Name>( ) { } ``` ## Enum Fields: ```cpp CodeComment InlineCmt; CodeAttributes Attributes; CodeType UnderlyingType; CodeBody Body; Code Prev; Code Next; parser::Token* Tok; Code Parent; StringCached Name; CodeT Type; ModuleFlag ModuleFlags; ``` Serialization: ```cpp // Enum_Fwd enum class : ; // Enum : { }; ``` ## Execution Just represents an execution body. Equivalent to an untyped body. Will be obsolute when function body parsing is implemented. Fields: ```cpp StringCached Content; Code Prev; Code Next; parser::Token* Tok; Code Parent; StringCached Name; CodeT Type; ``` Serialization: ```cpp ``` ## External Linkage Fields: ```cpp CodeBody Body; Code Prev; Code Next; parser::Token* Tok; Code Parent; StringCached Name; CodeT Type; ``` Serialization: ```cpp extern "" { } ``` ## Include Fields: ```cpp StringCached Content; Code Prev; Code Next; Code Parent; parser::Token* Tok; StringCached Name; CodeT Type; ``` Serialization: ```cpp #include ``` ## Friend This library (until its necessary become some third-party library to do otherwise) does not support friend declarations with in-statment function definitions. Fields: ```cpp CodeComment InlineCmt; Code Declaration; Code Prev; Code Next; parser::Token* Tok; Code Parent; StringCached Name; CodeT Type; ``` Serialization: ```cpp friend ; ``` ## Function Fields: ```cpp CodeComment InlineCmt; CodeAttributes Attributes; CodeSpecifiers Specs; CodeType ReturnType; CodeParam Params; CodeBody Body; Code Prev; Code Next; parser::Token* Tok; Code Parent; StringCached Name; CodeT Type; ModuleFlag ModuleFlags; ``` Serialization: ```cpp // Function_Fwd ( ) ; // Function ( ) { } ``` ## Module Fields: ```cpp Code Prev; Code Next; parser::Token* Tok; Code Parent; StringCached Name; CodeT Type; ModuleFlag ModuleFlags; ``` Serialization: ```cpp module ; ``` ## Namespace Fields: ```cpp CodeBody Body; Code Prev; Code Next; parser::Token* Tok; Code Parent; StringCached Name; CodeT Type; ModuleFlag ModuleFlags; ``` Serialization: ```cpp namespace { } ``` ## Operator Overload Fields: ```cpp CodeComment InlineCmt; CodeAttributes Attributes; CodeSpecifiers Specs; CodeType ReturnType; CodeParam Params; CodeBody Body; Code Prev; Code Next; parser::Token* Tok; Code Parent; StringCached Name; CodeT Type; ModuleFlag ModuleFlags; OperatorT Op; ``` Serialization: ```cpp // Operator_Fwd operator ( ) ; // Operator operator ( ) { } ``` ## Operator Cast Overload ( User-Defined Type Conversion ) Fields: ```cpp CodeComment InlineCmt; CodeSpecifiers Specs; CodeType ValueType; CodeBody Body; Code Prev; Code Next; parser::Token* Tok; Code Parent; StringCached Name; CodeT Type; ``` Serialization: ```cpp // Operator_Cast_Fwd operator () ; // Operator_Cast operator () { } ``` ## Parameters (AST_Param) Fields: ```cpp CodeType ValueType; Code Macro; Code Value; CodeParam Last; CodeParam Next; parser::Token* Tok; Code Parent; StringCached Name; CodeT Type; s32 NumEntries; ``` Serialization: ```cpp , ... , ... ``` ## Pragma Fields: ```cpp StringCached Content; Code Prev; Code Next; parser::Token* Tok; Code Parent; StringCached Name; CodeT Type; ``` Serialization: ```cpp #pragma ``` ## Preprocessor Conditional Fields: ```cpp StringCached Content; Code Prev; Code Next; paser::Token* Tok; Code Parent; StringCached Name; CodeT Type; ``` Serialization: ```cpp # ``` ## Specifiers Fields: ```cpp SpecifierT ArrSpecs[ AST_ArrSpecs_Cap ]; CodeSpecifiers NextSpecs; Code Prev; Code Next; parser::Token* Tok; Code Parent; StringCached Name; CodeT Type; s32 NumEntries; ``` Serialization: ```cpp , ... ``` ## Template Fields: ```cpp CodeParam Params; Code Declaration; Code Prev; Code Next; parser::Token* Tok; Code Parent; StringCached Name; CodeT Type; ModuleFlag ModuleFlags; ``` Serialization: ```cpp template< > ``` ## Typename Typenames represent the type "symbol". Fields: ```cpp CodeAttributes Attributes; CodeSpecifiers Specs; CodeReturnType ReturnType; CodeParam Params; Code ArrExpr; Code Prev; Code Next; parser::Token* Tok; Code Parent; StringCached Name; CodeT Type; b32 IsParamPack; ``` Serialization: ```cpp ``` ## Typedef Behave as usual except function or macro typedefs. Those (macros) don't use the underlying type field as everything was serialized under the Name field. Fields: ```cpp CodeComment InlineCmt; Code UnderlyingType; Code Prev; Code Next; parse::Token* Tok Code Parent; StringCached Name; CodeT Type; ModuleFlag ModuleFlags; b32 IsFunction; ``` Serialization: ```cpp // Regular typedef ; // Functions typedef ( ); typedef ( )( ); ``` ## Union Fields: ```cpp CodeAttributes Attributes; CodeBody Body; Code Prev; Code Next; parser::Token* Tok; Code Parent; StringCached Name; CodeT Type; ModuleFlag ModuleFlags; ``` Serialization: ```cpp union { } ``` ## Using Fields: ```cpp CodeComment InlineCmt; CodeAttributes Attributes; CodeType UnderlyingType; Code Prev; Code Next; parser::Token* Tok; Code Parent; StringCached Name; CodeT Type; ModuleFlag ModuleFlags; ``` Serialization: ```cpp // Regular using = ; // Namespace using namespace ; ``` ## Variable [Algo](./Parser_Algo.md:) Fields: ```cpp CodeComment InlineCmt; CodeAttributes Attributes; CodeSpecifiers Specs; CodeType ValueType; Code BitfieldSize; Code Value; CodeVar NextVar; Code Prev; Code Next; parser::Token* Tok; Code Parent; StringCached Name; CodeT Type; ModuleFlag ModuleFlags; ``` Serialization: ```cpp // Regular = , NextVar ...; // Bitfield : = , NextVar ...; ```