mirror of
https://github.com/Ed94/gencpp.git
synced 2025-06-15 03:01:47 -07:00
C-library gen progress: Header files mostly done, starting dep c impl and fixes to generic selection generation
This commit is contained in:
@ -6,6 +6,18 @@
|
||||
#include "gen/especifier.hpp"
|
||||
#endif
|
||||
|
||||
/*
|
||||
______ ______ ________ __ __ ______ __
|
||||
/ \ / \| \ | \ | \ / \ | \
|
||||
| ▓▓▓▓▓▓\ ▓▓▓▓▓▓\\▓▓▓▓▓▓▓▓ | ▓▓\ | ▓▓ | ▓▓▓▓▓▓\ ______ ____| ▓▓ ______
|
||||
| ▓▓__| ▓▓ ▓▓___\▓▓ | ▓▓ | ▓▓▓\| ▓▓ | ▓▓ \▓▓/ \ / ▓▓/ \
|
||||
| ▓▓ ▓▓\▓▓ \ | ▓▓ | ▓▓▓▓\ ▓▓ | ▓▓ | ▓▓▓▓▓▓\ ▓▓▓▓▓▓▓ ▓▓▓▓▓▓\
|
||||
| ▓▓▓▓▓▓▓▓_\▓▓▓▓▓▓\ | ▓▓ | ▓▓\▓▓ ▓▓ | ▓▓ __| ▓▓ | ▓▓ ▓▓ | ▓▓ ▓▓ ▓▓
|
||||
| ▓▓ | ▓▓ \__| ▓▓ | ▓▓ | ▓▓ \▓▓▓▓ | ▓▓__/ \ ▓▓__/ ▓▓ ▓▓__| ▓▓ ▓▓▓▓▓▓▓▓
|
||||
| ▓▓ | ▓▓\▓▓ ▓▓ | ▓▓ | ▓▓ \▓▓▓ \▓▓ ▓▓\▓▓ ▓▓\▓▓ ▓▓\▓▓ \
|
||||
\▓▓ \▓▓ \▓▓▓▓▓▓ \▓▓ \▓▓ \▓▓ \▓▓▓▓▓▓ \▓▓▓▓▓▓ \▓▓▓▓▓▓▓ \▓▓▓▓▓▓▓
|
||||
*/
|
||||
|
||||
struct AST;
|
||||
struct AST_Body;
|
||||
struct AST_Attributes;
|
||||
@ -84,6 +96,7 @@ typedef AST* Code;
|
||||
#else
|
||||
struct Code;
|
||||
#endif
|
||||
|
||||
Define_Code(Body);
|
||||
// These are to offer ease of use and optionally strong type safety for the AST.
|
||||
Define_Code(Attributes);
|
||||
@ -150,6 +163,7 @@ Define_Code(Typedef);
|
||||
Define_Code(Union);
|
||||
Define_Code(Using);
|
||||
Define_Code(Var);
|
||||
|
||||
#undef Define_Code
|
||||
|
||||
GEN_NS_PARSER_BEGIN
|
||||
@ -172,6 +186,7 @@ template< class Type> forceinline Type tmpl_cast( Code self ) { return * rcast(
|
||||
#endif
|
||||
|
||||
#pragma region Code C-Interface
|
||||
|
||||
void code_append (Code code, Code other );
|
||||
char const* code_debug_str (Code code);
|
||||
Code code_duplicate (Code code);
|
||||
@ -185,6 +200,7 @@ String code_to_string (Code self );
|
||||
void code_to_string_ptr(Code self, String* result );
|
||||
char const* code_type_str (Code self );
|
||||
bool code_validate_body(Code self );
|
||||
|
||||
#pragma endregion Code C-Interface
|
||||
|
||||
#if GEN_COMPILER_CPP
|
||||
@ -298,10 +314,11 @@ constexpr static
|
||||
int AST_ArrSpecs_Cap =
|
||||
(
|
||||
AST_POD_Size
|
||||
- sizeof(Code)
|
||||
- sizeof(StringCached)
|
||||
- sizeof(AST*) * 3
|
||||
- sizeof(Code) * 2
|
||||
- sizeof(Token*)
|
||||
- sizeof(AST*)
|
||||
- sizeof(Code)
|
||||
- sizeof(CodeType)
|
||||
- sizeof(ModuleFlag)
|
||||
- sizeof(u32)
|
||||
|
@ -4,6 +4,22 @@
|
||||
#endif
|
||||
|
||||
#pragma region AST Types
|
||||
|
||||
/*
|
||||
______ ______ ________ ________
|
||||
/ \ / \| \ | \
|
||||
| ▓▓▓▓▓▓\ ▓▓▓▓▓▓\\▓▓▓▓▓▓▓▓ \▓▓▓▓▓▓▓▓__ __ ______ ______ _______
|
||||
| ▓▓__| ▓▓ ▓▓___\▓▓ | ▓▓ | ▓▓ | \ | \/ \ / \ / \
|
||||
| ▓▓ ▓▓\▓▓ \ | ▓▓ | ▓▓ | ▓▓ | ▓▓ ▓▓▓▓▓▓\ ▓▓▓▓▓▓\ ▓▓▓▓▓▓▓
|
||||
| ▓▓▓▓▓▓▓▓_\▓▓▓▓▓▓\ | ▓▓ | ▓▓ | ▓▓ | ▓▓ ▓▓ | ▓▓ ▓▓ ▓▓\▓▓ \
|
||||
| ▓▓ | ▓▓ \__| ▓▓ | ▓▓ | ▓▓ | ▓▓__/ ▓▓ ▓▓__/ ▓▓ ▓▓▓▓▓▓▓▓_\▓▓▓▓▓▓\
|
||||
| ▓▓ | ▓▓\▓▓ ▓▓ | ▓▓ | ▓▓ \▓▓ ▓▓ ▓▓ ▓▓\▓▓ \ ▓▓
|
||||
\▓▓ \▓▓ \▓▓▓▓▓▓ \▓▓ \▓▓ _\▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓ \▓▓▓▓▓▓▓\▓▓▓▓▓▓▓
|
||||
| \__| ▓▓ ▓▓
|
||||
\▓▓ ▓▓ ▓▓
|
||||
\▓▓▓▓▓▓ \▓▓
|
||||
*/
|
||||
|
||||
/*
|
||||
Show only relevant members of the AST for its type.
|
||||
AST* fields are replaced with Code types.
|
||||
@ -12,7 +28,9 @@
|
||||
|
||||
struct AST_Body
|
||||
{
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
union {
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
};
|
||||
StringCached Name;
|
||||
Code Front;
|
||||
Code Back;
|
||||
@ -550,7 +568,9 @@ static_assert( sizeof(AST_Fn) == sizeof(AST), "ERROR: AST_Fn is not the same siz
|
||||
|
||||
struct AST_Module
|
||||
{
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
union {
|
||||
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
|
||||
};
|
||||
StringCached Name;
|
||||
Code Prev;
|
||||
Code Next;
|
||||
@ -693,7 +713,7 @@ static_assert( sizeof(AST_PreprocessCond) == sizeof(AST), "ERROR: AST_Preprocess
|
||||
|
||||
struct AST_Specifiers
|
||||
{
|
||||
Specifier ArrSpecs[ AST_ArrSpecs_Cap ];
|
||||
Specifier ArrSpecs[ AST_ArrSpecs_Cap ];
|
||||
StringCached Name;
|
||||
CodeSpecifiers NextSpecs;
|
||||
Code Prev;
|
||||
|
@ -3,7 +3,20 @@
|
||||
#include "ast.hpp"
|
||||
#endif
|
||||
|
||||
/*
|
||||
______ __ ______ __ ______
|
||||
/ \ | \ | \ | \ / \
|
||||
| ▓▓▓▓▓▓\ ______ ____| ▓▓ ______ \▓▓▓▓▓▓_______ _| ▓▓_ ______ ______ | ▓▓▓▓▓▓\ ______ _______ ______
|
||||
| ▓▓ \▓▓/ \ / ▓▓/ \ | ▓▓ | \| ▓▓ \ / \ / \| ▓▓_ \▓▓| \ / \/ \
|
||||
| ▓▓ | ▓▓▓▓▓▓\ ▓▓▓▓▓▓▓ ▓▓▓▓▓▓\ | ▓▓ | ▓▓▓▓▓▓▓\\▓▓▓▓▓▓ | ▓▓▓▓▓▓\ ▓▓▓▓▓▓\ ▓▓ \ \▓▓▓▓▓▓\ ▓▓▓▓▓▓▓ ▓▓▓▓▓▓\
|
||||
| ▓▓ __| ▓▓ | ▓▓ ▓▓ | ▓▓ ▓▓ ▓▓ | ▓▓ | ▓▓ | ▓▓ | ▓▓ __| ▓▓ ▓▓ ▓▓ \▓▓ ▓▓▓▓ / ▓▓ ▓▓ | ▓▓ ▓▓
|
||||
| ▓▓__/ \ ▓▓__/ ▓▓ ▓▓__| ▓▓ ▓▓▓▓▓▓▓▓ _| ▓▓_| ▓▓ | ▓▓ | ▓▓| \ ▓▓▓▓▓▓▓▓ ▓▓ | ▓▓ | ▓▓▓▓▓▓▓ ▓▓_____| ▓▓▓▓▓▓▓▓
|
||||
\▓▓ ▓▓\▓▓ ▓▓\▓▓ ▓▓\▓▓ \ | ▓▓ \ ▓▓ | ▓▓ \▓▓ ▓▓\▓▓ \ ▓▓ | ▓▓ \▓▓ ▓▓\▓▓ \\▓▓ \
|
||||
\▓▓▓▓▓▓ \▓▓▓▓▓▓ \▓▓▓▓▓▓▓ \▓▓▓▓▓▓▓ \▓▓▓▓▓▓\▓▓ \▓▓ \▓▓▓▓ \▓▓▓▓▓▓▓\▓▓ \▓▓ \▓▓▓▓▓▓▓ \▓▓▓▓▓▓▓ \▓▓▓▓▓▓▓
|
||||
*/
|
||||
|
||||
#pragma region Code Type C-Interface
|
||||
|
||||
void body_append ( CodeBody body, Code other );
|
||||
void body_append_body ( CodeBody body, CodeBody other );
|
||||
String body_to_string ( CodeBody body );
|
||||
@ -14,7 +27,7 @@ Code begin_CodeBody( CodeBody body);
|
||||
Code end_CodeBody ( CodeBody body );
|
||||
Code next_CodeBody ( CodeBody body, Code entry_iter );
|
||||
|
||||
void class_add_interface( CodeClass self, CodeType interface );
|
||||
void class_add_interface( CodeClass self, CodeTypename interface );
|
||||
String class_to_string ( CodeClass self );
|
||||
void class_to_string_def( CodeClass self, String* result );
|
||||
void class_to_string_fwd( CodeClass self, String* result );
|
||||
@ -39,7 +52,7 @@ Specifier* begin_CodeSpecifiers(CodeSpecifiers specifiers);
|
||||
Specifier* end_CodeSpecifiers (CodeSpecifiers specifiers);
|
||||
Specifier* next_CodeSpecifiers (CodeSpecifiers specifiers, Specifier* spec_iter);
|
||||
|
||||
void struct_add_interface(CodeStruct self, CodeType interface);
|
||||
void struct_add_interface(CodeStruct self, CodeTypename interface);
|
||||
String struct_to_string (CodeStruct self);
|
||||
void struct_to_string_fwd(CodeStruct self, String* result);
|
||||
void struct_to_string_def(CodeStruct self, String* result);
|
||||
@ -126,6 +139,7 @@ void using_to_string_ns (CodeUsing op_cast, String* result );
|
||||
|
||||
String var_to_string (CodeVar self);
|
||||
void var_to_string_ref(CodeVar self, String* result);
|
||||
|
||||
#pragma endregion Code Type C-Interface
|
||||
|
||||
#if GEN_COMPILER_CPP
|
||||
@ -214,24 +228,6 @@ struct CodeSpecifiers
|
||||
AST_Specifiers* ast;
|
||||
};
|
||||
|
||||
struct CodeStruct
|
||||
{
|
||||
#if ! GEN_C_LIKE_CPP
|
||||
Using_Code( CodeStruct );
|
||||
forceinline void add_interface( CodeType interface ) { return struct_add_interface(* this, interface); }
|
||||
forceinline String to_string() { return struct_to_string(* this); }
|
||||
forceinline void to_string_fwd( String& result ) { return struct_to_string_fwd(* this, & result); }
|
||||
forceinline void to_string_def( String& result ) { return struct_to_string_def(* this, & result); }
|
||||
#endif
|
||||
Using_CodeOps( CodeStruct );
|
||||
forceinline operator Code() { return * rcast( Code*, this ); }
|
||||
forceinline AST_Struct* operator->() {
|
||||
GEN_ASSERT(ast);
|
||||
return ast;
|
||||
}
|
||||
AST_Struct* ast;
|
||||
};
|
||||
|
||||
struct CodeAttributes
|
||||
{
|
||||
#if ! GEN_C_LIKE_CPP
|
||||
@ -907,6 +903,24 @@ struct CodeVar
|
||||
AST_Var* ast;
|
||||
};
|
||||
|
||||
struct CodeStruct
|
||||
{
|
||||
#if ! GEN_C_LIKE_CPP
|
||||
Using_Code( CodeStruct );
|
||||
forceinline void add_interface( CodeTypename interface ) { return struct_add_interface(* this, interface); }
|
||||
forceinline String to_string() { return struct_to_string(* this); }
|
||||
forceinline void to_string_fwd( String& result ) { return struct_to_string_fwd(* this, & result); }
|
||||
forceinline void to_string_def( String& result ) { return struct_to_string_def(* this, & result); }
|
||||
#endif
|
||||
Using_CodeOps( CodeStruct );
|
||||
forceinline operator Code() { return * rcast( Code*, this ); }
|
||||
forceinline AST_Struct* operator->() {
|
||||
GEN_ASSERT(ast);
|
||||
return ast;
|
||||
}
|
||||
AST_Struct* ast;
|
||||
};
|
||||
|
||||
#undef Define_CodeType
|
||||
#undef Using_Code
|
||||
#undef Using_CodeOps
|
||||
@ -982,6 +996,7 @@ struct NullCode_ImplicitCaster
|
||||
|
||||
#if ! GEN_C_LIKE_CPP
|
||||
GEN_OPTIMIZE_MAPPINGS_BEGIN
|
||||
|
||||
forceinline void append ( CodeBody body, Code other ) { return body_append(body, other); }
|
||||
forceinline void append ( CodeBody body, CodeBody other ) { return body_append_body(body, other); }
|
||||
forceinline String to_string ( CodeBody body ) { return body_to_string(body); }
|
||||
@ -992,7 +1007,7 @@ forceinline Code begin( CodeBody body) { return begin_CodeBody
|
||||
forceinline Code end ( CodeBody body ) { return end_CodeBody(body); }
|
||||
forceinline Code next ( CodeBody body, Code entry_iter ) { return next_CodeBody(body, entry_iter); }
|
||||
|
||||
forceinline void add_interface( CodeClass self, CodeType interface ) { return class_add_interface(self, interface); }
|
||||
forceinline void add_interface( CodeClass self, CodeTypename interface ) { return class_add_interface(self, interface); }
|
||||
forceinline String to_string ( CodeClass self ) { return class_to_string(self); }
|
||||
forceinline void to_string_def( CodeClass self, String& result ) { return class_to_string_def(self, & result); }
|
||||
forceinline void to_string_fwd( CodeClass self, String& result ) { return class_to_string_fwd(self, & result); }
|
||||
@ -1017,10 +1032,10 @@ forceinline Specifier* begin(CodeSpecifiers specifiers) {
|
||||
forceinline Specifier* end (CodeSpecifiers specifiers) { return end_CodeSpecifiers(specifiers); }
|
||||
forceinline Specifier* next (CodeSpecifiers specifiers, Specifier& spec_iter) { return next_CodeSpecifiers(specifiers, & spec_iter); }
|
||||
|
||||
forceinline void add_interface(CodeStruct self, CodeType interface) { return struct_add_interface(self, interface); }
|
||||
forceinline String to_string (CodeStruct self) { return struct_to_string(self); }
|
||||
forceinline void to_string_fwd(CodeStruct self, String& result) { return struct_to_string_fwd(self, & result); }
|
||||
forceinline void to_string_def(CodeStruct self, String& result) { return struct_to_string_def(self, & result); }
|
||||
forceinline void add_interface(CodeStruct self, CodeTypename interface) { return struct_add_interface(self, interface); }
|
||||
forceinline String to_string (CodeStruct self) { return struct_to_string(self); }
|
||||
forceinline void to_string_fwd(CodeStruct self, String& result) { return struct_to_string_fwd(self, & result); }
|
||||
forceinline void to_string_def(CodeStruct self, String& result) { return struct_to_string_def(self, & result); }
|
||||
|
||||
forceinline String to_string(CodeAttributes attributes) { return attributes_to_string(attributes); }
|
||||
forceinline void to_string(CodeAttributes attributes, String& result) { return attributes_to_string_ref(attributes, & result); }
|
||||
@ -1104,6 +1119,7 @@ forceinline void to_string_ns(CodeUsing op_cast, String& result ) { return usi
|
||||
|
||||
forceinline String to_string(CodeVar self) { return var_to_string(self); }
|
||||
forceinline void to_string(CodeVar self, String& result) { return var_to_string_ref(self, & result); }
|
||||
|
||||
GEN_OPITMIZE_MAPPINGS_END
|
||||
#endif //if GEN_C_LIKE_CPP
|
||||
|
||||
|
@ -68,7 +68,8 @@ enum CodeType : u32
|
||||
CT_Using,
|
||||
CT_Using_Namespace,
|
||||
CT_Variable,
|
||||
CT_NumTypes
|
||||
CT_NumTypes,
|
||||
CT_UnderlyingType = GEN_U32_MAX
|
||||
};
|
||||
|
||||
inline StrC codetype_to_str( CodeType type )
|
||||
|
@ -54,7 +54,8 @@ enum Operator : u32
|
||||
Op_NewArray,
|
||||
Op_Delete,
|
||||
Op_DeleteArray,
|
||||
NumOps
|
||||
Op_NumOps,
|
||||
Op_UnderlyingType = 0xffffffffu
|
||||
};
|
||||
|
||||
inline StrC operator_to_str( Operator op )
|
||||
|
@ -33,7 +33,8 @@ enum Specifier : u32
|
||||
Spec_Override,
|
||||
Spec_Pure,
|
||||
Spec_Volatile,
|
||||
Spec_NumSpecifiers
|
||||
Spec_NumSpecifiers,
|
||||
Spec_UnderlyingType = 0xffffffffu
|
||||
};
|
||||
|
||||
inline StrC spec_to_str( Specifier type )
|
||||
|
@ -6,13 +6,20 @@
|
||||
See Readme.md for more information from the project repository.
|
||||
|
||||
Public Address:
|
||||
https://github.com/Ed94/gencpp
|
||||
|
||||
! ----------------------------------------------------------------------- VERSION: v0.20-Alpha !
|
||||
! ============================================================================================ !
|
||||
! WARNING: THIS IS AN ALPHA VERSION OF THE LIBRARY, USE AT YOUR OWN DISCRETION !
|
||||
! NEVER DO CODE GENERATION WITHOUT AT LEAST HAVING CONTENT IN A CODEBASE UNDER VERSION CONTROL !
|
||||
! ============================================================================================ !
|
||||
https://github.com/Ed94/gencpp --------------------------------------------------------------.
|
||||
| _____ _____ _ _ |
|
||||
| / ____) / ____} | | | |
|
||||
| | / ___ ___ _ __ ___ _ __ _ __ | {___ | |__ _ _, __ _, ___ __| | |
|
||||
| | |{_ |/ _ \ '_ \ / __} '_ l| '_ l `\___ \| __/ _` |/ _` |/ _ \/ _` | |
|
||||
| | l__j | ___/ | | | {__; |+l } |+l | ____) | l| (_| | {_| | ___/ (_| | |
|
||||
| \_____|\___}_l |_|\___} ,__/| ,__/ (_____/ \__\__/_|\__, |\___}\__,_l |
|
||||
| | | | | __} | |
|
||||
| l_l l_l {___/ |
|
||||
! ----------------------------------------------------------------------- VERSION: v0.20-Alpha |
|
||||
! ============================================================================================ |
|
||||
! WARNING: THIS IS AN ALPHA VERSION OF THE LIBRARY, USE AT YOUR OWN DISCRETION |
|
||||
! NEVER DO CODE GENERATION WITHOUT AT LEAST HAVING CONTENT IN A CODEBASE UNDER VERSION CONTROL |
|
||||
! ============================================================================================ /
|
||||
*/
|
||||
#if ! defined(GEN_DONT_ENFORCE_GEN_TIME_GUARD) && ! defined(GEN_TIME)
|
||||
# error Gen.hpp : GEN_TIME not defined
|
||||
|
@ -104,7 +104,7 @@ forceinline
|
||||
char const* code_type_str(Code self)
|
||||
{
|
||||
GEN_ASSERT(self != nullptr);
|
||||
return codetype_to_str( self->Type );
|
||||
return codetype_to_str( self->Type ).Ptr;
|
||||
}
|
||||
#pragma endregion Code
|
||||
|
||||
@ -138,7 +138,8 @@ Code begin_CodeBody( CodeBody body) {
|
||||
GEN_ASSERT(body);
|
||||
if ( body != nullptr )
|
||||
return body->Front;
|
||||
return { nullptr };
|
||||
|
||||
return NullCode;
|
||||
}
|
||||
forceinline
|
||||
Code end_CodeBody(CodeBody body ){
|
||||
@ -170,7 +171,7 @@ void class_add_interface( CodeClass self, CodeTypename type )
|
||||
|
||||
while ( possible_slot != nullptr )
|
||||
{
|
||||
possible_slot = possible_slot->Next;
|
||||
possible_slot = cast(CodeTypename, possible_slot->Next);
|
||||
}
|
||||
|
||||
possible_slot = type;
|
||||
@ -212,7 +213,7 @@ CodeParam params_get(CodeParam self, s32 idx )
|
||||
do
|
||||
{
|
||||
if ( ++ param != nullptr )
|
||||
return { nullptr };
|
||||
return NullCode;
|
||||
|
||||
param = cast(CodeParam, cast(Code, param)->Next);
|
||||
}
|
||||
@ -246,7 +247,7 @@ forceinline
|
||||
CodeParam end_CodeParam(CodeParam params)
|
||||
{
|
||||
// return { (AST_Param*) rcast( AST*, ast)->Last };
|
||||
return { nullptr };
|
||||
return NullCode;
|
||||
}
|
||||
forceinline
|
||||
CodeParam next_CodeParam(CodeParam params, CodeParam param_iter)
|
||||
@ -347,7 +348,7 @@ Specifier* next_CodeSpecifiers(CodeSpecifiers self, Specifier* spec_iter)
|
||||
|
||||
#pragma region CodeStruct
|
||||
inline
|
||||
void add_interface(CodeStruct self, CodeTypename type )
|
||||
void struct_add_interface(CodeStruct self, CodeTypename type )
|
||||
{
|
||||
CodeTypename possible_slot = self->ParentType;
|
||||
if ( possible_slot != nullptr )
|
||||
@ -360,7 +361,7 @@ void add_interface(CodeStruct self, CodeTypename type )
|
||||
|
||||
while ( possible_slot != nullptr )
|
||||
{
|
||||
possible_slot = possible_slot->Next;
|
||||
possible_slot = cast(CodeTypename, possible_slot->Next);
|
||||
}
|
||||
|
||||
possible_slot = type;
|
||||
@ -385,7 +386,7 @@ CodeBody def_body( CodeType type )
|
||||
break;
|
||||
|
||||
default:
|
||||
log_failure( "def_body: Invalid type %s", (char const*)codetype_to_str(type) );
|
||||
log_failure( "def_body: Invalid type %s", codetype_to_str(type).Ptr );
|
||||
return (CodeBody)Code_Invalid;
|
||||
}
|
||||
|
||||
@ -407,6 +408,7 @@ StrC token_fmt_impl( ssize num, ... )
|
||||
ssize result = token_fmt_va(buf, GEN_PRINTF_MAXLEN, num, va);
|
||||
va_end(va);
|
||||
|
||||
return { result, buf };
|
||||
StrC str = { result, buf };
|
||||
return str;
|
||||
}
|
||||
#pragma endregion Interface
|
||||
|
@ -4,6 +4,16 @@
|
||||
#endif
|
||||
|
||||
#pragma region Gen Interface
|
||||
/*
|
||||
/ \ | \ | \ / \
|
||||
| ▓▓▓▓▓▓\ ______ _______ \▓▓▓▓▓▓_______ _| ▓▓_ ______ ______ | ▓▓▓▓▓▓\ ______ _______ ______
|
||||
| ▓▓ __\▓▓/ \| \ | ▓▓ | \| ▓▓ \ / \ / \| ▓▓_ \▓▓| \ / \/ \
|
||||
| ▓▓| \ ▓▓▓▓▓▓\ ▓▓▓▓▓▓▓\ | ▓▓ | ▓▓▓▓▓▓▓\\▓▓▓▓▓▓ | ▓▓▓▓▓▓\ ▓▓▓▓▓▓\ ▓▓ \ \▓▓▓▓▓▓\ ▓▓▓▓▓▓▓ ▓▓▓▓▓▓\
|
||||
| ▓▓ \▓▓▓▓ ▓▓ ▓▓ ▓▓ | ▓▓ | ▓▓ | ▓▓ | ▓▓ | ▓▓ __| ▓▓ ▓▓ ▓▓ \▓▓ ▓▓▓▓ / ▓▓ ▓▓ | ▓▓ ▓▓
|
||||
| ▓▓__| ▓▓ ▓▓▓▓▓▓▓▓ ▓▓ | ▓▓ _| ▓▓_| ▓▓ | ▓▓ | ▓▓| \ ▓▓▓▓▓▓▓▓ ▓▓ | ▓▓ | ▓▓▓▓▓▓▓ ▓▓_____| ▓▓▓▓▓▓▓▓
|
||||
\▓▓ ▓▓\▓▓ \ ▓▓ | ▓▓ | ▓▓ \ ▓▓ | ▓▓ \▓▓ ▓▓\▓▓ \ ▓▓ | ▓▓ \▓▓ ▓▓\▓▓ \\▓▓ \
|
||||
\▓▓▓▓▓▓ \▓▓▓▓▓▓▓\▓▓ \▓▓ \▓▓▓▓▓▓\▓▓ \▓▓ \▓▓▓▓ \▓▓▓▓▓▓▓\▓▓ \▓▓ \▓▓▓▓▓▓▓ \▓▓▓▓▓▓▓ \▓▓▓▓▓▓▓
|
||||
*/
|
||||
|
||||
// Initialize the library.
|
||||
// This currently just initializes the CodePool.
|
||||
@ -164,7 +174,7 @@ struct Opts_def_variable
|
||||
CodeVar def_variable( CodeTypename type, StrC name, Opts_def_variable opts GEN_PARAM_DEFAULT );
|
||||
|
||||
// Constructs an empty body. Use AST::validate_body() to check if the body is was has valid entries.
|
||||
CodeBody def_body( CodeTypename type );
|
||||
CodeBody def_body( CodeType type );
|
||||
|
||||
// There are two options for defining a struct body, either varadically provided with the args macro to auto-deduce the arg num,
|
||||
/// or provide as an array of Code objects.
|
||||
@ -199,23 +209,23 @@ CodeBody def_union_body ( s32 num, Code* codes );
|
||||
// TODO(Ed) : Implmeent the new parser API design.
|
||||
|
||||
#if 0
|
||||
namespace parser {
|
||||
struct StackNode
|
||||
{
|
||||
StackNode* Prev;
|
||||
GEN_NS_PARSER_BEGIN
|
||||
struct StackNode
|
||||
{
|
||||
StackNode* Prev;
|
||||
|
||||
Token Start;
|
||||
Token Name; // The name of the AST node (if parsed)
|
||||
StrC FailedProc; // The name of the procedure that failed
|
||||
};
|
||||
// Stack nodes are allocated the error's allocator
|
||||
Token Start;
|
||||
Token Name; // The name of the AST node (if parsed)
|
||||
StrC FailedProc; // The name of the procedure that failed
|
||||
};
|
||||
// Stack nodes are allocated the error's allocator
|
||||
|
||||
struct Error
|
||||
{
|
||||
String message;
|
||||
StackNode* context_stack;
|
||||
};
|
||||
}
|
||||
struct Error
|
||||
{
|
||||
String message;
|
||||
StackNode* context_stack;
|
||||
};
|
||||
GEN_NS_PARSER_END
|
||||
|
||||
struct ParseInfo
|
||||
{
|
||||
@ -223,9 +233,9 @@ struct ParseInfo
|
||||
Arena TokMem;
|
||||
Arena CodeMem;
|
||||
|
||||
FileContents FileContent;
|
||||
Array<parser::Token> Tokens;
|
||||
Array<parser::Error> Errors;
|
||||
FileContents FileContent;
|
||||
Array<Token> Tokens;
|
||||
Array<Error> Errors;
|
||||
// Errors are allocated to a dedicated general arena.
|
||||
};
|
||||
|
||||
|
@ -1224,7 +1224,7 @@ CodeStruct def_struct( StrC name, Opts_def_struct p )
|
||||
{
|
||||
for (s32 idx = 0; idx < num_interfaces; idx++ )
|
||||
{
|
||||
add_interface(result, interfaces[idx] );
|
||||
struct_add_interface(result, interfaces[idx] );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3010,15 +3010,21 @@ Code parse_simple_preprocess( TokType which, bool dont_consume_braces )
|
||||
eat( Tok_Statement_End );
|
||||
// <Macro>;
|
||||
|
||||
tok.Length += prevtok.Length;
|
||||
|
||||
// TODO(Ed): Reveiw the context for this? (ESPECIALLY THIS)
|
||||
if ( currtok_noskip.Type == Tok_Comment && currtok_noskip.Line == stmt_end.Line )
|
||||
{
|
||||
eat( Tok_Comment );
|
||||
// <Macro>; <InlineCmt>
|
||||
|
||||
tok.Length += prevtok.Length;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (
|
||||
strc_contains(calling_proc, txt("parse_global_nspace"))
|
||||
&& strc_contains(calling_proc, txt("parse_class_struct_body"))
|
||||
|| strc_contains(calling_proc, txt("parse_class_struct_body"))
|
||||
)
|
||||
{
|
||||
if (peektok.Type == Tok_Statement_End)
|
||||
@ -3026,10 +3032,11 @@ Code parse_simple_preprocess( TokType which, bool dont_consume_braces )
|
||||
Token stmt_end = currtok;
|
||||
eat( Tok_Statement_End );
|
||||
// <Macro>;
|
||||
tok.Length += prevtok.Length;
|
||||
}
|
||||
}
|
||||
|
||||
tok.Length = ( (sptr)currtok_noskip.Text + currtok_noskip.Length ) - (sptr)tok.Text;
|
||||
}
|
||||
// tok.Length = ( (sptr)prevtok.Text + prevtok.Length ) - (sptr)tok.Text;
|
||||
}
|
||||
|
||||
Leave_Scope_Early:
|
||||
|
@ -3,6 +3,22 @@
|
||||
#include "header_start.hpp"
|
||||
#endif
|
||||
|
||||
/*
|
||||
________ __ __ ________
|
||||
| \ | \ | \ | \
|
||||
| ▓▓▓▓▓▓▓▓_______ __ __ ______ ____ _______ | ▓▓\ | ▓▓ \▓▓▓▓▓▓▓▓__ __ ______ ______ _______
|
||||
| ▓▓__ | \| \ | \ \ \ / \ | ▓▓▓\| ▓▓ | ▓▓ | \ | \/ \ / \ / \
|
||||
| ▓▓ \ | ▓▓▓▓▓▓▓\ ▓▓ | ▓▓ ▓▓▓▓▓▓\▓▓▓▓\ ▓▓▓▓▓▓▓ | ▓▓▓▓\ ▓▓ | ▓▓ | ▓▓ | ▓▓ ▓▓▓▓▓▓\ ▓▓▓▓▓▓\ ▓▓▓▓▓▓▓
|
||||
| ▓▓▓▓▓ | ▓▓ | ▓▓ ▓▓ | ▓▓ ▓▓ | ▓▓ | ▓▓\▓▓ \ | ▓▓\▓▓ ▓▓ | ▓▓ | ▓▓ | ▓▓ ▓▓ | ▓▓ ▓▓ ▓▓\▓▓ \
|
||||
| ▓▓_____| ▓▓ | ▓▓ ▓▓__/ ▓▓ ▓▓ | ▓▓ | ▓▓_\▓▓▓▓▓▓\ | ▓▓ \▓▓▓▓ | ▓▓ | ▓▓__/ ▓▓ ▓▓__/ ▓▓ ▓▓▓▓▓▓▓▓_\▓▓▓▓▓▓\
|
||||
| ▓▓ \ ▓▓ | ▓▓\▓▓ ▓▓ ▓▓ | ▓▓ | ▓▓ ▓▓ | ▓▓ \▓▓▓ | ▓▓ \▓▓ ▓▓ ▓▓ ▓▓\▓▓ \ ▓▓
|
||||
\▓▓▓▓▓▓▓▓\▓▓ \▓▓ \▓▓▓▓▓▓ \▓▓ \▓▓ \▓▓\▓▓▓▓▓▓▓ \▓▓ \▓▓ \▓▓ _\▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓ \▓▓▓▓▓▓▓\▓▓▓▓▓▓▓
|
||||
| \__| ▓▓ ▓▓
|
||||
\▓▓ ▓▓ ▓▓
|
||||
\▓▓▓▓▓▓ \▓▓
|
||||
|
||||
*/
|
||||
|
||||
using LogFailType = ssize(*)(char const*, ...);
|
||||
|
||||
// By default this library will either crash or exit if an error is detected while generating codes.
|
||||
|
Reference in New Issue
Block a user