forked from github/verilator
WIP - type compare case grammar
This commit is contained in:
parent
14285f24cd
commit
2de586e678
@ -3024,6 +3024,18 @@ public:
|
||||
void priorityPragma(bool flag) { m_priorityPragma = flag; }
|
||||
};
|
||||
|
||||
class AstTypeCase : public AstNodeCase {
|
||||
// Case statement for type references
|
||||
// Parents: {statement list}
|
||||
// exprp Children: MATHs
|
||||
// casesp Children: CASEITEMs
|
||||
public:
|
||||
AstTypeCase(FileLine* fl, AstNodeDType* typep, AstNode* casesp)
|
||||
: ASTGEN_SUPER(fl, typep, casesp) { }
|
||||
ASTNODE_NODE_FUNCS(TypeCase)
|
||||
virtual string verilogKwd() const { return "case"; }
|
||||
};
|
||||
|
||||
class AstCaseItem : public AstNode {
|
||||
// Single item of a case statement
|
||||
// Parents: CASE
|
||||
|
@ -2708,6 +2708,7 @@ statement_item<nodep>: // IEEE: statement_item
|
||||
if ($1 == uniq_UNIQUE) $2->uniquePragma(true);
|
||||
if ($1 == uniq_UNIQUE0) $2->unique0Pragma(true);
|
||||
if ($1 == uniq_PRIORITY) $2->priorityPragma(true); }
|
||||
| typeCaseStart typeCase_itemListE yENDCASE { $$ = $1; if ($2) $1->addItemsp($2); }
|
||||
//
|
||||
// // IEEE: conditional_statement
|
||||
| unique_priorityE yIF '(' expr ')' stmtBlock %prec prLOWER_THAN_ELSE
|
||||
@ -2929,6 +2930,10 @@ caseStart<casep>: // IEEE: part of case_statement
|
||||
| yCASEZ '(' expr ')' { $$ = GRAMMARP->m_caseAttrp = new AstCase($1,VCaseType::CT_CASEZ,$3,NULL); }
|
||||
;
|
||||
|
||||
typeCaseStart<casep>: // IEEE: part of case_statement
|
||||
yCASE '(' type_reference ')' { $$ = new AstTypeCase($1,$3,NULL); }
|
||||
;
|
||||
|
||||
caseAttrE:
|
||||
/*empty*/ { }
|
||||
| caseAttrE yVL_FULL_CASE { GRAMMARP->m_caseAttrp->fullPragma(true); }
|
||||
@ -2945,6 +2950,11 @@ case_itemListE<caseitemp>: // IEEE: [ { case_item } ]
|
||||
| case_itemList { $$ = $1; }
|
||||
;
|
||||
|
||||
typeCase_itemListE<caseitemp>: // IEEE: [ { case_item } ]
|
||||
/* empty */ { $$ = NULL; }
|
||||
| typeCase_itemList { $$ = $1; }
|
||||
;
|
||||
|
||||
case_insideListE<caseitemp>: // IEEE: [ { case_inside_item } ]
|
||||
/* empty */ { $$ = NULL; }
|
||||
| case_inside_itemList { $$ = $1; }
|
||||
@ -2952,11 +2962,21 @@ case_insideListE<caseitemp>: // IEEE: [ { case_inside_item } ]
|
||||
|
||||
case_itemList<caseitemp>: // IEEE: { case_item + ... }
|
||||
caseCondList ':' stmtBlock { $$ = new AstCaseItem($2,$1,$3); }
|
||||
| yDEFAULT ':' stmtBlock { $$ = new AstCaseItem($1,NULL,$3); }
|
||||
| yDEFAULT stmtBlock { $$ = new AstCaseItem($1,NULL,$2); }
|
||||
| case_defaultItem { $$ = $1; }
|
||||
| case_itemList caseCondList ':' stmtBlock { $$ = $1;$1->addNext(new AstCaseItem($3,$2,$4)); }
|
||||
| case_itemList yDEFAULT stmtBlock { $$ = $1;$1->addNext(new AstCaseItem($2,NULL,$3)); }
|
||||
| case_itemList yDEFAULT ':' stmtBlock { $$ = $1;$1->addNext(new AstCaseItem($2,NULL,$4)); }
|
||||
| case_itemList case_defaultItem { $$ = $1;$1->addNext($2); }
|
||||
;
|
||||
|
||||
case_defaultItem<caseitemp>:
|
||||
yDEFAULT ':' stmtBlock { $$ = new AstCaseItem($1,NULL,$3); }
|
||||
| yDEFAULT stmtBlock { $$ = new AstCaseItem($1,NULL,$2); }
|
||||
;
|
||||
|
||||
typeCase_itemList<caseitemp>: // IEEE: { case_item + ... } but for type references
|
||||
typeCaseCondList ':' stmtBlock { $$ = new AstCaseItem($2,$1,$3); }
|
||||
| case_defaultItem { $$ = $1; }
|
||||
| typeCase_itemList typeCaseCondList ':' stmtBlock { $$ = $1;$1->addNext(new AstCaseItem($3,$2,$4)); }
|
||||
| typeCase_itemList case_defaultItem { $$ = $1;$1->addNext($2); }
|
||||
;
|
||||
|
||||
case_inside_itemList<caseitemp>: // IEEE: { case_inside_item + open_range_list ... }
|
||||
@ -2992,6 +3012,11 @@ caseCondList<nodep>: // IEEE: part of case_item
|
||||
| caseCondList ',' expr { $$ = $1;$1->addNext($3); }
|
||||
;
|
||||
|
||||
typeCaseCondList<nodep>: // IEEE: also part of case_item
|
||||
type_reference { $$ = $1; }
|
||||
| typeCaseCondList ',' type_reference { $$ = $1;$1->addNext($3); }
|
||||
;
|
||||
|
||||
patternNoExpr<nodep>: // IEEE: pattern **Excluding Expr*
|
||||
'.' id/*variable*/ { $$ = NULL; $1->v3error("Unsupported: '{} tagged patterns"); }
|
||||
| yP_DOTSTAR { $$ = NULL; $1->v3error("Unsupported: '{} tagged patterns"); }
|
||||
|
Loading…
Reference in New Issue
Block a user