ast_types.md: Formatting, Updates to AST_Design.md & AST_Types.md

This commit is contained in:
Edward R. Gonzalez 2024-12-16 12:26:17 -05:00
parent 8952cf5f1b
commit 15847f10b9
4 changed files with 368 additions and 347 deletions

View File

@ -53,6 +53,7 @@ StrBuilder <prefix>_to_strbuilder(Code code);
Where the first generates strings allocated using Allocator_StringArena and the other appends an existing strings with their backed allocator. Where the first generates strings allocated using Allocator_StringArena and the other appends an existing strings with their backed allocator.
Serialization of for the AST is defined for `Code` in [`ast.chpp`](../base/components/ast.cpp) with `code_to_strbuilder_ptr` & `code_to_strbuilder`. Serialization of for the AST is defined for `Code` in [`ast.cpp`](../base/components/ast.cpp) with `code_to_strbuilder_ptr` & `code_to_strbuilder`.
Serializtion for the rest of the code types is within [`code_serialization.cpp`](../base/components/code_serialization.cpp). Serializtion for the rest of the code types is within [`code_serialization.cpp`](../base/components/code_serialization.cpp).
Gencpp's serialization does not provide coherent formatting of the code. The user should use a formatter after serializing. Gencpp's serialization does not provide coherent formatting of the code. The user should use a formatter after serializing.

View File

@ -30,7 +30,7 @@ Code Front;
Code Back; Code Back;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
s32 NumEntries; s32 NumEntries;
``` ```
@ -62,7 +62,7 @@ Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
``` ```
Serialization: Serialization:
@ -86,7 +86,7 @@ Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
``` ```
Serialization: Serialization:
@ -114,7 +114,7 @@ CodeType Prev;
CodeType Next; CodeType Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
AccessSpec ParentAccess; AccessSpec ParentAccess;
``` ```
@ -148,7 +148,7 @@ Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
``` ```
Serialization: Serialization:
@ -178,13 +178,14 @@ Represents a preprocessor define
Fields: Fields:
```cpp ```cpp
StrCached Content; CodeDefineParams Params;
Code Body;
StrCached Name; StrCached Name;
Code Prev; Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
``` ```
Serialization: Serialization:
@ -193,6 +194,28 @@ Serialization:
#define <Name> <Content> #define <Name> <Content>
``` ```
## DefineParams
Preprocessor define's parameters.
Fields:
```cpp
StrCached Name;
Code Last;
Code Next;
Token* Tok;
Code Parent;
CodeType Type;
s32 NumEntries;
```
Serialization:
```cpp
<Name>, <Next> ...
```
## Destructor ## Destructor
Fields: Fields:
@ -206,7 +229,7 @@ Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
``` ```
Serialization: Serialization:
@ -243,7 +266,7 @@ Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
StrCached Name; StrCached Name;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
``` ```
@ -277,7 +300,7 @@ Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
``` ```
Serialization: Serialization:
@ -286,7 +309,7 @@ Serialization:
<Content> <Content>
``` ```
## External Linkage ## External Linkage (Extern)
Fields: Fields:
@ -297,7 +320,7 @@ Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
``` ```
Serialization: Serialization:
@ -320,7 +343,7 @@ Code Prev;
Code Next; Code Next;
Code Parent; Code Parent;
Token* Tok; Token* Tok;
CodeT Type; CodeType Type;
``` ```
Serialization: Serialization:
@ -343,7 +366,7 @@ Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
``` ```
Serialization: Serialization:
@ -368,7 +391,7 @@ Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
``` ```
@ -395,7 +418,7 @@ Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
``` ```
@ -416,7 +439,7 @@ Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
``` ```
@ -445,7 +468,7 @@ Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
OperatorT Op; OperatorT Op;
``` ```
@ -477,7 +500,7 @@ Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
``` ```
Serialization: Serialization:
@ -507,7 +530,7 @@ CodeParams Last;
CodeParams Next; CodeParams Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
s32 NumEntries; s32 NumEntries;
``` ```
@ -530,7 +553,7 @@ Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
``` ```
Serialization: Serialization:
@ -550,7 +573,7 @@ Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
``` ```
Serialization: Serialization:
@ -571,7 +594,7 @@ Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
s32 NumEntries; s32 NumEntries;
``` ```
@ -593,7 +616,7 @@ Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
``` ```
@ -622,7 +645,7 @@ Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
StrCached Name; StrCached Name;
CodeT Type; CodeType Type;
b32 IsParamPack; b32 IsParamPack;
ETypenameTag TypeTag; ETypenameTag TypeTag;
``` ```
@ -654,7 +677,7 @@ Code Prev;
Code Next; Code Next;
Token* Tok Token* Tok
Code Parent; Code Parent;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
b32 IsFunction; b32 IsFunction;
``` ```
@ -687,7 +710,7 @@ Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
``` ```
@ -713,7 +736,7 @@ Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
``` ```
@ -746,7 +769,7 @@ Code Prev;
Code Next; Code Next;
Token* Tok; Token* Tok;
Code Parent; Code Parent;
CodeT Type; CodeType Type;
ModuleFlag ModuleFlags; ModuleFlag ModuleFlags;
s32 VarParenthesizedInit; s32 VarParenthesizedInit;
``` ```

View File

@ -85,7 +85,7 @@ https://github.com/Ed94/gencpp/blob/967a044637f1615c709cb723dc61118fcc08dcdb/bas
*`OperatorT` is a typedef for `EOperator::Type` which has an underlying type of `u32`* *`OperatorT` is a typedef for `EOperator::Type` which has an underlying type of `u32`*
*`StrBuilder` is the dynamically allocating string builder type for the library* *`StrBuilder` is the dynamically allocating string builder type for the library*
AST widths are setup to be AST_POD_Size. AST widths are setup to be AST_POD_Size (128 bytes by default).
The width dictates how much the static array can hold before it must give way to using an allocated array: The width dictates how much the static array can hold before it must give way to using an allocated array:
```cpp ```cpp
@ -104,9 +104,6 @@ int AST_ArrSpecs_Cap =
) )
/ sizeof(Specifier) - 1; / sizeof(Specifier) - 1;
``` ```
*Ex: If the AST_POD_Size is 128 the capacity of the static array is 20.*
Data Notes: Data Notes:
* ASTs are wrapped for the user in a Code struct which is a wrapper for a AST* type. * ASTs are wrapped for the user in a Code struct which is a wrapper for a AST* type.