WIP : Various changes to project before small hiatus. (Broken)

I need to manually review these as the changes have various errors that are difficult to diagnose why.

I took a break to do handmade hero and now a bit rusty.
This commit is contained in:
2023-09-25 12:12:11 -04:00
parent 4b48b96a79
commit a8708abf8b
18 changed files with 277 additions and 155 deletions

View File

@ -11,7 +11,6 @@ char const* AST::debug_str()
{
String result = String::make_reserve( GlobalAllocator, kilobytes(1) );
#if 1
if ( Parent )
result.append_fmt( "\n\tParent : %S %S", Parent->type_str(), Name ? Name : "" );
else
@ -20,7 +19,6 @@ char const* AST::debug_str()
result.append_fmt( "\n\tName : %S", Name ? Name : "Null" );
result.append_fmt( "\n\tType : %S", type_str() );
result.append_fmt( "\n\tModule Flags : %S", to_str( ModuleFlags ) );
result.append_fmt( "\n\tToken : %d", Token );
switch ( Type )
{
@ -71,6 +69,19 @@ char const* AST::debug_str()
result.append_fmt( "\n\tBody : %S", Body ? Body->debug_str() : "Null" );
break;
case Class_Fwd:
case Struct_Fwd:
if ( Prev )
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name );
if ( Next )
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name );
result.append_fmt( "\n\tInlineCmd : %S", InlineCmt ? InlineCmt->Content : "Null" );
result.append_fmt( "\n\tAttributes : %S", Attributes ? Attributes->to_string() : "Null" );
result.append_fmt( "\n\tParentAccess: %s", ParentType ? to_str( ParentAccess ) : "No Parent" );
result.append_fmt( "\n\tParentType : %s", ParentType ? ParentType->type_str() : "Null" );
break;
case Constructor:
if ( Prev )
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name );
@ -84,6 +95,18 @@ char const* AST::debug_str()
result.append_fmt( "\n\tBody : %S", Body ? Body->debug_str() : "Null" );
break;
case Constructor_Fwd:
if ( Prev )
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name );
if ( Next )
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name );
result.append_fmt( "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
result.append_fmt( "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
result.append_fmt( "\n\tInitializerList: %S", InitializerList ? InitializerList->to_string() : "Null" );
result.append_fmt( "\n\tParams : %S", Params ? Params->to_string() : "Null" );
break;
case Destructor:
if ( Prev )
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name );
@ -95,7 +118,11 @@ char const* AST::debug_str()
result.append_fmt( "\n\tBody : %S", Body ? Body->debug_str() : "Null" );
break;
case Destructor_Fwd:
break;
case Enum:
case Enum_Class:
if ( Prev )
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name );
if ( Next )
@ -107,6 +134,10 @@ char const* AST::debug_str()
result.append_fmt( "\n\tBody : %S", Body ? Body->debug_str() : "Null" );
break;
case Enum_Class_Fwd:
break;
case Extern_Linkage:
case Namespace:
if ( Prev )
@ -275,7 +306,6 @@ char const* AST::debug_str()
result.append_fmt( "\n\tNextVar : %S", NextVar ? NextVar->debug_str() : "Null" );
break;
}
#endif
return result;
}
@ -334,43 +364,37 @@ String AST::to_string()
if ( bitfield_is_equal( u32, ModuleFlags, ModuleFlag::Export ))
result.append( "export " );
if ( Attributes || ParentType )
result.append( "class " );
if ( Attributes )
{
result.append( "class " );
result.append_fmt( "%S ", Attributes->to_string() );
}
if ( Attributes )
if ( ParentType )
{
char const* access_level = to_str( ParentAccess );
result.append_fmt( "%S : %s %S", Name, access_level, ParentType );
CodeType interface = ParentType->Next->cast< CodeType >();
if ( interface )
result.append( "\n" );
while ( interface )
{
result.append_fmt( "%S ", Attributes->to_string() );
}
if ( ParentType )
{
char const* access_level = to_str( ParentAccess );
result.append_fmt( "%S : %s %S", Name, access_level, ParentType );
CodeType interface = ParentType->Next->cast< CodeType >();
if ( interface )
result.append( "\n" );
while ( interface )
{
result.append_fmt( ", %S", interface.to_string() );
interface = interface->Next ? interface->Next->cast< CodeType >() : Code { nullptr };
}
result.append_fmt( "\n{\n%S\n}", Body->to_string() );
}
else
{
result.append_fmt( "%S \n{\n%S\n}", Name, Body->to_string() );
result.append_fmt( ", %S", interface.to_string() );
interface = interface->Next ? interface->Next->cast< CodeType >() : Code { nullptr };
}
}
else
if ( InlineCmt )
{
result.append_fmt( "class %S\n{\n%S\n}", Name, Body->to_string() );
result.append_fmt( " // %S", InlineCmt->Content );
}
result.append_fmt( "\n{\n%S\n}", Body->to_string() );
if ( Parent == nullptr || ( Parent->Type != ECode::Typedef && Parent->Type != ECode::Variable ) )
result.append(";\n");
}
@ -409,6 +433,9 @@ String AST::to_string()
if ( InitializerList )
result.append_fmt( " : %S", InitializerList->to_string() );
if ( InlineCmt )
result.append_fmt( " // %S", InlineCmt->Content );
result.append_fmt( "\n{\n%S\n}\n", Body->to_string() );
}
break;
@ -930,56 +957,39 @@ String AST::to_string()
if ( bitfield_is_equal( u32, ModuleFlags, ModuleFlag::Export ))
result.append( "export " );
if ( Name == nullptr)
result.append( "struct " );
if ( Attributes )
{
result.append_fmt( "struct\n{\n%S\n};\n", Body->to_string() );
break;
result.append_fmt( "%S ", Attributes->to_string() );
}
if ( Attributes || ParentType )
if ( ParentType )
{
result.append( "struct " );
char const* access_level = to_str( ParentAccess );
if ( Attributes )
result.append_fmt( "%S ", Attributes->to_string() );
result.append_fmt( "%S : %s %S", Name, access_level, ParentType );
if ( ParentType )
CodeType interface = ParentType->Next->cast< CodeType >();
if ( interface )
result.append( "\n" );
while ( interface )
{
char const* access_level = to_str( ParentAccess );
result.append_fmt( "%S : %s %S", Name, access_level, ParentType );
CodeType interface = ParentType->Next->cast< CodeType >();
if ( interface )
result.append( "\n" );
while ( interface )
{
result.append_fmt( ", %S", interface.to_string() );
interface = interface->Next ? interface->Next->cast< CodeType >() : Code { nullptr };
}
result.append_fmt( "\n{\n%S\n}", Body->to_string() );
}
else
{
if ( Name )
result.append_fmt( "%S \n{\n%S\n}", Name, Body->to_string() );
result.append_fmt( ", %S", interface.to_string() );
interface = interface->Next ? interface->Next->cast< CodeType >() : Code { nullptr };
}
}
else
if ( InlineCmt )
{
result.append_fmt( "struct %S\n{\n%S\n}", Name, Body->to_string() );
result.append_fmt( " // %S", InlineCmt->Content );
}
result.append_fmt( "\n{\n%S\n}", Body->to_string() );
if ( Parent == nullptr || ( Parent->Type != ECode::Typedef && Parent->Type != ECode::Variable ) )
{
if ( InlineCmt )
result.append_fmt("; %S", InlineCmt->Content );
else
result.append(";\n");
}
result.append(";\n");
}
break;

View File

@ -67,6 +67,11 @@ struct CodeUnion;
struct CodeUsing;
struct CodeVar;
// namespace Parser
// {
// struct Token;
// }
/*
AST* wrapper
- Not constantly have to append the '*' as this is written often..
@ -82,7 +87,7 @@ struct Code
static Code Invalid;
# pragma endregion Statics
# define Using_Code( Typename ) \
# define Using_Code( Typename ) \
char const* debug_str(); \
Code duplicate(); \
bool is_equal( Code other ); \
@ -108,7 +113,7 @@ struct Code
return ast;
}
Code& operator ++();
Code& operator*()
auto& operator*()
{
return *this;
}
@ -157,7 +162,7 @@ struct Code_POD
static_assert( sizeof(Code) == sizeof(Code_POD), "ERROR: Code is not POD" );
// Desired width of the AST data structure.
constexpr u32 AST_POD_Size = 128;
constexpr int AST_POD_Size = 128;
/*
Simple AST POD with functionality to seralize into C++ syntax.
@ -214,17 +219,20 @@ struct AST
# pragma endregion Member Functions
constexpr static
uw ArrSpecs_Cap =
int ArrSpecs_Cap =
#if 1
(
AST_POD_Size
- sizeof(AST*) * 4
- sizeof(StringCached)
- sizeof(CodeT)
- sizeof(void*) * 4
// - sizeof(Parser::Token*)
// - sizeof(AST*)
- sizeof(void*)
- sizeof(int)
- sizeof(ModuleFlag)
- sizeof(u32)
- sizeof(s32)
- sizeof(int)
)
/ sizeof(SpecifierT); // -1 for 4 extra bytes
#endif
union {
struct
@ -251,13 +259,13 @@ struct AST
};
union {
AST* NextVar; // Variable; Possible way to handle comma separated variables declarations. ( , NextVar->Specs NextVar->Name NextVar->ArrExpr = NextVar->Value )
AST* SpecsFuncSuffix; // Only used with typenames, to store the function suffix if typename is function signature.
AST* SpecsFuncSuffix; // Only used with typenames, to store the function suffix if typename is function signature. ( May not be needed )
};
};
StringCached Content; // Attributes, Comment, Execution, Include
struct {
SpecifierT ArrSpecs[AST::ArrSpecs_Cap]; // Specifiers
AST* NextSpecs; // Specifiers
AST* NextSpecs; // Specifiers; If ArrSpecs is full, then NextSpecs is used.
};
};
union {
@ -269,6 +277,7 @@ struct AST
AST* Next;
AST* Back;
};
// Parser::Token* Token; // Reference to starting token, only avaialble if it was derived from parsing.
AST* Parent;
StringCached Name;
CodeT Type;
@ -280,7 +289,6 @@ struct AST
AccessSpec ParentAccess;
s32 NumEntries;
};
s32 Token; // Handle to the token, stored in the CodeFile (Otherwise unretrivable)
};
struct AST_POD
@ -310,13 +318,13 @@ struct AST_POD
};
union {
AST* NextVar; // Variable; Possible way to handle comma separated variables declarations. ( , NextVar->Specs NextVar->Name NextVar->ArrExpr = NextVar->Value )
AST* SpecsFuncSuffix; // Only used with typenames, to store the function suffix if typename is function signature.
AST* SpecsFuncSuffix; // Only used with typenames, to store the function suffix if typename is function signature. ( May not be needed )
};
};
StringCached Content; // Attributes, Comment, Execution, Include
struct {
SpecifierT ArrSpecs[AST::ArrSpecs_Cap]; // Specifiers
AST* NextSpecs; // Specifiers
AST* NextSpecs; // Specifiers; If ArrSpecs is full, then NextSpecs is used.
};
};
union {
@ -328,6 +336,7 @@ struct AST_POD
AST* Next;
AST* Back;
};
// Parser::Token* Token; // Reference to starting token, only avaialble if it was derived from parsing.
AST* Parent;
StringCached Name;
CodeT Type;
@ -339,9 +348,11 @@ struct AST_POD
AccessSpec ParentAccess;
s32 NumEntries;
};
s32 Token; // Handle to the token, stored in the CodeFile (Otherwise unretrivable)
};
constexpr int specifierT_size = sizeof(SpecifierT);
constexpr int AST_SIZE = sizeof(AST);
// Its intended for the AST to have equivalent size to its POD.
// All extra functionality within the AST namespace should just be syntatic sugar.
static_assert( sizeof(AST) == sizeof(AST_POD), "ERROR: AST IS NOT POD" );

View File

@ -15,14 +15,14 @@ struct AST_Body
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
Code Front;
Code Back;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
s32 NumEntries;
s32 Token;
};
static_assert( sizeof(AST_Body) == sizeof(AST), "ERROR: AST_Filtered is not the same size as AST");
static_assert( sizeof(AST_Body) == sizeof(AST), "ERROR: AST_Body is not the same size as AST");
struct AST_Attributes
{
@ -32,11 +32,11 @@ struct AST_Attributes
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
s32 Token;
};
static_assert( sizeof(AST_Attributes) == sizeof(AST), "ERROR: AST_Attributes is not the same size as AST");
@ -48,11 +48,11 @@ struct AST_Comment
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
s32 Token;
};
static_assert( sizeof(AST_Comment) == sizeof(AST), "ERROR: AST_Comment is not the same size as AST");
@ -73,12 +73,12 @@ struct AST_Class
};
CodeType Prev;
CodeType Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
ModuleFlag ModuleFlags;
AccessSpec ParentAccess;
s32 Token;
};
static_assert( sizeof(AST_Class) == sizeof(AST), "ERROR: AST_Class is not the same size as AST");
@ -99,11 +99,11 @@ struct AST_Constructor
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
char _PAD_NAME_[ sizeof(StringCached) ];
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
s32 Token;
};
static_assert( sizeof(AST_Constructor) == sizeof(AST), "ERROR: AST_Constructor is not the same size as AST");
@ -115,11 +115,11 @@ struct AST_Define
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
s32 Token;
};
static_assert( sizeof(AST_Define) == sizeof(AST), "ERROR: AST_Define is not the same size as AST");
@ -139,11 +139,11 @@ struct AST_Destructor
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
char _PAD_NAME_[ sizeof(StringCached) ];
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
s32 Token;
};
static_assert( sizeof(AST_Destructor) == sizeof(AST), "ERROR: AST_Destructor is not the same size as AST");
@ -164,12 +164,12 @@ struct AST_Enum
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
ModuleFlag ModuleFlags;
char _PAD_UNUSED_[ sizeof(u32) ];
s32 Token;
};
static_assert( sizeof(AST_Enum) == sizeof(AST), "ERROR: AST_Enum is not the same size as AST");
@ -181,11 +181,11 @@ struct AST_Exec
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
s32 Token;
};
static_assert( sizeof(AST_Exec) == sizeof(AST), "ERROR: AST_Exec is not the same size as AST");
@ -202,11 +202,11 @@ struct AST_Extern
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
s32 Token;
};
static_assert( sizeof(AST_Extern) == sizeof(AST), "ERROR: AST_Extern is not the same size as AST");
@ -218,11 +218,11 @@ struct AST_Include
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
s32 Token;
};
static_assert( sizeof(AST_Include) == sizeof(AST), "ERROR: AST_Include is not the same size as AST");
@ -240,11 +240,11 @@ struct AST_Friend
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
s32 Token;
};
static_assert( sizeof(AST_Friend) == sizeof(AST), "ERROR: AST_Friend is not the same size as AST");
@ -264,13 +264,13 @@ struct AST_Fn
};
};
Code Prev;
Code Parent;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
ModuleFlag ModuleFlags;
char _PAD_UNUSED_[ sizeof(u32) ];
s32 Token;
};
static_assert( sizeof(AST_Fn) == sizeof(AST), "ERROR: AST_Fn is not the same size as AST");
@ -279,12 +279,12 @@ struct AST_Module
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
ModuleFlag ModuleFlags;
char _PAD_UNUSED_[ sizeof(u32) ];
s32 Token;
};
static_assert( sizeof(AST_Module) == sizeof(AST), "ERROR: AST_Module is not the same size as AST");
@ -300,12 +300,12 @@ struct AST_NS
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
ModuleFlag ModuleFlags;
char _PAD_UNUSED_[ sizeof(u32) ];
s32 Token;
};
static_assert( sizeof(AST_NS) == sizeof(AST), "ERROR: AST_NS is not the same size as AST");
@ -324,14 +324,14 @@ struct AST_Operator
char _PAD_PROPERTIES_ [ sizeof(AST*) ];
};
};
Code Prev;
Code Next;
Code Parent;
StringCached Name;
CodeT Type;
ModuleFlag ModuleFlags;
OperatorT Op;
s32 Token;
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
ModuleFlag ModuleFlags;
OperatorT Op;
};
static_assert( sizeof(AST_Operator) == sizeof(AST), "ERROR: AST_Operator is not the same size as AST");
@ -352,11 +352,11 @@ struct AST_OpCast
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
s32 Token;
};
static_assert( sizeof(AST_OpCast) == sizeof(AST), "ERROR: AST_OpCast is not the same size as AST");
@ -375,12 +375,12 @@ struct AST_Param
};
CodeParam Last;
CodeParam Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
s32 NumEntries;
s32 Token;
};
static_assert( sizeof(AST_Param) == sizeof(AST), "ERROR: AST_Param is not the same size as AST");
@ -392,11 +392,11 @@ struct AST_Pragma
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
s32 Token;
};
static_assert( sizeof(AST_Pragma) == sizeof(AST), "ERROR: AST_Pragma is not the same size as AST");
@ -408,11 +408,11 @@ struct AST_PreprocessCond
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ];
s32 Token;
};
static_assert( sizeof(AST_PreprocessCond) == sizeof(AST), "ERROR: AST_PreprocessCond is not the same size as AST");
@ -422,12 +422,12 @@ struct AST_Specifiers
CodeSpecifiers NextSpecs;
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
s32 NumEntries;
s32 Token;
};
static_assert( sizeof(AST_Specifiers) == sizeof(AST), "ERROR: AST_Specifier is not the same size as AST");
@ -448,12 +448,12 @@ struct AST_Struct
};
CodeType Prev;
CodeType Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
ModuleFlag ModuleFlags;
AccessSpec ParentAccess;
s32 Token;
};
static_assert( sizeof(AST_Struct) == sizeof(AST), "ERROR: AST_Struct is not the same size as AST");
@ -471,12 +471,12 @@ struct AST_Template
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
ModuleFlag ModuleFlags;
char _PAD_UNUSED_[ sizeof(u32) ];
s32 Token;
};
static_assert( sizeof(AST_Template) == sizeof(AST), "ERROR: AST_Template is not the same size as AST");
@ -497,12 +497,12 @@ struct AST_Type
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
b32 IsParamPack;
s32 Token;
};
static_assert( sizeof(AST_Type) == sizeof(AST), "ERROR: AST_Type is not the same size as AST");
@ -520,12 +520,12 @@ struct AST_Typedef
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
ModuleFlag ModuleFlags;
b32 IsFunction;
s32 Token;
};
static_assert( sizeof(AST_Typedef) == sizeof(AST), "ERROR: AST_Typedef is not the same size as AST");
@ -544,12 +544,12 @@ struct AST_Union
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
ModuleFlag ModuleFlags;
char _PAD_UNUSED_[ sizeof(u32) ];
s32 Token;
};
static_assert( sizeof(AST_Union) == sizeof(AST), "ERROR: AST_Union is not the same size as AST");
@ -568,12 +568,12 @@ struct AST_Using
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
ModuleFlag ModuleFlags;
char _PAD_UNUSED_[ sizeof(u32) ];
s32 Token;
};
static_assert( sizeof(AST_Using) == sizeof(AST), "ERROR: AST_Using is not the same size as AST");
@ -594,12 +594,12 @@ struct AST_Var
};
Code Prev;
Code Next;
Parser::Token* Token;
Code Parent;
StringCached Name;
CodeT Type;
ModuleFlag ModuleFlags;
char _PAD_UNUSED_[ sizeof(u32) ];
s32 Token;
};
static_assert( sizeof(AST_Var) == sizeof(AST), "ERROR: AST_Var is not the same size as AST");

View File

@ -1,6 +1,6 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
#pragma once
#include "types.hpp"
#include "components/Types.hpp"
#endif
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)

View File

@ -1,6 +1,6 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
#pragma once
#include "types.hpp"
#include "components/types.hpp"
#endif
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)

View File

@ -1,6 +1,6 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES
#pragma once
#include "types.hpp"
#include "components/types.hpp"
#endif
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)

View File

@ -419,15 +419,15 @@ Code make_code()
// mem_set( result.ast, 0, sizeof(AST) );
result->Type = ECode::Invalid;
result->Content = { nullptr };
result->Prev = { nullptr };
result->Next = { nullptr };
result->Parent = { nullptr };
result->Name = { nullptr };
result->Type = ECode::Invalid;
result->ModuleFlags = ModuleFlag::Invalid;
result->NumEntries = 0;
result->Token = -1;
result->Content = { nullptr };
result->Prev = { nullptr };
result->Next = { nullptr };
result->Token = nullptr;
result->Parent = { nullptr };
result->Name = { nullptr };
result->Type = ECode::Invalid;
result->ModuleFlags = ModuleFlag::Invalid;
result->NumEntries = 0;
return result;
}

View File

@ -6,6 +6,18 @@
namespace Parser
{
enum TokFlags : u32
{
TF_Operator = bit(0),
TF_Assign = bit(0),
TF_Preprocess = bit(1),
TF_Comment = bit(2),
TF_Attribute = bit(3),
TF_AccessSpecifier = bit(4),
TF_Specifier = bit(5),
TF_EndDefinition = bit(6), // Either ; or }
};
struct Token
{
char const* Text;
@ -251,11 +263,6 @@ namespace Parser
return true;
}
enum TokFlags : u32
{
IsAssign = bit(0),
};
global Array<Token> Tokens;
neverinline
@ -1638,6 +1645,7 @@ CodeAttributes parse_attributes()
{
eat( TokType::Attribute_Open);
start = currtok;
while ( left && currtok.Type != TokType::Attribute_Close )
{
eat( currtok.Type );
@ -1653,6 +1661,7 @@ CodeAttributes parse_attributes()
eat(TokType::Capture_Start);
eat(TokType::Capture_Start);
start = currtok;
while ( left && currtok.Type != TokType::Capture_End )
{
eat(currtok.Type);
@ -1669,6 +1678,7 @@ CodeAttributes parse_attributes()
eat( TokType::Decl_MSVC_Attribute );
eat( TokType::Capture_Start);
start = currtok;
while ( left && currtok.Type != TokType::Capture_End )
{
eat(currtok.Type);
@ -1697,6 +1707,7 @@ CodeAttributes parse_attributes()
result->Type = ECode::PlatformAttributes;
result->Name = get_cached_string( name_stripped );
result->Content = result->Name;
// result->Token =
return (CodeAttributes) result;
}
@ -1717,6 +1728,7 @@ CodeComment parse_comment()
result->Type = ECode::Comment;
result->Content = get_cached_string( currtok_noskip );
result->Name = result->Content;
// result->Token = currtok_noskip;
eat( TokType::Comment );
Context.pop();
@ -5052,7 +5064,7 @@ CodeType parse_type( bool* typedef_is_function )
CodeType
result = (CodeType) make_code();
result->Type = Typename;
result->Token = Context.Scope->Start;
// result->Token = Context.Scope->Start;
// Need to wait until were using the new parsing method to do this.
String name_stripped = strip_formatting( name, strip_formatting_dont_preserve_newlines );

View File

@ -41,6 +41,15 @@ char const* to_str( AccessSpec type )
return lookup[ (u32)type ];
}
enum CodeFlag : u32
{
FunctionType = bit(0),
ParamPack = bit(1),
Module_Export = bit(2),
Module_Import = bit(3),
};
// Used to indicate if enum definitoin is an enum class or regular enum.
enum class EnumT : u8
{