mirror of
https://github.com/Ed94/gencpp.git
synced 2024-12-22 15:54:45 -08:00
Corrected order of Str to how the slice type is defined in Odin and RAD Debugger (my reference on slice types)
This commit is contained in:
parent
6ffdca8595
commit
012fcb6bd5
@ -118,7 +118,7 @@ Code scan_file( char const* path )
|
|||||||
|
|
||||||
CodeBody parse_file( const char* path ) {
|
CodeBody parse_file( const char* path ) {
|
||||||
FileContents file = file_read_contents( GlobalAllocator, true, path );
|
FileContents file = file_read_contents( GlobalAllocator, true, path );
|
||||||
Str content = { file.size, (char const*)file.data };
|
Str content = { (char const*)file.data, file.size };
|
||||||
CodeBody code = parse_global_body( content );
|
CodeBody code = parse_global_body( content );
|
||||||
log_fmt("\nParsed: %s\n", path);
|
log_fmt("\nParsed: %s\n", path);
|
||||||
return code;
|
return code;
|
||||||
|
@ -41,6 +41,7 @@ int gen_main()
|
|||||||
CodeBody ecode = gen_ecode ( "enums/ECodeTypes.csv" );
|
CodeBody ecode = gen_ecode ( "enums/ECodeTypes.csv" );
|
||||||
CodeBody eoperator = gen_eoperator ( "enums/EOperator.csv" );
|
CodeBody eoperator = gen_eoperator ( "enums/EOperator.csv" );
|
||||||
CodeBody especifier = gen_especifier( "enums/ESpecifier.csv" );
|
CodeBody especifier = gen_especifier( "enums/ESpecifier.csv" );
|
||||||
|
CodeBody etoktype = gen_etoktype ( "enums/ETokType.csv", "enums/AttributeTokens.csv" );
|
||||||
CodeBody ast_inlines = gen_ast_inlines();
|
CodeBody ast_inlines = gen_ast_inlines();
|
||||||
|
|
||||||
Builder header_ecode = builder_open( "components/gen/ecodetypes.hpp" );
|
Builder header_ecode = builder_open( "components/gen/ecodetypes.hpp" );
|
||||||
@ -58,6 +59,11 @@ int gen_main()
|
|||||||
builder_print( & header_especifier, format(especifier) );
|
builder_print( & header_especifier, format(especifier) );
|
||||||
builder_write( & header_especifier);
|
builder_write( & header_especifier);
|
||||||
|
|
||||||
|
Builder header_etoktype = builder_open( "components/gen/etoktype.cpp" );
|
||||||
|
builder_print( & header_etoktype, gen_component_header );
|
||||||
|
builder_print( & header_etoktype, format(etoktype) );
|
||||||
|
builder_write( & header_etoktype);
|
||||||
|
|
||||||
Builder header_ast_inlines = builder_open( "components/gen/ast_inlines.hpp" );
|
Builder header_ast_inlines = builder_open( "components/gen/ast_inlines.hpp" );
|
||||||
builder_print( & header_ast_inlines, gen_component_header );
|
builder_print( & header_ast_inlines, gen_component_header );
|
||||||
builder_print( & header_ast_inlines, format(ast_inlines) );
|
builder_print( & header_ast_inlines, format(ast_inlines) );
|
||||||
|
@ -75,67 +75,67 @@ enum CodeType : u32
|
|||||||
inline Str codetype_to_str( CodeType type )
|
inline Str codetype_to_str( CodeType type )
|
||||||
{
|
{
|
||||||
local_persist Str lookup[61] = {
|
local_persist Str lookup[61] = {
|
||||||
{ sizeof( "Invalid" ), "Invalid" },
|
{ "Invalid", sizeof( "Invalid" ) },
|
||||||
{ sizeof( "Untyped" ), "Untyped" },
|
{ "Untyped", sizeof( "Untyped" ) },
|
||||||
{ sizeof( "NewLine" ), "NewLine" },
|
{ "NewLine", sizeof( "NewLine" ) },
|
||||||
{ sizeof( "Comment" ), "Comment" },
|
{ "Comment", sizeof( "Comment" ) },
|
||||||
{ sizeof( "Access_Private" ), "Access_Private" },
|
{ "Access_Private", sizeof( "Access_Private" ) },
|
||||||
{ sizeof( "Access_Protected" ), "Access_Protected" },
|
{ "Access_Protected", sizeof( "Access_Protected" ) },
|
||||||
{ sizeof( "Access_Public" ), "Access_Public" },
|
{ "Access_Public", sizeof( "Access_Public" ) },
|
||||||
{ sizeof( "PlatformAttributes" ), "PlatformAttributes" },
|
{ "PlatformAttributes", sizeof( "PlatformAttributes" ) },
|
||||||
{ sizeof( "Class" ), "Class" },
|
{ "Class", sizeof( "Class" ) },
|
||||||
{ sizeof( "Class_Fwd" ), "Class_Fwd" },
|
{ "Class_Fwd", sizeof( "Class_Fwd" ) },
|
||||||
{ sizeof( "Class_Body" ), "Class_Body" },
|
{ "Class_Body", sizeof( "Class_Body" ) },
|
||||||
{ sizeof( "Constructor" ), "Constructor" },
|
{ "Constructor", sizeof( "Constructor" ) },
|
||||||
{ sizeof( "Constructor_Fwd" ), "Constructor_Fwd" },
|
{ "Constructor_Fwd", sizeof( "Constructor_Fwd" ) },
|
||||||
{ sizeof( "Destructor" ), "Destructor" },
|
{ "Destructor", sizeof( "Destructor" ) },
|
||||||
{ sizeof( "Destructor_Fwd" ), "Destructor_Fwd" },
|
{ "Destructor_Fwd", sizeof( "Destructor_Fwd" ) },
|
||||||
{ sizeof( "Enum" ), "Enum" },
|
{ "Enum", sizeof( "Enum" ) },
|
||||||
{ sizeof( "Enum_Fwd" ), "Enum_Fwd" },
|
{ "Enum_Fwd", sizeof( "Enum_Fwd" ) },
|
||||||
{ sizeof( "Enum_Body" ), "Enum_Body" },
|
{ "Enum_Body", sizeof( "Enum_Body" ) },
|
||||||
{ sizeof( "Enum_Class" ), "Enum_Class" },
|
{ "Enum_Class", sizeof( "Enum_Class" ) },
|
||||||
{ sizeof( "Enum_Class_Fwd" ), "Enum_Class_Fwd" },
|
{ "Enum_Class_Fwd", sizeof( "Enum_Class_Fwd" ) },
|
||||||
{ sizeof( "Execution" ), "Execution" },
|
{ "Execution", sizeof( "Execution" ) },
|
||||||
{ sizeof( "Export_Body" ), "Export_Body" },
|
{ "Export_Body", sizeof( "Export_Body" ) },
|
||||||
{ sizeof( "Extern_Linkage" ), "Extern_Linkage" },
|
{ "Extern_Linkage", sizeof( "Extern_Linkage" ) },
|
||||||
{ sizeof( "Extern_Linkage_Body" ), "Extern_Linkage_Body" },
|
{ "Extern_Linkage_Body", sizeof( "Extern_Linkage_Body" ) },
|
||||||
{ sizeof( "Friend" ), "Friend" },
|
{ "Friend", sizeof( "Friend" ) },
|
||||||
{ sizeof( "Function" ), "Function" },
|
{ "Function", sizeof( "Function" ) },
|
||||||
{ sizeof( "Function_Fwd" ), "Function_Fwd" },
|
{ "Function_Fwd", sizeof( "Function_Fwd" ) },
|
||||||
{ sizeof( "Function_Body" ), "Function_Body" },
|
{ "Function_Body", sizeof( "Function_Body" ) },
|
||||||
{ sizeof( "Global_Body" ), "Global_Body" },
|
{ "Global_Body", sizeof( "Global_Body" ) },
|
||||||
{ sizeof( "Module" ), "Module" },
|
{ "Module", sizeof( "Module" ) },
|
||||||
{ sizeof( "Namespace" ), "Namespace" },
|
{ "Namespace", sizeof( "Namespace" ) },
|
||||||
{ sizeof( "Namespace_Body" ), "Namespace_Body" },
|
{ "Namespace_Body", sizeof( "Namespace_Body" ) },
|
||||||
{ sizeof( "Operator" ), "Operator" },
|
{ "Operator", sizeof( "Operator" ) },
|
||||||
{ sizeof( "Operator_Fwd" ), "Operator_Fwd" },
|
{ "Operator_Fwd", sizeof( "Operator_Fwd" ) },
|
||||||
{ sizeof( "Operator_Member" ), "Operator_Member" },
|
{ "Operator_Member", sizeof( "Operator_Member" ) },
|
||||||
{ sizeof( "Operator_Member_Fwd" ), "Operator_Member_Fwd" },
|
{ "Operator_Member_Fwd", sizeof( "Operator_Member_Fwd" ) },
|
||||||
{ sizeof( "Operator_Cast" ), "Operator_Cast" },
|
{ "Operator_Cast", sizeof( "Operator_Cast" ) },
|
||||||
{ sizeof( "Operator_Cast_Fwd" ), "Operator_Cast_Fwd" },
|
{ "Operator_Cast_Fwd", sizeof( "Operator_Cast_Fwd" ) },
|
||||||
{ sizeof( "Parameters" ), "Parameters" },
|
{ "Parameters", sizeof( "Parameters" ) },
|
||||||
{ sizeof( "Preprocess_Define" ), "Preprocess_Define" },
|
{ "Preprocess_Define", sizeof( "Preprocess_Define" ) },
|
||||||
{ sizeof( "Preprocess_Include" ), "Preprocess_Include" },
|
{ "Preprocess_Include", sizeof( "Preprocess_Include" ) },
|
||||||
{ sizeof( "Preprocess_If" ), "Preprocess_If" },
|
{ "Preprocess_If", sizeof( "Preprocess_If" ) },
|
||||||
{ sizeof( "Preprocess_IfDef" ), "Preprocess_IfDef" },
|
{ "Preprocess_IfDef", sizeof( "Preprocess_IfDef" ) },
|
||||||
{ sizeof( "Preprocess_IfNotDef" ), "Preprocess_IfNotDef" },
|
{ "Preprocess_IfNotDef", sizeof( "Preprocess_IfNotDef" ) },
|
||||||
{ sizeof( "Preprocess_ElIf" ), "Preprocess_ElIf" },
|
{ "Preprocess_ElIf", sizeof( "Preprocess_ElIf" ) },
|
||||||
{ sizeof( "Preprocess_Else" ), "Preprocess_Else" },
|
{ "Preprocess_Else", sizeof( "Preprocess_Else" ) },
|
||||||
{ sizeof( "Preprocess_EndIf" ), "Preprocess_EndIf" },
|
{ "Preprocess_EndIf", sizeof( "Preprocess_EndIf" ) },
|
||||||
{ sizeof( "Preprocess_Pragma" ), "Preprocess_Pragma" },
|
{ "Preprocess_Pragma", sizeof( "Preprocess_Pragma" ) },
|
||||||
{ sizeof( "Specifiers" ), "Specifiers" },
|
{ "Specifiers", sizeof( "Specifiers" ) },
|
||||||
{ sizeof( "Struct" ), "Struct" },
|
{ "Struct", sizeof( "Struct" ) },
|
||||||
{ sizeof( "Struct_Fwd" ), "Struct_Fwd" },
|
{ "Struct_Fwd", sizeof( "Struct_Fwd" ) },
|
||||||
{ sizeof( "Struct_Body" ), "Struct_Body" },
|
{ "Struct_Body", sizeof( "Struct_Body" ) },
|
||||||
{ sizeof( "Template" ), "Template" },
|
{ "Template", sizeof( "Template" ) },
|
||||||
{ sizeof( "Typedef" ), "Typedef" },
|
{ "Typedef", sizeof( "Typedef" ) },
|
||||||
{ sizeof( "Typename" ), "Typename" },
|
{ "Typename", sizeof( "Typename" ) },
|
||||||
{ sizeof( "Union" ), "Union" },
|
{ "Union", sizeof( "Union" ) },
|
||||||
{ sizeof( "Union_Fwd" ), "Union_Fwd" },
|
{ "Union_Fwd", sizeof( "Union_Fwd" ) },
|
||||||
{ sizeof( "Union_Body" ), "Union_Body" },
|
{ "Union_Body", sizeof( "Union_Body" ) },
|
||||||
{ sizeof( "Using" ), "Using" },
|
{ "Using", sizeof( "Using" ) },
|
||||||
{ sizeof( "Using_Namespace" ), "Using_Namespace" },
|
{ "Using_Namespace", sizeof( "Using_Namespace" ) },
|
||||||
{ sizeof( "Variable" ), "Variable" },
|
{ "Variable", sizeof( "Variable" ) },
|
||||||
};
|
};
|
||||||
return lookup[type];
|
return lookup[type];
|
||||||
}
|
}
|
||||||
@ -143,67 +143,67 @@ inline Str codetype_to_str( CodeType type )
|
|||||||
inline Str codetype_to_keyword_str( CodeType type )
|
inline Str codetype_to_keyword_str( CodeType type )
|
||||||
{
|
{
|
||||||
local_persist Str lookup[61] = {
|
local_persist Str lookup[61] = {
|
||||||
{ sizeof( "__NA__" ) - 1, "__NA__" },
|
{ "__NA__", sizeof( "__NA__" ) - 1 },
|
||||||
{ sizeof( "__NA__" ) - 1, "__NA__" },
|
{ "__NA__", sizeof( "__NA__" ) - 1 },
|
||||||
{ sizeof( "__NA__" ) - 1, "__NA__" },
|
{ "__NA__", sizeof( "__NA__" ) - 1 },
|
||||||
{ sizeof( "//" ) - 1, "//" },
|
{ "//", sizeof( "//" ) - 1 },
|
||||||
{ sizeof( "private" ) - 1, "private" },
|
{ "private", sizeof( "private" ) - 1 },
|
||||||
{ sizeof( "protected" ) - 1, "protected" },
|
{ "protected", sizeof( "protected" ) - 1 },
|
||||||
{ sizeof( "public" ) - 1, "public" },
|
{ "public", sizeof( "public" ) - 1 },
|
||||||
{ sizeof( "__NA__" ) - 1, "__NA__" },
|
{ "__NA__", sizeof( "__NA__" ) - 1 },
|
||||||
{ sizeof( "class" ) - 1, "class" },
|
{ "class", sizeof( "class" ) - 1 },
|
||||||
{ sizeof( "clsss" ) - 1, "clsss" },
|
{ "clsss", sizeof( "clsss" ) - 1 },
|
||||||
{ sizeof( "__NA__" ) - 1, "__NA__" },
|
{ "__NA__", sizeof( "__NA__" ) - 1 },
|
||||||
{ sizeof( "__NA__" ) - 1, "__NA__" },
|
{ "__NA__", sizeof( "__NA__" ) - 1 },
|
||||||
{ sizeof( "__NA__" ) - 1, "__NA__" },
|
{ "__NA__", sizeof( "__NA__" ) - 1 },
|
||||||
{ sizeof( "__NA__" ) - 1, "__NA__" },
|
{ "__NA__", sizeof( "__NA__" ) - 1 },
|
||||||
{ sizeof( "__NA__" ) - 1, "__NA__" },
|
{ "__NA__", sizeof( "__NA__" ) - 1 },
|
||||||
{ sizeof( "enum" ) - 1, "enum" },
|
{ "enum", sizeof( "enum" ) - 1 },
|
||||||
{ sizeof( "enum" ) - 1, "enum" },
|
{ "enum", sizeof( "enum" ) - 1 },
|
||||||
{ sizeof( "__NA__" ) - 1, "__NA__" },
|
{ "__NA__", sizeof( "__NA__" ) - 1 },
|
||||||
{ sizeof( "enum class" ) - 1, "enum class" },
|
{ "enum class", sizeof( "enum class" ) - 1 },
|
||||||
{ sizeof( "enum class" ) - 1, "enum class" },
|
{ "enum class", sizeof( "enum class" ) - 1 },
|
||||||
{ sizeof( "__NA__" ) - 1, "__NA__" },
|
{ "__NA__", sizeof( "__NA__" ) - 1 },
|
||||||
{ sizeof( "__NA__" ) - 1, "__NA__" },
|
{ "__NA__", sizeof( "__NA__" ) - 1 },
|
||||||
{ sizeof( "extern" ) - 1, "extern" },
|
{ "extern", sizeof( "extern" ) - 1 },
|
||||||
{ sizeof( "extern" ) - 1, "extern" },
|
{ "extern", sizeof( "extern" ) - 1 },
|
||||||
{ sizeof( "friend" ) - 1, "friend" },
|
{ "friend", sizeof( "friend" ) - 1 },
|
||||||
{ sizeof( "__NA__" ) - 1, "__NA__" },
|
{ "__NA__", sizeof( "__NA__" ) - 1 },
|
||||||
{ sizeof( "__NA__" ) - 1, "__NA__" },
|
{ "__NA__", sizeof( "__NA__" ) - 1 },
|
||||||
{ sizeof( "__NA__" ) - 1, "__NA__" },
|
{ "__NA__", sizeof( "__NA__" ) - 1 },
|
||||||
{ sizeof( "__NA__" ) - 1, "__NA__" },
|
{ "__NA__", sizeof( "__NA__" ) - 1 },
|
||||||
{ sizeof( "module" ) - 1, "module" },
|
{ "module", sizeof( "module" ) - 1 },
|
||||||
{ sizeof( "namespace" ) - 1, "namespace" },
|
{ "namespace", sizeof( "namespace" ) - 1 },
|
||||||
{ sizeof( "__NA__" ) - 1, "__NA__" },
|
{ "__NA__", sizeof( "__NA__" ) - 1 },
|
||||||
{ sizeof( "operator" ) - 1, "operator" },
|
{ "operator", sizeof( "operator" ) - 1 },
|
||||||
{ sizeof( "operator" ) - 1, "operator" },
|
{ "operator", sizeof( "operator" ) - 1 },
|
||||||
{ sizeof( "operator" ) - 1, "operator" },
|
{ "operator", sizeof( "operator" ) - 1 },
|
||||||
{ sizeof( "operator" ) - 1, "operator" },
|
{ "operator", sizeof( "operator" ) - 1 },
|
||||||
{ sizeof( "operator" ) - 1, "operator" },
|
{ "operator", sizeof( "operator" ) - 1 },
|
||||||
{ sizeof( "operator" ) - 1, "operator" },
|
{ "operator", sizeof( "operator" ) - 1 },
|
||||||
{ sizeof( "__NA__" ) - 1, "__NA__" },
|
{ "__NA__", sizeof( "__NA__" ) - 1 },
|
||||||
{ sizeof( "define" ) - 1, "define" },
|
{ "define", sizeof( "define" ) - 1 },
|
||||||
{ sizeof( "include" ) - 1, "include" },
|
{ "include", sizeof( "include" ) - 1 },
|
||||||
{ sizeof( "if" ) - 1, "if" },
|
{ "if", sizeof( "if" ) - 1 },
|
||||||
{ sizeof( "ifdef" ) - 1, "ifdef" },
|
{ "ifdef", sizeof( "ifdef" ) - 1 },
|
||||||
{ sizeof( "ifndef" ) - 1, "ifndef" },
|
{ "ifndef", sizeof( "ifndef" ) - 1 },
|
||||||
{ sizeof( "elif" ) - 1, "elif" },
|
{ "elif", sizeof( "elif" ) - 1 },
|
||||||
{ sizeof( "else" ) - 1, "else" },
|
{ "else", sizeof( "else" ) - 1 },
|
||||||
{ sizeof( "endif" ) - 1, "endif" },
|
{ "endif", sizeof( "endif" ) - 1 },
|
||||||
{ sizeof( "pragma" ) - 1, "pragma" },
|
{ "pragma", sizeof( "pragma" ) - 1 },
|
||||||
{ sizeof( "__NA__" ) - 1, "__NA__" },
|
{ "__NA__", sizeof( "__NA__" ) - 1 },
|
||||||
{ sizeof( "struct" ) - 1, "struct" },
|
{ "struct", sizeof( "struct" ) - 1 },
|
||||||
{ sizeof( "struct" ) - 1, "struct" },
|
{ "struct", sizeof( "struct" ) - 1 },
|
||||||
{ sizeof( "__NA__" ) - 1, "__NA__" },
|
{ "__NA__", sizeof( "__NA__" ) - 1 },
|
||||||
{ sizeof( "template" ) - 1, "template" },
|
{ "template", sizeof( "template" ) - 1 },
|
||||||
{ sizeof( "typedef" ) - 1, "typedef" },
|
{ "typedef", sizeof( "typedef" ) - 1 },
|
||||||
{ sizeof( "__NA__" ) - 1, "__NA__" },
|
{ "__NA__", sizeof( "__NA__" ) - 1 },
|
||||||
{ sizeof( "union" ) - 1, "union" },
|
{ "union", sizeof( "union" ) - 1 },
|
||||||
{ sizeof( "union" ) - 1, "union" },
|
{ "union", sizeof( "union" ) - 1 },
|
||||||
{ sizeof( "__NA__" ) - 1, "__NA__" },
|
{ "__NA__", sizeof( "__NA__" ) - 1 },
|
||||||
{ sizeof( "using" ) - 1, "using" },
|
{ "using", sizeof( "using" ) - 1 },
|
||||||
{ sizeof( "using namespace" ) - 1, "using namespace" },
|
{ "using namespace", sizeof( "using namespace" ) - 1 },
|
||||||
{ sizeof( "__NA__" ) - 1, "__NA__" },
|
{ "__NA__", sizeof( "__NA__" ) - 1 },
|
||||||
};
|
};
|
||||||
return lookup[type];
|
return lookup[type];
|
||||||
}
|
}
|
||||||
|
@ -61,53 +61,53 @@ enum Operator : u32
|
|||||||
inline Str operator_to_str( Operator op )
|
inline Str operator_to_str( Operator op )
|
||||||
{
|
{
|
||||||
local_persist Str lookup[47] = {
|
local_persist Str lookup[47] = {
|
||||||
{ sizeof( "INVALID" ), "INVALID" },
|
{ "INVALID", sizeof( "INVALID" ) },
|
||||||
{ sizeof( "=" ), "=" },
|
{ "=", sizeof( "=" ) },
|
||||||
{ sizeof( "+=" ), "+=" },
|
{ "+=", sizeof( "+=" ) },
|
||||||
{ sizeof( "-=" ), "-=" },
|
{ "-=", sizeof( "-=" ) },
|
||||||
{ sizeof( "*=" ), "*=" },
|
{ "*=", sizeof( "*=" ) },
|
||||||
{ sizeof( "/=" ), "/=" },
|
{ "/=", sizeof( "/=" ) },
|
||||||
{ sizeof( "%=" ), "%=" },
|
{ "%=", sizeof( "%=" ) },
|
||||||
{ sizeof( "&=" ), "&=" },
|
{ "&=", sizeof( "&=" ) },
|
||||||
{ sizeof( "|=" ), "|=" },
|
{ "|=", sizeof( "|=" ) },
|
||||||
{ sizeof( "^=" ), "^=" },
|
{ "^=", sizeof( "^=" ) },
|
||||||
{ sizeof( "<<=" ), "<<=" },
|
{ "<<=", sizeof( "<<=" ) },
|
||||||
{ sizeof( ">>=" ), ">>=" },
|
{ ">>=", sizeof( ">>=" ) },
|
||||||
{ sizeof( "++" ), "++" },
|
{ "++", sizeof( "++" ) },
|
||||||
{ sizeof( "--" ), "--" },
|
{ "--", sizeof( "--" ) },
|
||||||
{ sizeof( "+" ), "+" },
|
{ "+", sizeof( "+" ) },
|
||||||
{ sizeof( "-" ), "-" },
|
{ "-", sizeof( "-" ) },
|
||||||
{ sizeof( "!" ), "!" },
|
{ "!", sizeof( "!" ) },
|
||||||
{ sizeof( "+" ), "+" },
|
{ "+", sizeof( "+" ) },
|
||||||
{ sizeof( "-" ), "-" },
|
{ "-", sizeof( "-" ) },
|
||||||
{ sizeof( "*" ), "*" },
|
{ "*", sizeof( "*" ) },
|
||||||
{ sizeof( "/" ), "/" },
|
{ "/", sizeof( "/" ) },
|
||||||
{ sizeof( "%" ), "%" },
|
{ "%", sizeof( "%" ) },
|
||||||
{ sizeof( "~" ), "~" },
|
{ "~", sizeof( "~" ) },
|
||||||
{ sizeof( "&" ), "&" },
|
{ "&", sizeof( "&" ) },
|
||||||
{ sizeof( "|" ), "|" },
|
{ "|", sizeof( "|" ) },
|
||||||
{ sizeof( "^" ), "^" },
|
{ "^", sizeof( "^" ) },
|
||||||
{ sizeof( "<<" ), "<<" },
|
{ "<<", sizeof( "<<" ) },
|
||||||
{ sizeof( ">>" ), ">>" },
|
{ ">>", sizeof( ">>" ) },
|
||||||
{ sizeof( "&&" ), "&&" },
|
{ "&&", sizeof( "&&" ) },
|
||||||
{ sizeof( "||" ), "||" },
|
{ "||", sizeof( "||" ) },
|
||||||
{ sizeof( "==" ), "==" },
|
{ "==", sizeof( "==" ) },
|
||||||
{ sizeof( "!=" ), "!=" },
|
{ "!=", sizeof( "!=" ) },
|
||||||
{ sizeof( "<" ), "<" },
|
{ "<", sizeof( "<" ) },
|
||||||
{ sizeof( ">" ), ">" },
|
{ ">", sizeof( ">" ) },
|
||||||
{ sizeof( "<=" ), "<=" },
|
{ "<=", sizeof( "<=" ) },
|
||||||
{ sizeof( ">=" ), ">=" },
|
{ ">=", sizeof( ">=" ) },
|
||||||
{ sizeof( "[]" ), "[]" },
|
{ "[]", sizeof( "[]" ) },
|
||||||
{ sizeof( "*" ), "*" },
|
{ "*", sizeof( "*" ) },
|
||||||
{ sizeof( "&" ), "&" },
|
{ "&", sizeof( "&" ) },
|
||||||
{ sizeof( "->" ), "->" },
|
{ "->", sizeof( "->" ) },
|
||||||
{ sizeof( "->*" ), "->*" },
|
{ "->*", sizeof( "->*" ) },
|
||||||
{ sizeof( "()" ), "()" },
|
{ "()", sizeof( "()" ) },
|
||||||
{ sizeof( "," ), "," },
|
{ ",", sizeof( "," ) },
|
||||||
{ sizeof( "new" ), "new" },
|
{ "new", sizeof( "new" ) },
|
||||||
{ sizeof( "new[]" ), "new[]" },
|
{ "new[]", sizeof( "new[]" ) },
|
||||||
{ sizeof( "delete" ), "delete" },
|
{ "delete", sizeof( "delete" ) },
|
||||||
{ sizeof( "delete[]" ), "delete[]" },
|
{ "delete[]", sizeof( "delete[]" ) },
|
||||||
};
|
};
|
||||||
return lookup[op];
|
return lookup[op];
|
||||||
}
|
}
|
||||||
|
@ -40,32 +40,32 @@ enum Specifier : u32
|
|||||||
inline Str spec_to_str( Specifier type )
|
inline Str spec_to_str( Specifier type )
|
||||||
{
|
{
|
||||||
local_persist Str lookup[26] = {
|
local_persist Str lookup[26] = {
|
||||||
{ sizeof( "INVALID" ), "INVALID" },
|
{ "INVALID", sizeof( "INVALID" ) },
|
||||||
{ sizeof( "consteval" ), "consteval" },
|
{ "consteval", sizeof( "consteval" ) },
|
||||||
{ sizeof( "constexpr" ), "constexpr" },
|
{ "constexpr", sizeof( "constexpr" ) },
|
||||||
{ sizeof( "constinit" ), "constinit" },
|
{ "constinit", sizeof( "constinit" ) },
|
||||||
{ sizeof( "explicit" ), "explicit" },
|
{ "explicit", sizeof( "explicit" ) },
|
||||||
{ sizeof( "extern" ), "extern" },
|
{ "extern", sizeof( "extern" ) },
|
||||||
{ sizeof( "forceinline" ), "forceinline" },
|
{ "forceinline", sizeof( "forceinline" ) },
|
||||||
{ sizeof( "global" ), "global" },
|
{ "global", sizeof( "global" ) },
|
||||||
{ sizeof( "inline" ), "inline" },
|
{ "inline", sizeof( "inline" ) },
|
||||||
{ sizeof( "internal" ), "internal" },
|
{ "internal", sizeof( "internal" ) },
|
||||||
{ sizeof( "local_persist" ), "local_persist" },
|
{ "local_persist", sizeof( "local_persist" ) },
|
||||||
{ sizeof( "mutable" ), "mutable" },
|
{ "mutable", sizeof( "mutable" ) },
|
||||||
{ sizeof( "neverinline" ), "neverinline" },
|
{ "neverinline", sizeof( "neverinline" ) },
|
||||||
{ sizeof( "*" ), "*" },
|
{ "*", sizeof( "*" ) },
|
||||||
{ sizeof( "&" ), "&" },
|
{ "&", sizeof( "&" ) },
|
||||||
{ sizeof( "register" ), "register" },
|
{ "register", sizeof( "register" ) },
|
||||||
{ sizeof( "&&" ), "&&" },
|
{ "&&", sizeof( "&&" ) },
|
||||||
{ sizeof( "static" ), "static" },
|
{ "static", sizeof( "static" ) },
|
||||||
{ sizeof( "thread_local" ), "thread_local" },
|
{ "thread_local", sizeof( "thread_local" ) },
|
||||||
{ sizeof( "virtual" ), "virtual" },
|
{ "virtual", sizeof( "virtual" ) },
|
||||||
{ sizeof( "const" ), "const" },
|
{ "const", sizeof( "const" ) },
|
||||||
{ sizeof( "final" ), "final" },
|
{ "final", sizeof( "final" ) },
|
||||||
{ sizeof( "noexcept" ), "noexcept" },
|
{ "noexcept", sizeof( "noexcept" ) },
|
||||||
{ sizeof( "override" ), "override" },
|
{ "override", sizeof( "override" ) },
|
||||||
{ sizeof( "= 0" ), "= 0" },
|
{ "= 0", sizeof( "= 0" ) },
|
||||||
{ sizeof( "volatile" ), "volatile" },
|
{ "volatile", sizeof( "volatile" ) },
|
||||||
};
|
};
|
||||||
return lookup[type];
|
return lookup[type];
|
||||||
}
|
}
|
||||||
|
@ -114,103 +114,103 @@ enum TokType : u32
|
|||||||
inline Str toktype_to_str( TokType type )
|
inline Str toktype_to_str( TokType type )
|
||||||
{
|
{
|
||||||
local_persist Str lookup[] = {
|
local_persist Str lookup[] = {
|
||||||
{ sizeof( "__invalid__" ), "__invalid__" },
|
{ "__invalid__", sizeof( "__invalid__" ) },
|
||||||
{ sizeof( "private" ), "private" },
|
{ "private", sizeof( "private" ) },
|
||||||
{ sizeof( "protected" ), "protected" },
|
{ "protected", sizeof( "protected" ) },
|
||||||
{ sizeof( "public" ), "public" },
|
{ "public", sizeof( "public" ) },
|
||||||
{ sizeof( "." ), "." },
|
{ ".", sizeof( "." ) },
|
||||||
{ sizeof( "::" ), "::" },
|
{ "::", sizeof( "::" ) },
|
||||||
{ sizeof( "&" ), "&" },
|
{ "&", sizeof( "&" ) },
|
||||||
{ sizeof( "&&" ), "&&" },
|
{ "&&", sizeof( "&&" ) },
|
||||||
{ sizeof( ":" ), ":" },
|
{ ":", sizeof( ":" ) },
|
||||||
{ sizeof( "[[" ), "[[" },
|
{ "[[", sizeof( "[[" ) },
|
||||||
{ sizeof( "]]" ), "]]" },
|
{ "]]", sizeof( "]]" ) },
|
||||||
{ sizeof( "{" ), "{" },
|
{ "{", sizeof( "{" ) },
|
||||||
{ sizeof( "}" ), "}" },
|
{ "}", sizeof( "}" ) },
|
||||||
{ sizeof( "[" ), "[" },
|
{ "[", sizeof( "[" ) },
|
||||||
{ sizeof( "]" ), "]" },
|
{ "]", sizeof( "]" ) },
|
||||||
{ sizeof( "(" ), "(" },
|
{ "(", sizeof( "(" ) },
|
||||||
{ sizeof( ")" ), ")" },
|
{ ")", sizeof( ")" ) },
|
||||||
{ sizeof( "__comment__" ), "__comment__" },
|
{ "__comment__", sizeof( "__comment__" ) },
|
||||||
{ sizeof( "__comment_end__" ), "__comment_end__" },
|
{ "__comment_end__", sizeof( "__comment_end__" ) },
|
||||||
{ sizeof( "__comment_start__" ), "__comment_start__" },
|
{ "__comment_start__", sizeof( "__comment_start__" ) },
|
||||||
{ sizeof( "__character__" ), "__character__" },
|
{ "__character__", sizeof( "__character__" ) },
|
||||||
{ sizeof( "," ), "," },
|
{ ",", sizeof( "," ) },
|
||||||
{ sizeof( "class" ), "class" },
|
{ "class", sizeof( "class" ) },
|
||||||
{ sizeof( "__attribute__" ), "__attribute__" },
|
{ "__attribute__", sizeof( "__attribute__" ) },
|
||||||
{ sizeof( "__declspec" ), "__declspec" },
|
{ "__declspec", sizeof( "__declspec" ) },
|
||||||
{ sizeof( "enum" ), "enum" },
|
{ "enum", sizeof( "enum" ) },
|
||||||
{ sizeof( "extern" ), "extern" },
|
{ "extern", sizeof( "extern" ) },
|
||||||
{ sizeof( "friend" ), "friend" },
|
{ "friend", sizeof( "friend" ) },
|
||||||
{ sizeof( "module" ), "module" },
|
{ "module", sizeof( "module" ) },
|
||||||
{ sizeof( "namespace" ), "namespace" },
|
{ "namespace", sizeof( "namespace" ) },
|
||||||
{ sizeof( "operator" ), "operator" },
|
{ "operator", sizeof( "operator" ) },
|
||||||
{ sizeof( "struct" ), "struct" },
|
{ "struct", sizeof( "struct" ) },
|
||||||
{ sizeof( "template" ), "template" },
|
{ "template", sizeof( "template" ) },
|
||||||
{ sizeof( "typedef" ), "typedef" },
|
{ "typedef", sizeof( "typedef" ) },
|
||||||
{ sizeof( "using" ), "using" },
|
{ "using", sizeof( "using" ) },
|
||||||
{ sizeof( "union" ), "union" },
|
{ "union", sizeof( "union" ) },
|
||||||
{ sizeof( "__identifier__" ), "__identifier__" },
|
{ "__identifier__", sizeof( "__identifier__" ) },
|
||||||
{ sizeof( "import" ), "import" },
|
{ "import", sizeof( "import" ) },
|
||||||
{ sizeof( "export" ), "export" },
|
{ "export", sizeof( "export" ) },
|
||||||
{ sizeof( "__new_line__" ), "__new_line__" },
|
{ "__new_line__", sizeof( "__new_line__" ) },
|
||||||
{ sizeof( "__number__" ), "__number__" },
|
{ "__number__", sizeof( "__number__" ) },
|
||||||
{ sizeof( "__operator__" ), "__operator__" },
|
{ "__operator__", sizeof( "__operator__" ) },
|
||||||
{ sizeof( "#" ), "#" },
|
{ "#", sizeof( "#" ) },
|
||||||
{ sizeof( "define" ), "define" },
|
{ "define", sizeof( "define" ) },
|
||||||
{ sizeof( "if" ), "if" },
|
{ "if", sizeof( "if" ) },
|
||||||
{ sizeof( "ifdef" ), "ifdef" },
|
{ "ifdef", sizeof( "ifdef" ) },
|
||||||
{ sizeof( "ifndef" ), "ifndef" },
|
{ "ifndef", sizeof( "ifndef" ) },
|
||||||
{ sizeof( "elif" ), "elif" },
|
{ "elif", sizeof( "elif" ) },
|
||||||
{ sizeof( "else" ), "else" },
|
{ "else", sizeof( "else" ) },
|
||||||
{ sizeof( "endif" ), "endif" },
|
{ "endif", sizeof( "endif" ) },
|
||||||
{ sizeof( "include" ), "include" },
|
{ "include", sizeof( "include" ) },
|
||||||
{ sizeof( "pragma" ), "pragma" },
|
{ "pragma", sizeof( "pragma" ) },
|
||||||
{ sizeof( "__macro_content__" ), "__macro_content__" },
|
{ "__macro_content__", sizeof( "__macro_content__" ) },
|
||||||
{ sizeof( "__macro__" ), "__macro__" },
|
{ "__macro__", sizeof( "__macro__" ) },
|
||||||
{ sizeof( "__unsupported__" ), "__unsupported__" },
|
{ "__unsupported__", sizeof( "__unsupported__" ) },
|
||||||
{ sizeof( "alignas" ), "alignas" },
|
{ "alignas", sizeof( "alignas" ) },
|
||||||
{ sizeof( "const" ), "const" },
|
{ "const", sizeof( "const" ) },
|
||||||
{ sizeof( "consteval" ), "consteval" },
|
{ "consteval", sizeof( "consteval" ) },
|
||||||
{ sizeof( "constexpr" ), "constexpr" },
|
{ "constexpr", sizeof( "constexpr" ) },
|
||||||
{ sizeof( "constinit" ), "constinit" },
|
{ "constinit", sizeof( "constinit" ) },
|
||||||
{ sizeof( "explicit" ), "explicit" },
|
{ "explicit", sizeof( "explicit" ) },
|
||||||
{ sizeof( "extern" ), "extern" },
|
{ "extern", sizeof( "extern" ) },
|
||||||
{ sizeof( "final" ), "final" },
|
{ "final", sizeof( "final" ) },
|
||||||
{ sizeof( "forceinline" ), "forceinline" },
|
{ "forceinline", sizeof( "forceinline" ) },
|
||||||
{ sizeof( "global" ), "global" },
|
{ "global", sizeof( "global" ) },
|
||||||
{ sizeof( "inline" ), "inline" },
|
{ "inline", sizeof( "inline" ) },
|
||||||
{ sizeof( "internal" ), "internal" },
|
{ "internal", sizeof( "internal" ) },
|
||||||
{ sizeof( "local_persist" ), "local_persist" },
|
{ "local_persist", sizeof( "local_persist" ) },
|
||||||
{ sizeof( "mutable" ), "mutable" },
|
{ "mutable", sizeof( "mutable" ) },
|
||||||
{ sizeof( "neverinline" ), "neverinline" },
|
{ "neverinline", sizeof( "neverinline" ) },
|
||||||
{ sizeof( "override" ), "override" },
|
{ "override", sizeof( "override" ) },
|
||||||
{ sizeof( "static" ), "static" },
|
{ "static", sizeof( "static" ) },
|
||||||
{ sizeof( "thread_local" ), "thread_local" },
|
{ "thread_local", sizeof( "thread_local" ) },
|
||||||
{ sizeof( "volatile" ), "volatile" },
|
{ "volatile", sizeof( "volatile" ) },
|
||||||
{ sizeof( "virtual" ), "virtual" },
|
{ "virtual", sizeof( "virtual" ) },
|
||||||
{ sizeof( "*" ), "*" },
|
{ "*", sizeof( "*" ) },
|
||||||
{ sizeof( ";" ), ";" },
|
{ ";", sizeof( ";" ) },
|
||||||
{ sizeof( "static_assert" ), "static_assert" },
|
{ "static_assert", sizeof( "static_assert" ) },
|
||||||
{ sizeof( "__strbuilder__" ), "__strbuilder__" },
|
{ "__string__", sizeof( "__string__" ) },
|
||||||
{ sizeof( "typename" ), "typename" },
|
{ "typename", sizeof( "typename" ) },
|
||||||
{ sizeof( "unsigned" ), "unsigned" },
|
{ "unsigned", sizeof( "unsigned" ) },
|
||||||
{ sizeof( "signed" ), "signed" },
|
{ "signed", sizeof( "signed" ) },
|
||||||
{ sizeof( "short" ), "short" },
|
{ "short", sizeof( "short" ) },
|
||||||
{ sizeof( "long" ), "long" },
|
{ "long", sizeof( "long" ) },
|
||||||
{ sizeof( "bool" ), "bool" },
|
{ "bool", sizeof( "bool" ) },
|
||||||
{ sizeof( "char" ), "char" },
|
{ "char", sizeof( "char" ) },
|
||||||
{ sizeof( "int" ), "int" },
|
{ "int", sizeof( "int" ) },
|
||||||
{ sizeof( "double" ), "double" },
|
{ "double", sizeof( "double" ) },
|
||||||
{ sizeof( "__int8" ), "__int8" },
|
{ "__int8", sizeof( "__int8" ) },
|
||||||
{ sizeof( "__int16" ), "__int16" },
|
{ "__int16", sizeof( "__int16" ) },
|
||||||
{ sizeof( "__int32" ), "__int32" },
|
{ "__int32", sizeof( "__int32" ) },
|
||||||
{ sizeof( "__int64" ), "__int64" },
|
{ "__int64", sizeof( "__int64" ) },
|
||||||
{ sizeof( "_W64" ), "_W64" },
|
{ "_W64", sizeof( "_W64" ) },
|
||||||
{ sizeof( "..." ), "..." },
|
{ "...", sizeof( "..." ) },
|
||||||
{ sizeof( "__attrib_start__" ), "__attrib_start__" },
|
{ "__attrib_start__", sizeof( "__attrib_start__" ) },
|
||||||
{ sizeof( "GEN_API_Export_Code" ), "GEN_API_Export_Code" },
|
{ "GEN_API_Export_Code", sizeof( "GEN_API_Export_Code" ) },
|
||||||
{ sizeof( "GEN_API_Import_Code" ), "GEN_API_Import_Code" },
|
{ "GEN_API_Import_Code", sizeof( "GEN_API_Import_Code" ) },
|
||||||
};
|
};
|
||||||
return lookup[type];
|
return lookup[type];
|
||||||
}
|
}
|
||||||
|
235
base/components/gen/etoktype.hpp
Normal file
235
base/components/gen/etoktype.hpp
Normal file
@ -0,0 +1,235 @@
|
|||||||
|
#ifdef GEN_INTELLISENSE_DIRECTIVES
|
||||||
|
#pragma once
|
||||||
|
#include "components/types.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)
|
||||||
|
|
||||||
|
GEN_NS_PARSER_BEGIN
|
||||||
|
|
||||||
|
#define GEN_DEFINE_ATTRIBUTE_TOKENS Entry( Tok_Attribute_API_Export, "GEN_API_Export_Code" ) Entry( Tok_Attribute_API_Import, "GEN_API_Import_Code" )
|
||||||
|
|
||||||
|
enum TokType : u32
|
||||||
|
{
|
||||||
|
Tok_Invalid,
|
||||||
|
Tok_Access_Private,
|
||||||
|
Tok_Access_Protected,
|
||||||
|
Tok_Access_Public,
|
||||||
|
Tok_Access_MemberSymbol,
|
||||||
|
Tok_Access_StaticSymbol,
|
||||||
|
Tok_Ampersand,
|
||||||
|
Tok_Ampersand_DBL,
|
||||||
|
Tok_Assign_Classifer,
|
||||||
|
Tok_Attribute_Open,
|
||||||
|
Tok_Attribute_Close,
|
||||||
|
Tok_BraceCurly_Open,
|
||||||
|
Tok_BraceCurly_Close,
|
||||||
|
Tok_BraceSquare_Open,
|
||||||
|
Tok_BraceSquare_Close,
|
||||||
|
Tok_Capture_Start,
|
||||||
|
Tok_Capture_End,
|
||||||
|
Tok_Comment,
|
||||||
|
Tok_Comment_End,
|
||||||
|
Tok_Comment_Start,
|
||||||
|
Tok_Char,
|
||||||
|
Tok_Comma,
|
||||||
|
Tok_Decl_Class,
|
||||||
|
Tok_Decl_GNU_Attribute,
|
||||||
|
Tok_Decl_MSVC_Attribute,
|
||||||
|
Tok_Decl_Enum,
|
||||||
|
Tok_Decl_Extern_Linkage,
|
||||||
|
Tok_Decl_Friend,
|
||||||
|
Tok_Decl_Module,
|
||||||
|
Tok_Decl_Namespace,
|
||||||
|
Tok_Decl_Operator,
|
||||||
|
Tok_Decl_Struct,
|
||||||
|
Tok_Decl_Template,
|
||||||
|
Tok_Decl_Typedef,
|
||||||
|
Tok_Decl_Using,
|
||||||
|
Tok_Decl_Union,
|
||||||
|
Tok_Identifier,
|
||||||
|
Tok_Module_Import,
|
||||||
|
Tok_Module_Export,
|
||||||
|
Tok_NewLine,
|
||||||
|
Tok_Number,
|
||||||
|
Tok_Operator,
|
||||||
|
Tok_Preprocess_Hash,
|
||||||
|
Tok_Preprocess_Define,
|
||||||
|
Tok_Preprocess_If,
|
||||||
|
Tok_Preprocess_IfDef,
|
||||||
|
Tok_Preprocess_IfNotDef,
|
||||||
|
Tok_Preprocess_ElIf,
|
||||||
|
Tok_Preprocess_Else,
|
||||||
|
Tok_Preprocess_EndIf,
|
||||||
|
Tok_Preprocess_Include,
|
||||||
|
Tok_Preprocess_Pragma,
|
||||||
|
Tok_Preprocess_Content,
|
||||||
|
Tok_Preprocess_Macro,
|
||||||
|
Tok_Preprocess_Unsupported,
|
||||||
|
Tok_Spec_Alignas,
|
||||||
|
Tok_Spec_Const,
|
||||||
|
Tok_Spec_Consteval,
|
||||||
|
Tok_Spec_Constexpr,
|
||||||
|
Tok_Spec_Constinit,
|
||||||
|
Tok_Spec_Explicit,
|
||||||
|
Tok_Spec_Extern,
|
||||||
|
Tok_Spec_Final,
|
||||||
|
Tok_Spec_ForceInline,
|
||||||
|
Tok_Spec_Global,
|
||||||
|
Tok_Spec_Inline,
|
||||||
|
Tok_Spec_Internal_Linkage,
|
||||||
|
Tok_Spec_LocalPersist,
|
||||||
|
Tok_Spec_Mutable,
|
||||||
|
Tok_Spec_NeverInline,
|
||||||
|
Tok_Spec_Override,
|
||||||
|
Tok_Spec_Static,
|
||||||
|
Tok_Spec_ThreadLocal,
|
||||||
|
Tok_Spec_Volatile,
|
||||||
|
Tok_Spec_Virtual,
|
||||||
|
Tok_Star,
|
||||||
|
Tok_Statement_End,
|
||||||
|
Tok_StaticAssert,
|
||||||
|
Tok_String,
|
||||||
|
Tok_Type_Typename,
|
||||||
|
Tok_Type_Unsigned,
|
||||||
|
Tok_Type_Signed,
|
||||||
|
Tok_Type_Short,
|
||||||
|
Tok_Type_Long,
|
||||||
|
Tok_Type_bool,
|
||||||
|
Tok_Type_char,
|
||||||
|
Tok_Type_int,
|
||||||
|
Tok_Type_double,
|
||||||
|
Tok_Type_MS_int8,
|
||||||
|
Tok_Type_MS_int16,
|
||||||
|
Tok_Type_MS_int32,
|
||||||
|
Tok_Type_MS_int64,
|
||||||
|
Tok_Type_MS_W64,
|
||||||
|
Tok_Varadic_Argument,
|
||||||
|
Tok___Attributes_Start,
|
||||||
|
Tok_Attribute_API_Export,
|
||||||
|
Tok_Attribute_API_Import,
|
||||||
|
Tok_NumTokens
|
||||||
|
};
|
||||||
|
|
||||||
|
inline Str toktype_to_str( TokType type )
|
||||||
|
{
|
||||||
|
local_persist Str lookup[] = {
|
||||||
|
{ "__invalid__", sizeof( "__invalid__" ) },
|
||||||
|
{ "private", sizeof( "private" ) },
|
||||||
|
{ "protected", sizeof( "protected" ) },
|
||||||
|
{ "public", sizeof( "public" ) },
|
||||||
|
{ ".", sizeof( "." ) },
|
||||||
|
{ "::", sizeof( "::" ) },
|
||||||
|
{ "&", sizeof( "&" ) },
|
||||||
|
{ "&&", sizeof( "&&" ) },
|
||||||
|
{ ":", sizeof( ":" ) },
|
||||||
|
{ "[[", sizeof( "[[" ) },
|
||||||
|
{ "]]", sizeof( "]]" ) },
|
||||||
|
{ "{", sizeof( "{" ) },
|
||||||
|
{ "}", sizeof( "}" ) },
|
||||||
|
{ "[", sizeof( "[" ) },
|
||||||
|
{ "]", sizeof( "]" ) },
|
||||||
|
{ "(", sizeof( "(" ) },
|
||||||
|
{ ")", sizeof( ")" ) },
|
||||||
|
{ "__comment__", sizeof( "__comment__" ) },
|
||||||
|
{ "__comment_end__", sizeof( "__comment_end__" ) },
|
||||||
|
{ "__comment_start__", sizeof( "__comment_start__" ) },
|
||||||
|
{ "__character__", sizeof( "__character__" ) },
|
||||||
|
{ ",", sizeof( "," ) },
|
||||||
|
{ "class", sizeof( "class" ) },
|
||||||
|
{ "__attribute__", sizeof( "__attribute__" ) },
|
||||||
|
{ "__declspec", sizeof( "__declspec" ) },
|
||||||
|
{ "enum", sizeof( "enum" ) },
|
||||||
|
{ "extern", sizeof( "extern" ) },
|
||||||
|
{ "friend", sizeof( "friend" ) },
|
||||||
|
{ "module", sizeof( "module" ) },
|
||||||
|
{ "namespace", sizeof( "namespace" ) },
|
||||||
|
{ "operator", sizeof( "operator" ) },
|
||||||
|
{ "struct", sizeof( "struct" ) },
|
||||||
|
{ "template", sizeof( "template" ) },
|
||||||
|
{ "typedef", sizeof( "typedef" ) },
|
||||||
|
{ "using", sizeof( "using" ) },
|
||||||
|
{ "union", sizeof( "union" ) },
|
||||||
|
{ "__identifier__", sizeof( "__identifier__" ) },
|
||||||
|
{ "import", sizeof( "import" ) },
|
||||||
|
{ "export", sizeof( "export" ) },
|
||||||
|
{ "__new_line__", sizeof( "__new_line__" ) },
|
||||||
|
{ "__number__", sizeof( "__number__" ) },
|
||||||
|
{ "__operator__", sizeof( "__operator__" ) },
|
||||||
|
{ "#", sizeof( "#" ) },
|
||||||
|
{ "define", sizeof( "define" ) },
|
||||||
|
{ "if", sizeof( "if" ) },
|
||||||
|
{ "ifdef", sizeof( "ifdef" ) },
|
||||||
|
{ "ifndef", sizeof( "ifndef" ) },
|
||||||
|
{ "elif", sizeof( "elif" ) },
|
||||||
|
{ "else", sizeof( "else" ) },
|
||||||
|
{ "endif", sizeof( "endif" ) },
|
||||||
|
{ "include", sizeof( "include" ) },
|
||||||
|
{ "pragma", sizeof( "pragma" ) },
|
||||||
|
{ "__macro_content__", sizeof( "__macro_content__" ) },
|
||||||
|
{ "__macro__", sizeof( "__macro__" ) },
|
||||||
|
{ "__unsupported__", sizeof( "__unsupported__" ) },
|
||||||
|
{ "alignas", sizeof( "alignas" ) },
|
||||||
|
{ "const", sizeof( "const" ) },
|
||||||
|
{ "consteval", sizeof( "consteval" ) },
|
||||||
|
{ "constexpr", sizeof( "constexpr" ) },
|
||||||
|
{ "constinit", sizeof( "constinit" ) },
|
||||||
|
{ "explicit", sizeof( "explicit" ) },
|
||||||
|
{ "extern", sizeof( "extern" ) },
|
||||||
|
{ "final", sizeof( "final" ) },
|
||||||
|
{ "forceinline", sizeof( "forceinline" ) },
|
||||||
|
{ "global", sizeof( "global" ) },
|
||||||
|
{ "inline", sizeof( "inline" ) },
|
||||||
|
{ "internal", sizeof( "internal" ) },
|
||||||
|
{ "local_persist", sizeof( "local_persist" ) },
|
||||||
|
{ "mutable", sizeof( "mutable" ) },
|
||||||
|
{ "neverinline", sizeof( "neverinline" ) },
|
||||||
|
{ "override", sizeof( "override" ) },
|
||||||
|
{ "static", sizeof( "static" ) },
|
||||||
|
{ "thread_local", sizeof( "thread_local" ) },
|
||||||
|
{ "volatile", sizeof( "volatile" ) },
|
||||||
|
{ "virtual", sizeof( "virtual" ) },
|
||||||
|
{ "*", sizeof( "*" ) },
|
||||||
|
{ ";", sizeof( ";" ) },
|
||||||
|
{ "static_assert", sizeof( "static_assert" ) },
|
||||||
|
{ "__string__", sizeof( "__string__" ) },
|
||||||
|
{ "typename", sizeof( "typename" ) },
|
||||||
|
{ "unsigned", sizeof( "unsigned" ) },
|
||||||
|
{ "signed", sizeof( "signed" ) },
|
||||||
|
{ "short", sizeof( "short" ) },
|
||||||
|
{ "long", sizeof( "long" ) },
|
||||||
|
{ "bool", sizeof( "bool" ) },
|
||||||
|
{ "char", sizeof( "char" ) },
|
||||||
|
{ "int", sizeof( "int" ) },
|
||||||
|
{ "double", sizeof( "double" ) },
|
||||||
|
{ "__int8", sizeof( "__int8" ) },
|
||||||
|
{ "__int16", sizeof( "__int16" ) },
|
||||||
|
{ "__int32", sizeof( "__int32" ) },
|
||||||
|
{ "__int64", sizeof( "__int64" ) },
|
||||||
|
{ "_W64", sizeof( "_W64" ) },
|
||||||
|
{ "...", sizeof( "..." ) },
|
||||||
|
{ "__attrib_start__", sizeof( "__attrib_start__" ) },
|
||||||
|
{ "GEN_API_Export_Code", sizeof( "GEN_API_Export_Code" ) },
|
||||||
|
{ "GEN_API_Import_Code", sizeof( "GEN_API_Import_Code" ) },
|
||||||
|
};
|
||||||
|
return lookup[type];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline TokType str_to_toktype( Str str )
|
||||||
|
{
|
||||||
|
local_persist u32 keymap[Tok_NumTokens];
|
||||||
|
do_once_start for ( u32 index = 0; index < Tok_NumTokens; index++ )
|
||||||
|
{
|
||||||
|
Str enum_str = toktype_to_str( (TokType)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 < Tok_NumTokens; index++ )
|
||||||
|
{
|
||||||
|
if ( keymap[index] == hash )
|
||||||
|
return (TokType)index;
|
||||||
|
}
|
||||||
|
return Tok_Invalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
GEN_NS_PARSER_END
|
@ -408,7 +408,7 @@ Str token_fmt_impl( ssize num, ... )
|
|||||||
ssize result = token_fmt_va(buf, GEN_PRINTF_MAXLEN, num, va);
|
ssize result = token_fmt_va(buf, GEN_PRINTF_MAXLEN, num, va);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
|
|
||||||
Str str = { result, buf };
|
Str str = { buf, result };
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
#pragma endregion Interface
|
#pragma endregion Interface
|
||||||
|
@ -289,12 +289,12 @@ Code untyped_token_fmt( s32 num_tokens, char const* fmt, ... );
|
|||||||
#ifndef name
|
#ifndef name
|
||||||
// Convienence for defining any name used with the gen api.
|
// Convienence for defining any name used with the gen api.
|
||||||
// Lets you provide the length and string literal to the functions without the need for the DSL.
|
// Lets you provide the length and string literal to the functions without the need for the DSL.
|
||||||
#define name( Id_ ) { sizeof(stringize( Id_ )) - 1, stringize(Id_) }
|
#define name( Id_ ) { stringize(Id_), sizeof(stringize( Id_ )) - 1 }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef code
|
#ifndef code
|
||||||
// Same as name just used to indicate intention of literal for code instead of names.
|
// Same as name just used to indicate intention of literal for code instead of names.
|
||||||
#define code( ... ) { sizeof(stringize(__VA_ARGS__)) - 1, stringize( __VA_ARGS__ ) }
|
#define code( ... ) { stringize( __VA_ARGS__ ), sizeof(stringize(__VA_ARGS__)) - 1 }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef args
|
#ifndef args
|
||||||
|
@ -138,8 +138,8 @@ Code untyped_fmt( char const* fmt, ...)
|
|||||||
ssize length = c_str_fmt_va(buf, GEN_PRINTF_MAXLEN, fmt, va);
|
ssize length = c_str_fmt_va(buf, GEN_PRINTF_MAXLEN, fmt, va);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
|
|
||||||
Str buf_str = { c_str_len_capped(fmt, MaxNameLength), fmt };
|
Str buf_str = { fmt, c_str_len_capped(fmt, MaxNameLength) };
|
||||||
Str uncapped_str = { length, buf };
|
Str uncapped_str = { buf, length };
|
||||||
|
|
||||||
Code
|
Code
|
||||||
result = make_code();
|
result = make_code();
|
||||||
@ -172,7 +172,7 @@ Code untyped_token_fmt( s32 num_tokens, char const* fmt, ... )
|
|||||||
ssize length = token_fmt_va(buf, GEN_PRINTF_MAXLEN, num_tokens, va);
|
ssize length = token_fmt_va(buf, GEN_PRINTF_MAXLEN, num_tokens, va);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
|
|
||||||
Str buf_str = { length, buf };
|
Str buf_str = { buf, length };
|
||||||
|
|
||||||
Code
|
Code
|
||||||
result = make_code();
|
result = make_code();
|
||||||
|
@ -461,7 +461,7 @@ CodeComment def_comment( Str content )
|
|||||||
if ( * strbuilder_back(cmt_formatted) != '\n' )
|
if ( * strbuilder_back(cmt_formatted) != '\n' )
|
||||||
strbuilder_append_str( & cmt_formatted, txt("\n") );
|
strbuilder_append_str( & cmt_formatted, txt("\n") );
|
||||||
|
|
||||||
Str name = { strbuilder_length(cmt_formatted), cmt_formatted };
|
Str name = strbuilder_to_str(cmt_formatted);
|
||||||
|
|
||||||
Code
|
Code
|
||||||
result = make_code();
|
result = make_code();
|
||||||
@ -589,7 +589,7 @@ CodeDefine def_define( Str name, Str content, Opts_def_define p )
|
|||||||
if ( result->Name.Ptr[lex_id_len] == '(' )
|
if ( result->Name.Ptr[lex_id_len] == '(' )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Str lex_id = { lex_id_len, result->Name.Ptr };
|
Str lex_id = { result->Name.Ptr, lex_id_len };
|
||||||
array_append(PreprocessorDefines, lex_id );
|
array_append(PreprocessorDefines, lex_id );
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -895,7 +895,7 @@ CodeOperator def_operator( Operator op, Str nspace, Opts_def_operator p )
|
|||||||
else
|
else
|
||||||
name = c_str_fmt_buf( "operator %.*s", op_str.Len, op_str.Ptr );
|
name = c_str_fmt_buf( "operator %.*s", op_str.Len, op_str.Ptr );
|
||||||
|
|
||||||
Str name_resolved = { c_str_len(name), name };
|
Str name_resolved = { name, c_str_len(name) };
|
||||||
|
|
||||||
CodeOperator
|
CodeOperator
|
||||||
result = (CodeOperator) make_code();
|
result = (CodeOperator) make_code();
|
||||||
|
@ -43,7 +43,7 @@ AccessSpec tok_to_access_specifier(Token tok)
|
|||||||
|
|
||||||
Str tok_to_str(Token tok)
|
Str tok_to_str(Token tok)
|
||||||
{
|
{
|
||||||
Str str = { tok.Length, tok.Text };
|
Str str = { tok.Text, tok.Length };
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ StrBuilder parser_to_string(ParseContext ctx)
|
|||||||
length++;
|
length++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Str scope_str = { length, scope_start.Text };
|
Str scope_str = { scope_start.Text, length };
|
||||||
StrBuilder line = strbuilder_make_str( GlobalAllocator, scope_str );
|
StrBuilder line = strbuilder_make_str( GlobalAllocator, scope_str );
|
||||||
strbuilder_append_fmt( & result, "\tScope : %s\n", line );
|
strbuilder_append_fmt( & result, "\tScope : %s\n", line );
|
||||||
strbuilder_free(& line);
|
strbuilder_free(& line);
|
||||||
@ -68,7 +68,7 @@ StrBuilder parser_to_string(ParseContext ctx)
|
|||||||
sptr dist = (sptr)last_valid.Text - (sptr)scope_start.Text + 2;
|
sptr dist = (sptr)last_valid.Text - (sptr)scope_start.Text + 2;
|
||||||
sptr length_from_err = dist;
|
sptr length_from_err = dist;
|
||||||
|
|
||||||
Str err_str = { length_from_err, last_valid.Text };
|
Str err_str = { last_valid.Text, length_from_err };
|
||||||
StrBuilder line_from_err = strbuilder_make_str( GlobalAllocator, err_str );
|
StrBuilder line_from_err = strbuilder_make_str( GlobalAllocator, err_str );
|
||||||
|
|
||||||
if ( length_from_err < 100 )
|
if ( length_from_err < 100 )
|
||||||
@ -681,7 +681,7 @@ CodeAttributes parse_attributes()
|
|||||||
|
|
||||||
if ( len > 0 )
|
if ( len > 0 )
|
||||||
{
|
{
|
||||||
Str attribute_txt = { len, start.Text };
|
Str attribute_txt = { start.Text, len };
|
||||||
parser_pop(& Context);
|
parser_pop(& Context);
|
||||||
|
|
||||||
StrBuilder name_stripped = parser_strip_formatting( attribute_txt, parser_strip_formatting_dont_preserve_newlines );
|
StrBuilder name_stripped = parser_strip_formatting( attribute_txt, parser_strip_formatting_dont_preserve_newlines );
|
||||||
@ -1072,7 +1072,7 @@ CodeBody parse_class_struct_body( TokType which, Token name )
|
|||||||
StrBuilder fused = strbuilder_make_reserve( GlobalAllocator, attributes->Content.Len + more_attributes->Content.Len );
|
StrBuilder fused = strbuilder_make_reserve( GlobalAllocator, attributes->Content.Len + more_attributes->Content.Len );
|
||||||
strbuilder_append_fmt( & fused, "%SB %SB", attributes->Content, more_attributes->Content );
|
strbuilder_append_fmt( & fused, "%SB %SB", attributes->Content, more_attributes->Content );
|
||||||
|
|
||||||
Str attrib_name = { strbuilder_length(fused), fused };
|
Str attrib_name = strbuilder_to_str(fused);
|
||||||
attributes->Name = get_cached_string( attrib_name );
|
attributes->Name = get_cached_string( attrib_name );
|
||||||
attributes->Content = attributes->Name;
|
attributes->Content = attributes->Name;
|
||||||
// <Attributes> <Specifiers> <Attributes>
|
// <Attributes> <Specifiers> <Attributes>
|
||||||
@ -1616,7 +1616,7 @@ Code parse_function_body()
|
|||||||
|
|
||||||
if ( len > 0 )
|
if ( len > 0 )
|
||||||
{
|
{
|
||||||
Str str = { len, start.Text };
|
Str str = { start.Text, len };
|
||||||
body_append( result, cast(Code, def_execution( str )) );
|
body_append( result, cast(Code, def_execution( str )) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3157,7 +3157,7 @@ Code parse_static_assert()
|
|||||||
content.Length = ( (sptr)prevtok.Text + prevtok.Length ) - (sptr)content.Text;
|
content.Length = ( (sptr)prevtok.Text + prevtok.Length ) - (sptr)content.Text;
|
||||||
|
|
||||||
char const* str = c_str_fmt_buf( "%.*s\n", content.Length, content.Text );
|
char const* str = c_str_fmt_buf( "%.*s\n", content.Length, content.Text );
|
||||||
Str content_str = { content.Length + 1, str };
|
Str content_str = { str, content.Length + 1 };
|
||||||
assert->Content = get_cached_string( content_str );
|
assert->Content = get_cached_string( content_str );
|
||||||
assert->Name = assert->Content;
|
assert->Name = assert->Content;
|
||||||
|
|
||||||
@ -5082,7 +5082,7 @@ CodeTypedef parser_parse_typedef()
|
|||||||
|
|
||||||
if ( currtok.Type == Tok_Identifier )
|
if ( currtok.Type == Tok_Identifier )
|
||||||
{
|
{
|
||||||
Str name_str = { name.Length, name.Text };
|
Str name_str = { name.Text, name.Length };
|
||||||
type = untyped_str(name_str);
|
type = untyped_str(name_str);
|
||||||
name = currtok;
|
name = currtok;
|
||||||
eat(Tok_Identifier);
|
eat(Tok_Identifier);
|
||||||
@ -5279,7 +5279,7 @@ CodeUnion parser_parse_union( bool inplace_def )
|
|||||||
CodeAttributes attributes = parse_attributes();
|
CodeAttributes attributes = parse_attributes();
|
||||||
// <ModuleFlags> union <Attributes>
|
// <ModuleFlags> union <Attributes>
|
||||||
|
|
||||||
Str name = { 0, nullptr };
|
Str name = { nullptr, 0 };
|
||||||
if ( check( Tok_Identifier ) )
|
if ( check( Tok_Identifier ) )
|
||||||
{
|
{
|
||||||
name = tok_to_str(currtok);
|
name = tok_to_str(currtok);
|
||||||
|
@ -48,13 +48,13 @@ Str access_spec_to_str( AccessSpec type )
|
|||||||
{
|
{
|
||||||
local_persist
|
local_persist
|
||||||
Str lookup[ (u32)AccessSpec_Num_AccessSpec ] = {
|
Str lookup[ (u32)AccessSpec_Num_AccessSpec ] = {
|
||||||
{ sizeof("") - 1, "" },
|
{ "", sizeof( "" ) - 1 },
|
||||||
{ sizeof("prviate") - 1, "private" },
|
{ "private", sizeof("prviate") - 1 },
|
||||||
{ sizeof("protected") - 1, "private" },
|
{ "private", sizeof("protected") - 1 },
|
||||||
{ sizeof("public") - 1, "public" },
|
{ "public", sizeof("public") - 1 },
|
||||||
};
|
};
|
||||||
|
|
||||||
Str invalid = { sizeof("Invalid") - 1, "Invalid" };
|
Str invalid = { "Invalid", sizeof("Invalid") - 1 };
|
||||||
if ( type > AccessSpec_Public )
|
if ( type > AccessSpec_Public )
|
||||||
return invalid;
|
return invalid;
|
||||||
|
|
||||||
@ -101,13 +101,13 @@ Str module_flag_to_str( ModuleFlag flag )
|
|||||||
{
|
{
|
||||||
local_persist
|
local_persist
|
||||||
Str lookup[ (u32)Num_ModuleFlags ] = {
|
Str lookup[ (u32)Num_ModuleFlags ] = {
|
||||||
{ sizeof("__none__"), "__none__" },
|
{ "__none__", sizeof("__none__") - 1 },
|
||||||
{ sizeof("export"), "export" },
|
{ "export", sizeof("export") - 1 },
|
||||||
{ sizeof("import"), "import" },
|
{ "import", sizeof("import") - 1 },
|
||||||
};
|
};
|
||||||
|
|
||||||
local_persist
|
local_persist
|
||||||
Str invalid_flag = { sizeof("invalid"), "invalid" };
|
Str invalid_flag = { "invalid", sizeof("invalid") };
|
||||||
if ( flag > ModuleFlag_Import )
|
if ( flag > ModuleFlag_Import )
|
||||||
return invalid_flag;
|
return invalid_flag;
|
||||||
|
|
||||||
|
@ -18,8 +18,8 @@ Str str_visualize_whitespace(Str str, AllocatorInfo allocator);
|
|||||||
// Constant string with length.
|
// Constant string with length.
|
||||||
struct Str
|
struct Str
|
||||||
{
|
{
|
||||||
ssize Len;
|
|
||||||
char const* Ptr;
|
char const* Ptr;
|
||||||
|
ssize Len;
|
||||||
|
|
||||||
#if GEN_COMPILER_CPP
|
#if GEN_COMPILER_CPP
|
||||||
forceinline operator char const* () const { return Ptr; }
|
forceinline operator char const* () const { return Ptr; }
|
||||||
@ -40,9 +40,9 @@ struct Str
|
|||||||
|
|
||||||
#ifndef txt
|
#ifndef txt
|
||||||
# if GEN_COMPILER_CPP
|
# if GEN_COMPILER_CPP
|
||||||
# define txt( text ) Str { sizeof( text ) - 1, ( text ) }
|
# define txt( text ) Str { ( text ), sizeof( text ) - 1 }
|
||||||
# else
|
# else
|
||||||
# define txt( text ) (Str){ sizeof( text ) - 1, ( text ) }
|
# define txt( text ) (Str){ ( text ), sizeof( text ) - 1 }
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ b32 str_starts_with(Str str, Str substring) {
|
|||||||
|
|
||||||
inline
|
inline
|
||||||
Str to_str_from_c_str( char const* bad_str ) {
|
Str to_str_from_c_str( char const* bad_str ) {
|
||||||
Str result = { c_str_len( bad_str ), bad_str };
|
Str result = { bad_str, c_str_len( bad_str ) };
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ struct StrBuilder
|
|||||||
|
|
||||||
forceinline operator char*() { return Data; }
|
forceinline operator char*() { return Data; }
|
||||||
forceinline operator char const*() const { return Data; }
|
forceinline operator char const*() const { return Data; }
|
||||||
forceinline operator Str() const { return { strbuilder_length(* this), Data }; }
|
forceinline operator Str() const { return { Data, strbuilder_length(* this) }; }
|
||||||
|
|
||||||
StrBuilder const& operator=(StrBuilder const& other) const {
|
StrBuilder const& operator=(StrBuilder const& other) const {
|
||||||
if (this == &other)
|
if (this == &other)
|
||||||
@ -243,7 +243,7 @@ struct StrBuilder
|
|||||||
forceinline b32 starts_with(StrBuilder substring) const { return strbuilder_starts_with_string(* this, substring); }
|
forceinline b32 starts_with(StrBuilder substring) const { return strbuilder_starts_with_string(* this, substring); }
|
||||||
forceinline void skip_line() { strbuilder_skip_line(* this); }
|
forceinline void skip_line() { strbuilder_skip_line(* this); }
|
||||||
forceinline void strip_space() { strbuilder_strip_space(* this); }
|
forceinline void strip_space() { strbuilder_strip_space(* this); }
|
||||||
forceinline Str to_str() { return { strbuilder_length(*this), Data}; }
|
forceinline Str to_str() { return { Data, strbuilder_length(*this) }; }
|
||||||
forceinline void trim(char const* cut_set) { strbuilder_trim(* this, cut_set); }
|
forceinline void trim(char const* cut_set) { strbuilder_trim(* this, cut_set); }
|
||||||
forceinline void trim_space() { strbuilder_trim_space(* this); }
|
forceinline void trim_space() { strbuilder_trim_space(* this); }
|
||||||
forceinline StrBuilder visualize_whitespace() const { return strbuilder_visualize_whitespace(* this); }
|
forceinline StrBuilder visualize_whitespace() const { return strbuilder_visualize_whitespace(* this); }
|
||||||
@ -621,7 +621,7 @@ void strip_space(StrBuilder str)
|
|||||||
|
|
||||||
forceinline
|
forceinline
|
||||||
Str strbuilder_to_str(StrBuilder str) {
|
Str strbuilder_to_str(StrBuilder str) {
|
||||||
Str result = { strbuilder_length(str), (char const*)str };
|
Str result = { (char const*)str, strbuilder_length(str) };
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,8 +22,8 @@ CodeBody gen_ecode( char const* path, bool use_c_definition = false )
|
|||||||
char const* keyword = csv_enum.Col_2[idx].string;
|
char const* keyword = csv_enum.Col_2[idx].string;
|
||||||
// TODO(Ed): to_c_str_entries and the others in here didn't have proper sizing of the Str slice.
|
// TODO(Ed): to_c_str_entries and the others in here didn't have proper sizing of the Str slice.
|
||||||
strbuilder_append_fmt( & enum_entries, "CT_%s,\n", code );
|
strbuilder_append_fmt( & enum_entries, "CT_%s,\n", code );
|
||||||
strbuilder_append_fmt( & to_c_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", code, code );
|
strbuilder_append_fmt( & to_c_str_entries, "{ \"%s\", sizeof(\"%s\") },\n", code, code );
|
||||||
strbuilder_append_fmt( & to_keyword_c_str_entries, "{ sizeof(\"%s\") - 1, \"%s\" },\n", keyword, keyword );
|
strbuilder_append_fmt( & to_keyword_c_str_entries, "{ \"%s\", sizeof(\"%s\") - 1 },\n", keyword, keyword );
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeEnum enum_code;
|
CodeEnum enum_code;
|
||||||
@ -104,7 +104,7 @@ CodeBody gen_eoperator( char const* path, bool use_c_definition = false )
|
|||||||
char const* enum_str = csv_enum.Col_1[idx].string;
|
char const* enum_str = csv_enum.Col_1[idx].string;
|
||||||
char const* entry_to_str = csv_enum.Col_2[idx].string;
|
char const* entry_to_str = csv_enum.Col_2[idx].string;
|
||||||
strbuilder_append_fmt( & enum_entries, "Op_%s,\n", enum_str );
|
strbuilder_append_fmt( & enum_entries, "Op_%s,\n", enum_str );
|
||||||
strbuilder_append_fmt( & to_c_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str);
|
strbuilder_append_fmt( & to_c_str_entries, "{ \"%s\", sizeof(\"%s\") },\n", entry_to_str, entry_to_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeEnum enum_code;
|
CodeEnum enum_code;
|
||||||
@ -190,7 +190,7 @@ CodeBody gen_especifier( char const* path, bool use_c_definition = false )
|
|||||||
char const* enum_str = csv_enum.Col_1[idx].string;
|
char const* enum_str = csv_enum.Col_1[idx].string;
|
||||||
char const* entry_to_str = csv_enum.Col_2[idx].string;
|
char const* entry_to_str = csv_enum.Col_2[idx].string;
|
||||||
strbuilder_append_fmt( & enum_entries, "Spec_%s,\n", enum_str );
|
strbuilder_append_fmt( & enum_entries, "Spec_%s,\n", enum_str );
|
||||||
strbuilder_append_fmt( & to_c_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str);
|
strbuilder_append_fmt( & to_c_str_entries, "{ \"%s\", sizeof(\"%s\") },\n", entry_to_str, entry_to_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeEnum enum_code;
|
CodeEnum enum_code;
|
||||||
@ -347,7 +347,7 @@ CodeBody gen_etoktype( char const* etok_path, char const* attr_path, bool use_c_
|
|||||||
char const* entry_to_str = enum_c_str_strs [idx].string;
|
char const* entry_to_str = enum_c_str_strs [idx].string;
|
||||||
|
|
||||||
strbuilder_append_fmt( & enum_entries, "Tok_%s,\n", enum_str );
|
strbuilder_append_fmt( & enum_entries, "Tok_%s,\n", enum_str );
|
||||||
strbuilder_append_fmt( & to_c_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str);
|
strbuilder_append_fmt( & to_c_str_entries, "{ \"%s\", sizeof(\"%s\") },\n", entry_to_str, entry_to_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( usize idx = 0; idx < array_num(attribute_strs); idx++ )
|
for ( usize idx = 0; idx < array_num(attribute_strs); idx++ )
|
||||||
@ -356,7 +356,7 @@ CodeBody gen_etoktype( char const* etok_path, char const* attr_path, bool use_c_
|
|||||||
char const* entry_to_str = attribute_c_str_strs [idx].string;
|
char const* entry_to_str = attribute_c_str_strs [idx].string;
|
||||||
|
|
||||||
strbuilder_append_fmt( & attribute_entries, "Tok_Attribute_%s,\n", attribute_str );
|
strbuilder_append_fmt( & attribute_entries, "Tok_Attribute_%s,\n", attribute_str );
|
||||||
strbuilder_append_fmt( & to_c_str_attributes, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str);
|
strbuilder_append_fmt( & to_c_str_attributes, "{ \"%s\", sizeof(\"%s\") },\n", entry_to_str, entry_to_str);
|
||||||
strbuilder_append_fmt( & attribute_define_entries, "Entry( Tok_Attribute_%s, \"%s\" )", attribute_str, entry_to_str );
|
strbuilder_append_fmt( & attribute_define_entries, "Entry( Tok_Attribute_%s, \"%s\" )", attribute_str, entry_to_str );
|
||||||
|
|
||||||
if ( idx < array_num(attribute_strs) - 1 )
|
if ( idx < array_num(attribute_strs) - 1 )
|
||||||
|
@ -646,7 +646,7 @@ do \
|
|||||||
if (fn->Name.starts_with(txt("code_")))
|
if (fn->Name.starts_with(txt("code_")))
|
||||||
{
|
{
|
||||||
Str old_prefix = txt("code_");
|
Str old_prefix = txt("code_");
|
||||||
Str actual_name = { fn->Name.Len - old_prefix.Len, fn->Name.Ptr + old_prefix.Len };
|
Str actual_name = { fn->Name.Ptr + old_prefix.Len, fn->Name.Len - old_prefix.Len };
|
||||||
StrBuilder new_name = StrBuilder::fmt_buf(GlobalAllocator, "code__%S", actual_name );
|
StrBuilder new_name = StrBuilder::fmt_buf(GlobalAllocator, "code__%S", actual_name );
|
||||||
|
|
||||||
fn->Name = get_cached_string(new_name);
|
fn->Name = get_cached_string(new_name);
|
||||||
@ -796,7 +796,7 @@ R"(#define AST_ArrSpecs_Cap \
|
|||||||
{
|
{
|
||||||
generic_selector.clear();
|
generic_selector.clear();
|
||||||
Str private_prefix = txt("code__");
|
Str private_prefix = txt("code__");
|
||||||
Str actual_name = { fn->Name.Len - private_prefix.Len, fn->Name.Ptr + private_prefix.Len };
|
Str actual_name = { fn->Name.Ptr + private_prefix.Len, fn->Name.Len - private_prefix.Len };
|
||||||
StrBuilder interface_name = StrBuilder::fmt_buf(GlobalAllocator, "code_%S", actual_name );
|
StrBuilder interface_name = StrBuilder::fmt_buf(GlobalAllocator, "code_%S", actual_name );
|
||||||
|
|
||||||
// Resolve generic's arguments
|
// Resolve generic's arguments
|
||||||
@ -941,7 +941,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
|
|||||||
{
|
{
|
||||||
// Convert the definition to use a default struct: https://vxtwitter.com/vkrajacic/status/1749816169736073295
|
// Convert the definition to use a default struct: https://vxtwitter.com/vkrajacic/status/1749816169736073295
|
||||||
Str prefix = txt("def_");
|
Str prefix = txt("def_");
|
||||||
Str actual_name = { fn->Name.Len - prefix.Len, fn->Name.Ptr + prefix.Len };
|
Str actual_name = { fn->Name.Ptr + prefix.Len, fn->Name.Len - prefix.Len };
|
||||||
Str new_name = StrBuilder::fmt_buf(GlobalAllocator, "def__%S", actual_name ).to_str();
|
Str new_name = StrBuilder::fmt_buf(GlobalAllocator, "def__%S", actual_name ).to_str();
|
||||||
|
|
||||||
// Resolve define's arguments
|
// Resolve define's arguments
|
||||||
@ -1020,7 +1020,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
|
|||||||
if (fn->Name.starts_with(txt("code_")))
|
if (fn->Name.starts_with(txt("code_")))
|
||||||
{
|
{
|
||||||
Str old_prefix = txt("code_");
|
Str old_prefix = txt("code_");
|
||||||
Str actual_name = { fn->Name.Len - old_prefix.Len, fn->Name.Ptr + old_prefix.Len };
|
Str actual_name = { fn->Name.Ptr + old_prefix.Len, fn->Name.Len - old_prefix.Len };
|
||||||
StrBuilder new_name = StrBuilder::fmt_buf(GlobalAllocator, "code__%S", actual_name );
|
StrBuilder new_name = StrBuilder::fmt_buf(GlobalAllocator, "code__%S", actual_name );
|
||||||
|
|
||||||
fn->Name = get_cached_string(new_name);
|
fn->Name = get_cached_string(new_name);
|
||||||
@ -1175,7 +1175,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
|
|||||||
if (fn->Name.starts_with(txt("code_")))
|
if (fn->Name.starts_with(txt("code_")))
|
||||||
{
|
{
|
||||||
Str old_prefix = txt("code_");
|
Str old_prefix = txt("code_");
|
||||||
Str actual_name = { fn->Name.Len - old_prefix.Len, fn->Name.Ptr + old_prefix.Len };
|
Str actual_name = { fn->Name.Ptr + old_prefix.Len, fn->Name.Len - old_prefix.Len };
|
||||||
StrBuilder new_name = StrBuilder::fmt_buf(GlobalAllocator, "code__%S", actual_name );
|
StrBuilder new_name = StrBuilder::fmt_buf(GlobalAllocator, "code__%S", actual_name );
|
||||||
|
|
||||||
fn->Name = get_cached_string(new_name);
|
fn->Name = get_cached_string(new_name);
|
||||||
@ -1227,7 +1227,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
|
|||||||
for ( CodeParams opt_param : fn->Params ) if (opt_param->ValueType->Name.starts_with(txt("Opts_")))
|
for ( CodeParams opt_param : fn->Params ) if (opt_param->ValueType->Name.starts_with(txt("Opts_")))
|
||||||
{
|
{
|
||||||
Str prefix = txt("def_");
|
Str prefix = txt("def_");
|
||||||
Str actual_name = { fn->Name.Len - prefix.Len, fn->Name.Ptr + prefix.Len };
|
Str actual_name = { fn->Name.Ptr + prefix.Len, fn->Name.Len - prefix.Len };
|
||||||
Str new_name = StrBuilder::fmt_buf(GlobalAllocator, "def__%S", actual_name ).to_str();
|
Str new_name = StrBuilder::fmt_buf(GlobalAllocator, "def__%S", actual_name ).to_str();
|
||||||
|
|
||||||
fn->Name = get_cached_string(new_name);
|
fn->Name = get_cached_string(new_name);
|
||||||
|
@ -68,7 +68,7 @@ int gen_main()
|
|||||||
CodeBody macros = def_body( CT_Global_Body );
|
CodeBody macros = def_body( CT_Global_Body );
|
||||||
{
|
{
|
||||||
FileContents content = file_read_contents( GlobalAllocator, true, path_base "dependencies/macros.hpp" );
|
FileContents content = file_read_contents( GlobalAllocator, true, path_base "dependencies/macros.hpp" );
|
||||||
CodeBody ori_macros = parse_global_body( Str { content.size, (char const*)content.data });
|
CodeBody ori_macros = parse_global_body( Str { (char const*)content.data, content.size });
|
||||||
|
|
||||||
for (Code code = ori_macros.begin();
|
for (Code code = ori_macros.begin();
|
||||||
code != ori_macros.end();
|
code != ori_macros.end();
|
||||||
|
Loading…
Reference in New Issue
Block a user