bootstrap and singleheader compile and generate.

This commit is contained in:
Edward R. Gonzalez 2023-07-29 12:25:38 -04:00
parent 689646c393
commit 108b16739f
5 changed files with 69 additions and 56 deletions

View File

@ -1738,7 +1738,6 @@ internal
Code parse_class_struct( Parser::TokType which ) Code parse_class_struct( Parser::TokType which )
{ {
using namespace Parser; using namespace Parser;
push_scope();
if ( which != TokType::Decl_Class && which != TokType::Decl_Struct ) if ( which != TokType::Decl_Class && which != TokType::Decl_Struct )
{ {
@ -1814,7 +1813,6 @@ Code parse_class_struct( Parser::TokType which )
result = def_struct( name, body, (CodeType)parent, access, attributes, mflags ); result = def_struct( name, body, (CodeType)parent, access, attributes, mflags );
interfaces.free(); interfaces.free();
Context.pop();
return result; return result;
} }
@ -1865,7 +1863,6 @@ CodeBody parse_global_nspace( CodeT which )
{ {
using namespace Parser; using namespace Parser;
using namespace ECode; using namespace ECode;
push_scope();
if ( which != Namespace_Body && which != Global_Body && which != Export_Body && which != Extern_Linkage_Body ) if ( which != Namespace_Body && which != Global_Body && which != Export_Body && which != Extern_Linkage_Body )
return CodeInvalid; return CodeInvalid;
@ -2024,7 +2021,6 @@ CodeBody parse_global_nspace( CodeT which )
if ( which != Global_Body ) if ( which != Global_Body )
eat( TokType::BraceCurly_Close ); eat( TokType::BraceCurly_Close );
Context.pop();
return result; return result;
} }
@ -2047,6 +2043,7 @@ CodeClass parse_class( StrC def )
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return CodeInvalid;
Context.Tokens = toks;
push_scope(); push_scope();
CodeClass result = (CodeClass) parse_class_struct( TokType::Decl_Class ); CodeClass result = (CodeClass) parse_class_struct( TokType::Decl_Class );
Context.pop(); Context.pop();
@ -2171,6 +2168,7 @@ CodeEnum parse_enum( StrC def )
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return CodeInvalid;
Context.Tokens = toks;
return parse_enum(); return parse_enum();
} }
@ -2193,6 +2191,7 @@ CodeBody parse_export_body( StrC def )
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return CodeInvalid;
Context.Tokens = toks;
return parse_export_body(); return parse_export_body();
} }
@ -2247,6 +2246,7 @@ CodeExtern parse_extern_link( StrC def )
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return CodeInvalid;
Context.Tokens = toks;
return parse_extern_link(); return parse_extern_link();
} }
@ -2309,6 +2309,7 @@ CodeFriend parse_friend( StrC def )
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return CodeInvalid;
Context.Tokens = toks;
return parse_friend(); return parse_friend();
} }
@ -2388,6 +2389,7 @@ CodeFn parse_function( StrC def )
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return CodeInvalid;
Context.Tokens = toks;
return (CodeFn) parse_functon(); return (CodeFn) parse_functon();
} }
@ -2400,6 +2402,7 @@ CodeBody parse_global_body( StrC def )
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return CodeInvalid;
Context.Tokens = toks;
push_scope(); push_scope();
CodeBody result = parse_global_nspace( ECode::Global_Body ); CodeBody result = parse_global_nspace( ECode::Global_Body );
Context.pop(); Context.pop();
@ -2440,6 +2443,7 @@ CodeNamespace parse_namespace( StrC def )
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return CodeInvalid;
Context.Tokens = toks;
return parse_namespace(); return parse_namespace();
} }
@ -2512,6 +2516,7 @@ CodeOperator parse_operator( StrC def )
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return CodeInvalid;
Context.Tokens = toks;
return (CodeOperator) parse_operator(); return (CodeOperator) parse_operator();
} }
@ -2589,6 +2594,7 @@ CodeOpCast parse_operator_cast( StrC def )
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return CodeInvalid;
Context.Tokens = toks;
return parse_operator_cast(); return parse_operator_cast();
} }
@ -2611,6 +2617,7 @@ CodeStruct parse_struct( StrC def )
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return CodeInvalid;
Context.Tokens = toks;
return (CodeStruct) parse_class_struct( TokType::Decl_Struct ); return (CodeStruct) parse_class_struct( TokType::Decl_Struct );
} }
@ -2738,6 +2745,7 @@ CodeTemplate parse_template( StrC def )
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return CodeInvalid;
Context.Tokens = toks;
return parse_template(); return parse_template();
} }
@ -2927,6 +2935,7 @@ CodeType parse_type( StrC def )
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return CodeInvalid;
Context.Tokens = toks;
return parse_type(); return parse_type();
} }
@ -3004,6 +3013,7 @@ CodeTypedef parse_typedef( StrC def )
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return CodeInvalid;
Context.Tokens = toks;
return parse_typedef(); return parse_typedef();
} }
@ -3078,6 +3088,7 @@ CodeUnion parse_union( StrC def )
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return CodeInvalid;
Context.Tokens = toks;
return parse_union(); return parse_union();
} }
@ -3167,6 +3178,7 @@ CodeUsing parse_using( StrC def )
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return CodeInvalid;
Context.Tokens = toks;
return parse_using(); return parse_using();
} }
@ -3252,6 +3264,7 @@ CodeVar parse_variable( StrC def )
if ( toks.Arr == nullptr ) if ( toks.Arr == nullptr )
return CodeInvalid; return CodeInvalid;
Context.Tokens = toks;
return parse_variable(); return parse_variable();
} }

View File

@ -129,7 +129,7 @@ int gen_main()
CodeBody especifier = gen_especifier( "enums/ESpecifier.csv" ); CodeBody especifier = gen_especifier( "enums/ESpecifier.csv" );
// TODO : Make this optional to include // TODO : Make this optional to include
Code builder = scan_file( "file_proecessors/builder.hpp" ); Code builder = scan_file( "file_processors/builder.hpp" );
Builder Builder
header; header;
@ -160,7 +160,7 @@ int gen_main()
// gen.cpp // gen.cpp
{ {
Code impl_start = scan_file( "components/gen.impl_start.cpp" ); Code impl_start = scan_file( "components/impl_start.cpp" );
CodeInclude header = def_include( txt_StrC("gen.hpp") ); CodeInclude header = def_include( txt_StrC("gen.hpp") );
Code data = scan_file( "components/static_data.cpp" ); Code data = scan_file( "components/static_data.cpp" );
Code ast_case_macros = scan_file( "components/ast_case_macros.cpp" ); Code ast_case_macros = scan_file( "components/ast_case_macros.cpp" );
@ -174,7 +174,7 @@ int gen_main()
CodeNamespace parser_nspace = def_namespace( name(Parser), def_namespace_body( args(etoktype)) ); CodeNamespace parser_nspace = def_namespace( name(Parser), def_namespace_body( args(etoktype)) );
// TODO : Make this optional to include // TODO : Make this optional to include
Code builder = scan_file( "file_proecessors/builder.cpp" ); Code builder = scan_file( "file_processors/builder.cpp" );
Builder Builder
impl; impl;

View File

@ -3,7 +3,7 @@
AccessModifierOffset: -4 AccessModifierOffset: -4
AlignAfterOpenBracket: BlockIndent AlignAfterOpenBracket: BlockIndent
AlignArrayOfStructures: Right AlignArrayOfStructures: Left
AlignConsecutiveAssignments: AlignConsecutiveAssignments:
Enabled: true Enabled: true
AcrossEmptyLines: false AcrossEmptyLines: false
@ -61,7 +61,7 @@ BraceWrapping:
BeforeLambdaBody: false BeforeLambdaBody: false
BeforeWhile: false BeforeWhile: false
# BreakAfterAttributes: Always BreakAfterAttributes: Always
# BreakArrays: false # BreakArrays: false
# BreakBeforeInlineASMColon: OnlyMultiline # BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeBinaryOperators: NonAssignment BreakBeforeBinaryOperators: NonAssignment
@ -96,7 +96,7 @@ IncludeBlocks: Preserve
IndentCaseBlocks: false IndentCaseBlocks: false
IndentCaseLabels: false IndentCaseLabels: false
IndentExternBlock: AfterExternBlock IndentExternBlock: AfterExternBlock
IndentGotoLabels: false IndentGotoLabels: true
IndentPPDirectives: AfterHash IndentPPDirectives: AfterHash
IndentRequires: true IndentRequires: true
IndentWidth: 4 IndentWidth: 4
@ -127,7 +127,7 @@ SeparateDefinitionBlocks: Always
ShortNamespaceLines: 40 ShortNamespaceLines: 40
SortIncludes: true SortIncludes: false
SortUsingDeclarations: true SortUsingDeclarations: true
SpaceAfterCStyleCast: false SpaceAfterCStyleCast: false

View File

@ -2,8 +2,8 @@
#define GEN_ENFORCE_STRONG_CODE_TYPES #define GEN_ENFORCE_STRONG_CODE_TYPES
#define GEN_EXPOSE_BACKEND #define GEN_EXPOSE_BACKEND
#include "gen.cpp" #include "gen.cpp"
#include "filesystem/gen.scanner.hpp" #include "file_processors/scanner.hpp"
#include "helpers/gen.helper.hpp" #include "helpers/helper.hpp"
using namespace gen; using namespace gen;
@ -59,10 +59,10 @@ int gen_main()
#define project_dir "../project/" #define project_dir "../project/"
Code push_ignores = scan_file( project_dir "helpers/gen.push_ignores.inline.hpp" ); Code push_ignores = scan_file( project_dir "helpers/push_ignores.inline.hpp" );
Code pop_ignores = scan_file( project_dir "helpers/gen.pop_ignores.inline.hpp" ); Code pop_ignores = scan_file( project_dir "helpers/pop_ignores.inline.hpp" );
Code header_start = scan_file( "components/gen.header_start.hpp" ); Code header_start = scan_file( "components/header_start.hpp" );
Code nspace_macro = untyped_str( namespace_by_default ? nspace_default : nspace_non_default ); Code nspace_macro = untyped_str( namespace_by_default ? nspace_default : nspace_non_default );
Builder Builder
@ -80,19 +80,19 @@ int gen_main()
{ {
header.print_fmt( roll_own_dependencies_guard_start ); header.print_fmt( roll_own_dependencies_guard_start );
Code header_start = scan_file( project_dir "dependencies/gen.header_start.hpp" ); Code header_start = scan_file( project_dir "dependencies/header_start.hpp" );
Code macros = scan_file( project_dir "dependencies/gen.macros.hpp" ); Code macros = scan_file( project_dir "dependencies/macros.hpp" );
Code basic_types = scan_file( project_dir "dependencies/gen.basic_types.hpp" ); Code basic_types = scan_file( project_dir "dependencies/basic_types.hpp" );
Code debug = scan_file( project_dir "dependencies/gen.debug.hpp" ); Code debug = scan_file( project_dir "dependencies/debug.hpp" );
Code memory = scan_file( project_dir "dependencies/gen.memory.hpp" ); Code memory = scan_file( project_dir "dependencies/memory.hpp" );
Code string_ops = scan_file( project_dir "dependencies/gen.string_ops.hpp" ); Code string_ops = scan_file( project_dir "dependencies/string_ops.hpp" );
Code printing = scan_file( project_dir "dependencies/gen.printing.hpp" ); Code printing = scan_file( project_dir "dependencies/printing.hpp" );
Code containers = scan_file( project_dir "dependencies/gen.containers.hpp" ); Code containers = scan_file( project_dir "dependencies/containers.hpp" );
Code hashing = scan_file( project_dir "dependencies/gen.hashing.hpp" ); Code hashing = scan_file( project_dir "dependencies/hashing.hpp" );
Code string = scan_file( project_dir "dependencies/gen.string.hpp" ); Code string = scan_file( project_dir "dependencies/string.hpp" );
Code file_handling = scan_file( project_dir "dependencies/gen.file_handling.hpp" ); Code file_handling = scan_file( project_dir "dependencies/file_handling.hpp" );
Code parsing = scan_file( project_dir "dependencies/gen.parsing.hpp" ); Code parsing = scan_file( project_dir "dependencies/parsing.hpp" );
Code timing = scan_file( project_dir "dependencies/gen.timing.hpp" ); Code timing = scan_file( project_dir "dependencies/timing.hpp" );
header.print( header_start ); header.print( header_start );
header.print_fmt( "GEN_NS_BEGIN\n\n" ); header.print_fmt( "GEN_NS_BEGIN\n\n" );
@ -113,16 +113,16 @@ int gen_main()
header.print_fmt( roll_own_dependencies_guard_end ); header.print_fmt( roll_own_dependencies_guard_end );
} }
Code types = scan_file( project_dir "components/gen.types.hpp" ); Code types = scan_file( project_dir "components/types.hpp" );
Code data_structs = scan_file( project_dir "components/gen.data_structures.hpp" ); Code data_structs = scan_file( project_dir "components/data_structures.hpp" );
Code interface = scan_file( project_dir "components/gen.interface.hpp" ); Code interface = scan_file( project_dir "components/interface.hpp" );
Code header_end = scan_file( project_dir "components/gen.header_end.hpp" ); Code header_end = scan_file( project_dir "components/header_end.hpp" );
CodeBody ecode = gen_ecode( project_dir "components/ECode.csv" ); CodeBody ecode = gen_ecode( project_dir "enums/ECode.csv" );
CodeBody eoperator = gen_eoperator( project_dir "components/EOperator.csv" ); CodeBody eoperator = gen_eoperator( project_dir "enums/EOperator.csv" );
CodeBody especifier = gen_especifier( project_dir "components/ESpecifier.csv" ); CodeBody especifier = gen_especifier( project_dir "enums/ESpecifier.csv" );
Code builder = scan_file( project_dir "filesystem/gen.builder.hpp" ); Code builder = scan_file( project_dir "file_processors/builder.hpp" );
header.print_fmt( "GEN_NS_BEGIN\n\n" ); header.print_fmt( "GEN_NS_BEGIN\n\n" );
@ -146,17 +146,17 @@ int gen_main()
{ {
header.print_fmt( roll_own_dependencies_guard_start ); header.print_fmt( roll_own_dependencies_guard_start );
Code impl_start = scan_file( project_dir "dependencies/gen.impl_start.cpp" ); Code impl_start = scan_file( project_dir "dependencies/impl_start.cpp" );
Code debug = scan_file( project_dir "dependencies/gen.debug.cpp" ); Code debug = scan_file( project_dir "dependencies/debug.cpp" );
Code string_ops = scan_file( project_dir "dependencies/gen.string_ops.cpp" ); Code string_ops = scan_file( project_dir "dependencies/string_ops.cpp" );
Code printing = scan_file( project_dir "dependencies/gen.printing.cpp" ); Code printing = scan_file( project_dir "dependencies/printing.cpp" );
Code memory = scan_file( project_dir "dependencies/gen.memory.cpp" ); Code memory = scan_file( project_dir "dependencies/memory.cpp" );
Code parsing = scan_file( project_dir "dependencies/gen.parsing.cpp" ); Code parsing = scan_file( project_dir "dependencies/parsing.cpp" );
Code hashing = scan_file( project_dir "dependencies/gen.hashing.cpp" ); Code hashing = scan_file( project_dir "dependencies/hashing.cpp" );
Code string = scan_file( project_dir "dependencies/gen.string.cpp" ); Code string = scan_file( project_dir "dependencies/string.cpp" );
Code timing = scan_file( project_dir "dependencies/gen.timing.cpp" ); Code timing = scan_file( project_dir "dependencies/timing.cpp" );
Code file_handling = scan_file( project_dir "dependencies/gen.file_handling.cpp" ); Code file_handling = scan_file( project_dir "dependencies/file_handling.cpp" );
header.print_fmt( "GEN_NS_BEGIN\n\n"); header.print_fmt( "GEN_NS_BEGIN\n\n");
header.print( impl_start ); header.print( impl_start );
@ -176,18 +176,18 @@ int gen_main()
header.print_fmt( roll_own_dependencies_guard_end ); header.print_fmt( roll_own_dependencies_guard_end );
} }
Code data = scan_file( project_dir "components/gen.data.cpp" ); Code data = scan_file( project_dir "components/static_data.cpp" );
Code ast_case_macros = scan_file( project_dir "components/gen.ast_case_macros.cpp" ); Code ast_case_macros = scan_file( project_dir "components/ast_case_macros.cpp" );
Code ast = scan_file( project_dir "components/gen.ast.cpp" ); Code ast = scan_file( project_dir "components/ast.cpp" );
Code interface = scan_file( project_dir "components/gen.interface.cpp" ); Code interface = scan_file( project_dir "components/interface.cpp" );
Code upfront = scan_file( project_dir "components/gen.interface.upfront.cpp" ); Code upfront = scan_file( project_dir "components/interface.upfront.cpp" );
Code parsing = scan_file( project_dir "components/gen.interface.parsing.cpp" ); Code parsing = scan_file( project_dir "components/interface.parsing.cpp" );
Code untyped = scan_file( project_dir "components/gen.untyped.cpp" ); Code untyped = scan_file( project_dir "components/untyped.cpp" );
CodeBody etoktype = gen_etoktype( project_dir "components/ETokType.csv", project_dir "components/AttributeTokens.csv" ); CodeBody etoktype = gen_etoktype( project_dir "enums/ETokType.csv", project_dir "enums/AttributeTokens.csv" );
CodeNamespace parser_nspace = def_namespace( name(Parser), def_namespace_body( args(etoktype)) ); CodeNamespace parser_nspace = def_namespace( name(Parser), def_namespace_body( args(etoktype)) );
Code builder = scan_file( project_dir "filesystem/gen.builder.cpp" ); Code builder = scan_file( project_dir "file_processors/builder.cpp" );
header.print_fmt( "GEN_NS_BEGIN\n\n"); header.print_fmt( "GEN_NS_BEGIN\n\n");
header.print( data ); header.print( data );