mirror of
				https://github.com/Ed94/gencpp.git
				synced 2025-10-30 22:40:54 -07: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:
		| @@ -118,7 +118,7 @@ Code scan_file( char const* path ) | ||||
|  | ||||
| CodeBody parse_file( const char* 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 ); | ||||
| 	log_fmt("\nParsed: %s\n", path); | ||||
| 	return code; | ||||
|   | ||||
| @@ -41,6 +41,7 @@ int gen_main() | ||||
| 	CodeBody ecode       = gen_ecode     ( "enums/ECodeTypes.csv" ); | ||||
| 	CodeBody eoperator   = gen_eoperator ( "enums/EOperator.csv" ); | ||||
| 	CodeBody especifier  = gen_especifier( "enums/ESpecifier.csv" ); | ||||
| 	CodeBody etoktype    = gen_etoktype  ( "enums/ETokType.csv", "enums/AttributeTokens.csv" ); | ||||
| 	CodeBody ast_inlines = gen_ast_inlines(); | ||||
|  | ||||
| 	Builder header_ecode = builder_open( "components/gen/ecodetypes.hpp" ); | ||||
| @@ -58,6 +59,11 @@ int gen_main() | ||||
| 	builder_print( & header_especifier, format(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_print( & header_ast_inlines, gen_component_header ); | ||||
| 	builder_print( & header_ast_inlines, format(ast_inlines) ); | ||||
|   | ||||
| @@ -75,67 +75,67 @@ enum CodeType : u32 | ||||
| inline Str codetype_to_str( CodeType type ) | ||||
| { | ||||
| 	local_persist Str lookup[61] = { | ||||
| 		{ sizeof( "Invalid" ),             "Invalid"             }, | ||||
| 		{ sizeof( "Untyped" ),             "Untyped"             }, | ||||
| 		{ sizeof( "NewLine" ),             "NewLine"             }, | ||||
| 		{ sizeof( "Comment" ),             "Comment"             }, | ||||
| 		{ sizeof( "Access_Private" ),      "Access_Private"      }, | ||||
| 		{ sizeof( "Access_Protected" ),    "Access_Protected"    }, | ||||
| 		{ sizeof( "Access_Public" ),       "Access_Public"       }, | ||||
| 		{ sizeof( "PlatformAttributes" ),  "PlatformAttributes"  }, | ||||
| 		{ sizeof( "Class" ),               "Class"               }, | ||||
| 		{ sizeof( "Class_Fwd" ),           "Class_Fwd"           }, | ||||
| 		{ sizeof( "Class_Body" ),          "Class_Body"          }, | ||||
| 		{ sizeof( "Constructor" ),         "Constructor"         }, | ||||
| 		{ sizeof( "Constructor_Fwd" ),     "Constructor_Fwd"     }, | ||||
| 		{ sizeof( "Destructor" ),          "Destructor"          }, | ||||
| 		{ sizeof( "Destructor_Fwd" ),      "Destructor_Fwd"      }, | ||||
| 		{ sizeof( "Enum" ),                "Enum"                }, | ||||
| 		{ sizeof( "Enum_Fwd" ),            "Enum_Fwd"            }, | ||||
| 		{ sizeof( "Enum_Body" ),           "Enum_Body"           }, | ||||
| 		{ sizeof( "Enum_Class" ),          "Enum_Class"          }, | ||||
| 		{ sizeof( "Enum_Class_Fwd" ),      "Enum_Class_Fwd"      }, | ||||
| 		{ sizeof( "Execution" ),           "Execution"           }, | ||||
| 		{ sizeof( "Export_Body" ),         "Export_Body"         }, | ||||
| 		{ sizeof( "Extern_Linkage" ),      "Extern_Linkage"      }, | ||||
| 		{ sizeof( "Extern_Linkage_Body" ), "Extern_Linkage_Body" }, | ||||
| 		{ sizeof( "Friend" ),              "Friend"              }, | ||||
| 		{ sizeof( "Function" ),            "Function"            }, | ||||
| 		{ sizeof( "Function_Fwd" ),        "Function_Fwd"        }, | ||||
| 		{ sizeof( "Function_Body" ),       "Function_Body"       }, | ||||
| 		{ sizeof( "Global_Body" ),         "Global_Body"         }, | ||||
| 		{ sizeof( "Module" ),              "Module"              }, | ||||
| 		{ sizeof( "Namespace" ),           "Namespace"           }, | ||||
| 		{ sizeof( "Namespace_Body" ),      "Namespace_Body"      }, | ||||
| 		{ sizeof( "Operator" ),            "Operator"            }, | ||||
| 		{ sizeof( "Operator_Fwd" ),        "Operator_Fwd"        }, | ||||
| 		{ sizeof( "Operator_Member" ),     "Operator_Member"     }, | ||||
| 		{ sizeof( "Operator_Member_Fwd" ), "Operator_Member_Fwd" }, | ||||
| 		{ sizeof( "Operator_Cast" ),       "Operator_Cast"       }, | ||||
| 		{ sizeof( "Operator_Cast_Fwd" ),   "Operator_Cast_Fwd"   }, | ||||
| 		{ sizeof( "Parameters" ),          "Parameters"          }, | ||||
| 		{ sizeof( "Preprocess_Define" ),   "Preprocess_Define"   }, | ||||
| 		{ sizeof( "Preprocess_Include" ),  "Preprocess_Include"  }, | ||||
| 		{ sizeof( "Preprocess_If" ),       "Preprocess_If"       }, | ||||
| 		{ sizeof( "Preprocess_IfDef" ),    "Preprocess_IfDef"    }, | ||||
| 		{ sizeof( "Preprocess_IfNotDef" ), "Preprocess_IfNotDef" }, | ||||
| 		{ sizeof( "Preprocess_ElIf" ),     "Preprocess_ElIf"     }, | ||||
| 		{ sizeof( "Preprocess_Else" ),     "Preprocess_Else"     }, | ||||
| 		{ sizeof( "Preprocess_EndIf" ),    "Preprocess_EndIf"    }, | ||||
| 		{ sizeof( "Preprocess_Pragma" ),   "Preprocess_Pragma"   }, | ||||
| 		{ sizeof( "Specifiers" ),          "Specifiers"          }, | ||||
| 		{ sizeof( "Struct" ),              "Struct"              }, | ||||
| 		{ sizeof( "Struct_Fwd" ),          "Struct_Fwd"          }, | ||||
| 		{ sizeof( "Struct_Body" ),         "Struct_Body"         }, | ||||
| 		{ sizeof( "Template" ),            "Template"            }, | ||||
| 		{ sizeof( "Typedef" ),             "Typedef"             }, | ||||
| 		{ sizeof( "Typename" ),            "Typename"            }, | ||||
| 		{ sizeof( "Union" ),               "Union"               }, | ||||
| 		{ sizeof( "Union_Fwd" ),           "Union_Fwd"           }, | ||||
| 		{ sizeof( "Union_Body" ),          "Union_Body"          }, | ||||
| 		{ sizeof( "Using" ),               "Using"               }, | ||||
| 		{ sizeof( "Using_Namespace" ),     "Using_Namespace"     }, | ||||
| 		{ sizeof( "Variable" ),            "Variable"            }, | ||||
| 		{ "Invalid",             sizeof( "Invalid" )             }, | ||||
| 		{ "Untyped",             sizeof( "Untyped" )             }, | ||||
| 		{ "NewLine",             sizeof( "NewLine" )             }, | ||||
| 		{ "Comment",             sizeof( "Comment" )             }, | ||||
| 		{ "Access_Private",      sizeof( "Access_Private" )      }, | ||||
| 		{ "Access_Protected",    sizeof( "Access_Protected" )    }, | ||||
| 		{ "Access_Public",       sizeof( "Access_Public" )       }, | ||||
| 		{ "PlatformAttributes",  sizeof( "PlatformAttributes" )  }, | ||||
| 		{ "Class",               sizeof( "Class" )               }, | ||||
| 		{ "Class_Fwd",           sizeof( "Class_Fwd" )           }, | ||||
| 		{ "Class_Body",          sizeof( "Class_Body" )          }, | ||||
| 		{ "Constructor",         sizeof( "Constructor" )         }, | ||||
| 		{ "Constructor_Fwd",     sizeof( "Constructor_Fwd" )     }, | ||||
| 		{ "Destructor",          sizeof( "Destructor" )          }, | ||||
| 		{ "Destructor_Fwd",      sizeof( "Destructor_Fwd" )      }, | ||||
| 		{ "Enum",                sizeof( "Enum" )                }, | ||||
| 		{ "Enum_Fwd",            sizeof( "Enum_Fwd" )            }, | ||||
| 		{ "Enum_Body",           sizeof( "Enum_Body" )           }, | ||||
| 		{ "Enum_Class",          sizeof( "Enum_Class" )          }, | ||||
| 		{ "Enum_Class_Fwd",      sizeof( "Enum_Class_Fwd" )      }, | ||||
| 		{ "Execution",           sizeof( "Execution" )           }, | ||||
| 		{ "Export_Body",         sizeof( "Export_Body" )         }, | ||||
| 		{ "Extern_Linkage",      sizeof( "Extern_Linkage" )      }, | ||||
| 		{ "Extern_Linkage_Body", sizeof( "Extern_Linkage_Body" ) }, | ||||
| 		{ "Friend",              sizeof( "Friend" )              }, | ||||
| 		{ "Function",            sizeof( "Function" )            }, | ||||
| 		{ "Function_Fwd",        sizeof( "Function_Fwd" )        }, | ||||
| 		{ "Function_Body",       sizeof( "Function_Body" )       }, | ||||
| 		{ "Global_Body",         sizeof( "Global_Body" )         }, | ||||
| 		{ "Module",              sizeof( "Module" )              }, | ||||
| 		{ "Namespace",           sizeof( "Namespace" )           }, | ||||
| 		{ "Namespace_Body",      sizeof( "Namespace_Body" )      }, | ||||
| 		{ "Operator",            sizeof( "Operator" )            }, | ||||
| 		{ "Operator_Fwd",        sizeof( "Operator_Fwd" )        }, | ||||
| 		{ "Operator_Member",     sizeof( "Operator_Member" )     }, | ||||
| 		{ "Operator_Member_Fwd", sizeof( "Operator_Member_Fwd" ) }, | ||||
| 		{ "Operator_Cast",       sizeof( "Operator_Cast" )       }, | ||||
| 		{ "Operator_Cast_Fwd",   sizeof( "Operator_Cast_Fwd" )   }, | ||||
| 		{ "Parameters",          sizeof( "Parameters" )          }, | ||||
| 		{ "Preprocess_Define",   sizeof( "Preprocess_Define" )   }, | ||||
| 		{ "Preprocess_Include",  sizeof( "Preprocess_Include" )  }, | ||||
| 		{ "Preprocess_If",       sizeof( "Preprocess_If" )       }, | ||||
| 		{ "Preprocess_IfDef",    sizeof( "Preprocess_IfDef" )    }, | ||||
| 		{ "Preprocess_IfNotDef", sizeof( "Preprocess_IfNotDef" ) }, | ||||
| 		{ "Preprocess_ElIf",     sizeof( "Preprocess_ElIf" )     }, | ||||
| 		{ "Preprocess_Else",     sizeof( "Preprocess_Else" )     }, | ||||
| 		{ "Preprocess_EndIf",    sizeof( "Preprocess_EndIf" )    }, | ||||
| 		{ "Preprocess_Pragma",   sizeof( "Preprocess_Pragma" )   }, | ||||
| 		{ "Specifiers",          sizeof( "Specifiers" )          }, | ||||
| 		{ "Struct",              sizeof( "Struct" )              }, | ||||
| 		{ "Struct_Fwd",          sizeof( "Struct_Fwd" )          }, | ||||
| 		{ "Struct_Body",         sizeof( "Struct_Body" )         }, | ||||
| 		{ "Template",            sizeof( "Template" )            }, | ||||
| 		{ "Typedef",             sizeof( "Typedef" )             }, | ||||
| 		{ "Typename",            sizeof( "Typename" )            }, | ||||
| 		{ "Union",               sizeof( "Union" )               }, | ||||
| 		{ "Union_Fwd",           sizeof( "Union_Fwd" )           }, | ||||
| 		{ "Union_Body",          sizeof( "Union_Body" )          }, | ||||
| 		{ "Using",               sizeof( "Using" )               }, | ||||
| 		{ "Using_Namespace",     sizeof( "Using_Namespace" )     }, | ||||
| 		{ "Variable",            sizeof( "Variable" )            }, | ||||
| 	}; | ||||
| 	return lookup[type]; | ||||
| } | ||||
| @@ -143,67 +143,67 @@ inline Str codetype_to_str( CodeType type ) | ||||
| inline Str codetype_to_keyword_str( CodeType type ) | ||||
| { | ||||
| 	local_persist Str lookup[61] = { | ||||
| 		{ sizeof( "__NA__" ) - 1,          "__NA__"          }, | ||||
| 		{ sizeof( "__NA__" ) - 1,          "__NA__"          }, | ||||
| 		{ sizeof( "__NA__" ) - 1,          "__NA__"          }, | ||||
| 		{ sizeof( "//" ) - 1,              "//"              }, | ||||
| 		{ sizeof( "private" ) - 1,         "private"         }, | ||||
| 		{ sizeof( "protected" ) - 1,       "protected"       }, | ||||
| 		{ sizeof( "public" ) - 1,          "public"          }, | ||||
| 		{ sizeof( "__NA__" ) - 1,          "__NA__"          }, | ||||
| 		{ sizeof( "class" ) - 1,           "class"           }, | ||||
| 		{ sizeof( "clsss" ) - 1,           "clsss"           }, | ||||
| 		{ sizeof( "__NA__" ) - 1,          "__NA__"          }, | ||||
| 		{ sizeof( "__NA__" ) - 1,          "__NA__"          }, | ||||
| 		{ sizeof( "__NA__" ) - 1,          "__NA__"          }, | ||||
| 		{ sizeof( "__NA__" ) - 1,          "__NA__"          }, | ||||
| 		{ sizeof( "__NA__" ) - 1,          "__NA__"          }, | ||||
| 		{ sizeof( "enum" ) - 1,            "enum"            }, | ||||
| 		{ sizeof( "enum" ) - 1,            "enum"            }, | ||||
| 		{ sizeof( "__NA__" ) - 1,          "__NA__"          }, | ||||
| 		{ sizeof( "enum class" ) - 1,      "enum class"      }, | ||||
| 		{ sizeof( "enum class" ) - 1,      "enum class"      }, | ||||
| 		{ sizeof( "__NA__" ) - 1,          "__NA__"          }, | ||||
| 		{ sizeof( "__NA__" ) - 1,          "__NA__"          }, | ||||
| 		{ sizeof( "extern" ) - 1,          "extern"          }, | ||||
| 		{ sizeof( "extern" ) - 1,          "extern"          }, | ||||
| 		{ sizeof( "friend" ) - 1,          "friend"          }, | ||||
| 		{ sizeof( "__NA__" ) - 1,          "__NA__"          }, | ||||
| 		{ sizeof( "__NA__" ) - 1,          "__NA__"          }, | ||||
| 		{ sizeof( "__NA__" ) - 1,          "__NA__"          }, | ||||
| 		{ sizeof( "__NA__" ) - 1,          "__NA__"          }, | ||||
| 		{ sizeof( "module" ) - 1,          "module"          }, | ||||
| 		{ sizeof( "namespace" ) - 1,       "namespace"       }, | ||||
| 		{ sizeof( "__NA__" ) - 1,          "__NA__"          }, | ||||
| 		{ sizeof( "operator" ) - 1,        "operator"        }, | ||||
| 		{ sizeof( "operator" ) - 1,        "operator"        }, | ||||
| 		{ sizeof( "operator" ) - 1,        "operator"        }, | ||||
| 		{ sizeof( "operator" ) - 1,        "operator"        }, | ||||
| 		{ sizeof( "operator" ) - 1,        "operator"        }, | ||||
| 		{ sizeof( "operator" ) - 1,        "operator"        }, | ||||
| 		{ sizeof( "__NA__" ) - 1,          "__NA__"          }, | ||||
| 		{ sizeof( "define" ) - 1,          "define"          }, | ||||
| 		{ sizeof( "include" ) - 1,         "include"         }, | ||||
| 		{ sizeof( "if" ) - 1,              "if"              }, | ||||
| 		{ sizeof( "ifdef" ) - 1,           "ifdef"           }, | ||||
| 		{ sizeof( "ifndef" ) - 1,          "ifndef"          }, | ||||
| 		{ sizeof( "elif" ) - 1,            "elif"            }, | ||||
| 		{ sizeof( "else" ) - 1,            "else"            }, | ||||
| 		{ sizeof( "endif" ) - 1,           "endif"           }, | ||||
| 		{ sizeof( "pragma" ) - 1,          "pragma"          }, | ||||
| 		{ sizeof( "__NA__" ) - 1,          "__NA__"          }, | ||||
| 		{ sizeof( "struct" ) - 1,          "struct"          }, | ||||
| 		{ sizeof( "struct" ) - 1,          "struct"          }, | ||||
| 		{ sizeof( "__NA__" ) - 1,          "__NA__"          }, | ||||
| 		{ sizeof( "template" ) - 1,        "template"        }, | ||||
| 		{ sizeof( "typedef" ) - 1,         "typedef"         }, | ||||
| 		{ sizeof( "__NA__" ) - 1,          "__NA__"          }, | ||||
| 		{ sizeof( "union" ) - 1,           "union"           }, | ||||
| 		{ sizeof( "union" ) - 1,           "union"           }, | ||||
| 		{ sizeof( "__NA__" ) - 1,          "__NA__"          }, | ||||
| 		{ sizeof( "using" ) - 1,           "using"           }, | ||||
| 		{ sizeof( "using namespace" ) - 1, "using namespace" }, | ||||
| 		{ sizeof( "__NA__" ) - 1,          "__NA__"          }, | ||||
| 		{ "__NA__",          sizeof( "__NA__" ) - 1          }, | ||||
| 		{ "__NA__",          sizeof( "__NA__" ) - 1          }, | ||||
| 		{ "__NA__",          sizeof( "__NA__" ) - 1          }, | ||||
| 		{ "//",              sizeof( "//" ) - 1              }, | ||||
| 		{ "private",         sizeof( "private" ) - 1         }, | ||||
| 		{ "protected",       sizeof( "protected" ) - 1       }, | ||||
| 		{ "public",          sizeof( "public" ) - 1          }, | ||||
| 		{ "__NA__",          sizeof( "__NA__" ) - 1          }, | ||||
| 		{ "class",           sizeof( "class" ) - 1           }, | ||||
| 		{ "clsss",           sizeof( "clsss" ) - 1           }, | ||||
| 		{ "__NA__",          sizeof( "__NA__" ) - 1          }, | ||||
| 		{ "__NA__",          sizeof( "__NA__" ) - 1          }, | ||||
| 		{ "__NA__",          sizeof( "__NA__" ) - 1          }, | ||||
| 		{ "__NA__",          sizeof( "__NA__" ) - 1          }, | ||||
| 		{ "__NA__",          sizeof( "__NA__" ) - 1          }, | ||||
| 		{ "enum",            sizeof( "enum" ) - 1            }, | ||||
| 		{ "enum",            sizeof( "enum" ) - 1            }, | ||||
| 		{ "__NA__",          sizeof( "__NA__" ) - 1          }, | ||||
| 		{ "enum class",      sizeof( "enum class" ) - 1      }, | ||||
| 		{ "enum class",      sizeof( "enum class" ) - 1      }, | ||||
| 		{ "__NA__",          sizeof( "__NA__" ) - 1          }, | ||||
| 		{ "__NA__",          sizeof( "__NA__" ) - 1          }, | ||||
| 		{ "extern",          sizeof( "extern" ) - 1          }, | ||||
| 		{ "extern",          sizeof( "extern" ) - 1          }, | ||||
| 		{ "friend",          sizeof( "friend" ) - 1          }, | ||||
| 		{ "__NA__",          sizeof( "__NA__" ) - 1          }, | ||||
| 		{ "__NA__",          sizeof( "__NA__" ) - 1          }, | ||||
| 		{ "__NA__",          sizeof( "__NA__" ) - 1          }, | ||||
| 		{ "__NA__",          sizeof( "__NA__" ) - 1          }, | ||||
| 		{ "module",          sizeof( "module" ) - 1          }, | ||||
| 		{ "namespace",       sizeof( "namespace" ) - 1       }, | ||||
| 		{ "__NA__",          sizeof( "__NA__" ) - 1          }, | ||||
| 		{ "operator",        sizeof( "operator" ) - 1        }, | ||||
| 		{ "operator",        sizeof( "operator" ) - 1        }, | ||||
| 		{ "operator",        sizeof( "operator" ) - 1        }, | ||||
| 		{ "operator",        sizeof( "operator" ) - 1        }, | ||||
| 		{ "operator",        sizeof( "operator" ) - 1        }, | ||||
| 		{ "operator",        sizeof( "operator" ) - 1        }, | ||||
| 		{ "__NA__",          sizeof( "__NA__" ) - 1          }, | ||||
| 		{ "define",          sizeof( "define" ) - 1          }, | ||||
| 		{ "include",         sizeof( "include" ) - 1         }, | ||||
| 		{ "if",              sizeof( "if" ) - 1              }, | ||||
| 		{ "ifdef",           sizeof( "ifdef" ) - 1           }, | ||||
| 		{ "ifndef",          sizeof( "ifndef" ) - 1          }, | ||||
| 		{ "elif",            sizeof( "elif" ) - 1            }, | ||||
| 		{ "else",            sizeof( "else" ) - 1            }, | ||||
| 		{ "endif",           sizeof( "endif" ) - 1           }, | ||||
| 		{ "pragma",          sizeof( "pragma" ) - 1          }, | ||||
| 		{ "__NA__",          sizeof( "__NA__" ) - 1          }, | ||||
| 		{ "struct",          sizeof( "struct" ) - 1          }, | ||||
| 		{ "struct",          sizeof( "struct" ) - 1          }, | ||||
| 		{ "__NA__",          sizeof( "__NA__" ) - 1          }, | ||||
| 		{ "template",        sizeof( "template" ) - 1        }, | ||||
| 		{ "typedef",         sizeof( "typedef" ) - 1         }, | ||||
| 		{ "__NA__",          sizeof( "__NA__" ) - 1          }, | ||||
| 		{ "union",           sizeof( "union" ) - 1           }, | ||||
| 		{ "union",           sizeof( "union" ) - 1           }, | ||||
| 		{ "__NA__",          sizeof( "__NA__" ) - 1          }, | ||||
| 		{ "using",           sizeof( "using" ) - 1           }, | ||||
| 		{ "using namespace", sizeof( "using namespace" ) - 1 }, | ||||
| 		{ "__NA__",          sizeof( "__NA__" ) - 1          }, | ||||
| 	}; | ||||
| 	return lookup[type]; | ||||
| } | ||||
|   | ||||
| @@ -61,53 +61,53 @@ enum Operator : u32 | ||||
| inline Str operator_to_str( Operator op ) | ||||
| { | ||||
| 	local_persist Str lookup[47] = { | ||||
| 		{ sizeof( "INVALID" ),  "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( "new" ),      "new"      }, | ||||
| 		{ sizeof( "new[]" ),    "new[]"    }, | ||||
| 		{ sizeof( "delete" ),   "delete"   }, | ||||
| 		{ sizeof( "delete[]" ), "delete[]" }, | ||||
| 		{ "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( "," )        }, | ||||
| 		{ "new",      sizeof( "new" )      }, | ||||
| 		{ "new[]",    sizeof( "new[]" )    }, | ||||
| 		{ "delete",   sizeof( "delete" )   }, | ||||
| 		{ "delete[]", sizeof( "delete[]" ) }, | ||||
| 	}; | ||||
| 	return lookup[op]; | ||||
| } | ||||
|   | ||||
| @@ -40,32 +40,32 @@ enum Specifier : u32 | ||||
| inline Str spec_to_str( Specifier type ) | ||||
| { | ||||
| 	local_persist Str lookup[26] = { | ||||
| 		{ sizeof( "INVALID" ),       "INVALID"       }, | ||||
| 		{ sizeof( "consteval" ),     "consteval"     }, | ||||
| 		{ sizeof( "constexpr" ),     "constexpr"     }, | ||||
| 		{ sizeof( "constinit" ),     "constinit"     }, | ||||
| 		{ sizeof( "explicit" ),      "explicit"      }, | ||||
| 		{ sizeof( "extern" ),        "extern"        }, | ||||
| 		{ sizeof( "forceinline" ),   "forceinline"   }, | ||||
| 		{ sizeof( "global" ),        "global"        }, | ||||
| 		{ sizeof( "inline" ),        "inline"        }, | ||||
| 		{ sizeof( "internal" ),      "internal"      }, | ||||
| 		{ sizeof( "local_persist" ), "local_persist" }, | ||||
| 		{ sizeof( "mutable" ),       "mutable"       }, | ||||
| 		{ sizeof( "neverinline" ),   "neverinline"   }, | ||||
| 		{ sizeof( "*" ),             "*"             }, | ||||
| 		{ sizeof( "&" ),             "&"             }, | ||||
| 		{ sizeof( "register" ),      "register"      }, | ||||
| 		{ sizeof( "&&" ),            "&&"            }, | ||||
| 		{ sizeof( "static" ),        "static"        }, | ||||
| 		{ sizeof( "thread_local" ),  "thread_local"  }, | ||||
| 		{ sizeof( "virtual" ),       "virtual"       }, | ||||
| 		{ sizeof( "const" ),         "const"         }, | ||||
| 		{ sizeof( "final" ),         "final"         }, | ||||
| 		{ sizeof( "noexcept" ),      "noexcept"      }, | ||||
| 		{ sizeof( "override" ),      "override"      }, | ||||
| 		{ sizeof( "= 0" ),           "= 0"           }, | ||||
| 		{ sizeof( "volatile" ),      "volatile"      }, | ||||
| 		{ "INVALID",       sizeof( "INVALID" )       }, | ||||
| 		{ "consteval",     sizeof( "consteval" )     }, | ||||
| 		{ "constexpr",     sizeof( "constexpr" )     }, | ||||
| 		{ "constinit",     sizeof( "constinit" )     }, | ||||
| 		{ "explicit",      sizeof( "explicit" )      }, | ||||
| 		{ "extern",        sizeof( "extern" )        }, | ||||
| 		{ "forceinline",   sizeof( "forceinline" )   }, | ||||
| 		{ "global",        sizeof( "global" )        }, | ||||
| 		{ "inline",        sizeof( "inline" )        }, | ||||
| 		{ "internal",      sizeof( "internal" )      }, | ||||
| 		{ "local_persist", sizeof( "local_persist" ) }, | ||||
| 		{ "mutable",       sizeof( "mutable" )       }, | ||||
| 		{ "neverinline",   sizeof( "neverinline" )   }, | ||||
| 		{ "*",             sizeof( "*" )             }, | ||||
| 		{ "&",             sizeof( "&" )             }, | ||||
| 		{ "register",      sizeof( "register" )      }, | ||||
| 		{ "&&",            sizeof( "&&" )            }, | ||||
| 		{ "static",        sizeof( "static" )        }, | ||||
| 		{ "thread_local",  sizeof( "thread_local" )  }, | ||||
| 		{ "virtual",       sizeof( "virtual" )       }, | ||||
| 		{ "const",         sizeof( "const" )         }, | ||||
| 		{ "final",         sizeof( "final" )         }, | ||||
| 		{ "noexcept",      sizeof( "noexcept" )      }, | ||||
| 		{ "override",      sizeof( "override" )      }, | ||||
| 		{ "= 0",           sizeof( "= 0" )           }, | ||||
| 		{ "volatile",      sizeof( "volatile" )      }, | ||||
| 	}; | ||||
| 	return lookup[type]; | ||||
| } | ||||
|   | ||||
| @@ -114,103 +114,103 @@ enum TokType : u32 | ||||
| inline Str toktype_to_str( TokType type ) | ||||
| { | ||||
| 	local_persist Str 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( "__strbuilder__" ),          "__strbuilder__"          }, | ||||
| 		{ 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" }, | ||||
| 		{ "__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]; | ||||
| } | ||||
| @@ -220,7 +220,7 @@ 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 ); | ||||
| 		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 ); | ||||
|   | ||||
							
								
								
									
										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); | ||||
| 	va_end(va); | ||||
|  | ||||
| 	Str str = { result, buf }; | ||||
| 	Str str = { buf, result }; | ||||
| 	return str; | ||||
| } | ||||
| #pragma endregion Interface | ||||
|   | ||||
| @@ -289,12 +289,12 @@ Code untyped_token_fmt( s32 num_tokens, char const* fmt, ... ); | ||||
| #ifndef name | ||||
| //	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. | ||||
| #define name( Id_ )   { sizeof(stringize( Id_ )) - 1, stringize(Id_) } | ||||
| #define name( Id_ )   { stringize(Id_), sizeof(stringize( Id_ )) - 1 } | ||||
| #endif | ||||
|  | ||||
| #ifndef code | ||||
| //  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 | ||||
|  | ||||
| #ifndef args | ||||
|   | ||||
| @@ -138,8 +138,8 @@ Code untyped_fmt( char const* fmt, ...) | ||||
| 	ssize length = c_str_fmt_va(buf, GEN_PRINTF_MAXLEN, fmt, va); | ||||
| 	va_end(va); | ||||
|  | ||||
| 	Str buf_str      = { c_str_len_capped(fmt, MaxNameLength), fmt }; | ||||
|     Str uncapped_str = { length, buf }; | ||||
| 	Str buf_str      = { fmt, c_str_len_capped(fmt, MaxNameLength) }; | ||||
|     Str uncapped_str = { buf, length }; | ||||
|  | ||||
| 	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); | ||||
| 	va_end(va); | ||||
|  | ||||
| 	Str buf_str = { length, buf }; | ||||
| 	Str buf_str = { buf, length }; | ||||
|  | ||||
| 	Code | ||||
| 	result          = make_code(); | ||||
|   | ||||
| @@ -461,7 +461,7 @@ CodeComment def_comment( Str content ) | ||||
| 	if ( * strbuilder_back(cmt_formatted) != '\n' ) | ||||
| 		strbuilder_append_str( & cmt_formatted, txt("\n") ); | ||||
|  | ||||
| 	Str name = { strbuilder_length(cmt_formatted), cmt_formatted }; | ||||
| 	Str name = strbuilder_to_str(cmt_formatted); | ||||
|  | ||||
| 	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] == '(' ) | ||||
| 				break; | ||||
| 		} | ||||
| 		Str lex_id = { lex_id_len, result->Name.Ptr }; | ||||
| 		Str lex_id = { result->Name.Ptr,  lex_id_len }; | ||||
| 		array_append(PreprocessorDefines, lex_id ); | ||||
| 	} | ||||
| 	return result; | ||||
| @@ -895,7 +895,7 @@ CodeOperator def_operator( Operator op, Str nspace, Opts_def_operator p ) | ||||
| 	else | ||||
| 		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 | ||||
| 	result              = (CodeOperator) make_code(); | ||||
|   | ||||
| @@ -43,7 +43,7 @@ AccessSpec tok_to_access_specifier(Token tok) | ||||
|  | ||||
| Str tok_to_str(Token tok) | ||||
| { | ||||
| 	Str str = { tok.Length, tok.Text }; | ||||
| 	Str str = { tok.Text, tok.Length }; | ||||
| 	return str; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -60,7 +60,7 @@ StrBuilder parser_to_string(ParseContext ctx) | ||||
| 		length++; | ||||
| 	} | ||||
|  | ||||
| 	Str scope_str = { length, scope_start.Text }; | ||||
| 	Str scope_str = { scope_start.Text, length }; | ||||
| 	StrBuilder line = strbuilder_make_str( GlobalAllocator, scope_str ); | ||||
| 	strbuilder_append_fmt( & result, "\tScope    : %s\n", 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   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 ); | ||||
|  | ||||
| 	if ( length_from_err < 100 ) | ||||
| @@ -681,7 +681,7 @@ CodeAttributes parse_attributes() | ||||
|  | ||||
| 	if ( len > 0 ) | ||||
| 	{ | ||||
| 		Str attribute_txt = { len, start.Text }; | ||||
| 		Str attribute_txt = { start.Text, len }; | ||||
| 		parser_pop(& Context); | ||||
|  | ||||
| 		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_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->Content = attributes->Name; | ||||
| 						// <Attributes> <Specifiers> <Attributes> | ||||
| @@ -1616,7 +1616,7 @@ Code parse_function_body() | ||||
|  | ||||
| 	if ( len > 0 ) | ||||
| 	{ | ||||
| 		Str str = { len, start.Text }; | ||||
| 		Str str = { start.Text, len }; | ||||
| 		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; | ||||
|  | ||||
| 	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->Name	= assert->Content; | ||||
|  | ||||
| @@ -5082,7 +5082,7 @@ CodeTypedef parser_parse_typedef() | ||||
|  | ||||
| 		if ( currtok.Type == Tok_Identifier ) | ||||
| 		{ | ||||
| 			Str name_str = { name.Length, name.Text }; | ||||
| 			Str name_str = { name.Text, name.Length }; | ||||
| 			type = untyped_str(name_str); | ||||
| 			name = currtok; | ||||
| 			eat(Tok_Identifier); | ||||
| @@ -5279,7 +5279,7 @@ CodeUnion parser_parse_union( bool inplace_def ) | ||||
| 	CodeAttributes attributes = parse_attributes(); | ||||
| 	// <ModuleFlags> union <Attributes> | ||||
|  | ||||
| 	Str name = { 0, nullptr }; | ||||
| 	Str name = { nullptr, 0 }; | ||||
| 	if ( check( Tok_Identifier ) ) | ||||
| { | ||||
| 		name = tok_to_str(currtok); | ||||
|   | ||||
| @@ -48,13 +48,13 @@ Str access_spec_to_str( AccessSpec type ) | ||||
| { | ||||
| 	local_persist | ||||
| 	Str lookup[ (u32)AccessSpec_Num_AccessSpec ] = { | ||||
| 		{ sizeof("") - 1,          "" }, | ||||
| 		{ sizeof("prviate") - 1,   "private" }, | ||||
| 		{ sizeof("protected") - 1, "private" }, | ||||
| 		{ sizeof("public") - 1,    "public" }, | ||||
| 		{ "",        sizeof( "" )        - 1 }, | ||||
| 		{ "private", sizeof("prviate")   - 1 }, | ||||
| 		{ "private", sizeof("protected") - 1 }, | ||||
| 		{ "public",  sizeof("public")    - 1 }, | ||||
| 	}; | ||||
|  | ||||
| 	Str invalid = { sizeof("Invalid") - 1, "Invalid" }; | ||||
| 	Str invalid = { "Invalid", sizeof("Invalid") - 1 }; | ||||
| 	if ( type > AccessSpec_Public ) | ||||
| 		return invalid; | ||||
|  | ||||
| @@ -101,13 +101,13 @@ Str module_flag_to_str( ModuleFlag flag ) | ||||
| { | ||||
| 	local_persist | ||||
| 	Str lookup[ (u32)Num_ModuleFlags ] = { | ||||
| 		{ sizeof("__none__"), "__none__" }, | ||||
| 		{ sizeof("export"), "export" }, | ||||
| 		{ sizeof("import"), "import" }, | ||||
| 		{ "__none__", sizeof("__none__") - 1 }, | ||||
| 		{ "export",   sizeof("export")   - 1  }, | ||||
| 		{ "import",   sizeof("import")   - 1 }, | ||||
| 	}; | ||||
|  | ||||
| 	local_persist | ||||
| 	Str invalid_flag = { sizeof("invalid"), "invalid" }; | ||||
| 	Str invalid_flag = { "invalid", sizeof("invalid") }; | ||||
| 	if ( flag > ModuleFlag_Import ) | ||||
| 		return invalid_flag; | ||||
|  | ||||
|   | ||||
| @@ -18,8 +18,8 @@ Str         str_visualize_whitespace(Str str, AllocatorInfo allocator); | ||||
| // Constant string with length. | ||||
| struct Str | ||||
| { | ||||
| 	ssize       Len; | ||||
| 	char const* Ptr; | ||||
| 	ssize       Len; | ||||
|  | ||||
| #if GEN_COMPILER_CPP | ||||
| 	forceinline operator char const* ()               const { return Ptr; } | ||||
| @@ -40,9 +40,9 @@ struct Str | ||||
|  | ||||
| #ifndef txt | ||||
| #	if GEN_COMPILER_CPP | ||||
| #		define txt( text )          Str { sizeof( text ) - 1, ( text ) } | ||||
| #		define txt( text )          Str { ( text ), sizeof( text ) - 1 } | ||||
| #	else | ||||
| #		define txt( text )         (Str){ sizeof( text ) - 1, ( text ) } | ||||
| #		define txt( text )         (Str){ ( text ), sizeof( text ) - 1 } | ||||
| #	endif | ||||
| #endif | ||||
|  | ||||
| @@ -103,7 +103,7 @@ b32 str_starts_with(Str str, Str substring) { | ||||
|  | ||||
| inline | ||||
| 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; | ||||
| } | ||||
|  | ||||
| @@ -170,7 +170,7 @@ struct StrBuilder | ||||
|  | ||||
| 	forceinline operator char*()             { 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 { | ||||
| 		if (this == &other) | ||||
| @@ -243,7 +243,7 @@ struct StrBuilder | ||||
| 	forceinline b32           starts_with(StrBuilder substring) const        { return strbuilder_starts_with_string(* this, substring); } | ||||
| 	forceinline void          skip_line()                                    {        strbuilder_skip_line(* 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_space()                                   {        strbuilder_trim_space(* this); } | ||||
| 	forceinline StrBuilder    visualize_whitespace() const                   { return strbuilder_visualize_whitespace(* this); } | ||||
| @@ -621,7 +621,7 @@ void strip_space(StrBuilder str) | ||||
|  | ||||
| forceinline | ||||
| Str strbuilder_to_str(StrBuilder str) { | ||||
| 	Str result = { strbuilder_length(str), (char const*)str }; | ||||
| 	Str result = { (char const*)str, strbuilder_length(str) }; | ||||
| 	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; | ||||
| 		// 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( & to_c_str_entries,         "{ sizeof(\"%s\"), \"%s\" },\n", code, code ); | ||||
| 		strbuilder_append_fmt( & to_keyword_c_str_entries, "{ sizeof(\"%s\") - 1, \"%s\" },\n", keyword, keyword ); | ||||
| 		strbuilder_append_fmt( & to_c_str_entries,         "{ \"%s\",  sizeof(\"%s\") },\n", code, code ); | ||||
| 		strbuilder_append_fmt( & to_keyword_c_str_entries, "{  \"%s\", sizeof(\"%s\") - 1 },\n", keyword, keyword ); | ||||
| 	} | ||||
|  | ||||
| 	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* entry_to_str = csv_enum.Col_2[idx].string; | ||||
| 		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; | ||||
| @@ -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* entry_to_str = csv_enum.Col_2[idx].string; | ||||
| 		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; | ||||
| @@ -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; | ||||
|  | ||||
| 		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++ ) | ||||
| @@ -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; | ||||
|  | ||||
| 		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 ); | ||||
|  | ||||
| 		if ( idx < array_num(attribute_strs) - 1 ) | ||||
|   | ||||
| @@ -646,7 +646,7 @@ do                          \ | ||||
| 					if (fn->Name.starts_with(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 ); | ||||
|  | ||||
| 						fn->Name = get_cached_string(new_name); | ||||
| @@ -796,7 +796,7 @@ R"(#define AST_ArrSpecs_Cap \ | ||||
| 			{ | ||||
| 				generic_selector.clear(); | ||||
| 				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 ); | ||||
|  | ||||
| 				// 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 | ||||
| 				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(); | ||||
|  | ||||
| 				// Resolve define's arguments | ||||
| @@ -1020,7 +1020,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \ | ||||
| 			if (fn->Name.starts_with(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 ); | ||||
|  | ||||
| 				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_"))) | ||||
| 			{ | ||||
| 				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 ); | ||||
|  | ||||
| 				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_"))) | ||||
| 			{ | ||||
| 				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(); | ||||
|  | ||||
| 				fn->Name = get_cached_string(new_name); | ||||
|   | ||||
| @@ -68,7 +68,7 @@ int gen_main() | ||||
| 		CodeBody macros = def_body( CT_Global_Body ); | ||||
| 		{ | ||||
| 			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(); | ||||
| 						code != ori_macros.end(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user