mirror of
https://github.com/Ed94/gencpp.git
synced 2025-06-15 03:01:47 -07:00
Reorganization of parser, refactor of parse_type( bool* ) and progression of parser docs
Wanted to make parser implementation easier to sift through, so I emphasized alphabetical order more. Since I couldn't just strip whitespace from typenames I decided to make the parse_type more aware of the typename's components if it was a function signature. This ofc lead to the dark & damp hell that is parsing typenames. Also made initial implementation to support parsing decltype within a typename signature.. The test failure for the singleheader is still a thing, these changes have not addressed that.
This commit is contained in:
@ -773,7 +773,8 @@ String AST::to_string()
|
||||
|
||||
result.append( "typedef ");
|
||||
|
||||
if ( IsFunction )
|
||||
// Determines if the typedef is a function typename
|
||||
if ( UnderlyingType->ReturnType )
|
||||
result.append( UnderlyingType->to_string() );
|
||||
else
|
||||
result.append_fmt( "%S %S", UnderlyingType->to_string(), Name );
|
||||
@ -796,21 +797,45 @@ String AST::to_string()
|
||||
|
||||
case Typename:
|
||||
{
|
||||
if ( Attributes || Specs )
|
||||
#if GEN_USE_NEW_TYPENAME_PARSING
|
||||
if ( ReturnType && Params )
|
||||
{
|
||||
if ( Attributes )
|
||||
result.append_fmt( "%S ", Attributes->to_string() );
|
||||
|
||||
if ( Specs )
|
||||
result.append_fmt( "%S %S", Name, Specs->to_string() );
|
||||
|
||||
else
|
||||
result.append_fmt( "%S", Name );
|
||||
{
|
||||
if ( Specs )
|
||||
result.append_fmt( "%S ( %S ) ( %S ) %S", ReturnType->to_string(), Name, Params->to_string(), Specs->to_string() );
|
||||
else
|
||||
result.append_fmt( "%S ( %S ) ( %S )", ReturnType->to_string(), Name, Params->to_string() );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
else
|
||||
#else
|
||||
if ( ReturnType && Params )
|
||||
{
|
||||
result.append_fmt( "%S", Name );
|
||||
if ( Attributes )
|
||||
result.append_fmt( "%S ", Attributes->to_string() );
|
||||
else
|
||||
{
|
||||
if ( Specs )
|
||||
result.append_fmt( "%S %S ( %S ) %S", ReturnType->to_string(), Name, Params->to_string(), Specs->to_string() );
|
||||
else
|
||||
result.append_fmt( "%S %S ( %S )", ReturnType->to_string(), Name, Params->to_string() );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( Attributes )
|
||||
result.append_fmt( "%S ", Attributes->to_string() );
|
||||
|
||||
if ( Specs )
|
||||
result.append_fmt( "%S %S", Name, Specs->to_string() );
|
||||
else
|
||||
result.append_fmt( "%S", Name );
|
||||
|
||||
if ( IsParamPack )
|
||||
result.append("...");
|
||||
|
@ -6,11 +6,6 @@
|
||||
#include "gen/especifier.hpp"
|
||||
#endif
|
||||
|
||||
namespace Parser
|
||||
{
|
||||
struct Token;
|
||||
}
|
||||
|
||||
struct AST;
|
||||
struct AST_Body;
|
||||
struct AST_Attributes;
|
||||
@ -234,12 +229,15 @@ struct AST
|
||||
union {
|
||||
struct
|
||||
{
|
||||
AST* InlineCmt; // Class, Constructor, Destructor, Enum, Friend, Functon, Operator, OpCast, Struct, Typedef, Using, Variable
|
||||
AST* Attributes; // Class, Enum, Function, Struct, Typedef, Union, Using, Variable
|
||||
AST* Specs; // Destructor, Function, Operator, Typename, Variable
|
||||
union {
|
||||
AST* InlineCmt; // Class, Constructor, Destructor, Enum, Friend, Functon, Operator, OpCast, Struct, Typedef, Using, Variable
|
||||
AST* SpecsFuncSuffix; // Only used with typenames, to store the function suffix if typename is function signature.
|
||||
};
|
||||
AST* Attributes; // Class, Enum, Function, Struct, Typedef, Union, Using, Variable
|
||||
AST* Specs; // Destructor, Function, Operator, Typename, Variable
|
||||
union {
|
||||
AST* InitializerList; // Constructor
|
||||
AST* ParentType; // Class, Struct
|
||||
AST* ParentType; // Class, Struct, ParentType->Next has a possible list of interfaces.
|
||||
AST* ReturnType; // Function, Operator
|
||||
AST* UnderlyingType; // Enum, Typedef
|
||||
AST* ValueType; // Parameter, Variable
|
||||
@ -249,13 +247,13 @@ struct AST
|
||||
AST* Params; // Constructor, Function, Operator, Template
|
||||
};
|
||||
union {
|
||||
AST* ArrExpr; // Typename
|
||||
AST* Body; // Class, Constructr, Destructor, Enum, Function, Namespace, Struct, Union
|
||||
AST* Declaration; // Friend, Template
|
||||
AST* Value; // Parameter, Variable
|
||||
AST* ArrExpr; // Typename
|
||||
AST* Body; // Class, Constructr, Destructor, Enum, Function, Namespace, Struct, Union
|
||||
AST* Declaration; // Friend, Template
|
||||
AST* Value; // Parameter, Variable
|
||||
};
|
||||
};
|
||||
StringCached Content; // Attributes, Comment, Execution, Include
|
||||
StringCached Content; // Attributes, Comment, Execution, Include
|
||||
SpecifierT ArrSpecs[AST::ArrSpecs_Cap]; // Specifiers
|
||||
};
|
||||
union {
|
||||
@ -286,12 +284,15 @@ struct AST_POD
|
||||
union {
|
||||
struct
|
||||
{
|
||||
AST* InlineCmt; // Class, Constructor, Destructor, Enum, Friend, Functon, Operator, OpCast, Struct, Typedef, Using, Variable
|
||||
AST* Attributes; // Class, Enum, Function, Struct, Typename, Union, Using, Variable
|
||||
AST* Specs; // Function, Operator, Typename, Variable
|
||||
union {
|
||||
AST* InlineCmt; // Class, Constructor, Destructor, Enum, Friend, Functon, Operator, OpCast, Struct, Typedef, Using, Variable
|
||||
AST* SpecsFuncSuffix; // Only used with typenames, to store the function suffix if typename is function signature.
|
||||
};
|
||||
AST* Attributes; // Class, Enum, Function, Struct, Typename, Union, Using, Variable
|
||||
AST* Specs; // Function, Operator, Typename, Variable
|
||||
union {
|
||||
AST* InitializerList; // Constructor
|
||||
AST* ParentType; // Class, Struct
|
||||
AST* ParentType; // Class, Struct, ParentType->Next has a possible list of interfaces.
|
||||
AST* ReturnType; // Function, Operator
|
||||
AST* UnderlyingType; // Enum, Typedef
|
||||
AST* ValueType; // Parameter, Variable
|
||||
@ -301,13 +302,13 @@ struct AST_POD
|
||||
AST* Params; // Function, Operator, Template
|
||||
};
|
||||
union {
|
||||
AST* ArrExpr; // Type Symbol
|
||||
AST* Body; // Class, Constructr, Destructor, Enum, Function, Namespace, Struct, Union
|
||||
AST* Declaration; // Friend, Template
|
||||
AST* Value; // Parameter, Variable
|
||||
AST* ArrExpr; // Type Symbol
|
||||
AST* Body; // Class, Constructr, Destructor, Enum, Function, Namespace, Struct, Union
|
||||
AST* Declaration; // Friend, Template
|
||||
AST* Value; // Parameter, Variable
|
||||
};
|
||||
};
|
||||
StringCached Content; // Attributes, Comment, Execution, Include
|
||||
StringCached Content; // Attributes, Comment, Execution, Include
|
||||
SpecifierT ArrSpecs[AST::ArrSpecs_Cap]; // Specifiers
|
||||
};
|
||||
union {
|
||||
|
@ -472,11 +472,11 @@ struct AST_Type
|
||||
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ];
|
||||
struct
|
||||
{
|
||||
char _PAD_CMT_[ sizeof(AST*) ];
|
||||
CodeSpecifiers SpecsFuncSuffix; // Only used for function signatures
|
||||
CodeAttributes Attributes;
|
||||
CodeSpecifiers Specs;
|
||||
CodeType ReturnType; // Only used for function signatures
|
||||
CodeParam Params; // Only used for function signatures
|
||||
CodeType ReturnType; // Only used for function signatures
|
||||
CodeParam Params; // Only used for function signatures
|
||||
Code ArrExpr;
|
||||
};
|
||||
};
|
||||
|
@ -31,6 +31,7 @@ namespace ESpecifier
|
||||
Virtual,
|
||||
Const,
|
||||
Final,
|
||||
NoExceptions,
|
||||
Override,
|
||||
Pure,
|
||||
NumSpecifiers
|
||||
@ -67,6 +68,7 @@ namespace ESpecifier
|
||||
{ sizeof( "virtual" ), "virtual" },
|
||||
{ sizeof( "const" ), "const" },
|
||||
{ sizeof( "final" ), "final" },
|
||||
{ sizeof( "noexcept" ), "noexcept" },
|
||||
{ sizeof( "override" ), "override" },
|
||||
{ sizeof( "= 0" ), "= 0" },
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user