mirror of
https://github.com/Ed94/gencpp.git
synced 2024-12-22 07:44:45 -08:00
Updated zpl to latest refactor convention
This commit is contained in:
parent
4adb4654e9
commit
69e26bbdf8
@ -62,29 +62,29 @@ using zpl::arena_allocator;
|
|||||||
using zpl::arena_init_from_memory;
|
using zpl::arena_init_from_memory;
|
||||||
using zpl::arena_init_from_allocator;
|
using zpl::arena_init_from_allocator;
|
||||||
using zpl::arena_free;
|
using zpl::arena_free;
|
||||||
using zpl::bprintf;
|
using zpl::str_fmt_buf;
|
||||||
using zpl::char_is_alpha;
|
using zpl::char_is_alpha;
|
||||||
using zpl::char_is_alphanumeric;
|
using zpl::char_is_alphanumeric;
|
||||||
using zpl::char_is_space;
|
using zpl::char_is_space;
|
||||||
using zpl::crc32;
|
using zpl::crc32;
|
||||||
using zpl::free_all;
|
using zpl::free_all;
|
||||||
using zpl::memcopy;
|
using zpl::mem_copy;
|
||||||
using zpl::memset;
|
using zpl::mem_set;
|
||||||
using zpl::pool_allocator;
|
using zpl::pool_allocator;
|
||||||
using zpl::pool_init;
|
using zpl::pool_init;
|
||||||
using zpl::pool_free;
|
using zpl::pool_free;
|
||||||
using zpl::printf_va;
|
using zpl::process_exit;
|
||||||
using zpl::printf_err_va;
|
using zpl::str_fmt_out_va;
|
||||||
|
using zpl::str_fmt_out_err_va;
|
||||||
using zpl::str_compare;
|
using zpl::str_compare;
|
||||||
using zpl::snprintf_va;
|
using zpl::str_fmt_va;
|
||||||
using zpl::string_appendc;
|
using zpl::string_appendc;
|
||||||
using zpl::string_append_fmt;
|
using zpl::string_append_fmt;
|
||||||
using zpl::string_append_length;
|
using zpl::string_append_length;
|
||||||
using zpl::string_make_length;
|
using zpl::string_make_length;
|
||||||
using zpl::string_length;
|
using zpl::string_length;
|
||||||
using zpl::string_make;
|
using zpl::string_make;
|
||||||
using zpl::strnlen;
|
using zpl::str_len;
|
||||||
using zpl::exit;
|
|
||||||
|
|
||||||
|
|
||||||
#if __clang__
|
#if __clang__
|
||||||
@ -224,7 +224,7 @@ sw log_fmt(char const *fmt, ...)
|
|||||||
va_list va;
|
va_list va;
|
||||||
|
|
||||||
va_start(va, fmt);
|
va_start(va, fmt);
|
||||||
res = printf_va(fmt, va);
|
res = str_fmt_out_va(fmt, va);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
@ -247,7 +247,7 @@ sw fatal(char const *fmt, ...)
|
|||||||
return -1;
|
return -1;
|
||||||
#else
|
#else
|
||||||
va_start(va, fmt);
|
va_start(va, fmt);
|
||||||
printf_err_va( fmt, va);
|
str_fmt_out_err_va( fmt, va);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
|
333
project/gen.cpp
333
project/gen.cpp
@ -268,7 +268,6 @@ namespace gen
|
|||||||
switch ( Type )
|
switch ( Type )
|
||||||
{
|
{
|
||||||
case Invalid:
|
case Invalid:
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Untyped:
|
case Untyped:
|
||||||
@ -779,7 +778,7 @@ namespace gen
|
|||||||
return OpValidateResult::Fail;
|
return OpValidateResult::Fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
# pragma region Helper Macros
|
# pragma region Helper Macros
|
||||||
# define check_params() \
|
# define check_params() \
|
||||||
if ( ! params_code ) \
|
if ( ! params_code ) \
|
||||||
{ \
|
{ \
|
||||||
@ -804,7 +803,7 @@ namespace gen
|
|||||||
); \
|
); \
|
||||||
return OpValidateResult::Fail; \
|
return OpValidateResult::Fail; \
|
||||||
}
|
}
|
||||||
# pragma endregion Helper Macros
|
# pragma endregion Helper Macros
|
||||||
|
|
||||||
if ( ! ret_type )
|
if ( ! ret_type )
|
||||||
{
|
{
|
||||||
@ -821,7 +820,7 @@ namespace gen
|
|||||||
|
|
||||||
switch ( op )
|
switch ( op )
|
||||||
{
|
{
|
||||||
# define specs( ... ) macro_num_args( __VA_ARGS__ ), __VA_ARGS__
|
# define specs( ... ) macro_num_args( __VA_ARGS__ ), __VA_ARGS__
|
||||||
case Assign:
|
case Assign:
|
||||||
check_params();
|
check_params();
|
||||||
|
|
||||||
@ -1082,7 +1081,7 @@ namespace gen
|
|||||||
case Comma:
|
case Comma:
|
||||||
check_params();
|
check_params();
|
||||||
break;
|
break;
|
||||||
# undef specs
|
# undef specs
|
||||||
}
|
}
|
||||||
|
|
||||||
# undef check_params
|
# undef check_params
|
||||||
@ -1134,12 +1133,12 @@ namespace gen
|
|||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
# define null_check( Context_, Code_ ) \
|
# define null_check( Context_, Code_ ) \
|
||||||
if ( ! Code_ ) \
|
if ( ! Code_ ) \
|
||||||
{ \
|
{ \
|
||||||
log_failure( "gen::" txt(Context_) ": " txt(Code_) " provided is null" ); \
|
log_failure( "gen::" txt(Context_) ": " txt(Code_) " provided is null" ); \
|
||||||
return Code::Invalid; \
|
return Code::Invalid; \
|
||||||
}
|
}
|
||||||
|
|
||||||
# define null_or_invalid_check( Context_, Code_ ) \
|
# define null_or_invalid_check( Context_, Code_ ) \
|
||||||
{ \
|
{ \
|
||||||
@ -1442,11 +1441,11 @@ namespace gen
|
|||||||
return Code::Invalid;
|
return Code::Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
char const* name = bprintf( "operator%s", to_str(op) );
|
char const* name = str_fmt_buf( "operator%s", to_str(op) );
|
||||||
|
|
||||||
Code
|
Code
|
||||||
result = make_code();
|
result = make_code();
|
||||||
result->Name = get_cached_string( name, strnlen(name, MaxNameLength) );
|
result->Name = get_cached_string( name, str_len(name, MaxNameLength) );
|
||||||
|
|
||||||
if ( body )
|
if ( body )
|
||||||
{
|
{
|
||||||
@ -2502,6 +2501,7 @@ namespace gen
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
# endif // GEN_FEATURE_INCREMENTAL
|
||||||
# pragma endregion Incremetnal Constructions
|
# pragma endregion Incremetnal Constructions
|
||||||
|
|
||||||
# pragma region Parsing Constructors
|
# pragma region Parsing Constructors
|
||||||
@ -2533,70 +2533,7 @@ namespace gen
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
These macros are used to make the parsing code more readable.
|
These macros are used to make the parsing code more readable.
|
||||||
|
|
||||||
They expect the following variables to be defined withing the scope of parsing constructor:
|
|
||||||
SpecifierT specs_found[16] { ESpecifier::Num_Specifiers };
|
|
||||||
s32 num_specifiers = 0;
|
|
||||||
|
|
||||||
char const* name = nullptr;
|
|
||||||
s32 name_length = 0;
|
|
||||||
|
|
||||||
s32 left = length;
|
|
||||||
char const* scanner = def;
|
|
||||||
|
|
||||||
Code array_expr = Code::Invalid;
|
|
||||||
Code type = Code::Invalid;
|
|
||||||
|
|
||||||
char const* word = scanner;
|
|
||||||
s32 word_length = 0;
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
# define current ( * scanner )
|
|
||||||
|
|
||||||
# define move_forward() \
|
|
||||||
left--; \
|
|
||||||
scanner++
|
|
||||||
|
|
||||||
# define SkipWhitespace() \
|
|
||||||
while ( left && char_is_space( current ) ) \
|
|
||||||
{ \
|
|
||||||
move_forward(); \
|
|
||||||
}
|
|
||||||
|
|
||||||
# define SkipWhitespace_Checked( Context_, Msg_, ... ) \
|
|
||||||
while ( left && char_is_space( current ) ) \
|
|
||||||
{ \
|
|
||||||
move_forward(); \
|
|
||||||
} \
|
|
||||||
if ( left <= 0 ) \
|
|
||||||
{ \
|
|
||||||
log_failure( "gen::" txt(Context_) ": " Msg_, __VA_ARGS__ ); \
|
|
||||||
return Code::Invalid; \
|
|
||||||
}
|
|
||||||
|
|
||||||
# define GetWord() \
|
|
||||||
word = scanner; \
|
|
||||||
word_length = 0; \
|
|
||||||
while ( left && char_is_alphanumeric( current ) || current == '_' ) \
|
|
||||||
{ \
|
|
||||||
move_forward(); \
|
|
||||||
word_length++; \
|
|
||||||
}
|
|
||||||
|
|
||||||
# define CheckForSpecifiers() \
|
|
||||||
GetWord(); \
|
|
||||||
for ( s32 index = 0; index < ESpecifier::Num_Specifiers; index++ ) \
|
|
||||||
{ \
|
|
||||||
char const* specifier_str = ESpecifier::to_str( scast(SpecifierT, index) ); \
|
|
||||||
\
|
|
||||||
if ( str_compare( word, specifier_str, word_length ) == 0 ) \
|
|
||||||
{ \
|
|
||||||
specs_found[num_specifiers] = (SpecifierT) index; \
|
|
||||||
num_specifiers++; \
|
|
||||||
continue; \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
# define curr_tok ( * tokens )
|
# define curr_tok ( * tokens )
|
||||||
|
|
||||||
# define eat( Type_ ) \
|
# define eat( Type_ ) \
|
||||||
@ -2606,7 +2543,7 @@ namespace gen
|
|||||||
log_failure( "gen::" txt(context) ": expected %s, got %s", txt(Type_), curr_tok.Type ); \
|
log_failure( "gen::" txt(context) ": expected %s, got %s", txt(Type_), curr_tok.Type ); \
|
||||||
return Code::Invalid; \
|
return Code::Invalid; \
|
||||||
} \
|
} \
|
||||||
tokens++; \
|
tokIDX++; \
|
||||||
left--
|
left--
|
||||||
# pragma endregion Helper Macros
|
# pragma endregion Helper Macros
|
||||||
|
|
||||||
@ -2717,6 +2654,29 @@ namespace gen
|
|||||||
|
|
||||||
Array(Token) lex( s32 length, char const* content)
|
Array(Token) lex( s32 length, char const* content)
|
||||||
{
|
{
|
||||||
|
# define current ( * scanner )
|
||||||
|
|
||||||
|
# define move_forward() \
|
||||||
|
left--; \
|
||||||
|
scanner++
|
||||||
|
|
||||||
|
# define SkipWhitespace() \
|
||||||
|
while ( left && char_is_space( current ) ) \
|
||||||
|
{ \
|
||||||
|
move_forward(); \
|
||||||
|
}
|
||||||
|
|
||||||
|
# define SkipWhitespace_Checked( Context_, Msg_, ... ) \
|
||||||
|
while ( left && char_is_space( current ) ) \
|
||||||
|
{ \
|
||||||
|
move_forward(); \
|
||||||
|
} \
|
||||||
|
if ( left <= 0 ) \
|
||||||
|
{ \
|
||||||
|
log_failure( "gen::" txt(Context_) ": " Msg_, __VA_ARGS__ ); \
|
||||||
|
return Code::Invalid; \
|
||||||
|
}
|
||||||
|
|
||||||
do_once_start
|
do_once_start
|
||||||
arena_init_from_allocator( & LexAllocator, heap(), megabytes(10) );
|
arena_init_from_allocator( & LexAllocator, heap(), megabytes(10) );
|
||||||
|
|
||||||
@ -2746,7 +2706,7 @@ namespace gen
|
|||||||
if ( Tokens )
|
if ( Tokens )
|
||||||
array_clear( Tokens );
|
array_clear( Tokens );
|
||||||
|
|
||||||
array_init_reserve( Tokens, LexAllocator, length / 8 );
|
array_init_reserve( Tokens, arena_allocator( & LexAllocator), length / 8 );
|
||||||
|
|
||||||
while (left )
|
while (left )
|
||||||
{
|
{
|
||||||
@ -3095,6 +3055,11 @@ namespace gen
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Tokens;
|
return Tokens;
|
||||||
|
|
||||||
|
# undef current
|
||||||
|
# undef move_forward
|
||||||
|
# undef SkipWhitespace
|
||||||
|
# undef SkipWhitespace_Checked
|
||||||
}
|
}
|
||||||
# pragma endregion Lexer
|
# pragma endregion Lexer
|
||||||
|
|
||||||
@ -3117,42 +3082,29 @@ namespace gen
|
|||||||
|
|
||||||
Token& curr_token = * tokens;
|
Token& curr_token = * tokens;
|
||||||
|
|
||||||
s32 left = array_count( tokens );
|
s32 tokIDX = 0;
|
||||||
|
s32 left = array_count( tokens );
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Token token = tokens[ array_count(tokens) - left ];
|
|
||||||
|
|
||||||
eat( TokType::Decl_Class );
|
|
||||||
|
|
||||||
// check for api specifier...
|
|
||||||
|
|
||||||
name = curr_token;
|
|
||||||
|
|
||||||
switch ( token.Type )
|
|
||||||
{
|
|
||||||
case TokType::Identifier:
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
while ( left--, left > 0 );
|
while ( left--, left > 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
Code parse_enum( s32 length, char const* def )
|
Code parse_enum( s32 length, char const* def )
|
||||||
{
|
{
|
||||||
# define context parse_type
|
# define context parse_enum
|
||||||
|
check_parse_args( parse_enum, length, def );
|
||||||
check_parse_args( parse_typedef, length, def );
|
|
||||||
|
|
||||||
Array(Token) tokens = lex( length, def );
|
Array(Token) tokens = lex( length, def );
|
||||||
|
|
||||||
if ( tokens == nullptr )
|
if ( tokens == nullptr )
|
||||||
{
|
{
|
||||||
log_failure( "gen::parse_typedef: no tokens found for provided definition" );
|
log_failure( "gen::parse_enum: no tokens found for provided definition" );
|
||||||
return Code::Invalid;
|
return Code::Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 left = array_count( tokens );
|
s32 left = array_count( tokens );
|
||||||
|
s32 tokIDX = 0;
|
||||||
|
|
||||||
SpecifierT specs_found[16] { ESpecifier::Num_Specifiers };
|
SpecifierT specs_found[16] { ESpecifier::Num_Specifiers };
|
||||||
s32 num_specifiers = 0;
|
s32 num_specifiers = 0;
|
||||||
@ -3188,7 +3140,9 @@ namespace gen
|
|||||||
{
|
{
|
||||||
eat( TokType::Assign_Classifer );
|
eat( TokType::Assign_Classifer );
|
||||||
|
|
||||||
type = parse_type( curr_tok.Length, curr_tok.Text );
|
s32 left_length = curr_tok.Length + curr_tok.Text - array_front(tokens).Text;
|
||||||
|
|
||||||
|
type = parse_type( curr_tok.Length , curr_tok.Text );
|
||||||
if ( type == Code::Invalid )
|
if ( type == Code::Invalid )
|
||||||
{
|
{
|
||||||
log_failure( "gen::parse_enum: failed to parse enum type" );
|
log_failure( "gen::parse_enum: failed to parse enum type" );
|
||||||
@ -3242,6 +3196,7 @@ namespace gen
|
|||||||
|
|
||||||
result.lock();
|
result.lock();
|
||||||
return result;
|
return result;
|
||||||
|
# undef context
|
||||||
}
|
}
|
||||||
|
|
||||||
Code parse_execution( s32 length, char const* exec_def )
|
Code parse_execution( s32 length, char const* exec_def )
|
||||||
@ -3261,7 +3216,8 @@ namespace gen
|
|||||||
return Code::Invalid;
|
return Code::Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 left = array_count( tokens );
|
s32 left = array_count( tokens );
|
||||||
|
s32 tokIDX = 0;
|
||||||
|
|
||||||
eat( TokType::Decl_Friend );
|
eat( TokType::Decl_Friend );
|
||||||
|
|
||||||
@ -3269,7 +3225,16 @@ namespace gen
|
|||||||
// If its a function declaration, it will have a return type, followed by a name, followed by a parameter list.
|
// If its a function declaration, it will have a return type, followed by a name, followed by a parameter list.
|
||||||
// If its a simple type, it will have a type, followed by a name.
|
// If its a simple type, it will have a type, followed by a name.
|
||||||
|
|
||||||
return Code::Invalid;
|
|
||||||
|
|
||||||
|
|
||||||
|
using namespace ECode;
|
||||||
|
|
||||||
|
Code result = make_code();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Code parse_global_body( s32 length, char const* def )
|
Code parse_global_body( s32 length, char const* def )
|
||||||
@ -3303,113 +3268,28 @@ namespace gen
|
|||||||
static
|
static
|
||||||
Param Params[ 64 ] { 0 };
|
Param Params[ 64 ] { 0 };
|
||||||
|
|
||||||
char const* name;
|
|
||||||
s32 name_length = 0;
|
|
||||||
|
|
||||||
char const* body_str = nullptr;
|
|
||||||
s32 body_length = 0;
|
|
||||||
|
|
||||||
char const* ret_type_str = nullptr;
|
|
||||||
s32 ret_length = 0;
|
|
||||||
|
|
||||||
s32 left = length;
|
using namespace ECode;
|
||||||
char const* scanner = def;
|
|
||||||
|
|
||||||
while ( left -- )
|
|
||||||
{
|
|
||||||
// Find all specifiers (if any) and the return type
|
|
||||||
do
|
|
||||||
{
|
|
||||||
SkipWhitespace();
|
|
||||||
|
|
||||||
s32 length = 0;
|
|
||||||
char const* spec_or_type = scanner;
|
|
||||||
|
|
||||||
while ( char_is_alpha( * scanner) || * scanner == '_')
|
|
||||||
{
|
|
||||||
length++;
|
|
||||||
left--;
|
|
||||||
scanner++;
|
|
||||||
}
|
|
||||||
|
|
||||||
SpecifierT type = ESpecifier::to_type( spec_or_type, length );
|
|
||||||
|
|
||||||
if ( type != ESpecifier::Invalid )
|
|
||||||
{
|
|
||||||
specs_found[num_specifiers] = type;
|
|
||||||
num_specifiers++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Should be return type
|
|
||||||
ret_type_str = scanner;
|
|
||||||
ret_length = length;
|
|
||||||
scanner++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
while( left );
|
|
||||||
|
|
||||||
SkipWhitespace();
|
|
||||||
|
|
||||||
// Next up should be the name if before there were specifiers
|
|
||||||
name = scanner;
|
|
||||||
|
|
||||||
while ( char_is_alpha( * scanner) || * scanner == '_')
|
|
||||||
{
|
|
||||||
ret_length++;
|
|
||||||
left--;
|
|
||||||
scanner++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parameters
|
|
||||||
SkipWhitespace();
|
|
||||||
|
|
||||||
if ( * scanner != '(' )
|
|
||||||
{
|
|
||||||
log_failure("gen::parse_proc: Error, expected a ( in %s", string_make_length( g_allocator, scanner - 4, 100) );
|
|
||||||
return Code::Invalid;
|
|
||||||
}
|
|
||||||
|
|
||||||
scanner++;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
while (0);
|
|
||||||
|
|
||||||
// Get past ')'
|
|
||||||
scanner++;
|
|
||||||
|
|
||||||
SkipWhitespace()
|
|
||||||
|
|
||||||
// get end specifiers
|
|
||||||
|
|
||||||
if ( * scanner != '{')
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
not_implemented( parse_function );
|
|
||||||
}
|
|
||||||
|
|
||||||
Code specifiers = def_specifiers( num_specifiers, specs_found );
|
Code specifiers = def_specifiers( num_specifiers, specs_found );
|
||||||
|
|
||||||
Code params = make_code();
|
Code params = make_code();
|
||||||
Code ret_type = def_type( ret_length, ret_type_str );
|
// Code ret_type = def_type( ret_length, ret_type_str );
|
||||||
Code body = untyped_str( body_length, body_str );
|
// Code body = untyped_str( body_length, body_str );
|
||||||
|
|
||||||
Code
|
Code
|
||||||
result = make_code();
|
result = make_code();
|
||||||
result->Name = get_cached_string( name, name_length );
|
// result->Name = get_cached_string( name, name_length );
|
||||||
result->Type = ECode::Function;
|
result->Type = Function;
|
||||||
|
|
||||||
result->add_entry( body );
|
// result->add_entry( body );
|
||||||
|
|
||||||
if ( specifiers )
|
if ( specifiers )
|
||||||
result->add_entry( specifiers );
|
result->add_entry( specifiers );
|
||||||
|
|
||||||
result->add_entry( ret_type );
|
// result->add_entry( ret_type );
|
||||||
|
|
||||||
if ( params )
|
if ( params )
|
||||||
result->add_entry( params );
|
result->add_entry( params );
|
||||||
@ -3457,11 +3337,23 @@ namespace gen
|
|||||||
inline
|
inline
|
||||||
bool parse_type_helper( char const* func_name
|
bool parse_type_helper( char const* func_name
|
||||||
, Token& name
|
, Token& name
|
||||||
, s32& left, Array(Token)& tokens
|
, s32& left, s32& tokIDX, Array(Token)& tokens
|
||||||
, s32& num_specifiers, SpecifierT* specs_found
|
, s32& num_specifiers, SpecifierT* specs_found
|
||||||
, Code& array_expr
|
, Code& array_expr
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
# pragma push_macro( "eat" )
|
||||||
|
# undef eat
|
||||||
|
# define eat( Type_ ) \
|
||||||
|
if ( curr_tok.Type != Type_ ) \
|
||||||
|
{ \
|
||||||
|
String token_str = string_make_length( g_allocator, curr_tok.Text, curr_tok.Length ); \
|
||||||
|
log_failure( "gen::" txt(context) ": expected %s, got %s", txt(Type_), curr_tok.Type ); \
|
||||||
|
return Code::Invalid; \
|
||||||
|
} \
|
||||||
|
tokIDX++; \
|
||||||
|
left--
|
||||||
|
|
||||||
while ( left && tok_is_specifier( curr_tok ) )
|
while ( left && tok_is_specifier( curr_tok ) )
|
||||||
{
|
{
|
||||||
SpecifierT spec = ESpecifier::to_type( curr_tok.Text, curr_tok.Length );
|
SpecifierT spec = ESpecifier::to_type( curr_tok.Text, curr_tok.Length );
|
||||||
@ -3484,8 +3376,20 @@ namespace gen
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
name = curr_tok;
|
if ( curr_tok.Type == TokType::Decl_Class
|
||||||
eat( TokType::Identifier );
|
|| curr_tok.Type == TokType::Decl_Struct )
|
||||||
|
{
|
||||||
|
name = curr_tok;
|
||||||
|
eat( curr_tok.Type );
|
||||||
|
|
||||||
|
name.Length += curr_tok.Length;
|
||||||
|
eat( TokType::Identifier );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
name = curr_tok;
|
||||||
|
eat( TokType::Identifier );
|
||||||
|
}
|
||||||
|
|
||||||
while ( left && tok_is_specifier( curr_tok ) )
|
while ( left && tok_is_specifier( curr_tok ) )
|
||||||
{
|
{
|
||||||
@ -3547,12 +3451,11 @@ namespace gen
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
# pragma pop_macro( "eat" )
|
||||||
}
|
}
|
||||||
|
|
||||||
Code parse_type( s32 length, char const* def )
|
Code parse_type( s32 length, char const* def )
|
||||||
{
|
{
|
||||||
# define context parse_type
|
|
||||||
|
|
||||||
check_parse_args( parse_type, length, def );
|
check_parse_args( parse_type, length, def );
|
||||||
|
|
||||||
Array(Token) tokens = lex( length, def );
|
Array(Token) tokens = lex( length, def );
|
||||||
@ -3563,17 +3466,18 @@ namespace gen
|
|||||||
return Code::Invalid;
|
return Code::Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 left = array_count( tokens );
|
s32 left = array_count( tokens );
|
||||||
|
s32 tokIDX = 0;
|
||||||
|
|
||||||
Token* name = nullptr;
|
Token* name = nullptr;
|
||||||
Code array_expr = { nullptr };
|
Code array_expr = { nullptr };
|
||||||
|
|
||||||
SpecifierT specs_found[16] { ESpecifier::Num_Specifiers };
|
SpecifierT specs_found[16] { ESpecifier::Num_Specifiers };
|
||||||
u8 num_specifiers = 0;
|
s32 num_specifiers = 0;
|
||||||
|
|
||||||
bool helper_result = parse_type_helper( txt(parse_type)
|
bool helper_result = parse_type_helper( txt(parse_type)
|
||||||
, * name
|
, * name
|
||||||
, left, tokens
|
, left, tokIDX, tokens
|
||||||
, num_specifiers, specs_found
|
, num_specifiers, specs_found
|
||||||
, array_expr
|
, array_expr
|
||||||
);
|
);
|
||||||
@ -3604,8 +3508,7 @@ namespace gen
|
|||||||
|
|
||||||
Code parse_typedef( s32 length, char const* def )
|
Code parse_typedef( s32 length, char const* def )
|
||||||
{
|
{
|
||||||
# define context parse_type
|
# define context parse_typedef
|
||||||
|
|
||||||
check_parse_args( parse_typedef, length, def );
|
check_parse_args( parse_typedef, length, def );
|
||||||
|
|
||||||
Array(Token) tokens = lex( length, def );
|
Array(Token) tokens = lex( length, def );
|
||||||
@ -3616,7 +3519,8 @@ namespace gen
|
|||||||
return Code::Invalid;
|
return Code::Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 left = array_count( tokens );
|
s32 left = array_count( tokens );
|
||||||
|
s32 tokIDX = 0;
|
||||||
|
|
||||||
Token* name = nullptr;
|
Token* name = nullptr;
|
||||||
Code array_expr = { nullptr };
|
Code array_expr = { nullptr };
|
||||||
@ -3629,7 +3533,7 @@ namespace gen
|
|||||||
|
|
||||||
bool helper_result = parse_type_helper( txt(parse_typedef)
|
bool helper_result = parse_type_helper( txt(parse_typedef)
|
||||||
, * name
|
, * name
|
||||||
, left, tokens
|
, left, tokIDX, tokens
|
||||||
, num_specifiers, specs_found
|
, num_specifiers, specs_found
|
||||||
, array_expr
|
, array_expr
|
||||||
);
|
);
|
||||||
@ -3661,23 +3565,24 @@ namespace gen
|
|||||||
|
|
||||||
result.lock();
|
result.lock();
|
||||||
return result;
|
return result;
|
||||||
|
# undef context
|
||||||
}
|
}
|
||||||
|
|
||||||
Code parse_using( s32 length, char const* def )
|
Code parse_using( s32 length, char const* def )
|
||||||
{
|
{
|
||||||
# define context parse_type
|
# define context parse_using
|
||||||
|
check_parse_args( parse_using, length, def );
|
||||||
check_parse_args( parse_typedef, length, def );
|
|
||||||
|
|
||||||
Array(Token) tokens = lex( length, def );
|
Array(Token) tokens = lex( length, def );
|
||||||
|
|
||||||
if ( tokens == nullptr )
|
if ( tokens == nullptr )
|
||||||
{
|
{
|
||||||
log_failure( "gen::parse_typedef: no tokens found for provided definition" );
|
log_failure( "gen::parse_using: no tokens found for provided definition" );
|
||||||
return Code::Invalid;
|
return Code::Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 left = array_count( tokens );
|
s32 left = array_count( tokens );
|
||||||
|
s32 tokIDX = 0;
|
||||||
|
|
||||||
SpecifierT specs_found[16] { ESpecifier::Num_Specifiers };
|
SpecifierT specs_found[16] { ESpecifier::Num_Specifiers };
|
||||||
s32 num_specifiers = 0;
|
s32 num_specifiers = 0;
|
||||||
@ -3708,7 +3613,7 @@ namespace gen
|
|||||||
|
|
||||||
bool helper_result = parse_type_helper( txt(parse_using)
|
bool helper_result = parse_type_helper( txt(parse_using)
|
||||||
, * name
|
, * name
|
||||||
, left, tokens
|
, left, tokIDX, tokens
|
||||||
, num_specifiers, specs_found
|
, num_specifiers, specs_found
|
||||||
, array_expr
|
, array_expr
|
||||||
);
|
);
|
||||||
@ -3732,6 +3637,7 @@ namespace gen
|
|||||||
|
|
||||||
result.lock();
|
result.lock();
|
||||||
return result;
|
return result;
|
||||||
|
# undef context
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3883,7 +3789,6 @@ namespace gen
|
|||||||
This is a more robust lexer than the ones used for the lexer in the parse constructors interface.
|
This is a more robust lexer than the ones used for the lexer in the parse constructors interface.
|
||||||
Its needed to scan a C++ file and have awareness to skip content unsupported by the library.
|
Its needed to scan a C++ file and have awareness to skip content unsupported by the library.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#pragma endregion File Lexer
|
#pragma endregion File Lexer
|
||||||
|
|
||||||
@ -3894,10 +3799,8 @@ namespace gen
|
|||||||
|
|
||||||
#pragma region Scanner
|
#pragma region Scanner
|
||||||
#ifdef GEN_FEATURE_SCANNER
|
#ifdef GEN_FEATURE_SCANNER
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#pragma endregion Scanner
|
#pragma endregion Scanner
|
||||||
}
|
}
|
||||||
// end gen_time
|
// End: gen_time
|
||||||
#endif
|
#endif
|
||||||
|
@ -646,7 +646,7 @@ namespace gen
|
|||||||
{
|
{
|
||||||
char const* enum_str = to_str( (Type)index );
|
char const* enum_str = to_str( (Type)index );
|
||||||
|
|
||||||
keymap[index] = crc32( enum_str, strnlen(enum_str, 42) );
|
keymap[index] = crc32( enum_str, str_len(enum_str, 42) );
|
||||||
}
|
}
|
||||||
do_once_end
|
do_once_end
|
||||||
|
|
||||||
@ -817,7 +817,7 @@ namespace gen
|
|||||||
// Thus if its desired to keep the debug str
|
// Thus if its desired to keep the debug str
|
||||||
// for multiple calls to bprintf,
|
// for multiple calls to bprintf,
|
||||||
// allocate this to proper string.
|
// allocate this to proper string.
|
||||||
return bprintf( fmt
|
return str_fmt_buf( fmt
|
||||||
, type_str()
|
, type_str()
|
||||||
, Readonly ? "true" : "false"
|
, Readonly ? "true" : "false"
|
||||||
, Parent ? Parent->Name : ""
|
, Parent ? Parent->Name : ""
|
||||||
|
12663
thirdparty/zpl.h
vendored
12663
thirdparty/zpl.h
vendored
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user