Update readmes. Some minor changes to the API.

This commit is contained in:
2023-06-29 01:37:42 -04:00
parent 7f645c7357
commit 2da78e67d8
5 changed files with 175 additions and 82 deletions

View File

@ -18,6 +18,7 @@ Organization:
* ZPL inclusion and selective symbol exposure to global scope.
* Utility macro definitions used throughout the library.
* Global memory arena definition
* StrC and String definitions
* Token string formatter
* Formatted and Fatal Logs
@ -52,7 +53,10 @@ Major enum definitions and their associated functions used with the AST data
* `ECode` : Used to tag ASTs by their type
* `EOperator` : Used to tag operator overloads with thier op type
* `ESpecifier` : Used with specifier ASTs for all specifiers the user may tag an associated AST with.
* `ESpecifier` : Used with specifier ASTs for all specifiers the user may tag an associated
AST with.
* `AccessSpec` : Used with class and struct ASTs to denote the public, protected, or private fields.
* `ModuleFlag` : Used with any valid definition that can have export or import related keywords assoicated with it.
#### Data Structures
@ -85,3 +89,17 @@ Inlined functions related to the AST datatype that required forwards for gen int
## gen.cpp
* Static data defined at the top.
* AST Body case macros are next.
* AST implementation follows
* Gen interface begins with its `init`, `deinit`, etc.. Until `make_code_entires`
* operator__validate defined, which will be used to verify if an operator definition is constructible.
* Allocator interface for data arrays, code pool, code entries, string arenas, and string table.
* Helper macros used throughout the constructor API
* Upfront constructors, following the same order as shown in the header.
* Incremental constructors
* Parsing constructors, it defines its own lexer, and has many helper functions for parsing not exposed through the header.
* Untyped constructors
* Builder
* Editor
* Scanner

View File

@ -57,6 +57,8 @@ namespace gen
Code module_global_fragment;
Code module_private_fragment;
Code pragma_once;
Code spec_const;
Code spec_consteval;
Code spec_constexpr;
@ -1336,21 +1338,21 @@ namespace gen
access_private_write = ccast( Code, access_private );
access_private_write = make_code();
access_private_write->Type = ECode::Access_Private;
access_private_write->Name = get_cached_string( { sizeof("private"), "private" } );
access_private_write->Name = get_cached_string( StrC::from("private") );
access_private_write.lock();
Code&
access_protected_write = ccast( Code, access_protected );
access_protected_write = make_code();
access_protected_write->Type = ECode::Access_Protected;
access_protected_write->Name = get_cached_string( { sizeof("protected"), "protected" } );
access_protected_write->Name = get_cached_string( StrC::from("protected") );
access_protected_write.lock();
Code&
access_public_write = ccast( Code, access_public );
access_public_write = make_code();
access_public_write->Type = ECode::Access_Public;
access_public_write->Name = get_cached_string( { sizeof("public"), "public" } );
access_public_write->Name = get_cached_string( StrC::from("public") );
access_public_write.lock();
module_global_fragment = make_code();
@ -1365,6 +1367,12 @@ namespace gen
module_private_fragment->Content = module_private_fragment->Name;
module_private_fragment.lock();
pragma_once = make_code();
pragma_once->Type = ECode::Untyped;
pragma_once->Name = get_cached_string( StrC::from("#pragma once") );
pragma_once->Content = pragma_once->Name;
pragma_once.lock();
Code&
spec_local_persist_write = ccast( Code, spec_local_persist );
spec_local_persist_write = def_specifiers( 1, ESpecifier::Local_Persist );
@ -2009,6 +2017,23 @@ namespace gen
The largest of the functions is related to operator overload definitions.
I decided to validate a good protion of their form and thus the argument processing for is quite a bit.
*/
Code def_attributes( StrC content )
{
if ( content.Len <= 0 || content.Ptr == nullptr )
{
log_failure( "gen::def_attributes: Invalid attributes provided" );
return Code::Invalid;
}
Code
result = make_code();
result->Type = ECode::Attributes;
result->Name = get_cached_string( content );
result->Content = result->Name;
result.lock();
return result;
}
Code def_comment( StrC content )
{
@ -2028,24 +2053,6 @@ namespace gen
return result;
}
Code def_attributes( StrC content )
{
if ( content.Len <= 0 || content.Ptr == nullptr )
{
log_failure( "gen::def_attributes: Invalid attributes provided" );
return Code::Invalid;
}
Code
result = make_code();
result->Type = ECode::Attributes;
result->Name = get_cached_string( content );
result->Content = result->Name;
result.lock();
return result;
}
Code def_class( StrC name
, Code body
, Code parent, AccessSpec parent_access
@ -3442,7 +3449,7 @@ namespace gen
return result;
}
Code make_extern_linkage( StrC name, ModuleFlag mflags )
Code make_extern_link( StrC name, ModuleFlag mflags )
{
using namespace ECode;

View File

@ -556,8 +556,6 @@ namespace gen
constexpr static
uw ArrSpecs_Cap = ArrS_Cap * (sizeof(AST*) / sizeof(SpecifierT));
// static_assert( sizeof( AST* ) * ArrS_Cap == sizeof( AST** ) * ArrS_Cap, "Blah" );
# define Using_AST_POD \
union { \
AST* ArrStatic[AST::ArrS_Cap]; \
@ -778,8 +776,8 @@ namespace gen
void set_allocator_type_table ( AllocatorInfo type_reg_allocator );
# pragma region Upfront
Code def_comment ( StrC content );
Code def_attributes( StrC content );
Code def_comment ( StrC content );
Code def_class( StrC name
, Code body = NoCode
@ -819,8 +817,8 @@ namespace gen
, Code attributes = NoCode
, ModuleFlag mflags = ModuleFlag::None );
Code def_typedef( StrC name, Code type, Code attributes = NoCode, ModuleFlag mflags = ModuleFlag::None );
Code def_type ( StrC name, Code arrayexpr = NoCode, Code specifiers = NoCode );
Code def_typedef( StrC name, Code type, Code attributes = NoCode, ModuleFlag mflags = ModuleFlag::None );
Code def_union( StrC name, Code body, Code attributes = NoCode, ModuleFlag mflags = ModuleFlag::None );
@ -842,10 +840,10 @@ namespace gen
Code def_export_body ( s32 num, Code* codes);
Code def_extern_link_body( s32 num, ... );
Code def_extern_link_body( s32 num, Code* codes );
Code def_global_body ( s32 num, ... );
Code def_global_body ( s32 num, Code* codes );
Code def_function_body ( s32 num, ... );
Code def_function_body ( s32 num, Code* codes );
Code def_global_body ( s32 num, ... );
Code def_global_body ( s32 num, Code* codes );
Code def_namespace_body ( s32 num, ... );
Code def_namespace_body ( s32 num, Code* codes );
Code def_params ( s32 num, ... );
@ -869,8 +867,8 @@ namespace gen
, Code type = NoCode, EnumT specifier = EnumRegular
, Code attributes = NoCode, ModuleFlag mflags = ModuleFlag::None );
Code make_export_body ( StrC name = { 1, "" } );
Code make_extern_linkage( s32 length, char const* name, ModuleFlag mflags = ModuleFlag::None );
Code make_export_body( StrC name = { 1, "" } );
Code make_extern_link( s32 length, char const* name, ModuleFlag mflags = ModuleFlag::None );
Code make_function( StrC name
, Code params = NoCode, Code ret_type = NoCode
@ -1138,6 +1136,8 @@ namespace gen
extern Code module_global_fragment;
extern Code module_private_fragment;
extern Code pragma_once;
extern Code spec_const;
extern Code spec_consteval;
extern Code spec_constexpr;