📄 vparsebison.y
字号:
| yASSIGN expr '=' delayOrEvE expr ';' { } | yDEASSIGN variable_lvalue ';' { } | yFORCE expr '=' expr ';' { } | yRELEASE variable_lvalue ';' { } // // IEEE: case_statement | caseStart caseAttrE case_itemListE yENDCASE { } // // IEEE: conditional_statement | unique_priorityE yIF '(' expr ')' stmtBlock %prec prLOWER_THAN_ELSE { } | unique_priorityE yIF '(' expr ')' stmtBlock yELSE stmtBlock { } // | varRefDotBit yP_PLUSPLUS { } | varRefDotBit yP_MINUSMINUS { } | yP_PLUSPLUS varRefDotBit { } | yP_MINUSMINUS varRefDotBit { } // // IEEE: subroutine_call_statement (INCOMPLETE) | taskRef ';' { } // | ygenSYSCALL '(' ')' ';' { } | ygenSYSCALL '(' exprList ')' ';' { } | ygenSYSCALL ';' { } | delay_control stmtBlock { } | event_control stmtBlock { } // // IEEE: disable_statement | yDISABLE expr ';' { } | yDISABLE yFORK ';' { } // // IEEE: event_trigger | yP_MINUSGT expr ';' { } | yP_MINUSGTGT expr ';' { } // // IEEE: loop_statement (INCOMPLETE) | yFOREVER stmtBlock { } | yREPEAT '(' expr ')' stmtBlock { } | yWHILE '(' expr ')' stmtBlock { } | yFOR '(' variable_lvalue '=' expr ';' expr ';' variable_lvalue '=' expr ')' stmtBlock | yDO stmtBlock yWHILE '(' expr ')' { }// | yFOREACH ( varRefDotBit [ loop_variables ] ) stmt { } // // IEEE: jump_statement | yRETURN ';' { } | yRETURN expr ';' { } | yBREAK ';' { } | yCONTINUE ';' { } // // IEEE: wait_statement | yWAIT '(' expr ')' stmtBlock { } // // IEEE: randcase_statement | yRANDCASE case_itemList yENDCASE { } // | error ';' { } ;//************************************************// Case/Ifunique_priorityE: // IEEE: unique_priority + empty /*empty*/ { } | yPRIORITY { } | yUNIQUE { } ;caseStart: // IEEE: part of case_statement unique_priorityE yCASE '(' expr ')' { } | unique_priorityE yCASEX '(' expr ')' { } | unique_priorityE yCASEZ '(' expr ')' { } ;caseAttrE: /*empty*/ { } ;case_itemListE: // IEEE: [ { case_item } ] /* empty */ { } | case_itemList { } ;case_itemList: // IEEE: { case_item + ... } caseCondList ':' stmtBlock { } | yDEFAULT ':' stmtBlock { } | yDEFAULT stmtBlock { } | case_itemList caseCondList ':' stmtBlock { } | case_itemList yDEFAULT stmtBlock { } | case_itemList yDEFAULT ':' stmtBlock { } ;caseCondList: // IEEE: part of case_item expr { } | caseCondList ',' expr { } ;//************************************************// Functions/taskstaskRef: // IEEE: part of tf_call idDotted { } | idDotted '(' exprList ')' { } ;funcRef<str>: // IEEE: part of tf_call idDotted '(' exprList ')' { $1+"("+$3+")"; } ;task_declaration: // ==IEEE: task_declaration yTASK lifetimeE taskId tfGuts yENDTASK endLabelE { GRAMMARP->m_inFTask=false; PARSEP->endtaskfuncCb($<fl>5,$5); } ;function_declaration: // IEEE: function_declaration + function_body_declaration yFUNCTION lifetimeE funcId tfGuts yENDFUNCTION endLabelE { GRAMMARP->m_inFTask=false; PARSEP->endtaskfuncCb($<fl>5,$5); } ;lifetimeE: // IEEE: lifetime - plus empty /* empty */ { } | ySTATIC { } | yAUTOMATIC { } ;taskId: yaID { GRAMMARP->m_inFTask=true; PARSEP->taskCb($<fl>1,"task",$1); } ;funcId: // IEEE: function_data_type_or_implicit + part of function_body_declaration funcTypeE yaID { GRAMMARP->m_inFTask=true; PARSEP->functionCb($<fl>2,"function",$2,$1); } | ySIGNED funcTypeE yaID { GRAMMARP->m_inFTask=true; PARSEP->functionCb($<fl>3,"function",$3,"signed "+$2); } ;tfGuts: '(' {GRAMMARP->pinNum(1);} portV2kArgs ')' ';' tfBody { } | ';' tfBody { } ;tfBody: // IEEE: part of function_body_declaration/task_body_declaration funcVarList stmtBlock { } | stmtBlock { } ;funcTypeE<str>: /* empty */ { $$ = ""; } | varTypeKwds { $$ = $1; } | '[' constExpr ':' constExpr ']' { $$ = "["+$2+":"+$4+"]"; } ;funcVarList: funcVar { } | funcVarList funcVar { } ;funcVar: portDecl { } | varDecl { } ;//************************************************// ExpressionsconstExpr<str>: expr { $<fl>$=$<fl>1; $$ = $1; } ;exprNoStr<str>: expr yP_OROR expr { $<fl>$=$<fl>1; $$ = $1+$2+$3; } | expr yP_ANDAND expr { $<fl>$=$<fl>1; $$ = $1+$2+$3; } | expr '&' expr { $<fl>$=$<fl>1; $$ = $1+$2+$3; } | expr '|' expr { $<fl>$=$<fl>1; $$ = $1+$2+$3; } | expr yP_NAND expr { $<fl>$=$<fl>1; $$ = $1+$2+$3; } | expr yP_NOR expr { $<fl>$=$<fl>1; $$ = $1+$2+$3; } | expr '^' expr { $<fl>$=$<fl>1; $$ = $1+$2+$3; } | expr yP_XNOR expr { $<fl>$=$<fl>1; $$ = $1+$2+$3; } | expr yP_EQUAL expr { $<fl>$=$<fl>1; $$ = $1+$2+$3; } | expr yP_NOTEQUAL expr { $<fl>$=$<fl>1; $$ = $1+$2+$3; } | expr yP_CASEEQUAL expr { $<fl>$=$<fl>1; $$ = $1+$2+$3; } | expr yP_CASENOTEQUAL expr { $<fl>$=$<fl>1; $$ = $1+$2+$3; } | expr yP_WILDEQUAL expr { $<fl>$=$<fl>1; $$ = $1+$2+$3; } | expr yP_WILDNOTEQUAL expr { $<fl>$=$<fl>1; $$ = $1+$2+$3; } | expr '>' expr { $<fl>$=$<fl>1; $$ = $1+$2+$3; } | expr '<' expr { $<fl>$=$<fl>1; $$ = $1+$2+$3; } | expr yP_GTE expr { $<fl>$=$<fl>1; $$ = $1+$2+$3; } | expr yP_LTE expr { $<fl>$=$<fl>1; $$ = $1+$2+$3; } | expr yP_SLEFT expr { $<fl>$=$<fl>1; $$ = $1+$2+$3; } | expr yP_SRIGHT expr { $<fl>$=$<fl>1; $$ = $1+$2+$3; } | expr yP_SSRIGHT expr { $<fl>$=$<fl>1; $$ = $1+$2+$3; } | expr '+' expr { $<fl>$=$<fl>1; $$ = $1+$2+$3; } | expr '-' expr { $<fl>$=$<fl>1; $$ = $1+$2+$3; } | expr '*' expr { $<fl>$=$<fl>1; $$ = $1+$2+$3; } | expr '/' expr { $<fl>$=$<fl>1; $$ = $1+$2+$3; } | expr '%' expr { $<fl>$=$<fl>1; $$ = $1+$2+$3; } | expr yP_POW expr { $<fl>$=$<fl>1; $$ = $1+$2+$3; } // | '-' expr %prec prUNARYARITH { $<fl>$=$<fl>1; $$ = $1+$2; } | '+' expr %prec prUNARYARITH { $<fl>$=$<fl>1; $$ = $1+$2; } | '&' expr %prec prREDUCTION { $<fl>$=$<fl>1; $$ = $1+$2; } | '|' expr %prec prREDUCTION { $<fl>$=$<fl>1; $$ = $1+$2; } | '^' expr %prec prREDUCTION { $<fl>$=$<fl>1; $$ = $1+$2; } | yP_XNOR expr %prec prREDUCTION { $<fl>$=$<fl>1; $$ = $1+$2; } | yP_NAND expr %prec prREDUCTION { $<fl>$=$<fl>1; $$ = $1+$2; } | yP_NOR expr %prec prREDUCTION { $<fl>$=$<fl>1; $$ = $1+$2; } | '!' expr %prec prNEGATION { $<fl>$=$<fl>1; $$ = $1+$2; } | '~' expr %prec prNEGATION { $<fl>$=$<fl>1; $$ = $1+$2; } // | varRefDotBit yP_PLUSPLUS { $<fl>$=$<fl>1; $$ = $1+$2; } | varRefDotBit yP_MINUSMINUS { $<fl>$=$<fl>1; $$ = $1+$2; } | yP_PLUSPLUS varRefDotBit { $<fl>$=$<fl>1; $$ = $1+$2; } | yP_MINUSMINUS varRefDotBit { $<fl>$=$<fl>1; $$ = $1+$2; } // | expr '?' expr ':' expr { $<fl>$=$<fl>1; $$ = $1+"?"+$3+":"+$5; } | '(' expr ')' { $<fl>$=$<fl>1; $$ = "("+$2+")"; } | '_' '(' statePushVlg expr statePop ')' { $<fl>$=$<fl>1; $$ = "_("+$4+")"; } // Arbitrary Verilog inside PSL // // // IEEE: concatenation/constant_concatenation | '{' cateList '}' { $<fl>$=$<fl>1; $$ = "{"+$2+"}"; } | '{' constExpr '{' cateList '}' '}' { $<fl>$=$<fl>1; $$ = "{"+$2+"{"+$4+"}}"; } // | ygenSYSCALL { $<fl>$=$<fl>1; $$ = $1; } | ygenSYSCALL '(' ')' { $<fl>$=$<fl>1; $$ = $1; } | ygenSYSCALL '(' exprList ')' { $<fl>$=$<fl>1; $$ = $1+"("+$3+")"; } // | funcRef { $<fl>$=$<fl>1; $$ = $1; } // | yaINTNUM { $<fl>$=$<fl>1; $$ = $1; } | yaFLOATNUM { $<fl>$=$<fl>1; $$ = $1; } | yaTIMENUM { $<fl>$=$<fl>1; $$ = $1; } // | varRefDotBit { $<fl>$=$<fl>1; $$ = $1; } ;// Generic expressionsexpr<str>: exprNoStr { $<fl>$=$<fl>1; $$ = $1; } | strAsInt { $<fl>$=$<fl>1; $$ = $1; } ;cateList<str>: expr { $<fl>$=$<fl>1; $$ = $1; } | cateList ',' expr { $<fl>$=$<fl>1; $$ = $1+","+$3; } ;exprList<str>: expr { $<fl>$=$<fl>1; $$ = $1; } | exprList ',' expr { $<fl>$=$<fl>1; $$ = $1+","+$3; } | exprList ',' { $<fl>$=$<fl>1; $$ = $1+","; } // Verilog::Parser only: ,, is ok ;//************************************************// Gate declarations// We can't tell between UDPs and modules as they aren't declared yet.// For simplicity, assume everything is a module, perhaps nameless,// and deal with it later.// IEEE: cmos_switchtype + enable_gatetype + mos_switchtype// + n_input_gatetype + n_output_gatetype + pass_en_switchtype// + pass_switchtypegateKwd<str>: ygenGATE { $<fl>$=$<fl>1; INSTPREP($1,0); } | yAND { $<fl>$=$<fl>1; INSTPREP($1,0); } | yBUF { $<fl>$=$<fl>1; INSTPREP($1,0); } | yNAND { $<fl>$=$<fl>1; INSTPREP($1,0); } | yNOR { $<fl>$=$<fl>1; INSTPREP($1,0); } | yNOT { $<fl>$=$<fl>1; INSTPREP($1,0); } | yOR { $<fl>$=$<fl>1; INSTPREP($1,0); } | yXNOR { $<fl>$=$<fl>1; INSTPREP($1,0); } | yXOR { $<fl>$=$<fl>1; INSTPREP($1,0); } ;// This list is also hardcoded in VParseLex.lstrength: // IEEE: strength0+strength1 - plus HIGHZ/SMALL/MEDIUM/LARGE ygenSTRENGTH { } | ySUPPLY0 { } | ySUPPLY1 { } ;strengthSpecE: // IEEE: drive_strength + pullup_strength + pulldown_strength + charge_strength - plus empty /* empty */ { } | yP_PAR__STRENGTH strength ')' { } | yP_PAR__STRENGTH strength ',' strength ')' { } ;//************************************************// Tablescombinational_body: // ==IEEE: combinational_body yTABLE tableJunkList yENDTABLE { } ;tableJunkList: tableJunk { } /* ignored */ | tableJunkList tableJunk { } /* ignored */ ;tableJunk: BISONPRE_NOT(yTABLE,yENDTABLE) { } | yTABLE tableJunk yENDTABLE { } | error {} ;//************************************************// Specifyspecify_block: // ==IEEE: specify_block ySPECIFY specifyJunkList yENDSPECIFY { } | ySPECIFY yENDSPECIFY { } ;specifyJunkList: specifyJunk { } /* ignored */ | specifyJunkList specifyJunk { } /* ignored */ ;specifyJunk: BISONPRE_NOT(ySPECIFY,yENDSPECIFY) { } | ySPECIFY specifyJunk yENDSPECIFY { } | error {} ;//************************************************// IDs// VarRef to dotted, and/or arrayed, and/or bit-ranged variablevarRefDotBit<str>: idDotted { $<fl>$=$<fl>1; $$ = $1; } ;idDotted<str>: idArrayed { $<fl>$=$<fl>1; $$ = $1; } | idDotted '.' idArrayed { $<fl>$=$<fl>1; $$ = $1+"."+$3; } ;// Single component of dotted path, maybe [#].// Due to lookahead constraints, we can't know if [:] or [+:] are valid (last dotted part),// we'll assume so and cleanup later.idArrayed<str>: yaID { $<fl>$=$<fl>1; $$ = $1; } | yaID yP_COLONCOLON { PARSEP->importCb($<fl>1,$1); $<fl>$=$<fl>1; $$ = $1+"::"; } // // IEEE: id + part_select_range/constant_part_select_range | idArrayed '[' expr ']' { $<fl>$=$<fl>1; $$ = $1+"["+$3+"]"; } | idArrayed '[' constExpr ':' constExpr ']' { $<fl>$=$<fl>1; $$ = $1+"["+$3+":"+$5+"]"; } // // IEEE: id + indexed_range/constant_indexed_range | idArrayed '[' expr yP_PLUSCOLON constExpr ']' { $<fl>$=$<fl>1; $$ = $1+"["+$3+"+:"+$5+"]"; } | idArrayed '[' expr yP_MINUSCOLON constExpr ']' { $<fl>$=$<fl>1; $$ = $1+"["+$3+"-:"+$5+"]"; } ;// VarRef without any dots or vectorizaionvarRefBase<str>: yaID { $<fl>$=$<fl>1; $$ = $1; } ;strAsInt<str>: yaSTRING { $<fl>$=$<fl>1; $$ = $1; } ;endLabelE: /* empty */ { } | ':' yaID { } ;//************************************************// AssertslabeledStmt: assertStmt { } ;clocking_declaration: // IEEE: clocking_declaration (INCOMPLETE) yDEFAULT yCLOCKING '@' '(' senList ')' ';' yENDCLOCKING { } ;concurrent_assertion_item: // IEEE: concurrent_assertion_item concurrent_assertion_statement { } | yaID ':' concurrent_assertion_statement { } ;concurrent_assertion_statement: // IEEE: concurrent_assertion_statement (INCOMPLETE) cover_property_statement { } ;cover_property_statement: // IEEE: cover_property_statement yCOVER yPROPERTY '(' property_spec ')' stmtBlock { } ;property_spec: // IEEE: property_spec '@' '(' senitemEdge ')' property_spec_disable expr { } | property_spec_disable expr { } ;property_spec_disable: /* empty */ { } | yDISABLE yIFF '(' expr ')' { } ;assertStmt: yASSERT '(' expr ')' stmtBlock %prec prLOWER_THAN_ELSE { } | yASSERT '(' expr ')' yELSE stmtBlock { } | yASSERT '(' expr ')' stmtBlock yELSE stmtBlock { } ;//**********************************************************************// Classclass_declaration: // ==IEEE: part of class_declaration (INCOMPLETE) classHeader parameter_port_listE classExtendsE ';' class_itemListE yENDCLASS endLabelE { } ;classHeader: // IEEE: part of class_declaration yVIRTUAL__CLASS yCLASS lifetimeE yaID { } | yCLASS lifetimeE yaID { } ;classExtendsE: // IEEE: part of class_declaration /* empty */ { } | yEXTENDS yaID { }// | yEXTENDS yaID '(' list_of_arguments ')' { } ;class_itemListE: /* empty */ { } | class_itemList { } ;class_itemList: class_item { } | class_itemList class_item { } ;class_item: // ==IEEE: class_item (UNSUPPORTED) BISONPRE_NOT(yCLASS,yENDCLASS) { } | yCLASS class_itemListE yENDCLASS { } ;//**********************************************************************%%int VParseGrammar::parse() { s_grammarp = this; return VParseBisonparse();}void VParseGrammar::debug(int level) { VParseBisondebug = level;}const char* VParseGrammar::tokenName(int token) {#if YYDEBUG || YYERROR_VERBOSE if (token >= 255) return yytname[token-255]; else { static char ch[2]; ch[0]=token; ch[1]='\0'; return ch; }#else return "";#endif}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -