Should support parsing full definitions within typedef... (need to make tests)

This commit is contained in:
Edward R. Gonzalez 2023-07-23 23:28:21 -04:00
parent 80b5c9768d
commit 5df21998ef
2 changed files with 22 additions and 5 deletions

View File

@ -691,7 +691,6 @@ Names or Content fields are interned strings and thus showed be cached using `ge
# TODO
* Support defining & parsing full definitions inside a typedef. (For C patterns)
* Implement a context stack for the parsing, allows for accurate scope validation for the AST types.
* Trailing specifiers ( postfix ) for functions (const, override, final)
* Make a more robust test suite.

View File

@ -2530,13 +2530,28 @@ CodeType def_type( StrC name, Code arrayexpr, CodeSpecifier specifiers, CodeAttr
CodeTypedef def_typedef( StrC name, Code type, CodeAttributes attributes, ModuleFlag mflags )
{
using namespace ECode;
name_check( def_typedef, name );
null_check( def_typedef, type );
if ( type->Type != ECode::Typename )
switch ( type->Type )
{
log_failure( "gen::def_typedef: type was not a Typename - %s", type.debug_str() );
return CodeInvalid;
case Class:
case Class_Fwd:
case Enum:
case Enum_Fwd:
case Enum_Class:
case Enum_Class_Fwd:
case Function_Fwd:
case Struct:
case Struct_Fwd:
case Union:
case Typename:
break;
default:
log_failure( "gen::def_typedef: type was not a Class, Enum, Function Forward, Struct, Typename, or Union - %s", type.debug_str() );
return CodeInvalid;
}
if ( attributes && attributes->Type != ECode::PlatformAttributes )
@ -6116,8 +6131,11 @@ CodeTypedef parse_typedef( Parser::TokArray& toks, char const* context )
if ( check( TokType::Decl_Enum ) )
type = parse_enum( toks, context );
else if ( check(TokType::Decl_Class ) )
type = parse_class( toks, context );
else if ( check(TokType::Decl_Struct ) )
type = parse_enum( toks, context );
type = parse_struct( toks, context );
else if ( check(TokType::Decl_Union) )
type = parse_union( toks, context );