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.
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).
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;
Token* Tok;
Code Parent;
CodeT Type;
CodeType Type;
s32 NumEntries;
```
@ -62,7 +62,7 @@ Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
CodeType Type;
```
Serialization:
@ -86,7 +86,7 @@ Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
CodeType Type;
```
Serialization:
@ -114,7 +114,7 @@ CodeType Prev;
CodeType Next;
Token* Tok;
Code Parent;
CodeT Type;
CodeType Type;
ModuleFlag ModuleFlags;
AccessSpec ParentAccess;
```
@ -148,7 +148,7 @@ Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
CodeType Type;
```
Serialization:
@ -178,13 +178,14 @@ Represents a preprocessor define
Fields:
```cpp
StrCached Content;
CodeDefineParams Params;
Code Body;
StrCached Name;
Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
CodeType Type;
```
Serialization:
@ -193,6 +194,28 @@ Serialization:
#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
Fields:
@ -206,7 +229,7 @@ Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
CodeType Type;
```
Serialization:
@ -243,7 +266,7 @@ Code Next;
Token* Tok;
Code Parent;
StrCached Name;
CodeT Type;
CodeType Type;
ModuleFlag ModuleFlags;
```
@ -277,7 +300,7 @@ Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
CodeType Type;
```
Serialization:
@ -286,7 +309,7 @@ Serialization:
<Content>
```
## External Linkage
## External Linkage (Extern)
Fields:
@ -297,7 +320,7 @@ Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
CodeType Type;
```
Serialization:
@ -320,7 +343,7 @@ Code Prev;
Code Next;
Code Parent;
Token* Tok;
CodeT Type;
CodeType Type;
```
Serialization:
@ -343,7 +366,7 @@ Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
CodeType Type;
```
Serialization:
@ -368,7 +391,7 @@ Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
CodeType Type;
ModuleFlag ModuleFlags;
```
@ -395,7 +418,7 @@ Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
CodeType Type;
ModuleFlag ModuleFlags;
```
@ -416,7 +439,7 @@ Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
CodeType Type;
ModuleFlag ModuleFlags;
```
@ -445,7 +468,7 @@ Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
CodeType Type;
ModuleFlag ModuleFlags;
OperatorT Op;
```
@ -477,7 +500,7 @@ Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
CodeType Type;
```
Serialization:
@ -507,7 +530,7 @@ CodeParams Last;
CodeParams Next;
Token* Tok;
Code Parent;
CodeT Type;
CodeType Type;
s32 NumEntries;
```
@ -530,7 +553,7 @@ Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
CodeType Type;
```
Serialization:
@ -550,7 +573,7 @@ Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
CodeType Type;
```
Serialization:
@ -571,7 +594,7 @@ Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
CodeType Type;
s32 NumEntries;
```
@ -593,7 +616,7 @@ Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
CodeType Type;
ModuleFlag ModuleFlags;
```
@ -622,7 +645,7 @@ Code Next;
Token* Tok;
Code Parent;
StrCached Name;
CodeT Type;
CodeType Type;
b32 IsParamPack;
ETypenameTag TypeTag;
```
@ -654,7 +677,7 @@ Code Prev;
Code Next;
Token* Tok
Code Parent;
CodeT Type;
CodeType Type;
ModuleFlag ModuleFlags;
b32 IsFunction;
```
@ -687,7 +710,7 @@ Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
CodeType Type;
ModuleFlag ModuleFlags;
```
@ -713,7 +736,7 @@ Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
CodeType Type;
ModuleFlag ModuleFlags;
```
@ -746,7 +769,7 @@ Code Prev;
Code Next;
Token* Tok;
Code Parent;
CodeT Type;
CodeType Type;
ModuleFlag ModuleFlags;
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`*
*`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:
```cpp
@ -104,9 +104,6 @@ int AST_ArrSpecs_Cap =
)
/ sizeof(Specifier) - 1;
```
*Ex: If the AST_POD_Size is 128 the capacity of the static array is 20.*
Data Notes:
* ASTs are wrapped for the user in a Code struct which is a wrapper for a AST* type.