cpp feature reduction usage in parser

This commit is contained in:
Edward R. Gonzalez 2024-12-03 09:31:27 -05:00
parent 63ebd0d094
commit a7c9dad9fd
8 changed files with 531 additions and 513 deletions

View File

@ -243,7 +243,12 @@ int gen_main()
Code untyped = scan_file( "components/interface.untyped.cpp" ); Code untyped = scan_file( "components/interface.untyped.cpp" );
CodeBody etoktype = gen_etoktype( "enums/ETokType.csv", "enums/AttributeTokens.csv" ); CodeBody etoktype = gen_etoktype( "enums/ETokType.csv", "enums/AttributeTokens.csv" );
CodeNS nspaced_etoktype = def_namespace( name(parser), def_namespace_body( args(etoktype)) ); //CodeNS nspaced_etoktype = def_namespace( name(parser), def_namespace_body( args(etoktype)) );
CodeBody nspaced_etoktype = def_global_body( args(
untyped_str(txt("GEN_NS_PARSER_BEGIN\n")),
etoktype,
untyped_str(txt("GEN_NS_PARSER_END\n"))
));
Builder Builder
src = Builder::open( "gen/gen.cpp" ); src = Builder::open( "gen/gen.cpp" );

View File

@ -5,237 +5,236 @@
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp) // This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)
namespace parser GEN_NS_PARSER_BEGIN
namespace ETokType
{ {
namespace ETokType
{
#define GEN_DEFINE_ATTRIBUTE_TOKENS Entry( Attribute_API_Export, "GEN_API_Export_Code" ) Entry( Attribute_API_Import, "GEN_API_Import_Code" ) #define GEN_DEFINE_ATTRIBUTE_TOKENS Entry( Attribute_API_Export, "GEN_API_Export_Code" ) Entry( Attribute_API_Import, "GEN_API_Import_Code" )
enum Type : u32 enum Type : u32
{ {
Invalid, Invalid,
Access_Private, Access_Private,
Access_Protected, Access_Protected,
Access_Public, Access_Public,
Access_MemberSymbol, Access_MemberSymbol,
Access_StaticSymbol, Access_StaticSymbol,
Ampersand, Ampersand,
Ampersand_DBL, Ampersand_DBL,
Assign_Classifer, Assign_Classifer,
Attribute_Open, Attribute_Open,
Attribute_Close, Attribute_Close,
BraceCurly_Open, BraceCurly_Open,
BraceCurly_Close, BraceCurly_Close,
BraceSquare_Open, BraceSquare_Open,
BraceSquare_Close, BraceSquare_Close,
Capture_Start, Capture_Start,
Capture_End, Capture_End,
Comment, Comment,
Comment_End, Comment_End,
Comment_Start, Comment_Start,
Char, Char,
Comma, Comma,
Decl_Class, Decl_Class,
Decl_GNU_Attribute, Decl_GNU_Attribute,
Decl_MSVC_Attribute, Decl_MSVC_Attribute,
Decl_Enum, Decl_Enum,
Decl_Extern_Linkage, Decl_Extern_Linkage,
Decl_Friend, Decl_Friend,
Decl_Module, Decl_Module,
Decl_Namespace, Decl_Namespace,
Decl_Operator, Decl_Operator,
Decl_Struct, Decl_Struct,
Decl_Template, Decl_Template,
Decl_Typedef, Decl_Typedef,
Decl_Using, Decl_Using,
Decl_Union, Decl_Union,
Identifier, Identifier,
Module_Import, Module_Import,
Module_Export, Module_Export,
NewLine, NewLine,
Number, Number,
Operator, Operator,
Preprocess_Hash, Preprocess_Hash,
Preprocess_Define, Preprocess_Define,
Preprocess_If, Preprocess_If,
Preprocess_IfDef, Preprocess_IfDef,
Preprocess_IfNotDef, Preprocess_IfNotDef,
Preprocess_ElIf, Preprocess_ElIf,
Preprocess_Else, Preprocess_Else,
Preprocess_EndIf, Preprocess_EndIf,
Preprocess_Include, Preprocess_Include,
Preprocess_Pragma, Preprocess_Pragma,
Preprocess_Content, Preprocess_Content,
Preprocess_Macro, Preprocess_Macro,
Preprocess_Unsupported, Preprocess_Unsupported,
Spec_Alignas, Spec_Alignas,
Spec_Const, Spec_Const,
Spec_Consteval, Spec_Consteval,
Spec_Constexpr, Spec_Constexpr,
Spec_Constinit, Spec_Constinit,
Spec_Explicit, Spec_Explicit,
Spec_Extern, Spec_Extern,
Spec_Final, Spec_Final,
Spec_ForceInline, Spec_ForceInline,
Spec_Global, Spec_Global,
Spec_Inline, Spec_Inline,
Spec_Internal_Linkage, Spec_Internal_Linkage,
Spec_LocalPersist, Spec_LocalPersist,
Spec_Mutable, Spec_Mutable,
Spec_NeverInline, Spec_NeverInline,
Spec_Override, Spec_Override,
Spec_Static, Spec_Static,
Spec_ThreadLocal, Spec_ThreadLocal,
Spec_Volatile, Spec_Volatile,
Spec_Virtual, Spec_Virtual,
Star, Star,
Statement_End, Statement_End,
StaticAssert, StaticAssert,
String, String,
Type_Typename, Type_Typename,
Type_Unsigned, Type_Unsigned,
Type_Signed, Type_Signed,
Type_Short, Type_Short,
Type_Long, Type_Long,
Type_bool, Type_bool,
Type_char, Type_char,
Type_int, Type_int,
Type_double, Type_double,
Type_MS_int8, Type_MS_int8,
Type_MS_int16, Type_MS_int16,
Type_MS_int32, Type_MS_int32,
Type_MS_int64, Type_MS_int64,
Type_MS_W64, Type_MS_W64,
Varadic_Argument, Varadic_Argument,
__Attributes_Start, __Attributes_Start,
Attribute_API_Export, Attribute_API_Export,
Attribute_API_Import, Attribute_API_Import,
NumTokens NumTokens
};
inline StrC to_str( Type type )
{
local_persist StrC lookup[] {
{ sizeof( "__invalid__" ), "__invalid__" },
{ sizeof( "private" ), "private" },
{ sizeof( "protected" ), "protected" },
{ sizeof( "public" ), "public" },
{ sizeof( "." ), "." },
{ sizeof( "::" ), "::" },
{ sizeof( "&" ), "&" },
{ sizeof( "&&" ), "&&" },
{ sizeof( ":" ), ":" },
{ sizeof( "[[" ), "[[" },
{ sizeof( "]]" ), "]]" },
{ sizeof( "{" ), "{" },
{ sizeof( "}" ), "}" },
{ sizeof( "[" ), "[" },
{ sizeof( "]" ), "]" },
{ sizeof( "(" ), "(" },
{ sizeof( ")" ), ")" },
{ sizeof( "__comment__" ), "__comment__" },
{ sizeof( "__comment_end__" ), "__comment_end__" },
{ sizeof( "__comment_start__" ), "__comment_start__" },
{ sizeof( "__character__" ), "__character__" },
{ sizeof( "," ), "," },
{ sizeof( "class" ), "class" },
{ sizeof( "__attribute__" ), "__attribute__" },
{ sizeof( "__declspec" ), "__declspec" },
{ sizeof( "enum" ), "enum" },
{ sizeof( "extern" ), "extern" },
{ sizeof( "friend" ), "friend" },
{ sizeof( "module" ), "module" },
{ sizeof( "namespace" ), "namespace" },
{ sizeof( "operator" ), "operator" },
{ sizeof( "struct" ), "struct" },
{ sizeof( "template" ), "template" },
{ sizeof( "typedef" ), "typedef" },
{ sizeof( "using" ), "using" },
{ sizeof( "union" ), "union" },
{ sizeof( "__identifier__" ), "__identifier__" },
{ sizeof( "import" ), "import" },
{ sizeof( "export" ), "export" },
{ sizeof( "__new_line__" ), "__new_line__" },
{ sizeof( "__number__" ), "__number__" },
{ sizeof( "__operator__" ), "__operator__" },
{ sizeof( "#" ), "#" },
{ sizeof( "define" ), "define" },
{ sizeof( "if" ), "if" },
{ sizeof( "ifdef" ), "ifdef" },
{ sizeof( "ifndef" ), "ifndef" },
{ sizeof( "elif" ), "elif" },
{ sizeof( "else" ), "else" },
{ sizeof( "endif" ), "endif" },
{ sizeof( "include" ), "include" },
{ sizeof( "pragma" ), "pragma" },
{ sizeof( "__macro_content__" ), "__macro_content__" },
{ sizeof( "__macro__" ), "__macro__" },
{ sizeof( "__unsupported__" ), "__unsupported__" },
{ sizeof( "alignas" ), "alignas" },
{ sizeof( "const" ), "const" },
{ sizeof( "consteval" ), "consteval" },
{ sizeof( "constexpr" ), "constexpr" },
{ sizeof( "constinit" ), "constinit" },
{ sizeof( "explicit" ), "explicit" },
{ sizeof( "extern" ), "extern" },
{ sizeof( "final" ), "final" },
{ sizeof( "forceinline" ), "forceinline" },
{ sizeof( "global" ), "global" },
{ sizeof( "inline" ), "inline" },
{ sizeof( "internal" ), "internal" },
{ sizeof( "local_persist" ), "local_persist" },
{ sizeof( "mutable" ), "mutable" },
{ sizeof( "neverinline" ), "neverinline" },
{ sizeof( "override" ), "override" },
{ sizeof( "static" ), "static" },
{ sizeof( "thread_local" ), "thread_local" },
{ sizeof( "volatile" ), "volatile" },
{ sizeof( "virtual" ), "virtual" },
{ sizeof( "*" ), "*" },
{ sizeof( ";" ), ";" },
{ sizeof( "static_assert" ), "static_assert" },
{ sizeof( "__string__" ), "__string__" },
{ sizeof( "typename" ), "typename" },
{ sizeof( "unsigned" ), "unsigned" },
{ sizeof( "signed" ), "signed" },
{ sizeof( "short" ), "short" },
{ sizeof( "long" ), "long" },
{ sizeof( "bool" ), "bool" },
{ sizeof( "char" ), "char" },
{ sizeof( "int" ), "int" },
{ sizeof( "double" ), "double" },
{ sizeof( "__int8" ), "__int8" },
{ sizeof( "__int16" ), "__int16" },
{ sizeof( "__int32" ), "__int32" },
{ sizeof( "__int64" ), "__int64" },
{ sizeof( "_W64" ), "_W64" },
{ sizeof( "..." ), "..." },
{ sizeof( "__attrib_start__" ), "__attrib_start__" },
{ sizeof( "GEN_API_Export_Code" ), "GEN_API_Export_Code" },
{ sizeof( "GEN_API_Import_Code" ), "GEN_API_Import_Code" },
}; };
return lookup[type];
}
inline StrC to_str( Type type ) inline Type to_type( StrC str )
{
local_persist u32 keymap[NumTokens];
do_once_start for ( u32 index = 0; index < NumTokens; index++ )
{ {
local_persist StrC lookup[] { StrC enum_str = to_str( (Type)index );
{ sizeof( "__invalid__" ), "__invalid__" }, keymap[index] = crc32( enum_str.Ptr, enum_str.Len - 1 );
{ sizeof( "private" ), "private" },
{ sizeof( "protected" ), "protected" },
{ sizeof( "public" ), "public" },
{ sizeof( "." ), "." },
{ sizeof( "::" ), "::" },
{ sizeof( "&" ), "&" },
{ sizeof( "&&" ), "&&" },
{ sizeof( ":" ), ":" },
{ sizeof( "[[" ), "[[" },
{ sizeof( "]]" ), "]]" },
{ sizeof( "{" ), "{" },
{ sizeof( "}" ), "}" },
{ sizeof( "[" ), "[" },
{ sizeof( "]" ), "]" },
{ sizeof( "(" ), "(" },
{ sizeof( ")" ), ")" },
{ sizeof( "__comment__" ), "__comment__" },
{ sizeof( "__comment_end__" ), "__comment_end__" },
{ sizeof( "__comment_start__" ), "__comment_start__" },
{ sizeof( "__character__" ), "__character__" },
{ sizeof( "," ), "," },
{ sizeof( "class" ), "class" },
{ sizeof( "__attribute__" ), "__attribute__" },
{ sizeof( "__declspec" ), "__declspec" },
{ sizeof( "enum" ), "enum" },
{ sizeof( "extern" ), "extern" },
{ sizeof( "friend" ), "friend" },
{ sizeof( "module" ), "module" },
{ sizeof( "namespace" ), "namespace" },
{ sizeof( "operator" ), "operator" },
{ sizeof( "struct" ), "struct" },
{ sizeof( "template" ), "template" },
{ sizeof( "typedef" ), "typedef" },
{ sizeof( "using" ), "using" },
{ sizeof( "union" ), "union" },
{ sizeof( "__identifier__" ), "__identifier__" },
{ sizeof( "import" ), "import" },
{ sizeof( "export" ), "export" },
{ sizeof( "__new_line__" ), "__new_line__" },
{ sizeof( "__number__" ), "__number__" },
{ sizeof( "__operator__" ), "__operator__" },
{ sizeof( "#" ), "#" },
{ sizeof( "define" ), "define" },
{ sizeof( "if" ), "if" },
{ sizeof( "ifdef" ), "ifdef" },
{ sizeof( "ifndef" ), "ifndef" },
{ sizeof( "elif" ), "elif" },
{ sizeof( "else" ), "else" },
{ sizeof( "endif" ), "endif" },
{ sizeof( "include" ), "include" },
{ sizeof( "pragma" ), "pragma" },
{ sizeof( "__macro_content__" ), "__macro_content__" },
{ sizeof( "__macro__" ), "__macro__" },
{ sizeof( "__unsupported__" ), "__unsupported__" },
{ sizeof( "alignas" ), "alignas" },
{ sizeof( "const" ), "const" },
{ sizeof( "consteval" ), "consteval" },
{ sizeof( "constexpr" ), "constexpr" },
{ sizeof( "constinit" ), "constinit" },
{ sizeof( "explicit" ), "explicit" },
{ sizeof( "extern" ), "extern" },
{ sizeof( "final" ), "final" },
{ sizeof( "forceinline" ), "forceinline" },
{ sizeof( "global" ), "global" },
{ sizeof( "inline" ), "inline" },
{ sizeof( "internal" ), "internal" },
{ sizeof( "local_persist" ), "local_persist" },
{ sizeof( "mutable" ), "mutable" },
{ sizeof( "neverinline" ), "neverinline" },
{ sizeof( "override" ), "override" },
{ sizeof( "static" ), "static" },
{ sizeof( "thread_local" ), "thread_local" },
{ sizeof( "volatile" ), "volatile" },
{ sizeof( "virtual" ), "virtual" },
{ sizeof( "*" ), "*" },
{ sizeof( ";" ), ";" },
{ sizeof( "static_assert" ), "static_assert" },
{ sizeof( "__string__" ), "__string__" },
{ sizeof( "typename" ), "typename" },
{ sizeof( "unsigned" ), "unsigned" },
{ sizeof( "signed" ), "signed" },
{ sizeof( "short" ), "short" },
{ sizeof( "long" ), "long" },
{ sizeof( "bool" ), "bool" },
{ sizeof( "char" ), "char" },
{ sizeof( "int" ), "int" },
{ sizeof( "double" ), "double" },
{ sizeof( "__int8" ), "__int8" },
{ sizeof( "__int16" ), "__int16" },
{ sizeof( "__int32" ), "__int32" },
{ sizeof( "__int64" ), "__int64" },
{ sizeof( "_W64" ), "_W64" },
{ sizeof( "..." ), "..." },
{ sizeof( "__attrib_start__" ), "__attrib_start__" },
{ sizeof( "GEN_API_Export_Code" ), "GEN_API_Export_Code" },
{ sizeof( "GEN_API_Import_Code" ), "GEN_API_Import_Code" },
};
return lookup[type];
} }
do_once_end u32 hash = crc32( str.Ptr, str.Len );
inline Type to_type( StrC str ) for ( u32 index = 0; index < NumTokens; index++ )
{ {
local_persist u32 keymap[NumTokens]; if ( keymap[index] == hash )
do_once_start for ( u32 index = 0; index < NumTokens; index++ ) return (Type)index;
{
StrC enum_str = to_str( (Type)index );
keymap[index] = crc32( enum_str.Ptr, enum_str.Len - 1 );
}
do_once_end u32 hash = crc32( str.Ptr, str.Len );
for ( u32 index = 0; index < NumTokens; index++ )
{
if ( keymap[index] == hash )
return (Type)index;
}
return Invalid;
} }
return Invalid;
}
} // namespace ETokType } // namespace ETokType
using TokType = ETokType::Type; using TokType = ETokType::Type;
GEN_NS_PARSER_END
} // namespace parser

View File

@ -10,23 +10,24 @@
CodeClass parse_class( StrC def ) CodeClass parse_class( StrC def )
{ {
GEN_USING_NS_PARSER;
check_parse_args( def ); check_parse_args( def );
parser::TokArray toks = parser::lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return InvalidCode; return InvalidCode;
parser::Context.Tokens = toks; Context.Tokens = toks;
push_scope(); push_scope();
CodeClass result = (CodeClass) parser::parse_class_struct( parser::TokType::Decl_Class ); CodeClass result = (CodeClass) parse_class_struct( parser::TokType::Decl_Class );
parser::Context.pop(); pop(& Context);
return result; return result;
} }
CodeConstructor parse_constructor( StrC def ) CodeConstructor parse_constructor( StrC def )
{ {
GEN_USING_NS_PARSER;
check_parse_args( def ); check_parse_args( def );
using namespace parser;
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
@ -58,8 +59,8 @@ CodeConstructor parse_constructor( StrC def )
break; break;
default : default :
log_failure( "Invalid specifier %s for variable\n%s", ESpecifier::to_str( spec ), Context.to_string() ); log_failure( "Invalid specifier %s for variable\n%s", ESpecifier::to_str( spec ), to_string(Context) );
Context.pop(); pop(& Context);
return InvalidCode; return InvalidCode;
} }
@ -85,8 +86,8 @@ CodeConstructor parse_constructor( StrC def )
CodeDestructor parse_destructor( StrC def ) CodeDestructor parse_destructor( StrC def )
{ {
GEN_USING_NS_PARSER;
check_parse_args( def ); check_parse_args( def );
using namespace parser;
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
@ -102,13 +103,13 @@ CodeDestructor parse_destructor( StrC def )
CodeEnum parse_enum( StrC def ) CodeEnum parse_enum( StrC def )
{ {
GEN_USING_NS_PARSER;
check_parse_args( def ); check_parse_args( def );
using namespace parser;
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
{ {
Context.pop(); pop(& Context);
return InvalidCode; return InvalidCode;
} }
@ -118,8 +119,8 @@ CodeEnum parse_enum( StrC def )
CodeBody parse_export_body( StrC def ) CodeBody parse_export_body( StrC def )
{ {
GEN_USING_NS_PARSER;
check_parse_args( def ); check_parse_args( def );
using namespace parser;
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
@ -131,8 +132,8 @@ CodeBody parse_export_body( StrC def )
CodeExtern parse_extern_link( StrC def ) CodeExtern parse_extern_link( StrC def )
{ {
GEN_USING_NS_PARSER;
check_parse_args( def ); check_parse_args( def );
using namespace parser;
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
@ -144,8 +145,8 @@ CodeExtern parse_extern_link( StrC def )
CodeFriend parse_friend( StrC def ) CodeFriend parse_friend( StrC def )
{ {
GEN_USING_NS_PARSER;
check_parse_args( def ); check_parse_args( def );
using namespace parser;
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
@ -157,8 +158,8 @@ CodeFriend parse_friend( StrC def )
CodeFn parse_function( StrC def ) CodeFn parse_function( StrC def )
{ {
GEN_USING_NS_PARSER;
check_parse_args( def ); check_parse_args( def );
using namespace parser;
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
@ -170,8 +171,8 @@ CodeFn parse_function( StrC def )
CodeBody parse_global_body( StrC def ) CodeBody parse_global_body( StrC def )
{ {
GEN_USING_NS_PARSER;
check_parse_args( def ); check_parse_args( def );
using namespace parser;
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
@ -180,14 +181,14 @@ CodeBody parse_global_body( StrC def )
Context.Tokens = toks; Context.Tokens = toks;
push_scope(); push_scope();
CodeBody result = parse_global_nspace( ECode::Global_Body ); CodeBody result = parse_global_nspace( ECode::Global_Body );
Context.pop(); pop(& Context);
return result; return result;
} }
CodeNS parse_namespace( StrC def ) CodeNS parse_namespace( StrC def )
{ {
GEN_USING_NS_PARSER;
check_parse_args( def ); check_parse_args( def );
using namespace parser;
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
@ -199,8 +200,8 @@ CodeNS parse_namespace( StrC def )
CodeOperator parse_operator( StrC def ) CodeOperator parse_operator( StrC def )
{ {
GEN_USING_NS_PARSER;
check_parse_args( def ); check_parse_args( def );
using namespace parser;
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
@ -212,8 +213,8 @@ CodeOperator parse_operator( StrC def )
CodeOpCast parse_operator_cast( StrC def ) CodeOpCast parse_operator_cast( StrC def )
{ {
GEN_USING_NS_PARSER;
check_parse_args( def ); check_parse_args( def );
using namespace parser;
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
@ -225,8 +226,8 @@ CodeOpCast parse_operator_cast( StrC def )
CodeStruct parse_struct( StrC def ) CodeStruct parse_struct( StrC def )
{ {
GEN_USING_NS_PARSER;
check_parse_args( def ); check_parse_args( def );
using namespace parser;
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
@ -235,14 +236,14 @@ CodeStruct parse_struct( StrC def )
Context.Tokens = toks; Context.Tokens = toks;
push_scope(); push_scope();
CodeStruct result = (CodeStruct) parse_class_struct( TokType::Decl_Struct ); CodeStruct result = (CodeStruct) parse_class_struct( TokType::Decl_Struct );
Context.pop(); pop(& Context);
return result; return result;
} }
CodeTemplate parse_template( StrC def ) CodeTemplate parse_template( StrC def )
{ {
GEN_USING_NS_PARSER;
check_parse_args( def ); check_parse_args( def );
using namespace parser;
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
@ -254,8 +255,8 @@ CodeTemplate parse_template( StrC def )
CodeType parse_type( StrC def ) CodeType parse_type( StrC def )
{ {
GEN_USING_NS_PARSER;
check_parse_args( def ); check_parse_args( def );
using namespace parser;
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
@ -267,8 +268,8 @@ CodeType parse_type( StrC def )
CodeTypedef parse_typedef( StrC def ) CodeTypedef parse_typedef( StrC def )
{ {
GEN_USING_NS_PARSER;
check_parse_args( def ); check_parse_args( def );
using namespace parser;
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
@ -280,8 +281,8 @@ CodeTypedef parse_typedef( StrC def )
CodeUnion parse_union( StrC def ) CodeUnion parse_union( StrC def )
{ {
GEN_USING_NS_PARSER;
check_parse_args( def ); check_parse_args( def );
using namespace parser;
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
@ -293,8 +294,8 @@ CodeUnion parse_union( StrC def )
CodeUsing parse_using( StrC def ) CodeUsing parse_using( StrC def )
{ {
GEN_USING_NS_PARSER;
check_parse_args( def ); check_parse_args( def );
using namespace parser;
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
@ -306,8 +307,8 @@ CodeUsing parse_using( StrC def )
CodeVar parse_variable( StrC def ) CodeVar parse_variable( StrC def )
{ {
GEN_USING_NS_PARSER;
check_parse_args( def ); check_parse_args( def );
using namespace parser;
TokArray toks = lex( def ); TokArray toks = lex( def );
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )

View File

@ -499,7 +499,7 @@ CodeConstructor def_constructor( Opts_def_constructor p )
{ {
CodeParam params = p.params; CodeParam params = p.params;
Code initializer_list = p.initializer_list; Code initializer_list = p.initializer_list;
Code body = p.body; Code body = p.body;
if ( params && params->Type != ECode::Parameters ) if ( params && params->Type != ECode::Parameters )
{ {

View File

@ -450,7 +450,7 @@ s32 lex_preprocessor_directive( LexContext* ctx )
} }
forceinline forceinline
void lex_found_token( LexContext* ctx ) void lex_found_token( LexContext* ctx )
{ {
if ( ctx->token.Type != TokType::Invalid ) if ( ctx->token.Type != TokType::Invalid )
{ {

File diff suppressed because it is too large Load Diff

View File

@ -135,6 +135,7 @@
# if GEN_COMPILER_C # if GEN_COMPILER_C
# define GEN_NS_PARSER_BEGIN # define GEN_NS_PARSER_BEGIN
# define GEN_NS_PARSER_END # define GEN_NS_PARSER_END
# define GEN_USING_NS_PARSER
# define GEN_NS_ENUM_BEGIN # define GEN_NS_ENUM_BEGIN
# define GEN_NS_ENUM_END # define GEN_NS_ENUM_END
# define GEN_NS # define GEN_NS
@ -143,6 +144,7 @@
# else # else
# define GEN_NS_PARSER_BEGIN namespace parser { # define GEN_NS_PARSER_BEGIN namespace parser {
# define GEN_NS_PARSER_END } # define GEN_NS_PARSER_END }
# define GEN_USING_NS_PARSER using namespace parser
# define GEN_NS_ENUM_BEGIN namespace gen_internal_enums { # define GEN_NS_ENUM_BEGIN namespace gen_internal_enums {
# define GEN_NS_ENUM_END } # define GEN_NS_ENUM_END }
# define GEN_NS :: # define GEN_NS ::
@ -152,6 +154,7 @@
#else #else
# define GEN_NS_PARSER_BEGIN namespace parser { # define GEN_NS_PARSER_BEGIN namespace parser {
# define GEN_NS_PARSER_END } # define GEN_NS_PARSER_END }
# define GEN_USING_NS_PARSER using namespace parser
# define GEN_NS_ENUM_BEGIN namespace gen_internal_enums { # define GEN_NS_ENUM_BEGIN namespace gen_internal_enums {
# define GEN_NS_ENUM_END } # define GEN_NS_ENUM_END }
# define GEN_NS gen:: # define GEN_NS gen::

View File

@ -335,10 +335,17 @@ CodeBody gen_etoktype( char const* etok_path, char const* attr_path )
#pragma pop_macro("do_once_start") #pragma pop_macro("do_once_start")
#pragma pop_macro("do_once_end") #pragma pop_macro("do_once_end")
CodeNS nspace = def_namespace( name(ETokType), def_namespace_body( args( attribute_entires_def, enum_code, to_str, to_type ) ) ); //CodeNS nspace = def_namespace( name(ETokType), def_namespace_body( args( attribute_entires_def, enum_code, to_str, to_type ) ) );
CodeUsing td_toktype = def_using( name(TokType), def_type( name(ETokType::Type) ) ); CodeUsing td_toktype = def_using( name(TokType), def_type( name(ETokType::Type) ) );
return def_global_body( args( nspace, td_toktype ) ); return def_global_body( args(
untyped_str(txt("GEN_NS_PARSER_BEGIN\n")),
attribute_entires_def,
enum_code,
to_str,
td_toktype,
untyped_str(txt("GEN_NS_PARSER_END\n"))
));
} }
CodeBody gen_ast_inlines() CodeBody gen_ast_inlines()