From d45908fb3271d6e93674a9d99b81521d56b708e7 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Tue, 3 Dec 2024 09:50:30 -0500 Subject: [PATCH] reduce TokType enum to c-compatiable --- project/components/gen/etoktype.cpp | 438 ++++---- project/components/interface.parsing.cpp | 4 +- project/components/lexer.cpp | 152 +-- project/components/parser.cpp | 1234 +++++++++++----------- project/helpers/helper.hpp | 37 +- 5 files changed, 930 insertions(+), 935 deletions(-) diff --git a/project/components/gen/etoktype.cpp b/project/components/gen/etoktype.cpp index b1ce2ef..445201b 100644 --- a/project/components/gen/etoktype.cpp +++ b/project/components/gen/etoktype.cpp @@ -6,235 +6,231 @@ // 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" ) -namespace ETokType +typedef TokType_Def TokType; + +enum TokType_Def : u32 { -#define GEN_DEFINE_ATTRIBUTE_TOKENS Entry( Attribute_API_Export, "GEN_API_Export_Code" ) Entry( Attribute_API_Import, "GEN_API_Import_Code" ) + 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 +}; - enum Type : u32 - { - Invalid, - Access_Private, - Access_Protected, - Access_Public, - Access_MemberSymbol, - Access_StaticSymbol, - Ampersand, - Ampersand_DBL, - Assign_Classifer, - Attribute_Open, - Attribute_Close, - BraceCurly_Open, - BraceCurly_Close, - BraceSquare_Open, - BraceSquare_Close, - Capture_Start, - Capture_End, - Comment, - Comment_End, - Comment_Start, - Char, - Comma, - Decl_Class, - Decl_GNU_Attribute, - Decl_MSVC_Attribute, - Decl_Enum, - Decl_Extern_Linkage, - Decl_Friend, - Decl_Module, - Decl_Namespace, - Decl_Operator, - Decl_Struct, - Decl_Template, - Decl_Typedef, - Decl_Using, - Decl_Union, - Identifier, - Module_Import, - Module_Export, - NewLine, - Number, - Operator, - Preprocess_Hash, - Preprocess_Define, - Preprocess_If, - Preprocess_IfDef, - Preprocess_IfNotDef, - Preprocess_ElIf, - Preprocess_Else, - Preprocess_EndIf, - Preprocess_Include, - Preprocess_Pragma, - Preprocess_Content, - Preprocess_Macro, - Preprocess_Unsupported, - Spec_Alignas, - Spec_Const, - Spec_Consteval, - Spec_Constexpr, - Spec_Constinit, - Spec_Explicit, - Spec_Extern, - Spec_Final, - Spec_ForceInline, - Spec_Global, - Spec_Inline, - Spec_Internal_Linkage, - Spec_LocalPersist, - Spec_Mutable, - Spec_NeverInline, - Spec_Override, - Spec_Static, - Spec_ThreadLocal, - Spec_Volatile, - Spec_Virtual, - Star, - Statement_End, - StaticAssert, - String, - Type_Typename, - Type_Unsigned, - Type_Signed, - Type_Short, - Type_Long, - Type_bool, - Type_char, - Type_int, - Type_double, - Type_MS_int8, - Type_MS_int16, - Type_MS_int32, - Type_MS_int64, - Type_MS_W64, - Varadic_Argument, - __Attributes_Start, - Attribute_API_Export, - Attribute_API_Import, - NumTokens +inline StrC to_str( TokType type ) +{ + local_persist StrC lookup[] { + { sizeof( "__invalid__" ), "__invalid__" }, + { sizeof( "private" ), "private" }, + { sizeof( "protected" ), "protected" }, + { sizeof( "public" ), "public" }, + { sizeof( "." ), "." }, + { sizeof( "::" ), "::" }, + { sizeof( "&" ), "&" }, + { sizeof( "&&" ), "&&" }, + { sizeof( ":" ), ":" }, + { sizeof( "[[" ), "[[" }, + { sizeof( "]]" ), "]]" }, + { sizeof( "{" ), "{" }, + { sizeof( "}" ), "}" }, + { sizeof( "[" ), "[" }, + { sizeof( "]" ), "]" }, + { sizeof( "(" ), "(" }, + { sizeof( ")" ), ")" }, + { sizeof( "__comment__" ), "__comment__" }, + { sizeof( "__comment_end__" ), "__comment_end__" }, + { sizeof( "__comment_start__" ), "__comment_start__" }, + { sizeof( "__character__" ), "__character__" }, + { sizeof( "," ), "," }, + { sizeof( "class" ), "class" }, + { sizeof( "__attribute__" ), "__attribute__" }, + { sizeof( "__declspec" ), "__declspec" }, + { sizeof( "enum" ), "enum" }, + { sizeof( "extern" ), "extern" }, + { sizeof( "friend" ), "friend" }, + { sizeof( "module" ), "module" }, + { sizeof( "namespace" ), "namespace" }, + { sizeof( "operator" ), "operator" }, + { sizeof( "struct" ), "struct" }, + { sizeof( "template" ), "template" }, + { sizeof( "typedef" ), "typedef" }, + { sizeof( "using" ), "using" }, + { sizeof( "union" ), "union" }, + { sizeof( "__identifier__" ), "__identifier__" }, + { sizeof( "import" ), "import" }, + { sizeof( "export" ), "export" }, + { sizeof( "__new_line__" ), "__new_line__" }, + { sizeof( "__number__" ), "__number__" }, + { sizeof( "__operator__" ), "__operator__" }, + { sizeof( "#" ), "#" }, + { sizeof( "define" ), "define" }, + { sizeof( "if" ), "if" }, + { sizeof( "ifdef" ), "ifdef" }, + { sizeof( "ifndef" ), "ifndef" }, + { sizeof( "elif" ), "elif" }, + { sizeof( "else" ), "else" }, + { sizeof( "endif" ), "endif" }, + { sizeof( "include" ), "include" }, + { sizeof( "pragma" ), "pragma" }, + { sizeof( "__macro_content__" ), "__macro_content__" }, + { sizeof( "__macro__" ), "__macro__" }, + { sizeof( "__unsupported__" ), "__unsupported__" }, + { sizeof( "alignas" ), "alignas" }, + { sizeof( "const" ), "const" }, + { sizeof( "consteval" ), "consteval" }, + { sizeof( "constexpr" ), "constexpr" }, + { sizeof( "constinit" ), "constinit" }, + { sizeof( "explicit" ), "explicit" }, + { sizeof( "extern" ), "extern" }, + { sizeof( "final" ), "final" }, + { sizeof( "forceinline" ), "forceinline" }, + { sizeof( "global" ), "global" }, + { sizeof( "inline" ), "inline" }, + { sizeof( "internal" ), "internal" }, + { sizeof( "local_persist" ), "local_persist" }, + { sizeof( "mutable" ), "mutable" }, + { sizeof( "neverinline" ), "neverinline" }, + { sizeof( "override" ), "override" }, + { sizeof( "static" ), "static" }, + { sizeof( "thread_local" ), "thread_local" }, + { sizeof( "volatile" ), "volatile" }, + { sizeof( "virtual" ), "virtual" }, + { sizeof( "*" ), "*" }, + { sizeof( ";" ), ";" }, + { sizeof( "static_assert" ), "static_assert" }, + { sizeof( "__string__" ), "__string__" }, + { sizeof( "typename" ), "typename" }, + { sizeof( "unsigned" ), "unsigned" }, + { sizeof( "signed" ), "signed" }, + { sizeof( "short" ), "short" }, + { sizeof( "long" ), "long" }, + { sizeof( "bool" ), "bool" }, + { sizeof( "char" ), "char" }, + { sizeof( "int" ), "int" }, + { sizeof( "double" ), "double" }, + { sizeof( "__int8" ), "__int8" }, + { sizeof( "__int16" ), "__int16" }, + { sizeof( "__int32" ), "__int32" }, + { sizeof( "__int64" ), "__int64" }, + { sizeof( "_W64" ), "_W64" }, + { sizeof( "..." ), "..." }, + { sizeof( "__attrib_start__" ), "__attrib_start__" }, + { sizeof( "GEN_API_Export_Code" ), "GEN_API_Export_Code" }, + { sizeof( "GEN_API_Import_Code" ), "GEN_API_Import_Code" }, }; + return lookup[type]; +} - inline StrC to_str( Type type ) +inline TokType to_type( StrC str ) +{ + local_persist u32 keymap[Tok_NumTokens]; + do_once_start for ( u32 index = 0; index < Tok_NumTokens; index++ ) { - local_persist StrC lookup[] { - { sizeof( "__invalid__" ), "__invalid__" }, - { sizeof( "private" ), "private" }, - { sizeof( "protected" ), "protected" }, - { sizeof( "public" ), "public" }, - { sizeof( "." ), "." }, - { sizeof( "::" ), "::" }, - { sizeof( "&" ), "&" }, - { sizeof( "&&" ), "&&" }, - { sizeof( ":" ), ":" }, - { sizeof( "[[" ), "[[" }, - { sizeof( "]]" ), "]]" }, - { sizeof( "{" ), "{" }, - { sizeof( "}" ), "}" }, - { sizeof( "[" ), "[" }, - { sizeof( "]" ), "]" }, - { sizeof( "(" ), "(" }, - { sizeof( ")" ), ")" }, - { sizeof( "__comment__" ), "__comment__" }, - { sizeof( "__comment_end__" ), "__comment_end__" }, - { sizeof( "__comment_start__" ), "__comment_start__" }, - { sizeof( "__character__" ), "__character__" }, - { sizeof( "," ), "," }, - { sizeof( "class" ), "class" }, - { sizeof( "__attribute__" ), "__attribute__" }, - { sizeof( "__declspec" ), "__declspec" }, - { sizeof( "enum" ), "enum" }, - { sizeof( "extern" ), "extern" }, - { sizeof( "friend" ), "friend" }, - { sizeof( "module" ), "module" }, - { sizeof( "namespace" ), "namespace" }, - { sizeof( "operator" ), "operator" }, - { sizeof( "struct" ), "struct" }, - { sizeof( "template" ), "template" }, - { sizeof( "typedef" ), "typedef" }, - { sizeof( "using" ), "using" }, - { sizeof( "union" ), "union" }, - { sizeof( "__identifier__" ), "__identifier__" }, - { sizeof( "import" ), "import" }, - { sizeof( "export" ), "export" }, - { sizeof( "__new_line__" ), "__new_line__" }, - { sizeof( "__number__" ), "__number__" }, - { sizeof( "__operator__" ), "__operator__" }, - { sizeof( "#" ), "#" }, - { sizeof( "define" ), "define" }, - { sizeof( "if" ), "if" }, - { sizeof( "ifdef" ), "ifdef" }, - { sizeof( "ifndef" ), "ifndef" }, - { sizeof( "elif" ), "elif" }, - { sizeof( "else" ), "else" }, - { sizeof( "endif" ), "endif" }, - { sizeof( "include" ), "include" }, - { sizeof( "pragma" ), "pragma" }, - { sizeof( "__macro_content__" ), "__macro_content__" }, - { sizeof( "__macro__" ), "__macro__" }, - { sizeof( "__unsupported__" ), "__unsupported__" }, - { sizeof( "alignas" ), "alignas" }, - { sizeof( "const" ), "const" }, - { sizeof( "consteval" ), "consteval" }, - { sizeof( "constexpr" ), "constexpr" }, - { sizeof( "constinit" ), "constinit" }, - { sizeof( "explicit" ), "explicit" }, - { sizeof( "extern" ), "extern" }, - { sizeof( "final" ), "final" }, - { sizeof( "forceinline" ), "forceinline" }, - { sizeof( "global" ), "global" }, - { sizeof( "inline" ), "inline" }, - { sizeof( "internal" ), "internal" }, - { sizeof( "local_persist" ), "local_persist" }, - { sizeof( "mutable" ), "mutable" }, - { sizeof( "neverinline" ), "neverinline" }, - { sizeof( "override" ), "override" }, - { sizeof( "static" ), "static" }, - { sizeof( "thread_local" ), "thread_local" }, - { sizeof( "volatile" ), "volatile" }, - { sizeof( "virtual" ), "virtual" }, - { sizeof( "*" ), "*" }, - { sizeof( ";" ), ";" }, - { sizeof( "static_assert" ), "static_assert" }, - { sizeof( "__string__" ), "__string__" }, - { sizeof( "typename" ), "typename" }, - { sizeof( "unsigned" ), "unsigned" }, - { sizeof( "signed" ), "signed" }, - { sizeof( "short" ), "short" }, - { sizeof( "long" ), "long" }, - { sizeof( "bool" ), "bool" }, - { sizeof( "char" ), "char" }, - { sizeof( "int" ), "int" }, - { sizeof( "double" ), "double" }, - { sizeof( "__int8" ), "__int8" }, - { sizeof( "__int16" ), "__int16" }, - { sizeof( "__int32" ), "__int32" }, - { sizeof( "__int64" ), "__int64" }, - { sizeof( "_W64" ), "_W64" }, - { sizeof( "..." ), "..." }, - { sizeof( "__attrib_start__" ), "__attrib_start__" }, - { sizeof( "GEN_API_Export_Code" ), "GEN_API_Export_Code" }, - { sizeof( "GEN_API_Import_Code" ), "GEN_API_Import_Code" }, - }; - return lookup[type]; + StrC enum_str = to_str( (TokType)index ); + keymap[index] = crc32( enum_str.Ptr, enum_str.Len - 1 ); } - - inline Type to_type( StrC str ) + do_once_end u32 hash = crc32( str.Ptr, str.Len ); + for ( u32 index = 0; index < Tok_NumTokens; index++ ) { - local_persist u32 keymap[NumTokens]; - do_once_start for ( u32 index = 0; index < NumTokens; index++ ) - { - StrC enum_str = to_str( (Type)index ); - keymap[index] = crc32( enum_str.Ptr, enum_str.Len - 1 ); - } - do_once_end u32 hash = crc32( str.Ptr, str.Len ); - for ( u32 index = 0; index < NumTokens; index++ ) - { - if ( keymap[index] == hash ) - return (Type)index; - } - return Invalid; + if ( keymap[index] == hash ) + return (TokType)index; } + return Tok_Invalid; +} -} // namespace ETokType - -using TokType = ETokType::Type; GEN_NS_PARSER_END diff --git a/project/components/interface.parsing.cpp b/project/components/interface.parsing.cpp index 1abc9eb..ca448f2 100644 --- a/project/components/interface.parsing.cpp +++ b/project/components/interface.parsing.cpp @@ -19,7 +19,7 @@ CodeClass parse_class( StrC def ) Context.Tokens = toks; push_scope(); - CodeClass result = (CodeClass) parse_class_struct( parser::TokType::Decl_Class ); + CodeClass result = (CodeClass) parse_class_struct( Tok_Decl_Class ); pop(& Context); return result; } @@ -235,7 +235,7 @@ CodeStruct parse_struct( StrC def ) Context.Tokens = toks; push_scope(); - CodeStruct result = (CodeStruct) parse_class_struct( TokType::Decl_Struct ); + CodeStruct result = (CodeStruct) parse_class_struct( Tok_Decl_Struct ); pop(& Context); return result; } diff --git a/project/components/lexer.cpp b/project/components/lexer.cpp index ddf47da..671fc08 100644 --- a/project/components/lexer.cpp +++ b/project/components/lexer.cpp @@ -33,7 +33,7 @@ struct Token u32 Flags; }; -constexpr Token NullToken { nullptr, 0, TokType::Invalid, false, 0, TF_Null }; +constexpr Token NullToken { nullptr, 0, Tok_Invalid, false, 0, TF_Null }; AccessSpec to_access_specifier(Token tok) { @@ -47,7 +47,7 @@ StrC to_str(Token tok) bool is_valid( Token tok ) { - return tok.Text && tok.Length && tok.Type != TokType::Invalid; + return tok.Text && tok.Length && tok.Type != Tok_Invalid; } bool is_access_operator(Token tok) @@ -94,7 +94,7 @@ String to_string(Token tok) { String result = string_make_reserve( GlobalAllocator, kilobytes(4) ); - StrC type_str = ETokType::to_str( tok.Type ); + StrC type_str = to_str( tok.Type ); append_fmt( & result, "Line: %d Column: %d, Type: %.*s Content: %.*s" , tok.Line, tok.Column @@ -117,7 +117,7 @@ Token* current(TokArray* self, bool skip_formatting ) { if ( skip_formatting ) { - while ( self->Arr[self->Idx].Type == TokType::NewLine || self->Arr[self->Idx].Type == TokType::Comment ) + while ( self->Arr[self->Idx].Type == Tok_NewLine || self->Arr[self->Idx].Type == Tok_Comment ) self->Idx++; } @@ -130,7 +130,7 @@ Token* previous(TokArray self, bool skip_formatting) if ( skip_formatting ) { - while ( self.Arr[idx].Type == TokType::NewLine ) + while ( self.Arr[idx].Type == Tok_NewLine ) idx --; return & self.Arr[idx]; @@ -145,7 +145,7 @@ Token* next(TokArray self, bool skip_formatting) if ( skip_formatting ) { - while ( self.Arr[idx].Type == TokType::NewLine ) + while ( self.Arr[idx].Type == Tok_NewLine ) idx++; return & self.Arr[idx + 1]; @@ -221,7 +221,7 @@ forceinline s32 lex_preprocessor_directive( LexContext* ctx ) { char const* hash = ctx->scanner; - append( & Tokens, { hash, 1, TokType::Preprocess_Hash, ctx->line, ctx->column, TF_Preprocess } ); + append( & Tokens, { hash, 1, Tok_Preprocess_Hash, ctx->line, ctx->column, TF_Preprocess } ); move_forward(); SkipWhitespace(); @@ -233,12 +233,12 @@ s32 lex_preprocessor_directive( LexContext* ctx ) ctx->token.Length++; } - ctx->token.Type = ETokType::to_type( to_str(ctx->token) ); + ctx->token.Type = to_type( to_str(ctx->token) ); - bool is_preprocessor = ctx->token.Type >= TokType::Preprocess_Define && ctx->token.Type <= TokType::Preprocess_Pragma; + bool is_preprocessor = ctx->token.Type >= Tok_Preprocess_Define && ctx->token.Type <= Tok_Preprocess_Pragma; if ( ! is_preprocessor ) { - ctx->token.Type = TokType::Preprocess_Unsupported; + ctx->token.Type = Tok_Preprocess_Unsupported; // Its an unsupported directive, skip it s32 within_string = false; @@ -301,14 +301,14 @@ s32 lex_preprocessor_directive( LexContext* ctx ) return Lex_Continue; // Skip found token, its all handled here. } - if ( ctx->token.Type == TokType::Preprocess_Else || ctx->token.Type == TokType::Preprocess_EndIf ) + if ( ctx->token.Type == Tok_Preprocess_Else || ctx->token.Type == Tok_Preprocess_EndIf ) { ctx->token.Flags |= TF_Preprocess_Cond; append( & Tokens, ctx->token ); end_line(); return Lex_Continue; } - else if ( ctx->token.Type >= TokType::Preprocess_If && ctx->token.Type <= TokType::Preprocess_ElIf ) + else if ( ctx->token.Type >= Tok_Preprocess_If && ctx->token.Type <= Tok_Preprocess_ElIf ) { ctx->token.Flags |= TF_Preprocess_Cond; } @@ -317,9 +317,9 @@ s32 lex_preprocessor_directive( LexContext* ctx ) SkipWhitespace(); - if ( ctx->token.Type == TokType::Preprocess_Define ) + if ( ctx->token.Type == Tok_Preprocess_Define ) { - Token name = { ctx->scanner, 0, TokType::Identifier, ctx->line, ctx->column, TF_Preprocess }; + Token name = { ctx->scanner, 0, Tok_Identifier, ctx->line, ctx->column, TF_Preprocess }; name.Text = ctx->scanner; name.Length = 1; @@ -343,11 +343,11 @@ s32 lex_preprocessor_directive( LexContext* ctx ) set(& ctx->defines, key, to_str(name) ); } - Token preprocess_content = { ctx->scanner, 0, TokType::Preprocess_Content, ctx->line, ctx->column, TF_Preprocess }; + Token preprocess_content = { ctx->scanner, 0, Tok_Preprocess_Content, ctx->line, ctx->column, TF_Preprocess }; - if ( ctx->token.Type == TokType::Preprocess_Include ) + if ( ctx->token.Type == Tok_Preprocess_Include ) { - preprocess_content.Type = TokType::String; + preprocess_content.Type = Tok_String; if ( current != '"' && current != '<' ) { @@ -452,31 +452,31 @@ s32 lex_preprocessor_directive( LexContext* ctx ) forceinline void lex_found_token( LexContext* ctx ) { - if ( ctx->token.Type != TokType::Invalid ) + if ( ctx->token.Type != Tok_Invalid ) { append( & Tokens, ctx->token ); return; } - TokType type = ETokType::to_type( to_str(ctx->token) ); + TokType type = to_type( to_str(ctx->token) ); - if (type <= TokType::Access_Public && type >= TokType::Access_Private ) + if (type <= Tok_Access_Public && type >= Tok_Access_Private ) { ctx->token.Flags |= TF_AccessSpecifier; } - if ( type > TokType::__Attributes_Start ) + if ( type > Tok___Attributes_Start ) { ctx->token.Flags |= TF_Attribute; } - if ( type == ETokType::Decl_Extern_Linkage ) + if ( type == Tok_Decl_Extern_Linkage ) { SkipWhitespace(); if ( current != '"' ) { - type = ETokType::Spec_Extern; + type = Tok_Spec_Extern; ctx->token.Flags |= TF_Specifier; } @@ -485,9 +485,9 @@ void lex_found_token( LexContext* ctx ) return; } - if ( ( type <= TokType::Star && type >= TokType::Spec_Alignas) - || type == TokType::Ampersand - || type == TokType::Ampersand_DBL ) + if ( ( type <= Tok_Star && type >= Tok_Spec_Alignas) + || type == Tok_Ampersand + || type == Tok_Ampersand_DBL ) { ctx->token.Type = type; ctx->token.Flags |= TF_Specifier; @@ -496,7 +496,7 @@ void lex_found_token( LexContext* ctx ) } - if ( type != TokType::Invalid ) + if ( type != Tok_Invalid ) { ctx->token.Type = type; append( & Tokens, ctx->token ); @@ -512,7 +512,7 @@ void lex_found_token( LexContext* ctx ) StrC* define = get(ctx->defines, key ); if ( define ) { - ctx->token.Type = TokType::Preprocess_Macro; + ctx->token.Type = Tok_Preprocess_Macro; // Want to ignore any arguments the define may have as they can be execution expressions. if ( ctx->left && current == '(' ) @@ -548,7 +548,7 @@ void lex_found_token( LexContext* ctx ) } else { - ctx->token.Type = TokType::Identifier; + ctx->token.Type = Tok_Identifier; } append( & Tokens, ctx->token ); @@ -607,7 +607,7 @@ TokArray lex( StrC content ) } #endif - c.token = { c.scanner, 0, TokType::Invalid, c.line, c.column, TF_Null }; + c.token = { c.scanner, 0, Tok_Invalid, c.line, c.column, TF_Null }; bool is_define = false; @@ -623,7 +623,7 @@ TokArray lex( StrC content ) { move_forward(); - c.token.Type = TokType::NewLine; + c.token.Type = Tok_NewLine; c.token.Length++; append( & Tokens, c.token ); @@ -655,7 +655,7 @@ TokArray lex( StrC content ) { c.token.Text = c.scanner; c.token.Length = 1; - c.token.Type = TokType::Access_MemberSymbol; + c.token.Type = Tok_Access_MemberSymbol; c.token.Flags = TF_AccessOperator; if (c.left) { @@ -668,7 +668,7 @@ TokArray lex( StrC content ) if( current == '.' ) { c.token.Length = 3; - c.token.Type = TokType::Varadic_Argument; + c.token.Type = Tok_Varadic_Argument; c.token.Flags = TF_Null; move_forward(); } @@ -686,7 +686,7 @@ TokArray lex( StrC content ) { c.token.Text = c.scanner; c.token.Length = 1; - c.token.Type = TokType::Ampersand; + c.token.Type = Tok_Ampersand; c.token.Flags |= TF_Operator; c.token.Flags |= TF_Specifier; @@ -696,7 +696,7 @@ TokArray lex( StrC content ) if ( current == '&' ) // && { c.token.Length = 2; - c.token.Type = TokType::Ampersand_DBL; + c.token.Type = Tok_Ampersand_DBL; if (c.left) move_forward(); @@ -708,9 +708,9 @@ TokArray lex( StrC content ) { c.token.Text = c.scanner; c.token.Length = 1; - c.token.Type = TokType::Assign_Classifer; + c.token.Type = Tok_Assign_Classifer; // Can be either a classifier (ParentType, Bitfield width), or ternary else - // token.Type = TokType::Colon; + // token.Type = Tok_Colon; if (c.left) move_forward(); @@ -718,7 +718,7 @@ TokArray lex( StrC content ) if ( current == ':' ) { move_forward(); - c.token.Type = TokType::Access_StaticSymbol; + c.token.Type = Tok_Access_StaticSymbol; c.token.Length++; } goto FoundToken; @@ -727,7 +727,7 @@ TokArray lex( StrC content ) { c.token.Text = c.scanner; c.token.Length = 1; - c.token.Type = TokType::BraceCurly_Open; + c.token.Type = Tok_BraceCurly_Open; if (c.left) move_forward(); @@ -737,7 +737,7 @@ TokArray lex( StrC content ) { c.token.Text = c.scanner; c.token.Length = 1; - c.token.Type = TokType::BraceCurly_Close; + c.token.Type = Tok_BraceCurly_Close; c.token.Flags = TF_EndDefinition; if (c.left) @@ -750,7 +750,7 @@ TokArray lex( StrC content ) { c.token.Text = c.scanner; c.token.Length = 1; - c.token.Type = TokType::BraceSquare_Open; + c.token.Type = Tok_BraceSquare_Open; if ( c.left ) { move_forward(); @@ -758,7 +758,7 @@ TokArray lex( StrC content ) if ( current == ']' ) { c.token.Length = 2; - c.token.Type = TokType::Operator; + c.token.Type = Tok_Operator; move_forward(); } } @@ -768,7 +768,7 @@ TokArray lex( StrC content ) { c.token.Text = c.scanner; c.token.Length = 1; - c.token.Type = TokType::BraceSquare_Close; + c.token.Type = Tok_BraceSquare_Close; if (c.left) move_forward(); @@ -778,7 +778,7 @@ TokArray lex( StrC content ) { c.token.Text = c.scanner; c.token.Length = 1; - c.token.Type = TokType::Capture_Start; + c.token.Type = Tok_Capture_Start; if (c.left) move_forward(); @@ -788,7 +788,7 @@ TokArray lex( StrC content ) { c.token.Text = c.scanner; c.token.Length = 1; - c.token.Type = TokType::Capture_End; + c.token.Type = Tok_Capture_End; if (c.left) move_forward(); @@ -798,7 +798,7 @@ TokArray lex( StrC content ) { c.token.Text = c.scanner; c.token.Length = 1; - c.token.Type = TokType::Char; + c.token.Type = Tok_Char; c.token.Flags = TF_Literal; move_forward(); @@ -832,7 +832,7 @@ TokArray lex( StrC content ) { c.token.Text = c.scanner; c.token.Length = 1; - c.token.Type = TokType::Comma; + c.token.Type = Tok_Comma; c.token.Flags = TF_Operator; if (c.left) @@ -843,7 +843,7 @@ TokArray lex( StrC content ) { c.token.Text = c.scanner; c.token.Length = 1; - c.token.Type = TokType::Star; + c.token.Type = Tok_Star; c.token.Flags |= TF_Specifier; c.token.Flags |= TF_Operator; @@ -854,7 +854,7 @@ TokArray lex( StrC content ) { c.token.Length++; c.token.Flags |= TF_Assign; - // c.token.Type = TokType::Assign_Multiply; + // c.token.Type = Tok_Assign_Multiply; if ( c.left ) move_forward(); @@ -866,7 +866,7 @@ TokArray lex( StrC content ) { c.token.Text = c.scanner; c.token.Length = 1; - c.token.Type = TokType::Statement_End; + c.token.Type = Tok_Statement_End; c.token.Flags = TF_EndDefinition; if (c.left) @@ -879,7 +879,7 @@ TokArray lex( StrC content ) { c.token.Text = c.scanner; c.token.Length = 1; - c.token.Type = TokType::String; + c.token.Type = Tok_String; c.token.Flags |= TF_Literal; move_forward(); @@ -913,8 +913,8 @@ TokArray lex( StrC content ) { c.token.Text = c.scanner; c.token.Length = 1; - c.token.Type = TokType::Operator; - // c.token.Type = TokType::Ternary; + c.token.Type = Tok_Operator; + // c.token.Type = Tok_Ternary; c.token.Flags = TF_Operator; if (c.left) @@ -926,8 +926,8 @@ TokArray lex( StrC content ) { c.token.Text = c.scanner; c.token.Length = 1; - c.token.Type = TokType::Operator; - // c.token.Type = TokType::Assign; + c.token.Type = Tok_Operator; + // c.token.Type = Tok_Assign; c.token.Flags = TF_Operator; c.token.Flags |= TF_Assign; @@ -947,44 +947,44 @@ TokArray lex( StrC content ) } case '+': { - // c.token.Type = TokType::Add + // c.token.Type = Tok_Add } case '%': { - // c.token.Type = TokType::Modulo; + // c.token.Type = Tok_Modulo; } case '^': { - // c.token.Type = TokType::B_XOr; + // c.token.Type = Tok_B_XOr; } case '~': { - // c.token.Type = TokType::Unary_Not; + // c.token.Type = Tok_Unary_Not; } case '!': { - // c.token.Type = TokType::L_Not; + // c.token.Type = Tok_L_Not; } case '<': { - // c.token.Type = TokType::Lesser; + // c.token.Type = Tok_Lesser; } case '>': { - // c.token.Type = TokType::Greater; + // c.token.Type = Tok_Greater; } case '|': { c.token.Text = c.scanner; c.token.Length = 1; - c.token.Type = TokType::Operator; + c.token.Type = Tok_Operator; c.token.Flags = TF_Operator; - // token.Type = TokType::L_Or; + // token.Type = Tok_L_Or; if (c.left) move_forward(); @@ -994,7 +994,7 @@ TokArray lex( StrC content ) c.token.Length++; c.token.Flags |= TF_Assign; // token.Flags |= TokFlags::Assignment; - // token.Type = TokType::Assign_L_Or; + // token.Type = Tok_Assign_L_Or; if (c.left) move_forward(); @@ -1014,8 +1014,8 @@ TokArray lex( StrC content ) { c.token.Text = c.scanner; c.token.Length = 1; - c.token.Type = TokType::Operator; - // token.Type = TokType::Subtract; + c.token.Type = Tok_Operator; + // token.Type = Tok_Subtract; c.token.Flags = TF_Operator; if ( c.left ) { @@ -1024,13 +1024,13 @@ TokArray lex( StrC content ) if ( current == '>' ) { c.token.Length++; -// token.Type = TokType::Access_PointerToMemberSymbol; +// token.Type = Tok_Access_PointerToMemberSymbol; c.token.Flags |= TF_AccessOperator; move_forward(); if ( current == '*' ) { -// token.Type = TokType::Access_PointerToMemberOfPointerSymbol; +// token.Type = Tok_Access_PointerToMemberOfPointerSymbol; c.token.Length++; move_forward(); } @@ -1038,7 +1038,7 @@ TokArray lex( StrC content ) else if ( current == '=' ) { c.token.Length++; - // token.Type = TokType::Assign_Subtract; + // token.Type = Tok_Assign_Subtract; c.token.Flags |= TF_Assign; if (c.left) @@ -1058,8 +1058,8 @@ TokArray lex( StrC content ) { c.token.Text = c.scanner; c.token.Length = 1; - c.token.Type = TokType::Operator; - // token.Type = TokType::Divide; + c.token.Type = Tok_Operator; + // token.Type = Tok_Divide; c.token.Flags = TF_Operator; move_forward(); @@ -1074,7 +1074,7 @@ TokArray lex( StrC content ) } else if ( current == '/' ) { - c.token.Type = TokType::Comment; + c.token.Type = Tok_Comment; c.token.Length = 2; c.token.Flags = TF_Null; move_forward(); @@ -1100,7 +1100,7 @@ TokArray lex( StrC content ) } else if ( current == '*' ) { - c.token.Type = TokType::Comment; + c.token.Type = Tok_Comment; c.token.Length = 2; c.token.Flags = TF_Null; move_forward(); @@ -1160,7 +1160,7 @@ TokArray lex( StrC content ) c.token.Text = c.scanner; c.token.Length = 1; - c.token.Type = TokType::Number; + c.token.Type = Tok_Number; c.token.Flags = TF_Literal; move_forward(); @@ -1230,7 +1230,7 @@ TokArray lex( StrC content ) { log_fmt( "Token %d Type: %s : %.*s\n" , idx - , ETokType::to_str( Tokens[ idx ].Type ).Ptr + , to_str( Tokens[ idx ].Type ).Ptr , Tokens[ idx ].Length, Tokens[ idx ].Text ); } diff --git a/project/components/parser.cpp b/project/components/parser.cpp index 88b4032..a5e4ecb 100644 --- a/project/components/parser.cpp +++ b/project/components/parser.cpp @@ -7,7 +7,7 @@ GEN_NS_PARSER_BEGIN -// TODO(Ed) : Rename ETokType::Capture_Start, ETokType::Capture_End to Open_Parenthesis adn Close_Parenthesis +// TODO(Ed) : Rename ETok_Capture_Start, ETok_Capture_End to Open_Parenthesis adn Close_Parenthesis constexpr bool dont_skip_formatting = false; constexpr bool skip_formatting = true; @@ -105,8 +105,8 @@ bool __eat(TokArray* self, TokType type ) Token at_idx = self->Arr[ self->Idx ]; - if ( ( at_idx.Type == TokType::NewLine && type != TokType::NewLine ) - || ( at_idx.Type == TokType::Comment && type != TokType::Comment ) ) + if ( ( at_idx.Type == Tok_NewLine && type != Tok_NewLine ) + || ( at_idx.Type == Tok_Comment && type != Tok_Comment ) ) { self->Idx ++; } @@ -115,7 +115,7 @@ bool __eat(TokArray* self, TokType type ) { Token tok = * current( self, skip_formatting ); log_failure( "Parse Error, TokArray::eat, Expected: ' %s ' not ' %.*s ' (%d, %d)`\n%s" - , ETokType::to_str(type).Ptr + , to_str(type).Ptr , at_idx.Length, at_idx.Text , tok.Line , tok.Column @@ -494,19 +494,19 @@ Code parse_array_decl() { push_scope(); - if ( check( TokType::Operator ) && currtok.Text[0] == '[' && currtok.Text[1] == ']' ) + if ( check( Tok_Operator ) && currtok.Text[0] == '[' && currtok.Text[1] == ']' ) { Code array_expr = untyped_str( to_str(currtok) ); - eat( TokType::Operator ); + eat( Tok_Operator ); // [] pop(& Context); return array_expr; } - if ( check( TokType::BraceSquare_Open ) ) + if ( check( Tok_BraceSquare_Open ) ) { - eat( TokType::BraceSquare_Open ); + eat( Tok_BraceSquare_Open ); // [ if ( left == 0 ) @@ -516,7 +516,7 @@ Code parse_array_decl() return InvalidCode; } - if ( currtok.Type == TokType::BraceSquare_Close ) + if ( currtok.Type == Tok_BraceSquare_Close ) { log_failure( "Error, empty array expression in definition\n%s", to_string(Context) ); pop(& Context); @@ -525,7 +525,7 @@ Code parse_array_decl() Token untyped_tok = currtok; - while ( left && currtok.Type != TokType::BraceSquare_Close ) + while ( left && currtok.Type != Tok_BraceSquare_Close ) { eat( currtok.Type ); } @@ -542,18 +542,18 @@ Code parse_array_decl() return InvalidCode; } - if ( currtok.Type != TokType::BraceSquare_Close ) + if ( currtok.Type != Tok_BraceSquare_Close ) { - log_failure( "%s: Error, expected ] in array declaration, not %s\n%s", ETokType::to_str( currtok.Type ), to_string(Context) ); + log_failure( "%s: Error, expected ] in array declaration, not %s\n%s", to_str( currtok.Type ), to_string(Context) ); pop(& Context); return InvalidCode; } - eat( TokType::BraceSquare_Close ); + eat( Tok_BraceSquare_Close ); // [ ] // Its a multi-dimensional array - if ( check( TokType::BraceSquare_Open )) + if ( check( Tok_BraceSquare_Open )) { Code adjacent_arr_expr = parse_array_decl(); // [ ][ ]... @@ -581,54 +581,54 @@ CodeAttributes parse_attributes() // TODO(Ed): Support keeping an linked list of attributes similar to parameters while ( left && is_attribute(currtok) ) { - if ( check( TokType::Attribute_Open ) ) + if ( check( Tok_Attribute_Open ) ) { - eat( TokType::Attribute_Open ); + eat( Tok_Attribute_Open ); // [[ - while ( left && currtok.Type != TokType::Attribute_Close ) + while ( left && currtok.Type != Tok_Attribute_Close ) { eat( currtok.Type ); } // [[ - eat( TokType::Attribute_Close ); + eat( Tok_Attribute_Close ); // [[ ]] len = ( ( sptr )prevtok.Text + prevtok.Length ) - ( sptr )start.Text; } - else if ( check( TokType::Decl_GNU_Attribute ) ) + else if ( check( Tok_Decl_GNU_Attribute ) ) { - eat( TokType::Decl_GNU_Attribute ); - eat( TokType::Capture_Start ); - eat( TokType::Capture_Start ); + eat( Tok_Decl_GNU_Attribute ); + eat( Tok_Capture_Start ); + eat( Tok_Capture_Start ); // __attribute__(( - while ( left && currtok.Type != TokType::Capture_End ) + while ( left && currtok.Type != Tok_Capture_End ) { eat( currtok.Type ); } // __attribute__(( - eat( TokType::Capture_End ); - eat( TokType::Capture_End ); + eat( Tok_Capture_End ); + eat( Tok_Capture_End ); // __attribute__(( )) len = ( ( sptr )prevtok.Text + prevtok.Length ) - ( sptr )start.Text; } - else if ( check( TokType::Decl_MSVC_Attribute ) ) + else if ( check( Tok_Decl_MSVC_Attribute ) ) { - eat( TokType::Decl_MSVC_Attribute ); - eat( TokType::Capture_Start ); + eat( Tok_Decl_MSVC_Attribute ); + eat( Tok_Capture_Start ); // __declspec( - while ( left && currtok.Type != TokType::Capture_End ) + while ( left && currtok.Type != Tok_Capture_End ) { eat( currtok.Type ); } // __declspec( - eat( TokType::Capture_End ); + eat( Tok_Capture_End ); // __declspec( ) len = ( ( sptr )prevtok.Text + prevtok.Length ) - ( sptr )start.Text; @@ -639,20 +639,20 @@ CodeAttributes parse_attributes() // // If its a macro based attribute, this could be a functional macro such as Unreal's UE_DEPRECATED(...) - if ( check( TokType::Capture_Start)) + if ( check( Tok_Capture_Start)) { - eat( TokType::Capture_Start ); + eat( Tok_Capture_Start ); s32 level = 0; - while (left && currtok.Type != TokType::Capture_End && level == 0) + while (left && currtok.Type != Tok_Capture_End && level == 0) { - if (currtok.Type == TokType::Capture_Start) + if (currtok.Type == Tok_Capture_Start) ++ level; - if (currtok.Type == TokType::Capture_End) + if (currtok.Type == Tok_Capture_End) --level; eat(currtok.Type); } - eat(TokType::Capture_End); + eat(Tok_Capture_End); } len = ( ( sptr )prevtok.Text + prevtok.Length ) - ( sptr )start.Text; @@ -683,13 +683,13 @@ CodeAttributes parse_attributes() internal Code parse_class_struct( TokType which, bool inplace_def = false ) { - if ( which != TokType::Decl_Class && which != TokType::Decl_Struct ) + if ( which != Tok_Decl_Class && which != Tok_Decl_Struct ) { - log_failure( "Error, expected class or struct, not %s\n%s", ETokType::to_str( which ), to_string(Context) ); + log_failure( "Error, expected class or struct, not %s\n%s", to_str( which ), to_string(Context) ); return InvalidCode; } - Token name { nullptr, 0, TokType::Invalid }; + Token name { nullptr, 0, Tok_Invalid }; AccessSpec access = AccessSpec_Default; CodeType parent = { nullptr }; @@ -699,10 +699,10 @@ Code parse_class_struct( TokType which, bool inplace_def = false ) CodeClass result = InvalidCode; - if ( check(TokType::Module_Export) ) + if ( check(Tok_Module_Export) ) { mflags = ModuleFlag_Export; - eat( TokType::Module_Export ); + eat( Tok_Module_Export ); } // @@ -712,7 +712,7 @@ Code parse_class_struct( TokType which, bool inplace_def = false ) attributes = parse_attributes(); // - if ( check( TokType::Identifier ) ) + if ( check( Tok_Identifier ) ) { name = parse_identifier(); Context.Scope->Name = name; @@ -727,9 +727,9 @@ Code parse_class_struct( TokType which, bool inplace_def = false ) } // TODO(Ed) : Make an AST_DerivedType, we'll store any arbitary derived type into there as a linear linked list of them. - if ( check( TokType::Assign_Classifer ) ) + if ( check( Tok_Assign_Classifer ) ) { - eat( TokType::Assign_Classifer ); + eat( Tok_Assign_Classifer ); // : if ( is_access_specifier(currtok) ) @@ -743,9 +743,9 @@ Code parse_class_struct( TokType which, bool inplace_def = false ) parent = def_type( to_str(parent_tok) ); // : - while ( check(TokType::Comma) ) + while ( check(Tok_Comma) ) { - eat( TokType::Comma ); + eat( Tok_Comma ); // : , if ( is_access_specifier(currtok) ) @@ -759,7 +759,7 @@ Code parse_class_struct( TokType which, bool inplace_def = false ) } } - if ( check( TokType::BraceCurly_Open ) ) + if ( check( Tok_BraceCurly_Open ) ) { body = parse_class_struct_body( which, name ); } @@ -769,15 +769,15 @@ Code parse_class_struct( TokType which, bool inplace_def = false ) if ( ! inplace_def ) { Token stmt_end = currtok; - eat( TokType::Statement_End ); + eat( Tok_Statement_End ); // : , ... { }; - if ( currtok_noskip.Type == TokType::Comment && currtok_noskip.Line == stmt_end.Line ) + if ( currtok_noskip.Type == Tok_Comment && currtok_noskip.Line == stmt_end.Line ) inline_cmt = parse_comment(); // : , ... { }; } - if ( which == TokType::Decl_Class ) + if ( which == Tok_Decl_Class ) result = def_class( to_str(name), { body, parent, access, attributes, mflags } ); else @@ -796,19 +796,19 @@ CodeBody parse_class_struct_body( TokType which, Token name ) using namespace ECode; push_scope(); - eat( TokType::BraceCurly_Open ); + eat( Tok_BraceCurly_Open ); // { CodeBody result = (CodeBody) make_code(); - if ( which == TokType::Decl_Class ) + if ( which == Tok_Decl_Class ) result->Type = Class_Body; else result->Type = Struct_Body; - while ( left && currtok_noskip.Type != TokType::BraceCurly_Close ) + while ( left && currtok_noskip.Type != Tok_BraceCurly_Close ) { Code member = Code_Invalid; CodeAttributes attributes = { nullptr }; @@ -818,94 +818,94 @@ CodeBody parse_class_struct_body( TokType which, Token name ) // Context.Scope->Start = currtok_noskip; - if ( currtok_noskip.Type == TokType::Preprocess_Hash ) - eat( TokType::Preprocess_Hash ); + if ( currtok_noskip.Type == Tok_Preprocess_Hash ) + eat( Tok_Preprocess_Hash ); switch ( currtok_noskip.Type ) { - case TokType::Statement_End: + case Tok_Statement_End: { // TODO(Ed): Convert this to a general warning procedure log_fmt("Dangling end statement found %S\n", to_string(currtok_noskip)); - eat( TokType::Statement_End ); + eat( Tok_Statement_End ); continue; } - case TokType::NewLine: + case Tok_NewLine: member = fmt_newline; - eat( TokType::NewLine ); + eat( Tok_NewLine ); break; - case TokType::Comment: + case Tok_Comment: member = parse_comment(); break; - case TokType::Access_Public: + case Tok_Access_Public: member = access_public; - eat( TokType::Access_Public ); - eat( TokType::Assign_Classifer ); + eat( Tok_Access_Public ); + eat( Tok_Assign_Classifer ); // public: break; - case TokType::Access_Protected: + case Tok_Access_Protected: member = access_protected; - eat( TokType::Access_Protected ); - eat( TokType::Assign_Classifer ); + eat( Tok_Access_Protected ); + eat( Tok_Assign_Classifer ); // protected: break; - case TokType::Access_Private: + case Tok_Access_Private: member = access_private; - eat( TokType::Access_Private ); - eat( TokType::Assign_Classifer ); + eat( Tok_Access_Private ); + eat( Tok_Assign_Classifer ); // private: break; - case TokType::Decl_Class: - member = parse_complicated_definition( TokType::Decl_Class ); + case Tok_Decl_Class: + member = parse_complicated_definition( Tok_Decl_Class ); // class break; - case TokType::Decl_Enum: - member = parse_complicated_definition( TokType::Decl_Enum ); + case Tok_Decl_Enum: + member = parse_complicated_definition( Tok_Decl_Enum ); // enum break; - case TokType::Decl_Friend: + case Tok_Decl_Friend: member = parse_friend(); // friend break; - case TokType::Decl_Operator: + case Tok_Decl_Operator: member = parse_operator_cast(); // operator () break; - case TokType::Decl_Struct: - member = parse_complicated_definition( TokType::Decl_Struct ); + case Tok_Decl_Struct: + member = parse_complicated_definition( Tok_Decl_Struct ); // struct break; - case TokType::Decl_Template: + case Tok_Decl_Template: member = parse_template(); // template< ... > break; - case TokType::Decl_Typedef: + case Tok_Decl_Typedef: member = parse_typedef(); // typedef break; - case TokType::Decl_Union: - member = parse_complicated_definition( TokType::Decl_Union ); + case Tok_Decl_Union: + member = parse_complicated_definition( Tok_Decl_Union ); // union break; - case TokType::Decl_Using: + case Tok_Decl_Using: member = parse_using(); // using break; - case TokType::Operator: + case Tok_Operator: if ( currtok.Text[0] != '~' ) { log_failure( "Operator token found in global body but not destructor unary negation\n%s", to_string(Context) ); @@ -916,60 +916,60 @@ CodeBody parse_class_struct_body( TokType which, Token name ) // ~() break; - case TokType::Preprocess_Define: + case Tok_Preprocess_Define: member = parse_define(); // #define break; - case TokType::Preprocess_Include: + case Tok_Preprocess_Include: member = parse_include(); // #include break; - case TokType::Preprocess_If: - case TokType::Preprocess_IfDef: - case TokType::Preprocess_IfNotDef: - case TokType::Preprocess_ElIf: + case Tok_Preprocess_If: + case Tok_Preprocess_IfDef: + case Tok_Preprocess_IfNotDef: + case Tok_Preprocess_ElIf: member = parse_preprocess_cond(); // # break; - case TokType::Preprocess_Else: + case Tok_Preprocess_Else: member = preprocess_else; - eat( TokType::Preprocess_Else ); + eat( Tok_Preprocess_Else ); // #else break; - case TokType::Preprocess_EndIf: + case Tok_Preprocess_EndIf: member = preprocess_endif; - eat( TokType::Preprocess_EndIf ); + eat( Tok_Preprocess_EndIf ); // #endif break; - case TokType::Preprocess_Macro: - member = parse_simple_preprocess( TokType::Preprocess_Macro ); + case Tok_Preprocess_Macro: + member = parse_simple_preprocess( Tok_Preprocess_Macro ); // break; - case TokType::Preprocess_Pragma: + case Tok_Preprocess_Pragma: member = parse_pragma(); // #pragma break; - case TokType::Preprocess_Unsupported: - member = parse_simple_preprocess( TokType::Preprocess_Unsupported ); + case Tok_Preprocess_Unsupported: + member = parse_simple_preprocess( Tok_Preprocess_Unsupported ); // # break; - case TokType::StaticAssert: + case Tok_StaticAssert: member = parse_static_assert(); // static_assert break; - case TokType::Attribute_Open: - case TokType::Decl_GNU_Attribute: - case TokType::Decl_MSVC_Attribute: - #define Entry( attribute, str ) case TokType::attribute: + case Tok_Attribute_Open: + case Tok_Decl_GNU_Attribute: + case Tok_Decl_MSVC_Attribute: + #define Entry( attribute, str ) case attribute: GEN_DEFINE_ATTRIBUTE_TOKENS #undef Entry { @@ -977,17 +977,17 @@ CodeBody parse_class_struct_body( TokType which, Token name ) // } //! Fallthrough intended - case TokType::Spec_Consteval: - case TokType::Spec_Constexpr: - case TokType::Spec_Constinit: - case TokType::Spec_Explicit: - case TokType::Spec_ForceInline: - case TokType::Spec_Inline: - case TokType::Spec_Mutable: - case TokType::Spec_NeverInline: - case TokType::Spec_Static: - case TokType::Spec_Volatile: - case TokType::Spec_Virtual: + case Tok_Spec_Consteval: + case Tok_Spec_Constexpr: + case Tok_Spec_Constinit: + case Tok_Spec_Explicit: + case Tok_Spec_ForceInline: + case Tok_Spec_Inline: + case Tok_Spec_Mutable: + case Tok_Spec_NeverInline: + case Tok_Spec_Static: + case Tok_Spec_Volatile: + case Tok_Spec_Virtual: { SpecifierT specs_found[16] { ESpecifier::NumSpecifiers }; s32 NumSpecifiers = 0; @@ -1059,14 +1059,14 @@ CodeBody parse_class_struct_body( TokType which, Token name ) attributes = more_attributes; } - if ( currtok.Type == TokType::Operator && currtok.Text[0] == '~' ) + if ( currtok.Type == Tok_Operator && currtok.Text[0] == '~' ) { member = parse_destructor( specifiers ); // ~() break; } - if ( currtok.Type == TokType::Decl_Operator ) + if ( currtok.Type == Tok_Decl_Operator ) { member = parse_operator_cast( specifiers ); // operator () @@ -1074,18 +1074,18 @@ CodeBody parse_class_struct_body( TokType which, Token name ) } } //! Fallthrough intentional - case TokType::Identifier: - case TokType::Spec_Const: - case TokType::Type_Unsigned: - case TokType::Type_Signed: - case TokType::Type_Short: - case TokType::Type_Long: - case TokType::Type_bool: - case TokType::Type_char: - case TokType::Type_int: - case TokType::Type_double: + case Tok_Identifier: + case Tok_Spec_Const: + case Tok_Type_Unsigned: + case Tok_Type_Signed: + case Tok_Type_Short: + case Tok_Type_Long: + case Tok_Type_bool: + case Tok_Type_char: + case Tok_Type_int: + case Tok_Type_double: { - if ( nexttok.Type == TokType::Capture_Start && name.Length && currtok.Type == TokType::Identifier ) + if ( nexttok.Type == Tok_Capture_Start && name.Length && currtok.Type == Tok_Identifier ) { if ( str_compare( name.Text, currtok.Text, name.Length ) == 0 ) { @@ -1105,7 +1105,7 @@ CodeBody parse_class_struct_body( TokType which, Token name ) default: Token untyped_tok = currtok; - while ( left && currtok.Type != TokType::BraceCurly_Close ) + while ( left && currtok.Type != Tok_BraceCurly_Close ) { untyped_tok.Length = ( (sptr)currtok.Text + currtok.Length ) - (sptr)untyped_tok.Text; eat( currtok.Type ); @@ -1126,7 +1126,7 @@ CodeBody parse_class_struct_body( TokType which, Token name ) append(result, member ); } - eat( TokType::BraceCurly_Close ); + eat( Tok_BraceCurly_Close ); // { } pop(& Context); return result; @@ -1143,7 +1143,7 @@ CodeComment parse_comment() result->Content = get_cached_string( to_str(currtok_noskip) ); result->Name = result->Content; // result->Token = currtok_noskip; - eat( TokType::Comment ); + eat( Tok_Comment ); pop(& Context); return result; @@ -1162,13 +1162,13 @@ Code parse_complicated_definition( TokType which ) s32 level = 0; for ( ; idx < num(tokens.Arr); idx++ ) { - if ( tokens.Arr[ idx ].Type == TokType::BraceCurly_Open ) + if ( tokens.Arr[ idx ].Type == Tok_BraceCurly_Open ) level++; - if ( tokens.Arr[ idx ].Type == TokType::BraceCurly_Close ) + if ( tokens.Arr[ idx ].Type == Tok_BraceCurly_Close ) level--; - if ( level == 0 && tokens.Arr[ idx ].Type == TokType::Statement_End ) + if ( level == 0 && tokens.Arr[ idx ].Type == Tok_Statement_End ) break; } @@ -1194,7 +1194,7 @@ Code parse_complicated_definition( TokType which ) spec = tokens.Arr[spec_idx]; } - if ( tokens.Arr[spec_idx].Type == TokType::Capture_End ) + if ( tokens.Arr[spec_idx].Type == Tok_Capture_End ) { // Forward declaration with trailing specifiers for a procedure tok = tokens.Arr[spec_idx]; @@ -1209,27 +1209,27 @@ Code parse_complicated_definition( TokType which ) pop(& Context); return InvalidCode; } - if ( tok.Type == TokType::Identifier ) + if ( tok.Type == Tok_Identifier ) { tok = tokens.Arr[ idx - 2 ]; - bool is_indirection = tok.Type == TokType::Ampersand || tok.Type == TokType::Star; + bool is_indirection = tok.Type == Tok_Ampersand || tok.Type == Tok_Star; bool ok_to_parse = false; - if ( tok.Type == TokType::BraceCurly_Close ) + if ( tok.Type == Tok_BraceCurly_Close ) { // Its an inplace definition // { ... } ; ok_to_parse = true; is_inplace = true; } - else if ( tok.Type == TokType::Identifier && tokens.Arr[ idx - 3 ].Type == which ) + else if ( tok.Type == Tok_Identifier && tokens.Arr[ idx - 3 ].Type == which ) { // Its a variable with type ID using namespace. // ; ok_to_parse = true; } - else if ( tok.Type == TokType::Assign_Classifer - && ( ( tokens.Arr[idx - 5].Type == which && tokens.Arr[idx - 4].Type == TokType::Decl_Class ) + else if ( tok.Type == Tok_Assign_Classifer + && ( ( tokens.Arr[idx - 5].Type == which && tokens.Arr[idx - 4].Type == Tok_Decl_Class ) || ( tokens.Arr[idx - 4].Type == which)) ) { @@ -1260,12 +1260,12 @@ Code parse_complicated_definition( TokType which ) pop(& Context); return result; } - else if ( tok.Type >= TokType::Type_Unsigned && tok.Type <= TokType::Type_MS_W64 ) + else if ( tok.Type >= Tok_Type_Unsigned && tok.Type <= Tok_Type_MS_W64 ) { tok = tokens.Arr[ idx - 2 ]; - if ( tok.Type != TokType::Assign_Classifer - || ( ( tokens.Arr[idx - 5].Type != which && tokens.Arr[idx - 4].Type != TokType::Decl_Class ) + if ( tok.Type != Tok_Assign_Classifer + || ( ( tokens.Arr[idx - 5].Type != which && tokens.Arr[idx - 4].Type != Tok_Decl_Class ) && ( tokens.Arr[idx - 4].Type != which)) ) { @@ -1281,7 +1281,7 @@ Code parse_complicated_definition( TokType which ) pop(& Context); return result; } - else if ( tok.Type == TokType::BraceCurly_Close ) + else if ( tok.Type == Tok_BraceCurly_Close ) { // Its a definition Code result = parse_forward_or_definition( which, is_inplace ); @@ -1289,7 +1289,7 @@ Code parse_complicated_definition( TokType which ) pop(& Context); return result; } - else if ( tok.Type == TokType::BraceSquare_Close ) + else if ( tok.Type == Tok_BraceSquare_Close ) { // Its an array definition Code result = parse_operator_function_or_variable( false, { nullptr }, { nullptr } ); @@ -1309,14 +1309,14 @@ internal inline CodeDefine parse_define() { push_scope(); - eat( TokType::Preprocess_Define ); + eat( Tok_Preprocess_Define ); // #define CodeDefine define = (CodeDefine) make_code(); define->Type = ECode::Preprocess_Define; - if ( ! check( TokType::Identifier ) ) + if ( ! check( Tok_Identifier ) ) { log_failure( "Error, expected identifier after #define\n%s", to_string(Context) ); pop(& Context); @@ -1325,10 +1325,10 @@ CodeDefine parse_define() Context.Scope->Name = currtok; define->Name = get_cached_string( to_str(currtok) ); - eat( TokType::Identifier ); + eat( Tok_Identifier ); // #define - if ( ! check( TokType::Preprocess_Content )) + if ( ! check( Tok_Preprocess_Content )) { log_failure( "Error, expected content after #define %s\n%s", define->Name, to_string(Context) ); pop(& Context); @@ -1338,7 +1338,7 @@ CodeDefine parse_define() if ( currtok.Length == 0 ) { define->Content = get_cached_string( to_str(currtok) ); - eat( TokType::Preprocess_Content ); + eat( Tok_Preprocess_Content ); // #define pop(& Context); @@ -1346,7 +1346,7 @@ CodeDefine parse_define() } define->Content = get_cached_string( strip_formatting( to_str(currtok), strip_formatting_dont_preserve_newlines ) ); - eat( TokType::Preprocess_Content ); + eat( Tok_Preprocess_Content ); // #define pop(& Context); @@ -1358,12 +1358,12 @@ Code parse_assignment_expression() { Code expr = { nullptr }; - eat( TokType::Operator ); + eat( Tok_Operator ); // = Token expr_tok = currtok; - if ( currtok.Type == TokType::Statement_End && currtok.Type != TokType::Comma ) + if ( currtok.Type == Tok_Statement_End && currtok.Type != Tok_Comma ) { log_failure( "Expected expression after assignment operator\n%s", to_string(Context) ); pop(& Context); @@ -1371,15 +1371,15 @@ Code parse_assignment_expression() } s32 level = 0; - while ( left && currtok.Type != TokType::Statement_End && (currtok.Type != TokType::Comma || level > 0) ) + while ( left && currtok.Type != Tok_Statement_End && (currtok.Type != Tok_Comma || level > 0) ) { - if (currtok.Type == TokType::BraceCurly_Open ) + if (currtok.Type == Tok_BraceCurly_Open ) level++; - if (currtok.Type == TokType::BraceCurly_Close ) + if (currtok.Type == Tok_BraceCurly_Close ) level--; - if (currtok.Type == TokType::Capture_Start) + if (currtok.Type == Tok_Capture_Start) level++; - else if (currtok.Type == TokType::Capture_End) + else if (currtok.Type == Tok_Capture_End) level--; eat( currtok.Type ); @@ -1398,19 +1398,19 @@ Code parse_forward_or_definition( TokType which, bool is_inplace ) switch ( which ) { - case TokType::Decl_Class: + case Tok_Decl_Class: result = parse_class( is_inplace ); return result; - case TokType::Decl_Enum: + case Tok_Decl_Enum: result = parse_enum( is_inplace ); return result; - case TokType::Decl_Struct: + case Tok_Decl_Struct: result = parse_struct( is_inplace ); return result; - case TokType::Decl_Union: + case Tok_Decl_Union: result = parse_union( is_inplace ); return result; @@ -1454,7 +1454,7 @@ CodeFn parse_function_after_name( CodeBody body = NullCode; CodeComment inline_cmt = NullCode; - if ( check( TokType::BraceCurly_Open ) ) + if ( check( Tok_BraceCurly_Open ) ) { body = parse_function_body(); if ( body == Code_Invalid ) @@ -1464,27 +1464,27 @@ CodeFn parse_function_after_name( } // ( ) { } } - else if ( check(TokType::Operator) && currtok.Text[0] == '=' ) + else if ( check(Tok_Operator) && currtok.Text[0] == '=' ) { - eat(TokType::Operator); + eat(Tok_Operator); append(specifiers, ESpecifier::Pure ); - eat( TokType::Number); + eat( Tok_Number); Token stmt_end = currtok; - eat( TokType::Statement_End ); + eat( Tok_Statement_End ); // ( ) = 0; - if ( currtok_noskip.Type == TokType::Comment && currtok_noskip.Line == stmt_end.Line ) + if ( currtok_noskip.Type == Tok_Comment && currtok_noskip.Line == stmt_end.Line ) inline_cmt = parse_comment(); // ( ) ; } else { Token stmt_end = currtok; - eat( TokType::Statement_End ); + eat( Tok_Statement_End ); // ( ) ; - if ( currtok_noskip.Type == TokType::Comment && currtok_noskip.Line == stmt_end.Line ) + if ( currtok_noskip.Type == Tok_Comment && currtok_noskip.Line == stmt_end.Line ) inline_cmt = parse_comment(); // ( ) ; } @@ -1548,7 +1548,7 @@ Code parse_function_body() using namespace ECode; push_scope(); - eat( TokType::BraceCurly_Open ); + eat( Tok_BraceCurly_Open ); CodeBody result = (CodeBody) make_code(); @@ -1558,12 +1558,12 @@ Code parse_function_body() Token start = currtok_noskip; s32 level = 0; - while ( left && ( currtok_noskip.Type != TokType::BraceCurly_Close || level > 0 ) ) + while ( left && ( currtok_noskip.Type != Tok_BraceCurly_Close || level > 0 ) ) { - if ( currtok_noskip.Type == TokType::BraceCurly_Open ) + if ( currtok_noskip.Type == Tok_BraceCurly_Open ) level++; - else if ( currtok_noskip.Type == TokType::BraceCurly_Close && level > 0 ) + else if ( currtok_noskip.Type == Tok_BraceCurly_Close && level > 0 ) level--; eat( currtok_noskip.Type ); @@ -1578,7 +1578,7 @@ Code parse_function_body() append( result, def_execution( { len, start.Text } ) ); } - eat( TokType::BraceCurly_Close ); + eat( Tok_BraceCurly_Close ); pop(& Context); return result; @@ -1595,14 +1595,14 @@ CodeBody parse_global_nspace( CodeT which ) return InvalidCode; if ( which != Global_Body ) - eat( TokType::BraceCurly_Open ); + eat( Tok_BraceCurly_Open ); // { CodeBody result = (CodeBody) make_code(); result->Type = which; - while ( left && currtok_noskip.Type != TokType::BraceCurly_Close ) + while ( left && currtok_noskip.Type != Tok_BraceCurly_Close ) { Code member = Code_Invalid; CodeAttributes attributes = { nullptr }; @@ -1612,39 +1612,39 @@ CodeBody parse_global_nspace( CodeT which ) // Context.Scope->Start = currtok_noskip; - if ( currtok_noskip.Type == TokType::Preprocess_Hash ) - eat( TokType::Preprocess_Hash ); + if ( currtok_noskip.Type == Tok_Preprocess_Hash ) + eat( Tok_Preprocess_Hash ); switch ( currtok_noskip.Type ) { - case TokType::Statement_End: + case Tok_Statement_End: { // TODO(Ed): Convert this to a general warning procedure log_fmt("Dangling end statement found %S\n", to_string(currtok_noskip)); - eat( TokType::Statement_End ); + eat( Tok_Statement_End ); continue; } - case TokType::NewLine: + case Tok_NewLine: // Empty lines are auto skipped by Tokens.current() member = fmt_newline; - eat( TokType::NewLine ); + eat( Tok_NewLine ); break; - case TokType::Comment: + case Tok_Comment: member = parse_comment(); break; - case TokType::Decl_Class: - member = parse_complicated_definition( TokType::Decl_Class ); + case Tok_Decl_Class: + member = parse_complicated_definition( Tok_Decl_Class ); // class break; - case TokType::Decl_Enum: - member = parse_complicated_definition( TokType::Decl_Enum ); + case Tok_Decl_Enum: + member = parse_complicated_definition( Tok_Decl_Enum ); // enum break; - case TokType::Decl_Extern_Linkage: + case Tok_Decl_Extern_Linkage: if ( which == Extern_Linkage_Body ) log_failure( "Nested extern linkage\n%s", to_string(Context) ); @@ -1652,87 +1652,87 @@ CodeBody parse_global_nspace( CodeT which ) // extern "..." { ... } break; - case TokType::Decl_Namespace: + case Tok_Decl_Namespace: member = parse_namespace(); // namespace { ... } break; - case TokType::Decl_Struct: - member = parse_complicated_definition( TokType::Decl_Struct ); + case Tok_Decl_Struct: + member = parse_complicated_definition( Tok_Decl_Struct ); // struct ... break; - case TokType::Decl_Template: + case Tok_Decl_Template: member = parse_template(); // template<...> ... break; - case TokType::Decl_Typedef: + case Tok_Decl_Typedef: member = parse_typedef(); // typedef ... break; - case TokType::Decl_Union: - member = parse_complicated_definition( TokType::Decl_Union ); + case Tok_Decl_Union: + member = parse_complicated_definition( Tok_Decl_Union ); // union ... break; - case TokType::Decl_Using: + case Tok_Decl_Using: member = parse_using(); // using ... break; - case TokType::Preprocess_Define: + case Tok_Preprocess_Define: member = parse_define(); // #define ... break; - case TokType::Preprocess_Include: + case Tok_Preprocess_Include: member = parse_include(); // #include ... break; - case TokType::Preprocess_If: - case TokType::Preprocess_IfDef: - case TokType::Preprocess_IfNotDef: - case TokType::Preprocess_ElIf: + case Tok_Preprocess_If: + case Tok_Preprocess_IfDef: + case Tok_Preprocess_IfNotDef: + case Tok_Preprocess_ElIf: member = parse_preprocess_cond(); // # ... break; - case TokType::Preprocess_Else: + case Tok_Preprocess_Else: member = preprocess_else; - eat( TokType::Preprocess_Else ); + eat( Tok_Preprocess_Else ); // #else break; - case TokType::Preprocess_EndIf: + case Tok_Preprocess_EndIf: member = preprocess_endif; - eat( TokType::Preprocess_EndIf ); + eat( Tok_Preprocess_EndIf ); // #endif break; - case TokType::Preprocess_Macro: - member = parse_simple_preprocess( TokType::Preprocess_Macro ); + case Tok_Preprocess_Macro: + member = parse_simple_preprocess( Tok_Preprocess_Macro ); // break; - case TokType::Preprocess_Pragma: + case Tok_Preprocess_Pragma: member = parse_pragma(); // #pragma ... break; - case TokType::Preprocess_Unsupported: - member = parse_simple_preprocess( TokType::Preprocess_Unsupported ); + case Tok_Preprocess_Unsupported: + member = parse_simple_preprocess( Tok_Preprocess_Unsupported ); // # ... break; - case TokType::StaticAssert: + case Tok_StaticAssert: member = parse_static_assert(); // static_assert( , ... ); break; - case TokType::Module_Export: + case Tok_Module_Export: if ( which == Export_Body ) log_failure( "Nested export declaration\n%s", to_string(Context) ); @@ -1740,16 +1740,16 @@ CodeBody parse_global_nspace( CodeT which ) // export { ... } break; - case TokType::Module_Import: + case Tok_Module_Import: { not_implemented( context ); // import ... } //! Fallthrough intentional - case TokType::Attribute_Open: - case TokType::Decl_GNU_Attribute: - case TokType::Decl_MSVC_Attribute: - #define Entry( attribute, str ) case TokType::attribute: + case Tok_Attribute_Open: + case Tok_Decl_GNU_Attribute: + case Tok_Decl_MSVC_Attribute: + #define Entry( attribute, str ) case attribute: GEN_DEFINE_ATTRIBUTE_TOKENS #undef Entry { @@ -1757,16 +1757,16 @@ CodeBody parse_global_nspace( CodeT which ) // } //! Fallthrough intentional - case TokType::Spec_Consteval: - case TokType::Spec_Constexpr: - case TokType::Spec_Constinit: - case TokType::Spec_Extern: - case TokType::Spec_ForceInline: - case TokType::Spec_Global: - case TokType::Spec_Inline: - case TokType::Spec_Internal_Linkage: - case TokType::Spec_NeverInline: - case TokType::Spec_Static: + case Tok_Spec_Consteval: + case Tok_Spec_Constexpr: + case Tok_Spec_Constinit: + case Tok_Spec_Extern: + case Tok_Spec_ForceInline: + case Tok_Spec_Global: + case Tok_Spec_Inline: + case Tok_Spec_Internal_Linkage: + case Tok_Spec_NeverInline: + case Tok_Spec_Static: { SpecifierT specs_found[16] { ESpecifier::NumSpecifiers }; s32 NumSpecifiers = 0; @@ -1823,16 +1823,16 @@ CodeBody parse_global_nspace( CodeT which ) // } //! Fallthrough intentional - case TokType::Identifier: - case TokType::Spec_Const: - case TokType::Type_Long: - case TokType::Type_Short: - case TokType::Type_Signed: - case TokType::Type_Unsigned: - case TokType::Type_bool: - case TokType::Type_char: - case TokType::Type_double: - case TokType::Type_int: + case Tok_Identifier: + case Tok_Spec_Const: + case Tok_Type_Long: + case Tok_Type_Short: + case Tok_Type_Signed: + case Tok_Type_Unsigned: + case Tok_Type_bool: + case Tok_Type_char: + case Tok_Type_double: + case Tok_Type_int: { Code constructor_destructor = parse_global_nspace_constructor_destructor( specifiers ); // Possible constructor implemented at global file scope. @@ -1849,17 +1849,17 @@ CodeBody parse_global_nspace( CodeT which ) { Token tok = Context.Tokens.Arr[ idx ]; - if ( tok.Type == TokType::Identifier ) + if ( tok.Type == Tok_Identifier ) { idx++; tok = Context.Tokens.Arr[ idx ]; - if ( tok.Type == TokType::Access_StaticSymbol ) + if ( tok.Type == Tok_Access_StaticSymbol ) continue; break; } - if ( tok.Type == TokType::Decl_Operator ) + if ( tok.Type == Tok_Decl_Operator ) found_operator_cast_outside_class_implmentation = true; break; @@ -1889,7 +1889,7 @@ CodeBody parse_global_nspace( CodeT which ) } if ( which != Global_Body ) - eat( TokType::BraceCurly_Close ); + eat( Tok_BraceCurly_Close ); // { } pop(& Context); @@ -1931,10 +1931,10 @@ Code parse_global_nspace_constructor_destructor( CodeSpecifiers specifiers ) if (nav.Text[ 0 ] == '>') -- template_level; - if (nav.Type == TokType::Operator && nav.Text[1] == '>') + if (nav.Type == Tok_Operator && nav.Text[1] == '>') -- template_level; - if ( nav.Type == ETokType::Capture_Start) + if ( nav.Type == Tok_Capture_Start) { if (template_level != 0 ) ++ capture_level; @@ -1942,12 +1942,12 @@ Code parse_global_nspace_constructor_destructor( CodeSpecifiers specifiers ) break; } - if ( template_level != 0 && nav.Type == ETokType::Capture_End) + if ( template_level != 0 && nav.Type == Tok_Capture_End) -- capture_level; } } - if ( nav.Type == TokType::Capture_Start ) + if ( nav.Type == Tok_Capture_Start ) break; } @@ -1955,7 +1955,7 @@ Code parse_global_nspace_constructor_destructor( CodeSpecifiers specifiers ) Token tok_right = tokens.Arr[idx]; Token tok_left = NullToken; - if (tok_right.Type != TokType::Identifier) + if (tok_right.Type != Tok_Identifier) { // We're not dealing with a constructor if there is no identifier right before the opening of a parameter's scope. return result; @@ -1966,14 +1966,14 @@ Code parse_global_nspace_constructor_destructor( CodeSpecifiers specifiers ) // ... bool possible_destructor = false; - if ( tok_left.Type == TokType::Operator && tok_left.Text[0] == '~') + if ( tok_left.Type == Tok_Operator && tok_left.Text[0] == '~') { possible_destructor = true; -- idx; tok_left = tokens.Arr[idx]; } - if ( tok_left.Type != TokType::Access_StaticSymbol ) + if ( tok_left.Type != Tok_Access_StaticSymbol ) return result; -- idx; @@ -1990,16 +1990,16 @@ Code parse_global_nspace_constructor_destructor( CodeSpecifiers specifiers ) if (tok_left.Text[ 0 ] == '>') -- template_level; - if (tok_left.Type == TokType::Operator && tok_left.Text[1] == '>') + if (tok_left.Type == Tok_Operator && tok_left.Text[1] == '>') -- template_level; - if ( template_level != 0 && tok_left.Type == ETokType::Capture_Start) + if ( template_level != 0 && tok_left.Type == Tok_Capture_Start) ++ capture_level; - if ( template_level != 0 && tok_left.Type == ETokType::Capture_End) + if ( template_level != 0 && tok_left.Type == Tok_Capture_End) -- capture_level; - if ( capture_level == 0 && template_level == 0 && tok_left.Type == TokType::Identifier ) + if ( capture_level == 0 && template_level == 0 && tok_left.Type == Tok_Identifier ) break; -- idx; @@ -2007,7 +2007,7 @@ Code parse_global_nspace_constructor_destructor( CodeSpecifiers specifiers ) } bool is_same = str_compare( tok_right.Text, tok_left.Text, tok_right.Length ) == 0; - if (tok_left.Type == TokType::Identifier && is_same) + if (tok_left.Type == Tok_Identifier && is_same) { // We have found the pattern we desired if (possible_destructor) @@ -2034,25 +2034,25 @@ Token parse_identifier( bool* possible_member_function ) Token name = currtok; Context.Scope->Name = name; - eat( TokType::Identifier ); + eat( Tok_Identifier ); // parse_template_args( name ); //