mirror of
https://github.com/Ed94/gencpp.git
synced 2024-11-10 02:54:53 -08:00
Finished iniital refactor pass. Comples, but has runtime issues.
This commit is contained in:
parent
c5afede7b5
commit
689646c393
@ -97,9 +97,9 @@ namespace Parser
|
|||||||
|
|
||||||
result.append_fmt("\tContext:\n");
|
result.append_fmt("\tContext:\n");
|
||||||
|
|
||||||
char* current = Tokens.current().Text;
|
char const* current = Tokens.current().Text;
|
||||||
sptr length = Tokens.current().Length;
|
sptr length = Tokens.current().Length;
|
||||||
while ( current != Tokens.back().Text && current != '\n' )
|
while ( current != Tokens.Arr.back().Text && *current != '\n' )
|
||||||
{
|
{
|
||||||
current++;
|
current++;
|
||||||
length--;
|
length--;
|
||||||
@ -109,21 +109,19 @@ namespace Parser
|
|||||||
result.append_fmt("\t(%d, %d): %s", Tokens.current().Line, Tokens.current().Column, line );
|
result.append_fmt("\t(%d, %d): %s", Tokens.current().Line, Tokens.current().Column, line );
|
||||||
line.free();
|
line.free();
|
||||||
|
|
||||||
StackNode* current = Scope;
|
StackNode* curr_scope = Scope;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if ( current->Name )
|
if ( curr_scope->Name )
|
||||||
{
|
{
|
||||||
result.append_fmt("\tProcedure: %s, AST Name: %s\n", current->ProcName, (StrC)current->Name );
|
result.append_fmt("\tProcedure: %s, AST Name: %s\n", curr_scope->ProcName, (StrC)curr_scope->Name );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result.append_fmt("\tProcedure: %s\n", current->ProcName );
|
result.append_fmt("\tProcedure: %s\n", curr_scope->ProcName );
|
||||||
}
|
}
|
||||||
|
|
||||||
current = current->Prev;
|
curr_scope = curr_scope->Prev;
|
||||||
|
|
||||||
name.free();
|
|
||||||
}
|
}
|
||||||
while ( current );
|
while ( current );
|
||||||
return result;
|
return result;
|
||||||
@ -137,7 +135,7 @@ namespace Parser
|
|||||||
|
|
||||||
void pop()
|
void pop()
|
||||||
{
|
{
|
||||||
Context.Scope = Context.Scope->Prev;
|
Scope = Scope->Prev;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -709,12 +707,12 @@ namespace Parser
|
|||||||
# define check_parse_args( def ) \
|
# define check_parse_args( def ) \
|
||||||
if ( def.Len <= 0 ) \
|
if ( def.Len <= 0 ) \
|
||||||
{ \
|
{ \
|
||||||
log_failure( "gen::" stringize( __func__ ) ": length must greater than 0" ); \
|
log_failure( "gen::" stringize(__func__) ": length must greater than 0" ); \
|
||||||
return CodeInvalid; \
|
return CodeInvalid; \
|
||||||
} \
|
} \
|
||||||
if ( def.Ptr == nullptr ) \
|
if ( def.Ptr == nullptr ) \
|
||||||
{ \
|
{ \
|
||||||
log_failure( "gen::" stringize( __func__ ) ": def was null" ); \
|
log_failure( "gen::" stringize(__func__) ": def was null" ); \
|
||||||
return CodeInvalid; \
|
return CodeInvalid; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -871,7 +869,7 @@ CodeAttributes parse_attributes()
|
|||||||
return def_attributes( attribute_txt );
|
return def_attributes( attribute_txt );
|
||||||
}
|
}
|
||||||
|
|
||||||
pop_context();
|
Context.pop();
|
||||||
return { nullptr };
|
return { nullptr };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -931,7 +929,7 @@ Parser::Token parse_identifier()
|
|||||||
name.Length = ( (sptr)prevtok.Text + (sptr)prevtok.Length ) - (sptr)name.Text;
|
name.Length = ( (sptr)prevtok.Text + (sptr)prevtok.Length ) - (sptr)name.Text;
|
||||||
}
|
}
|
||||||
|
|
||||||
pop_context();
|
Context.pop();
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -996,7 +994,7 @@ CodeParam parse_params( bool use_template_capture = false )
|
|||||||
eat( currtok.Type );
|
eat( currtok.Type );
|
||||||
}
|
}
|
||||||
|
|
||||||
value = parse_type( toks, context );
|
value = parse_type();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1031,7 +1029,7 @@ CodeParam parse_params( bool use_template_capture = false )
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
type = parse_type( toks, context );
|
type = parse_type();
|
||||||
if ( type == Code::Invalid )
|
if ( type == Code::Invalid )
|
||||||
return CodeInvalid;
|
return CodeInvalid;
|
||||||
|
|
||||||
@ -1060,7 +1058,7 @@ CodeParam parse_params( bool use_template_capture = false )
|
|||||||
eat( currtok.Type );
|
eat( currtok.Type );
|
||||||
}
|
}
|
||||||
|
|
||||||
value = parse_type( toks, context );
|
value = parse_type();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1110,7 +1108,7 @@ CodeFn parse_function_after_name(
|
|||||||
using namespace Parser;
|
using namespace Parser;
|
||||||
push_scope();
|
push_scope();
|
||||||
|
|
||||||
CodeParam params = parse_params( toks, stringize(parse_function) );
|
CodeParam params = parse_params();
|
||||||
|
|
||||||
while ( left && currtok.is_specifier() )
|
while ( left && currtok.is_specifier() )
|
||||||
{
|
{
|
||||||
@ -1121,7 +1119,7 @@ CodeFn parse_function_after_name(
|
|||||||
CodeBody body = { nullptr };
|
CodeBody body = { nullptr };
|
||||||
if ( check( TokType::BraceCurly_Open ) )
|
if ( check( TokType::BraceCurly_Open ) )
|
||||||
{
|
{
|
||||||
body = parse_function_body( toks, stringize(parse_function) );
|
body = parse_function_body();
|
||||||
if ( body == Code::Invalid )
|
if ( body == Code::Invalid )
|
||||||
return CodeInvalid;
|
return CodeInvalid;
|
||||||
}
|
}
|
||||||
@ -1382,7 +1380,7 @@ CodeOperator parse_operator_after_ret_type(
|
|||||||
eat( TokType::Operator );
|
eat( TokType::Operator );
|
||||||
|
|
||||||
// Parse Params
|
// Parse Params
|
||||||
CodeParam params = parse_params( toks, stringize(parse_operator) );
|
CodeParam params = parse_params();
|
||||||
|
|
||||||
while ( left && currtok.is_specifier() )
|
while ( left && currtok.is_specifier() )
|
||||||
{
|
{
|
||||||
@ -1394,7 +1392,7 @@ CodeOperator parse_operator_after_ret_type(
|
|||||||
CodeBody body = { nullptr };
|
CodeBody body = { nullptr };
|
||||||
if ( check( TokType::BraceCurly_Open ) )
|
if ( check( TokType::BraceCurly_Open ) )
|
||||||
{
|
{
|
||||||
body = parse_function_body( toks, stringize(parse_function) );
|
body = parse_function_body();
|
||||||
if ( body == Code::Invalid )
|
if ( body == Code::Invalid )
|
||||||
return CodeInvalid;
|
return CodeInvalid;
|
||||||
}
|
}
|
||||||
@ -1515,7 +1513,7 @@ Code parse_operator_function_or_variable( bool expects_function, CodeAttributes
|
|||||||
|
|
||||||
Code result = Code::Invalid;
|
Code result = Code::Invalid;
|
||||||
|
|
||||||
CodeType type = parse_type( toks, stringize(parse_variable) );
|
CodeType type = parse_type();
|
||||||
|
|
||||||
if ( type == Code::Invalid )
|
if ( type == Code::Invalid )
|
||||||
return CodeInvalid;
|
return CodeInvalid;
|
||||||
@ -1605,39 +1603,39 @@ CodeBody parse_class_struct_body( Parser::TokType which )
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TokType::Decl_Class:
|
case TokType::Decl_Class:
|
||||||
member = parse_class( toks, context );
|
member = parse_class();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TokType::Decl_Enum:
|
case TokType::Decl_Enum:
|
||||||
member = parse_enum( toks, context );
|
member = parse_enum();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TokType::Decl_Friend:
|
case TokType::Decl_Friend:
|
||||||
member = parse_friend( toks, context );
|
member = parse_friend();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TokType::Decl_Operator:
|
case TokType::Decl_Operator:
|
||||||
member = parse_operator_cast( toks, context );
|
member = parse_operator_cast();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TokType::Decl_Struct:
|
case TokType::Decl_Struct:
|
||||||
member = parse_struct( toks, context );
|
member = parse_struct();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TokType::Decl_Template:
|
case TokType::Decl_Template:
|
||||||
member = parse_template( toks, context );
|
member = parse_template();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TokType::Decl_Typedef:
|
case TokType::Decl_Typedef:
|
||||||
member = parse_typedef( toks, context );
|
member = parse_typedef();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TokType::Decl_Union:
|
case TokType::Decl_Union:
|
||||||
member = parse_variable( toks, context );
|
member = parse_variable();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TokType::Decl_Using:
|
case TokType::Decl_Using:
|
||||||
member = parse_using( toks, context );
|
member = parse_using();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TokType::Attribute_Open:
|
case TokType::Attribute_Open:
|
||||||
@ -1769,7 +1767,7 @@ Code parse_class_struct( Parser::TokType which )
|
|||||||
attributes = parse_attributes();
|
attributes = parse_attributes();
|
||||||
|
|
||||||
if ( check( TokType::Identifier ) )
|
if ( check( TokType::Identifier ) )
|
||||||
name = parse_identifier( toks, context );
|
name = parse_identifier();
|
||||||
|
|
||||||
local_persist
|
local_persist
|
||||||
char interface_arr_mem[ kilobytes(4) ] {0};
|
char interface_arr_mem[ kilobytes(4) ] {0};
|
||||||
@ -1784,7 +1782,7 @@ Code parse_class_struct( Parser::TokType which )
|
|||||||
access = currtok.to_access_specifier();
|
access = currtok.to_access_specifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
Token parent_tok = parse_identifier( toks, context );
|
Token parent_tok = parse_identifier();
|
||||||
parent = def_type( parent_tok );
|
parent = def_type( parent_tok );
|
||||||
|
|
||||||
while ( check(TokType::Comma) )
|
while ( check(TokType::Comma) )
|
||||||
@ -1796,7 +1794,7 @@ Code parse_class_struct( Parser::TokType which )
|
|||||||
eat(currtok.Type);
|
eat(currtok.Type);
|
||||||
}
|
}
|
||||||
|
|
||||||
Token interface_tok = parse_identifier( toks, context );
|
Token interface_tok = parse_identifier();
|
||||||
|
|
||||||
interfaces.append( def_type( interface_tok ) );
|
interfaces.append( def_type( interface_tok ) );
|
||||||
}
|
}
|
||||||
@ -1804,22 +1802,16 @@ Code parse_class_struct( Parser::TokType which )
|
|||||||
|
|
||||||
if ( check( TokType::BraceCurly_Open ) )
|
if ( check( TokType::BraceCurly_Open ) )
|
||||||
{
|
{
|
||||||
body = parse_class_struct_body( which, toks, context );
|
body = parse_class_struct_body( which );
|
||||||
}
|
}
|
||||||
|
|
||||||
eat( TokType::Statement_End );
|
eat( TokType::Statement_End );
|
||||||
|
|
||||||
if ( which == TokType::Decl_Class )
|
if ( which == TokType::Decl_Class )
|
||||||
result = def_class( name, body, parent, access
|
result = def_class( name, body, parent, access, attributes, mflags );
|
||||||
, attributes
|
|
||||||
, mflags
|
|
||||||
);
|
|
||||||
|
|
||||||
else
|
else
|
||||||
result = def_struct( name, body, (CodeType)parent, access
|
result = def_struct( name, body, (CodeType)parent, access, attributes, mflags );
|
||||||
, attributes
|
|
||||||
, mflags
|
|
||||||
);
|
|
||||||
|
|
||||||
interfaces.free();
|
interfaces.free();
|
||||||
Context.pop();
|
Context.pop();
|
||||||
@ -1901,49 +1893,49 @@ CodeBody parse_global_nspace( CodeT which )
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TokType::Decl_Enum:
|
case TokType::Decl_Enum:
|
||||||
member = parse_enum( toks, context);
|
member = parse_enum();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TokType::Decl_Class:
|
case TokType::Decl_Class:
|
||||||
member = parse_class( toks, context );
|
member = parse_class();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TokType::Decl_Extern_Linkage:
|
case TokType::Decl_Extern_Linkage:
|
||||||
if ( which == Extern_Linkage_Body )
|
if ( which == Extern_Linkage_Body )
|
||||||
log_failure( "Nested extern linkage\n%s", Context.to_string() );
|
log_failure( "Nested extern linkage\n%s", Context.to_string() );
|
||||||
|
|
||||||
member = parse_extern_link_body( toks, context );
|
member = parse_extern_link_body();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TokType::Decl_Namespace:
|
case TokType::Decl_Namespace:
|
||||||
member = parse_namespace( toks, context );
|
member = parse_namespace();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TokType::Decl_Struct:
|
case TokType::Decl_Struct:
|
||||||
member = parse_struct( toks, context );
|
member = parse_struct();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TokType::Decl_Template:
|
case TokType::Decl_Template:
|
||||||
member = parse_template( toks, context );
|
member = parse_template();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TokType::Decl_Typedef:
|
case TokType::Decl_Typedef:
|
||||||
member = parse_typedef( toks, context );
|
member = parse_typedef();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TokType::Decl_Union:
|
case TokType::Decl_Union:
|
||||||
member = parse_union( toks, context );
|
member = parse_union();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TokType::Decl_Using:
|
case TokType::Decl_Using:
|
||||||
member = parse_using( toks, context );
|
member = parse_using();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TokType::Module_Export:
|
case TokType::Module_Export:
|
||||||
if ( which == Export_Body )
|
if ( which == Export_Body )
|
||||||
log_failure( "Nested export declaration\n%s", Context.to_string() );
|
log_failure( "Nested export declaration\n%s", Context.to_string() );
|
||||||
|
|
||||||
member = parse_export_body( toks, context );
|
member = parse_export_body();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TokType::Module_Import:
|
case TokType::Module_Import:
|
||||||
@ -2016,7 +2008,7 @@ CodeBody parse_global_nspace( CodeT which )
|
|||||||
case TokType::Type_double:
|
case TokType::Type_double:
|
||||||
case TokType::Type_int:
|
case TokType::Type_int:
|
||||||
{
|
{
|
||||||
member = parse_operator_function_or_variable( expects_function, attributes, specifiers, toks, context );
|
member = parse_operator_function_or_variable( expects_function, attributes, specifiers );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2039,15 +2031,16 @@ CodeBody parse_global_nspace( CodeT which )
|
|||||||
internal
|
internal
|
||||||
CodeClass parse_class()
|
CodeClass parse_class()
|
||||||
{
|
{
|
||||||
|
using namespace Parser;
|
||||||
push_scope();
|
push_scope();
|
||||||
CodeClass result = (CodeClass) parse_class_struct( Parser::TokType::Decl_Class, toks, context );
|
CodeClass result = (CodeClass) parse_class_struct( Parser::TokType::Decl_Class );
|
||||||
Context.pop();
|
Context.pop();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeClass parse_class( StrC def )
|
CodeClass parse_class( StrC def )
|
||||||
{
|
{
|
||||||
check_parse_args( parse_class, def );
|
check_parse_args( def );
|
||||||
using namespace Parser;
|
using namespace Parser;
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
@ -2103,7 +2096,7 @@ CodeEnum parse_enum()
|
|||||||
{
|
{
|
||||||
eat( TokType::Assign_Classifer );
|
eat( TokType::Assign_Classifer );
|
||||||
|
|
||||||
type = parse_type( toks, stringize(parse_enum) );
|
type = parse_type();
|
||||||
if ( type == Code::Invalid )
|
if ( type == Code::Invalid )
|
||||||
return CodeInvalid;
|
return CodeInvalid;
|
||||||
}
|
}
|
||||||
@ -2171,7 +2164,7 @@ CodeEnum parse_enum()
|
|||||||
|
|
||||||
CodeEnum parse_enum( StrC def )
|
CodeEnum parse_enum( StrC def )
|
||||||
{
|
{
|
||||||
check_parse_args( parse_enum, def );
|
check_parse_args( def );
|
||||||
using namespace Parser;
|
using namespace Parser;
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
@ -2184,6 +2177,7 @@ CodeEnum parse_enum( StrC def )
|
|||||||
internal inline
|
internal inline
|
||||||
CodeBody parse_export_body()
|
CodeBody parse_export_body()
|
||||||
{
|
{
|
||||||
|
using namespace Parser;
|
||||||
push_scope();
|
push_scope();
|
||||||
CodeBody result = parse_global_nspace( ECode::Export_Body );
|
CodeBody result = parse_global_nspace( ECode::Export_Body );
|
||||||
Context.pop();
|
Context.pop();
|
||||||
@ -2192,7 +2186,7 @@ CodeBody parse_export_body()
|
|||||||
|
|
||||||
CodeBody parse_export_body( StrC def )
|
CodeBody parse_export_body( StrC def )
|
||||||
{
|
{
|
||||||
check_parse_args( parse_export_body, def );
|
check_parse_args( def );
|
||||||
using namespace Parser;
|
using namespace Parser;
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
@ -2205,6 +2199,7 @@ CodeBody parse_export_body( StrC def )
|
|||||||
internal inline
|
internal inline
|
||||||
CodeBody parse_extern_link_body()
|
CodeBody parse_extern_link_body()
|
||||||
{
|
{
|
||||||
|
using namespace Parser;
|
||||||
push_scope();
|
push_scope();
|
||||||
CodeBody result = parse_global_nspace( ECode::Extern_Linkage_Body );
|
CodeBody result = parse_global_nspace( ECode::Extern_Linkage_Body );
|
||||||
Context.pop();
|
Context.pop();
|
||||||
@ -2230,7 +2225,7 @@ CodeExtern parse_extern_link()
|
|||||||
result->Type = ECode::Extern_Linkage;
|
result->Type = ECode::Extern_Linkage;
|
||||||
result->Name = get_cached_string( name );
|
result->Name = get_cached_string( name );
|
||||||
|
|
||||||
Code entry = parse_extern_link_body( toks, context );
|
Code entry = parse_extern_link_body();
|
||||||
if ( entry == Code::Invalid )
|
if ( entry == Code::Invalid )
|
||||||
{
|
{
|
||||||
log_failure( "Failed to parse body\n%s", Context.to_string() );
|
log_failure( "Failed to parse body\n%s", Context.to_string() );
|
||||||
@ -2245,7 +2240,7 @@ CodeExtern parse_extern_link()
|
|||||||
|
|
||||||
CodeExtern parse_extern_link( StrC def )
|
CodeExtern parse_extern_link( StrC def )
|
||||||
{
|
{
|
||||||
check_parse_args( parse_extern_link, def );
|
check_parse_args( def );
|
||||||
using namespace Parser;
|
using namespace Parser;
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
@ -2267,7 +2262,7 @@ CodeFriend parse_friend()
|
|||||||
CodeFn function = { nullptr };
|
CodeFn function = { nullptr };
|
||||||
|
|
||||||
// Type declaration or return type
|
// Type declaration or return type
|
||||||
CodeType type = parse_type( toks, stringize(parse_friend) );
|
CodeType type = parse_type();
|
||||||
if ( type == Code::Invalid )
|
if ( type == Code::Invalid )
|
||||||
return CodeInvalid;
|
return CodeInvalid;
|
||||||
|
|
||||||
@ -2275,10 +2270,10 @@ CodeFriend parse_friend()
|
|||||||
if ( currtok.Type == TokType::Identifier )
|
if ( currtok.Type == TokType::Identifier )
|
||||||
{
|
{
|
||||||
// Name
|
// Name
|
||||||
Token name = parse_identifier( toks, stringize(parse_friend) );
|
Token name = parse_identifier();
|
||||||
|
|
||||||
// Parameter list
|
// Parameter list
|
||||||
CodeParam params = parse_params( toks, stringize(parse_friend) );
|
CodeParam params = parse_params();
|
||||||
|
|
||||||
function = make_code();
|
function = make_code();
|
||||||
function->Type = Function_Fwd;
|
function->Type = Function_Fwd;
|
||||||
@ -2307,7 +2302,7 @@ CodeFriend parse_friend()
|
|||||||
|
|
||||||
CodeFriend parse_friend( StrC def )
|
CodeFriend parse_friend( StrC def )
|
||||||
{
|
{
|
||||||
check_parse_args( parse_friend, def );
|
check_parse_args( def );
|
||||||
using namespace Parser;
|
using namespace Parser;
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
@ -2370,11 +2365,11 @@ CodeFn parse_functon()
|
|||||||
specifiers = def_specifiers( NumSpecifiers, specs_found );
|
specifiers = def_specifiers( NumSpecifiers, specs_found );
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeType ret_type = parse_type( toks, stringize(parse_function) );
|
CodeType ret_type = parse_type();
|
||||||
if ( ret_type == Code::Invalid )
|
if ( ret_type == Code::Invalid )
|
||||||
return CodeInvalid;
|
return CodeInvalid;
|
||||||
|
|
||||||
Token name = parse_identifier( toks, stringize(parse_function) );
|
Token name = parse_identifier();
|
||||||
if ( ! name )
|
if ( ! name )
|
||||||
return CodeInvalid;
|
return CodeInvalid;
|
||||||
|
|
||||||
@ -2386,7 +2381,7 @@ CodeFn parse_functon()
|
|||||||
|
|
||||||
CodeFn parse_function( StrC def )
|
CodeFn parse_function( StrC def )
|
||||||
{
|
{
|
||||||
check_parse_args( parse_function, def );
|
check_parse_args( def );
|
||||||
using namespace Parser;
|
using namespace Parser;
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
@ -2398,7 +2393,7 @@ CodeFn parse_function( StrC def )
|
|||||||
|
|
||||||
CodeBody parse_global_body( StrC def )
|
CodeBody parse_global_body( StrC def )
|
||||||
{
|
{
|
||||||
check_parse_args( parse_global_body, def );
|
check_parse_args( def );
|
||||||
using namespace Parser;
|
using namespace Parser;
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
@ -2412,16 +2407,16 @@ CodeBody parse_global_body( StrC def )
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal
|
internal
|
||||||
CodeNamespace parse_namespace( Parser::TokArray& toks, char const* context )
|
CodeNamespace parse_namespace()
|
||||||
{
|
{
|
||||||
using namespace Parser;
|
using namespace Parser;
|
||||||
push_scope();
|
push_scope();
|
||||||
|
|
||||||
eat( TokType::Decl_Namespace );
|
eat( TokType::Decl_Namespace );
|
||||||
|
|
||||||
Token name = parse_identifier( toks, stringize(parse_namespace) );
|
Token name = parse_identifier();
|
||||||
|
|
||||||
CodeBody body = parse_global_nspace( ECode::Namespace_Body, toks, stringize(parse_namespace) );
|
CodeBody body = parse_global_nspace( ECode::Namespace_Body );
|
||||||
if ( body == Code::Invalid )
|
if ( body == Code::Invalid )
|
||||||
return CodeInvalid;
|
return CodeInvalid;
|
||||||
|
|
||||||
@ -2438,7 +2433,7 @@ CodeNamespace parse_namespace( Parser::TokArray& toks, char const* context )
|
|||||||
|
|
||||||
CodeNamespace parse_namespace( StrC def )
|
CodeNamespace parse_namespace( StrC def )
|
||||||
{
|
{
|
||||||
check_parse_args( parse_namespace, def );
|
check_parse_args( def );
|
||||||
using namespace Parser;
|
using namespace Parser;
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
@ -2500,7 +2495,7 @@ CodeOperator parse_operator()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parse Return Type
|
// Parse Return Type
|
||||||
CodeType ret_type = parse_type( toks, stringize(parse_operator) );
|
CodeType ret_type = parse_type();
|
||||||
|
|
||||||
CodeOperator result = parse_operator_after_ret_type( mflags, attributes, specifiers, ret_type );
|
CodeOperator result = parse_operator_after_ret_type( mflags, attributes, specifiers, ret_type );
|
||||||
|
|
||||||
@ -2510,7 +2505,7 @@ CodeOperator parse_operator()
|
|||||||
|
|
||||||
CodeOperator parse_operator( StrC def )
|
CodeOperator parse_operator( StrC def )
|
||||||
{
|
{
|
||||||
check_parse_args( parse_operator, def );
|
check_parse_args( def );
|
||||||
using namespace Parser;
|
using namespace Parser;
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
@ -2527,7 +2522,7 @@ CodeOpCast parse_operator_cast()
|
|||||||
|
|
||||||
eat( TokType::Decl_Operator );
|
eat( TokType::Decl_Operator );
|
||||||
|
|
||||||
Code type = parse_type( toks, stringize(parse_operator_cast) );
|
Code type = parse_type();
|
||||||
|
|
||||||
eat( TokType::Capture_Start );
|
eat( TokType::Capture_Start );
|
||||||
eat( TokType::Capture_End );
|
eat( TokType::Capture_End );
|
||||||
@ -2587,7 +2582,7 @@ CodeOpCast parse_operator_cast()
|
|||||||
|
|
||||||
CodeOpCast parse_operator_cast( StrC def )
|
CodeOpCast parse_operator_cast( StrC def )
|
||||||
{
|
{
|
||||||
check_parse_args( parse_operator_cast, def );
|
check_parse_args( def );
|
||||||
using namespace Parser;
|
using namespace Parser;
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
@ -2600,15 +2595,16 @@ CodeOpCast parse_operator_cast( StrC def )
|
|||||||
internal inline
|
internal inline
|
||||||
CodeStruct parse_struct()
|
CodeStruct parse_struct()
|
||||||
{
|
{
|
||||||
|
using namespace Parser;
|
||||||
push_scope();
|
push_scope();
|
||||||
CodeStruct result = (CodeStruct) parse_class_struct();
|
CodeStruct result = (CodeStruct) parse_class_struct( TokType::Decl_Struct );
|
||||||
Context.pop();
|
Context.pop();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeStruct parse_struct( StrC def )
|
CodeStruct parse_struct( StrC def )
|
||||||
{
|
{
|
||||||
check_parse_args( parse_struct, def );
|
check_parse_args( def );
|
||||||
using namespace Parser;
|
using namespace Parser;
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
@ -2636,7 +2632,7 @@ CodeTemplate parse_template()
|
|||||||
|
|
||||||
eat( TokType::Decl_Template );
|
eat( TokType::Decl_Template );
|
||||||
|
|
||||||
Code params = parse_params( toks, stringize(parse_template), UseTemplateCapture );
|
Code params = parse_params( UseTemplateCapture );
|
||||||
if ( params == Code::Invalid )
|
if ( params == Code::Invalid )
|
||||||
return CodeInvalid;
|
return CodeInvalid;
|
||||||
|
|
||||||
@ -2646,19 +2642,19 @@ CodeTemplate parse_template()
|
|||||||
{
|
{
|
||||||
if ( check( TokType::Decl_Class ) )
|
if ( check( TokType::Decl_Class ) )
|
||||||
{
|
{
|
||||||
definition = parse_class( toks, stringize(parse_template) );
|
definition = parse_class();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( check( TokType::Decl_Struct ) )
|
if ( check( TokType::Decl_Struct ) )
|
||||||
{
|
{
|
||||||
definition = parse_enum( toks, stringize(parse_template) );
|
definition = parse_enum();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( check( TokType::Decl_Using ))
|
if ( check( TokType::Decl_Using ))
|
||||||
{
|
{
|
||||||
definition = parse_using( toks, stringize(parse_template) );
|
definition = parse_using();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2717,7 +2713,7 @@ CodeTemplate parse_template()
|
|||||||
specifiers = def_specifiers( NumSpecifiers, specs_found );
|
specifiers = def_specifiers( NumSpecifiers, specs_found );
|
||||||
}
|
}
|
||||||
|
|
||||||
definition = parse_operator_function_or_variable( expects_function, attributes, specifiers, toks, stringize(parse_template) );
|
definition = parse_operator_function_or_variable( expects_function, attributes, specifiers );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2735,7 +2731,7 @@ CodeTemplate parse_template()
|
|||||||
|
|
||||||
CodeTemplate parse_template( StrC def )
|
CodeTemplate parse_template( StrC def )
|
||||||
{
|
{
|
||||||
check_parse_args( parse_template, def );
|
check_parse_args( def );
|
||||||
using namespace Parser;
|
using namespace Parser;
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
@ -2806,7 +2802,7 @@ CodeType parse_type()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
name = parse_identifier( toks, context );
|
name = parse_identifier();
|
||||||
if ( ! name )
|
if ( ! name )
|
||||||
return CodeInvalid;
|
return CodeInvalid;
|
||||||
|
|
||||||
@ -2924,7 +2920,7 @@ CodeType parse_type()
|
|||||||
|
|
||||||
CodeType parse_type( StrC def )
|
CodeType parse_type( StrC def )
|
||||||
{
|
{
|
||||||
check_parse_args( parse_type, def );
|
check_parse_args( def );
|
||||||
using namespace Parser;
|
using namespace Parser;
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
@ -2955,19 +2951,19 @@ CodeTypedef parse_typedef()
|
|||||||
eat( TokType::Decl_Typedef );
|
eat( TokType::Decl_Typedef );
|
||||||
|
|
||||||
if ( check( TokType::Decl_Enum ) )
|
if ( check( TokType::Decl_Enum ) )
|
||||||
type = parse_enum( toks, context );
|
type = parse_enum();
|
||||||
|
|
||||||
else if ( check(TokType::Decl_Class ) )
|
else if ( check(TokType::Decl_Class ) )
|
||||||
type = parse_class( toks, context );
|
type = parse_class();
|
||||||
|
|
||||||
else if ( check(TokType::Decl_Struct ) )
|
else if ( check(TokType::Decl_Struct ) )
|
||||||
type = parse_struct( toks, context );
|
type = parse_struct();
|
||||||
|
|
||||||
else if ( check(TokType::Decl_Union) )
|
else if ( check(TokType::Decl_Union) )
|
||||||
type = parse_union( toks, context );
|
type = parse_union();
|
||||||
|
|
||||||
else
|
else
|
||||||
type = parse_type( toks, context );
|
type = parse_type();
|
||||||
|
|
||||||
if ( ! check( TokType::Identifier ) )
|
if ( ! check( TokType::Identifier ) )
|
||||||
{
|
{
|
||||||
@ -2978,7 +2974,7 @@ CodeTypedef parse_typedef()
|
|||||||
name = currtok;
|
name = currtok;
|
||||||
eat( TokType::Identifier );
|
eat( TokType::Identifier );
|
||||||
|
|
||||||
array_expr = parse_array_decl( toks, context );
|
array_expr = parse_array_decl();
|
||||||
|
|
||||||
eat( TokType::Statement_End );
|
eat( TokType::Statement_End );
|
||||||
|
|
||||||
@ -3001,7 +2997,7 @@ CodeTypedef parse_typedef()
|
|||||||
|
|
||||||
CodeTypedef parse_typedef( StrC def )
|
CodeTypedef parse_typedef( StrC def )
|
||||||
{
|
{
|
||||||
check_parse_args( parse_typedef, def );
|
check_parse_args( def );
|
||||||
using namespace Parser;
|
using namespace Parser;
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
@ -3046,7 +3042,7 @@ CodeUnion parse_union()
|
|||||||
|
|
||||||
while ( ! check( TokType::BraceCurly_Close ) )
|
while ( ! check( TokType::BraceCurly_Close ) )
|
||||||
{
|
{
|
||||||
Code entry = parse_variable( toks, context );
|
Code entry = parse_variable();
|
||||||
|
|
||||||
if ( entry )
|
if ( entry )
|
||||||
body.append( entry );
|
body.append( entry );
|
||||||
@ -3075,7 +3071,7 @@ CodeUnion parse_union()
|
|||||||
|
|
||||||
CodeUnion parse_union( StrC def )
|
CodeUnion parse_union( StrC def )
|
||||||
{
|
{
|
||||||
check_parse_args( parse_union, def );
|
check_parse_args( def );
|
||||||
using namespace Parser;
|
using namespace Parser;
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
@ -3122,14 +3118,14 @@ CodeUsing parse_using()
|
|||||||
|
|
||||||
if ( currtok.IsAssign )
|
if ( currtok.IsAssign )
|
||||||
{
|
{
|
||||||
attributes = parse_attributes( toks, context );
|
attributes = parse_attributes();
|
||||||
|
|
||||||
eat( TokType::Operator );
|
eat( TokType::Operator );
|
||||||
|
|
||||||
type = parse_type( toks, context );
|
type = parse_type();
|
||||||
}
|
}
|
||||||
|
|
||||||
array_expr = parse_array_decl( toks, context );
|
array_expr = parse_array_decl();
|
||||||
|
|
||||||
eat( TokType::Statement_End );
|
eat( TokType::Statement_End );
|
||||||
|
|
||||||
@ -3164,7 +3160,7 @@ CodeUsing parse_using()
|
|||||||
|
|
||||||
CodeUsing parse_using( StrC def )
|
CodeUsing parse_using( StrC def )
|
||||||
{
|
{
|
||||||
check_parse_args( parse_using, def );
|
check_parse_args( def );
|
||||||
using namespace Parser;
|
using namespace Parser;
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
@ -3195,7 +3191,7 @@ CodeVar parse_variable()
|
|||||||
|
|
||||||
attributes = parse_attributes();
|
attributes = parse_attributes();
|
||||||
|
|
||||||
while ( left && tok_is_specifier( currtok ) )
|
while ( left && currtok.is_specifier() )
|
||||||
{
|
{
|
||||||
SpecifierT spec = ESpecifier::to_type( currtok );
|
SpecifierT spec = ESpecifier::to_type( currtok );
|
||||||
|
|
||||||
@ -3233,12 +3229,12 @@ CodeVar parse_variable()
|
|||||||
specifiers = def_specifiers( NumSpecifiers, specs_found );
|
specifiers = def_specifiers( NumSpecifiers, specs_found );
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeType type = parse_type( toks, context );
|
CodeType type = parse_type();
|
||||||
|
|
||||||
if ( type == Code::Invalid )
|
if ( type == Code::Invalid )
|
||||||
return CodeInvalid;
|
return CodeInvalid;
|
||||||
|
|
||||||
Context.Scope->Name = current;
|
Context.Scope->Name = currtok;
|
||||||
eat( TokType::Identifier );
|
eat( TokType::Identifier );
|
||||||
|
|
||||||
CodeVar result = parse_variable_after_name( mflags, attributes, specifiers, type, Context.Scope->Name );
|
CodeVar result = parse_variable_after_name( mflags, attributes, specifiers, type, Context.Scope->Name );
|
||||||
@ -3249,7 +3245,7 @@ CodeVar parse_variable()
|
|||||||
|
|
||||||
CodeVar parse_variable( StrC def )
|
CodeVar parse_variable( StrC def )
|
||||||
{
|
{
|
||||||
check_parse_args( parse_variable, def );
|
check_parse_args( def );
|
||||||
using namespace Parser;
|
using namespace Parser;
|
||||||
|
|
||||||
TokArray toks = lex( def );
|
TokArray toks = lex( def );
|
||||||
|
@ -17,7 +17,7 @@ sw str_fmt_out_err_va( char const* fmt, va_list va );
|
|||||||
// TODO : Move these to file handling.
|
// TODO : Move these to file handling.
|
||||||
|
|
||||||
sw str_fmt_file ( FileInfo* f, char const* fmt, ... );
|
sw str_fmt_file ( FileInfo* f, char const* fmt, ... );
|
||||||
sw str_fmt_file_va ( FileInfo* f, char const* fmt, va_list va )
|
sw str_fmt_file_va ( FileInfo* f, char const* fmt, va_list va );
|
||||||
|
|
||||||
constexpr
|
constexpr
|
||||||
char const* Msg_Invalid_Value = "INVALID VALUE PROVIDED";
|
char const* Msg_Invalid_Value = "INVALID VALUE PROVIDED";
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define GEN_ENFORCE_STRONG_CODE_TYPES
|
#define GEN_ENFORCE_STRONG_CODE_TYPES
|
||||||
#define GEN_EXPOSE_BACKEND
|
#define GEN_EXPOSE_BACKEND
|
||||||
#include "gen.cpp"
|
#include "gen.cpp"
|
||||||
#include "filesystem/scanner.hpp"
|
#include "file_processors/scanner.hpp"
|
||||||
#include "helpers/helper.hpp"
|
#include "helpers/helper.hpp"
|
||||||
|
|
||||||
using namespace gen;
|
using namespace gen;
|
||||||
|
@ -27,7 +27,7 @@ GEN_NS_BEGIN
|
|||||||
#include "components/interface.parsing.cpp"
|
#include "components/interface.parsing.cpp"
|
||||||
#include "components/untyped.cpp"
|
#include "components/untyped.cpp"
|
||||||
|
|
||||||
#include "file_proecessors/builder.cpp"
|
#include "file_processors/builder.cpp"
|
||||||
|
|
||||||
GEN_NS_END
|
GEN_NS_END
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user