mirror of
https://github.com/Ed94/gencpp.git
synced 2024-11-10 02:54:53 -08:00
first serialization of singlehearder without asserts. (Still failing after around 4k lines.
This commit is contained in:
parent
0f16d1131e
commit
684569750d
@ -448,7 +448,7 @@ String AST::to_string()
|
||||
{
|
||||
if ( Specs )
|
||||
{
|
||||
result.append_fmt( "operator %s()" );
|
||||
result.append_fmt( "operator %s()", EOperator::to_str( Op ) );
|
||||
|
||||
CodeSpecifiers specs = cast<CodeSpecifiers>();
|
||||
|
||||
@ -488,6 +488,12 @@ String AST::to_string()
|
||||
|
||||
case Parameters:
|
||||
{
|
||||
if ( ValueType == nullptr )
|
||||
{
|
||||
result.append_fmt( "%s", Name );
|
||||
break;
|
||||
}
|
||||
|
||||
if ( Name )
|
||||
result.append_fmt( "%s %s", ValueType->to_string(), Name );
|
||||
|
||||
@ -508,39 +514,39 @@ String AST::to_string()
|
||||
break;
|
||||
|
||||
case Preprocess_Define:
|
||||
result.append_fmt( "#define %s %s\n", Name, Content );
|
||||
result.append_fmt( "#define %s %s", Name, Content );
|
||||
break;
|
||||
|
||||
case Preprocess_If:
|
||||
result.append_fmt( "#if %s\n", Content );
|
||||
result.append_fmt( "#if %s", Content );
|
||||
break;
|
||||
|
||||
case Preprocess_IfDef:
|
||||
result.append_fmt( "#ifdef %s\n", Content );
|
||||
result.append_fmt( "#ifdef %s", Content );
|
||||
break;
|
||||
|
||||
case Preprocess_IfNotDef:
|
||||
result.append_fmt( "#ifndef %s\n", Content );
|
||||
result.append_fmt( "#ifndef %s", Content );
|
||||
break;
|
||||
|
||||
case Preprocess_Include:
|
||||
result.append_fmt( "#include \"%s\"\n", Content );
|
||||
result.append_fmt( "#include \"%s\"", Content );
|
||||
break;
|
||||
|
||||
case Preprocess_ElIf:
|
||||
result.append_fmt( "#elif %s\n", Content );
|
||||
result.append_fmt( "#elif %s", Content );
|
||||
break;
|
||||
|
||||
case Preprocess_Else:
|
||||
result.append_fmt( "#else\n" );
|
||||
result.append_fmt( "#else" );
|
||||
break;
|
||||
|
||||
case Preprocess_EndIf:
|
||||
result.append_fmt( "#endif\n" );
|
||||
result.append_fmt( "#endif" );
|
||||
break;
|
||||
|
||||
case Preprocess_Pragma:
|
||||
result.append_fmt( "#pragma %s\n", Content );
|
||||
result.append_fmt( "#pragma %s", Content );
|
||||
break;
|
||||
|
||||
case Specifiers:
|
||||
|
@ -74,6 +74,11 @@ void define_constants()
|
||||
Code::Invalid = make_code();
|
||||
Code::Invalid.set_global();
|
||||
|
||||
t_empty = (CodeType) make_code();
|
||||
t_empty->Type = ECode::Typename;
|
||||
t_empty->Name = get_cached_string( txt_StrC("") );
|
||||
t_empty.set_global();
|
||||
|
||||
access_private = make_code();
|
||||
access_private->Type = ECode::Access_Private;
|
||||
access_private->Name = get_cached_string( txt_StrC("private:") );
|
||||
@ -161,11 +166,6 @@ void define_constants()
|
||||
#endif
|
||||
# undef def_constant_code_type
|
||||
|
||||
t_empty = (CodeType) make_code();
|
||||
t_empty->Type = ECode::Typename;
|
||||
t_empty->Name = get_cached_string( txt_StrC("") );
|
||||
t_empty.set_global();
|
||||
|
||||
# pragma push_macro( "global" )
|
||||
# pragma push_macro( "internal" )
|
||||
# pragma push_macro( "local_persist" )
|
||||
|
@ -2036,6 +2036,22 @@ CodeVar parse_variable_after_name(
|
||||
return result;
|
||||
}
|
||||
|
||||
internal inline
|
||||
Code parse_simple_preprocess( Parser::TokType which )
|
||||
{
|
||||
using namespace Parser;
|
||||
push_scope();
|
||||
|
||||
Token tok = currtok;
|
||||
tok.Text = str_fmt_buf( "%.*s\n", tok.Length, tok.Text );
|
||||
tok.Length++;
|
||||
Code result = untyped_str( tok );
|
||||
eat( which );
|
||||
|
||||
Context.pop();
|
||||
return result;
|
||||
}
|
||||
|
||||
internal inline
|
||||
Code parse_variable_assignment()
|
||||
{
|
||||
@ -2070,7 +2086,6 @@ Code parse_variable_assignment()
|
||||
return expr;
|
||||
}
|
||||
|
||||
|
||||
internal inline
|
||||
Code parse_operator_function_or_variable( bool expects_function, CodeAttributes attributes, CodeSpecifiers specifiers )
|
||||
{
|
||||
@ -2351,8 +2366,7 @@ CodeBody parse_class_struct_body( Parser::TokType which )
|
||||
break;
|
||||
|
||||
case TokType::Preprocess_Macro:
|
||||
member = untyped_str( currtok );
|
||||
eat( TokType::Preprocess_Macro );
|
||||
member = parse_simple_preprocess( TokType::Preprocess_Macro );
|
||||
break;
|
||||
|
||||
case TokType::Preprocess_Pragma:
|
||||
@ -2370,8 +2384,7 @@ CodeBody parse_class_struct_body( Parser::TokType which )
|
||||
break;
|
||||
|
||||
case TokType::Preprocess_Unsupported:
|
||||
member = untyped_str( currtok );
|
||||
eat( TokType::Preprocess_Unsupported );
|
||||
member = parse_simple_preprocess( TokType::Preprocess_Unsupported );
|
||||
break;
|
||||
|
||||
case TokType::StaticAssert:
|
||||
@ -2687,8 +2700,7 @@ CodeBody parse_global_nspace( CodeT which )
|
||||
break;
|
||||
|
||||
case TokType::Preprocess_Macro:
|
||||
member = untyped_str( currtok );
|
||||
eat( TokType::Preprocess_Macro );
|
||||
member = parse_simple_preprocess( TokType::Preprocess_Macro );
|
||||
break;
|
||||
|
||||
case TokType::Preprocess_Pragma:
|
||||
@ -2706,8 +2718,7 @@ CodeBody parse_global_nspace( CodeT which )
|
||||
break;
|
||||
|
||||
case TokType::Preprocess_Unsupported:
|
||||
member = untyped_str( currtok );
|
||||
eat( TokType::Preprocess_Unsupported );
|
||||
member = parse_simple_preprocess( TokType::Preprocess_Unsupported );
|
||||
break;
|
||||
|
||||
case TokType::StaticAssert:
|
||||
@ -2893,6 +2904,7 @@ CodeEnum parse_enum( bool inplace_def )
|
||||
if ( currtok.Type == TokType::BraceCurly_Open )
|
||||
{
|
||||
body = (CodeBody) make_code();
|
||||
body->Type = ECode::Enum_Body;
|
||||
|
||||
eat( TokType::BraceCurly_Open );
|
||||
|
||||
@ -2929,14 +2941,17 @@ CodeEnum parse_enum( bool inplace_def )
|
||||
break;
|
||||
|
||||
case TokType::Preprocess_Macro:
|
||||
member = untyped_str( currtok );
|
||||
eat( TokType::Preprocess_Macro );
|
||||
member = parse_simple_preprocess( TokType::Preprocess_Macro );
|
||||
break;
|
||||
|
||||
case TokType::Preprocess_Pragma:
|
||||
member = parse_pragma();
|
||||
break;
|
||||
|
||||
case TokType::Preprocess_Unsupported:
|
||||
member = parse_simple_preprocess( TokType::Preprocess_Unsupported );
|
||||
break;
|
||||
|
||||
default:
|
||||
Token entry = currtok;
|
||||
|
||||
@ -3986,14 +4001,17 @@ CodeUnion parse_union( bool inplace_def )
|
||||
break;
|
||||
|
||||
case TokType::Preprocess_Macro:
|
||||
member = untyped_str( currtok );
|
||||
eat( TokType::Preprocess_Macro );
|
||||
member = parse_simple_preprocess( TokType::Preprocess_Macro );
|
||||
break;
|
||||
|
||||
case TokType::Preprocess_Pragma:
|
||||
member = parse_pragma();
|
||||
break;
|
||||
|
||||
case TokType::Preprocess_Unsupported:
|
||||
member = parse_simple_preprocess( TokType::Preprocess_Unsupported );
|
||||
break;
|
||||
|
||||
default:
|
||||
member = parse_variable();
|
||||
break;
|
||||
|
@ -28,7 +28,7 @@ void check_singleheader_ast()
|
||||
}
|
||||
|
||||
Builder builder;
|
||||
builder.open( "singleheader_copy.hpp" );
|
||||
builder.open( "singleheader_copy.gen.hpp" );
|
||||
log_fmt("serializng ast\n");
|
||||
builder.print( ast );
|
||||
builder.write();
|
||||
|
Loading…
Reference in New Issue
Block a user