mirror of
https://github.com/Ed94/gencpp.git
synced 2024-12-22 15:54:45 -08:00
Got rid of the temp compoonent files, they are now generated via bootstrapping.
This isn't the last step though everything in the main project directory that isn't md files needs to be generated only. Can't do that till testing is robust enough...
This commit is contained in:
parent
6d85dd8fe8
commit
a42e241afb
@ -145,6 +145,34 @@ int gen_main()
|
||||
header.print_fmt( "GEN_NS_END\n\n" );
|
||||
header.print( pop_ignores );
|
||||
header.write();
|
||||
|
||||
Builder
|
||||
header_ecode = Builder::open( "components/gen/ecode.hpp" );
|
||||
header_ecode.print_fmt( generation_notice );
|
||||
header_ecode.print( pragma_once );
|
||||
header_ecode.print( ecode );
|
||||
header_ecode.write();
|
||||
|
||||
Builder
|
||||
header_eoperator = Builder::open( "components/gen/eoperator.hpp" );
|
||||
header_eoperator.print_fmt( generation_notice );
|
||||
header_eoperator.print( pragma_once );
|
||||
header_eoperator.print( eoperator );
|
||||
header_eoperator.write();
|
||||
|
||||
Builder
|
||||
header_especifier = Builder::open( "components/gen/especifier.hpp" );
|
||||
header_especifier.print_fmt( generation_notice );
|
||||
header_especifier.print( pragma_once );
|
||||
header_especifier.print( especifier );
|
||||
header_especifier.write();
|
||||
|
||||
Builder
|
||||
header_ast_inlines = Builder::open( "components/gen/ast_inlines.hpp" );
|
||||
header_ast_inlines.print_fmt( generation_notice );
|
||||
header_ast_inlines.print( pragma_once );
|
||||
header_ast_inlines.print( ast_inlines );
|
||||
header_ast_inlines.write();
|
||||
}
|
||||
|
||||
// gen.cpp
|
||||
@ -158,8 +186,8 @@ int gen_main()
|
||||
Code parsing = scan_file( "components/interface.parsing.cpp" );
|
||||
Code untyped = scan_file( "components/interface.untyped.cpp" );
|
||||
|
||||
CodeBody etoktype = gen_etoktype( "enums/ETokType.csv", "enums/AttributeTokens.csv" );
|
||||
CodeNS parser_nspace = def_namespace( name(Parser), def_namespace_body( args(etoktype)) );
|
||||
CodeBody etoktype = gen_etoktype( "enums/ETokType.csv", "enums/AttributeTokens.csv" );
|
||||
CodeNS nspaced_etoktype = def_namespace( name(Parser), def_namespace_body( args(etoktype)) );
|
||||
|
||||
Builder
|
||||
src = Builder::open( "gen/gen.cpp" );
|
||||
@ -179,7 +207,7 @@ int gen_main()
|
||||
src.print( interface );
|
||||
src.print( upfront );
|
||||
src.print_fmt( "#pragma region Parsing\n\n" );
|
||||
src.print( parser_nspace );
|
||||
src.print( nspaced_etoktype );
|
||||
src.print( parsing );
|
||||
src.print( untyped );
|
||||
src.print_fmt( "#pragma endregion Parsing\n\n" );
|
||||
@ -188,11 +216,18 @@ int gen_main()
|
||||
src.print_fmt( "GEN_NS_END\n\n");
|
||||
src.print( pop_ignores );
|
||||
src.write();
|
||||
|
||||
Builder
|
||||
src_etoktype = Builder::open( "components/gen/etoktype.cpp" );
|
||||
src_etoktype.print_fmt( generation_notice );
|
||||
src_etoktype.print( pragma_once );
|
||||
src_etoktype.print( nspaced_etoktype );
|
||||
src_etoktype.write();
|
||||
}
|
||||
|
||||
// gen_builder.hpp
|
||||
{
|
||||
Code builder = scan_file( "auxillary/builder.hpp", DontSkipInitialDirectives );
|
||||
Code builder = scan_file( "auxillary/builder.hpp" );
|
||||
|
||||
Builder
|
||||
header = Builder::open( "gen/gen.builder.hpp" );
|
||||
@ -207,7 +242,7 @@ int gen_main()
|
||||
|
||||
// gen_builder.cpp
|
||||
{
|
||||
Code builder = scan_file( "auxillary/builder.cpp", DontSkipInitialDirectives );
|
||||
Code builder = scan_file( "auxillary/builder.cpp" );
|
||||
|
||||
Builder
|
||||
src = Builder::open( "gen/gen.builder.cpp" );
|
||||
@ -222,7 +257,7 @@ int gen_main()
|
||||
// gen_scanner.hpp
|
||||
{
|
||||
Code parsing = scan_file( "dependencies/parsing.hpp" );
|
||||
Code scanner = scan_file( "auxillary/scanner.hpp", DontSkipInitialDirectives );
|
||||
Code scanner = scan_file( "auxillary/scanner.hpp" );
|
||||
|
||||
Builder
|
||||
header = Builder::open( "gen/gen.scanner.hpp" );
|
||||
@ -239,7 +274,7 @@ int gen_main()
|
||||
// gen_scanner.cpp
|
||||
{
|
||||
Code parsing = scan_file( "dependencies/parsing.cpp" );
|
||||
Code scanner = scan_file( "auxillary/scanner.cpp", DontSkipInitialDirectives );
|
||||
Code scanner = scan_file( "auxillary/scanner.cpp" );
|
||||
|
||||
Builder
|
||||
src = Builder::open( "gen/gen.scanner.cpp" );
|
||||
|
@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
#include "types.hpp"
|
||||
#include "temp/ecode.hpp"
|
||||
#include "temp/eoperator.hpp"
|
||||
#include "temp/especifier.hpp"
|
||||
#include "gen/ecode.hpp"
|
||||
#include "gen/eoperator.hpp"
|
||||
#include "gen/especifier.hpp"
|
||||
|
||||
struct AST;
|
||||
struct AST_Body;
|
||||
|
3012
project/components/gen/ast_inlines.hpp
Normal file
3012
project/components/gen/ast_inlines.hpp
Normal file
File diff suppressed because it is too large
Load Diff
141
project/components/gen/ecode.hpp
Normal file
141
project/components/gen/ecode.hpp
Normal file
@ -0,0 +1,141 @@
|
||||
// This file was generated automatially by gen.bootstrap.cpp (See: https://github.com/Ed94/gencpp)
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace ECode
|
||||
{
|
||||
enum Type : u32
|
||||
{
|
||||
Invalid,
|
||||
Untyped,
|
||||
NewLine,
|
||||
Comment,
|
||||
Access_Private,
|
||||
Access_Protected,
|
||||
Access_Public,
|
||||
PlatformAttributes,
|
||||
Class,
|
||||
Class_Fwd,
|
||||
Class_Body,
|
||||
Constructor,
|
||||
Constructor_Fwd,
|
||||
Destructor,
|
||||
Destructor_Fwd,
|
||||
Enum,
|
||||
Enum_Fwd,
|
||||
Enum_Body,
|
||||
Enum_Class,
|
||||
Enum_Class_Fwd,
|
||||
Execution,
|
||||
Export_Body,
|
||||
Extern_Linkage,
|
||||
Extern_Linkage_Body,
|
||||
Friend,
|
||||
Function,
|
||||
Function_Fwd,
|
||||
Function_Body,
|
||||
Global_Body,
|
||||
Module,
|
||||
Namespace,
|
||||
Namespace_Body,
|
||||
Operator,
|
||||
Operator_Fwd,
|
||||
Operator_Member,
|
||||
Operator_Member_Fwd,
|
||||
Operator_Cast,
|
||||
Operator_Cast_Fwd,
|
||||
Parameters,
|
||||
Preprocess_Define,
|
||||
Preprocess_Include,
|
||||
Preprocess_If,
|
||||
Preprocess_IfDef,
|
||||
Preprocess_IfNotDef,
|
||||
Preprocess_ElIf,
|
||||
Preprocess_Else,
|
||||
Preprocess_EndIf,
|
||||
Preprocess_Pragma,
|
||||
Specifiers,
|
||||
Struct,
|
||||
Struct_Fwd,
|
||||
Struct_Body,
|
||||
Template,
|
||||
Typedef,
|
||||
Typename,
|
||||
Union,
|
||||
Union_Body,
|
||||
Using,
|
||||
Using_Namespace,
|
||||
Variable,
|
||||
NumTypes
|
||||
};
|
||||
|
||||
StrC to_str( Type type )
|
||||
{
|
||||
local_persist StrC lookup[] {
|
||||
{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_Body" ), "Union_Body" },
|
||||
{ sizeof( "Using" ), "Using" },
|
||||
{ sizeof( "Using_Namespace" ), "Using_Namespace" },
|
||||
{ sizeof( "Variable" ), "Variable" },
|
||||
};
|
||||
return lookup[ type ];
|
||||
}
|
||||
|
||||
} // namespace ECode
|
||||
|
||||
using CodeT = ECode::Type;
|
107
project/components/gen/eoperator.hpp
Normal file
107
project/components/gen/eoperator.hpp
Normal file
@ -0,0 +1,107 @@
|
||||
// This file was generated automatially by gen.bootstrap.cpp (See: https://github.com/Ed94/gencpp)
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace EOperator
|
||||
{
|
||||
enum Type : u32
|
||||
{
|
||||
Invalid,
|
||||
Assign,
|
||||
Assign_Add,
|
||||
Assign_Subtract,
|
||||
Assign_Multiply,
|
||||
Assign_Divide,
|
||||
Assign_Modulo,
|
||||
Assign_BAnd,
|
||||
Assign_BOr,
|
||||
Assign_BXOr,
|
||||
Assign_LShift,
|
||||
Assign_RShift,
|
||||
Increment,
|
||||
Decrement,
|
||||
Unary_Plus,
|
||||
Unary_Minus,
|
||||
UnaryNot,
|
||||
Add,
|
||||
Subtract,
|
||||
Multiply,
|
||||
Divide,
|
||||
Modulo,
|
||||
BNot,
|
||||
BAnd,
|
||||
BOr,
|
||||
BXOr,
|
||||
LShift,
|
||||
RShift,
|
||||
LAnd,
|
||||
LOr,
|
||||
LEqual,
|
||||
LNot,
|
||||
Lesser,
|
||||
Greater,
|
||||
LesserEqual,
|
||||
GreaterEqual,
|
||||
Subscript,
|
||||
Indirection,
|
||||
AddressOf,
|
||||
MemberOfPointer,
|
||||
PtrToMemOfPtr,
|
||||
FunctionCall,
|
||||
Comma,
|
||||
NumOps
|
||||
};
|
||||
|
||||
StrC to_str( Type op )
|
||||
{
|
||||
local_persist StrC lookup[] {
|
||||
{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( "," ), "," },
|
||||
};
|
||||
return lookup[ op ];
|
||||
}
|
||||
|
||||
} // namespace EOperator
|
||||
|
||||
using OperatorT = EOperator::Type;
|
93
project/components/gen/especifier.hpp
Normal file
93
project/components/gen/especifier.hpp
Normal file
@ -0,0 +1,93 @@
|
||||
// This file was generated automatially by gen.bootstrap.cpp (See: https://github.com/Ed94/gencpp)
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace ESpecifier
|
||||
{
|
||||
enum Type : u32
|
||||
{
|
||||
Invalid,
|
||||
Consteval,
|
||||
Constexpr,
|
||||
Constinit,
|
||||
Explicit,
|
||||
External_Linkage,
|
||||
ForceInline,
|
||||
Global,
|
||||
Inline,
|
||||
Internal_Linkage,
|
||||
Local_Persist,
|
||||
Mutable,
|
||||
NeverInline,
|
||||
Ptr,
|
||||
Ref,
|
||||
Register,
|
||||
RValue,
|
||||
Static,
|
||||
Thread_Local,
|
||||
Volatile,
|
||||
Virtual,
|
||||
Const,
|
||||
Final,
|
||||
Override,
|
||||
Pure,
|
||||
NumSpecifiers
|
||||
};
|
||||
|
||||
bool is_trailing( Type specifier )
|
||||
{
|
||||
return specifier > Virtual;
|
||||
}
|
||||
|
||||
StrC to_str( Type type )
|
||||
{
|
||||
local_persist StrC lookup[] {
|
||||
{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( "volatile" ), "volatile" },
|
||||
{ sizeof( "virtual" ), "virtual" },
|
||||
{ sizeof( "const" ), "const" },
|
||||
{ sizeof( "final" ), "final" },
|
||||
{ sizeof( "override" ), "override" },
|
||||
{ sizeof( "= 0" ), "= 0" },
|
||||
};
|
||||
return lookup[ type ];
|
||||
}
|
||||
|
||||
Type to_type( StrC str )
|
||||
{
|
||||
local_persist u32 keymap[ NumSpecifiers ];
|
||||
do_once_start for ( u32 index = 0; index < NumSpecifiers; 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 < NumSpecifiers; index++ )
|
||||
{
|
||||
if ( keymap[ index ] == hash )
|
||||
return ( Type )index;
|
||||
}
|
||||
return Invalid;
|
||||
}
|
||||
|
||||
} // namespace ESpecifier
|
||||
|
||||
using SpecifierT = ESpecifier::Type;
|
234
project/components/gen/etoktype.cpp
Normal file
234
project/components/gen/etoktype.cpp
Normal file
@ -0,0 +1,234 @@
|
||||
// This file was generated automatially by gen.bootstrap.cpp (See: https://github.com/Ed94/gencpp)
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace Parser
|
||||
{
|
||||
namespace ETokType
|
||||
{
|
||||
#define GEN_DEFINE_ATTRIBUTE_TOKENS Entry( API_Export, GEN_API_Export_Code ) Entry( API_Import, GEN_API_Import_Code )
|
||||
|
||||
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_Unsigned,
|
||||
Type_Signed,
|
||||
Type_Short,
|
||||
Type_Long,
|
||||
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,
|
||||
API_Export,
|
||||
API_Import,
|
||||
NumTokens
|
||||
};
|
||||
|
||||
StrC to_str( Type type )
|
||||
{
|
||||
local_persist StrC lookup[] {
|
||||
{sizeof( "__invalid__" ), "__invalid__" },
|
||||
{ sizeof( "private" ), "private" },
|
||||
{ sizeof( "protected" ), "protected" },
|
||||
{ sizeof( "public" ), "public" },
|
||||
{ sizeof( "." ), "." },
|
||||
{ sizeof( "::" ), "::" },
|
||||
{ sizeof( "&" ), "&" },
|
||||
{ sizeof( "&&" ), "&&" },
|
||||
{ sizeof( ":" ), ":" },
|
||||
{ sizeof( "[[" ), "[[" },
|
||||
{ sizeof( "]]" ), "]]" },
|
||||
{ sizeof( "{" ), "{" },
|
||||
{ sizeof( "}" ), "}" },
|
||||
{ sizeof( "[" ), "[" },
|
||||
{ sizeof( "]" ), "]" },
|
||||
{ sizeof( "(" ), "(" },
|
||||
{ sizeof( ")" ), ")" },
|
||||
{ sizeof( "__comemnt__" ), "__comemnt__" },
|
||||
{ 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( "unsigned" ), "unsigned" },
|
||||
{ sizeof( "signed" ), "signed" },
|
||||
{ sizeof( "short" ), "short" },
|
||||
{ sizeof( "long" ), "long" },
|
||||
{ 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 ];
|
||||
}
|
||||
|
||||
Type to_type( StrC str )
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
} // namespace ETokType
|
||||
|
||||
using TokType = ETokType::Type;
|
||||
|
||||
} // namespace Parser
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include "inlines.hpp"
|
||||
#include "temp/ast_inlines.hpp"
|
||||
#include "gen/ast_inlines.hpp"
|
||||
|
||||
#pragma region Constants
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include "temp/etoktype.cpp"
|
||||
#include "gen/etoktype.cpp"
|
||||
#include "interface.upfront.cpp"
|
||||
|
||||
namespace Parser
|
||||
|
@ -1,8 +0,0 @@
|
||||
# Temporary Code
|
||||
|
||||
These are heavy macro code used throughout the library thats intended to be replaced with codegen done with the library itself.
|
||||
|
||||
The reason for this is to minimize macro generation to only trivial cases.
|
||||
This makes the library more verbose but makes it easier to debug which is of higher priority.
|
||||
|
||||
Any sort of verbosity cost will be mitigated with better docs and heavy usage of pragma regions.
|
@ -1,232 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// This is the non-bootstraped version of the Common AST Implementation. This will be obsolete once bootstrap is stress tested.
|
||||
|
||||
#pragma region AST Common
|
||||
|
||||
#define Define_CodeImpl( Typename ) \
|
||||
char const* Typename::debug_str() \
|
||||
{ \
|
||||
if ( ast == nullptr ) \
|
||||
return "Code::debug_str: AST is null!"; \
|
||||
\
|
||||
return rcast(AST*, ast)->debug_str(); \
|
||||
} \
|
||||
Code Typename::duplicate() \
|
||||
{ \
|
||||
if ( ast == nullptr ) \
|
||||
{ \
|
||||
log_failure("Code::duplicate: Cannot duplicate code, AST is null!"); \
|
||||
return Code::Invalid; \
|
||||
} \
|
||||
\
|
||||
return { rcast(AST*, ast)->duplicate() }; \
|
||||
} \
|
||||
bool Typename::is_equal( Code other ) \
|
||||
{ \
|
||||
if ( ast == nullptr || other.ast == nullptr ) \
|
||||
{ \
|
||||
log_failure("Code::is_equal: Cannot compare code, AST is null!"); \
|
||||
return false; \
|
||||
} \
|
||||
\
|
||||
return rcast(AST*, ast)->is_equal( other.ast ); \
|
||||
} \
|
||||
bool Typename::is_valid() \
|
||||
{ \
|
||||
return (AST*) ast != nullptr && rcast( AST*, ast)->Type != CodeT::Invalid; \
|
||||
} \
|
||||
void Typename::set_global() \
|
||||
{ \
|
||||
if ( ast == nullptr ) \
|
||||
{ \
|
||||
log_failure("Code::set_global: Cannot set code as global, AST is null!"); \
|
||||
return; \
|
||||
} \
|
||||
\
|
||||
rcast(AST*, ast)->Parent = Code::Global.ast; \
|
||||
} \
|
||||
String Typename::to_string() \
|
||||
{ \
|
||||
if ( ast == nullptr ) \
|
||||
{ \
|
||||
log_failure("Code::to_string: Cannot convert code to string, AST is null!"); \
|
||||
return { nullptr }; \
|
||||
} \
|
||||
\
|
||||
return rcast(AST*, ast)->to_string(); \
|
||||
} \
|
||||
Typename& Typename::operator =( Code other ) \
|
||||
{ \
|
||||
if ( other.ast && other->Parent ) \
|
||||
{ \
|
||||
ast = rcast( decltype(ast), other.ast->duplicate() ); \
|
||||
rcast( AST*, ast)->Parent = nullptr; \
|
||||
} \
|
||||
\
|
||||
ast = rcast( decltype(ast), other.ast ); \
|
||||
return *this; \
|
||||
} \
|
||||
bool Typename::operator ==( Code other ) \
|
||||
{ \
|
||||
return (AST*) ast == other.ast; \
|
||||
} \
|
||||
bool Typename::operator !=( Code other ) \
|
||||
{ \
|
||||
return (AST*) ast != other.ast; \
|
||||
} \
|
||||
Typename::operator bool() \
|
||||
{ \
|
||||
return ast != nullptr; \
|
||||
}
|
||||
|
||||
#define Define_CodeType_Impl( Typename ) \
|
||||
AST* Code##Typename::raw() \
|
||||
{ \
|
||||
return rcast( AST*, ast ); \
|
||||
} \
|
||||
Code##Typename::operator Code() \
|
||||
{ \
|
||||
return *rcast( Code*, this ); \
|
||||
} \
|
||||
AST_##Typename* Code##Typename::operator->() \
|
||||
{ \
|
||||
if ( ast == nullptr ) \
|
||||
{ \
|
||||
log_failure( "Attempt to dereference a nullptr!" ); \
|
||||
return nullptr; \
|
||||
} \
|
||||
return ast; \
|
||||
} \
|
||||
|
||||
Define_CodeImpl( Code );
|
||||
Define_CodeImpl( CodeBody );
|
||||
Define_CodeImpl( CodeAttributes );
|
||||
Define_CodeImpl( CodeComment );
|
||||
Define_CodeImpl( CodeClass );
|
||||
Define_CodeImpl( CodeConstructor );
|
||||
Define_CodeImpl( CodeDefine );
|
||||
Define_CodeImpl( CodeDestructor );
|
||||
Define_CodeImpl( CodeEnum );
|
||||
Define_CodeImpl( CodeExec );
|
||||
Define_CodeImpl( CodeExtern );
|
||||
Define_CodeImpl( CodeInclude );
|
||||
Define_CodeImpl( CodeFriend );
|
||||
Define_CodeImpl( CodeFn );
|
||||
Define_CodeImpl( CodeModule );
|
||||
Define_CodeImpl( CodeNS );
|
||||
Define_CodeImpl( CodeOperator );
|
||||
Define_CodeImpl( CodeOpCast );
|
||||
Define_CodeImpl( CodeParam );
|
||||
Define_CodeImpl( CodePragma );
|
||||
Define_CodeImpl( CodePreprocessCond );
|
||||
Define_CodeImpl( CodeSpecifiers );
|
||||
Define_CodeImpl( CodeStruct );
|
||||
Define_CodeImpl( CodeTemplate );
|
||||
Define_CodeImpl( CodeType );
|
||||
Define_CodeImpl( CodeTypedef );
|
||||
Define_CodeImpl( CodeUnion );
|
||||
Define_CodeImpl( CodeUsing );
|
||||
Define_CodeImpl( CodeVar );
|
||||
|
||||
Define_CodeType_Impl( Attributes );
|
||||
Define_CodeType_Impl( Comment );
|
||||
Define_CodeType_Impl( Constructor );
|
||||
Define_CodeType_Impl( Define );
|
||||
Define_CodeType_Impl( Destructor );
|
||||
Define_CodeType_Impl( Enum );
|
||||
Define_CodeType_Impl( Exec );
|
||||
Define_CodeType_Impl( Extern );
|
||||
Define_CodeType_Impl( Include );
|
||||
Define_CodeType_Impl( Friend );
|
||||
Define_CodeType_Impl( Fn );
|
||||
Define_CodeType_Impl( Module );
|
||||
Define_CodeType_Impl( NS );
|
||||
Define_CodeType_Impl( Operator );
|
||||
Define_CodeType_Impl( OpCast );
|
||||
Define_CodeType_Impl( Pragma );
|
||||
Define_CodeType_Impl( PreprocessCond );
|
||||
Define_CodeType_Impl( Template );
|
||||
Define_CodeType_Impl( Type );
|
||||
Define_CodeType_Impl( Typedef );
|
||||
Define_CodeType_Impl( Union );
|
||||
Define_CodeType_Impl( Using );
|
||||
Define_CodeType_Impl( Var );
|
||||
|
||||
#undef Define_CodeImpl
|
||||
#undef Define_CodeType_Impl
|
||||
|
||||
#define Define_AST_Cast( typename ) \
|
||||
AST::operator Code ## typename() \
|
||||
{ \
|
||||
return { rcast( AST_ ## typename*, this ) }; \
|
||||
}
|
||||
|
||||
Define_AST_Cast( Body );
|
||||
Define_AST_Cast( Attributes );
|
||||
Define_AST_Cast( Comment );
|
||||
Define_AST_Cast( Constructor );
|
||||
Define_AST_Cast( Class );
|
||||
Define_AST_Cast( Define );
|
||||
Define_AST_Cast( Destructor );
|
||||
Define_AST_Cast( Enum );
|
||||
Define_AST_Cast( Exec );
|
||||
Define_AST_Cast( Extern );
|
||||
Define_AST_Cast( Include );
|
||||
Define_AST_Cast( Friend );
|
||||
Define_AST_Cast( Fn );
|
||||
Define_AST_Cast( Module );
|
||||
Define_AST_Cast( NS );
|
||||
Define_AST_Cast( Operator );
|
||||
Define_AST_Cast( OpCast );
|
||||
Define_AST_Cast( Param );
|
||||
Define_AST_Cast( Pragma );
|
||||
Define_AST_Cast( PreprocessCond );
|
||||
Define_AST_Cast( Struct );
|
||||
Define_AST_Cast( Specifiers );
|
||||
Define_AST_Cast( Template );
|
||||
Define_AST_Cast( Type );
|
||||
Define_AST_Cast( Typedef );
|
||||
Define_AST_Cast( Union );
|
||||
Define_AST_Cast( Using );
|
||||
Define_AST_Cast( Var );
|
||||
#undef Define_AST_Cast
|
||||
|
||||
#define Define_CodeCast( type ) \
|
||||
Code::operator Code ## type() const \
|
||||
{ \
|
||||
return { (AST_ ## type*) ast }; \
|
||||
}
|
||||
|
||||
Define_CodeCast( Attributes );
|
||||
Define_CodeCast( Comment );
|
||||
Define_CodeCast( Constructor );
|
||||
Define_CodeCast( Class );
|
||||
Define_CodeCast( Define );
|
||||
Define_CodeCast( Destructor );
|
||||
Define_CodeCast( Exec );
|
||||
Define_CodeCast( Enum );
|
||||
Define_CodeCast( Extern );
|
||||
Define_CodeCast( Include );
|
||||
Define_CodeCast( Friend );
|
||||
Define_CodeCast( Fn );
|
||||
Define_CodeCast( Module );
|
||||
Define_CodeCast( NS );
|
||||
Define_CodeCast( Operator );
|
||||
Define_CodeCast( OpCast );
|
||||
Define_CodeCast( Param );
|
||||
Define_CodeCast( Pragma );
|
||||
Define_CodeCast( PreprocessCond );
|
||||
Define_CodeCast( Specifiers );
|
||||
Define_CodeCast( Struct );
|
||||
Define_CodeCast( Template );
|
||||
Define_CodeCast( Type );
|
||||
Define_CodeCast( Typedef );
|
||||
Define_CodeCast( Union );
|
||||
Define_CodeCast( Using );
|
||||
Define_CodeCast( Var );
|
||||
Define_CodeCast( Body);
|
||||
#undef Define_CodeCast
|
||||
|
||||
#pragma endregion AST Common
|
||||
|
@ -1,95 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// This is the non-bootstraped version of the ECode. This will be obsolete once bootstrap is stress tested.
|
||||
|
||||
namespace ECode
|
||||
{
|
||||
# define Define_Types \
|
||||
Entry( Invalid ) \
|
||||
Entry( Untyped ) \
|
||||
Entry( NewLine ) \
|
||||
Entry( Comment ) \
|
||||
Entry( Access_Private ) \
|
||||
Entry( Access_Protected ) \
|
||||
Entry( Access_Public ) \
|
||||
Entry( PlatformAttributes ) \
|
||||
Entry( Class ) \
|
||||
Entry( Class_Fwd ) \
|
||||
Entry( Class_Body ) \
|
||||
Entry( Constructor ) \
|
||||
Entry( Constructor_Fwd ) \
|
||||
Entry( Destructor ) \
|
||||
Entry( Destructor_Fwd ) \
|
||||
Entry( Enum ) \
|
||||
Entry( Enum_Fwd ) \
|
||||
Entry( Enum_Body ) \
|
||||
Entry( Enum_Class ) \
|
||||
Entry( Enum_Class_Fwd ) \
|
||||
Entry( Execution ) \
|
||||
Entry( Export_Body ) \
|
||||
Entry( Extern_Linkage ) \
|
||||
Entry( Extern_Linkage_Body ) \
|
||||
Entry( Friend ) \
|
||||
Entry( Function ) \
|
||||
Entry( Function_Fwd ) \
|
||||
Entry( Function_Body ) \
|
||||
Entry( Global_Body ) \
|
||||
Entry( Module ) \
|
||||
Entry( Namespace ) \
|
||||
Entry( Namespace_Body ) \
|
||||
Entry( Operator ) \
|
||||
Entry( Operator_Fwd ) \
|
||||
Entry( Operator_Member ) \
|
||||
Entry( Operator_Member_Fwd ) \
|
||||
Entry( Operator_Cast ) \
|
||||
Entry( Operator_Cast_Fwd ) \
|
||||
Entry( Parameters ) \
|
||||
Entry( Preprocess_Define ) \
|
||||
Entry( Preprocess_If ) \
|
||||
Entry( Preprocess_IfDef ) \
|
||||
Entry( Preprocess_IfNotDef ) \
|
||||
Entry( Preprocess_ElIf ) \
|
||||
Entry( Preprocess_Else ) \
|
||||
Entry( Preprocess_EndIf ) \
|
||||
Entry( Preprocess_Include ) \
|
||||
Entry( Preprocess_Pragma ) \
|
||||
Entry( Specifiers ) \
|
||||
Entry( Struct ) \
|
||||
Entry( Struct_Fwd ) \
|
||||
Entry( Struct_Body ) \
|
||||
Entry( Template ) \
|
||||
Entry( Typedef ) \
|
||||
Entry( Typename ) \
|
||||
Entry( Union ) \
|
||||
Entry( Union_Body) \
|
||||
Entry( Using ) \
|
||||
Entry( Using_Namespace ) \
|
||||
Entry( Variable )
|
||||
|
||||
enum Type : u32
|
||||
{
|
||||
# define Entry( Type ) Type,
|
||||
Define_Types
|
||||
# undef Entry
|
||||
|
||||
Num_Types
|
||||
};
|
||||
|
||||
inline
|
||||
StrC to_str( Type type )
|
||||
{
|
||||
static
|
||||
StrC lookup[Num_Types] = {
|
||||
# define Entry( Type ) { sizeof(stringize(Type)), stringize(Type) },
|
||||
Define_Types
|
||||
# undef Entry
|
||||
};
|
||||
|
||||
return lookup[ type ];
|
||||
}
|
||||
|
||||
# undef Define_Types
|
||||
}
|
||||
using CodeT = ECode::Type;
|
||||
using ECode::to_str;
|
||||
|
@ -1,79 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// This is the non-bootstraped version of the EOperator. This will be obsolete once bootstrap is stress tested.
|
||||
|
||||
namespace EOperator
|
||||
{
|
||||
# define Define_Operators \
|
||||
Entry( Invalid, INVALID ) \
|
||||
Entry( Assign, = ) \
|
||||
Entry( Assign_Add, += ) \
|
||||
Entry( Assign_Subtract, -= ) \
|
||||
Entry( Assign_Multiply, *= ) \
|
||||
Entry( Assign_Divide, /= ) \
|
||||
Entry( Assign_Modulo, %= ) \
|
||||
Entry( Assign_BAnd, &= ) \
|
||||
Entry( Assign_BOr, |= ) \
|
||||
Entry( Assign_BXOr, ^= ) \
|
||||
Entry( Assign_LShift, <<= ) \
|
||||
Entry( Assign_RShift, >>= ) \
|
||||
Entry( Increment, ++ ) \
|
||||
Entry( Decrement, -- ) \
|
||||
Entry( Unary_Plus, + ) \
|
||||
Entry( Unary_Minus, - ) \
|
||||
Entry( UnaryNot, ! ) \
|
||||
Entry( Add, + ) \
|
||||
Entry( Subtract, - ) \
|
||||
Entry( Multiply, * ) \
|
||||
Entry( Divide, / ) \
|
||||
Entry( Modulo, % ) \
|
||||
Entry( BNot, ~ ) \
|
||||
Entry( BAnd, & ) \
|
||||
Entry( BOr, | ) \
|
||||
Entry( BXOr, ^ ) \
|
||||
Entry( LShift, << ) \
|
||||
Entry( RShift, >> ) \
|
||||
Entry( LAnd, && ) \
|
||||
Entry( LOr, || ) \
|
||||
Entry( LEqual, == ) \
|
||||
Entry( LNot, != ) \
|
||||
Entry( Lesser, < ) \
|
||||
Entry( Greater, > ) \
|
||||
Entry( LesserEqual, <= ) \
|
||||
Entry( GreaterEqual, >= ) \
|
||||
Entry( Subscript, [] ) \
|
||||
Entry( Indirection, * ) \
|
||||
Entry( AddressOf, & ) \
|
||||
Entry( MemberOfPointer, -> ) \
|
||||
Entry( PtrToMemOfPtr, ->* ) \
|
||||
Entry( FunctionCall, () )
|
||||
|
||||
enum Type : u32
|
||||
{
|
||||
# define Entry( Type_, Token_ ) Type_,
|
||||
Define_Operators
|
||||
# undef Entry
|
||||
Comma,
|
||||
|
||||
Num_Ops,
|
||||
};
|
||||
|
||||
inline
|
||||
StrC to_str( Type op )
|
||||
{
|
||||
local_persist
|
||||
StrC lookup[ Num_Ops ] = {
|
||||
# define Entry( Type_, Token_ ) { sizeof(stringize(Token_)), stringize(Token_) },
|
||||
Define_Operators
|
||||
# undef Entry
|
||||
txt(",")
|
||||
};
|
||||
|
||||
return lookup[ op ];
|
||||
}
|
||||
|
||||
# undef Define_Operators
|
||||
}
|
||||
using OperatorT = EOperator::Type;
|
||||
using EOperator::to_str;
|
||||
|
@ -1,114 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// This is the non-bootstraped version of the ESpecifier. This will be obsolete once bootstrap is stress tested.
|
||||
|
||||
namespace ESpecifier
|
||||
{
|
||||
/*
|
||||
Note: The following are handled separately:
|
||||
attributes
|
||||
alignas
|
||||
*/
|
||||
|
||||
# define Define_Specifiers \
|
||||
Entry( Invalid, INVALID ) \
|
||||
Entry( Consteval, consteval ) \
|
||||
Entry( Constexpr, constexpr ) \
|
||||
Entry( Constinit, constinit ) \
|
||||
Entry( Explicit, explicit ) \
|
||||
Entry( External_Linkage, extern ) \
|
||||
Entry( ForceInline, forceinline ) \
|
||||
Entry( Global, global ) \
|
||||
Entry( Inline, inline ) \
|
||||
Entry( Internal_Linkage, internal ) \
|
||||
Entry( Local_Persist, local_persist ) \
|
||||
Entry( Mutable, mutable ) \
|
||||
Entry( NeverInline, neverinline ) \
|
||||
Entry( Ptr, * ) \
|
||||
Entry( Ref, & ) \
|
||||
Entry( Register, register ) \
|
||||
Entry( RValue, && ) \
|
||||
Entry( Static, static ) \
|
||||
Entry( Thread_Local, thread_local ) \
|
||||
Entry( Volatile, volatile ) \
|
||||
Entry( Virtual, virtual ) \
|
||||
Entry( Const, const ) \
|
||||
Entry( Final, final ) \
|
||||
Entry( Override, override ) \
|
||||
Entry( Pure, = 0 )
|
||||
|
||||
enum Type : u32
|
||||
{
|
||||
# define Entry( Specifier, Code ) Specifier,
|
||||
Define_Specifiers
|
||||
# undef Entry
|
||||
|
||||
NumSpecifiers,
|
||||
};
|
||||
|
||||
inline
|
||||
bool is_trailing( Type specifier )
|
||||
{
|
||||
return specifier > Virtual;
|
||||
}
|
||||
|
||||
// Specifier to string
|
||||
inline
|
||||
StrC to_str( Type specifier )
|
||||
{
|
||||
local_persist
|
||||
StrC lookup[ NumSpecifiers ] = {
|
||||
# pragma push_macro( "global" )
|
||||
# pragma push_macro( "internal" )
|
||||
# pragma push_macro( "local_persist" )
|
||||
# pragma push_macro( "neverinline" )
|
||||
# undef global
|
||||
# undef internal
|
||||
# undef local_persist
|
||||
# undef neverinline
|
||||
|
||||
# define Entry( Spec_, Code_ ) { sizeof(stringize(Code_)), stringize(Code_) },
|
||||
Define_Specifiers
|
||||
# undef Entry
|
||||
|
||||
# pragma pop_macro( "global" )
|
||||
# pragma pop_macro( "internal" )
|
||||
# pragma pop_macro( "local_persist" )
|
||||
# pragma pop_macro( "neverinline" )
|
||||
};
|
||||
|
||||
return lookup[ specifier ];
|
||||
}
|
||||
|
||||
inline
|
||||
Type to_type( StrC str )
|
||||
{
|
||||
local_persist
|
||||
u32 keymap[ NumSpecifiers ];
|
||||
do_once_start
|
||||
for ( u32 index = 0; index < NumSpecifiers; index++ )
|
||||
{
|
||||
StrC enum_str = to_str( (Type)index );
|
||||
|
||||
// We subtract 1 to remove the null terminator
|
||||
// This is because the tokens lexed are not null terminated.
|
||||
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 < NumSpecifiers; index++ )
|
||||
{
|
||||
if ( keymap[index] == hash )
|
||||
return (Type)index;
|
||||
}
|
||||
|
||||
return Invalid;
|
||||
}
|
||||
|
||||
# undef Define_Specifiers
|
||||
}
|
||||
using SpecifierT = ESpecifier::Type;
|
||||
using ESpecifier::to_str;
|
||||
|
@ -1,174 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
namespace Parser
|
||||
{
|
||||
/*
|
||||
This is a simple lexer that focuses on tokenizing only tokens relevant to the library.
|
||||
It will not be capable of lexing C++ code with unsupported features.
|
||||
|
||||
For the sake of scanning files, it can scan preprocessor directives
|
||||
|
||||
__Attributes_Start is only used to indicate the start of the user_defined attribute list.
|
||||
*/
|
||||
|
||||
#ifndef GEN_DEFINE_ATTRIBUTE_TOKENS
|
||||
# define GEN_DEFINE_ATTRIBUTE_TOKENS \
|
||||
Entry( API_Export, "GEN_API_Export_Code" ) \
|
||||
Entry( API_Import, "GEN_API_Import_Code" )
|
||||
#endif
|
||||
|
||||
# define Define_TokType \
|
||||
Entry( Invalid, "INVALID" ) \
|
||||
Entry( Access_Private, "private" ) \
|
||||
Entry( Access_Protected, "protected" ) \
|
||||
Entry( Access_Public, "public" ) \
|
||||
Entry( Access_MemberSymbol, "." ) \
|
||||
Entry( Access_StaticSymbol, "::") \
|
||||
Entry( Ampersand, "&" ) \
|
||||
Entry( Ampersand_DBL, "&&" ) \
|
||||
Entry( Assign_Classifer, ":" ) \
|
||||
Entry( Attribute_Open, "[[" ) \
|
||||
Entry( Attribute_Close, "]]" ) \
|
||||
Entry( BraceCurly_Open, "{" ) \
|
||||
Entry( BraceCurly_Close, "}" ) \
|
||||
Entry( BraceSquare_Open, "[" ) \
|
||||
Entry( BraceSquare_Close, "]" ) \
|
||||
Entry( Capture_Start, "(" ) \
|
||||
Entry( Capture_End, ")" ) \
|
||||
Entry( Comment, "__comment__" ) \
|
||||
Entry( Comment_End, "__comment_end__" ) \
|
||||
Entry( Comment_Start, "__comment start__" ) \
|
||||
Entry( Char, "__character__" ) \
|
||||
Entry( Comma, "," ) \
|
||||
Entry( Decl_Class, "class" ) \
|
||||
Entry( Decl_GNU_Attribute, "__attribute__" ) \
|
||||
Entry( Decl_MSVC_Attribute, "__declspec" ) \
|
||||
Entry( Decl_Enum, "enum" ) \
|
||||
Entry( Decl_Extern_Linkage, "extern" ) \
|
||||
Entry( Decl_Friend, "friend" ) \
|
||||
Entry( Decl_Module, "module" ) \
|
||||
Entry( Decl_Namespace, "namespace" ) \
|
||||
Entry( Decl_Operator, "operator" ) \
|
||||
Entry( Decl_Struct, "struct" ) \
|
||||
Entry( Decl_Template, "template" ) \
|
||||
Entry( Decl_Typedef, "typedef" ) \
|
||||
Entry( Decl_Using, "using" ) \
|
||||
Entry( Decl_Union, "union" ) \
|
||||
Entry( Identifier, "__identifier__" ) \
|
||||
Entry( Module_Import, "import" ) \
|
||||
Entry( Module_Export, "export" ) \
|
||||
Entry( NewLine, "__NewLine__" ) \
|
||||
Entry( Number, "__number__" ) \
|
||||
Entry( Operator, "__operator__" ) \
|
||||
Entry( Preprocess_Hash, "#" ) \
|
||||
Entry( Preprocess_Define, "define") \
|
||||
Entry( Preprocess_If, "if") \
|
||||
Entry( Preprocess_IfDef, "ifdef") \
|
||||
Entry( Preprocess_IfNotDef, "ifndef") \
|
||||
Entry( Preprocess_ElIf, "elif") \
|
||||
Entry( Preprocess_Else, "else") \
|
||||
Entry( Preprocess_EndIf, "endif") \
|
||||
Entry( Preprocess_Include, "include" ) \
|
||||
Entry( Preprocess_Pragma, "pragma") \
|
||||
Entry( Preprocess_Content, "__macro_content__") \
|
||||
Entry( Preprocess_Macro, "__macro__") \
|
||||
Entry( Preprocess_Unsupported, "__unsupported__" ) \
|
||||
Entry( Spec_Alignas, "alignas" ) \
|
||||
Entry( Spec_Const, "const" ) \
|
||||
Entry( Spec_Consteval, "consteval" ) \
|
||||
Entry( Spec_Constexpr, "constexpr" ) \
|
||||
Entry( Spec_Constinit, "constinit" ) \
|
||||
Entry( Spec_Explicit, "explicit" ) \
|
||||
Entry( Spec_Extern, "extern" ) \
|
||||
Entry( Spec_ForceInline, "forceinline" ) \
|
||||
Entry( Spec_Final, "final" ) \
|
||||
Entry( Spec_Global, "global" ) \
|
||||
Entry( Spec_Inline, "inline" ) \
|
||||
Entry( Spec_Internal_Linkage, "internal" ) \
|
||||
Entry( Spec_LocalPersist, "local_persist" ) \
|
||||
Entry( Spec_Mutable, "mutable" ) \
|
||||
Entry( Spec_NeverInline, "neverinline" ) \
|
||||
Entry( Spec_Override, "override" ) \
|
||||
Entry( Spec_Static, "static" ) \
|
||||
Entry( Spec_ThreadLocal, "thread_local" ) \
|
||||
Entry( Spec_Virtual, "virtual" ) \
|
||||
Entry( Spec_Volatile, "volatile") \
|
||||
Entry( Star, "*" ) \
|
||||
Entry( Statement_End, ";" ) \
|
||||
Entry( StaticAssert, "static_assert" ) \
|
||||
Entry( String, "__string__" ) \
|
||||
Entry( Type_Unsigned, "unsigned" ) \
|
||||
Entry( Type_Signed, "signed" ) \
|
||||
Entry( Type_Short, "short" ) \
|
||||
Entry( Type_Long, "long" ) \
|
||||
Entry( Type_char, "char" ) \
|
||||
Entry( Type_int, "int" ) \
|
||||
Entry( Type_double, "double" ) \
|
||||
Entry( Type_MS_int8, "__int8" ) \
|
||||
Entry( Type_MS_int16, "__int16" ) \
|
||||
Entry( Type_MS_int32, "__int32" ) \
|
||||
Entry( Type_MS_int64, "__int64" ) \
|
||||
Entry( Type_MS_W64, "_W64" ) \
|
||||
Entry( Varadic_Argument, "..." ) \
|
||||
Entry( __Attributes_Start, "__attrib_start__" )
|
||||
|
||||
namespace ETokType
|
||||
{
|
||||
enum Type : u32
|
||||
{
|
||||
# define Entry( Name_, Str_ ) Name_,
|
||||
Define_TokType
|
||||
GEN_DEFINE_ATTRIBUTE_TOKENS
|
||||
# undef Entry
|
||||
NumTokens,
|
||||
};
|
||||
|
||||
internal inline
|
||||
Type to_type( StrC str_tok )
|
||||
{
|
||||
local_persist
|
||||
StrC lookup[(u32)NumTokens] =
|
||||
{
|
||||
# define Entry( Name_, Str_ ) { sizeof(Str_), Str_ },
|
||||
Define_TokType
|
||||
GEN_DEFINE_ATTRIBUTE_TOKENS
|
||||
# undef Entry
|
||||
};
|
||||
|
||||
for ( u32 index = 0; index < (u32)NumTokens; index++ )
|
||||
{
|
||||
s32 lookup_len = lookup[index].Len - 1;
|
||||
char const* lookup_str = lookup[index].Ptr;
|
||||
|
||||
if ( lookup_len != str_tok.Len )
|
||||
continue;
|
||||
|
||||
if ( str_compare( str_tok.Ptr, lookup_str, lookup_len ) == 0 )
|
||||
return scast(Type, index);
|
||||
}
|
||||
|
||||
return Invalid;
|
||||
}
|
||||
|
||||
internal inline
|
||||
StrC to_str( Type type )
|
||||
{
|
||||
local_persist
|
||||
StrC lookup[(u32)NumTokens] =
|
||||
{
|
||||
# define Entry( Name_, Str_ ) { sizeof(Str_), Str_ },
|
||||
Define_TokType
|
||||
GEN_DEFINE_ATTRIBUTE_TOKENS
|
||||
# undef Entry
|
||||
};
|
||||
|
||||
return lookup[(u32)type];
|
||||
}
|
||||
# undef Define_TokType
|
||||
};
|
||||
|
||||
using TokType = ETokType::Type;
|
||||
using ETokType::to_str;
|
||||
|
||||
} // Parser
|
||||
|
@ -23,7 +23,7 @@ GEN_NS_BEGIN
|
||||
|
||||
#include "components/interface.cpp"
|
||||
#include "components/interface.upfront.cpp"
|
||||
#include "components/temp/etoktype.cpp"
|
||||
#include "components/gen/etoktype.cpp"
|
||||
#include "components/interface.parsing.cpp"
|
||||
#include "components/interface.untyped.cpp"
|
||||
|
||||
|
@ -14,9 +14,9 @@
|
||||
GEN_NS_BEGIN
|
||||
|
||||
#include "components/types.hpp"
|
||||
#include "components/temp/ecode.hpp"
|
||||
#include "components/temp/eoperator.hpp"
|
||||
#include "components/temp/especifier.hpp"
|
||||
#include "components/gen/ecode.hpp"
|
||||
#include "components/gen/eoperator.hpp"
|
||||
#include "components/gen/especifier.hpp"
|
||||
|
||||
#include "components/ast.hpp"
|
||||
#include "components/ast_types.hpp"
|
||||
@ -24,7 +24,7 @@ GEN_NS_BEGIN
|
||||
#include "components/interface.hpp"
|
||||
|
||||
#include "components/inlines.hpp"
|
||||
#include "components/temp/ast_inlines.hpp"
|
||||
#include "components/gen/ast_inlines.hpp"
|
||||
#include "components/header_end.hpp"
|
||||
|
||||
GEN_NS_END
|
||||
|
@ -307,8 +307,9 @@ $path_test = Join-Path $path_root test
|
||||
|
||||
if ( $bootstrap )
|
||||
{
|
||||
$path_build = join-path $path_project build
|
||||
$path_gen = join-path $path_project gen
|
||||
$path_build = join-path $path_project build
|
||||
$path_gen = join-path $path_project gen
|
||||
$path_comp_gen = join-path $path_project components/gen
|
||||
|
||||
if ( -not(Test-Path($path_build) )) {
|
||||
New-Item -ItemType Directory -Path $path_build
|
||||
@ -316,6 +317,9 @@ if ( $bootstrap )
|
||||
if ( -not(Test-Path($path_gen) )) {
|
||||
New-Item -ItemType Directory -Path $path_gen
|
||||
}
|
||||
if ( -not(Test-Path($path_comp_gen) )) {
|
||||
New-Item -ItemType Directory -Path $path_comp_gen
|
||||
}
|
||||
|
||||
$includes = @( $path_project)
|
||||
$unit = join-path $path_project "bootstrap.cpp"
|
||||
@ -431,7 +435,8 @@ function format-cpp
|
||||
|
||||
if ( $bootstrap -and (Test-Path (Join-Path $path_project "gen/gen.hpp")) )
|
||||
{
|
||||
$path_gen = join-path $path_project gen
|
||||
$path_gen = join-path $path_project gen
|
||||
$path_comp_gen = join-path $path_project components/gen
|
||||
$include = @(
|
||||
'gen.hpp', 'gen.cpp',
|
||||
'gen.dep.hpp', 'gen.dep.cpp',
|
||||
@ -440,6 +445,7 @@ if ( $bootstrap -and (Test-Path (Join-Path $path_project "gen/gen.hpp")) )
|
||||
)
|
||||
$exclude = $null
|
||||
format-cpp $path_gen $include $exclude
|
||||
format-cpp $path_comp_gen @( 'ast_inlines.hpp', 'ecode.hpp', 'especifier.hpp', 'eoperator.hpp', 'etoktype.cpp' ) $null
|
||||
}
|
||||
|
||||
if ( $singleheader -and (Test-Path (Join-Path $path_singleheader "gen/gen.hpp")) )
|
||||
|
@ -150,14 +150,14 @@ int gen_main()
|
||||
if ( generate_builder )
|
||||
{
|
||||
header.print_fmt( "#pragma region Builder\n\n" );
|
||||
header.print( scan_file( project_dir "auxillary/builder.hpp",DontSkipInitialDirectives ) );
|
||||
header.print( scan_file( project_dir "auxillary/builder.hpp" ) );
|
||||
header.print_fmt( "#pragma endregion Builder\n\n" );
|
||||
}
|
||||
|
||||
if ( generate_scanner )
|
||||
{
|
||||
header.print_fmt( "#pragma region Scanner\n\n" );
|
||||
header.print( scan_file( project_dir "auxillary/scanner.hpp", DontSkipInitialDirectives ) );
|
||||
header.print( scan_file( project_dir "auxillary/scanner.hpp" ) );
|
||||
header.print_fmt( "#pragma endregion Scanner\n\n" );
|
||||
}
|
||||
|
||||
@ -236,7 +236,7 @@ int gen_main()
|
||||
if ( generate_builder )
|
||||
{
|
||||
header.print_fmt( "#pragma region Builder\n\n" );
|
||||
header.print( scan_file( project_dir "auxillary/builder.cpp", DontSkipInitialDirectives ) );
|
||||
header.print( scan_file( project_dir "auxillary/builder.cpp" ) );
|
||||
header.print_fmt( "#pragma endregion Builder\n\n" );
|
||||
}
|
||||
|
||||
@ -244,7 +244,7 @@ int gen_main()
|
||||
if ( generate_scanner )
|
||||
{
|
||||
header.print_fmt( "#pragma region Scanner\n\n" );
|
||||
header.print( scan_file( project_dir "auxillary/scanner.cpp", DontSkipInitialDirectives ) );
|
||||
header.print( scan_file( project_dir "auxillary/scanner.cpp" ) );
|
||||
header.print_fmt( "#pragma endregion Scanner\n\n" );
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user