From b66826169d733848f7e34a9309d224a26589ea3f Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 20 May 2020 23:10:45 -0400 Subject: [PATCH] Internals: Refactor inherits/extends parse so don't need type vs nontype IDs. --- src/verilog.y | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/src/verilog.y b/src/verilog.y index 7b9ac13d3..9968a78fd 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -4456,6 +4456,11 @@ idAny: // Any kind of identifier | yaID__ETC { $$ = $1; $$=$1; } ; +idNonPkg: // Non-package identifier used by extents/implements + yaID__aTYPE { $$ = $1; $$=$1; } + | yaID__ETC { $$ = $1; $$=$1; } + ; + idRefDType: // IEEE: class_identifier or other type identifier // Used where reference is needed yaID__aTYPE { $$ = new AstRefDType($1, *$1); } @@ -5572,10 +5577,10 @@ classExtendsList: // IEEE: part of class_declaration ; classExtendsOne: // IEEE: part of class_declaration - class_typeWithoutId + class_typeExtImp { $$ = new AstClassExtends($1->fileline(), $1); } // // IEEE: Might not be legal to have more than one set of parameters in an extends - | class_typeWithoutId '(' list_of_argumentsE ')' + | class_typeExtImp '(' list_of_argumentsE ')' { $$ = new AstClassExtends($1->fileline(), $1); if ($3) BBUNSUP($3, "Unsupported: extends with parameters"); } ; @@ -5588,8 +5593,32 @@ classImplementsE: // IEEE: part of class_declaration classImplementsList: // IEEE: part of class_declaration // // All 1800-2012 - class_typeWithoutId { $$ = NULL; BBUNSUP($1, "Unsupported: implements class"); } - | classImplementsList ',' class_typeWithoutId { $$ = AstNode::addNextNull($1, $3); } + class_typeExtImp { $$ = NULL; BBUNSUP($1, "Unsupported: implements class"); } + | classImplementsList ',' class_typeExtImp { $$ = AstNode::addNextNull($1, $3); } + ; + +class_typeExtImp: // as with class_typeWithoutId but from extends/implements + // // and we thus don't need to resolve it in specified package + class_typeExtImpOneList { $$ = $1; } + | package_scopeIdFollows class_typeExtImpOneList { $$ = $2; $2->packagep($1); } + ; + +class_typeExtImpOneList: // IEEE: class_type: "id [ parameter_value_assignment ]" + // // but allow yaID__aTYPE for extends/implements + // // If you follow the rules down, class_type is really a list via ps_class_identifier + // // Must propagate scp up for next id + class_typeExtImpOne { $$ = $1; } + | class_typeExtImpOneList yP_COLONCOLON class_typeExtImpOne + { $$ = $3; BBUNSUP($2, "Unsupported: Hierarchical class references"); } + ; + +class_typeExtImpOne: // IEEE: class_type: "id [ parameter_value_assignment ]" + // // but allow yaID__aTYPE for extends/implements + // // If you follow the rules down, class_type is really a list via ps_class_identifier + // // Not listed in IEEE, but see bug627 any parameter type maybe a class + idNonPkg parameter_value_assignmentE + { $$ = new AstRefDType($1, *$1); + if ($2) BBUNSUP($2->fileline(), "Unsupported: Parameterized classes"); } ; //========= @@ -5608,12 +5637,8 @@ ps_type: // IEEE: ps_parameter_identifier | ps_type_identifier // // Simplify typing - from ps_covergroup_identifier ; -//=== Below rules assume special scoping per above -class_typeWithoutId: // as with class_typeWithoutId but allow yaID__aTYPE - // // and we thus don't need to resolve it in specified package - package_scopeIdFollowsE class_typeOneList { $$ = $2; $2->packagep($1); } - ; +//=== Below rules assume special scoping per above class_scopeWithoutId: // class_type standalone without following id // // and we thus don't need to resolve it in specified package