1 // -*- mode: C++; c-file-style: "cc-mode" -*-
2 //*************************************************************************
3 // DESCRIPTION: Verilator: Bison grammer file
4 //
5 // Code available from: https://verilator.org
6 //
7 //*************************************************************************
8 //
9 // Copyright 2003-2021 by Wilson Snyder. This program is free software; you
10 // can redistribute it and/or modify it under the terms of either the GNU
11 // Lesser General Public License Version 3 or the Perl Artistic License
12 // Version 2.0.
13 // SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
14 //
15 //*************************************************************************
16 // Original code here by Paul Wasson and Duane Galbi
17 //*************************************************************************
18 // clang-format off
19
20 %{
21 #ifdef NEVER_JUST_FOR_CLANG_FORMAT
22 }
23 #endif
24 // clang-format on
25 #include "V3Ast.h"
26 #include "V3Global.h"
27 #include "V3Config.h"
28 #include "V3ParseImp.h" // Defines YYTYPE; before including bison header
29
30 #include <cstdlib>
31 #include <cstdarg>
32 #include <stack>
33
34 #define YYINITDEPTH 10000 // Older bisons ignore YYMAXDEPTH
35 #define YYMAXDEPTH 10000
36
37 // Pick up new lexer
38 #define yylex PARSEP->tokenToBison
39 #define BBUNSUP(fl, msg) (fl)->v3warn(E_UNSUPPORTED, msg)
40 #define GATEUNSUP(fl, tok) \
41 { BBUNSUP((fl), "Unsupported: Verilog 1995 gate primitive: " << (tok)); }
42
43 //======================================================================
44 // Statics (for here only)
45
46 #define PARSEP V3ParseImp::parsep()
47 #define SYMP PARSEP->symp()
48 #define GRAMMARP V3ParseGrammar::singletonp()
49
50 class V3ParseGrammar {
51 public:
52 bool m_impliedDecl = false; // Allow implied wire declarations
53 AstVarType m_varDecl; // Type for next signal declaration (reg/wire/etc)
54 bool m_varDeclTyped = false; // Var got reg/wire for dedup check
55 VDirection m_varIO; // Direction for next signal declaration (reg/wire/etc)
56 VLifetime m_varLifetime; // Static/Automatic for next signal
57 AstVar* m_varAttrp = nullptr; // Current variable for attribute adding
58 AstRange* m_gateRangep = nullptr; // Current range for gate declarations
59 AstCase* m_caseAttrp = nullptr; // Current case statement for attribute adding
60 AstNodeDType* m_varDTypep = nullptr; // Pointer to data type for next signal declaration
61 AstNodeDType* m_memDTypep = nullptr; // Pointer to data type for next member declaration
62 AstNodeModule* m_modp = nullptr; // Last module for timeunits
63 bool m_pinAnsi = false; // In ANSI port list
64 FileLine* m_instModuleFl = nullptr; // Fileline of module referenced for instantiations
65 string m_instModule; // Name of module referenced for instantiations
66 AstPin* m_instParamp = nullptr; // Parameters for instantiations
67 bool m_tracingParse = true; // Tracing disable for parser
68
69 int m_pinNum = -1; // Pin number currently parsing
70 std::stack<int> m_pinStack; // Queue of pin numbers being parsed
71
72 static int s_modTypeImpNum; // Implicit type number, incremented each module
73
74 // CONSTRUCTORS
V3ParseGrammar()75 V3ParseGrammar() {
76 m_varDecl = AstVarType::UNKNOWN;
77 m_varIO = VDirection::NONE;
78 }
singletonp()79 static V3ParseGrammar* singletonp() {
80 static V3ParseGrammar singleton;
81 return &singleton;
82 }
83
84 // METHODS
85 AstNode* argWrapList(AstNode* nodep);
allTracingOn(FileLine * fl)86 bool allTracingOn(FileLine* fl) {
87 return v3Global.opt.trace() && m_tracingParse && fl->tracingOn();
88 }
89 AstRange* scrubRange(AstNodeRange* rangep);
90 AstNodeDType* createArray(AstNodeDType* basep, AstNodeRange* rangep, bool isPacked);
91 AstVar* createVariable(FileLine* fileline, const string& name, AstNodeRange* arrayp,
92 AstNode* attrsp);
93 AstNode* createSupplyExpr(FileLine* fileline, const string& name, int value);
createTextQuoted(FileLine * fileline,const string & text)94 AstText* createTextQuoted(FileLine* fileline, const string& text) {
95 string newtext = deQuote(fileline, text);
96 return new AstText(fileline, newtext);
97 }
createDisplayError(FileLine * fileline)98 AstDisplay* createDisplayError(FileLine* fileline) {
99 AstDisplay* nodep
100 = new AstDisplay(fileline, AstDisplayType::DT_ERROR, "", nullptr, nullptr);
101 nodep->addNext(new AstStop(fileline, true));
102 return nodep;
103 }
createGatePin(AstNode * exprp)104 AstNode* createGatePin(AstNode* exprp) {
105 AstRange* const rangep = m_gateRangep;
106 if (!rangep) {
107 return exprp;
108 } else {
109 return new AstGatePin(rangep->fileline(), exprp, rangep->cloneTree(true));
110 }
111 }
createTypedef(FileLine * fl,const string & name,AstNode * attrsp,AstNodeDType * basep,AstNodeRange * rangep)112 AstNode* createTypedef(FileLine* fl, const string& name, AstNode* attrsp, AstNodeDType* basep,
113 AstNodeRange* rangep) {
114 AstNode* const nodep = new AstTypedef{fl, name, attrsp, VFlagChildDType{},
115 GRAMMARP->createArray(basep, rangep, false)};
116 SYMP->reinsert(nodep);
117 PARSEP->tagNodep(nodep);
118 return nodep;
119 }
createTypedefFwd(FileLine * fl,const string & name)120 AstNode* createTypedefFwd(FileLine* fl, const string& name) {
121 AstNode* const nodep = new AstTypedefFwd{fl, name};
122 SYMP->reinsert(nodep);
123 PARSEP->tagNodep(nodep);
124 return nodep;
125 }
endLabel(FileLine * fl,AstNode * nodep,string * endnamep)126 void endLabel(FileLine* fl, AstNode* nodep, string* endnamep) {
127 endLabel(fl, nodep->prettyName(), endnamep);
128 }
endLabel(FileLine * fl,const string & name,string * endnamep)129 void endLabel(FileLine* fl, const string& name, string* endnamep) {
130 if (fl && endnamep && *endnamep != "" && name != *endnamep
131 && name != AstNode::prettyName(*endnamep)) {
132 fl->v3warn(ENDLABEL, "End label '" << *endnamep << "' does not match begin label '"
133 << name << "'");
134 }
135 }
setVarDecl(AstVarType type)136 void setVarDecl(AstVarType type) { m_varDecl = type; }
setDType(AstNodeDType * dtypep)137 void setDType(AstNodeDType* dtypep) {
138 if (m_varDTypep) VL_DO_CLEAR(m_varDTypep->deleteTree(), m_varDTypep = nullptr);
139 m_varDTypep = dtypep;
140 }
pinPush()141 void pinPush() {
142 m_pinStack.push(m_pinNum);
143 m_pinNum = 1;
144 }
pinPop(FileLine * fl)145 void pinPop(FileLine* fl) {
146 if (VL_UNCOVERABLE(m_pinStack.empty())) { fl->v3fatalSrc("Underflow of pin stack"); }
147 m_pinNum = m_pinStack.top();
148 m_pinStack.pop();
149 }
addRange(AstBasicDType * dtypep,AstNodeRange * rangesp,bool isPacked)150 AstNodeDType* addRange(AstBasicDType* dtypep, AstNodeRange* rangesp, bool isPacked) {
151 // If dtypep isn't basic, don't use this, call createArray() instead
152 if (!rangesp) {
153 return dtypep;
154 } else {
155 // If rangesp is "wire [3:3][2:2][1:1] foo [5:5][4:4]"
156 // then [1:1] becomes the basicdtype range; everything else is arraying
157 // the final [5:5][4:4] will be passed in another call to createArray
158 AstNodeRange* rangearraysp = nullptr;
159 if (dtypep->isRanged()) {
160 rangearraysp = rangesp; // Already a range; everything is an array
161 } else {
162 AstNodeRange* finalp = rangesp;
163 while (finalp->nextp()) finalp = VN_CAST(finalp->nextp(), Range);
164 if (finalp != rangesp) {
165 finalp->unlinkFrBack();
166 rangearraysp = rangesp;
167 }
168 if (AstRange* const finalRangep = VN_CAST(finalp, Range)) { // not an UnsizedRange
169 if (dtypep->implicit()) {
170 // It's no longer implicit but a wire logic type
171 AstBasicDType* const newp = new AstBasicDType{
172 dtypep->fileline(), AstBasicDTypeKwd::LOGIC, dtypep->numeric(),
173 dtypep->width(), dtypep->widthMin()};
174 VL_DO_DANGLING(dtypep->deleteTree(), dtypep);
175 dtypep = newp;
176 }
177 dtypep->rangep(finalRangep);
178 }
179 }
180 return createArray(dtypep, rangearraysp, isPacked);
181 }
182 }
183 string deQuote(FileLine* fileline, string text);
checkDpiVer(FileLine * fileline,const string & str)184 void checkDpiVer(FileLine* fileline, const string& str) {
185 if (str != "DPI-C" && !v3Global.opt.bboxSys()) {
186 fileline->v3error("Unsupported DPI type '" << str << "': Use 'DPI-C'");
187 }
188 }
189 };
190
191 const AstBasicDTypeKwd LOGIC = AstBasicDTypeKwd::LOGIC; // Shorthand "LOGIC"
192 const AstBasicDTypeKwd LOGIC_IMPLICIT = AstBasicDTypeKwd::LOGIC_IMPLICIT;
193
194 int V3ParseGrammar::s_modTypeImpNum = 0;
195
196 //======================================================================
197 // Macro functions
198
199 #define CRELINE() \
200 (PARSEP->copyOrSameFileLine()) // Only use in empty rules, so lines point at beginnings
201 #define FILELINE_OR_CRE(nodep) ((nodep) ? (nodep)->fileline() : CRELINE())
202
203 #define VARRESET_LIST(decl) \
204 { \
205 GRAMMARP->m_pinNum = 1; \
206 GRAMMARP->m_pinAnsi = false; \
207 VARRESET(); \
208 VARDECL(decl); \
209 } // Start of pinlist
210 #define VARRESET_NONLIST(decl) \
211 { \
212 GRAMMARP->m_pinNum = 0; \
213 GRAMMARP->m_pinAnsi = false; \
214 VARRESET(); \
215 VARDECL(decl); \
216 } // Not in a pinlist
217 #define VARRESET() \
218 { \
219 VARDECL(UNKNOWN); \
220 VARIO(NONE); \
221 VARDTYPE_NDECL(nullptr); \
222 GRAMMARP->m_varLifetime = VLifetime::NONE; \
223 GRAMMARP->m_varDeclTyped = false; \
224 }
225 #define VARDECL(type) \
226 { GRAMMARP->setVarDecl(AstVarType::type); }
227 #define VARIO(type) \
228 { GRAMMARP->m_varIO = VDirection::type; }
229 #define VARLIFE(flag) \
230 { GRAMMARP->m_varLifetime = flag; }
231 #define VARDTYPE(dtypep) \
232 { \
233 GRAMMARP->setDType(dtypep); \
234 GRAMMARP->m_varDeclTyped = true; \
235 }
236 #define VARDTYPE_NDECL(dtypep) \
237 { GRAMMARP->setDType(dtypep); } // Port that is range or signed only (not a decl)
238
239 #define VARDONEA(fl, name, array, attrs) GRAMMARP->createVariable((fl), (name), (array), (attrs))
240 #define VARDONEP(portp, array, attrs) \
241 GRAMMARP->createVariable((portp)->fileline(), (portp)->name(), (array), (attrs))
242 #define PINNUMINC() (GRAMMARP->m_pinNum++)
243
244 #define GATERANGE(rangep) \
245 { GRAMMARP->m_gateRangep = rangep; }
246
247 #define INSTPREP(modfl, modname, paramsp) \
248 { \
249 GRAMMARP->m_impliedDecl = true; \
250 GRAMMARP->m_instModuleFl = modfl; \
251 GRAMMARP->m_instModule = modname; \
252 GRAMMARP->m_instParamp = paramsp; \
253 }
254
255 #define DEL(nodep) \
256 { \
257 if (nodep) nodep->deleteTree(); \
258 }
259
ERRSVKWD(FileLine * fileline,const string & tokname)260 static void ERRSVKWD(FileLine* fileline, const string& tokname) {
261 static int toldonce = 0;
262 fileline->v3error(
263 std::string{"Unexpected '"} + tokname + "': '" + tokname
264 + "' is a SystemVerilog keyword misused as an identifier."
265 + (!toldonce++ ? "\n" + V3Error::warnMore()
266 + "... Suggest modify the Verilog-2001 code to avoid SV keywords,"
267 + " or use `begin_keywords or --language."
268 : ""));
269 }
270
UNSUPREAL(FileLine * fileline)271 static void UNSUPREAL(FileLine* fileline) {
272 fileline->v3warn(SHORTREAL,
273 "Unsupported: shortreal being promoted to real (suggest use real instead)");
274 }
275
276 //======================================================================
277
yyerror(const char * errmsg)278 void yyerror(const char* errmsg) { PARSEP->bisonLastFileline()->v3error(errmsg); }
279
280 //======================================================================
281
282 class AstSenTree;
283 // clang-format off
284 %}
285
286 // Bison 3.0 and newer
287 BISONPRE_VERSION(3.0,%define parse.error verbose)
288
289 // We run bison with the -d argument. This tells it to generate a
290 // header file with token names. Old versions of bison pasted the
291 // contents of that file into the generated source as well; newer
292 // versions just include it.
293 //
294 // Since we run bison through ../bisonpre, it doesn't know the correct
295 // header file name, so we need to tell it.
296 BISONPRE_VERSION(3.7,%define api.header.include {"V3ParseBison.h"})
297
298 // When writing Bison patterns we use yTOKEN instead of "token",
299 // so Bison will error out on unknown "token"s.
300
301 // Generic lexer tokens, for example a number
302 // IEEE: real_number
303 %token<cdouble> yaFLOATNUM "FLOATING-POINT NUMBER"
304
305 // IEEE: identifier, class_identifier, class_variable_identifier,
306 // covergroup_variable_identifier, dynamic_array_variable_identifier,
307 // enum_identifier, interface_identifier, interface_instance_identifier,
308 // package_identifier, type_identifier, variable_identifier,
309 %token<strp> yaID__ETC "IDENTIFIER"
310 %token<strp> yaID__CC "IDENTIFIER-::"
311 %token<strp> yaID__LEX "IDENTIFIER-in-lex"
312 %token<strp> yaID__aTYPE "TYPE-IDENTIFIER"
313 // Can't predecode aFUNCTION, can declare after use
314 // Can't predecode aINTERFACE, can declare after use
315 // Can't predecode aTASK, can declare after use
316
317 // IEEE: integral_number
318 %token<nump> yaINTNUM "INTEGER NUMBER"
319 // IEEE: time_literal + time_unit
320 %token<cdouble> yaTIMENUM "TIME NUMBER"
321 // IEEE: string_literal
322 %token<strp> yaSTRING "STRING"
323 %token<strp> yaSTRING__IGNORE "STRING-ignored" // Used when expr:string not allowed
324
325 %token<fl> yaTIMINGSPEC "TIMING SPEC ELEMENT"
326
327 %token<fl> ygenSTRENGTH "STRENGTH keyword (strong1/etc)"
328
329 %token<strp> yaTABLELINE "TABLE LINE"
330
331 %token<strp> yaSCHDR "`systemc_header BLOCK"
332 %token<strp> yaSCINT "`systemc_ctor BLOCK"
333 %token<strp> yaSCIMP "`systemc_dtor BLOCK"
334 %token<strp> yaSCIMPH "`systemc_interface BLOCK"
335 %token<strp> yaSCCTOR "`systemc_implementation BLOCK"
336 %token<strp> yaSCDTOR "`systemc_imp_header BLOCK"
337
338 %token<fl> yVLT_CLOCKER "clocker"
339 %token<fl> yVLT_CLOCK_ENABLE "clock_enable"
340 %token<fl> yVLT_COVERAGE_BLOCK_OFF "coverage_block_off"
341 %token<fl> yVLT_COVERAGE_OFF "coverage_off"
342 %token<fl> yVLT_COVERAGE_ON "coverage_on"
343 %token<fl> yVLT_FULL_CASE "full_case"
344 %token<fl> yVLT_HIER_BLOCK "hier_block"
345 %token<fl> yVLT_INLINE "inline"
346 %token<fl> yVLT_ISOLATE_ASSIGNMENTS "isolate_assignments"
347 %token<fl> yVLT_LINT_OFF "lint_off"
348 %token<fl> yVLT_LINT_ON "lint_on"
349 %token<fl> yVLT_NO_CLOCKER "no_clocker"
350 %token<fl> yVLT_NO_INLINE "no_inline"
351 %token<fl> yVLT_PARALLEL_CASE "parallel_case"
352 %token<fl> yVLT_PROFILE_DATA "profile_data"
353 %token<fl> yVLT_PUBLIC "public"
354 %token<fl> yVLT_PUBLIC_FLAT "public_flat"
355 %token<fl> yVLT_PUBLIC_FLAT_RD "public_flat_rd"
356 %token<fl> yVLT_PUBLIC_FLAT_RW "public_flat_rw"
357 %token<fl> yVLT_PUBLIC_MODULE "public_module"
358 %token<fl> yVLT_SC_BV "sc_bv"
359 %token<fl> yVLT_SFORMAT "sformat"
360 %token<fl> yVLT_SPLIT_VAR "split_var"
361 %token<fl> yVLT_TRACING_OFF "tracing_off"
362 %token<fl> yVLT_TRACING_ON "tracing_on"
363
364 %token<fl> yVLT_D_BLOCK "--block"
365 %token<fl> yVLT_D_COST "--cost"
366 %token<fl> yVLT_D_FILE "--file"
367 %token<fl> yVLT_D_FUNCTION "--function"
368 %token<fl> yVLT_D_LINES "--lines"
369 %token<fl> yVLT_D_MATCH "--match"
370 %token<fl> yVLT_D_MODEL "--model"
371 %token<fl> yVLT_D_MODULE "--module"
372 %token<fl> yVLT_D_MSG "--msg"
373 %token<fl> yVLT_D_MTASK "--mtask"
374 %token<fl> yVLT_D_RULE "--rule"
375 %token<fl> yVLT_D_TASK "--task"
376 %token<fl> yVLT_D_VAR "--var"
377
378 %token<strp> yaD_PLI "${pli-system}"
379
380 %token<fl> yaT_NOUNCONNECTED "`nounconnecteddrive"
381 %token<fl> yaT_RESETALL "`resetall"
382 %token<fl> yaT_UNCONNECTED_PULL0 "`unconnected_drive pull0"
383 %token<fl> yaT_UNCONNECTED_PULL1 "`unconnected_drive pull1"
384
385 // <fl> is the fileline, abbreviated to shorten "$<fl>1" references
386 %token<fl> '!'
387 %token<fl> '#'
388 %token<fl> '%'
389 %token<fl> '&'
390 %token<fl> '(' // See also yP_PAR__STRENGTH
391 %token<fl> ')'
392 %token<fl> '*'
393 %token<fl> '+'
394 %token<fl> ','
395 %token<fl> '-'
396 %token<fl> '.'
397 %token<fl> '/'
398 %token<fl> ':' // See also yP_COLON__BEGIN or yP_COLON__FORK
399 %token<fl> ';'
400 %token<fl> '<'
401 %token<fl> '='
402 %token<fl> '>'
403 %token<fl> '?'
404 %token<fl> '@'
405 %token<fl> '['
406 %token<fl> ']'
407 %token<fl> '^'
408 %token<fl> '{'
409 %token<fl> '|'
410 %token<fl> '}'
411 %token<fl> '~'
412
413 // Specific keywords
414 // yKEYWORD means match "keyword"
415 // Other cases are yXX_KEYWORD where XX makes it unique,
416 // for example yP_ for punctuation based operators.
417 // Double underscores "yX__Y" means token X followed by Y,
418 // and "yX__ETC" means X folled by everything but Y(s).
419 //UNSUP %token<fl> yACCEPT_ON "accept_on"
420 %token<fl> yALIAS "alias"
421 %token<fl> yALWAYS "always"
422 %token<fl> yALWAYS_COMB "always_comb"
423 %token<fl> yALWAYS_FF "always_ff"
424 %token<fl> yALWAYS_LATCH "always_latch"
425 %token<fl> yAND "and"
426 %token<fl> yASSERT "assert"
427 %token<fl> yASSIGN "assign"
428 %token<fl> yASSUME "assume"
429 %token<fl> yAUTOMATIC "automatic"
430 %token<fl> yBEFORE "before"
431 %token<fl> yBEGIN "begin"
432 %token<fl> yBIND "bind"
433 //UNSUP %token<fl> yBINS "bins"
434 //UNSUP %token<fl> yBINSOF "binsof"
435 %token<fl> yBIT "bit"
436 %token<fl> yBREAK "break"
437 %token<fl> yBUF "buf"
438 %token<fl> yBUFIF0 "bufif0"
439 %token<fl> yBUFIF1 "bufif1"
440 %token<fl> yBYTE "byte"
441 %token<fl> yCASE "case"
442 %token<fl> yCASEX "casex"
443 %token<fl> yCASEZ "casez"
444 %token<fl> yCHANDLE "chandle"
445 //UNSUP %token<fl> yCHECKER "checker"
446 %token<fl> yCLASS "class"
447 //UNSUP %token<fl> yCLOCK "clock"
448 %token<fl> yCLOCKING "clocking"
449 %token<fl> yCMOS "cmos"
450 %token<fl> yCONSTRAINT "constraint"
451 %token<fl> yCONST__ETC "const"
452 %token<fl> yCONST__LEX "const-in-lex"
453 //UNSUP %token<fl> yCONST__LOCAL "const-then-local"
454 %token<fl> yCONST__REF "const-then-ref"
455 %token<fl> yCONTEXT "context"
456 %token<fl> yCONTINUE "continue"
457 %token<fl> yCOVER "cover"
458 //UNSUP %token<fl> yCOVERGROUP "covergroup"
459 //UNSUP %token<fl> yCOVERPOINT "coverpoint"
460 //UNSUP %token<fl> yCROSS "cross"
461 %token<fl> yDEASSIGN "deassign"
462 %token<fl> yDEFAULT "default"
463 %token<fl> yDEFPARAM "defparam"
464 %token<fl> yDISABLE "disable"
465 %token<fl> yDIST "dist"
466 %token<fl> yDO "do"
467 %token<fl> yEDGE "edge"
468 %token<fl> yELSE "else"
469 %token<fl> yEND "end"
470 %token<fl> yENDCASE "endcase"
471 //UNSUP %token<fl> yENDCHECKER "endchecker"
472 %token<fl> yENDCLASS "endclass"
473 %token<fl> yENDCLOCKING "endclocking"
474 %token<fl> yENDFUNCTION "endfunction"
475 %token<fl> yENDGENERATE "endgenerate"
476 //UNSUP %token<fl> yENDGROUP "endgroup"
477 %token<fl> yENDINTERFACE "endinterface"
478 %token<fl> yENDMODULE "endmodule"
479 %token<fl> yENDPACKAGE "endpackage"
480 %token<fl> yENDPRIMITIVE "endprimitive"
481 %token<fl> yENDPROGRAM "endprogram"
482 %token<fl> yENDPROPERTY "endproperty"
483 //UNSUP %token<fl> yENDSEQUENCE "endsequence"
484 %token<fl> yENDSPECIFY "endspecify"
485 %token<fl> yENDTABLE "endtable"
486 %token<fl> yENDTASK "endtask"
487 %token<fl> yENUM "enum"
488 %token<fl> yEVENT "event"
489 //UNSUP %token<fl> yEVENTUALLY "eventually"
490 //UNSUP %token<fl> yEXPECT "expect"
491 %token<fl> yEXPORT "export"
492 %token<fl> yEXTENDS "extends"
493 %token<fl> yEXTERN "extern"
494 %token<fl> yFINAL "final"
495 //UNSUP %token<fl> yFIRST_MATCH "first_match"
496 %token<fl> yFOR "for"
497 %token<fl> yFORCE "force"
498 %token<fl> yFOREACH "foreach"
499 %token<fl> yFOREVER "forever"
500 %token<fl> yFORK "fork"
501 %token<fl> yFORKJOIN "forkjoin"
502 %token<fl> yFUNCTION "function"
503 //UNSUP %token<fl> yFUNCTION__ETC "function"
504 //UNSUP %token<fl> yFUNCTION__LEX "function-in-lex"
505 //UNSUP %token<fl> yFUNCTION__aPUREV "function-is-pure-virtual"
506 %token<fl> yGENERATE "generate"
507 %token<fl> yGENVAR "genvar"
508 %token<fl> yGLOBAL__CLOCKING "global-then-clocking"
509 %token<fl> yGLOBAL__ETC "global"
510 %token<fl> yGLOBAL__LEX "global-in-lex"
511 %token<fl> yIF "if"
512 %token<fl> yIFF "iff"
513 //UNSUP %token<fl> yIGNORE_BINS "ignore_bins"
514 //UNSUP %token<fl> yILLEGAL_BINS "illegal_bins"
515 %token<fl> yIMPLEMENTS "implements"
516 //UNSUP %token<fl> yIMPLIES "implies"
517 %token<fl> yIMPORT "import"
518 %token<fl> yINITIAL "initial"
519 %token<fl> yINOUT "inout"
520 %token<fl> yINPUT "input"
521 %token<fl> yINSIDE "inside"
522 %token<fl> yINT "int"
523 %token<fl> yINTEGER "integer"
524 //UNSUP %token<fl> yINTERCONNECT "interconnect"
525 %token<fl> yINTERFACE "interface"
526 //UNSUP %token<fl> yINTERSECT "intersect"
527 %token<fl> yJOIN "join"
528 %token<fl> yJOIN_ANY "join_any"
529 %token<fl> yJOIN_NONE "join_none"
530 //UNSUP %token<fl> yLET "let"
531 %token<fl> yLOCALPARAM "localparam"
532 %token<fl> yLOCAL__COLONCOLON "local-then-::"
533 %token<fl> yLOCAL__ETC "local"
534 %token<fl> yLOCAL__LEX "local-in-lex"
535 %token<fl> yLOGIC "logic"
536 %token<fl> yLONGINT "longint"
537 //UNSUP %token<fl> yMATCHES "matches"
538 %token<fl> yMODPORT "modport"
539 %token<fl> yMODULE "module"
540 %token<fl> yNAND "nand"
541 %token<fl> yNEGEDGE "negedge"
542 //UNSUP %token<fl> yNETTYPE "nettype"
543 %token<fl> yNEW__ETC "new"
544 %token<fl> yNEW__LEX "new-in-lex"
545 %token<fl> yNEW__PAREN "new-then-paren"
546 //UNSUP %token<fl> yNEXTTIME "nexttime"
547 %token<fl> yNMOS "nmos"
548 %token<fl> yNOR "nor"
549 %token<fl> yNOT "not"
550 %token<fl> yNOTIF0 "notif0"
551 %token<fl> yNOTIF1 "notif1"
552 %token<fl> yNULL "null"
553 %token<fl> yOR "or"
554 %token<fl> yOUTPUT "output"
555 %token<fl> yPACKAGE "package"
556 %token<fl> yPACKED "packed"
557 %token<fl> yPARAMETER "parameter"
558 %token<fl> yPMOS "pmos"
559 %token<fl> yPOSEDGE "posedge"
560 %token<fl> yPRIMITIVE "primitive"
561 %token<fl> yPRIORITY "priority"
562 %token<fl> yPROGRAM "program"
563 %token<fl> yPROPERTY "property"
564 %token<fl> yPROTECTED "protected"
565 %token<fl> yPULLDOWN "pulldown"
566 %token<fl> yPULLUP "pullup"
567 %token<fl> yPURE "pure"
568 %token<fl> yRAND "rand"
569 %token<fl> yRANDC "randc"
570 %token<fl> yRANDCASE "randcase"
571 %token<fl> yRANDOMIZE "randomize"
572 //UNSUP %token<fl> yRANDSEQUENCE "randsequence"
573 %token<fl> yRCMOS "rcmos"
574 %token<fl> yREAL "real"
575 %token<fl> yREALTIME "realtime"
576 %token<fl> yREF "ref"
577 %token<fl> yREG "reg"
578 //UNSUP %token<fl> yREJECT_ON "reject_on"
579 %token<fl> yRELEASE "release"
580 %token<fl> yREPEAT "repeat"
581 %token<fl> yRESTRICT "restrict"
582 %token<fl> yRETURN "return"
583 %token<fl> yRNMOS "rnmos"
584 %token<fl> yRPMOS "rpmos"
585 %token<fl> yRTRAN "rtran"
586 %token<fl> yRTRANIF0 "rtranif0"
587 %token<fl> yRTRANIF1 "rtranif1"
588 %token<fl> ySCALARED "scalared"
589 //UNSUP %token<fl> ySEQUENCE "sequence"
590 %token<fl> ySHORTINT "shortint"
591 %token<fl> ySHORTREAL "shortreal"
592 %token<fl> ySIGNED "signed"
593 %token<fl> ySOFT "soft"
594 %token<fl> ySOLVE "solve"
595 %token<fl> ySPECIFY "specify"
596 %token<fl> ySPECPARAM "specparam"
597 %token<fl> ySTATIC__CONSTRAINT "static-then-constraint"
598 %token<fl> ySTATIC__ETC "static"
599 %token<fl> ySTATIC__LEX "static-in-lex"
600 %token<fl> ySTRING "string"
601 //UNSUP %token<fl> ySTRONG "strong"
602 %token<fl> ySTRUCT "struct"
603 %token<fl> ySUPER "super"
604 %token<fl> ySUPPLY0 "supply0"
605 %token<fl> ySUPPLY1 "supply1"
606 //UNSUP %token<fl> ySYNC_ACCEPT_ON "sync_accept_on"
607 //UNSUP %token<fl> ySYNC_REJECT_ON "sync_reject_on"
608 //UNSUP %token<fl> yS_ALWAYS "s_always"
609 //UNSUP %token<fl> yS_EVENTUALLY "s_eventually"
610 //UNSUP %token<fl> yS_NEXTTIME "s_nexttime"
611 //UNSUP %token<fl> yS_UNTIL "s_until"
612 //UNSUP %token<fl> yS_UNTIL_WITH "s_until_with"
613 %token<fl> yTABLE "table"
614 //UNSUP %token<fl> yTAGGED "tagged"
615 %token<fl> yTASK "task"
616 //UNSUP %token<fl> yTASK__ETC "task"
617 //UNSUP %token<fl> yTASK__LEX "task-in-lex"
618 //UNSUP %token<fl> yTASK__aPUREV "task-is-pure-virtual"
619 %token<fl> yTHIS "this"
620 //UNSUP %token<fl> yTHROUGHOUT "throughout"
621 %token<fl> yTIME "time"
622 %token<fl> yTIMEPRECISION "timeprecision"
623 %token<fl> yTIMEUNIT "timeunit"
624 %token<fl> yTRAN "tran"
625 %token<fl> yTRANIF0 "tranif0"
626 %token<fl> yTRANIF1 "tranif1"
627 %token<fl> yTRI "tri"
628 %token<fl> yTRI0 "tri0"
629 %token<fl> yTRI1 "tri1"
630 %token<fl> yTRIAND "triand"
631 %token<fl> yTRIOR "trior"
632 %token<fl> yTRIREG "trireg"
633 %token<fl> yTRUE "true"
634 %token<fl> yTYPE "type"
635 %token<fl> yTYPEDEF "typedef"
636 %token<fl> yUNION "union"
637 %token<fl> yUNIQUE "unique"
638 %token<fl> yUNIQUE0 "unique0"
639 %token<fl> yUNSIGNED "unsigned"
640 //UNSUP %token<fl> yUNTIL "until"
641 //UNSUP %token<fl> yUNTIL_WITH "until_with"
642 //UNSUP %token<fl> yUNTYPED "untyped"
643 %token<fl> yVAR "var"
644 %token<fl> yVECTORED "vectored"
645 %token<fl> yVIRTUAL__CLASS "virtual-then-class"
646 %token<fl> yVIRTUAL__ETC "virtual"
647 %token<fl> yVIRTUAL__INTERFACE "virtual-then-interface"
648 %token<fl> yVIRTUAL__LEX "virtual-in-lex"
649 %token<fl> yVIRTUAL__anyID "virtual-then-identifier"
650 %token<fl> yVOID "void"
651 %token<fl> yWAIT "wait"
652 //UNSUP %token<fl> yWAIT_ORDER "wait_order"
653 %token<fl> yWAND "wand"
654 //UNSUP %token<fl> yWEAK "weak"
655 %token<fl> yWHILE "while"
656 //UNSUP %token<fl> yWILDCARD "wildcard"
657 %token<fl> yWIRE "wire"
658 //UNSUP %token<fl> yWITHIN "within"
659 %token<fl> yWITH__BRA "with-then-["
660 %token<fl> yWITH__CUR "with-then-{"
661 %token<fl> yWITH__ETC "with"
662 %token<fl> yWITH__LEX "with-in-lex"
663 %token<fl> yWITH__PAREN "with-then-("
664 %token<fl> yWOR "wor"
665 %token<fl> yWREAL "wreal"
666 %token<fl> yXNOR "xnor"
667 %token<fl> yXOR "xor"
668
669 %token<fl> yD_ACOS "$acos"
670 %token<fl> yD_ACOSH "$acosh"
671 %token<fl> yD_ASIN "$asin"
672 %token<fl> yD_ASINH "$asinh"
673 %token<fl> yD_ATAN "$atan"
674 %token<fl> yD_ATAN2 "$atan2"
675 %token<fl> yD_ATANH "$atanh"
676 %token<fl> yD_BITS "$bits"
677 %token<fl> yD_BITSTOREAL "$bitstoreal"
678 %token<fl> yD_BITSTOSHORTREAL "$bitstoshortreal"
679 %token<fl> yD_C "$c"
680 %token<fl> yD_CAST "$cast"
681 %token<fl> yD_CEIL "$ceil"
682 %token<fl> yD_CHANGED "$changed"
683 %token<fl> yD_CLOG2 "$clog2"
684 %token<fl> yD_COS "$cos"
685 %token<fl> yD_COSH "$cosh"
686 %token<fl> yD_COUNTBITS "$countbits"
687 %token<fl> yD_COUNTONES "$countones"
688 %token<fl> yD_DIMENSIONS "$dimensions"
689 %token<fl> yD_DISPLAY "$display"
690 %token<fl> yD_DISPLAYB "$displayb"
691 %token<fl> yD_DISPLAYH "$displayh"
692 %token<fl> yD_DISPLAYO "$displayo"
693 %token<fl> yD_DUMPALL "$dumpall"
694 %token<fl> yD_DUMPFILE "$dumpfile"
695 %token<fl> yD_DUMPFLUSH "$dumpflush"
696 %token<fl> yD_DUMPLIMIT "$dumplimit"
697 %token<fl> yD_DUMPOFF "$dumpoff"
698 %token<fl> yD_DUMPON "$dumpon"
699 %token<fl> yD_DUMPPORTS "$dumpports"
700 %token<fl> yD_DUMPVARS "$dumpvars"
701 %token<fl> yD_ERROR "$error"
702 %token<fl> yD_EXIT "$exit"
703 %token<fl> yD_EXP "$exp"
704 %token<fl> yD_FATAL "$fatal"
705 %token<fl> yD_FCLOSE "$fclose"
706 %token<fl> yD_FDISPLAY "$fdisplay"
707 %token<fl> yD_FDISPLAYB "$fdisplayb"
708 %token<fl> yD_FDISPLAYH "$fdisplayh"
709 %token<fl> yD_FDISPLAYO "$fdisplayo"
710 %token<fl> yD_FELL "$fell"
711 %token<fl> yD_FEOF "$feof"
712 %token<fl> yD_FERROR "$ferror"
713 %token<fl> yD_FFLUSH "$fflush"
714 %token<fl> yD_FGETC "$fgetc"
715 %token<fl> yD_FGETS "$fgets"
716 %token<fl> yD_FINISH "$finish"
717 %token<fl> yD_FLOOR "$floor"
718 %token<fl> yD_FMONITOR "$fmonitor"
719 %token<fl> yD_FMONITORB "$fmonitorb"
720 %token<fl> yD_FMONITORH "$fmonitorh"
721 %token<fl> yD_FMONITORO "$fmonitoro"
722 %token<fl> yD_FOPEN "$fopen"
723 %token<fl> yD_FREAD "$fread"
724 %token<fl> yD_FREWIND "$frewind"
725 %token<fl> yD_FSCANF "$fscanf"
726 %token<fl> yD_FSEEK "$fseek"
727 %token<fl> yD_FSTROBE "$fstrobe"
728 %token<fl> yD_FSTROBEB "$fstrobeb"
729 %token<fl> yD_FSTROBEH "$fstrobeh"
730 %token<fl> yD_FSTROBEO "$fstrobeo"
731 %token<fl> yD_FTELL "$ftell"
732 %token<fl> yD_FWRITE "$fwrite"
733 %token<fl> yD_FWRITEB "$fwriteb"
734 %token<fl> yD_FWRITEH "$fwriteh"
735 %token<fl> yD_FWRITEO "$fwriteo"
736 %token<fl> yD_HIGH "$high"
737 %token<fl> yD_HYPOT "$hypot"
738 %token<fl> yD_INCREMENT "$increment"
739 %token<fl> yD_INFO "$info"
740 %token<fl> yD_ISUNBOUNDED "$isunbounded"
741 %token<fl> yD_ISUNKNOWN "$isunknown"
742 %token<fl> yD_ITOR "$itor"
743 %token<fl> yD_LEFT "$left"
744 %token<fl> yD_LN "$ln"
745 %token<fl> yD_LOG10 "$log10"
746 %token<fl> yD_LOW "$low"
747 %token<fl> yD_MONITOR "$monitor"
748 %token<fl> yD_MONITORB "$monitorb"
749 %token<fl> yD_MONITORH "$monitorh"
750 %token<fl> yD_MONITORO "$monitoro"
751 %token<fl> yD_MONITOROFF "$monitoroff"
752 %token<fl> yD_MONITORON "$monitoron"
753 %token<fl> yD_ONEHOT "$onehot"
754 %token<fl> yD_ONEHOT0 "$onehot0"
755 %token<fl> yD_PAST "$past"
756 %token<fl> yD_POW "$pow"
757 %token<fl> yD_PRINTTIMESCALE "$printtimescale"
758 %token<fl> yD_RANDOM "$random"
759 %token<fl> yD_READMEMB "$readmemb"
760 %token<fl> yD_READMEMH "$readmemh"
761 %token<fl> yD_REALTIME "$realtime"
762 %token<fl> yD_REALTOBITS "$realtobits"
763 %token<fl> yD_REWIND "$rewind"
764 %token<fl> yD_RIGHT "$right"
765 %token<fl> yD_ROOT "$root"
766 %token<fl> yD_ROSE "$rose"
767 %token<fl> yD_RTOI "$rtoi"
768 %token<fl> yD_SAMPLED "$sampled"
769 %token<fl> yD_SFORMAT "$sformat"
770 %token<fl> yD_SFORMATF "$sformatf"
771 %token<fl> yD_SHORTREALTOBITS "$shortrealtobits"
772 %token<fl> yD_SIGNED "$signed"
773 %token<fl> yD_SIN "$sin"
774 %token<fl> yD_SINH "$sinh"
775 %token<fl> yD_SIZE "$size"
776 %token<fl> yD_SQRT "$sqrt"
777 %token<fl> yD_SSCANF "$sscanf"
778 %token<fl> yD_STABLE "$stable"
779 %token<fl> yD_STIME "$stime"
780 %token<fl> yD_STOP "$stop"
781 %token<fl> yD_STROBE "$strobe"
782 %token<fl> yD_STROBEB "$strobeb"
783 %token<fl> yD_STROBEH "$strobeh"
784 %token<fl> yD_STROBEO "$strobeo"
785 %token<fl> yD_SWRITE "$swrite"
786 %token<fl> yD_SWRITEB "$swriteb"
787 %token<fl> yD_SWRITEH "$swriteh"
788 %token<fl> yD_SWRITEO "$swriteo"
789 %token<fl> yD_SYSTEM "$system"
790 %token<fl> yD_TAN "$tan"
791 %token<fl> yD_TANH "$tanh"
792 %token<fl> yD_TESTPLUSARGS "$test$plusargs"
793 %token<fl> yD_TIME "$time"
794 %token<fl> yD_TIMEFORMAT "$timeformat"
795 %token<fl> yD_TYPENAME "$typename"
796 %token<fl> yD_UNGETC "$ungetc"
797 %token<fl> yD_UNIT "$unit"
798 %token<fl> yD_UNPACKED_DIMENSIONS "$unpacked_dimensions"
799 %token<fl> yD_UNSIGNED "$unsigned"
800 %token<fl> yD_URANDOM "$urandom"
801 %token<fl> yD_URANDOM_RANGE "$urandom_range"
802 %token<fl> yD_VALUEPLUSARGS "$value$plusargs"
803 %token<fl> yD_WARNING "$warning"
804 %token<fl> yD_WRITE "$write"
805 %token<fl> yD_WRITEB "$writeb"
806 %token<fl> yD_WRITEH "$writeh"
807 %token<fl> yD_WRITEMEMB "$writememb"
808 %token<fl> yD_WRITEMEMH "$writememh"
809 %token<fl> yD_WRITEO "$writeo"
810
811 %token<fl> yVL_CLOCKER "/*verilator clocker*/"
812 %token<fl> yVL_CLOCK_ENABLE "/*verilator clock_enable*/"
813 %token<fl> yVL_COVERAGE_BLOCK_OFF "/*verilator coverage_block_off*/"
814 %token<fl> yVL_FULL_CASE "/*verilator full_case*/"
815 %token<fl> yVL_HIER_BLOCK "/*verilator hier_block*/"
816 %token<fl> yVL_INLINE_MODULE "/*verilator inline_module*/"
817 %token<fl> yVL_ISOLATE_ASSIGNMENTS "/*verilator isolate_assignments*/"
818 %token<fl> yVL_NO_CLOCKER "/*verilator no_clocker*/"
819 %token<fl> yVL_NO_INLINE_MODULE "/*verilator no_inline_module*/"
820 %token<fl> yVL_NO_INLINE_TASK "/*verilator no_inline_task*/"
821 %token<fl> yVL_PARALLEL_CASE "/*verilator parallel_case*/"
822 %token<fl> yVL_PUBLIC "/*verilator public*/"
823 %token<fl> yVL_PUBLIC_FLAT "/*verilator public_flat*/"
824 %token<fl> yVL_PUBLIC_FLAT_RD "/*verilator public_flat_rd*/"
825 %token<fl> yVL_PUBLIC_FLAT_RW "/*verilator public_flat_rw*/"
826 %token<fl> yVL_PUBLIC_MODULE "/*verilator public_module*/"
827 %token<fl> yVL_SC_BV "/*verilator sc_bv*/"
828 %token<fl> yVL_SFORMAT "/*verilator sformat*/"
829 %token<fl> yVL_SPLIT_VAR "/*verilator split_var*/"
830 %token<strp> yVL_TAG "/*verilator tag*/"
831 %token<fl> yVL_TRACE_INIT_TASK "/*verilator trace_init_task*/"
832
833 %token<fl> yP_TICK "'"
834 %token<fl> yP_TICKBRA "'{"
835 %token<fl> yP_OROR "||"
836 %token<fl> yP_ANDAND "&&"
837 %token<fl> yP_NOR "~|"
838 %token<fl> yP_XNOR "^~"
839 %token<fl> yP_NAND "~&"
840 %token<fl> yP_EQUAL "=="
841 %token<fl> yP_NOTEQUAL "!="
842 %token<fl> yP_CASEEQUAL "==="
843 %token<fl> yP_CASENOTEQUAL "!=="
844 %token<fl> yP_WILDEQUAL "==?"
845 %token<fl> yP_WILDNOTEQUAL "!=?"
846 %token<fl> yP_GTE ">="
847 %token<fl> yP_LTE "<="
848 %token<fl> yP_LTE__IGNORE "<=-ignored" // Used when expr:<= means assignment
849 %token<fl> yP_SLEFT "<<"
850 %token<fl> yP_SRIGHT ">>"
851 %token<fl> yP_SSRIGHT ">>>"
852 %token<fl> yP_POW "**"
853
854 %token<fl> yP_COLON__BEGIN ":-begin"
855 %token<fl> yP_COLON__FORK ":-fork"
856 //UNSUP %token<fl> yP_PAR__IGNORE "(-ignored" // Used when sequence_expr:expr:( is ignored
857 %token<fl> yP_PAR__STRENGTH "(-for-strength"
858
859 %token<fl> yP_LTMINUSGT "<->"
860 %token<fl> yP_PLUSCOLON "+:"
861 %token<fl> yP_MINUSCOLON "-:"
862 %token<fl> yP_MINUSGT "->"
863 %token<fl> yP_MINUSGTGT "->>"
864 %token<fl> yP_EQGT "=>"
865 %token<fl> yP_ASTGT "*>"
866 %token<fl> yP_ANDANDAND "&&&"
867 %token<fl> yP_POUNDPOUND "##"
868 //UNSUP %token<fl> yP_POUNDMINUSPD "#-#"
869 //UNSUP %token<fl> yP_POUNDEQPD "#=#"
870 %token<fl> yP_DOTSTAR ".*"
871
872 %token<fl> yP_ATAT "@@"
873 %token<fl> yP_COLONCOLON "::"
874 %token<fl> yP_COLONEQ ":="
875 %token<fl> yP_COLONDIV ":/"
876 %token<fl> yP_ORMINUSGT "|->"
877 %token<fl> yP_OREQGT "|=>"
878 %token<fl> yP_BRASTAR "[*"
879 %token<fl> yP_BRAEQ "[="
880 %token<fl> yP_BRAMINUSGT "[->"
881 //UNSUP %token<fl> yP_BRAPLUSKET "[+]"
882
883 %token<fl> yP_PLUSPLUS "++"
884 %token<fl> yP_MINUSMINUS "--"
885 %token<fl> yP_PLUSEQ "+="
886 %token<fl> yP_MINUSEQ "-="
887 %token<fl> yP_TIMESEQ "*="
888 %token<fl> yP_DIVEQ "/="
889 %token<fl> yP_MODEQ "%="
890 %token<fl> yP_ANDEQ "&="
891 %token<fl> yP_OREQ "|="
892 %token<fl> yP_XOREQ "^="
893 %token<fl> yP_SLEFTEQ "<<="
894 %token<fl> yP_SRIGHTEQ ">>="
895 %token<fl> yP_SSRIGHTEQ ">>>="
896
897 // [* is not a operator, as "[ * ]" is legal
898 // [= and [-> could be repitition operators, but to match [* we don't add them.
899 // '( is not a operator, as "' (" is legal
900
901 //********************
902 // Verilog op precedence
903 //UNSUP %token<fl> prUNARYARITH
904 //UNSUP %token<fl> prREDUCTION
905 //UNSUP %token<fl> prNEGATION
906 //UNSUP %token<fl> prEVENTBEGIN
907 //UNSUP %token<fl> prTAGGED
908
909 // These prevent other conflicts
910 %left yP_ANDANDAND
911 //UNSUP %left yMATCHES
912 //UNSUP %left prTAGGED
913 //UNSUP %left prSEQ_CLOCKING
914
915 // PSL op precedence
916
917 // Lowest precedence
918 // These are in IEEE 17.7.1
919 //UNSUP %nonassoc yALWAYS yS_ALWAYS yEVENTUALLY yS_EVENTUALLY yACCEPT_ON yREJECT_ON ySYNC_ACCEPT_ON ySYNC_REJECT_ON
920
921 %right yP_ORMINUSGT yP_OREQGT
922 //UNSUP %right yP_ORMINUSGT yP_OREQGT yP_POUNDMINUSPD yP_POUNDEQPD
923 //UNSUP %right yUNTIL yS_UNTIL yUNTIL_WITH yS_UNTIL_WITH yIMPLIES
924 //UNSUP %right yIFF
925 //UNSUP %left yOR
926 //UNSUP %left yAND
927 //UNSUP %nonassoc yNOT yNEXTTIME yS_NEXTTIME
928 //UNSUP %left yINTERSECT
929 //UNSUP %left yWITHIN
930 //UNSUP %right yTHROUGHOUT
931 //UNSUP %left prPOUNDPOUND_MULTI
932 //UNSUP %left yP_POUNDPOUND
933 //UNSUP %left yP_BRASTAR yP_BRAEQ yP_BRAMINUSGT yP_BRAPLUSKET
934
935 // Not specified, but needed higher than yOR, lower than normal non-pexpr expressions
936 //UNSUP %left yPOSEDGE yNEGEDGE yEDGE
937
938 //UNSUP %left '{' '}'
939
940 // Verilog op precedence
941 %right yP_MINUSGT yP_LTMINUSGT
942 %right '?' ':' yP_COLON__BEGIN yP_COLON__FORK
943 %left yP_OROR
944 %left yP_ANDAND
945 %left '|' yP_NOR
946 %left '^' yP_XNOR
947 %left '&' yP_NAND
948 %left yP_EQUAL yP_NOTEQUAL yP_CASEEQUAL yP_CASENOTEQUAL yP_WILDEQUAL yP_WILDNOTEQUAL
949 %left '>' '<' yP_GTE yP_LTE yP_LTE__IGNORE yINSIDE yDIST
950 %left yP_SLEFT yP_SRIGHT yP_SSRIGHT
951 %left '+' '-'
952 %left '*' '/' '%'
953 %left yP_POW
954 %left prUNARYARITH yP_MINUSMINUS yP_PLUSPLUS prREDUCTION prNEGATION
955 %left '.'
956 // Not in IEEE, but need to avoid conflicts; TICK should bind tightly just lower than COLONCOLON
957 %left yP_TICK
958 //%left '(' ')' '[' ']' yP_COLONCOLON '.'
959
960 %nonassoc prLOWER_THAN_ELSE
961 %nonassoc yELSE
962
963 //BISONPRE_TYPES
964 // Blank lines for type insertion
965 // Blank lines for type insertion
966 // Blank lines for type insertion
967 // Blank lines for type insertion
968 // Blank lines for type insertion
969 // Blank lines for type insertion
970 // Blank lines for type insertion
971 // Blank lines for type insertion
972 // Blank lines for type insertion
973 // Blank lines for type insertion
974 // Blank lines for type insertion
975 // Blank lines for type insertion
976 // Blank lines for type insertion
977 // Blank lines for type insertion
978 // Blank lines for type insertion
979 // Blank lines for type insertion
980 // Blank lines for type insertion
981 // Blank lines for type insertion
982 // Blank lines for type insertion
983 // Blank lines for type insertion
984 // Blank lines for type insertion
985 // Blank lines for type insertion
986 // Blank lines for type insertion
987 // Blank lines for type insertion
988 // Blank lines for type insertion
989 // Blank lines for type insertion
990 // Blank lines for type insertion
991 // Blank lines for type insertion
992 // Blank lines for type insertion
993 // Blank lines for type insertion
994 // Blank lines for type insertion
995 // Blank lines for type insertion
996 // Blank lines for type insertion
997 // Blank lines for type insertion
998 // Blank lines for type insertion
999 // Blank lines for type insertion
1000 // Blank lines for type insertion
1001
1002 %start source_text
1003
1004 %%
1005 //**********************************************************************
1006 // Files
1007
1008 source_text: // ==IEEE: source_text
1009 /* empty */ { }
1010 // // timeunits_declaration moved into description:package_item
1011 | descriptionList { }
1012 ;
1013
1014 descriptionList: // IEEE: part of source_text
1015 description { }
1016 | descriptionList description { }
1017 ;
1018
1019 description: // ==IEEE: description
1020 module_declaration { }
1021 // // udp_declaration moved into module_declaration
1022 | interface_declaration { }
1023 | program_declaration { }
1024 | package_declaration { }
1025 | package_item { if ($1) PARSEP->unitPackage($1->fileline())->addStmtp($1); }
1026 | bind_directive { if ($1) PARSEP->unitPackage($1->fileline())->addStmtp($1); }
1027 // unsupported // IEEE: config_declaration
1028 // // Verilator only
1029 | yaT_RESETALL { } // Else, under design, and illegal based on IEEE 22.3
1030 | yaT_NOUNCONNECTED { PARSEP->unconnectedDrive(VOptionBool::OPT_DEFAULT_FALSE); }
1031 | yaT_UNCONNECTED_PULL0 { PARSEP->unconnectedDrive(VOptionBool::OPT_FALSE); }
1032 | yaT_UNCONNECTED_PULL1 { PARSEP->unconnectedDrive(VOptionBool::OPT_TRUE); }
1033 | vltItem { }
1034 | error { }
1035 ;
1036
1037 timeunits_declaration<nodep>: // ==IEEE: timeunits_declaration
1038 yTIMEUNIT yaTIMENUM ';'
1039 { PARSEP->timescaleMod($<fl>2, GRAMMARP->m_modp, true, $2, false, 0); $$ = nullptr; }
1040 | yTIMEUNIT yaTIMENUM '/' yaTIMENUM ';'
1041 { PARSEP->timescaleMod($<fl>2, GRAMMARP->m_modp, true, $2, true, $4); $$ = nullptr; }
1042 | yTIMEPRECISION yaTIMENUM ';'
1043 { PARSEP->timescaleMod($<fl>2, GRAMMARP->m_modp, false, 0, true, $2); $$ = nullptr; }
1044 ;
1045
1046 //**********************************************************************
1047 // Packages
1048
1049 package_declaration: // ==IEEE: package_declaration
1050 packageFront package_itemListE yENDPACKAGE endLabelE
1051 { $1->modTrace(GRAMMARP->allTracingOn($1->fileline())); // Stash for implicit wires, etc
1052 if ($2) $1->addStmtp($2);
1053 GRAMMARP->m_modp = nullptr;
1054 SYMP->popScope($1);
1055 GRAMMARP->endLabel($<fl>4,$1,$4); }
1056 ;
1057
1058 packageFront<nodeModulep>:
1059 yPACKAGE lifetimeE idAny ';'
1060 { $$ = new AstPackage($<fl>3, *$3);
1061 $$->inLibrary(true); // packages are always libraries; don't want to make them a "top"
1062 $$->lifetime($2);
1063 $$->modTrace(GRAMMARP->allTracingOn($$->fileline()));
1064 $$->timeunit(PARSEP->timeLastUnit());
1065 PARSEP->rootp()->addModulep($$);
1066 SYMP->pushNew($$);
1067 GRAMMARP->m_modp = $$; }
1068 ;
1069
1070 package_itemListE<nodep>: // IEEE: [{ package_item }]
1071 /* empty */ { $$ = nullptr; }
1072 | package_itemList { $$ = $1; }
1073 ;
1074
1075 package_itemList<nodep>: // IEEE: { package_item }
1076 package_item { $$ = $1; }
1077 | package_itemList package_item { $$ = $1->addNextNull($2); }
1078 ;
1079
1080 package_item<nodep>: // ==IEEE: package_item
1081 package_or_generate_item_declaration { $$ = $1; }
1082 | anonymous_program { $$ = $1; }
1083 | package_export_declaration { $$ = $1; }
1084 | timeunits_declaration { $$ = $1; }
1085 ;
1086
1087 package_or_generate_item_declaration<nodep>: // ==IEEE: package_or_generate_item_declaration
1088 net_declaration { $$ = $1; }
1089 | data_declaration { $$ = $1; }
1090 | task_declaration { $$ = $1; }
1091 | function_declaration { $$ = $1; }
1092 //UNSUP checker_declaration { $$ = $1; }
1093 | dpi_import_export { $$ = $1; }
1094 //UNSUP extern_constraint_declaration { $$ = $1; }
1095 | class_declaration { $$ = $1; }
1096 // // class_constructor_declaration is part of function_declaration
1097 // // local_parameter_declaration under parameter_declaration
1098 | parameter_declaration ';' { $$ = $1; }
1099 //UNSUP covergroup_declaration { $$ = $1; }
1100 //UNSUP assertion_item_declaration { $$ = $1; }
1101 | ';' { $$ = nullptr; }
1102 ;
1103
1104 package_import_declarationList<nodep>:
1105 package_import_declaration { $$ = $1; }
1106 | package_import_declarationList package_import_declaration { $$ = $1->addNextNull($2); }
1107 ;
1108
1109 package_import_declaration<nodep>: // ==IEEE: package_import_declaration
1110 yIMPORT package_import_itemList ';' { $$ = $2; }
1111 ;
1112
1113 package_import_itemList<nodep>:
1114 package_import_item { $$ = $1; }
1115 | package_import_itemList ',' package_import_item { $$ = $1->addNextNull($3); }
1116 ;
1117
1118 package_import_item<nodep>: // ==IEEE: package_import_item
1119 idCC/*package_identifier*/ yP_COLONCOLON package_import_itemObj
1120 {
1121 if (!VN_IS($<scp>1, Package)) {
1122 $$ = nullptr;
1123 $<fl>1->v3error("Importing from missing package '" << *$<strp>1 << "'");
1124 } else {
1125 $$ = new AstPackageImport($<fl>2, VN_CAST($<scp>1, Package), *$3);
1126 SYMP->importItem($<scp>1,*$3);
1127 } }
1128 ;
1129
1130 package_import_itemObj<strp>: // IEEE: part of package_import_item
1131 idAny/*package_identifier*/ { $<fl>$ = $<fl>1; $$ = $1; }
1132 | '*' { $<fl>$ = $<fl>1; static string star = "*"; $$ = ☆ }
1133 ;
1134
1135 package_export_declaration<nodep>: // IEEE: package_export_declaration
1136 yEXPORT '*' yP_COLONCOLON '*' ';' { $$ = new AstPackageExportStarStar($<fl>2); SYMP->exportStarStar($<scp>1); }
1137 | yEXPORT package_export_itemList ';' { $$ = $2; }
1138 ;
1139
1140 package_export_itemList<nodep>:
1141 package_export_item { $$ = $1; }
1142 | package_export_itemList ',' package_export_item { $$ = $1->addNextNull($3); }
1143 ;
1144
1145 package_export_item<nodep>: // ==IEEE: package_export_item
1146 idCC yP_COLONCOLON package_import_itemObj
1147 { $$ = new AstPackageExport($<fl>3, VN_CAST($<scp>1, Package), *$3);
1148 SYMP->exportItem($<scp>1,*$3); }
1149 ;
1150
1151 //**********************************************************************
1152 // Module headers
1153
1154 module_declaration: // ==IEEE: module_declaration
1155 // // timeunits_declaration instead in module_item
1156 // // IEEE: module_nonansi_header + module_ansi_header
1157 modFront importsAndParametersE portsStarE ';'
1158 /*cont*/ module_itemListE yENDMODULE endLabelE
1159 { $1->modTrace(GRAMMARP->allTracingOn($1->fileline())); // Stash for implicit wires, etc
1160 if ($2) $1->addStmtp($2);
1161 if ($3) $1->addStmtp($3);
1162 if ($5) $1->addStmtp($5);
1163 GRAMMARP->m_modp = nullptr;
1164 SYMP->popScope($1);
1165 GRAMMARP->endLabel($<fl>7,$1,$7); }
1166 | udpFront parameter_port_listE portsStarE ';'
1167 /*cont*/ module_itemListE yENDPRIMITIVE endLabelE
1168 { $1->modTrace(false); // Stash for implicit wires, etc
1169 if ($2) $1->addStmtp($2);
1170 if ($3) $1->addStmtp($3);
1171 if ($5) $1->addStmtp($5);
1172 GRAMMARP->m_tracingParse = true;
1173 GRAMMARP->m_modp = nullptr;
1174 SYMP->popScope($1);
1175 GRAMMARP->endLabel($<fl>7,$1,$7); }
1176 //
1177 | yEXTERN modFront parameter_port_listE portsStarE ';'
1178 { BBUNSUP($<fl>1, "Unsupported: extern module"); }
1179 ;
1180
1181 modFront<nodeModulep>:
1182 // // General note: all *Front functions must call symPushNew before
1183 // // any formal arguments, as the arguments must land in the new scope.
1184 yMODULE lifetimeE idAny
1185 { $$ = new AstModule($<fl>3,*$3);
1186 $$->lifetime($2);
1187 $$->inLibrary(PARSEP->inLibrary() || $$->fileline()->celldefineOn());
1188 $$->modTrace(GRAMMARP->allTracingOn($$->fileline()));
1189 $$->timeunit(PARSEP->timeLastUnit());
1190 $$->unconnectedDrive(PARSEP->unconnectedDrive());
1191 PARSEP->rootp()->addModulep($$);
1192 SYMP->pushNew($$);
1193 GRAMMARP->m_modp = $$; }
1194 ;
1195
1196 importsAndParametersE<nodep>: // IEEE: common part of module_declaration, interface_declaration, program_declaration
1197 // // { package_import_declaration } [ parameter_port_list ]
1198 parameter_port_listE { $$ = $1; }
1199 | package_import_declarationList parameter_port_listE { $$ = $1->addNextNull($2); }
1200 ;
1201
1202 udpFront<nodeModulep>:
1203 yPRIMITIVE lifetimeE idAny
1204 { $$ = new AstPrimitive($<fl>3, *$3); $$->inLibrary(true);
1205 $$->lifetime($2);
1206 $$->modTrace(false);
1207 $$->addStmtp(new AstPragma($<fl>3, AstPragmaType::INLINE_MODULE));
1208 GRAMMARP->m_tracingParse = false;
1209 PARSEP->rootp()->addModulep($$);
1210 SYMP->pushNew($$); }
1211 ;
1212
1213 parameter_value_assignmentE<pinp>: // IEEE: [ parameter_value_assignment ]
1214 /* empty */ { $$ = nullptr; }
1215 | parameter_value_assignment { $$ = $1; }
1216 ;
1217
1218 parameter_value_assignment<pinp>: // IEEE: parameter_value_assignment
1219 '#' '(' cellparamList ')' { $$ = $3; }
1220 // // Parentheses are optional around a single parameter
1221 | '#' yaINTNUM { $$ = new AstPin($<fl>2, 1, "", new AstConst($<fl>2, *$2)); }
1222 | '#' yaFLOATNUM { $$ = new AstPin($<fl>2, 1, "",
1223 new AstConst($<fl>2, AstConst::Unsized32(),
1224 (int)(($2<0)?($2-0.5):($2+0.5)))); }
1225 | '#' timeNumAdjusted { $$ = new AstPin($<fl>2, 1, "", $2); }
1226 | '#' idClassSel { $$ = new AstPin($<fl>2, 1, "", $2); }
1227 // // Not needed in Verilator:
1228 // // Side effect of combining *_instantiations
1229 // // '#' delay_value { UNSUP }
1230 ;
1231
1232 parameter_value_assignmentClass<pinp>: // IEEE: [ parameter_value_assignment ] (for classes)
1233 // // Like parameter_value_assignment, but for classes only, which always have #()
1234 '#' '(' cellparamList ')' { $$ = $3; }
1235 ;
1236
1237 parameter_port_listE<nodep>: // IEEE: parameter_port_list + empty == parameter_value_assignment
1238 /* empty */ { $$ = nullptr; }
1239 | '#' '(' ')' { $$ = nullptr; }
1240 // // IEEE: '#' '(' list_of_param_assignments { ',' parameter_port_declaration } ')'
1241 // // IEEE: '#' '(' parameter_port_declaration { ',' parameter_port_declaration } ')'
1242 // // Can't just do that as "," conflicts with between vars and between stmts, so
1243 // // split into pre-comma and post-comma parts
1244 | '#' '(' {VARRESET_LIST(GPARAM);} paramPortDeclOrArgList ')' { $$ = $4; VARRESET_NONLIST(UNKNOWN); }
1245 // // Note legal to start with "a=b" with no parameter statement
1246 ;
1247
1248 paramPortDeclOrArgList<nodep>: // IEEE: list_of_param_assignments + { parameter_port_declaration }
1249 paramPortDeclOrArg { $$ = $1; }
1250 | paramPortDeclOrArgList ',' paramPortDeclOrArg { $$ = $1->addNext($3); }
1251 ;
1252
1253 paramPortDeclOrArg<nodep>: // IEEE: param_assignment + parameter_port_declaration
1254 // // We combine the two as we can't tell which follows a comma
1255 parameter_port_declarationFrontE param_assignment { $$ = $2; }
1256 | parameter_port_declarationTypeFrontE type_assignment { $$ = $2; }
1257 | vlTag { $$ = nullptr; }
1258 ;
1259
1260 portsStarE<nodep>: // IEEE: .* + list_of_ports + list_of_port_declarations + empty
1261 /* empty */ { $$ = nullptr; }
1262 | '(' ')' { $$ = nullptr; }
1263 // // .* expanded from module_declaration
1264 //UNSUP '(' yP_DOTSTAR ')' { UNSUP }
1265 | '(' {VARRESET_LIST(PORT);} list_of_ports ')' { $$ = $3; VARRESET_NONLIST(UNKNOWN); }
1266 ;
1267
1268 list_of_portsE<nodep>: // IEEE: list_of_ports + list_of_port_declarations
1269 portAndTagE { $$ = $1; }
1270 | list_of_portsE ',' portAndTagE { $$ = $1->addNextNull($3); }
1271 ;
1272
1273 list_of_ports<nodep>: // IEEE: list_of_ports + list_of_port_declarations
1274 portAndTag { $$ = $1; }
1275 | list_of_portsE ',' portAndTagE { $$ = $1->addNextNull($3); }
1276 ;
1277
1278 portAndTagE<nodep>:
1279 /* empty */
1280 { int p = PINNUMINC();
1281 const string name = "__pinNumber" + cvtToStr(p);
1282 $$ = new AstPort{CRELINE(), p, name};
1283 AstVar* varp = new AstVar{CRELINE(), AstVarType::PORT, name, VFlagChildDType{},
1284 new AstBasicDType{CRELINE(), LOGIC_IMPLICIT}};
1285 varp->declDirection(VDirection::INPUT);
1286 varp->direction(VDirection::INPUT);
1287 varp->ansi(false);
1288 varp->declTyped(true);
1289 varp->trace(false);
1290 $$ = $$->addNext(varp);
1291 $$->v3warn(NULLPORT, "Null port on module (perhaps extraneous comma)"); }
1292 | portAndTag { $$ = $1; }
1293 ;
1294
1295 portAndTag<nodep>:
1296 port { $$ = $1; }
1297 | vlTag port { $$ = $2; } // Tag will associate with previous port
1298 ;
1299
1300 port<nodep>: // ==IEEE: port
1301 // // SEE ALSO port_declaration, tf_port_declaration,
1302 // // data_declarationVarFront
1303 //
1304 // // Though not type for interfaces, we factor out the port direction and type
1305 // // so we can simply handle it in one place
1306 //
1307 // // IEEE: interface_port_header port_identifier { unpacked_dimension }
1308 // // Expanded interface_port_header
1309 // // We use instantCb here because the non-port form looks just like a module instantiation
1310 portDirNetE id/*interface*/ portSig variable_dimensionListE sigAttrListE
1311 { $$ = $3; VARDECL(IFACEREF); VARIO(NONE);
1312 VARDTYPE(new AstIfaceRefDType($<fl>2,"",*$2));
1313 $$->addNextNull(VARDONEP($$,$4,$5)); }
1314 | portDirNetE id/*interface*/ '.' idAny/*modport*/ portSig variable_dimensionListE sigAttrListE
1315 { $$ = $5; VARDECL(IFACEREF); VARIO(NONE);
1316 VARDTYPE(new AstIfaceRefDType($<fl>2, $<fl>4, "", *$2, *$4));
1317 $$->addNextNull(VARDONEP($$,$6,$7)); }
1318 | portDirNetE yINTERFACE portSig rangeListE sigAttrListE
1319 { $$ = nullptr; BBUNSUP($<fl>2, "Unsupported: virtual or generic interfaces"); }
1320 | portDirNetE yINTERFACE '.' idAny/*modport*/ portSig rangeListE sigAttrListE
1321 { $$ = nullptr; BBUNSUP($<fl>2, "Unsupported: virtual or generic interfaces"); }
1322 //
1323 // // IEEE: ansi_port_declaration, with [port_direction] removed
1324 // // IEEE: [ net_port_header | interface_port_header ] port_identifier { unpacked_dimension } [ '=' constant_expression ]
1325 // // IEEE: [ net_port_header | variable_port_header ] '.' port_identifier '(' [ expression ] ')'
1326 // // IEEE: [ variable_port_header ] port_identifier { variable_dimension } [ '=' constant_expression ]
1327 // // Substitute net_port_header = [ port_direction ] net_port_type
1328 // // Substitute variable_port_header = [ port_direction ] variable_port_type
1329 // // Substitute net_port_type = [ net_type ] data_type_or_implicit
1330 // // Substitute variable_port_type = var_data_type
1331 // // Substitute var_data_type = data_type | yVAR data_type_or_implicit
1332 // // [ [ port_direction ] net_port_type | interface_port_header ] port_identifier { unpacked_dimension }
1333 // // [ [ port_direction ] var_data_type ] port_identifier variable_dimensionListE [ '=' constant_expression ]
1334 // // [ [ port_direction ] net_port_type | [ port_direction ] var_data_type ] '.' port_identifier '(' [ expression ] ')'
1335 //
1336 // // Remove optional '[...] id' is in portAssignment
1337 // // Remove optional '[port_direction]' is in port
1338 // // net_port_type | interface_port_header port_identifier { unpacked_dimension }
1339 // // net_port_type | interface_port_header port_identifier { unpacked_dimension }
1340 // // var_data_type port_identifier variable_dimensionListE [ '=' constExpr ]
1341 // // net_port_type | [ port_direction ] var_data_type '.' port_identifier '(' [ expr ] ')'
1342 // // Expand implicit_type
1343 //
1344 // // variable_dimensionListE instead of rangeListE to avoid conflicts
1345 //
1346 // // Note implicit rules looks just line declaring additional followon port
1347 // // No VARDECL("port") for implicit, as we don't want to declare variables for them
1348 //UNSUP portDirNetE data_type '.' portSig '(' portAssignExprE ')' sigAttrListE
1349 //UNSUP { UNSUP }
1350 //UNSUP portDirNetE yVAR data_type '.' portSig '(' portAssignExprE ')' sigAttrListE
1351 //UNSUP { UNSUP }
1352 //UNSUP portDirNetE yVAR implicit_type '.' portSig '(' portAssignExprE ')' sigAttrListE
1353 //UNSUP { UNSUP }
1354 //UNSUP portDirNetE signingE rangeList '.' portSig '(' portAssignExprE ')' sigAttrListE
1355 //UNSUP { UNSUP }
1356 //UNSUP portDirNetE /*implicit*/ '.' portSig '(' portAssignExprE ')' sigAttrListE
1357 //UNSUP { UNSUP }
1358 //
1359 | portDirNetE data_type portSig variable_dimensionListE sigAttrListE
1360 { $$=$3; VARDTYPE($2); $$->addNextNull(VARDONEP($$,$4,$5)); }
1361 | portDirNetE yVAR data_type portSig variable_dimensionListE sigAttrListE
1362 { $$=$4; VARDTYPE($3); $$->addNextNull(VARDONEP($$,$5,$6)); }
1363 | portDirNetE yVAR implicit_typeE portSig variable_dimensionListE sigAttrListE
1364 { $$=$4; VARDTYPE($3); $$->addNextNull(VARDONEP($$,$5,$6)); }
1365 | portDirNetE signing portSig variable_dimensionListE sigAttrListE
1366 { $$=$3; VARDTYPE_NDECL(new AstBasicDType($3->fileline(), LOGIC_IMPLICIT, $2)); $$->addNextNull(VARDONEP($$,$4,$5)); }
1367 | portDirNetE signingE rangeList portSig variable_dimensionListE sigAttrListE
1368 { $$=$4; VARDTYPE_NDECL(GRAMMARP->addRange(new AstBasicDType($3->fileline(), LOGIC_IMPLICIT, $2), $3,true)); $$->addNextNull(VARDONEP($$,$5,$6)); }
1369 | portDirNetE /*implicit*/ portSig variable_dimensionListE sigAttrListE
1370 { $$=$2; /*VARDTYPE-same*/ $$->addNextNull(VARDONEP($$,$3,$4)); }
1371 //
1372 | portDirNetE data_type portSig variable_dimensionListE sigAttrListE '=' constExpr
1373 { $$=$3; VARDTYPE($2); if (AstVar* vp = VARDONEP($$, $4, $5)) { $$->addNextNull(vp); vp->valuep($7); } }
1374 | portDirNetE yVAR data_type portSig variable_dimensionListE sigAttrListE '=' constExpr
1375 { $$=$4; VARDTYPE($3); if (AstVar* vp = VARDONEP($$, $5, $6)) { $$->addNextNull(vp); vp->valuep($8); } }
1376 | portDirNetE yVAR implicit_typeE portSig variable_dimensionListE sigAttrListE '=' constExpr
1377 { $$=$4; VARDTYPE($3); if (AstVar* vp = VARDONEP($$, $5, $6)) { $$->addNextNull(vp); vp->valuep($8); } }
1378 | portDirNetE /*implicit*/ portSig variable_dimensionListE sigAttrListE '=' constExpr
1379 { $$=$2; /*VARDTYPE-same*/ if (AstVar* vp = VARDONEP($$, $3, $4)) { $$->addNextNull(vp); vp->valuep($6); } }
1380 ;
1381
1382 portDirNetE: // IEEE: part of port, optional net type and/or direction
1383 /* empty */ { }
1384 // // Per spec, if direction given default the nettype.
1385 // // The higher level rule may override this VARDTYPE with one later in the parse.
1386 | port_direction { VARDECL(PORT); VARDTYPE_NDECL(nullptr); }
1387 | port_direction { VARDECL(PORT); } net_type { VARDTYPE_NDECL(nullptr); } // net_type calls VARDECL
1388 | net_type { VARDTYPE_NDECL(nullptr); } // net_type calls VARDECL
1389 ;
1390
1391 port_declNetE: // IEEE: part of port_declaration, optional net type
1392 /* empty */ { }
1393 | net_type { } // net_type calls VARDECL
1394 ;
1395
1396 portSig<nodep>:
1397 id/*port*/ { $$ = new AstPort($<fl>1,PINNUMINC(),*$1); }
1398 | idSVKwd { $$ = new AstPort($<fl>1,PINNUMINC(),*$1); }
1399 ;
1400
1401 //**********************************************************************
1402 // Interface headers
1403
1404 interface_declaration: // IEEE: interface_declaration + interface_nonansi_header + interface_ansi_header:
1405 // // timeunits_delcarationE is instead in interface_item
1406 intFront importsAndParametersE portsStarE ';'
1407 interface_itemListE yENDINTERFACE endLabelE
1408 { if ($2) $1->addStmtp($2);
1409 if ($3) $1->addStmtp($3);
1410 if ($5) $1->addStmtp($5);
1411 SYMP->popScope($1); }
1412 | yEXTERN intFront parameter_port_listE portsStarE ';'
1413 { BBUNSUP($<fl>1, "Unsupported: extern interface"); }
1414 ;
1415
1416 intFront<nodeModulep>:
1417 yINTERFACE lifetimeE idAny/*new_interface*/
1418 { $$ = new AstIface($<fl>3, *$3);
1419 $$->inLibrary(true);
1420 $$->lifetime($2);
1421 PARSEP->rootp()->addModulep($$);
1422 SYMP->pushNew($$); }
1423 ;
1424
1425 interface_itemListE<nodep>:
1426 /* empty */ { $$ = nullptr; }
1427 | interface_itemList { $$ = $1; }
1428 ;
1429
1430 interface_itemList<nodep>:
1431 interface_item { $$ = $1; }
1432 | interface_itemList interface_item { $$ = $1->addNextNull($2); }
1433 ;
1434
1435 interface_item<nodep>: // IEEE: interface_item + non_port_interface_item
1436 port_declaration ';' { $$ = $1; }
1437 // // IEEE: non_port_interface_item
1438 // // IEEE: generate_region
1439 | interface_generate_region { $$ = $1; }
1440 | interface_or_generate_item { $$ = $1; }
1441 | program_declaration
1442 { $$ = nullptr; BBUNSUP(CRELINE(), "Unsupported: program decls within interface decls"); }
1443 // // IEEE 1800-2017: modport_item
1444 // // See instead old 2012 position in interface_or_generate_item
1445 | interface_declaration
1446 { $$ = nullptr; BBUNSUP(CRELINE(), "Unsupported: interface decls within interface decls"); }
1447 | timeunits_declaration { $$ = $1; }
1448 // // See note in interface_or_generate item
1449 | module_common_item { $$ = $1; }
1450 ;
1451
1452 interface_generate_region<nodep>: // ==IEEE: generate_region
1453 yGENERATE interface_itemList yENDGENERATE { $$ = $2; }
1454 | yGENERATE yENDGENERATE { $$ = nullptr; }
1455 ;
1456
1457 interface_or_generate_item<nodep>: // ==IEEE: interface_or_generate_item
1458 // // module_common_item in interface_item, as otherwise duplicated
1459 // // with module_or_generate_item's module_common_item
1460 modport_declaration { $$ = $1; }
1461 | extern_tf_declaration { $$ = $1; }
1462 ;
1463
1464 //**********************************************************************
1465 // Program headers
1466
1467 anonymous_program<nodep>: // ==IEEE: anonymous_program
1468 // // See the spec - this doesn't change the scope, items still go up "top"
1469 yPROGRAM ';' anonymous_program_itemListE yENDPROGRAM
1470 { $$ = nullptr; BBUNSUP($<fl>1, "Unsupported: Anonymous programs"); }
1471 ;
1472
1473 anonymous_program_itemListE<nodep>: // IEEE: { anonymous_program_item }
1474 /* empty */ { $$ = nullptr; }
1475 | anonymous_program_itemList { $$ = $1; }
1476 ;
1477
1478 anonymous_program_itemList<nodep>: // IEEE: { anonymous_program_item }
1479 anonymous_program_item { $$ = $1; }
1480 | anonymous_program_itemList anonymous_program_item { $$ = $1->addNextNull($2); }
1481 ;
1482
1483 anonymous_program_item<nodep>: // ==IEEE: anonymous_program_item
1484 task_declaration { $$ = $1; }
1485 | function_declaration { $$ = $1; }
1486 | class_declaration { $$ = $1; }
1487 //UNSUP covergroup_declaration { $$ = $1; }
1488 // // class_constructor_declaration is part of function_declaration
1489 | ';' { $$ = nullptr; }
1490 ;
1491
1492 program_declaration: // IEEE: program_declaration + program_nonansi_header + program_ansi_header:
1493 // // timeunits_delcarationE is instead in program_item
1494 pgmFront parameter_port_listE portsStarE ';'
1495 /*cont*/ program_itemListE yENDPROGRAM endLabelE
1496 { $1->modTrace(GRAMMARP->allTracingOn($1->fileline())); // Stash for implicit wires, etc
1497 if ($2) $1->addStmtp($2);
1498 if ($3) $1->addStmtp($3);
1499 if ($5) $1->addStmtp($5);
1500 GRAMMARP->m_modp = nullptr;
1501 SYMP->popScope($1);
1502 GRAMMARP->endLabel($<fl>7,$1,$7); }
1503 | yEXTERN pgmFront parameter_port_listE portsStarE ';'
1504 { BBUNSUP($<fl>1, "Unsupported: extern program");
1505 SYMP->popScope($2); }
1506 ;
1507
1508 pgmFront<nodeModulep>:
1509 yPROGRAM lifetimeE idAny/*new_program*/
1510 { $$ = new AstModule($<fl>3, *$3, true);
1511 $$->lifetime($2);
1512 $$->inLibrary(PARSEP->inLibrary() || $$->fileline()->celldefineOn());
1513 $$->modTrace(GRAMMARP->allTracingOn($$->fileline()));
1514 $$->timeunit(PARSEP->timeLastUnit());
1515 PARSEP->rootp()->addModulep($$);
1516 SYMP->pushNew($$);
1517 GRAMMARP->m_modp = $$; }
1518 ;
1519
1520 program_itemListE<nodep>: // ==IEEE: [{ program_item }]
1521 /* empty */ { $$ = nullptr; }
1522 | program_itemList { $$ = $1; }
1523 ;
1524
1525 program_itemList<nodep>: // ==IEEE: { program_item }
1526 program_item { $$ = $1; }
1527 | program_itemList program_item { $$ = $1->addNextNull($2); }
1528 ;
1529
1530 program_item<nodep>: // ==IEEE: program_item
1531 port_declaration ';' { $$ = $1; }
1532 | non_port_program_item { $$ = $1; }
1533 ;
1534
1535 non_port_program_item<nodep>: // ==IEEE: non_port_program_item
1536 continuous_assign { $$ = $1; }
1537 | module_or_generate_item_declaration { $$ = $1; }
1538 | initial_construct { $$ = $1; }
1539 | final_construct { $$ = $1; }
1540 | concurrent_assertion_item { $$ = $1; }
1541 | timeunits_declaration { $$ = $1; }
1542 | program_generate_item { $$ = $1; }
1543 ;
1544
1545 program_generate_item<nodep>: // ==IEEE: program_generate_item
1546 loop_generate_construct { $$ = $1; }
1547 | conditional_generate_construct { $$ = $1; }
1548 | generate_region { $$ = $1; }
1549 | elaboration_system_task { $$ = $1; }
1550 ;
1551
1552 extern_tf_declaration<nodep>: // ==IEEE: extern_tf_declaration
1553 yEXTERN task_prototype ';'
1554 { $$ = nullptr; BBUNSUP($<fl>1, "Unsupported: extern task"); }
1555 | yEXTERN function_prototype ';'
1556 { $$ = nullptr; BBUNSUP($<fl>1, "Unsupported: extern function"); }
1557 | yEXTERN yFORKJOIN task_prototype ';'
1558 { $$ = nullptr; BBUNSUP($<fl>1, "Unsupported: extern forkjoin"); }
1559 ;
1560
1561 modport_declaration<nodep>: // ==IEEE: modport_declaration
1562 yMODPORT modport_itemList ';' { $$ = $2; }
1563 ;
1564
1565 modport_itemList<nodep>: // IEEE: part of modport_declaration
1566 modport_item { $$ = $1; }
1567 | modport_itemList ',' modport_item { $$ = $1->addNextNull($3); }
1568 ;
1569
1570 modport_item<nodep>: // ==IEEE: modport_item
1571 id/*new-modport*/ '('
1572 /*mid*/ { VARRESET_NONLIST(UNKNOWN); VARIO(INOUT); }
1573 /*cont*/ modportPortsDeclList ')' { $$ = new AstModport($<fl>1, *$1, $4); }
1574 ;
1575
1576 modportPortsDeclList<nodep>:
1577 modportPortsDecl { $$ = $1; }
1578 | modportPortsDeclList ',' modportPortsDecl { $$ = $1->addNextNull($3); }
1579 ;
1580
1581 // IEEE: modport_ports_declaration + modport_simple_ports_declaration
1582 // + (modport_tf_ports_declaration+import_export) + modport_clocking_declaration
1583 // We've expanded the lists each take to instead just have standalone ID ports.
1584 // We track the type as with the V2k series of defines, then create as each ID is seen.
1585 modportPortsDecl<nodep>:
1586 // // IEEE: modport_simple_ports_declaration
1587 port_direction modportSimplePort { $$ = new AstModportVarRef($<fl>2, *$2, GRAMMARP->m_varIO); }
1588 // // IEEE: modport_clocking_declaration
1589 | yCLOCKING idAny/*clocking_identifier*/
1590 { $$ = nullptr; BBUNSUP($<fl>1, "Unsupported: Modport clocking"); }
1591 // // IEEE: yIMPORT modport_tf_port
1592 // // IEEE: yEXPORT modport_tf_port
1593 // // modport_tf_port expanded here
1594 | yIMPORT id/*tf_identifier*/ { $$ = new AstModportFTaskRef($<fl>2, *$2, false); }
1595 | yEXPORT id/*tf_identifier*/ { $$ = new AstModportFTaskRef($<fl>2, *$2, true); }
1596 | yIMPORT method_prototype
1597 { $$ = nullptr; BBUNSUP($<fl>1, "Unsupported: Modport import with prototype"); }
1598 | yEXPORT method_prototype
1599 { $$ = nullptr; BBUNSUP($<fl>1, "Unsupported: Modport export with prototype"); }
1600 // Continuations of above after a comma.
1601 // // IEEE: modport_simple_ports_declaration
1602 | modportSimplePort { $$ = new AstModportVarRef($<fl>1,*$1,GRAMMARP->m_varIO); }
1603 ;
1604
1605 modportSimplePort<strp>: // IEEE: modport_simple_port or modport_tf_port, depending what keyword was earlier
1606 id { $$ = $1; }
1607 //UNSUP '.' idAny '(' ')' { }
1608 //UNSUP '.' idAny '(' expr ')' { }
1609 ;
1610
1611 //************************************************
1612 // Variable Declarations
1613
1614 genvar_declaration<nodep>: // ==IEEE: genvar_declaration
1615 yGENVAR list_of_genvar_identifiers ';' { $$ = $2; }
1616 ;
1617
1618 list_of_genvar_identifiers<nodep>: // IEEE: list_of_genvar_identifiers (for declaration)
1619 genvar_identifierDecl { $$ = $1; }
1620 | list_of_genvar_identifiers ',' genvar_identifierDecl { $$ = $1->addNext($3); }
1621 ;
1622
1623 genvar_identifierDecl<varp>: // IEEE: genvar_identifier (for declaration)
1624 id/*new-genvar_identifier*/ sigAttrListE
1625 { VARRESET_NONLIST(GENVAR);
1626 VARDTYPE(new AstBasicDType($<fl>1, AstBasicDTypeKwd::INTEGER));
1627 $$ = VARDONEA($<fl>1, *$1, nullptr, $2); }
1628 ;
1629
1630 parameter_declaration<nodep>: // IEEE: local_ or parameter_declaration
1631 // // IEEE: yPARAMETER yTYPE list_of_type_assignments ';'
1632 // // Instead of list_of_type_assignments
1633 // // we use list_of_param_assignments because for port handling
1634 // // it already must accept types, so simpler to have code only one place
1635 // // Front must execute first so VARDTYPE is ready before list of vars
1636 parameter_declarationFront list_of_param_assignments { $$ = $2; }
1637 | parameter_declarationTypeFront list_of_type_assignments { $$ = $2; }
1638 ;
1639
1640 parameter_declarationFront: // IEEE: local_ or parameter_declaration w/o assignment
1641 // // Front must execute first so VARDTYPE is ready before list of vars
1642 varParamReset implicit_typeE { /*VARRESET-in-varParam*/ VARDTYPE($2); }
1643 | varParamReset data_type { /*VARRESET-in-varParam*/ VARDTYPE($2); }
1644 ;
1645
1646 parameter_declarationTypeFront: // IEEE: local_ or parameter_declaration w/o assignment
1647 // // Front must execute first so VARDTYPE is ready before list of vars
1648 varParamReset yTYPE { /*VARRESET-in-varParam*/ VARDTYPE(new AstParseTypeDType($2)); }
1649 ;
1650
1651 parameter_port_declarationFrontE: // IEEE: local_ or parameter_port_declaration w/o assignment
1652 // // IEEE: parameter_declaration (minus assignment)
1653 // // IEEE: local_parameter_declaration (minus assignment)
1654 // // Front must execute first so VARDTYPE is ready before list of vars
1655 varParamReset implicit_typeE { /*VARRESET-in-varParam*/ VARDTYPE($2); }
1656 | varParamReset data_type { /*VARRESET-in-varParam*/ VARDTYPE($2); }
1657 | implicit_typeE { /*VARRESET-in-varParam*/ VARDTYPE($1); }
1658 | data_type { /*VARRESET-in-varParam*/ VARDTYPE($1); }
1659 ;
1660
1661 parameter_port_declarationTypeFrontE: // IEEE: parameter_port_declaration w/o assignment
1662 // // IEEE: parameter_declaration (minus assignment)
1663 // // IEEE: local_parameter_declaration (minus assignment)
1664 // // Front must execute first so VARDTYPE is ready before list of vars
1665 varParamReset yTYPE { /*VARRESET-in-varParam*/ VARDTYPE(new AstParseTypeDType($2)); }
1666 | yTYPE { /*VARRESET-in-varParam*/ VARDTYPE(new AstParseTypeDType($1)); }
1667 ;
1668
1669 net_declaration<nodep>: // IEEE: net_declaration - excluding implict
1670 net_declarationFront netSigList ';' { $$ = $2; }
1671 ;
1672
1673 net_declarationFront: // IEEE: beginning of net_declaration
1674 net_declRESET net_type strengthSpecE net_scalaredE net_dataTypeE { VARDTYPE_NDECL($5); }
1675 //UNSUP net_declRESET yINTERCONNECT signingE rangeListE { VARNET($2); VARDTYPE(x); }
1676 ;
1677
1678 net_declRESET:
1679 /* empty */ { VARRESET_NONLIST(UNKNOWN); }
1680 ;
1681
1682 net_scalaredE:
1683 /* empty */ { }
1684 // //UNSUP: ySCALARED/yVECTORED ignored
1685 | ySCALARED { }
1686 | yVECTORED { }
1687 ;
1688
1689 net_dataTypeE<nodeDTypep>:
1690 // // If there's a SV data type there shouldn't be a delay on this wire
1691 // // Otherwise #(...) can't be determined to be a delay or parameters
1692 // // Submit this as a footnote to the committee
1693 var_data_type { $$ = $1; }
1694 | signingE rangeList delayE { $$ = GRAMMARP->addRange(new AstBasicDType($2->fileline(), LOGIC, $1),$2,true); } // not implicit
1695 | signing { $$ = new AstBasicDType($<fl>1, LOGIC, $1); } // not implicit
1696 | /*implicit*/ delayE { $$ = new AstBasicDType(CRELINE(), LOGIC); } // not implicit
1697 ;
1698
1699 net_type: // ==IEEE: net_type
1700 ySUPPLY0 { VARDECL(SUPPLY0); }
1701 | ySUPPLY1 { VARDECL(SUPPLY1); }
1702 | yTRI { VARDECL(TRIWIRE); }
1703 | yTRI0 { VARDECL(TRI0); }
1704 | yTRI1 { VARDECL(TRI1); }
1705 | yTRIAND { VARDECL(WIRE); BBUNSUP($1, "Unsupported: triand"); }
1706 | yTRIOR { VARDECL(WIRE); BBUNSUP($1, "Unsupported: trior"); }
1707 | yTRIREG { VARDECL(WIRE); BBUNSUP($1, "Unsupported: trireg"); }
1708 | yWAND { VARDECL(WIRE); BBUNSUP($1, "Unsupported: wand"); }
1709 | yWIRE { VARDECL(WIRE); }
1710 | yWOR { VARDECL(WIRE); BBUNSUP($1, "Unsupported: wor"); }
1711 // // VAMS - somewhat hackish
1712 | yWREAL { VARDECL(WREAL); }
1713 ;
1714
1715 varParamReset:
1716 yPARAMETER { VARRESET_NONLIST(GPARAM); }
1717 | yLOCALPARAM { VARRESET_NONLIST(LPARAM); }
1718 ;
1719
1720 port_direction: // ==IEEE: port_direction + tf_port_direction
1721 // // IEEE 19.8 just "input" FIRST forces type to wire - we'll ignore that here
1722 // // Only used for ANSI declarations
1723 yINPUT { GRAMMARP->m_pinAnsi = true; VARIO(INPUT); }
1724 | yOUTPUT { GRAMMARP->m_pinAnsi = true; VARIO(OUTPUT); }
1725 | yINOUT { GRAMMARP->m_pinAnsi = true; VARIO(INOUT); }
1726 | yREF { GRAMMARP->m_pinAnsi = true; VARIO(REF); }
1727 | yCONST__REF yREF { GRAMMARP->m_pinAnsi = true; VARIO(CONSTREF); }
1728 ;
1729
1730 port_directionReset: // IEEE: port_direction that starts a port_declaraiton
1731 // // Used only for declarations outside the port list
1732 yINPUT { VARRESET_NONLIST(UNKNOWN); VARIO(INPUT); }
1733 | yOUTPUT { VARRESET_NONLIST(UNKNOWN); VARIO(OUTPUT); }
1734 | yINOUT { VARRESET_NONLIST(UNKNOWN); VARIO(INOUT); }
1735 | yREF { VARRESET_NONLIST(UNKNOWN); VARIO(REF); }
1736 | yCONST__REF yREF { VARRESET_NONLIST(UNKNOWN); VARIO(CONSTREF); }
1737 ;
1738
1739 port_declaration<nodep>: // ==IEEE: port_declaration
1740 // // Non-ANSI; used inside block followed by ';'
1741 // // SEE ALSO port, tf_port_declaration, data_declarationVarFront
1742 //
1743 // // IEEE: inout_declaration
1744 // // IEEE: input_declaration
1745 // // IEEE: output_declaration
1746 // // IEEE: ref_declaration
1747 port_directionReset port_declNetE data_type
1748 /*mid*/ { VARDTYPE($3); }
1749 /*cont*/ list_of_variable_decl_assignments { $$ = $5; }
1750 | port_directionReset port_declNetE yVAR data_type
1751 /*mid*/ { VARDTYPE($4); }
1752 /*cont*/ list_of_variable_decl_assignments { $$ = $6; }
1753 | port_directionReset port_declNetE yVAR implicit_typeE
1754 /*mid*/ { VARDTYPE($4); }
1755 /*cont*/ list_of_variable_decl_assignments { $$ = $6; }
1756 | port_directionReset port_declNetE signingE rangeList
1757 /*mid*/ { VARDTYPE_NDECL(GRAMMARP->addRange(new AstBasicDType($4->fileline(), LOGIC_IMPLICIT, $3), $4, true)); }
1758 /*cont*/ list_of_variable_decl_assignments { $$ = $6; }
1759 | port_directionReset port_declNetE signing
1760 /*mid*/ { VARDTYPE_NDECL(new AstBasicDType($<fl>3, LOGIC_IMPLICIT, $3)); }
1761 /*cont*/ list_of_variable_decl_assignments { $$ = $5; }
1762 | port_directionReset port_declNetE /*implicit*/
1763 /*mid*/ { VARDTYPE_NDECL(nullptr); /*default_nettype*/ }
1764 /*cont*/ list_of_variable_decl_assignments { $$ = $4; }
1765 // // IEEE: interface_declaration
1766 // // Looks just like variable declaration unless has a period
1767 // // See etcInst
1768 ;
1769
1770 tf_port_declaration<nodep>: // ==IEEE: tf_port_declaration
1771 // // Used inside function; followed by ';'
1772 // // SEE ALSO port_declaration, port, data_declarationVarFront
1773 //
1774 port_directionReset data_type { VARDTYPE($2); } list_of_tf_variable_identifiers ';' { $$ = $4; }
1775 | port_directionReset implicit_typeE { VARDTYPE_NDECL($2); } list_of_tf_variable_identifiers ';' { $$ = $4; }
1776 | port_directionReset yVAR data_type { VARDTYPE($3); } list_of_tf_variable_identifiers ';' { $$ = $5; }
1777 | port_directionReset yVAR implicit_typeE { VARDTYPE($3); } list_of_tf_variable_identifiers ';' { $$ = $5; }
1778 ;
1779
1780 integer_atom_type<basicDTypep>: // ==IEEE: integer_atom_type
1781 yBYTE { $$ = new AstBasicDType($1,AstBasicDTypeKwd::BYTE); }
1782 | ySHORTINT { $$ = new AstBasicDType($1,AstBasicDTypeKwd::SHORTINT); }
1783 | yINT { $$ = new AstBasicDType($1,AstBasicDTypeKwd::INT); }
1784 | yLONGINT { $$ = new AstBasicDType($1,AstBasicDTypeKwd::LONGINT); }
1785 | yINTEGER { $$ = new AstBasicDType($1,AstBasicDTypeKwd::INTEGER); }
1786 | yTIME { $$ = new AstBasicDType($1,AstBasicDTypeKwd::TIME); }
1787 ;
1788
1789 integer_vector_type<basicDTypep>: // ==IEEE: integer_atom_type
1790 yBIT { $$ = new AstBasicDType($1,AstBasicDTypeKwd::BIT); }
1791 | yLOGIC { $$ = new AstBasicDType($1,AstBasicDTypeKwd::LOGIC); }
1792 | yREG { $$ = new AstBasicDType($1,AstBasicDTypeKwd::LOGIC); } // logic==reg
1793 ;
1794
1795 non_integer_type<basicDTypep>: // ==IEEE: non_integer_type
1796 yREAL { $$ = new AstBasicDType($1,AstBasicDTypeKwd::DOUBLE); }
1797 | yREALTIME { $$ = new AstBasicDType($1,AstBasicDTypeKwd::DOUBLE); }
1798 | ySHORTREAL { $$ = new AstBasicDType($1,AstBasicDTypeKwd::DOUBLE); UNSUPREAL($1); }
1799 ;
1800
1801 signingE<signstate>: // IEEE: signing - plus empty
1802 /*empty*/ { $$ = VSigning::NOSIGN; }
1803 | signing { $$ = $1; }
1804 ;
1805
1806 signing<signstate>: // ==IEEE: signing
1807 ySIGNED { $<fl>$ = $<fl>1; $$ = VSigning::SIGNED; }
1808 | yUNSIGNED { $<fl>$ = $<fl>1; $$ = VSigning::UNSIGNED; }
1809 ;
1810
1811 //************************************************
1812 // Data Types
1813
1814 simple_type<nodeDTypep>: // ==IEEE: simple_type
1815 // // IEEE: integer_type
1816 integer_atom_type { $$ = $1; }
1817 | integer_vector_type { $$ = $1; }
1818 | non_integer_type { $$ = $1; }
1819 // // IEEE: ps_type_identifier
1820 // // IEEE: ps_parameter_identifier (presumably a PARAMETER TYPE)
1821 // // Even though we looked up the type and have a AstNode* to it,
1822 // // we can't fully resolve it because it may have been just a forward definition.
1823 | packageClassScopeE idType
1824 { AstRefDType* const refp = new AstRefDType{$<fl>2, *$2, $1, nullptr};
1825 $$ = refp; }
1826 //
1827 // // { generate_block_identifer ... } '.'
1828 // // Need to determine if generate_block_identifier can be lex-detected
1829 ;
1830
1831 data_type<nodeDTypep>: // ==IEEE: data_type
1832 // // This expansion also replicated elsewhere, IE data_type__AndID
1833 data_typeNoRef { $$ = $1; }
1834 //
1835 // // REFERENCES
1836 //
1837 // // IEEE: [ class_scope | package_scope ] type_identifier { packed_dimension }
1838 // // IEEE: class_type
1839 // // IEEE: ps_covergroup_identifier
1840 // // Don't distinguish between types and classes so all these combined
1841 | packageClassScopeE idType packed_dimensionListE
1842 { AstRefDType* const refp = new AstRefDType{$<fl>2, *$2, $1, nullptr};
1843 $$ = GRAMMARP->createArray(refp, $3, true); }
1844 | packageClassScopeE idType parameter_value_assignmentClass packed_dimensionListE
1845 { AstRefDType* const refp = new AstRefDType{$<fl>2, *$2, $1, $3};
1846 $$ = GRAMMARP->createArray(refp, $4, true); }
1847 ;
1848
1849 data_typeBasic<nodeDTypep>: // IEEE: part of data_type
1850 integer_vector_type signingE rangeListE { $1->setSignedState($2); $$ = GRAMMARP->addRange($1,$3,true); }
1851 | integer_atom_type signingE { $1->setSignedState($2); $$ = $1; }
1852 | non_integer_type { $$ = $1; }
1853 ;
1854
1855 data_typeNoRef<nodeDTypep>: // ==IEEE: data_type, excluding class_type etc references
1856 data_typeBasic { $$ = $1; }
1857 | struct_unionDecl packed_dimensionListE { $$ = GRAMMARP->createArray(new AstDefImplicitDType($1->fileline(),"__typeimpsu"+cvtToStr(GRAMMARP->s_modTypeImpNum++),
1858 SYMP,VFlagChildDType(),$1),$2,true); }
1859 | enumDecl { $$ = new AstDefImplicitDType($1->fileline(),"__typeimpenum"+cvtToStr(GRAMMARP->s_modTypeImpNum++),
1860 SYMP,VFlagChildDType(),$1); }
1861 | ySTRING { $$ = new AstBasicDType($1,AstBasicDTypeKwd::STRING); }
1862 | yCHANDLE { $$ = new AstBasicDType($1,AstBasicDTypeKwd::CHANDLE); }
1863 | yEVENT { $$ = new AstBasicDType($1,AstBasicDTypeKwd::EVENTVALUE); }
1864 // // Rules overlap virtual_interface_declaration
1865 // // Parameters here are SV2009
1866 // // IEEE has ['.' modport] but that will conflict with port
1867 // // declarations which decode '.' modport themselves, so
1868 // // instead see data_typeVar
1869 | yVIRTUAL__INTERFACE yINTERFACE id/*interface*/
1870 { $$ = new AstBasicDType{$1, AstBasicDTypeKwd::CHANDLE};
1871 BBUNSUP($1, "Unsupported: virtual interface"); }
1872 | yVIRTUAL__anyID id/*interface*/
1873 { $$ = new AstBasicDType{$1, AstBasicDTypeKwd::CHANDLE};
1874 BBUNSUP($1, "Unsupported: virtual data type"); }
1875 | type_reference { $$ = $1; }
1876 // // IEEE: class_scope: see data_type above
1877 // // IEEE: class_type: see data_type above
1878 // // IEEE: ps_covergroup: see data_type above
1879 ;
1880
1881 data_type_or_void<nodeDTypep>: // ==IEEE: data_type_or_void
1882 data_type { $$ = $1; }
1883 //UNSUP yVOID { UNSUP } // No yTAGGED structures
1884 ;
1885
1886 var_data_type<nodeDTypep>: // ==IEEE: var_data_type
1887 data_type { $$ = $1; }
1888 | yVAR data_type { $$ = $2; }
1889 | yVAR implicit_typeE { $$ = $2; }
1890 ;
1891
1892 type_reference<nodeDTypep>: // ==IEEE: type_reference
1893 yTYPE '(' exprOrDataType ')'
1894 { $$ = new AstRefDType($1, AstRefDType::FlagTypeOfExpr(), $3); }
1895 ;
1896
1897 struct_unionDecl<nodeUOrStructDTypep>: // IEEE: part of data_type
1898 // // packedSigningE is NOP for unpacked
1899 ySTRUCT packedSigningE '{'
1900 /*mid*/ { $<nodeUOrStructDTypep>$ = new AstStructDType($1, $2); SYMP->pushNew($<nodeUOrStructDTypep>$); }
1901 /*cont*/ struct_union_memberList '}'
1902 { $$ = $<nodeUOrStructDTypep>4; $$->addMembersp($5); SYMP->popScope($$); }
1903 | yUNION taggedE packedSigningE '{'
1904 /*mid*/ { $<nodeUOrStructDTypep>$ = new AstUnionDType($1, $3); SYMP->pushNew($<nodeUOrStructDTypep>$); }
1905 /*cont*/ struct_union_memberList '}'
1906 { $$ = $<nodeUOrStructDTypep>5; $$->addMembersp($6); SYMP->popScope($$); }
1907 ;
1908
1909 struct_union_memberList<nodep>: // IEEE: { struct_union_member }
1910 struct_union_member { $$ = $1; }
1911 | struct_union_memberList struct_union_member { $$ = $1->addNextNull($2); }
1912 ;
1913
1914 struct_union_member<nodep>: // ==IEEE: struct_union_member
1915 // // UNSUP random_qualifer not propagagted until have randomize support
1916 random_qualifierE data_type_or_void
1917 /*mid*/ { GRAMMARP->m_memDTypep = $2; } // As a list follows, need to attach this dtype to each member.
1918 /*cont*/ list_of_member_decl_assignments ';' { $$ = $4; GRAMMARP->m_memDTypep = nullptr; }
1919 | vlTag { $$ = nullptr; }
1920 ;
1921
1922 list_of_member_decl_assignments<nodep>: // Derived from IEEE: list_of_variable_decl_assignments
1923 member_decl_assignment { $$ = $1; }
1924 | list_of_member_decl_assignments ',' member_decl_assignment { $$ = $1->addNextNull($3); }
1925 ;
1926
1927 member_decl_assignment<memberDTypep>: // Derived from IEEE: variable_decl_assignment
1928 // // At present we allow only packed structures/unions. So this is different from variable_decl_assignment
1929 id variable_dimensionListE
1930 { if ($2) $2->v3warn(UNPACKED, "Unsupported: Unpacked array in packed struct/union (struct/union converted to unpacked)");
1931 $$ = new AstMemberDType($<fl>1, *$1, VFlagChildDType(),
1932 AstNodeDType::cloneTreeNull(GRAMMARP->m_memDTypep, true));
1933 PARSEP->tagNodep($$);
1934 }
1935 | id variable_dimensionListE '=' variable_declExpr
1936 { BBUNSUP($4, "Unsupported: Initial values in struct/union members.");
1937 // But still need error if packed according to IEEE 7.2.2
1938 $$ = nullptr; }
1939 | idSVKwd { $$ = nullptr; }
1940 //
1941 // // IEEE: "dynamic_array_variable_identifier '[' ']' [ '=' dynamic_array_new ]"
1942 // // Matches above with variable_dimensionE = "[]"
1943 // // IEEE: "class_variable_identifier [ '=' class_new ]"
1944 // // variable_dimensionE must be empty
1945 // // Pushed into variable_declExpr:dynamic_array_new
1946 //
1947 // // IEEE: "[ covergroup_variable_identifier ] '=' class_new
1948 // // Pushed into variable_declExpr:class_new
1949 | '=' class_new
1950 { $$ = nullptr; BBUNSUP($1, "Unsupported: member declaration assignment with new()"); }
1951 ;
1952
1953 list_of_variable_decl_assignments<varp>: // ==IEEE: list_of_variable_decl_assignments
1954 variable_decl_assignment { $$ = $1; }
1955 | list_of_variable_decl_assignments ',' variable_decl_assignment { $$ = VN_CAST($1->addNextNull($3), Var); }
1956 ;
1957
1958 variable_decl_assignment<varp>: // ==IEEE: variable_decl_assignment
1959 id variable_dimensionListE sigAttrListE
1960 { $$ = VARDONEA($<fl>1,*$1,$2,$3); }
1961 | id variable_dimensionListE sigAttrListE '=' variable_declExpr
1962 { $$ = VARDONEA($<fl>1,*$1,$2,$3); $$->valuep($5); }
1963 | idSVKwd { $$ = nullptr; }
1964 //
1965 // // IEEE: "dynamic_array_variable_identifier '[' ']' [ '=' dynamic_array_new ]"
1966 // // Matches above with variable_dimensionE = "[]"
1967 // // IEEE: "class_variable_identifier [ '=' class_new ]"
1968 // // variable_dimensionE must be empty
1969 // // Pushed into variable_declExpr:dynamic_array_new
1970 //
1971 // // IEEE: "[ covergroup_variable_identifier ] '=' class_new
1972 // // Pushed into variable_declExpr:class_new
1973 | '=' class_new
1974 { $$ = nullptr; BBUNSUP($1, "Unsupported: declaration assignment with new()"); }
1975 ;
1976
1977 list_of_tf_variable_identifiers<nodep>: // ==IEEE: list_of_tf_variable_identifiers
1978 tf_variable_identifier { $$ = $1; }
1979 | list_of_tf_variable_identifiers ',' tf_variable_identifier { $$ = $1->addNext($3); }
1980 ;
1981
1982 tf_variable_identifier<varp>: // IEEE: part of list_of_tf_variable_identifiers
1983 id variable_dimensionListE sigAttrListE exprEqE
1984 { $$ = VARDONEA($<fl>1,*$1, $2, $3);
1985 if ($4) $$->addNext(new AstAssign($4->fileline(), new AstVarRef($<fl>1, *$1, VAccess::WRITE), $4)); }
1986 ;
1987
1988 variable_declExpr<nodep>: // IEEE: part of variable_decl_assignment - rhs of expr
1989 expr { $$ = $1; }
1990 | dynamic_array_new { $$ = $1; }
1991 | class_new { $$ = $1; }
1992 ;
1993
1994 variable_dimensionListE<nodeRangep>: // IEEE: variable_dimension + empty
1995 /*empty*/ { $$ = nullptr; }
1996 | variable_dimensionList { $$ = $1; }
1997 ;
1998
1999 variable_dimensionList<nodeRangep>: // IEEE: variable_dimension + empty
2000 variable_dimension { $$ = $1; }
2001 | variable_dimensionList variable_dimension { $$ = VN_CAST($1->addNext($2), NodeRange); }
2002 ;
2003
2004 variable_dimension<nodeRangep>: // ==IEEE: variable_dimension
2005 // // IEEE: unsized_dimension
2006 '[' ']' { $$ = new AstUnsizedRange($1); }
2007 // // IEEE: unpacked_dimension
2008 | anyrange { $$ = $1; }
2009 // // IEEE: unpacked_dimension (if const_expr)
2010 // // IEEE: associative_dimension (if data_type)
2011 // // Can't tell which until see if expr is data type or not
2012 | '[' exprOrDataType ']' { $$ = new AstBracketRange($1, $2); }
2013 | yP_BRASTAR ']'
2014 { $$ = nullptr; BBUNSUP($1, "Unsupported: [*] wildcard associative arrays"); }
2015 | '[' '*' ']'
2016 { $$ = nullptr; BBUNSUP($2, "Unsupported: [*] wildcard associative arrays"); }
2017 // // IEEE: queue_dimension
2018 // // '[' '$' ']' -- $ is part of expr, see '[' constExpr ']'
2019 // // '[' '$' ':' expr ']' -- anyrange:expr:$
2020 ;
2021
2022 random_qualifierE<qualifiers>: // IEEE: random_qualifier + empty
2023 /*empty*/ { $$ = VMemberQualifiers::none(); }
2024 | random_qualifier { $$ = $1; }
2025 ;
2026
2027 random_qualifier<qualifiers>: // ==IEEE: random_qualifier
2028 yRAND { $$ = VMemberQualifiers::none(); $$.m_rand = true; }
2029 | yRANDC { $$ = VMemberQualifiers::none(); $$.m_randc = true; }
2030 ;
2031
2032 taggedE:
2033 /*empty*/ { }
2034 //UNSUP yTAGGED { UNSUP }
2035 ;
2036
2037 packedSigningE<signstate>:
2038 // // VSigning::NOSIGN overloaded to indicate not packed
2039 /*empty*/ { $$ = VSigning::NOSIGN; }
2040 | yPACKED signingE { $$ = $2; if ($$ == VSigning::NOSIGN) $$ = VSigning::UNSIGNED; }
2041 ;
2042
2043 //************************************************
2044 // enum
2045
2046 // IEEE: part of data_type
2047 enumDecl<nodeDTypep>:
2048 yENUM enum_base_typeE '{' enum_nameList '}' { $$ = new AstEnumDType($1,VFlagChildDType(),$2,$4); }
2049 ;
2050
2051 enum_base_typeE<nodeDTypep>: // IEEE: enum_base_type
2052 /* empty */ { $$ = new AstBasicDType(CRELINE(), AstBasicDTypeKwd::INT); }
2053 // // Not in spec, but obviously "enum [1:0]" should work
2054 // // implicit_type expanded, without empty
2055 // // Note enum base types are always packed data types
2056 | signingE rangeList { $$ = GRAMMARP->addRange(new AstBasicDType($2->fileline(), LOGIC_IMPLICIT, $1),$2,true); }
2057 | signing { $$ = new AstBasicDType($<fl>1, LOGIC_IMPLICIT, $1); }
2058 //
2059 | integer_atom_type signingE { $1->setSignedState($2); $$ = $1; }
2060 | integer_vector_type signingE rangeListE { $1->setSignedState($2); $$ = GRAMMARP->addRange($1,$3,true); }
2061 // // below can be idAny or yaID__aTYPE
2062 // // IEEE requires a type, though no shift conflict if idAny
2063 // // IEEE: type_identifier [ packed_dimension ]
2064 // // however other simulators allow [ class_scope | package_scope ] type_identifier
2065 | idAny rangeListE
2066 { $$ = GRAMMARP->createArray(new AstRefDType($<fl>1, *$1), $2, true); }
2067 | packageClassScope idAny rangeListE
2068 { AstRefDType* refp = new AstRefDType($<fl>2, *$2, $1, nullptr);
2069 $$ = GRAMMARP->createArray(refp, $3, true); }
2070 ;
2071
2072 enum_nameList<nodep>:
2073 enum_name_declaration { $$ = $1; }
2074 | enum_nameList ',' enum_name_declaration { $$ = $1->addNextNull($3); }
2075 ;
2076
2077 enum_name_declaration<nodep>: // ==IEEE: enum_name_declaration
2078 idAny/*enum_identifier*/ enumNameRangeE enumNameStartE { $$ = new AstEnumItem($<fl>1, *$1, $2, $3); }
2079 ;
2080
2081 enumNameRangeE<nodep>: // IEEE: second part of enum_name_declaration
2082 /* empty */ { $$ = nullptr; }
2083 | '[' intnumAsConst ']' { $$ = new AstRange($1, new AstConst($1, 0), new AstConst($1, $2->toSInt()-1)); }
2084 | '[' intnumAsConst ':' intnumAsConst ']' { $$ = new AstRange($1,$2,$4); }
2085 ;
2086
2087 enumNameStartE<nodep>: // IEEE: third part of enum_name_declaration
2088 /* empty */ { $$ = nullptr; }
2089 | '=' constExpr { $$ = $2; }
2090 ;
2091
2092 intnumAsConst<constp>:
2093 yaINTNUM { $$ = new AstConst($<fl>1,*$1); }
2094 ;
2095
2096 //************************************************
2097 // Typedef
2098
2099 data_declaration<nodep>: // ==IEEE: data_declaration
2100 // // VARRESET can't be called here - conflicts
2101 data_declarationVar { $$ = $1; }
2102 | type_declaration { $$ = $1; }
2103 | package_import_declaration { $$ = $1; }
2104 // // IEEE: virtual_interface_declaration
2105 // // "yVIRTUAL yID yID" looks just like a data_declaration
2106 // // Therefore the virtual_interface_declaration term isn't used
2107 // // 1800-2009:
2108 //UNSUP net_type_declaration { $$ = $1; }
2109 | vlTag { $$ = nullptr; }
2110 ;
2111
2112 class_property<nodep>: // ==IEEE: class_property, which is {property_qualifier} data_declaration
2113 memberQualListE data_declarationVarClass { $$ = $2; $1.applyToNodes($2); }
2114 // // UNSUP: Import needs to apply local/protected from memberQualList, and error on others
2115 | memberQualListE type_declaration { $$ = $2; }
2116 // // UNSUP: Import needs to apply local/protected from memberQualList, and error on others
2117 | memberQualListE package_import_declaration { $$ = $2; }
2118 // // IEEE: virtual_interface_declaration
2119 // // "yVIRTUAL yID yID" looks just like a data_declaration
2120 // // Therefore the virtual_interface_declaration term isn't used
2121 ;
2122
2123 data_declarationVar<varp>: // IEEE: part of data_declaration
2124 // // The first declaration has complications between assuming what's the type vs ID declaring
2125 data_declarationVarFront list_of_variable_decl_assignments ';' { $$ = $2; }
2126 ;
2127
2128 data_declarationVarClass<varp>: // IEEE: part of data_declaration (for class_property)
2129 // // The first declaration has complications between assuming what's the type vs ID declaring
2130 data_declarationVarFrontClass list_of_variable_decl_assignments ';' { $$ = $2; }
2131 ;
2132
2133 data_declarationVarFront: // IEEE: part of data_declaration
2134 // // Non-ANSI; used inside block followed by ';'
2135 // // SEE ALSO port_declaration, tf_port_declaration, port
2136 //
2137 // // Expanded: "constE yVAR lifetimeE data_type"
2138 // // implicit_type expanded into /*empty*/ or "signingE rangeList"
2139 yVAR lifetimeE data_type
2140 { VARRESET_NONLIST(VAR); VARLIFE($2); VARDTYPE($3); }
2141 | yVAR lifetimeE
2142 { VARRESET_NONLIST(VAR); VARLIFE($2);
2143 VARDTYPE(new AstBasicDType($<fl>1, LOGIC_IMPLICIT)); }
2144 | yVAR lifetimeE signingE rangeList
2145 { /*VARRESET-in-ddVar*/ VARLIFE($2);
2146 VARDTYPE(GRAMMARP->addRange(new AstBasicDType($<fl>1, LOGIC_IMPLICIT, $3), $4,true)); }
2147 //
2148 // // implicit_type expanded into /*empty*/ or "signingE rangeList"
2149 | yCONST__ETC yVAR lifetimeE data_type
2150 { VARRESET_NONLIST(VAR); VARLIFE($3);
2151 VARDTYPE(new AstConstDType($<fl>2, VFlagChildDType(), $4)); }
2152 | yCONST__ETC yVAR lifetimeE
2153 { VARRESET_NONLIST(VAR); VARLIFE($3);
2154 VARDTYPE(new AstConstDType($<fl>2, VFlagChildDType(), new AstBasicDType($<fl>2, LOGIC_IMPLICIT))); }
2155 | yCONST__ETC yVAR lifetimeE signingE rangeList
2156 { VARRESET_NONLIST(VAR); VARLIFE($3);
2157 VARDTYPE(new AstConstDType($<fl>2, VFlagChildDType(),
2158 GRAMMARP->addRange(new AstBasicDType($<fl>2, LOGIC_IMPLICIT, $4), $5,true))); }
2159 //
2160 // // Expanded: "constE lifetimeE data_type"
2161 | /**/ data_type { VARRESET_NONLIST(VAR); VARDTYPE($1); }
2162 | /**/ lifetime data_type { VARRESET_NONLIST(VAR); VARLIFE($1); VARDTYPE($2); }
2163 | yCONST__ETC lifetimeE data_type
2164 { VARRESET_NONLIST(VAR); VARLIFE($2);
2165 VARDTYPE(new AstConstDType($<fl>1, VFlagChildDType(), $3)); }
2166 // // = class_new is in variable_decl_assignment
2167 ;
2168
2169 data_declarationVarFrontClass: // IEEE: part of data_declaration (for class_property)
2170 // // VARRESET called before this rule
2171 // // yCONST is removed, added to memberQual rules
2172 // // implicit_type expanded into /*empty*/ or "signingE rangeList"
2173 yVAR lifetimeE data_type { VARRESET_NONLIST(VAR); VARLIFE($2); VARDTYPE($3); }
2174 | yVAR lifetimeE { VARRESET_NONLIST(VAR); VARLIFE($2); }
2175 | yVAR lifetimeE signingE rangeList
2176 { /*VARRESET-in-ddVar*/ VARDTYPE(GRAMMARP->addRange(new AstBasicDType($<fl>1, LOGIC_IMPLICIT, $3), $4,true));
2177 VARLIFE($2); }
2178 //
2179 // // Expanded: "constE lifetimeE data_type"
2180 | data_type { VARRESET_NONLIST(VAR); VARDTYPE($1); }
2181 // // lifetime is removed, added to memberQual rules to avoid conflict
2182 // // yCONST is removed, added to memberQual rules to avoid conflict
2183 // // = class_new is in variable_decl_assignment
2184 ;
2185
2186 //UNSUPnet_type_declaration: // IEEE: net_type_declaration
2187 //UNSUP yNETTYPE data_type idAny/*net_type_identifier*/ ';' { }
2188 //UNSUP // // package_scope part of data_type
2189 //UNSUP | yNETTYPE data_type idAny yWITH__ETC packageClassScope id/*tf_identifier*/ ';' { }
2190 //UNSUP | yNETTYPE packageClassScope id/*net_type_identifier*/ idAny/*net_type_identifier*/ ';' { }
2191 //UNSUP ;
2192
2193 implicit_typeE<nodeDTypep>: // IEEE: part of *data_type_or_implicit
2194 // // Also expanded in data_declaration
2195 /* empty */ { $$ = nullptr; }
2196 | signingE rangeList { $$ = GRAMMARP->addRange(new AstBasicDType($2->fileline(), LOGIC_IMPLICIT, $1),$2,true); }
2197 | signing { $$ = new AstBasicDType($<fl>1, LOGIC_IMPLICIT, $1); }
2198 ;
2199
2200 //UNSUPassertion_variable_declaration: // IEEE: assertion_variable_declaration
2201 //UNSUP // // IEEE: var_data_type expanded
2202 //UNSUP var_data_type list_of_variable_decl_assignments ';' { }
2203 //UNSUP ;
2204
2205 type_declaration<nodep>: // ==IEEE: type_declaration
2206 // Data_type expanded
2207 yTYPEDEF data_typeNoRef
2208 /*cont*/ idAny variable_dimensionListE dtypeAttrListE ';'
2209 { AstNodeDType* dtp = $2;
2210 $$ = GRAMMARP->createTypedef($<fl>3, *$3, $5, dtp, $4); }
2211 | yTYPEDEF packageClassScope idType packed_dimensionListE
2212 /*cont*/ idAny variable_dimensionListE dtypeAttrListE ';'
2213 { AstRefDType* refp = new AstRefDType($<fl>3, *$3, $2, nullptr);
2214 AstNodeDType* dtp = GRAMMARP->createArray(refp, $4, true);
2215 $$ = GRAMMARP->createTypedef($<fl>5, *$5, $7, dtp, $6); }
2216 | yTYPEDEF packageClassScope idType parameter_value_assignmentClass packed_dimensionListE
2217 /*cont*/ idAny variable_dimensionListE dtypeAttrListE ';'
2218 { AstRefDType* refp = new AstRefDType($<fl>3, *$3, $2, $4);
2219 AstNodeDType* dtp = GRAMMARP->createArray(refp, $5, true);
2220 $$ = GRAMMARP->createTypedef($<fl>6, *$6, $8, dtp, $7); }
2221 | yTYPEDEF idType packed_dimensionListE
2222 /*cont*/ idAny variable_dimensionListE dtypeAttrListE ';'
2223 { AstRefDType* refp = new AstRefDType($<fl>2, *$2, nullptr, nullptr);
2224 AstNodeDType* dtp = GRAMMARP->createArray(refp, $3, true);
2225 $$ = GRAMMARP->createTypedef($<fl>4, *$4, $6, dtp, $5); }
2226 | yTYPEDEF idType parameter_value_assignmentClass packed_dimensionListE
2227 /*cont*/ idAny variable_dimensionListE dtypeAttrListE ';'
2228 { AstRefDType* refp = new AstRefDType($<fl>2, *$2, nullptr, $3);
2229 AstNodeDType* dtp = GRAMMARP->createArray(refp, $4, true);
2230 $$ = GRAMMARP->createTypedef($<fl>5, *$5, $7, dtp, $6); }
2231 // //
2232 | yTYPEDEF id/*interface*/ '.' idAny/*type*/ idAny/*type*/ dtypeAttrListE ';'
2233 { $$ = nullptr; BBUNSUP($1, "Unsupported: SystemVerilog 2005 typedef in this context"); }
2234 // // Allow redeclaring same typedef again
2235 // // Alternative is use of idAny below, but this will cause conflicts with ablve
2236 | yTYPEDEF idType ';' { $$ = GRAMMARP->createTypedefFwd($<fl>2, *$2); }
2237 // // Combines into above "data_type id" rule
2238 // // Verilator: Not important what it is in the AST, just need to make sure the yaID__aTYPE gets returned
2239 | yTYPEDEF id ';' { $$ = GRAMMARP->createTypedefFwd($<fl>2, *$2); }
2240 | yTYPEDEF yENUM idAny ';' { $$ = GRAMMARP->createTypedefFwd($<fl>3, *$3); }
2241 | yTYPEDEF ySTRUCT idAny ';' { $$ = GRAMMARP->createTypedefFwd($<fl>3, *$3); }
2242 | yTYPEDEF yUNION idAny ';' { $$ = GRAMMARP->createTypedefFwd($<fl>3, *$3); }
2243 | yTYPEDEF yCLASS idAny ';' { $$ = GRAMMARP->createTypedefFwd($<fl>3, *$3); }
2244 | yTYPEDEF yINTERFACE yCLASS idAny ';' { $$ = GRAMMARP->createTypedefFwd($<fl>4, *$4); }
2245 ;
2246
2247 dtypeAttrListE<nodep>:
2248 /* empty */ { $$ = nullptr; }
2249 | dtypeAttrList { $$ = $1; }
2250 ;
2251
2252 dtypeAttrList<nodep>:
2253 dtypeAttr { $$ = $1; }
2254 | dtypeAttrList dtypeAttr { $$ = $1->addNextNull($2); }
2255 ;
2256
2257 dtypeAttr<nodep>:
2258 yVL_PUBLIC { $$ = new AstAttrOf($1,AstAttrType::DT_PUBLIC); }
2259 ;
2260
2261 vlTag: // verilator tag handling
2262 yVL_TAG { if (PARSEP->tagNodep()) PARSEP->tagNodep()->tag(*$1); }
2263 ;
2264
2265 //************************************************
2266 // Module Items
2267
2268 module_itemListE<nodep>: // IEEE: Part of module_declaration
2269 /* empty */ { $$ = nullptr; }
2270 | module_itemList { $$ = $1; }
2271 ;
2272
2273 module_itemList<nodep>: // IEEE: Part of module_declaration
2274 module_item { $$ = $1; }
2275 | module_itemList module_item { $$ = $1->addNextNull($2); }
2276 ;
2277
2278 module_item<nodep>: // ==IEEE: module_item
2279 port_declaration ';' { $$ = $1; }
2280 | non_port_module_item { $$ = $1; }
2281 ;
2282
2283 non_port_module_item<nodep>: // ==IEEE: non_port_module_item
2284 generate_region { $$ = $1; }
2285 | module_or_generate_item { $$ = $1; }
2286 | specify_block { $$ = $1; }
2287 | specparam_declaration { $$ = $1; }
2288 | program_declaration
2289 { $$ = nullptr; BBUNSUP(CRELINE(), "Unsupported: program decls within module decls"); }
2290 | module_declaration
2291 { $$ = nullptr; BBUNSUP(CRELINE(), "Unsupported: module decls within module decls"); }
2292 | interface_declaration
2293 { $$ = nullptr; BBUNSUP(CRELINE(), "Unsupported: interface decls within module decls"); }
2294 | timeunits_declaration { $$ = $1; }
2295 // // Verilator specific
2296 | yaSCHDR { $$ = new AstScHdr($<fl>1,*$1); }
2297 | yaSCINT { $$ = new AstScInt($<fl>1,*$1); }
2298 | yaSCIMP { $$ = new AstScImp($<fl>1,*$1); }
2299 | yaSCIMPH { $$ = new AstScImpHdr($<fl>1,*$1); }
2300 | yaSCCTOR { $$ = new AstScCtor($<fl>1,*$1); }
2301 | yaSCDTOR { $$ = new AstScDtor($<fl>1,*$1); }
2302 | yVL_HIER_BLOCK { $$ = new AstPragma($1,AstPragmaType::HIER_BLOCK); }
2303 | yVL_INLINE_MODULE { $$ = new AstPragma($1,AstPragmaType::INLINE_MODULE); }
2304 | yVL_NO_INLINE_MODULE { $$ = new AstPragma($1,AstPragmaType::NO_INLINE_MODULE); }
2305 | yVL_PUBLIC_MODULE { $$ = new AstPragma($1,AstPragmaType::PUBLIC_MODULE); v3Global.dpi(true); }
2306 ;
2307
2308 module_or_generate_item<nodep>: // ==IEEE: module_or_generate_item
2309 // // IEEE: parameter_override
2310 yDEFPARAM list_of_defparam_assignments ';' { $$ = $2; }
2311 // // IEEE: gate_instantiation + udp_instantiation + module_instantiation
2312 // // not here, see etcInst in module_common_item
2313 // // We joined udp & module definitions, so this goes here
2314 | combinational_body { $$ = $1; }
2315 // // This module_common_item shared with interface_or_generate_item:module_common_item
2316 | module_common_item { $$ = $1; }
2317 ;
2318
2319 module_common_item<nodep>: // ==IEEE: module_common_item
2320 module_or_generate_item_declaration { $$ = $1; }
2321 // // IEEE: interface_instantiation
2322 // // + IEEE: program_instantiation
2323 // // + module_instantiation from module_or_generate_item
2324 | etcInst { $$ = $1; }
2325 | assertion_item { $$ = $1; }
2326 | bind_directive { $$ = $1; }
2327 | continuous_assign { $$ = $1; }
2328 // // IEEE: net_alias
2329 | yALIAS variable_lvalue aliasEqList ';'
2330 { $$ = nullptr; BBUNSUP($1, "Unsupported: alias statements"); }
2331 | initial_construct { $$ = $1; }
2332 | final_construct { $$ = $1; }
2333 // // IEEE: always_construct
2334 // // Verilator only - event_control attached to always
2335 | yALWAYS stmtBlock { $$ = new AstAlways($1,VAlwaysKwd::ALWAYS, nullptr, $2); }
2336 | yALWAYS_FF stmtBlock { $$ = new AstAlways($1,VAlwaysKwd::ALWAYS_FF, nullptr, $2); }
2337 | yALWAYS_LATCH stmtBlock { $$ = new AstAlways($1,VAlwaysKwd::ALWAYS_LATCH, nullptr, $2); }
2338 | yALWAYS_COMB stmtBlock { $$ = new AstAlways($1,VAlwaysKwd::ALWAYS_COMB, nullptr, $2); }
2339 //
2340 | loop_generate_construct { $$ = $1; }
2341 | conditional_generate_construct { $$ = $1; }
2342 | elaboration_system_task { $$ = $1; }
2343 //
2344 | error ';' { $$ = nullptr; }
2345 ;
2346
2347 continuous_assign<nodep>: // IEEE: continuous_assign
2348 yASSIGN strengthSpecE delayE assignList ';' { $$ = $4; }
2349 ;
2350
2351 initial_construct<nodep>: // IEEE: initial_construct
2352 yINITIAL stmtBlock { $$ = new AstInitial($1,$2); }
2353 ;
2354
2355 final_construct<nodep>: // IEEE: final_construct
2356 yFINAL stmtBlock { $$ = new AstFinal($1,$2); }
2357 ;
2358
2359 module_or_generate_item_declaration<nodep>: // ==IEEE: module_or_generate_item_declaration
2360 package_or_generate_item_declaration { $$ = $1; }
2361 | genvar_declaration { $$ = $1; }
2362 | clocking_declaration { $$ = $1; }
2363 | yDEFAULT yCLOCKING idAny/*new-clocking_identifier*/ ';'
2364 { $$ = nullptr; BBUNSUP($1, "Unsupported: default clocking identifier"); }
2365 //UNSUP yDEFAULT yDISABLE yIFF expr/*expression_or_dist*/ ';' { }
2366 ;
2367
2368 aliasEqList: // IEEE: part of net_alias
2369 '=' variable_lvalue { }
2370 | aliasEqList '=' variable_lvalue { }
2371 ;
2372
2373 bind_directive<nodep>: // ==IEEE: bind_directive + bind_target_scope
2374 // // ';' - Note IEEE grammar is wrong, includes extra ';' - it's already in module_instantiation
2375 // // We merged the rules - id may be a bind_target_instance or module_identifier or interface_identifier
2376 yBIND bind_target_instance bind_instantiation { $$ = new AstBind($<fl>2, *$2, $3); }
2377 | yBIND bind_target_instance ':' bind_target_instance_list bind_instantiation
2378 { $$ = nullptr; BBUNSUP($1, "Unsupported: Bind with instance list"); }
2379 ;
2380
2381 bind_target_instance_list: // ==IEEE: bind_target_instance_list
2382 bind_target_instance { }
2383 | bind_target_instance_list ',' bind_target_instance { }
2384 ;
2385
2386 bind_target_instance<strp>: // ==IEEE: bind_target_instance
2387 //UNSUP hierarchical_identifierBit { }
2388 idAny { $$ = $1; }
2389 ;
2390
2391 bind_instantiation<nodep>: // ==IEEE: bind_instantiation
2392 // // IEEE: program_instantiation
2393 // // IEEE: + module_instantiation
2394 // // IEEE: + interface_instantiation
2395 // // Need to get an AstBind instead of AstCell, so have special rules
2396 instDecl { $$ = $1; }
2397 ;
2398
2399 //************************************************
2400 // Generates
2401 //
2402 // Way down in generate_item is speced a difference between module,
2403 // interface and checker generates. modules and interfaces are almost
2404 // identical (minus DEFPARAMs) so we overlap them. Checkers are too
2405 // different, so we copy all rules for checkers.
2406
2407 generate_region<nodep>: // ==IEEE: generate_region
2408 yGENERATE ~c~genItemList yENDGENERATE { $$ = $2; }
2409 | yGENERATE yENDGENERATE { $$ = nullptr; }
2410 ;
2411
2412 //UNSUPc_generate_region<nodep>: // IEEE: generate_region (for checkers)
2413 //UNSUP BISONPRE_COPY(generate_region,{s/~c~/c_/g}) // {copied}
2414 //UNSUP ;
2415
2416 generate_block_or_null<nodep>: // IEEE: generate_block_or_null (called from gencase/genif/genfor)
2417 // ';' // is included in
2418 // // IEEE: generate_block
2419 // // Must always return a BEGIN node, or nullptr - see GenFor construction
2420 generate_item { $$ = $1 ? (new AstBegin($1->fileline(),"",$1,true,true)) : nullptr; }
2421 | genItemBegin { $$ = $1; }
2422 ;
2423
2424 genItemBegin<nodep>: // IEEE: part of generate_block
2425 yBEGIN ~c~genItemList yEND { $$ = new AstBegin($1,"",$2,true,false); }
2426 | yBEGIN yEND { $$ = nullptr; }
2427 | id yP_COLON__BEGIN yBEGIN ~c~genItemList yEND endLabelE
2428 { $$ = new AstBegin($<fl>1,*$1,$4,true,false); GRAMMARP->endLabel($<fl>6,*$1,$6); }
2429 | id yP_COLON__BEGIN yBEGIN yEND endLabelE
2430 { $$ = nullptr; GRAMMARP->endLabel($<fl>5,*$1,$5); }
2431 | yBEGIN ':' idAny ~c~genItemList yEND endLabelE
2432 { $$ = new AstBegin($<fl>3,*$3,$4,true,false); GRAMMARP->endLabel($<fl>6,*$3,$6); }
2433 | yBEGIN ':' idAny yEND endLabelE { $$ = nullptr; GRAMMARP->endLabel($<fl>5,*$3,$5); }
2434 ;
2435
2436 //UNSUPc_genItemBegin<nodep>: // IEEE: part of generate_block (for checkers)
2437 //UNSUP BISONPRE_COPY(genItemBegin,{s/~c~/c_/g}) // {copied}
2438 //UNSUP ;
2439
2440 genItemOrBegin<nodep>: // Not in IEEE, but our begin isn't under generate_item
2441 ~c~generate_item { $$ = $1; }
2442 | ~c~genItemBegin { $$ = $1; }
2443 ;
2444
2445 //UNSUPc_genItemOrBegin<nodep>: // (for checkers)
2446 //UNSUP BISONPRE_COPY(genItemOrBegin,{s/~c~/c_/g}) // {copied}
2447 //UNSUP ;
2448
2449 genItemList<nodep>:
2450 ~c~genItemOrBegin { $$ = $1; }
2451 | ~c~genItemList ~c~genItemOrBegin { $$ = $1->addNextNull($2); }
2452 ;
2453
2454 //UNSUPc_genItemList<nodep>: // (for checkers)
2455 //UNSUP BISONPRE_COPY(genItemList,{s/~c~/c_/g}) // {copied}
2456 //UNSUP ;
2457
2458 generate_item<nodep>: // IEEE: module_or_interface_or_generate_item
2459 // // Only legal when in a generate under a module (or interface under a module)
2460 module_or_generate_item { $$ = $1; }
2461 // // Only legal when in a generate under an interface
2462 //UNSUP interface_or_generate_item { $$ = $1; }
2463 // // IEEE: checker_or_generate_item
2464 // // Only legal when in a generate under a checker
2465 // // so below in c_generate_item
2466 ;
2467
2468 //UNSUPc_generate_item<nodep>: // IEEE: generate_item (for checkers)
2469 //UNSUP checker_or_generate_item { $$ = $1; }
2470 //UNSUP ;
2471
2472 conditional_generate_construct<nodep>: // ==IEEE: conditional_generate_construct
2473 yCASE '(' expr ')' ~c~case_generate_itemListE yENDCASE
2474 { $$ = new AstGenCase($1, $3, $5); }
2475 | yIF '(' expr ')' ~c~generate_block_or_null %prec prLOWER_THAN_ELSE
2476 { $$ = new AstGenIf($1, $3, $5, nullptr); }
2477 | yIF '(' expr ')' ~c~generate_block_or_null yELSE ~c~generate_block_or_null
2478 { $$ = new AstGenIf($1, $3, $5, $7); }
2479 ;
2480
2481 //UNSUPc_conditional_generate_construct<nodep>: // IEEE: conditional_generate_construct (for checkers)
2482 //UNSUP BISONPRE_COPY(conditional_generate_construct,{s/~c~/c_/g}) // {copied}
2483 //UNSUP ;
2484
2485 loop_generate_construct<nodep>: // ==IEEE: loop_generate_construct
2486 yFOR '(' genvar_initialization ';' expr ';' genvar_iteration ')' ~c~generate_block_or_null
2487 { // Convert BEGIN(...) to BEGIN(GENFOR(...)), as we need the BEGIN to hide the local genvar
2488 AstBegin* lowerBegp = VN_CAST($9, Begin);
2489 UASSERT_OBJ(!($9 && !lowerBegp), $9, "Child of GENFOR should have been begin");
2490
2491 if (!lowerBegp) lowerBegp = new AstBegin{$1, "", nullptr, true, false}; // Empty body
2492 AstNode* const lowerNoBegp = lowerBegp->stmtsp();
2493 if (lowerNoBegp) lowerNoBegp->unlinkFrBackWithNext();
2494 //
2495 AstBegin* const blkp = new AstBegin{$1, lowerBegp->name(), nullptr, true, true};
2496 // V3LinkDot detects BEGIN(GENFOR(...)) as a special case
2497 AstNode* initp = $3;
2498 AstNode* const varp = $3;
2499 if (VN_IS(varp, Var)) { // Genvar
2500 initp = varp->nextp();
2501 initp->unlinkFrBackWithNext(); // Detach 2nd from varp, make 1st init
2502 blkp->addStmtsp(varp);
2503 }
2504 // Statements are under 'genforp' as cells under this
2505 // for loop won't get an extra layer of hierarchy tacked on
2506 blkp->addGenforp(new AstGenFor($1, initp, $5, $7, lowerNoBegp));
2507 $$ = blkp;
2508 VL_DO_DANGLING(lowerBegp->deleteTree(), lowerBegp);
2509 }
2510 ;
2511
2512 //UNSUPc_loop_generate_construct<nodep>: // IEEE: loop_generate_construct (for checkers)
2513 //UNSUP BISONPRE_COPY(loop_generate_construct,{s/~c~/c_/g}) // {copied}
2514 //UNSUP ;
2515
2516 genvar_initialization<nodep>: // ==IEEE: genvar_initialization
2517 varRefBase '=' expr { $$ = new AstAssign($2,$1,$3); }
2518 | yGENVAR genvar_identifierDecl '=' constExpr
2519 { $$ = $2; $2->addNext(new AstAssign($3, new AstVarRef($2->fileline(), $2, VAccess::WRITE), $4)); }
2520 ;
2521
2522 genvar_iteration<nodep>: // ==IEEE: genvar_iteration
2523 varRefBase '=' expr { $$ = new AstAssign($2,$1,$3); }
2524 | varRefBase yP_PLUSEQ expr { $$ = new AstAssign($2,$1,new AstAdd ($2,$1->cloneTree(true),$3)); }
2525 | varRefBase yP_MINUSEQ expr { $$ = new AstAssign($2,$1,new AstSub ($2,$1->cloneTree(true),$3)); }
2526 | varRefBase yP_TIMESEQ expr { $$ = new AstAssign($2,$1,new AstMul ($2,$1->cloneTree(true),$3)); }
2527 | varRefBase yP_DIVEQ expr { $$ = new AstAssign($2,$1,new AstDiv ($2,$1->cloneTree(true),$3)); }
2528 | varRefBase yP_MODEQ expr { $$ = new AstAssign($2,$1,new AstModDiv ($2,$1->cloneTree(true),$3)); }
2529 | varRefBase yP_ANDEQ expr { $$ = new AstAssign($2,$1,new AstAnd ($2,$1->cloneTree(true),$3)); }
2530 | varRefBase yP_OREQ expr { $$ = new AstAssign($2,$1,new AstOr ($2,$1->cloneTree(true),$3)); }
2531 | varRefBase yP_XOREQ expr { $$ = new AstAssign($2,$1,new AstXor ($2,$1->cloneTree(true),$3)); }
2532 | varRefBase yP_SLEFTEQ expr { $$ = new AstAssign($2,$1,new AstShiftL ($2,$1->cloneTree(true),$3)); }
2533 | varRefBase yP_SRIGHTEQ expr { $$ = new AstAssign($2,$1,new AstShiftR ($2,$1->cloneTree(true),$3)); }
2534 | varRefBase yP_SSRIGHTEQ expr { $$ = new AstAssign($2,$1,new AstShiftRS($2,$1->cloneTree(true),$3)); }
2535 // // inc_or_dec_operator
2536 // When support ++ as a real AST type, maybe AstWhile::precondsp() becomes generic AstNodeMathStmt?
2537 | yP_PLUSPLUS varRefBase { $$ = new AstAssign($1,$2,new AstAdd ($1,$2->cloneTree(true), new AstConst($1, AstConst::StringToParse(), "'b1"))); }
2538 | yP_MINUSMINUS varRefBase { $$ = new AstAssign($1,$2,new AstSub ($1,$2->cloneTree(true), new AstConst($1, AstConst::StringToParse(), "'b1"))); }
2539 | varRefBase yP_PLUSPLUS { $$ = new AstAssign($2,$1,new AstAdd ($2,$1->cloneTree(true), new AstConst($2, AstConst::StringToParse(), "'b1"))); }
2540 | varRefBase yP_MINUSMINUS { $$ = new AstAssign($2,$1,new AstSub ($2,$1->cloneTree(true), new AstConst($2, AstConst::StringToParse(), "'b1"))); }
2541 ;
2542
2543 case_generate_itemListE<nodep>: // IEEE: [{ case_generate_itemList }]
2544 /* empty */ { $$ = nullptr; }
2545 | case_generate_itemList { $$ = $1; }
2546 ;
2547
2548 case_generate_itemList<nodep>: // IEEE: { case_generate_itemList }
2549 ~c~case_generate_item { $$ = $1; }
2550 | ~c~case_generate_itemList ~c~case_generate_item { $$ = $1; $1->addNext($2); }
2551 ;
2552
2553 //UNSUPc_case_generate_itemList<nodep>: // IEEE: { case_generate_item } (for checkers)
2554 //UNSUP BISONPRE_COPY(case_generate_itemList,{s/~c~/c_/g}) // {copied}
2555 //UNSUP ;
2556
2557 case_generate_item<nodep>: // ==IEEE: case_generate_item
2558 caseCondList colon generate_block_or_null { $$ = new AstCaseItem{$2, $1, $3}; }
2559 | yDEFAULT colon generate_block_or_null { $$ = new AstCaseItem{$1, nullptr, $3}; }
2560 | yDEFAULT generate_block_or_null { $$ = new AstCaseItem{$1, nullptr, $2}; }
2561 ;
2562
2563 //UNSUPc_case_generate_item<nodep>: // IEEE: case_generate_item (for checkers)
2564 //UNSUP BISONPRE_COPY(case_generate_item,{s/~c~/c_/g}) // {copied}
2565 //UNSUP ;
2566
2567 //************************************************
2568 // Assignments and register declarations
2569
2570 assignList<nodep>:
2571 assignOne { $$ = $1; }
2572 | assignList ',' assignOne { $$ = $1->addNext($3); }
2573 ;
2574
2575 assignOne<nodep>:
2576 variable_lvalue '=' expr { $$ = new AstAssignW($2,$1,$3); }
2577 ;
2578
2579 //UNSUPdelay_or_event_controlE<nodep>: // IEEE: delay_or_event_control plus empty
2580 //UNSUP /* empty */ { $$ = nullptr; }
2581 //UNSUP | delay_control { $$ = $1; }
2582 //UNSUP | event_control { $$ = $1; }
2583 //UNSUP | yREPEAT '(' expr ')' event_control { }
2584 //UNSUP ;
2585
2586 delayE:
2587 /* empty */ { }
2588 | delay { }
2589 ;
2590
2591 delay:
2592 delay_control
2593 { $1->v3warn(ASSIGNDLY, "Unsupported: Ignoring delay on this assignment/primitive.");
2594 DEL($1); }
2595 ;
2596
2597 delay_control<nodep>: //== IEEE: delay_control
2598 '#' delay_value { $$ = $2; }
2599 | '#' '(' minTypMax ')' { $$ = $3; }
2600 | '#' '(' minTypMax ',' minTypMax ')' { $$ = $3; DEL($5); }
2601 | '#' '(' minTypMax ',' minTypMax ',' minTypMax ')' { $$ = $3; DEL($5); DEL($7); }
2602 ;
2603
2604 delay_value<nodep>: // ==IEEE:delay_value
2605 // // IEEE: ps_identifier
2606 packageClassScopeE varRefBase { $$ = AstDot::newIfPkg($<fl>2, $1, $2); }
2607 | yaINTNUM { $$ = new AstConst($<fl>1, *$1); }
2608 | yaFLOATNUM { $$ = new AstConst($<fl>1, AstConst::RealDouble(), $1); }
2609 | timeNumAdjusted { $$ = $1; }
2610 ;
2611
2612 delayExpr<nodep>:
2613 expr { $$ = $1; }
2614 ;
2615
2616 minTypMax<nodep>: // IEEE: mintypmax_expression and constant_mintypmax_expression
2617 delayExpr { $$ = $1; }
2618 | delayExpr ':' delayExpr ':' delayExpr { $$ = $3; DEL($1); DEL($5); }
2619 ;
2620
2621 netSigList<varp>: // IEEE: list_of_port_identifiers
2622 netSig { $$ = $1; }
2623 | netSigList ',' netSig { $$ = $1; $1->addNext($3); }
2624 ;
2625
2626 netSig<varp>: // IEEE: net_decl_assignment - one element from list_of_port_identifiers
2627 netId sigAttrListE { $$ = VARDONEA($<fl>1,*$1, nullptr, $2); }
2628 | netId sigAttrListE '=' expr { $$ = VARDONEA($<fl>1,*$1, nullptr, $2);
2629 $$->addNext(new AstAssignW($3, new AstVarRef($<fl>1, *$1, VAccess::WRITE), $4)); }
2630 | netId variable_dimensionList sigAttrListE { $$ = VARDONEA($<fl>1,*$1, $2, $3); }
2631 ;
2632
2633 netId<strp>:
2634 id/*new-net*/ { $$ = $1; $<fl>$ = $<fl>1; }
2635 | idSVKwd { $$ = $1; $<fl>$ = $<fl>1; }
2636 ;
2637
2638 sigAttrListE<nodep>:
2639 /* empty */ { $$ = nullptr; }
2640 | sigAttrList { $$ = $1; }
2641 ;
2642
2643 sigAttrList<nodep>:
2644 sigAttr { $$ = $1; }
2645 | sigAttrList sigAttr { $$ = $1->addNextNull($2); }
2646 ;
2647
2648 sigAttr<nodep>:
2649 yVL_CLOCKER { $$ = new AstAttrOf($1,AstAttrType::VAR_CLOCKER); }
2650 | yVL_NO_CLOCKER { $$ = new AstAttrOf($1,AstAttrType::VAR_NO_CLOCKER); }
2651 | yVL_CLOCK_ENABLE { $$ = new AstAttrOf($1,AstAttrType::VAR_CLOCK_ENABLE); }
2652 | yVL_PUBLIC { $$ = new AstAttrOf($1,AstAttrType::VAR_PUBLIC); v3Global.dpi(true); }
2653 | yVL_PUBLIC_FLAT { $$ = new AstAttrOf($1,AstAttrType::VAR_PUBLIC_FLAT); v3Global.dpi(true); }
2654 | yVL_PUBLIC_FLAT_RD { $$ = new AstAttrOf($1,AstAttrType::VAR_PUBLIC_FLAT_RD); v3Global.dpi(true); }
2655 | yVL_PUBLIC_FLAT_RW { $$ = new AstAttrOf($1,AstAttrType::VAR_PUBLIC_FLAT_RW); v3Global.dpi(true); }
2656 | yVL_PUBLIC_FLAT_RW attr_event_control { $$ = new AstAttrOf($1,AstAttrType::VAR_PUBLIC_FLAT_RW); v3Global.dpi(true);
2657 $$ = $$->addNext(new AstAlwaysPublic($1,$2,nullptr)); }
2658 | yVL_ISOLATE_ASSIGNMENTS { $$ = new AstAttrOf($1,AstAttrType::VAR_ISOLATE_ASSIGNMENTS); }
2659 | yVL_SC_BV { $$ = new AstAttrOf($1,AstAttrType::VAR_SC_BV); }
2660 | yVL_SFORMAT { $$ = new AstAttrOf($1,AstAttrType::VAR_SFORMAT); }
2661 | yVL_SPLIT_VAR { $$ = new AstAttrOf($1,AstAttrType::VAR_SPLIT_VAR); }
2662 ;
2663
2664 rangeListE<nodeRangep>: // IEEE: [{packed_dimension}]
2665 /* empty */ { $$ = nullptr; }
2666 | rangeList { $$ = $1; }
2667 ;
2668
2669 rangeList<nodeRangep>: // IEEE: {packed_dimension}
2670 anyrange { $$ = $1; }
2671 | rangeList anyrange { $$ = $1; $1->addNext($2); }
2672 ;
2673
2674 //UNSUPbit_selectE<fl>: // IEEE: constant_bit_select (IEEE included empty)
2675 //UNSUP /* empty */ { $$ = nullptr; }
2676 //UNSUP | '[' constExpr ']' { $<fl>$ = $<fl>1; $$ = "[" + $2 + "]"; }
2677 //UNSUP ;
2678
2679 // IEEE: select
2680 // Merged into more general idArray
2681
2682 anyrange<nodeRangep>:
2683 '[' constExpr ':' constExpr ']' { $$ = new AstRange($1,$2,$4); }
2684 ;
2685
2686 packed_dimensionListE<nodeRangep>: // IEEE: [{ packed_dimension }]
2687 /* empty */ { $$ = nullptr; }
2688 | packed_dimensionList { $$ = $1; }
2689 ;
2690
2691 packed_dimensionList<nodeRangep>: // IEEE: { packed_dimension }
2692 packed_dimension { $$ = $1; }
2693 | packed_dimensionList packed_dimension { $$ = VN_CAST($1->addNext($2), NodeRange); }
2694 ;
2695
2696 packed_dimension<nodeRangep>: // ==IEEE: packed_dimension
2697 anyrange { $$ = $1; }
2698 | '[' ']'
2699 { $$ = nullptr; BBUNSUP($<fl>1, "Unsupported: [] dimensions"); }
2700 ;
2701
2702 //************************************************
2703 // Parameters
2704
2705 param_assignment<varp>: // ==IEEE: param_assignment
2706 // // IEEE: constant_param_expression
2707 // // constant_param_expression: '$' is in expr
2708 id/*new-parameter*/ variable_dimensionListE sigAttrListE exprOrDataTypeEqE
2709 { // To handle #(type A=int, B=A) and properly imply B
2710 // as a type (for parsing) we need to detect "A" is a type
2711 if (AstNodeDType* const refp = VN_CAST($4, NodeDType)) {
2712 if (VSymEnt* const foundp = SYMP->symCurrentp()->findIdFallback(refp->name())) {
2713 UINFO(9, "declaring type via param assignment" << foundp->nodep() << endl);
2714 VARDTYPE(new AstParseTypeDType{$<fl>1})
2715 SYMP->reinsert(foundp->nodep()->cloneTree(false), nullptr, *$1); }}
2716 $$ = VARDONEA($<fl>1, *$1, $2, $3);
2717 if ($4) $$->valuep($4); }
2718 ;
2719
2720 list_of_param_assignments<varp>: // ==IEEE: list_of_param_assignments
2721 param_assignment { $$ = $1; }
2722 | list_of_param_assignments ',' param_assignment { $$ = $1; $1->addNext($3); }
2723 ;
2724
2725 type_assignment<varp>: // ==IEEE: type_assignment
2726 // // note exptOrDataType being a data_type is only for yPARAMETER yTYPE
2727 idAny/*new-parameter*/ sigAttrListE '=' data_type
2728 { $$ = VARDONEA($<fl>1, *$1, nullptr, $2); $$->valuep($4); }
2729 ;
2730
2731 list_of_type_assignments<varp>: // ==IEEE: list_of_type_assignments
2732 type_assignment { $$ = $1; }
2733 | list_of_type_assignments ',' type_assignment { $$ = $1; $1->addNext($3); }
2734 ;
2735
2736 list_of_defparam_assignments<nodep>: //== IEEE: list_of_defparam_assignments
2737 defparam_assignment { $$ = $1; }
2738 | list_of_defparam_assignments ',' defparam_assignment { $$ = $1->addNext($3); }
2739 ;
2740
2741 defparam_assignment<nodep>: // ==IEEE: defparam_assignment
2742 idAny '.' idAny '=' expr { $$ = new AstDefParam($4, *$1, *$3, $5); }
2743 | idAny '.' idAny '.'
2744 { $$ = nullptr; BBUNSUP($4, "Unsupported: defparam with more than one dot"); }
2745 ;
2746
2747 //************************************************
2748 // Instances
2749 // We don't know identifier types, so this matches all module,udp,etc instantiation
2750 // module_id [#(params)] name (pins) [, name ...] ; // module_instantiation
2751 // gate (strong0) [#(delay)] [name] (pins) [, (pins)...] ; // gate_instantiation
2752 // program_id [#(params}] name ; // program_instantiation
2753 // interface_id [#(params}] name ; // interface_instantiation
2754 // checker_id name (pins) ; // checker_instantiation
2755
2756 etcInst<nodep>: // IEEE: module_instantiation + gate_instantiation + udp_instantiation
2757 instDecl { $$ = $1; }
2758 | gateDecl { $$ = $1; }
2759 ;
2760
2761 instDecl<nodep>:
2762 // // Currently disambiguated from data_declaration based on
2763 // // VARs being type, and cells non-type.
2764 // // IEEE requires a '(' to disambiguate, we need TODO force this
2765 id parameter_value_assignmentE {INSTPREP($<fl>1, *$1, $2);} instnameList ';'
2766 { $$ = $4;
2767 GRAMMARP->m_impliedDecl = false;
2768 if (GRAMMARP->m_instParamp) {
2769 VL_DO_CLEAR(GRAMMARP->m_instParamp->deleteTree(),
2770 GRAMMARP->m_instParamp = nullptr);
2771 } }
2772 // // IEEE: interface_identifier' .' modport_identifier list_of_interface_identifiers
2773 | id/*interface*/ '.' id/*modport*/
2774 /*mid*/ { VARRESET_NONLIST(AstVarType::IFACEREF);
2775 VARDTYPE(new AstIfaceRefDType($<fl>1, $<fl>3, "", *$1, *$3)); }
2776 /*cont*/ mpInstnameList ';'
2777 { $$ = VARDONEP($5,nullptr,nullptr); }
2778 //UNSUP: strengthSpecE for udp_instantiations
2779 ;
2780
2781 mpInstnameList<nodep>: // Similar to instnameList, but for modport instantiations which have no parenthesis
2782 mpInstnameParen { $$ = $1; }
2783 | mpInstnameList ',' mpInstnameParen { $$ = $1->addNext($3); }
2784 ;
2785
2786 mpInstnameParen<nodep>: // Similar to instnameParen, but for modport instantiations which have no parenthesis
2787 id instRangeListE sigAttrListE { $$ = VARDONEA($<fl>1,*$1,$2,$3); }
2788 ;
2789
2790 instnameList<nodep>:
2791 instnameParen { $$ = $1; }
2792 | instnameList ',' instnameParen { $$ = $1->addNext($3); }
2793 ;
2794
2795 instnameParen<cellp>:
2796 // // Must clone m_instParamp as may be comma'ed list of instances
2797 id instRangeListE '(' cellpinList ')' { $$ = new AstCell($<fl>1, GRAMMARP->m_instModuleFl,
2798 *$1, GRAMMARP->m_instModule, $4,
2799 AstPin::cloneTreeNull(GRAMMARP->m_instParamp, true),
2800 GRAMMARP->scrubRange($2));
2801 $$->trace(GRAMMARP->allTracingOn($<fl>1)); }
2802 | id instRangeListE { $$ = new AstCell($<fl>1, GRAMMARP->m_instModuleFl,
2803 *$1, GRAMMARP->m_instModule, nullptr,
2804 AstPin::cloneTreeNull(GRAMMARP->m_instParamp, true),
2805 GRAMMARP->scrubRange($2));
2806 $$->trace(GRAMMARP->allTracingOn($<fl>1)); }
2807 //UNSUP instRangeListE '(' cellpinList ')' { UNSUP } // UDP
2808 // // Adding above and switching to the Verilog-Perl syntax
2809 // // causes a shift conflict due to use of idClassSel inside exprScope.
2810 // // It also breaks allowing "id foo;" instantiation syntax.
2811 ;
2812
2813 instRangeListE<nodeRangep>:
2814 /* empty */ { $$ = nullptr; }
2815 | instRangeList { $$ = $1; }
2816 ;
2817
2818 instRangeList<nodeRangep>:
2819 instRange { $$ = $1; }
2820 | instRangeList instRange { $$ = VN_CAST($1->addNextNull($2), Range); }
2821 ;
2822
2823 instRange<nodeRangep>:
2824 '[' constExpr ']' { $$ = new AstRange($1, new AstConst($1, 0), new AstSub($1, $2, new AstConst($1, 1))); }
2825 | '[' constExpr ':' constExpr ']' { $$ = new AstRange($1,$2,$4); }
2826 ;
2827
2828 cellparamList<pinp>:
2829 { GRAMMARP->pinPush(); } cellparamItList { $$ = $2; GRAMMARP->pinPop(CRELINE()); }
2830 ;
2831
2832 cellpinList<pinp>:
2833 {VARRESET_LIST(UNKNOWN);} cellpinItList { $$ = $2; VARRESET_NONLIST(UNKNOWN); }
2834 ;
2835
2836 cellparamItList<pinp>: // IEEE: list_of_parameter_assignmente
2837 cellparamItemE { $$ = $1; }
2838 | cellparamItList ',' cellparamItemE { $$ = VN_CAST($1->addNextNull($3), Pin); }
2839 ;
2840
2841 cellpinItList<pinp>: // IEEE: list_of_port_connections
2842 cellpinItemE { $$ = $1; }
2843 | cellpinItList ',' cellpinItemE { $$ = VN_CAST($1->addNextNull($3), Pin); }
2844 ;
2845
2846 cellparamItemE<pinp>: // IEEE: named_parameter_assignment + empty
2847 // // Note empty can match either () or (,); V3LinkCells cleans up ()
2848 /* empty: ',,' is legal */ { $$ = new AstPin(CRELINE(), PINNUMINC(), "", nullptr); }
2849 | yP_DOTSTAR { $$ = new AstPin($1,PINNUMINC(),".*",nullptr); }
2850 | '.' idSVKwd { $$ = new AstPin($<fl>2,PINNUMINC(), *$2,
2851 new AstParseRef($<fl>2,VParseRefExp::PX_TEXT,*$2,nullptr,nullptr));
2852 $$->svImplicit(true); }
2853 | '.' idAny { $$ = new AstPin($<fl>2,PINNUMINC(), *$2,
2854 new AstParseRef($<fl>2,VParseRefExp::PX_TEXT,*$2,nullptr,nullptr));
2855 $$->svImplicit(true); }
2856 | '.' idAny '(' ')' { $$ = new AstPin($<fl>2,PINNUMINC(),*$2,nullptr); }
2857 // // mintypmax is expanded here, as it might be a UDP or gate primitive
2858 // // data_type for 'parameter type' hookups
2859 | '.' idAny '(' exprOrDataType ')' { $$ = new AstPin($<fl>2, PINNUMINC(), *$2, $4); }
2860 //UNSUP '.' idAny '(' exprOrDataType/*expr*/ ':' expr ')' { }
2861 //UNSUP '.' idAny '(' exprOrDataType/*expr*/ ':' expr ':' expr ')' { }
2862 // // data_type for 'parameter type' hookups
2863 | exprOrDataType { $$ = new AstPin(FILELINE_OR_CRE($1), PINNUMINC(), "", $1); }
2864 //UNSUP exprOrDataType/*expr*/ ':' expr { }
2865 //UNSUP exprOrDataType/*expr*/ ':' expr ':' expr { }
2866 ;
2867
2868 cellpinItemE<pinp>: // IEEE: named_port_connection + empty
2869 // // Note empty can match either () or (,); V3LinkCells cleans up ()
2870 /* empty: ',,' is legal */ { $$ = new AstPin(CRELINE(), PINNUMINC(), "", nullptr); }
2871 | yP_DOTSTAR { $$ = new AstPin($1,PINNUMINC(),".*",nullptr); }
2872 | '.' idSVKwd { $$ = new AstPin($<fl>2,PINNUMINC(),*$2,new AstParseRef($<fl>2,VParseRefExp::PX_TEXT,*$2,nullptr,nullptr)); $$->svImplicit(true);}
2873 | '.' idAny { $$ = new AstPin($<fl>2,PINNUMINC(),*$2,new AstParseRef($<fl>2,VParseRefExp::PX_TEXT,*$2,nullptr,nullptr)); $$->svImplicit(true);}
2874 | '.' idAny '(' ')' { $$ = new AstPin($<fl>2,PINNUMINC(),*$2,nullptr); }
2875 // // mintypmax is expanded here, as it might be a UDP or gate primitive
2876 //UNSUP pev_expr below
2877 | '.' idAny '(' expr ')' { $$ = new AstPin($<fl>2,PINNUMINC(),*$2,$4); }
2878 //UNSUP '.' idAny '(' pev_expr ':' expr ')' { }
2879 //UNSUP '.' idAny '(' pev_expr ':' expr ':' expr ')' { }
2880 //
2881 | expr { $$ = new AstPin(FILELINE_OR_CRE($1),PINNUMINC(),"",$1); }
2882 //UNSUP expr ':' expr { }
2883 //UNSUP expr ':' expr ':' expr { }
2884 ;
2885
2886 //************************************************
2887 // EventControl lists
2888
2889 attr_event_controlE<senTreep>:
2890 /* empty */ { $$ = nullptr; }
2891 | attr_event_control { $$ = $1; }
2892 ;
2893
2894 attr_event_control<senTreep>: // ==IEEE: event_control
2895 '@' '(' event_expression ')' { $$ = new AstSenTree($1,$3); }
2896 | '@' '(' '*' ')' { $$ = nullptr; }
2897 | '@' '*' { $$ = nullptr; }
2898 ;
2899
2900 event_control<senTreep>: // ==IEEE: event_control
2901 '@' '(' event_expression ')' { $$ = new AstSenTree($1,$3); }
2902 | '@' '(' '*' ')' { $$ = nullptr; }
2903 | '@' '*' { $$ = nullptr; }
2904 // // IEEE: hierarchical_event_identifier
2905 // // UNSUP below should be idClassSel
2906 | '@' senitemVar { $$ = new AstSenTree($1,$2); } /* For events only */
2907 // // IEEE: sequence_instance
2908 // // sequence_instance without parens matches idClassSel above.
2909 // // Ambiguity: "'@' sequence (-for-sequence" versus expr:delay_or_event_controlE "'@' id (-for-expr
2910 // // For now we avoid this, as it's very unlikely someone would mix
2911 // // 1995 delay with a sequence with parameters.
2912 // // Alternatively split this out of event_control, and delay_or_event_controlE
2913 // // and anywhere delay_or_event_controlE is called allow two expressions
2914 //UNSUP '@' idClassSel '(' list_of_argumentsE ')' { }
2915 ;
2916
2917 event_expression<senItemp>: // IEEE: event_expression - split over several
2918 //UNSUP // Below are all removed
2919 senitem { $$ = $1; }
2920 | event_expression yOR senitem { $$ = VN_CAST($1->addNextNull($3), SenItem); }
2921 | event_expression ',' senitem { $$ = VN_CAST($1->addNextNull($3), SenItem); } /* Verilog 2001 */
2922 //UNSUP // Above are all removed, replace with:
2923 //UNSUP ev_expr { $$ = $1; }
2924 //UNSUP event_expression ',' ev_expr %prec yOR { $$ = VN_CAST($1->addNextNull($3), SenItem); }
2925 ;
2926
2927 senitem<senItemp>: // IEEE: part of event_expression, non-'OR' ',' terms
2928 senitemEdge { $$ = $1; }
2929 | senitemVar { $$ = $1; }
2930 | '(' senitem ')' { $$ = $2; }
2931 //UNSUP expr { UNSUP }
2932 | '{' event_expression '}' { $$ = $2; }
2933 | senitem yP_ANDAND senitem { $$ = new AstSenItem($2, AstSenItem::Illegal()); }
2934 //UNSUP expr yIFF expr { UNSUP }
2935 // Since expr is unsupported we allow and ignore constants (removed in V3Const)
2936 | yaINTNUM { $$ = nullptr; }
2937 | yaFLOATNUM { $$ = nullptr; }
2938 ;
2939
2940 senitemVar<senItemp>:
2941 idClassSel { $$ = new AstSenItem($1->fileline(), VEdgeType::ET_ANYEDGE, $1); }
2942 ;
2943
2944 senitemEdge<senItemp>: // IEEE: part of event_expression
2945 //UNSUP // Below are all removed
2946 yPOSEDGE idClassSel { $$ = new AstSenItem($1, VEdgeType::ET_POSEDGE, $2); }
2947 | yNEGEDGE idClassSel { $$ = new AstSenItem($1, VEdgeType::ET_NEGEDGE, $2); }
2948 | yEDGE idClassSel { $$ = new AstSenItem($1, VEdgeType::ET_BOTHEDGE, $2); }
2949 | yPOSEDGE '(' idClassSel ')' { $$ = new AstSenItem($1, VEdgeType::ET_POSEDGE, $3); }
2950 | yNEGEDGE '(' idClassSel ')' { $$ = new AstSenItem($1, VEdgeType::ET_NEGEDGE, $3); }
2951 | yEDGE '(' idClassSel ')' { $$ = new AstSenItem($1, VEdgeType::ET_BOTHEDGE, $3); }
2952 //UNSUP // Above are all removed, replace with:
2953 //UNSUP yPOSEDGE expr { UNSUP }
2954 //UNSUP yPOSEDGE expr yIFF expr { UNSUP }
2955 //UNSUP yNEGEDGE expr { UNSUP }
2956 //UNSUP yNEGEDGE expr yIFF expr { UNSUP }
2957 //UNSUP yEDGE expr { UNSUP }
2958 //UNSUP yEDGE expr yIFF expr { UNSUP }
2959 ;
2960
2961 //************************************************
2962 // Statements
2963
2964 stmtBlock<nodep>: // IEEE: statement + seq_block + par_block
2965 stmt { $$ = $1; }
2966 ;
2967
2968 seq_block<nodep>: // ==IEEE: seq_block
2969 // // IEEE doesn't allow declarations in unnamed blocks, but several simulators do.
2970 // // So need AstBegin's even if unnamed to scope variables down
2971 seq_blockFront blockDeclStmtListE yEND endLabelE
2972 { $$ = $1; $1->addStmtsp($2);
2973 SYMP->popScope($1); GRAMMARP->endLabel($<fl>4, $1, $4); }
2974 ;
2975
2976 seq_blockPreId<nodep>: // IEEE: seq_block, but called with leading ID
2977 seq_blockFrontPreId blockDeclStmtListE yEND endLabelE
2978 { $$ = $1; $1->addStmtsp($2);
2979 SYMP->popScope($1); GRAMMARP->endLabel($<fl>4, $1, $4); }
2980 ;
2981
2982 par_block<nodep>: // ==IEEE: par_block
2983 par_blockFront blockDeclStmtListE yJOIN endLabelE
2984 { $$ = $1; $1->addStmtsp($2);
2985 $1->joinType(VJoinType::JOIN);
2986 SYMP->popScope($1); GRAMMARP->endLabel($<fl>4, $1, $4); }
2987 | par_blockFront blockDeclStmtListE yJOIN_ANY endLabelE
2988 { $$ = $1; $1->addStmtsp($2);
2989 $1->joinType(VJoinType::JOIN_ANY);
2990 SYMP->popScope($1); GRAMMARP->endLabel($<fl>4, $1, $4); }
2991 | par_blockFront blockDeclStmtListE yJOIN_NONE endLabelE
2992 { $$ = $1; $1->addStmtsp($2);
2993 $1->joinType(VJoinType::JOIN_NONE);
2994 SYMP->popScope($1); GRAMMARP->endLabel($<fl>4, $1, $4); }
2995 ;
2996
2997 par_blockPreId<nodep>: // ==IEEE: par_block but called with leading ID
2998 par_blockFrontPreId blockDeclStmtListE yJOIN endLabelE
2999 { $$ = $1; $1->addStmtsp($2);
3000 $1->joinType(VJoinType::JOIN);
3001 SYMP->popScope($1); GRAMMARP->endLabel($<fl>4, $1, $4); }
3002 | par_blockFrontPreId blockDeclStmtListE yJOIN_ANY endLabelE
3003 { $$ = $1; $1->addStmtsp($2);
3004 $1->joinType(VJoinType::JOIN_ANY);
3005 SYMP->popScope($1); GRAMMARP->endLabel($<fl>4, $1, $4); }
3006 | par_blockFrontPreId blockDeclStmtListE yJOIN_NONE endLabelE
3007 { $$ = $1; $1->addStmtsp($2);
3008 $1->joinType(VJoinType::JOIN_NONE);
3009 SYMP->popScope($1); GRAMMARP->endLabel($<fl>4, $1, $4); }
3010 ;
3011
3012 seq_blockFront<beginp>: // IEEE: part of seq_block
3013 yBEGIN { $$ = new AstBegin($1,"",nullptr); SYMP->pushNew($$); }
3014 | yBEGIN ':' idAny/*new-block_identifier*/ { $$ = new AstBegin($<fl>3, *$3, nullptr); SYMP->pushNew($$); }
3015 ;
3016
3017 par_blockFront<forkp>: // IEEE: part of par_block
3018 yFORK { $$ = new AstFork($1, "", nullptr); SYMP->pushNew($$); }
3019 | yFORK ':' idAny/*new-block_identifier*/ { $$ = new AstFork($<fl>3, *$3, nullptr); SYMP->pushNew($$); }
3020 ;
3021
3022 seq_blockFrontPreId<beginp>: // IEEE: part of seq_block/stmt with leading id
3023 id/*block_identifier*/ yP_COLON__BEGIN yBEGIN
3024 { $$ = new AstBegin($3, *$1, nullptr); SYMP->pushNew($$); }
3025 ;
3026
3027 par_blockFrontPreId<forkp>: // IEEE: part of par_block/stmt with leading id
3028 id/*block_identifier*/ yP_COLON__FORK yFORK
3029 { $$ = new AstFork($3, *$1, nullptr); SYMP->pushNew($$); }
3030 ;
3031
3032
3033 blockDeclStmtList<nodep>: // IEEE: { block_item_declaration } { statement or null }
3034 // // The spec seems to suggest a empty declaration isn't ok, but most simulators take it
3035 block_item_declarationList { $$ = $1; }
3036 | block_item_declarationList stmtList { $$ = $1->addNextNull($2); }
3037 | stmtList { $$ = $1; }
3038 ;
3039
3040 blockDeclStmtListE<nodep>: // IEEE: [ { block_item_declaration } { statement or null } ]
3041 /*empty*/ { $$ = nullptr; }
3042 | blockDeclStmtList { $$ = $1; }
3043 ;
3044
3045 block_item_declarationList<nodep>: // IEEE: [ block_item_declaration ]
3046 block_item_declaration { $$ = $1; }
3047 | block_item_declarationList block_item_declaration { $$ = $1->addNextNull($2); }
3048 ;
3049
3050 block_item_declaration<nodep>: // ==IEEE: block_item_declaration
3051 data_declaration { $$ = $1; }
3052 | parameter_declaration ';' { $$ = $1; }
3053 //UNSUP let_declaration { $$ = $1; }
3054 ;
3055
3056 stmtList<nodep>:
3057 stmtBlock { $$ = $1; }
3058 | stmtList stmtBlock { $$ = $2 ? $1->addNext($2) : $1; }
3059 ;
3060
3061 stmt<nodep>: // IEEE: statement_or_null == function_statement_or_null
3062 statement_item { $$ = $1; }
3063 // // S05 block creation rule
3064 | id/*block_identifier*/ ':' statement_item { $$ = new AstBegin($<fl>1, *$1, $3); }
3065 // // from _or_null
3066 | ';' { $$ = nullptr; }
3067 // // labeled par_block/seq_block with leading ':'
3068 | seq_blockPreId { $$ = $1; }
3069 | par_blockPreId { $$ = $1; }
3070 ;
3071
3072 statement_item<nodep>: // IEEE: statement_item
3073 // // IEEE: operator_assignment
3074 foperator_assignment ';' { $$ = $1; }
3075 //
3076 // // IEEE: blocking_assignment
3077 // // 1800-2009 restricts LHS of assignment to new to not have a range
3078 // // This is ignored to avoid conflicts
3079 | fexprLvalue '=' class_new ';' { $$ = new AstAssign($2, $1, $3); }
3080 | fexprLvalue '=' dynamic_array_new ';' { $$ = new AstAssign($2, $1, $3); }
3081 //
3082 // // IEEE: nonblocking_assignment
3083 | fexprLvalue yP_LTE delayE expr ';' { $$ = new AstAssignDly($2,$1,$4); }
3084 //UNSUP fexprLvalue yP_LTE delay_or_event_controlE expr ';' { UNSUP }
3085 //
3086 // // IEEE: procedural_continuous_assignment
3087 | yASSIGN idClassSel '=' delayE expr ';' { $$ = new AstAssign($1,$2,$5); }
3088 //UNSUP: delay_or_event_controlE above
3089 | yDEASSIGN variable_lvalue ';'
3090 { $$ = nullptr; BBUNSUP($1, "Unsupported: Verilog 1995 deassign"); }
3091 | yFORCE expr '=' expr ';'
3092 { $$ = nullptr; BBUNSUP($1, "Unsupported: Verilog 1995 force"); }
3093 | yRELEASE variable_lvalue ';'
3094 { $$ = nullptr; BBUNSUP($1, "Unsupported: Verilog 1995 release"); }
3095 //
3096 // // IEEE: case_statement
3097 | unique_priorityE caseStart caseAttrE case_itemListE yENDCASE { $$ = $2; if ($4) $2->addItemsp($4);
3098 if ($1 == uniq_UNIQUE) $2->uniquePragma(true);
3099 if ($1 == uniq_UNIQUE0) $2->unique0Pragma(true);
3100 if ($1 == uniq_PRIORITY) $2->priorityPragma(true); }
3101 //UNSUP caseStart caseAttrE yMATCHES case_patternListE yENDCASE { }
3102 | unique_priorityE caseStart caseAttrE yINSIDE case_insideListE yENDCASE
3103 { $$ = $2; if ($5) $2->addItemsp($5);
3104 if (!$2->caseSimple()) $2->v3error("Illegal to have inside on a casex/casez");
3105 $2->caseInsideSet();
3106 if ($1 == uniq_UNIQUE) $2->uniquePragma(true);
3107 if ($1 == uniq_UNIQUE0) $2->unique0Pragma(true);
3108 if ($1 == uniq_PRIORITY) $2->priorityPragma(true); }
3109 //
3110 // // IEEE: conditional_statement
3111 | unique_priorityE yIF '(' expr ')' stmtBlock %prec prLOWER_THAN_ELSE
3112 { AstIf* const newp = new AstIf{$2, $4, $6, nullptr};
3113 $$ = newp;
3114 if ($1 == uniq_UNIQUE) newp->uniquePragma(true);
3115 if ($1 == uniq_UNIQUE0) newp->unique0Pragma(true);
3116 if ($1 == uniq_PRIORITY) newp->priorityPragma(true); }
3117 | unique_priorityE yIF '(' expr ')' stmtBlock yELSE stmtBlock
3118 { AstIf* const newp = new AstIf{$2, $4, $6, $8};
3119 $$ = newp;
3120 if ($1 == uniq_UNIQUE) newp->uniquePragma(true);
3121 if ($1 == uniq_UNIQUE0) newp->unique0Pragma(true);
3122 if ($1 == uniq_PRIORITY) newp->priorityPragma(true); }
3123 //
3124 | finc_or_dec_expression ';' { $$ = $1; }
3125 // // IEEE: inc_or_dec_expression
3126 // // Below under expr
3127 //
3128 // // IEEE: subroutine_call_statement
3129 // // IEEE says we then expect a function call
3130 // // (function_subroutine_callNoMethod), but rest of
3131 // // the code expects an AstTask when used as a statement,
3132 // // so parse as if task
3133 // // Alternative would be shim with new AstVoidStmt.
3134 | yVOID yP_TICK '(' task_subroutine_callNoMethod ')' ';'
3135 { $$ = $4;
3136 FileLine* const newfl = new FileLine{$$->fileline()};
3137 newfl->warnOff(V3ErrorCode::IGNOREDRETURN, true);
3138 $$->fileline(newfl); }
3139 | yVOID yP_TICK '(' expr '.' task_subroutine_callNoMethod ')' ';'
3140 { $$ = new AstDot{$5, false, $4, $6};
3141 FileLine* const newfl = new FileLine{$6->fileline()};
3142 newfl->warnOff(V3ErrorCode::IGNOREDRETURN, true);
3143 $6->fileline(newfl); }
3144 // // Expr included here to resolve our not knowing what is a method call
3145 // // Expr here must result in a subroutine_call
3146 | task_subroutine_callNoMethod ';' { $$ = $1; }
3147 //UNSUP fexpr '.' array_methodNoRoot ';' { UNSUP }
3148 | fexpr '.' task_subroutine_callNoMethod ';' { $$ = new AstDot($<fl>2, false, $1, $3); }
3149 //UNSUP fexprScope ';' { UNSUP }
3150 // // Not here in IEEE; from class_constructor_declaration
3151 // // Because we've joined class_constructor_declaration into generic functions
3152 // // Way over-permissive;
3153 // // IEEE: [ ySUPER '.' yNEW [ '(' list_of_arguments ')' ] ';' ]
3154 | fexpr '.' class_new ';' { $$ = new AstDot($<fl>2, false, $1, $3); }
3155 //
3156 | statementVerilatorPragmas { $$ = $1; }
3157 //
3158 // // IEEE: disable_statement
3159 | yDISABLE idAny/*hierarchical_identifier-task_or_block*/ ';' { $$ = new AstDisable($1,*$2); }
3160 | yDISABLE yFORK ';' { $$ = new AstDisableFork($1); }
3161 // // IEEE: event_trigger
3162 | yP_MINUSGT idDotted/*hierarchical_identifier-event*/ ';'
3163 { // AssignDly because we don't have stratified queue, and need to
3164 // read events, clear next event, THEN apply this set
3165 $$ = new AstAssignDly($1, $2, new AstConst($1, AstConst::BitTrue())); }
3166 //UNSUP yP_MINUSGTGT delay_or_event_controlE hierarchical_identifier/*event*/ ';' { UNSUP }
3167 // // IEEE remove below
3168 | yP_MINUSGTGT delayE idDotted/*hierarchical_identifier-event*/ ';'
3169 { $$ = new AstAssignDly($1, $3, new AstConst($1, AstConst::BitTrue())); }
3170 //
3171 // // IEEE: loop_statement
3172 | yFOREVER stmtBlock { $$ = new AstWhile($1,new AstConst($1, AstConst::BitTrue()), $2); }
3173 | yREPEAT '(' expr ')' stmtBlock { $$ = new AstRepeat{$1, $3, $5}; }
3174 | yWHILE '(' expr ')' stmtBlock { $$ = new AstWhile{$1, $3, $5}; }
3175 // // for's first ';' is in for_initialization
3176 | statementFor { $$ = $1; }
3177 | yDO stmtBlock yWHILE '(' expr ')' ';' { if ($2) {
3178 $$ = $2->cloneTree(true);
3179 $$->addNext(new AstWhile($1,$5,$2));
3180 }
3181 else $$ = new AstWhile($1,$5,nullptr); }
3182 // // IEEE says array_identifier here, but dotted accepted in VMM and 1800-2009
3183 | yFOREACH '(' idClassSelForeach ')' stmtBlock { $$ = new AstForeach($1, $3, $5); }
3184 //
3185 // // IEEE: jump_statement
3186 | yRETURN ';' { $$ = new AstReturn($1); }
3187 | yRETURN expr ';' { $$ = new AstReturn($1,$2); }
3188 | yBREAK ';' { $$ = new AstBreak($1); }
3189 | yCONTINUE ';' { $$ = new AstContinue($1); }
3190 //
3191 | par_block { $$ = $1; }
3192 // // IEEE: procedural_timing_control_statement + procedural_timing_control
3193 | delay_control stmtBlock { $$ = new AstDelay($1->fileline(), $1); $$->addNextNull($2); }
3194 | event_control stmtBlock { $$ = new AstTimingControl(FILELINE_OR_CRE($1), $1, $2); }
3195 //UNSUP cycle_delay stmtBlock { UNSUP }
3196 //
3197 | seq_block { $$ = $1; }
3198 //
3199 // // IEEE: wait_statement
3200 | yWAIT '(' expr ')' stmtBlock { $$ = new AstWait($1, $3, $5); }
3201 | yWAIT yFORK ';' { $$ = new AstWaitFork($1); }
3202 //UNSUP yWAIT_ORDER '(' hierarchical_identifierList ')' action_block { UNSUP }
3203 //
3204 // // IEEE: procedural_assertion_statement
3205 | procedural_assertion_statement { $$ = $1; }
3206 //
3207 // // IEEE: clocking_drive ';'
3208 // // Pattern w/o cycle_delay handled by nonblocking_assign above
3209 // // clockvar_expression made to fexprLvalue to prevent reduce conflict
3210 // // Note LTE in this context is highest precedence, so first on left wins
3211 //UNSUP cycle_delay fexprLvalue yP_LTE ';' { UNSUP }
3212 //UNSUP fexprLvalue yP_LTE cycle_delay expr ';' { UNSUP }
3213 //
3214 //UNSUP randsequence_statement { $$ = $1; }
3215 //
3216 // // IEEE: randcase_statement
3217 | yRANDCASE case_itemList yENDCASE
3218 { $$ = nullptr; BBUNSUP($1, "Unsupported: SystemVerilog 2005 randcase statements"); }
3219 //
3220 //UNSUP expect_property_statement { $$ = $1; }
3221 //
3222 | error ';' { $$ = nullptr; }
3223 ;
3224
3225 statementFor<beginp>: // IEEE: part of statement
3226 yFOR '(' for_initialization expr ';' for_stepE ')' stmtBlock
3227 { $$ = new AstBegin($1, "", $3, false, true);
3228 $$->addStmtsp(new AstWhile($1, $4,$8,$6)); }
3229 | yFOR '(' for_initialization ';' for_stepE ')' stmtBlock
3230 { $$ = new AstBegin($1, "", $3, false, true);
3231 $$->addStmtsp(new AstWhile($1, new AstConst($1,AstConst::BitTrue()), $7, $5)); }
3232 ;
3233
3234 statementVerilatorPragmas<nodep>:
3235 yVL_COVERAGE_BLOCK_OFF { $$ = new AstPragma($1,AstPragmaType::COVERAGE_BLOCK_OFF); }
3236 ;
3237
3238 //UNSUPoperator_assignment<nodep>: // IEEE: operator_assignment
3239 //UNSUP ~f~exprLvalue '=' delay_or_event_controlE expr { }
3240 //UNSUP | ~f~exprLvalue yP_PLUSEQ expr { }
3241 //UNSUP | ~f~exprLvalue yP_MINUSEQ expr { }
3242 //UNSUP | ~f~exprLvalue yP_TIMESEQ expr { }
3243 //UNSUP | ~f~exprLvalue yP_DIVEQ expr { }
3244 //UNSUP | ~f~exprLvalue yP_MODEQ expr { }
3245 //UNSUP | ~f~exprLvalue yP_ANDEQ expr { }
3246 //UNSUP | ~f~exprLvalue yP_OREQ expr { }
3247 //UNSUP | ~f~exprLvalue yP_XOREQ expr { }
3248 //UNSUP | ~f~exprLvalue yP_SLEFTEQ expr { }
3249 //UNSUP | ~f~exprLvalue yP_SRIGHTEQ expr { }
3250 //UNSUP | ~f~exprLvalue yP_SSRIGHTEQ expr { }
3251 //UNSUP ;
3252
3253 foperator_assignment<nodep>: // IEEE: operator_assignment (for first part of expression)
3254 fexprLvalue '=' delayE expr { $$ = new AstAssign($2,$1,$4); }
3255 | fexprLvalue '=' yD_FOPEN '(' expr ')' { $$ = new AstFOpenMcd($3,$1,$5); }
3256 | fexprLvalue '=' yD_FOPEN '(' expr ',' expr ')' { $$ = new AstFOpen($3,$1,$5,$7); }
3257 //
3258 //UNSUP ~f~exprLvalue '=' delay_or_event_controlE expr { UNSUP }
3259 //UNSUP ~f~exprLvalue yP_PLUS(etc) expr { UNSUP }
3260 | fexprLvalue yP_PLUSEQ expr { $$ = new AstAssign($2,$1,new AstAdd ($2,$1->cloneTree(true),$3)); }
3261 | fexprLvalue yP_MINUSEQ expr { $$ = new AstAssign($2,$1,new AstSub ($2,$1->cloneTree(true),$3)); }
3262 | fexprLvalue yP_TIMESEQ expr { $$ = new AstAssign($2,$1,new AstMul ($2,$1->cloneTree(true),$3)); }
3263 | fexprLvalue yP_DIVEQ expr { $$ = new AstAssign($2,$1,new AstDiv ($2,$1->cloneTree(true),$3)); }
3264 | fexprLvalue yP_MODEQ expr { $$ = new AstAssign($2,$1,new AstModDiv ($2,$1->cloneTree(true),$3)); }
3265 | fexprLvalue yP_ANDEQ expr { $$ = new AstAssign($2,$1,new AstAnd ($2,$1->cloneTree(true),$3)); }
3266 | fexprLvalue yP_OREQ expr { $$ = new AstAssign($2,$1,new AstOr ($2,$1->cloneTree(true),$3)); }
3267 | fexprLvalue yP_XOREQ expr { $$ = new AstAssign($2,$1,new AstXor ($2,$1->cloneTree(true),$3)); }
3268 | fexprLvalue yP_SLEFTEQ expr { $$ = new AstAssign($2,$1,new AstShiftL ($2,$1->cloneTree(true),$3)); }
3269 | fexprLvalue yP_SRIGHTEQ expr { $$ = new AstAssign($2,$1,new AstShiftR ($2,$1->cloneTree(true),$3)); }
3270 | fexprLvalue yP_SSRIGHTEQ expr { $$ = new AstAssign($2,$1,new AstShiftRS($2,$1->cloneTree(true),$3)); }
3271 //UNSUP replace above with:
3272 //UNSUP BISONPRE_COPY(operator_assignment,{s/~f~/f/g}) // {copied}
3273 ;
3274
3275 inc_or_dec_expression<nodep>: // ==IEEE: inc_or_dec_expression
3276 // // Need fexprScope instead of variable_lvalue to prevent conflict
3277 ~l~exprScope yP_PLUSPLUS
3278 { $<fl>$ = $<fl>1; $$ = new AstPostAdd{$2, new AstConst{$2, AstConst::StringToParse(), "'b1"}, $1, $1->cloneTree(true)}; }
3279 | ~l~exprScope yP_MINUSMINUS
3280 { $<fl>$ = $<fl>1; $$ = new AstPostSub{$2, new AstConst{$2, AstConst::StringToParse(), "'b1"}, $1, $1->cloneTree(true)}; }
3281 // // Need expr instead of variable_lvalue to prevent conflict
3282 | yP_PLUSPLUS expr
3283 { $<fl>$ = $<fl>1; $$ = new AstPreAdd{$1, new AstConst{$1, AstConst::StringToParse(), "'b1"}, $2, $2->cloneTree(true)}; }
3284 | yP_MINUSMINUS expr
3285 { $<fl>$ = $<fl>1; $$ = new AstPreSub{$1, new AstConst{$1, AstConst::StringToParse(), "'b1"}, $2, $2->cloneTree(true)}; }
3286 ;
3287
3288 finc_or_dec_expression<nodep>: // ==IEEE: inc_or_dec_expression
3289 BISONPRE_COPY(inc_or_dec_expression,{s/~l~/f/g}) // {copied}
3290 ;
3291
3292 //UNSUPsinc_or_dec_expression<nodep>: // IEEE: inc_or_dec_expression (for sequence_expression)
3293 //UNSUP BISONPRE_COPY(inc_or_dec_expression,{s/~l~/s/g}) // {copied}
3294 //UNSUP ;
3295
3296 //UNSUPpinc_or_dec_expression<nodep>: // IEEE: inc_or_dec_expression (for property_expression)
3297 //UNSUP BISONPRE_COPY(inc_or_dec_expression,{s/~l~/p/g}) // {copied}
3298 //UNSUP ;
3299
3300 //UNSUPev_inc_or_dec_expression<nodep>: // IEEE: inc_or_dec_expression (for ev_expr)
3301 //UNSUP BISONPRE_COPY(inc_or_dec_expression,{s/~l~/ev_/g}) // {copied}
3302 //UNSUP ;
3303
3304 //UNSUPpev_inc_or_dec_expression<nodep>: // IEEE: inc_or_dec_expression (for pev_expr)
3305 //UNSUP BISONPRE_COPY(inc_or_dec_expression,{s/~l~/pev_/g}) // {copied}
3306 //UNSUP ;
3307
3308 class_new<nodep>: // ==IEEE: class_new
3309 // // Special precence so (...) doesn't match expr
3310 yNEW__ETC { $$ = new AstNew($1, nullptr); }
3311 | yNEW__ETC expr { $$ = new AstNewCopy($1, $2); }
3312 | yNEW__PAREN '(' list_of_argumentsE ')' { $$ = new AstNew($1, $3); }
3313 ;
3314
3315 dynamic_array_new<nodep>: // ==IEEE: dynamic_array_new
3316 yNEW__ETC '[' expr ']' { $$ = new AstNewDynamic($1, $3, nullptr); }
3317 | yNEW__ETC '[' expr ']' '(' expr ')' { $$ = new AstNewDynamic($1, $3, $6); }
3318 ;
3319
3320 //************************************************
3321 // Case/If
3322
3323 unique_priorityE<uniqstate>: // IEEE: unique_priority + empty
3324 /*empty*/ { $$ = uniq_NONE; }
3325 | yPRIORITY { $$ = uniq_PRIORITY; }
3326 | yUNIQUE { $$ = uniq_UNIQUE; }
3327 | yUNIQUE0 { $$ = uniq_UNIQUE0; }
3328 ;
3329
3330 caseStart<casep>: // IEEE: part of case_statement
3331 yCASE '(' expr ')' { $$ = GRAMMARP->m_caseAttrp = new AstCase($1,VCaseType::CT_CASE,$3,nullptr); }
3332 | yCASEX '(' expr ')' { $$ = GRAMMARP->m_caseAttrp = new AstCase($1,VCaseType::CT_CASEX,$3,nullptr); }
3333 | yCASEZ '(' expr ')' { $$ = GRAMMARP->m_caseAttrp = new AstCase($1,VCaseType::CT_CASEZ,$3,nullptr); }
3334 ;
3335
3336 caseAttrE:
3337 /*empty*/ { }
3338 | caseAttrE yVL_FULL_CASE { GRAMMARP->m_caseAttrp->fullPragma(true); }
3339 | caseAttrE yVL_PARALLEL_CASE { GRAMMARP->m_caseAttrp->parallelPragma(true); }
3340 ;
3341
3342 //UNSUPcase_patternListE<nodep>: // IEEE: case_pattern_item
3343 //UNSUP // &&& is part of expr so aliases to case_itemList
3344 //UNSUP case_itemListE { $$ = $1; }
3345 //UNSUP ;
3346
3347 case_itemListE<caseItemp>: // IEEE: [ { case_item } ]
3348 /* empty */ { $$ = nullptr; }
3349 | case_itemList { $$ = $1; }
3350 ;
3351
3352 case_insideListE<caseItemp>: // IEEE: [ { case_inside_item } ]
3353 /* empty */ { $$ = nullptr; }
3354 | case_inside_itemList { $$ = $1; }
3355 ;
3356
3357 case_itemList<caseItemp>: // IEEE: { case_item + ... }
3358 caseCondList colon stmtBlock { $$ = new AstCaseItem{$2, $1, $3}; }
3359 | yDEFAULT colon stmtBlock { $$ = new AstCaseItem{$1, nullptr, $3}; }
3360 | yDEFAULT stmtBlock { $$ = new AstCaseItem{$1, nullptr, $2}; }
3361 | case_itemList caseCondList colon stmtBlock { $$ = $1; $1->addNext(new AstCaseItem{$3, $2, $4}); }
3362 | case_itemList yDEFAULT stmtBlock { $$ = $1; $1->addNext(new AstCaseItem{$2, nullptr, $3}); }
3363 | case_itemList yDEFAULT colon stmtBlock { $$ = $1; $1->addNext(new AstCaseItem{$2, nullptr, $4}); }
3364 ;
3365
3366 case_inside_itemList<caseItemp>: // IEEE: { case_inside_item + open_range_list ... }
3367 open_range_list colon stmtBlock { $$ = new AstCaseItem{$2, $1, $3}; }
3368 | yDEFAULT colon stmtBlock { $$ = new AstCaseItem{$1, nullptr, $3}; }
3369 | yDEFAULT stmtBlock { $$ = new AstCaseItem{$1, nullptr, $2}; }
3370 | case_inside_itemList open_range_list colon stmtBlock { $$ = $1; $1->addNext(new AstCaseItem{$3, $2, $4}); }
3371 | case_inside_itemList yDEFAULT stmtBlock { $$ = $1; $1->addNext(new AstCaseItem{$2, nullptr, $3}); }
3372 | case_inside_itemList yDEFAULT colon stmtBlock { $$ = $1; $1->addNext(new AstCaseItem{$2, nullptr, $4}); }
3373 ;
3374
3375 open_range_list<nodep>: // ==IEEE: open_range_list + open_value_range
3376 open_value_range { $$ = $1; }
3377 | open_range_list ',' open_value_range { $$ = $1; $1->addNext($3); }
3378 ;
3379
3380 open_value_range<nodep>: // ==IEEE: open_value_range
3381 value_range { $$ = $1; }
3382 ;
3383
3384 value_range<nodep>: // ==IEEE: value_range
3385 expr { $$ = $1; }
3386 | '[' expr ':' expr ']' { $$ = new AstInsideRange($1, $2, $4); }
3387 ;
3388
3389 //UNSUPcovergroup_value_range<nodep>: // ==IEEE-2012: covergroup_value_range
3390 //UNSUP cgexpr { $$ = $1; }
3391 //UNSUP | '[' cgexpr ':' cgexpr ']' { }
3392 //UNSUP ;
3393
3394 caseCondList<nodep>: // IEEE: part of case_item
3395 expr { $$ = $1; }
3396 | caseCondList ',' expr { $$ = $1; $1->addNext($3); }
3397 ;
3398
3399 patternNoExpr<nodep>: // IEEE: pattern **Excluding Expr*
3400 '.' id/*variable*/
3401 { $$ = nullptr; BBUNSUP($1, "Unsupported: '{} tagged patterns"); }
3402 | yP_DOTSTAR
3403 { $$ = nullptr; BBUNSUP($1, "Unsupported: '{} tagged patterns"); }
3404 // // IEEE: "expr" excluded; expand in callers
3405 // // "yTAGGED id [expr]" Already part of expr
3406 //UNSUP yTAGGED id/*member_identifier*/ patternNoExpr
3407 //UNSUP { $$ = nullptr; BBUNSUP($1, "Unsupported: '{} tagged patterns"); }
3408 // // "yP_TICKBRA patternList '}'" part of expr under assignment_pattern
3409 ;
3410
3411 patternList<nodep>: // IEEE: part of pattern
3412 patternOne { $$ = $1; }
3413 | patternList ',' patternOne { $$ = $1->addNextNull($3); }
3414 ;
3415
3416 patternOne<nodep>: // IEEE: part of pattern
3417 expr
3418 { if ($1) $$ = new AstPatMember{$1->fileline(), $1, nullptr, nullptr}; else $$ = nullptr; }
3419 | expr '{' argsExprList '}' { $$ = new AstPatMember{$2, $3, nullptr, $1}; }
3420 | patternNoExpr { $$ = $1; }
3421 ;
3422
3423 patternMemberList<nodep>: // IEEE: part of pattern and assignment_pattern
3424 patternMemberOne { $$ = $1; }
3425 | patternMemberList ',' patternMemberOne { $$ = $1->addNextNull($3); }
3426 ;
3427
3428 patternMemberOne<patMemberp>: // IEEE: part of pattern and assignment_pattern
3429 patternKey ':' expr { $$ = new AstPatMember($1->fileline(),$3,$1,nullptr); }
3430 | patternKey ':' patternNoExpr { $$ = nullptr; BBUNSUP($2, "Unsupported: '{} .* patterns"); }
3431 // // From assignment_pattern_key
3432 | yDEFAULT ':' expr { $$ = new AstPatMember($1,$3,nullptr,nullptr); $$->isDefault(true); }
3433 | yDEFAULT ':' patternNoExpr { $$ = nullptr; BBUNSUP($2, "Unsupported: '{} .* patterns"); }
3434 ;
3435
3436 patternKey<nodep>: // IEEE: merge structure_pattern_key, array_pattern_key, assignment_pattern_key
3437 // // IEEE: structure_pattern_key
3438 // // id/*member*/ is part of constExpr below
3439 //UNSUP constExpr { $$ = $1; }
3440 // // IEEE: assignment_pattern_key
3441 //UNSUP simple_type { $1->v3error("Unsupported: '{} with data type as key"); $$ = $1; }
3442 // // simple_type reference looks like constExpr
3443 // // Verilator:
3444 // // The above expressions cause problems because "foo" may be a constant identifier
3445 // // (if array) or a reference to the "foo"member (if structure)
3446 // // So for now we only allow a true constant number, or a identifier which we treat as a structure member name
3447 yaINTNUM { $$ = new AstConst($<fl>1,*$1); }
3448 | yaFLOATNUM { $$ = new AstConst($<fl>1,AstConst::RealDouble(),$1); }
3449 | id { $$ = new AstText($<fl>1,*$1); }
3450 | strAsInt { $$ = $1; }
3451 ;
3452
3453 assignment_pattern<patternp>: // ==IEEE: assignment_pattern
3454 // This doesn't match the text of the spec. I think a : is missing, or example code needed
3455 // yP_TICKBRA constExpr exprList '}' { $$="'{"+$2+" "+$3"}"; }
3456 // // "'{ const_expression }" is same as patternList with one entry
3457 // // From patternNoExpr
3458 // // also IEEE: "''{' expression { ',' expression } '}'"
3459 // // matches since patternList includes expr
3460 yP_TICKBRA patternList '}' { $$ = new AstPattern($1,$2); }
3461 // // From patternNoExpr
3462 // // also IEEE "''{' structure_pattern_key ':' ...
3463 // // also IEEE "''{' array_pattern_key ':' ...
3464 | yP_TICKBRA patternMemberList '}' { $$ = new AstPattern($1,$2); }
3465 // // IEEE: Not in grammar, but in VMM
3466 | yP_TICKBRA '}' { $$ = new AstPattern($1, nullptr); }
3467 ;
3468
3469 // "datatype id = x {, id = x }" | "yaId = x {, id=x}" is legal
3470 for_initialization<nodep>: // ==IEEE: for_initialization + for_variable_declaration + extra terminating ";"
3471 // // IEEE: for_variable_declaration
3472 for_initializationItemList ';' { $$ = $1; }
3473 // // IEEE: 1800-2017 empty initialization
3474 | ';' { $$ = nullptr; }
3475 ;
3476
3477 for_initializationItemList<nodep>: // IEEE: [for_variable_declaration...]
3478 for_initializationItem { $$ = $1; }
3479 | for_initializationItemList ',' for_initializationItem
3480 { $$ = $1; BBUNSUP($2, "Unsupported: for loop initialization after the first comma"); }
3481 ;
3482
3483 for_initializationItem<nodep>: // IEEE: variable_assignment + for_variable_declaration
3484 // // IEEE: for_variable_declaration
3485 data_type idAny/*new*/ '=' expr
3486 { VARRESET_NONLIST(VAR); VARDTYPE($1);
3487 $$ = VARDONEA($<fl>2,*$2,nullptr,nullptr);
3488 $$->addNext(new AstAssign($3, new AstVarRef($<fl>2, *$2, VAccess::WRITE), $4)); }
3489 // // IEEE-2012:
3490 | yVAR data_type idAny/*new*/ '=' expr
3491 { VARRESET_NONLIST(VAR); VARDTYPE($2);
3492 $$ = VARDONEA($<fl>3,*$3,nullptr,nullptr);
3493 $$->addNext(new AstAssign($4, new AstVarRef($<fl>3, *$3, VAccess::WRITE), $5)); }
3494 // // IEEE: variable_assignment
3495 // // UNSUP variable_lvalue below
3496 | varRefBase '=' expr { $$ = new AstAssign($2, $1, $3); }
3497 ;
3498
3499 for_stepE<nodep>: // IEEE: for_step + empty
3500 /* empty */ { $$ = nullptr; }
3501 | for_step { $$ = $1; }
3502 ;
3503
3504 for_step<nodep>: // IEEE: for_step
3505 for_step_assignment { $$ = $1; }
3506 | for_step ',' for_step_assignment { $$ = AstNode::addNextNull($1, $3); }
3507 ;
3508
3509 for_step_assignment<nodep>: // ==IEEE: for_step_assignment
3510 //UNSUP operator_assignment { $$ = $1; }
3511 //
3512 //UNSUP inc_or_dec_expression { $$ = $1; }
3513 // // IEEE: subroutine_call
3514 //UNSUP function_subroutine_callNoMethod { $$ = $1; }
3515 // // method_call:array_method requires a '.'
3516 //UNSUP expr '.' array_methodNoRoot { }
3517 //UNSUP exprScope { $$ = $1; }
3518 //UNSUP remove below
3519 genvar_iteration { $$ = $1; }
3520 //UNSUP remove above
3521 ;
3522
3523 loop_variables<nodep>: // IEEE: loop_variables
3524 varRefBase { $$ = $1; }
3525 | loop_variables ',' varRefBase { $$ = $1; $1->addNext($3); }
3526 ;
3527
3528 //************************************************
3529 // Functions/tasks
3530
3531 taskRef<nodep>: // IEEE: part of tf_call
3532 id { $$ = new AstTaskRef($<fl>1,*$1,nullptr); }
3533 | id '(' list_of_argumentsE ')' { $$ = new AstTaskRef($<fl>1,*$1,$3); }
3534 | packageClassScope id '(' list_of_argumentsE ')'
3535 { $$ = AstDot::newIfPkg($<fl>2, $1, new AstTaskRef($<fl>2, *$2, $4)); }
3536 ;
3537
3538 funcRef<nodep>: // IEEE: part of tf_call
3539 // // package_scope/hierarchical_... is part of expr, so just need ID
3540 // // making-a id-is-a
3541 // // ----------------- ------------------
3542 // // tf_call tf_identifier expr (list_of_arguments)
3543 // // method_call(post .) function_identifier expr (list_of_arguments)
3544 // // property_instance property_identifier property_actual_arg
3545 // // sequence_instance sequence_identifier sequence_actual_arg
3546 // // let_expression let_identifier let_actual_arg
3547 //
3548 id '(' list_of_argumentsE ')'
3549 { $$ = new AstFuncRef($<fl>1, *$1, $3); }
3550 | packageClassScope id '(' list_of_argumentsE ')'
3551 { $$ = AstDot::newIfPkg($<fl>2, $1, new AstFuncRef($<fl>2, *$2, $4)); }
3552 //UNSUP list_of_argumentE should be pev_list_of_argumentE
3553 //UNSUP: idDotted is really just id to allow dotted method calls
3554 ;
3555
3556 task_subroutine_callNoMethod<nodep>: // function_subroutine_callNoMethod (as task)
3557 // // IEEE: tf_call
3558 taskRef { $$ = $1; }
3559 // // funcref below not task ref to avoid conflict, must later handle either
3560 | funcRef yWITH__PAREN '(' expr ')' { $$ = new AstWithParse($2, true, $1, $4); }
3561 // // can call as method and yWITH without parenthesis
3562 | id yWITH__PAREN '(' expr ')' { $$ = new AstWithParse($2, true, new AstFuncRef($<fl>1, *$1, nullptr), $4); }
3563 | system_t_call { $$ = $1; }
3564 // // IEEE: method_call requires a "." so is in expr
3565 // // IEEE: ['std::'] not needed, as normal std package resolution will find it
3566 // // IEEE: randomize_call
3567 // // We implement randomize as a normal funcRef, since randomize isn't a keyword
3568 // // Note yNULL is already part of expressions, so they come for free
3569 //UNSUP funcRef yWITH__CUR constraint_block { }
3570 ;
3571
3572 function_subroutine_callNoMethod<nodep>: // IEEE: function_subroutine_call (as function)
3573 // // IEEE: tf_call
3574 funcRef { $$ = $1; }
3575 | funcRef yWITH__PAREN '(' expr ')' { $$ = new AstWithParse($2, false, $1, $4); }
3576 // // can call as method and yWITH without parenthesis
3577 | id yWITH__PAREN '(' expr ')' { $$ = new AstWithParse($2, false, new AstFuncRef($<fl>1, *$1, nullptr), $4); }
3578 | system_f_call { $$ = $1; }
3579 // // IEEE: method_call requires a "." so is in expr
3580 // // IEEE: ['std::'] not needed, as normal std package resolution will find it
3581 // // IEEE: randomize_call
3582 // // We implement randomize as a normal funcRef, since randomize isn't a keyword
3583 // // Note yNULL is already part of expressions, so they come for free
3584 | funcRef yWITH__CUR constraint_block
3585 { $$ = $1; BBUNSUP($2, "Unsupported: randomize() 'with' constraint"); }
3586 | funcRef yWITH__CUR '{' '}' { $$ = new AstWithParse($2, false, $1, nullptr); }
3587 ;
3588
3589 system_t_call<nodep>: // IEEE: system_tf_call (as task)
3590 //
3591 yaD_PLI systemDpiArgsE { $$ = new AstTaskRef($<fl>1, *$1, $2); VN_CAST($$, TaskRef)->pli(true); }
3592 //
3593 | yD_DUMPPORTS '(' idDotted ',' expr ')' { $$ = new AstDumpCtl($<fl>1, VDumpCtlType::FILE, $5); DEL($3);
3594 $$->addNext(new AstDumpCtl($<fl>1, VDumpCtlType::VARS,
3595 new AstConst($<fl>1, 1))); }
3596 | yD_DUMPPORTS '(' ',' expr ')' { $$ = new AstDumpCtl($<fl>1, VDumpCtlType::FILE, $4);
3597 $$->addNext(new AstDumpCtl($<fl>1, VDumpCtlType::VARS,
3598 new AstConst($<fl>1, 1))); }
3599 | yD_DUMPFILE '(' expr ')' { $$ = new AstDumpCtl($<fl>1, VDumpCtlType::FILE, $3); }
3600 | yD_DUMPVARS parenE { $$ = new AstDumpCtl($<fl>1, VDumpCtlType::VARS,
3601 new AstConst($<fl>1, 0)); }
3602 | yD_DUMPVARS '(' expr ')' { $$ = new AstDumpCtl($<fl>1, VDumpCtlType::VARS, $3); }
3603 | yD_DUMPVARS '(' expr ',' idDotted ')' { $$ = new AstDumpCtl($<fl>1, VDumpCtlType::VARS, $3); DEL($5); }
3604 | yD_DUMPALL parenE { $$ = new AstDumpCtl($<fl>1, VDumpCtlType::ALL); }
3605 | yD_DUMPALL '(' expr ')' { $$ = new AstDumpCtl($<fl>1, VDumpCtlType::ALL); DEL($3); }
3606 | yD_DUMPFLUSH parenE { $$ = new AstDumpCtl($<fl>1, VDumpCtlType::FLUSH); }
3607 | yD_DUMPFLUSH '(' expr ')' { $$ = new AstDumpCtl($<fl>1, VDumpCtlType::FLUSH); DEL($3); }
3608 | yD_DUMPLIMIT '(' expr ')' { $$ = new AstDumpCtl($<fl>1, VDumpCtlType::LIMIT, $3); }
3609 | yD_DUMPLIMIT '(' expr ',' expr ')' { $$ = new AstDumpCtl($<fl>1, VDumpCtlType::LIMIT, $3); DEL($5); }
3610 | yD_DUMPOFF parenE { $$ = new AstDumpCtl($<fl>1, VDumpCtlType::OFF); }
3611 | yD_DUMPOFF '(' expr ')' { $$ = new AstDumpCtl($<fl>1, VDumpCtlType::OFF); DEL($3); }
3612 | yD_DUMPON parenE { $$ = new AstDumpCtl($<fl>1, VDumpCtlType::ON); }
3613 | yD_DUMPON '(' expr ')' { $$ = new AstDumpCtl($<fl>1, VDumpCtlType::ON); DEL($3); }
3614 //
3615 | yD_C '(' cStrList ')' { $$ = (v3Global.opt.ignc() ? nullptr : new AstUCStmt($1,$3)); }
3616 | yD_SYSTEM '(' expr ')' { $$ = new AstSystemT($1, $3); }
3617 //
3618 | yD_EXIT parenE { $$ = new AstFinish($1); }
3619 //
3620 | yD_FCLOSE '(' idClassSel ')' { $$ = new AstFClose($1, $3); }
3621 | yD_FFLUSH parenE { $$ = new AstFFlush($1, nullptr); }
3622 | yD_FFLUSH '(' expr ')' { $$ = new AstFFlush($1, $3); }
3623 | yD_FINISH parenE { $$ = new AstFinish($1); }
3624 | yD_FINISH '(' expr ')' { $$ = new AstFinish($1); DEL($3); }
3625 | yD_STOP parenE { $$ = new AstStop($1, false); }
3626 | yD_STOP '(' expr ')' { $$ = new AstStop($1, false); DEL($3); }
3627 //
3628 | yD_SFORMAT '(' expr ',' exprDispList ')' { $$ = new AstSFormat($1, $3, $5); }
3629 | yD_SWRITE '(' expr ',' exprDispList ')' { $$ = new AstSFormat($1, $3, $5); }
3630 | yD_SWRITEB '(' expr ',' exprDispList ')' { $$ = new AstSFormat($1, $3, $5, 'b'); }
3631 | yD_SWRITEH '(' expr ',' exprDispList ')' { $$ = new AstSFormat($1, $3, $5, 'h'); }
3632 | yD_SWRITEO '(' expr ',' exprDispList ')' { $$ = new AstSFormat($1, $3, $5, 'o'); }
3633 //
3634 | yD_DISPLAY parenE { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY, nullptr, nullptr); }
3635 | yD_DISPLAY '(' exprDispList ')' { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY, nullptr, $3); }
3636 | yD_DISPLAYB parenE { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY, nullptr, nullptr, 'b'); }
3637 | yD_DISPLAYB '(' exprDispList ')' { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY, nullptr, $3, 'b'); }
3638 | yD_DISPLAYH parenE { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY, nullptr, nullptr, 'h'); }
3639 | yD_DISPLAYH '(' exprDispList ')' { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY, nullptr, $3, 'h'); }
3640 | yD_DISPLAYO parenE { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY, nullptr, nullptr, 'o'); }
3641 | yD_DISPLAYO '(' exprDispList ')' { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY, nullptr, $3, 'o'); }
3642 | yD_MONITOR '(' exprDispList ')' { $$ = new AstDisplay($1, AstDisplayType::DT_MONITOR, nullptr, $3); }
3643 | yD_MONITORB '(' exprDispList ')' { $$ = new AstDisplay($1, AstDisplayType::DT_MONITOR, nullptr, $3, 'b'); }
3644 | yD_MONITORH '(' exprDispList ')' { $$ = new AstDisplay($1, AstDisplayType::DT_MONITOR, nullptr, $3, 'h'); }
3645 | yD_MONITORO '(' exprDispList ')' { $$ = new AstDisplay($1, AstDisplayType::DT_MONITOR, nullptr, $3, 'o'); }
3646 | yD_STROBE '(' exprDispList ')' { $$ = new AstDisplay($1, AstDisplayType::DT_STROBE, nullptr, $3); }
3647 | yD_STROBEB '(' exprDispList ')' { $$ = new AstDisplay($1, AstDisplayType::DT_STROBE, nullptr, $3, 'b'); }
3648 | yD_STROBEH '(' exprDispList ')' { $$ = new AstDisplay($1, AstDisplayType::DT_STROBE, nullptr, $3, 'h'); }
3649 | yD_STROBEO '(' exprDispList ')' { $$ = new AstDisplay($1, AstDisplayType::DT_STROBE, nullptr, $3, 'o'); }
3650 | yD_WRITE parenE { $$ = nullptr; } // NOP
3651 | yD_WRITE '(' exprDispList ')' { $$ = new AstDisplay($1,AstDisplayType::DT_WRITE, nullptr, $3); }
3652 | yD_WRITEB parenE { $$ = nullptr; } // NOP
3653 | yD_WRITEB '(' exprDispList ')' { $$ = new AstDisplay($1,AstDisplayType::DT_WRITE, nullptr, $3, 'b'); }
3654 | yD_WRITEH parenE { $$ = nullptr; } // NOP
3655 | yD_WRITEH '(' exprDispList ')' { $$ = new AstDisplay($1,AstDisplayType::DT_WRITE, nullptr, $3, 'h'); }
3656 | yD_WRITEO parenE { $$ = nullptr; } // NOP
3657 | yD_WRITEO '(' exprDispList ')' { $$ = new AstDisplay($1,AstDisplayType::DT_WRITE, nullptr, $3, 'o'); }
3658 | yD_FDISPLAY '(' expr ')' { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY, $3, nullptr); }
3659 | yD_FDISPLAY '(' expr ',' exprDispList ')' { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY, $3, $5); }
3660 | yD_FDISPLAYB '(' expr ')' { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY, $3, nullptr, 'b'); }
3661 | yD_FDISPLAYB '(' expr ',' exprDispList ')' { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY, $3, $5, 'b'); }
3662 | yD_FDISPLAYH '(' expr ')' { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY, $3, nullptr, 'h'); }
3663 | yD_FDISPLAYH '(' expr ',' exprDispList ')' { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY, $3, $5, 'h'); }
3664 | yD_FDISPLAYO '(' expr ')' { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY, $3, nullptr, 'o'); }
3665 | yD_FDISPLAYO '(' expr ',' exprDispList ')' { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY, $3, $5, 'o'); }
3666 | yD_FMONITOR '(' expr ',' exprDispList ')' { $$ = new AstDisplay($1, AstDisplayType::DT_MONITOR, $3, $5); }
3667 | yD_FMONITORB '(' expr ',' exprDispList ')' { $$ = new AstDisplay($1, AstDisplayType::DT_MONITOR, $3, $5, 'b'); }
3668 | yD_FMONITORH '(' expr ',' exprDispList ')' { $$ = new AstDisplay($1, AstDisplayType::DT_MONITOR, $3, $5, 'h'); }
3669 | yD_FMONITORO '(' expr ',' exprDispList ')' { $$ = new AstDisplay($1, AstDisplayType::DT_MONITOR, $3, $5, 'o'); }
3670 | yD_FSTROBE '(' expr ',' exprDispList ')' { $$ = new AstDisplay($1, AstDisplayType::DT_STROBE, $3, $5); }
3671 | yD_FSTROBEB '(' expr ',' exprDispList ')' { $$ = new AstDisplay($1, AstDisplayType::DT_STROBE, $3, $5, 'b'); }
3672 | yD_FSTROBEH '(' expr ',' exprDispList ')' { $$ = new AstDisplay($1, AstDisplayType::DT_STROBE, $3, $5, 'h'); }
3673 | yD_FSTROBEO '(' expr ',' exprDispList ')' { $$ = new AstDisplay($1, AstDisplayType::DT_STROBE, $3, $5, 'o'); }
3674 | yD_FWRITE '(' expr ',' exprDispList ')' { $$ = new AstDisplay($1, AstDisplayType::DT_WRITE, $3, $5); }
3675 | yD_FWRITEB '(' expr ',' exprDispList ')' { $$ = new AstDisplay($1, AstDisplayType::DT_WRITE, $3, $5, 'b'); }
3676 | yD_FWRITEH '(' expr ',' exprDispList ')' { $$ = new AstDisplay($1, AstDisplayType::DT_WRITE, $3, $5, 'h'); }
3677 | yD_FWRITEO '(' expr ',' exprDispList ')' { $$ = new AstDisplay($1, AstDisplayType::DT_WRITE, $3, $5, 'o'); }
3678 | yD_INFO parenE { $$ = new AstDisplay($1,AstDisplayType::DT_INFO, nullptr, nullptr); }
3679 | yD_INFO '(' exprDispList ')' { $$ = new AstDisplay($1,AstDisplayType::DT_INFO, nullptr, $3); }
3680 | yD_WARNING parenE { $$ = new AstDisplay($1,AstDisplayType::DT_WARNING, nullptr, nullptr); }
3681 | yD_WARNING '(' exprDispList ')' { $$ = new AstDisplay($1,AstDisplayType::DT_WARNING, nullptr, $3); }
3682 | yD_ERROR parenE { $$ = GRAMMARP->createDisplayError($1); }
3683 | yD_ERROR '(' exprDispList ')' { $$ = new AstDisplay($1,AstDisplayType::DT_ERROR, nullptr, $3); $$->addNext(new AstStop($1, true)); }
3684 | yD_FATAL parenE { $$ = new AstDisplay($1,AstDisplayType::DT_FATAL, nullptr, nullptr); $$->addNext(new AstStop($1, false)); }
3685 | yD_FATAL '(' expr ')' { $$ = new AstDisplay($1,AstDisplayType::DT_FATAL, nullptr, nullptr); $$->addNext(new AstStop($1, false)); DEL($3); }
3686 | yD_FATAL '(' expr ',' exprDispList ')' { $$ = new AstDisplay($1,AstDisplayType::DT_FATAL, nullptr, $5); $$->addNext(new AstStop($1, false)); DEL($3); }
3687 //
3688 | yD_MONITOROFF parenE { $$ = new AstMonitorOff($1, true); }
3689 | yD_MONITORON parenE { $$ = new AstMonitorOff($1, false); }
3690 //
3691 | yD_PRINTTIMESCALE { $$ = new AstPrintTimeScale($1); }
3692 | yD_PRINTTIMESCALE '(' ')' { $$ = new AstPrintTimeScale($1); }
3693 | yD_PRINTTIMESCALE '(' idClassSel ')' { $$ = new AstPrintTimeScale($1); DEL($3); }
3694 | yD_TIMEFORMAT '(' expr ',' expr ',' expr ',' expr ')' { $$ = new AstTimeFormat($1, $3, $5, $7, $9); }
3695 //
3696 | yD_READMEMB '(' expr ',' idClassSel ')' { $$ = new AstReadMem($1,false,$3,$5,nullptr,nullptr); }
3697 | yD_READMEMB '(' expr ',' idClassSel ',' expr ')' { $$ = new AstReadMem($1,false,$3,$5,$7,nullptr); }
3698 | yD_READMEMB '(' expr ',' idClassSel ',' expr ',' expr ')' { $$ = new AstReadMem($1,false,$3,$5,$7,$9); }
3699 | yD_READMEMH '(' expr ',' idClassSel ')' { $$ = new AstReadMem($1,true, $3,$5,nullptr,nullptr); }
3700 | yD_READMEMH '(' expr ',' idClassSel ',' expr ')' { $$ = new AstReadMem($1,true, $3,$5,$7,nullptr); }
3701 | yD_READMEMH '(' expr ',' idClassSel ',' expr ',' expr ')' { $$ = new AstReadMem($1,true, $3,$5,$7,$9); }
3702 //
3703 | yD_WRITEMEMB '(' expr ',' idClassSel ')' { $$ = new AstWriteMem($1, false, $3, $5, nullptr, nullptr); }
3704 | yD_WRITEMEMB '(' expr ',' idClassSel ',' expr ')' { $$ = new AstWriteMem($1, false, $3, $5, $7, nullptr); }
3705 | yD_WRITEMEMB '(' expr ',' idClassSel ',' expr ',' expr ')' { $$ = new AstWriteMem($1, false, $3, $5, $7, $9); }
3706 | yD_WRITEMEMH '(' expr ',' idClassSel ')' { $$ = new AstWriteMem($1, true, $3, $5, nullptr, nullptr); }
3707 | yD_WRITEMEMH '(' expr ',' idClassSel ',' expr ')' { $$ = new AstWriteMem($1, true, $3, $5, $7, nullptr); }
3708 | yD_WRITEMEMH '(' expr ',' idClassSel ',' expr ',' expr ')' { $$ = new AstWriteMem($1, true, $3, $5, $7, $9); }
3709 //
3710 | yD_CAST '(' expr ',' expr ')'
3711 { FileLine* const fl_nowarn = new FileLine{$1};
3712 fl_nowarn->warnOff(V3ErrorCode::WIDTH, true);
3713 $$ = new AstAssertIntrinsic(fl_nowarn, new AstCastDynamic(fl_nowarn, $5, $3), nullptr, nullptr, true); }
3714 //
3715 // Any system function as a task
3716 | system_f_call_or_t { $$ = new AstSysFuncAsTask($<fl>1, $1); }
3717 ;
3718
3719 system_f_call<nodep>: // IEEE: system_tf_call (as func)
3720 yaD_PLI systemDpiArgsE { $$ = new AstFuncRef($<fl>1, *$1, $2); VN_CAST($$, FuncRef)->pli(true); }
3721 //
3722 | yD_C '(' cStrList ')' { $$ = (v3Global.opt.ignc() ? nullptr : new AstUCFunc($1,$3)); }
3723 | yD_CAST '(' expr ',' expr ')' { $$ = new AstCastDynamic($1, $5, $3); }
3724 | yD_SYSTEM '(' expr ')' { $$ = new AstSystemF($1,$3); }
3725 //
3726 | system_f_call_or_t { $$ = $1; }
3727 ;
3728
3729 systemDpiArgsE<nodep>: // IEEE: part of system_if_call for aruments of $dpi call
3730 parenE { $$ = nullptr; }
3731 | '(' exprList ')' { $$ = GRAMMARP->argWrapList($2); }
3732 ;
3733
3734 system_f_call_or_t<nodep>: // IEEE: part of system_tf_call (can be task or func)
3735 yD_ACOS '(' expr ')' { $$ = new AstAcosD($1,$3); }
3736 | yD_ACOSH '(' expr ')' { $$ = new AstAcoshD($1,$3); }
3737 | yD_ASIN '(' expr ')' { $$ = new AstAsinD($1,$3); }
3738 | yD_ASINH '(' expr ')' { $$ = new AstAsinhD($1,$3); }
3739 | yD_ATAN '(' expr ')' { $$ = new AstAtanD($1,$3); }
3740 | yD_ATAN2 '(' expr ',' expr ')' { $$ = new AstAtan2D($1,$3,$5); }
3741 | yD_ATANH '(' expr ')' { $$ = new AstAtanhD($1,$3); }
3742 | yD_BITS '(' exprOrDataType ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_BITS,$3); }
3743 | yD_BITS '(' exprOrDataType ',' expr ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_BITS,$3,$5); }
3744 | yD_BITSTOREAL '(' expr ')' { $$ = new AstBitsToRealD($1,$3); }
3745 | yD_BITSTOSHORTREAL '(' expr ')' { $$ = new AstBitsToRealD($1,$3); UNSUPREAL($1); }
3746 | yD_CEIL '(' expr ')' { $$ = new AstCeilD($1,$3); }
3747 | yD_CHANGED '(' expr ')' { $$ = new AstLogNot($1, new AstStable($1, $3)); }
3748 | yD_CHANGED '(' expr ',' expr ')' { $$ = $3; BBUNSUP($1, "Unsupported: $changed and clock arguments"); }
3749 | yD_CLOG2 '(' expr ')' { $$ = new AstCLog2($1,$3); }
3750 | yD_COS '(' expr ')' { $$ = new AstCosD($1,$3); }
3751 | yD_COSH '(' expr ')' { $$ = new AstCoshD($1,$3); }
3752 | yD_COUNTBITS '(' expr ',' expr ')' { $$ = new AstCountBits($1,$3,$5); }
3753 | yD_COUNTBITS '(' expr ',' expr ',' expr ')' { $$ = new AstCountBits($1,$3,$5,$7); }
3754 | yD_COUNTBITS '(' expr ',' expr ',' expr ',' expr ')' { $$ = new AstCountBits($1,$3,$5,$7,$9); }
3755 | yD_COUNTBITS '(' expr ',' expr ',' expr ',' expr ',' exprList ')'
3756 { $$ = new AstCountBits($1, $3, $5, $7, $9);
3757 BBUNSUP($11, "Unsupported: $countbits with more than 3 control fields"); }
3758 | yD_COUNTONES '(' expr ')' { $$ = new AstCountOnes($1,$3); }
3759 | yD_DIMENSIONS '(' exprOrDataType ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_DIMENSIONS,$3); }
3760 | yD_EXP '(' expr ')' { $$ = new AstExpD($1,$3); }
3761 | yD_FELL '(' expr ')' { $$ = new AstFell($1,$3); }
3762 | yD_FELL '(' expr ',' expr ')' { $$ = $3; BBUNSUP($1, "Unsupported: $fell and clock arguments"); }
3763 | yD_FEOF '(' expr ')' { $$ = new AstFEof($1,$3); }
3764 | yD_FERROR '(' idClassSel ',' idClassSel ')' { $$ = new AstFError($1, $3, $5); }
3765 | yD_FGETC '(' expr ')' { $$ = new AstFGetC($1,$3); }
3766 | yD_FGETS '(' idClassSel ',' expr ')' { $$ = new AstFGetS($1,$3,$5); }
3767 | yD_FREAD '(' idClassSel ',' expr ')' { $$ = new AstFRead($1,$3,$5,nullptr,nullptr); }
3768 | yD_FREAD '(' idClassSel ',' expr ',' expr ')' { $$ = new AstFRead($1,$3,$5,$7,nullptr); }
3769 | yD_FREAD '(' idClassSel ',' expr ',' expr ',' expr ')' { $$ = new AstFRead($1,$3,$5,$7,$9); }
3770 | yD_FREWIND '(' idClassSel ')' { $$ = new AstFRewind($1, $3); }
3771 | yD_FLOOR '(' expr ')' { $$ = new AstFloorD($1,$3); }
3772 | yD_FSCANF '(' expr ',' str commaVRDListE ')' { $$ = new AstFScanF($1,*$5,$3,$6); }
3773 | yD_FSEEK '(' idClassSel ',' expr ',' expr ')' { $$ = new AstFSeek($1,$3,$5,$7); }
3774 | yD_FTELL '(' idClassSel ')' { $$ = new AstFTell($1, $3); }
3775 | yD_HIGH '(' exprOrDataType ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_HIGH,$3,nullptr); }
3776 | yD_HIGH '(' exprOrDataType ',' expr ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_HIGH,$3,$5); }
3777 | yD_HYPOT '(' expr ',' expr ')' { $$ = new AstHypotD($1,$3,$5); }
3778 | yD_INCREMENT '(' exprOrDataType ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_INCREMENT,$3,nullptr); }
3779 | yD_INCREMENT '(' exprOrDataType ',' expr ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_INCREMENT,$3,$5); }
3780 | yD_ISUNBOUNDED '(' expr ')' { $$ = new AstIsUnbounded($1, $3); }
3781 | yD_ISUNKNOWN '(' expr ')' { $$ = new AstIsUnknown($1, $3); }
3782 | yD_ITOR '(' expr ')' { $$ = new AstIToRD($1,$3); }
3783 | yD_LEFT '(' exprOrDataType ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_LEFT,$3,nullptr); }
3784 | yD_LEFT '(' exprOrDataType ',' expr ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_LEFT,$3,$5); }
3785 | yD_LN '(' expr ')' { $$ = new AstLogD($1,$3); }
3786 | yD_LOG10 '(' expr ')' { $$ = new AstLog10D($1,$3); }
3787 | yD_LOW '(' exprOrDataType ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_LOW,$3,nullptr); }
3788 | yD_LOW '(' exprOrDataType ',' expr ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_LOW,$3,$5); }
3789 | yD_ONEHOT '(' expr ')' { $$ = new AstOneHot($1,$3); }
3790 | yD_ONEHOT0 '(' expr ')' { $$ = new AstOneHot0($1,$3); }
3791 | yD_PAST '(' expr ')' { $$ = new AstPast($1,$3, nullptr); }
3792 | yD_PAST '(' expr ',' expr ')' { $$ = new AstPast($1,$3, $5); }
3793 | yD_PAST '(' expr ',' expr ',' expr ')' { $$ = $3; BBUNSUP($1, "Unsupported: $past expr2 and clock arguments"); }
3794 | yD_PAST '(' expr ',' expr ',' expr ',' expr')' { $$ = $3; BBUNSUP($1, "Unsupported: $past expr2 and clock arguments"); }
3795 | yD_POW '(' expr ',' expr ')' { $$ = new AstPowD($1,$3,$5); }
3796 | yD_RANDOM '(' expr ')' { $$ = new AstRand($1, $3, false); }
3797 | yD_RANDOM parenE { $$ = new AstRand($1, nullptr, false); }
3798 | yD_REALTIME parenE { $$ = new AstTimeD($1, VTimescale(VTimescale::NONE)); }
3799 | yD_REALTOBITS '(' expr ')' { $$ = new AstRealToBits($1,$3); }
3800 | yD_REWIND '(' idClassSel ')' { $$ = new AstFSeek($1, $3, new AstConst($1, 0), new AstConst($1, 0)); }
3801 | yD_RIGHT '(' exprOrDataType ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_RIGHT,$3,nullptr); }
3802 | yD_RIGHT '(' exprOrDataType ',' expr ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_RIGHT,$3,$5); }
3803 | yD_ROSE '(' expr ')' { $$ = new AstRose($1,$3); }
3804 | yD_ROSE '(' expr ',' expr ')' { $$ = $3; BBUNSUP($1, "Unsupported: $rose and clock arguments"); }
3805 | yD_RTOI '(' expr ')' { $$ = new AstRToIS($1,$3); }
3806 | yD_SAMPLED '(' expr ')' { $$ = new AstSampled($1, $3); }
3807 | yD_SFORMATF '(' exprDispList ')' { $$ = new AstSFormatF($1, AstSFormatF::NoFormat(), $3, 'd', false); }
3808 | yD_SHORTREALTOBITS '(' expr ')' { $$ = new AstRealToBits($1,$3); UNSUPREAL($1); }
3809 | yD_SIGNED '(' expr ')' { $$ = new AstSigned($1,$3); }
3810 | yD_SIN '(' expr ')' { $$ = new AstSinD($1,$3); }
3811 | yD_SINH '(' expr ')' { $$ = new AstSinhD($1,$3); }
3812 | yD_SIZE '(' exprOrDataType ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_SIZE,$3,nullptr); }
3813 | yD_SIZE '(' exprOrDataType ',' expr ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_SIZE,$3,$5); }
3814 | yD_SQRT '(' expr ')' { $$ = new AstSqrtD($1,$3); }
3815 | yD_SSCANF '(' expr ',' str commaVRDListE ')' { $$ = new AstSScanF($1,*$5,$3,$6); }
3816 | yD_STIME parenE { $$ = new AstSel($1, new AstTime($1, VTimescale(VTimescale::NONE)), 0, 32); }
3817 | yD_STABLE '(' expr ')' { $$ = new AstStable($1,$3); }
3818 | yD_STABLE '(' expr ',' expr ')' { $$ = $3; BBUNSUP($1, "Unsupported: $stable and clock arguments"); }
3819 | yD_TAN '(' expr ')' { $$ = new AstTanD($1,$3); }
3820 | yD_TANH '(' expr ')' { $$ = new AstTanhD($1,$3); }
3821 | yD_TESTPLUSARGS '(' str ')' { $$ = new AstTestPlusArgs($1,*$3); }
3822 | yD_TIME parenE { $$ = new AstTime($1, VTimescale(VTimescale::NONE)); }
3823 | yD_TYPENAME '(' exprOrDataType ')' { $$ = new AstAttrOf($1, AstAttrType::TYPENAME, $3); }
3824 | yD_UNGETC '(' expr ',' expr ')' { $$ = new AstFUngetC($1, $5, $3); } // Arg swap to file first
3825 | yD_UNPACKED_DIMENSIONS '(' exprOrDataType ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_UNPK_DIMENSIONS,$3); }
3826 | yD_UNSIGNED '(' expr ')' { $$ = new AstUnsigned($1, $3); }
3827 | yD_URANDOM '(' expr ')' { $$ = new AstRand($1, $3, true); }
3828 | yD_URANDOM parenE { $$ = new AstRand($1, nullptr, true); }
3829 | yD_URANDOM_RANGE '(' expr ')' { $$ = new AstURandomRange($1, $3, new AstConst($1, 0)); }
3830 | yD_URANDOM_RANGE '(' expr ',' expr ')' { $$ = new AstURandomRange($1, $3, $5); }
3831 | yD_VALUEPLUSARGS '(' expr ',' expr ')' { $$ = new AstValuePlusArgs($1, $3, $5); }
3832 ;
3833
3834 elaboration_system_task<nodep>: // IEEE: elaboration_system_task (1800-2009)
3835 // // TODO: These currently just make initial statements, should instead give runtime error
3836 elaboration_system_task_guts ';' { $$ = new AstInitial($<fl>1, $1); }
3837 ;
3838
3839 elaboration_system_task_guts<nodep>: // IEEE: part of elaboration_system_task (1800-2009)
3840 // // $fatal first argument is exit number, must be constant
3841 yD_INFO parenE { $$ = new AstElabDisplay($1, AstDisplayType::DT_INFO, nullptr); }
3842 | yD_INFO '(' exprList ')' { $$ = new AstElabDisplay($1, AstDisplayType::DT_INFO, $3); }
3843 | yD_WARNING parenE { $$ = new AstElabDisplay($1, AstDisplayType::DT_WARNING, nullptr); }
3844 | yD_WARNING '(' exprList ')' { $$ = new AstElabDisplay($1, AstDisplayType::DT_WARNING, $3); }
3845 | yD_ERROR parenE { $$ = new AstElabDisplay($1, AstDisplayType::DT_ERROR, nullptr); }
3846 | yD_ERROR '(' exprList ')' { $$ = new AstElabDisplay($1, AstDisplayType::DT_ERROR, $3); }
3847 | yD_FATAL parenE { $$ = new AstElabDisplay($1, AstDisplayType::DT_FATAL, nullptr); }
3848 | yD_FATAL '(' expr ')' { $$ = new AstElabDisplay($1, AstDisplayType::DT_FATAL, nullptr); DEL($3); }
3849 | yD_FATAL '(' expr ',' exprListE ')' { $$ = new AstElabDisplay($1, AstDisplayType::DT_FATAL, $5); DEL($3); }
3850 ;
3851
3852 //UNSUPproperty_actual_arg<nodep>: // ==IEEE: property_actual_arg
3853 //UNSUP // // IEEE: property_expr
3854 //UNSUP // // IEEE: sequence_actual_arg
3855 //UNSUP pev_expr { $$ = $1; }
3856 //UNSUP // // IEEE: sequence_expr
3857 //UNSUP // // property_expr already includes sequence_expr
3858 //UNSUP ;
3859
3860 exprOrDataType<nodep>: // expr | data_type: combined to prevent conflicts
3861 expr { $$ = $1; }
3862 // // data_type includes id that overlaps expr, so special flavor
3863 | data_type { $$ = $1; }
3864 // // not in spec, but needed for $past(sig,1,,@(posedge clk))
3865 //UNSUP event_control { }
3866 ;
3867
3868 //UNSUPexprOrDataTypeOrMinTypMax<nodep>: // exprOrDataType or mintypmax_expression
3869 //UNSUP expr { $$ = $1; }
3870 //UNSUP | expr ':' expr ':' expr { $$ = $3; }
3871 //UNSUP // // data_type includes id that overlaps expr, so special flavor
3872 //UNSUP | data_type { $$ = $1; }
3873 //UNSUP // // not in spec, but needed for $past(sig,1,,@(posedge clk))
3874 //UNSUP | event_control { $$ = $1; }
3875 //UNSUP ;
3876
3877 //UNSUPexprOrDataTypeList<nodep>:
3878 //UNSUP exprOrDataType { $$ = $1; }
3879 //UNSUP | exprOrDataTypeList ',' exprOrDataType { $$ = AstNode::addNextNull($1, $3); }
3880 //UNSUP ;
3881
3882 list_of_argumentsE<nodep>: // IEEE: [list_of_arguments]
3883 argsDottedList { $$ = $1; }
3884 | argsExprListE
3885 { if (VN_IS($1, Arg) && VN_CAST($1, Arg)->emptyConnectNoNext()) {
3886 $1->deleteTree(); $$ = nullptr; // Mis-created when have 'func()'
3887 } else { $$ = $1; } }
3888 | argsExprListE ',' argsDottedList { $$ = $1->addNextNull($3); }
3889 ;
3890
3891 task_declaration<nodeFTaskp>: // ==IEEE: task_declaration
3892 yTASK lifetimeE taskId tfGuts yENDTASK endLabelE
3893 { $$ = $3; $$->addStmtsp($4); SYMP->popScope($$);
3894 $$->lifetime($2);
3895 GRAMMARP->endLabel($<fl>6,$$,$6); }
3896 ;
3897
3898 task_prototype<nodeFTaskp>: // ==IEEE: task_prototype
3899 yTASK taskId '(' tf_port_listE ')'
3900 { $$ = $2; $$->addStmtsp($4); $$->prototype(true); SYMP->popScope($$); }
3901 | yTASK taskId
3902 { $$ = $2; $$->prototype(true); SYMP->popScope($$); }
3903 ;
3904
3905 function_declaration<nodeFTaskp>: // IEEE: function_declaration + function_body_declaration
3906 yFUNCTION lifetimeE funcId funcIsolateE tfGuts yENDFUNCTION endLabelE
3907 { $$ = $3; $3->attrIsolateAssign($4); $$->addStmtsp($5);
3908 $$->lifetime($2);
3909 SYMP->popScope($$);
3910 GRAMMARP->endLabel($<fl>7,$$,$7); }
3911 | yFUNCTION lifetimeE funcIdNew funcIsolateE tfGuts yENDFUNCTION endLabelE
3912 { $$ = $3; $3->attrIsolateAssign($4); $$->addStmtsp($5);
3913 $$->lifetime($2);
3914 SYMP->popScope($$);
3915 GRAMMARP->endLabel($<fl>7,$$,$7); }
3916 ;
3917
3918 function_prototype<nodeFTaskp>: // IEEE: function_prototype
3919 yFUNCTION funcId '(' tf_port_listE ')'
3920 { $$ = $2; $$->addStmtsp($4); $$->prototype(true); SYMP->popScope($$); }
3921 | yFUNCTION funcId
3922 { $$ = $2; $$->prototype(true); SYMP->popScope($$); }
3923 ;
3924
3925 class_constructor_prototype<nodeFTaskp>: // ==IEEE: class_constructor_prototype
3926 yFUNCTION funcIdNew '(' tf_port_listE ')' ';'
3927 { $$ = $2; $$->addStmtsp($4); $$->prototype(true); SYMP->popScope($$); }
3928 | yFUNCTION funcIdNew ';'
3929 { $$ = $2; $$->prototype(true); SYMP->popScope($$); }
3930 ;
3931
3932 funcIsolateE<cint>:
3933 /* empty */ { $$ = 0; }
3934 | yVL_ISOLATE_ASSIGNMENTS { $$ = 1; }
3935 ;
3936
3937 method_prototype<nodeFTaskp>:
3938 task_prototype { $$ = $1; }
3939 | function_prototype { $$ = $1; }
3940 ;
3941
3942 lifetimeE<lifetime>: // IEEE: [lifetime]
3943 /* empty */ { $$ = VLifetime::NONE; }
3944 | lifetime { $$ = $1; }
3945 ;
3946
3947 lifetime<lifetime>: // ==IEEE: lifetime
3948 // // Note lifetime used by members is instead under memberQual
3949 ySTATIC__ETC { $$ = VLifetime::STATIC; }
3950 | yAUTOMATIC { $$ = VLifetime::AUTOMATIC; }
3951 ;
3952
3953 taskId<nodeFTaskp>:
3954 id
3955 { $$ = new AstTask($<fl>$, *$1, nullptr);
3956 SYMP->pushNewUnderNodeOrCurrent($$, nullptr); }
3957 //
3958 | id/*interface_identifier*/ '.' id
3959 { $$ = new AstTask($<fl>$, *$3, nullptr);
3960 BBUNSUP($2, "Unsupported: Out of block function declaration");
3961 SYMP->pushNewUnderNodeOrCurrent($$, nullptr); }
3962 //
3963 | packageClassScope id
3964 { $$ = new AstTask($<fl>$, *$2, nullptr);
3965 $$->classOrPackagep($1);
3966 SYMP->pushNewUnderNodeOrCurrent($$, $<scp>1); }
3967 ;
3968
3969 funcId<nodeFTaskp>: // IEEE: function_data_type_or_implicit + part of function_body_declaration
3970 // // IEEE: function_data_type_or_implicit must be expanded here to prevent conflict
3971 // // function_data_type expanded here to prevent conflicts with implicit_type:empty vs data_type:ID
3972 /**/ fIdScoped
3973 { $$ = $1;
3974 $$->addFvarp(new AstBasicDType($<fl>1, LOGIC_IMPLICIT));
3975 SYMP->pushNewUnderNodeOrCurrent($$, $<scp>1); }
3976 | signingE rangeList fIdScoped
3977 { $$ = $3;
3978 $$->addFvarp(GRAMMARP->addRange(new AstBasicDType($<fl>3, LOGIC_IMPLICIT, $1), $2,true));
3979 SYMP->pushNewUnderNodeOrCurrent($$, $<scp>3); }
3980 | signing fIdScoped
3981 { $$ = $2;
3982 $$->addFvarp(new AstBasicDType($<fl>2, LOGIC_IMPLICIT, $1));
3983 SYMP->pushNewUnderNodeOrCurrent($$, $<scp>2); }
3984 | data_type fIdScoped
3985 { $$ = $2;
3986 $$->addFvarp($1);
3987 SYMP->pushNewUnderNodeOrCurrent($$, $<scp>2); }
3988 // // To verilator tasks are the same as void functions (we separately detect time passing)
3989 | yVOID taskId
3990 { $$ = $2; }
3991 ;
3992
3993 funcIdNew<nodeFTaskp>: // IEEE: from class_constructor_declaration
3994 yNEW__ETC
3995 { $$ = new AstFunc($<fl>1, "new", nullptr, nullptr);
3996 $$->isConstructor(true);
3997 SYMP->pushNewUnder($$, nullptr); }
3998 | yNEW__PAREN
3999 { $$ = new AstFunc($<fl>1, "new", nullptr, nullptr);
4000 $$->isConstructor(true);
4001 SYMP->pushNewUnder($$, nullptr); }
4002 | packageClassScopeNoId yNEW__PAREN
4003 { $$ = new AstFunc($<fl>2, "new", nullptr, nullptr);
4004 $$->classOrPackagep($1);
4005 $$->isConstructor(true);
4006 SYMP->pushNewUnderNodeOrCurrent($$, $<scp>1); }
4007 ;
4008
4009 fIdScoped<funcp>: // IEEE: part of function_body_declaration/task_body_declaration
4010 // // IEEE: [ interface_identifier '.' | class_scope ] function_identifier
4011 id
4012 { $<fl>$ = $<fl>1;
4013 $<scp>$ = nullptr;
4014 $$ = new AstFunc($<fl>$, *$1, nullptr, nullptr); }
4015 //
4016 | id/*interface_identifier*/ '.' id
4017 { $<fl>$ = $<fl>1;
4018 $<scp>$ = nullptr;
4019 $$ = new AstFunc($<fl>$, *$1, nullptr, nullptr);
4020 BBUNSUP($2, "Unsupported: Out of block function declaration"); }
4021 //
4022 | packageClassScope id
4023 { $<fl>$ = $<fl>1;
4024 $<scp>$ = $<scp>1;
4025 $$ = new AstFunc($<fl>$, *$2, nullptr, nullptr);
4026 $$->classOrPackagep($1); }
4027 ;
4028
4029 tfGuts<nodep>:
4030 '(' tf_port_listE ')' ';' tfBodyE { $$ = $2->addNextNull($5); }
4031 | ';' tfBodyE { $$ = $2; }
4032 ;
4033
4034 tfBodyE<nodep>: // IEEE: part of function_body_declaration/task_body_declaration
4035 /* empty */ { $$ = nullptr; }
4036 | tf_item_declarationList { $$ = $1; }
4037 | tf_item_declarationList stmtList { $$ = $1->addNextNull($2); }
4038 | stmtList { $$ = $1; }
4039 ;
4040
4041 tf_item_declarationList<nodep>:
4042 tf_item_declaration { $$ = $1; }
4043 | tf_item_declarationList tf_item_declaration { $$ = $1->addNextNull($2); }
4044 ;
4045
4046 tf_item_declaration<nodep>: // ==IEEE: tf_item_declaration
4047 block_item_declaration { $$ = $1; }
4048 | tf_port_declaration { $$ = $1; }
4049 | tf_item_declarationVerilator { $$ = $1; }
4050 ;
4051
4052 tf_item_declarationVerilator<nodep>: // Verilator extensions
4053 yVL_PUBLIC { $$ = new AstPragma($1,AstPragmaType::PUBLIC_TASK); v3Global.dpi(true); }
4054 | yVL_NO_INLINE_TASK { $$ = new AstPragma($1,AstPragmaType::NO_INLINE_TASK); }
4055 ;
4056
4057 tf_port_listE<nodep>: // IEEE: tf_port_list + empty
4058 // // Empty covered by tf_port_item
4059 /*empty*/
4060 /*mid*/ { VARRESET_LIST(UNKNOWN); VARIO(INPUT); }
4061 /*cont*/ tf_port_listList { $$ = $2; VARRESET_NONLIST(UNKNOWN); }
4062 ;
4063
4064 tf_port_listList<nodep>: // IEEE: part of tf_port_list
4065 tf_port_item { $$ = $1; }
4066 | tf_port_listList ',' tf_port_item { $$ = $1->addNextNull($3); }
4067 ;
4068
4069 tf_port_item<nodep>: // ==IEEE: tf_port_item
4070 // // We split tf_port_item into the type and assignment as don't know what follows a comma
4071 /* empty */ { $$ = nullptr; PINNUMINC(); } // For example a ",," port
4072 | tf_port_itemFront tf_port_itemAssignment { $$ = $2; }
4073 | tf_port_itemAssignment { $$ = $1; }
4074 ;
4075
4076 tf_port_itemFront: // IEEE: part of tf_port_item, which has the data type
4077 data_type { VARDTYPE($1); }
4078 | signingE rangeList { VARDTYPE(GRAMMARP->addRange(new AstBasicDType($2->fileline(), LOGIC_IMPLICIT, $1), $2, true)); }
4079 | signing { VARDTYPE(new AstBasicDType($<fl>1, LOGIC_IMPLICIT, $1)); }
4080 | yVAR data_type { VARDTYPE($2); }
4081 | yVAR implicit_typeE { VARDTYPE($2); }
4082 //
4083 | tf_port_itemDir /*implicit*/ { VARDTYPE(nullptr); /*default_nettype-see spec*/ }
4084 | tf_port_itemDir data_type { VARDTYPE($2); }
4085 | tf_port_itemDir signingE rangeList { VARDTYPE(GRAMMARP->addRange(new AstBasicDType($3->fileline(), LOGIC_IMPLICIT, $2),$3,true)); }
4086 | tf_port_itemDir signing { VARDTYPE(new AstBasicDType($<fl>2, LOGIC_IMPLICIT, $2)); }
4087 | tf_port_itemDir yVAR data_type { VARDTYPE($3); }
4088 | tf_port_itemDir yVAR implicit_typeE { VARDTYPE($3); }
4089 ;
4090
4091 tf_port_itemDir: // IEEE: part of tf_port_item, direction
4092 port_direction { } // port_direction sets VARIO
4093 ;
4094
4095 tf_port_itemAssignment<varp>: // IEEE: part of tf_port_item, which has assignment
4096 id variable_dimensionListE sigAttrListE exprEqE
4097 { $$ = VARDONEA($<fl>1, *$1, $2, $3); if ($4) $$->valuep($4); }
4098 ;
4099
4100 parenE:
4101 /* empty */ { }
4102 | '(' ')' { }
4103 ;
4104
4105 // method_call: // ==IEEE: method_call + method_call_body
4106 // // IEEE: method_call_root '.' method_identifier [ '(' list_of_arguments ')' ]
4107 // // "method_call_root '.' method_identifier" looks just like "expr '.' id"
4108 // // "method_call_root '.' method_identifier (...)" looks just like "expr '.' tf_call"
4109 // // IEEE: built_in_method_call
4110 // // method_call_root not needed, part of expr resolution
4111 // // What's left is below array_methodNoRoot
4112 array_methodNoRoot<nodeFTaskRefp>:
4113 yOR { $$ = new AstFuncRef($1, "or", nullptr); }
4114 | yAND { $$ = new AstFuncRef($1, "and", nullptr); }
4115 | yXOR { $$ = new AstFuncRef($1, "xor", nullptr); }
4116 | yUNIQUE { $$ = new AstFuncRef($1, "unique", nullptr); }
4117 ;
4118
4119 array_methodWith<nodep>:
4120 array_methodNoRoot parenE { $$ = $1; }
4121 | array_methodNoRoot parenE yWITH__PAREN '(' expr ')'
4122 { $$ = new AstWithParse($3, false, $1, $5); }
4123 | array_methodNoRoot '(' expr ')' yWITH__PAREN '(' expr ')'
4124 { $$ = new AstWithParse($5, false, $1, $7); $1->addPinsp(new AstArg($<fl>3, "", $3)); }
4125 ;
4126
4127 dpi_import_export<nodep>: // ==IEEE: dpi_import_export
4128 yIMPORT yaSTRING dpi_tf_import_propertyE dpi_importLabelE function_prototype dpi_tf_TraceInitE ';'
4129 { $$ = $5;
4130 if (*$4 != "") $5->cname(*$4);
4131 $5->dpiContext($3 == iprop_CONTEXT);
4132 $5->pure($3 == iprop_PURE);
4133 $5->dpiImport(true);
4134 $5->dpiTraceInit($6);
4135 GRAMMARP->checkDpiVer($1, *$2); v3Global.dpi(true);
4136 if ($$->prettyName()[0]=='$') SYMP->reinsert($$,nullptr,$$->prettyName()); // For $SysTF overriding
4137 SYMP->reinsert($$); }
4138 | yIMPORT yaSTRING dpi_tf_import_propertyE dpi_importLabelE task_prototype ';'
4139 { $$ = $5;
4140 if (*$4 != "") $5->cname(*$4);
4141 $5->dpiContext($3 == iprop_CONTEXT);
4142 $5->pure($3 == iprop_PURE);
4143 $5->dpiImport(true);
4144 $5->dpiTask(true);
4145 GRAMMARP->checkDpiVer($1, *$2); v3Global.dpi(true);
4146 if ($$->prettyName()[0]=='$') SYMP->reinsert($$,nullptr,$$->prettyName()); // For $SysTF overriding
4147 SYMP->reinsert($$); }
4148 | yEXPORT yaSTRING dpi_importLabelE yFUNCTION idAny ';'
4149 { $$ = new AstDpiExport($<fl>5, *$5, *$3);
4150 GRAMMARP->checkDpiVer($1, *$2); v3Global.dpi(true); }
4151 | yEXPORT yaSTRING dpi_importLabelE yTASK idAny ';'
4152 { $$ = new AstDpiExport($<fl>5, *$5, *$3);
4153 GRAMMARP->checkDpiVer($1, *$2); v3Global.dpi(true); }
4154 ;
4155
4156 dpi_importLabelE<strp>: // IEEE: part of dpi_import_export
4157 /* empty */ { static string s; $$ = &s; }
4158 | idAny/*c_identifier*/ '=' { $$ = $1; $<fl>$ = $<fl>1; }
4159 ;
4160
4161 dpi_tf_import_propertyE<iprop>: // IEEE: [ dpi_function_import_property + dpi_task_import_property ]
4162 /* empty */ { $$ = iprop_NONE; }
4163 | yCONTEXT { $$ = iprop_CONTEXT; }
4164 | yPURE { $$ = iprop_PURE; }
4165 ;
4166
4167 dpi_tf_TraceInitE<cbool>: // Verilator extension
4168 /* empty */ { $$ = false; }
4169 | yVL_TRACE_INIT_TASK { $$ = true; $<fl>$ = $<fl>1; }
4170 ;
4171
4172
4173 //************************************************
4174 // Expressions
4175 //
4176 // ~l~ means this is the (l)eft hand side of any operator
4177 // it will get replaced by "", "f" or "s"equence
4178 // ~r~ means this is a (r)ight hand later expansion in the same statement,
4179 // not under parenthesis for <= disambiguation
4180 // it will get replaced by "", or "f"
4181 // ~p~ means this is a (p)arenthetized expression
4182 // it will get replaced by "", or "s"equence
4183
4184 exprEqE<nodep>: // IEEE: optional '=' expression (part of param_assignment)
4185 // // constant_param_expression: '$' is in expr
4186 /*empty*/ { $$ = nullptr; }
4187 | '=' expr { $$ = $2; }
4188 ;
4189
4190 exprOrDataTypeEqE<nodep>: // IEEE: optional '=' expression (part of param_assignment)
4191 // // constant_param_expression: '$' is in expr
4192 /*empty*/ { $$ = nullptr; }
4193 | '=' exprOrDataType { $$ = $2; }
4194 ;
4195
4196 constExpr<nodep>:
4197 expr { $$ = $1; }
4198 ;
4199
4200 expr<nodep>: // IEEE: part of expression/constant_expression/primary
4201 // *SEE BELOW* // IEEE: primary/constant_primary
4202 //
4203 // // IEEE: unary_operator primary
4204 '+' ~r~expr %prec prUNARYARITH { $$ = $2; }
4205 | '-' ~r~expr %prec prUNARYARITH { $$ = new AstNegate ($1,$2); }
4206 | '!' ~r~expr %prec prNEGATION { $$ = new AstLogNot ($1,$2); }
4207 | '&' ~r~expr %prec prREDUCTION { $$ = new AstRedAnd ($1,$2); }
4208 | '~' ~r~expr %prec prNEGATION { $$ = new AstNot ($1,$2); }
4209 | '|' ~r~expr %prec prREDUCTION { $$ = new AstRedOr ($1,$2); }
4210 | '^' ~r~expr %prec prREDUCTION { $$ = new AstRedXor ($1,$2); }
4211 | yP_NAND ~r~expr %prec prREDUCTION { $$ = new AstLogNot($1, new AstRedAnd($1, $2)); }
4212 | yP_NOR ~r~expr %prec prREDUCTION { $$ = new AstLogNot($1, new AstRedOr($1, $2)); }
4213 | yP_XNOR ~r~expr %prec prREDUCTION { $$ = new AstLogNot($1, new AstRedXor($1, $2)); }
4214 //
4215 // // IEEE: inc_or_dec_expression
4216 | ~l~inc_or_dec_expression { $<fl>$ = $<fl>1; $$ = $1; }
4217 //
4218 // // IEEE: '(' operator_assignment ')'
4219 // // Need exprScope of variable_lvalue to prevent conflict
4220 //UNSUP '(' ~p~exprScope '=' expr ')' { UNSUP }
4221 //UNSUP '(' ~p~exprScope yP_PLUSEQ expr ')' { UNSUP }
4222 //UNSUP '(' ~p~exprScope yP_MINUSEQ expr ')' { UNSUP }
4223 //UNSUP '(' ~p~exprScope yP_TIMESEQ expr ')' { UNSUP }
4224 //UNSUP '(' ~p~exprScope yP_DIVEQ expr ')' { UNSUP }
4225 //UNSUP '(' ~p~exprScope yP_MODEQ expr ')' { UNSUP }
4226 //UNSUP '(' ~p~exprScope yP_ANDEQ expr ')' { UNSUP }
4227 //UNSUP '(' ~p~exprScope yP_OREQ expr ')' { UNSUP }
4228 //UNSUP '(' ~p~exprScope yP_XOREQ expr ')' { UNSUP }
4229 //UNSUP '(' ~p~exprScope yP_SLEFTEQ expr ')' { UNSUP }
4230 //UNSUP '(' ~p~exprScope yP_SRIGHTEQ expr ')' { UNSUP }
4231 //UNSUP '(' ~p~exprScope yP_SSRIGHTEQ expr ')' { UNSUP }
4232 //
4233 // // IEEE: expression binary_operator expression
4234 | ~l~expr '+' ~r~expr { $$ = new AstAdd ($2,$1,$3); }
4235 | ~l~expr '-' ~r~expr { $$ = new AstSub ($2,$1,$3); }
4236 | ~l~expr '*' ~r~expr { $$ = new AstMul ($2,$1,$3); }
4237 | ~l~expr '/' ~r~expr { $$ = new AstDiv ($2,$1,$3); }
4238 | ~l~expr '%' ~r~expr { $$ = new AstModDiv ($2,$1,$3); }
4239 | ~l~expr yP_EQUAL ~r~expr { $$ = new AstEq ($2,$1,$3); }
4240 | ~l~expr yP_NOTEQUAL ~r~expr { $$ = new AstNeq ($2,$1,$3); }
4241 | ~l~expr yP_CASEEQUAL ~r~expr { $$ = new AstEqCase ($2,$1,$3); }
4242 | ~l~expr yP_CASENOTEQUAL ~r~expr { $$ = new AstNeqCase ($2,$1,$3); }
4243 | ~l~expr yP_WILDEQUAL ~r~expr { $$ = new AstEqWild ($2,$1,$3); }
4244 | ~l~expr yP_WILDNOTEQUAL ~r~expr { $$ = new AstNeqWild ($2,$1,$3); }
4245 | ~l~expr yP_ANDAND ~r~expr { $$ = new AstLogAnd ($2,$1,$3); }
4246 | ~l~expr yP_OROR ~r~expr { $$ = new AstLogOr ($2,$1,$3); }
4247 | ~l~expr yP_POW ~r~expr { $$ = new AstPow ($2,$1,$3); }
4248 | ~l~expr '<' ~r~expr { $$ = new AstLt ($2,$1,$3); }
4249 | ~l~expr '>' ~r~expr { $$ = new AstGt ($2,$1,$3); }
4250 | ~l~expr yP_GTE ~r~expr { $$ = new AstGte ($2,$1,$3); }
4251 | ~l~expr '&' ~r~expr { $$ = new AstAnd ($2,$1,$3); }
4252 | ~l~expr '|' ~r~expr { $$ = new AstOr ($2,$1,$3); }
4253 | ~l~expr '^' ~r~expr { $$ = new AstXor ($2,$1,$3); }
4254 | ~l~expr yP_XNOR ~r~expr { $$ = new AstNot{$2, new AstXor{$2, $1, $3}}; }
4255 | ~l~expr yP_NOR ~r~expr { $$ = new AstNot{$2, new AstOr{$2, $1, $3}}; }
4256 | ~l~expr yP_NAND ~r~expr { $$ = new AstNot{$2, new AstAnd{$2, $1, $3}}; }
4257 | ~l~expr yP_SLEFT ~r~expr { $$ = new AstShiftL ($2,$1,$3); }
4258 | ~l~expr yP_SRIGHT ~r~expr { $$ = new AstShiftR ($2,$1,$3); }
4259 | ~l~expr yP_SSRIGHT ~r~expr { $$ = new AstShiftRS ($2,$1,$3); }
4260 | ~l~expr yP_LTMINUSGT ~r~expr { $$ = new AstLogEq ($2,$1,$3); }
4261 //
4262 // // IEEE: expr yP_MINUSGT expr (1800-2009)
4263 // // Conflicts with constraint_expression:"expr yP_MINUSGT constraint_set"
4264 // // To duplicating expr for constraints, just allow the more general form
4265 // // Later Ast processing must ignore constraint terms where inappropriate
4266 //UNSUP ~l~expr yP_MINUSGT constraint_set { $<fl>$ = $<fl>1; $$ = $1 + $2 + $3; }
4267 //UNSUP remove line below
4268 | ~l~expr yP_MINUSGT ~r~expr { $$ = new AstLogIf($2, $1, $3); }
4269 //
4270 // // <= is special, as we need to disambiguate it with <= assignment
4271 // // We copy all of expr to fexpr and rename this token to a fake one.
4272 | ~l~expr yP_LTE~f__IGNORE~ ~r~expr { $$ = new AstLte($2, $1, $3); }
4273 //
4274 // // IEEE: conditional_expression
4275 | ~l~expr '?' ~r~expr ':' ~r~expr { $$ = new AstCond($2,$1,$3,$5); }
4276 //
4277 // // IEEE: inside_expression
4278 | ~l~expr yINSIDE '{' open_range_list '}' { $$ = new AstInside($2,$1,$4); }
4279 //
4280 // // IEEE: tagged_union_expression
4281 //UNSUP yTAGGED id/*member*/ %prec prTAGGED { UNSUP }
4282 //UNSUP yTAGGED id/*member*/ %prec prTAGGED expr { UNSUP }
4283 //
4284 //======================// IEEE: primary/constant_primary
4285 //
4286 // // IEEE: primary_literal (minus string, which is handled specially)
4287 | yaINTNUM { $$ = new AstConst($<fl>1,*$1); }
4288 | yaFLOATNUM { $$ = new AstConst($<fl>1,AstConst::RealDouble(),$1); }
4289 | timeNumAdjusted { $$ = $1; }
4290 | strAsInt~noStr__IGNORE~ { $$ = $1; }
4291 //
4292 // // IEEE: "... hierarchical_identifier select" see below
4293 //
4294 // // IEEE: empty_queue (IEEE 1800-2017 empty_unpacked_array_concatenation)
4295 | '{' '}' { $$ = new AstEmptyQueue($1); }
4296 //
4297 // // IEEE: concatenation/constant_concatenation
4298 // // Part of exprOkLvalue below
4299 //
4300 // // IEEE: multiple_concatenation/constant_multiple_concatenation
4301 | '{' constExpr '{' cateList '}' '}' { $$ = new AstReplicate($3, $4, $2); }
4302 // // UNSUP some other rules above
4303 //
4304 | function_subroutine_callNoMethod { $$ = $1; }
4305 // // method_call
4306 | ~l~expr '.' function_subroutine_callNoMethod { $$ = new AstDot($2, false, $1, $3); }
4307 // // method_call:array_method requires a '.'
4308 | ~l~expr '.' array_methodWith { $$ = new AstDot($2, false, $1, $3); }
4309 //
4310 // // IEEE: let_expression
4311 // // see funcRef
4312 //
4313 // // IEEE: '(' mintypmax_expression ')'
4314 | ~noPar__IGNORE~'(' expr ')' { $$ = $2; }
4315 | ~noPar__IGNORE~'(' expr ':' expr ':' expr ')'
4316 { $$ = $2; BBUNSUP($1, "Unsupported: min typ max expressions"); }
4317 // // PSL rule
4318 | '_' '(' expr ')' { $$ = $3; } // Arbitrary Verilog inside PSL
4319 //
4320 // // IEEE: cast/constant_cast
4321 // // expanded from casting_type
4322 | simple_type yP_TICK '(' expr ')' { $$ = new AstCast($1->fileline(), $4, VFlagChildDType{}, $1); }
4323 | yTYPE '(' exprOrDataType ')' yP_TICK '(' expr ')'
4324 { $$ = new AstCast($1, $7, VFlagChildDType(), new AstRefDType($1, AstRefDType::FlagTypeOfExpr(), $3)); }
4325 | ySIGNED yP_TICK '(' expr ')' { $$ = new AstSigned($1, $4); }
4326 | yUNSIGNED yP_TICK '(' expr ')' { $$ = new AstUnsigned($1, $4); }
4327 | ySTRING yP_TICK '(' expr ')' { $$ = new AstCvtPackString($1, $4); }
4328 | yCONST__ETC yP_TICK '(' expr ')' { $$ = $4; } // Not linting const presently
4329 // // Spec only allows primary with addition of a type reference
4330 // // We'll be more general, and later assert LHS was a type.
4331 | ~l~expr yP_TICK '(' expr ')' { $$ = new AstCastParse($2, $4, $1); }
4332 //
4333 // // IEEE: assignment_pattern_expression
4334 // // IEEE: streaming_concatenation
4335 // // See exprOkLvalue
4336 //
4337 // // IEEE: sequence_method_call
4338 // // Indistinguishable from function_subroutine_call:method_call
4339 //
4340 | '$' { $$ = new AstUnbounded($<fl>1); }
4341 | yNULL { $$ = new AstConst($1, AstConst::Null{}); }
4342 // // IEEE: yTHIS
4343 // // See exprScope
4344 //
4345 //----------------------
4346 //
4347 // // Part of expr that may also be used as lvalue
4348 | ~l~exprOkLvalue { $$ = $1; }
4349 //
4350 //----------------------
4351 //
4352 // // IEEE: cond_predicate - here to avoid reduce problems
4353 // // Note expr includes cond_pattern
4354 | ~l~expr yP_ANDANDAND ~r~expr { $$ = new AstConst($2, AstConst::BitFalse());
4355 BBUNSUP($<fl>2, "Unsupported: &&& expression"); }
4356 //
4357 // // IEEE: cond_pattern - here to avoid reduce problems
4358 // // "expr yMATCHES pattern"
4359 // // IEEE: pattern - expanded here to avoid conflicts
4360 //UNSUP ~l~expr yMATCHES patternNoExpr { UNSUP }
4361 //UNSUP ~l~expr yMATCHES ~r~expr { UNSUP }
4362 //
4363 // // IEEE: expression_or_dist - here to avoid reduce problems
4364 // // "expr yDIST '{' dist_list '}'"
4365 | ~l~expr yDIST '{' dist_list '}' { $$ = $1; BBUNSUP($2, "Unsupported: dist"); }
4366 ;
4367
4368 fexpr<nodep>: // For use as first part of statement (disambiguates <=)
4369 BISONPRE_COPY(expr,{s/~l~/f/g; s/~r~/f/g; s/~f__IGNORE~/__IGNORE/g;}) // {copied}
4370 ;
4371
4372 //UNSUPev_expr<nodep>: // IEEE: event_expression
4373 //UNSUP // // for yOR/, see event_expression
4374 //UNSUP //
4375 //UNSUP // // IEEE: [ edge_identifier ] expression [ yIFF expression ]
4376 //UNSUP // // expr alone see below
4377 //UNSUP senitemEdge { $$ = $1; }
4378 //UNSUP | ev_expr yIFF expr { }
4379 //UNSUP //
4380 //UNSUP // // IEEE: sequence_instance [ yIFF expression ]
4381 //UNSUP // // seq_inst is in expr, so matches senitem rule above
4382 //UNSUP //
4383 //UNSUP // // IEEE: event_expression yOR event_expression
4384 //UNSUP | ev_expr yOR ev_expr { }
4385 //UNSUP // // IEEE: event_expression ',' event_expression
4386 //UNSUP // // See real event_expression rule
4387 //UNSUP //
4388 //UNSUP //---------------------
4389 //UNSUP // // IEEE: expr
4390 //UNSUP | BISONPRE_COPY(expr,{s/~l~/ev_/g; s/~r~/ev_/g; s/~p~/ev_/g; s/~noPar__IGNORE~/yP_PAR__IGNORE /g;}) // {copied}
4391 //UNSUP //
4392 //UNSUP // // IEEE: '(' event_expression ')'
4393 //UNSUP // // expr:'(' x ')' conflicts with event_expression:'(' event_expression ')'
4394 //UNSUP // // so we use a special expression class
4395 //UNSUP | '(' event_expression ')' { $<fl>$ = $<fl>1; $$ = "(...)"; }
4396 //UNSUP // // IEEE: From normal expr: '(' expr ':' expr ':' expr ')'
4397 //UNSUP // // But must avoid conflict
4398 //UNSUP | '(' event_expression ':' expr ':' expr ')' { $<fl>$ = $<fl>1; $$ = "(...)"; }
4399 //UNSUP ;
4400
4401 exprNoStr<nodep>: // expression with string removed
4402 BISONPRE_COPY(expr,{s/~noStr__IGNORE~/Ignore/g;}) // {copied}
4403 ;
4404
4405 exprOkLvalue<nodep>: // expression that's also OK to use as a variable_lvalue
4406 ~l~exprScope { $$ = $1; }
4407 // // IEEE: concatenation/constant_concatenation
4408 // // Replicate(1) required as otherwise "{a}" would not be self-determined
4409 | '{' cateList '}' { $$ = new AstReplicate($1,$2,1); }
4410 | '{' cateList '}' '[' expr ']' { $$ = new AstSelBit($4, new AstReplicate($1,$2,1), $5); }
4411 | '{' cateList '}' '[' constExpr ':' constExpr ']'
4412 { $$ = new AstSelExtract($4, new AstReplicate($1,$2,1), $5, $7); }
4413 | '{' cateList '}' '[' expr yP_PLUSCOLON constExpr ']'
4414 { $$ = new AstSelPlus($4, new AstReplicate($1,$2,1), $5, $7); }
4415 | '{' cateList '}' '[' expr yP_MINUSCOLON constExpr ']'
4416 { $$ = new AstSelMinus($4, new AstReplicate($1,$2,1), $5, $7); }
4417 // // IEEE: assignment_pattern_expression
4418 // // IEEE: [ assignment_pattern_expression_type ] == [ ps_type_id /ps_paremeter_id/data_type]
4419 // // We allow more here than the spec requires
4420 //UNSUP ~l~exprScope assignment_pattern { UNSUP }
4421 | data_type assignment_pattern { $$ = $2; if ($2) $2->childDTypep($1); }
4422 | assignment_pattern { $$ = $1; }
4423 //
4424 | streaming_concatenation { $$ = $1; }
4425 ;
4426
4427 fexprOkLvalue<nodep>: // exprOkLValue, For use as first part of statement (disambiguates <=)
4428 BISONPRE_COPY(exprOkLvalue,{s/~l~/f/g}) // {copied}
4429 ;
4430
4431 //UNSUPsexprOkLvalue<nodep>: // exprOkLValue, For use by sequence_expr
4432 //UNSUP BISONPRE_COPY(exprOkLvalue,{s/~l~/s/g}) // {copied}
4433 //UNSUP ;
4434
4435 //UNSUPpexprOkLvalue<nodep>: // exprOkLValue, For use by property_expr
4436 //UNSUP BISONPRE_COPY(exprOkLvalue,{s/~l~/p/g}) // {copied}
4437 //UNSUP ;
4438
4439 //UNSUPev_exprOkLvalue<nodep>: // exprOkLValue, For use by ev_expr
4440 //UNSUP BISONPRE_COPY(exprOkLvalue,{s/~l~/ev_/g}) // {copied}
4441 //UNSUP ;
4442
4443 //UNSUPpev_exprOkLvalue<nodep>: // exprOkLValue, For use by ev_expr
4444 //UNSUP BISONPRE_COPY(exprOkLvalue,{s/~l~/pev_/g}) // {copied}
4445 //UNSUP ;
4446
4447 fexprLvalue<nodep>: // For use as first part of statement (disambiguates <=)
4448 fexprOkLvalue { $<fl>$ = $<fl>1; $$ = $1; }
4449 ;
4450
4451 exprScope<nodep>: // scope and variable for use to inside an expression
4452 // // Here we've split method_call_root | implicit_class_handle | class_scope | package_scope
4453 // // from the object being called and let expr's "." deal with resolving it.
4454 // // (note method_call_root was simplified to require a primary in 1800-2009)
4455 //
4456 // // IEEE: [ implicit_class_handle . | class_scope | package_scope ] hierarchical_identifier select
4457 // // Or method_call_body without parenthesis
4458 // // See also varRefClassBit, which is the non-expr version of most of this
4459 yTHIS { $$ = new AstParseRef($<fl>1, VParseRefExp::PX_ROOT, "this"); }
4460 | yD_ROOT { $$ = new AstParseRef($<fl>1, VParseRefExp::PX_ROOT, "$root"); }
4461 | idArrayed { $$ = $1; }
4462 | packageClassScope idArrayed { $$ = AstDot::newIfPkg($2->fileline(), $1, $2); }
4463 | ~l~expr '.' idArrayed { $$ = new AstDot($<fl>2, false, $1, $3); }
4464 // // expr below must be a "yTHIS"
4465 | ~l~expr '.' ySUPER { $$ = $1; BBUNSUP($3, "Unsupported: super"); }
4466 // // Part of implicit_class_handle
4467 | ySUPER { $$ = new AstParseRef($<fl>1, VParseRefExp::PX_ROOT, "super"); }
4468 ;
4469
4470 fexprScope<nodep>: // exprScope, For use as first part of statement (disambiguates <=)
4471 BISONPRE_COPY(exprScope,{s/~l~/f/g}) // {copied}
4472 ;
4473
4474 //UNSUPsexprScope<nodep>: // exprScope, For use by sequence_expr
4475 //UNSUP BISONPRE_COPY(exprScope,{s/~l~/s/g}) // {copied}
4476 //UNSUP ;
4477
4478 //UNSUPpexprScope<nodep>: // exprScope, For use by property_expr
4479 //UNSUP BISONPRE_COPY(exprScope,{s/~l~/p/g}) // {copied}
4480 //UNSUP ;
4481
4482 //UNSUPev_exprScope<nodep>: // exprScope, For use by ev_expr
4483 //UNSUP BISONPRE_COPY(exprScope,{s/~l~/ev_/g}) // {copied}
4484 //UNSUP ;
4485
4486 //UNSUPpev_exprScope<nodep>: // exprScope, For use by ev_expr
4487 //UNSUP BISONPRE_COPY(exprScope,{s/~l~/pev_/g}) // {copied}
4488 //UNSUP ;
4489
4490 // PLI calls exclude "" as integers, they're strings
4491 // For $c("foo","bar") we want "bar" as a string, not a Verilog integer.
4492 exprStrText<nodep>:
4493 exprNoStr { $$ = $1; }
4494 | strAsText { $$ = $1; }
4495 ;
4496
4497 cStrList<nodep>:
4498 exprStrText { $$ = $1; }
4499 | exprStrText ',' cStrList { $$ = $1; $1->addNext($3); }
4500 ;
4501
4502 cateList<nodep>:
4503 // // Not just 'expr' to prevent conflict via stream_concOrExprOrType
4504 stream_expression { $$ = $1; }
4505 | cateList ',' stream_expression { $$ = new AstConcat($2,$1,$3); }
4506 ;
4507
4508 exprListE<nodep>:
4509 /* empty */ { $$ = nullptr; }
4510 | exprList { $$ = $1; }
4511 ;
4512
4513 exprList<nodep>:
4514 expr { $$ = $1; }
4515 | exprList ',' expr { $$ = $1; $1->addNext($3); }
4516 ;
4517
4518 exprDispList<nodep>: // exprList for within $display
4519 expr { $$ = $1; }
4520 | exprDispList ',' expr { $$ = $1; $1->addNext($3); }
4521 // // ,, creates a space in $display
4522 | exprDispList ',' /*empty*/
4523 { $$ = $1; $1->addNext(new AstConst($<fl>2, AstConst::VerilogStringLiteral(), " ")); }
4524 ;
4525
4526 vrdList<nodep>:
4527 idClassSel { $$ = $1; }
4528 | vrdList ',' idClassSel { $$ = $1; $1->addNext($3); }
4529 ;
4530
4531 commaVRDListE<nodep>:
4532 /* empty */ { $$ = nullptr; }
4533 | ',' vrdList { $$ = $2; }
4534 ;
4535
4536 argsExprList<nodep>: // IEEE: part of list_of_arguments (used where ,, isn't legal)
4537 expr { $$ = $1; }
4538 | argsExprList ',' expr { $$ = $1->addNext($3); }
4539 ;
4540
4541 argsExprListE<nodep>: // IEEE: part of list_of_arguments
4542 argsExprOneE { $$ = $1; }
4543 | argsExprListE ',' argsExprOneE { $$ = $1->addNext($3); }
4544 ;
4545
4546 //UNSUPpev_argsExprListE<nodep>: // IEEE: part of list_of_arguments - pev_expr at bottom
4547 //UNSUP pev_argsExprOneE { $$ = $1; }
4548 //UNSUP | pev_argsExprListE ',' pev_argsExprOneE { $$ = AstNode::addNextNull($1, $3); }
4549 //UNSUP ;
4550
4551 argsExprOneE<nodep>: // IEEE: part of list_of_arguments
4552 /*empty*/ { $$ = new AstArg(CRELINE(), "", nullptr); }
4553 | expr { $$ = new AstArg($1->fileline(), "", $1); }
4554 ;
4555
4556 //UNSUPpev_argsExprOneE<nodep>: // IEEE: part of list_of_arguments - pev_expr at bottom
4557 //UNSUP /*empty*/ { $$ = nullptr; } // ,, is legal in list_of_arguments
4558 //UNSUP | pev_expr { $$ = $1; }
4559 //UNSUP ;
4560
4561 argsDottedList<nodep>: // IEEE: part of list_of_arguments
4562 argsDotted { $$ = $1; }
4563 | argsDottedList ',' argsDotted { $$ = $1->addNextNull($3); }
4564 ;
4565
4566 //UNSUPpev_argsDottedList<nodep>: // IEEE: part of list_of_arguments - pev_expr at bottom
4567 //UNSUP pev_argsDotted { $$ = $1; }
4568 //UNSUP | pev_argsDottedList ',' pev_argsDotted { $$ = AstNode::addNextNull($1, $3); }
4569 //UNSUP ;
4570
4571 argsDotted<nodep>: // IEEE: part of list_of_arguments
4572 '.' idAny '(' ')' { $$ = new AstArg($<fl>2, *$2, nullptr); }
4573 | '.' idAny '(' expr ')' { $$ = new AstArg($<fl>2, *$2, $4); }
4574 ;
4575
4576 //UNSUPpev_argsDotted<nodep>: // IEEE: part of list_of_arguments - pev_expr at bottom
4577 //UNSUP '.' idAny '(' ')' { $$ = new AstArg($<fl>2, *$2, nullptr); }
4578 //UNSUP | '.' idAny '(' pev_expr ')' { $$ = new AstArg($<fl>2, *$2, $4); }
4579 //UNSUP ;
4580
4581 streaming_concatenation<nodep>: // ==IEEE: streaming_concatenation
4582 // // Need to disambiguate {<< expr-{ ... expr-} stream_concat }
4583 // // From {<< stream-{ ... stream-} }
4584 // // Likewise simple_type's idScoped from constExpr's idScope
4585 // // Thus we allow always any two operations. Sorry
4586 // // IEEE: "'{' yP_SL/R stream_concatenation '}'"
4587 // // IEEE: "'{' yP_SL/R simple_type stream_concatenation '}'"
4588 // // IEEE: "'{' yP_SL/R constExpr stream_concatenation '}'"
4589 '{' yP_SLEFT stream_concatenation '}'
4590 { $$ = new AstStreamL($2, $3, new AstConst($2, 1)); }
4591 | '{' yP_SRIGHT stream_concatenation '}'
4592 { $$ = new AstStreamR($2, $3, new AstConst($2, 1)); }
4593 | '{' yP_SLEFT stream_expressionOrDataType stream_concatenation '}'
4594 { $$ = new AstStreamL($2, $4, $3); }
4595 | '{' yP_SRIGHT stream_expressionOrDataType stream_concatenation '}'
4596 { $$ = new AstStreamR($2, $4, $3); }
4597 ;
4598
4599 stream_concatenation<nodep>: // ==IEEE: stream_concatenation
4600 // // '{' { stream_expression } '}'
4601 '{' cateList '}' { $$ = $2; }
4602 ;
4603
4604 stream_expression<nodep>: // ==IEEE: stream_expression
4605 // // IEEE: array_range_expression expanded below
4606 expr { $$ = $1; }
4607 //UNSUP expr yWITH__BRA '[' expr ']' { UNSUP }
4608 //UNSUP expr yWITH__BRA '[' expr ':' expr ']' { UNSUP }
4609 //UNSUP expr yWITH__BRA '[' expr yP_PLUSCOLON expr ']' { UNSUP }
4610 //UNSUP expr yWITH__BRA '[' expr yP_MINUSCOLON expr ']' { UNSUP }
4611 ;
4612
4613 stream_expressionOrDataType<nodep>: // IEEE: from streaming_concatenation
4614 exprOrDataType { $$ = $1; }
4615 //UNSUP expr yWITH__BRA '[' expr ']' { UNSUP }
4616 //UNSUP expr yWITH__BRA '[' expr ':' expr ']' { UNSUP }
4617 //UNSUP expr yWITH__BRA '[' expr yP_PLUSCOLON expr ']' { UNSUP }
4618 //UNSUP expr yWITH__BRA '[' expr yP_MINUSCOLON expr ']' { UNSUP }
4619 ;
4620
4621 //************************************************
4622 // Gate declarations
4623
4624 gateDecl<nodep>:
4625 yBUF delayE gateBufList ';' { $$ = $3; }
4626 | yBUFIF0 delayE gateBufif0List ';' { $$ = $3; }
4627 | yBUFIF1 delayE gateBufif1List ';' { $$ = $3; }
4628 | yNOT delayE gateNotList ';' { $$ = $3; }
4629 | yNOTIF0 delayE gateNotif0List ';' { $$ = $3; }
4630 | yNOTIF1 delayE gateNotif1List ';' { $$ = $3; }
4631 | yAND delayE gateAndList ';' { $$ = $3; }
4632 | yNAND delayE gateNandList ';' { $$ = $3; }
4633 | yOR delayE gateOrList ';' { $$ = $3; }
4634 | yNOR delayE gateNorList ';' { $$ = $3; }
4635 | yXOR delayE gateXorList ';' { $$ = $3; }
4636 | yXNOR delayE gateXnorList ';' { $$ = $3; }
4637 | yPULLUP delayE gatePullupList ';' { $$ = $3; }
4638 | yPULLDOWN delayE gatePulldownList ';' { $$ = $3; }
4639 | yNMOS delayE gateBufif1List ';' { $$ = $3; } // ~=bufif1, as don't have strengths yet
4640 | yPMOS delayE gateBufif0List ';' { $$ = $3; } // ~=bufif0, as don't have strengths yet
4641 //
4642 | yTRAN delayE gateUnsupList ';' { $$ = $3; GATEUNSUP($3,"tran"); } // Unsupported
4643 | yRCMOS delayE gateUnsupList ';' { $$ = $3; GATEUNSUP($3,"rcmos"); } // Unsupported
4644 | yCMOS delayE gateUnsupList ';' { $$ = $3; GATEUNSUP($3,"cmos"); } // Unsupported
4645 | yRNMOS delayE gateUnsupList ';' { $$ = $3; GATEUNSUP($3,"rmos"); } // Unsupported
4646 | yRPMOS delayE gateUnsupList ';' { $$ = $3; GATEUNSUP($3,"pmos"); } // Unsupported
4647 | yRTRAN delayE gateUnsupList ';' { $$ = $3; GATEUNSUP($3,"rtran"); } // Unsupported
4648 | yRTRANIF0 delayE gateUnsupList ';' { $$ = $3; GATEUNSUP($3,"rtranif0"); } // Unsupported
4649 | yRTRANIF1 delayE gateUnsupList ';' { $$ = $3; GATEUNSUP($3,"rtranif1"); } // Unsupported
4650 | yTRANIF0 delayE gateUnsupList ';' { $$ = $3; GATEUNSUP($3,"tranif0"); } // Unsupported
4651 | yTRANIF1 delayE gateUnsupList ';' { $$ = $3; GATEUNSUP($3,"tranif1"); } // Unsupported
4652 ;
4653
4654 gateBufList<nodep>:
4655 gateBuf { $$ = $1; }
4656 | gateBufList ',' gateBuf { $$ = $1->addNext($3); }
4657 ;
4658 gateBufif0List<nodep>:
4659 gateBufif0 { $$ = $1; }
4660 | gateBufif0List ',' gateBufif0 { $$ = $1->addNext($3); }
4661 ;
4662 gateBufif1List<nodep>:
4663 gateBufif1 { $$ = $1; }
4664 | gateBufif1List ',' gateBufif1 { $$ = $1->addNext($3); }
4665 ;
4666 gateNotList<nodep>:
4667 gateNot { $$ = $1; }
4668 | gateNotList ',' gateNot { $$ = $1->addNext($3); }
4669 ;
4670 gateNotif0List<nodep>:
4671 gateNotif0 { $$ = $1; }
4672 | gateNotif0List ',' gateNotif0 { $$ = $1->addNext($3); }
4673 ;
4674 gateNotif1List<nodep>:
4675 gateNotif1 { $$ = $1; }
4676 | gateNotif1List ',' gateNotif1 { $$ = $1->addNext($3); }
4677 ;
4678 gateAndList<nodep>:
4679 gateAnd { $$ = $1; }
4680 | gateAndList ',' gateAnd { $$ = $1->addNext($3); }
4681 ;
4682 gateNandList<nodep>:
4683 gateNand { $$ = $1; }
4684 | gateNandList ',' gateNand { $$ = $1->addNext($3); }
4685 ;
4686 gateOrList<nodep>:
4687 gateOr { $$ = $1; }
4688 | gateOrList ',' gateOr { $$ = $1->addNext($3); }
4689 ;
4690 gateNorList<nodep>:
4691 gateNor { $$ = $1; }
4692 | gateNorList ',' gateNor { $$ = $1->addNext($3); }
4693 ;
4694 gateXorList<nodep>:
4695 gateXor { $$ = $1; }
4696 | gateXorList ',' gateXor { $$ = $1->addNext($3); }
4697 ;
4698 gateXnorList<nodep>:
4699 gateXnor { $$ = $1; }
4700 | gateXnorList ',' gateXnor { $$ = $1->addNext($3); }
4701 ;
4702 gatePullupList<nodep>:
4703 gatePullup { $$ = $1; }
4704 | gatePullupList ',' gatePullup { $$ = $1->addNext($3); }
4705 ;
4706 gatePulldownList<nodep>:
4707 gatePulldown { $$ = $1; }
4708 | gatePulldownList ',' gatePulldown { $$ = $1->addNext($3); }
4709 ;
4710 gateUnsupList<nodep>:
4711 gateUnsup { $$ = $1; }
4712 | gateUnsupList ',' gateUnsup { $$ = $1->addNext($3); }
4713 ;
4714
4715 gateRangeE<nodep>:
4716 instRangeListE { $$ = $1; GATERANGE(GRAMMARP->scrubRange($1)); }
4717 ;
4718
4719 gateBuf<nodep>:
4720 gateFront variable_lvalue ',' gatePinExpr ')'
4721 { $$ = new AstAssignW($<fl>1, $2, $4); DEL($1); }
4722 // UNSUP // IEEE: Multiple output variable_lvalues
4723 // UNSUP // Causes conflict - need to take in variable_lvalue or a gatePinExpr
4724 ;
4725 gateBufif0<nodep>:
4726 gateFront variable_lvalue ',' gatePinExpr ',' gatePinExpr ')'
4727 { $$ = new AstAssignW($<fl>1, $2, new AstBufIf1($<fl>1, new AstNot($<fl>1, $6), $4)); DEL($1); }
4728 ;
4729 gateBufif1<nodep>:
4730 gateFront variable_lvalue ',' gatePinExpr ',' gatePinExpr ')'
4731 { $$ = new AstAssignW($<fl>1, $2, new AstBufIf1($<fl>1, $6, $4)); DEL($1); }
4732 ;
4733 gateNot<nodep>:
4734 gateFront variable_lvalue ',' gatePinExpr ')'
4735 { $$ = new AstAssignW($<fl>1, $2, new AstNot($<fl>1, $4)); DEL($1); }
4736 // UNSUP // IEEE: Multiple output variable_lvalues
4737 // UNSUP // Causes conflict - need to take in variable_lvalue or a gatePinExpr
4738 ;
4739 gateNotif0<nodep>:
4740 gateFront variable_lvalue ',' gatePinExpr ',' gatePinExpr ')'
4741 { $$ = new AstAssignW($<fl>1, $2, new AstBufIf1($<fl>1, new AstNot($<fl>1, $6),
4742 new AstNot($<fl>1, $4))); DEL($1); }
4743 ;
4744 gateNotif1<nodep>:
4745 gateFront variable_lvalue ',' gatePinExpr ',' gatePinExpr ')'
4746 { $$ = new AstAssignW($<fl>1, $2, new AstBufIf1($<fl>1, $6, new AstNot($<fl>1, $4))); DEL($1); }
4747 ;
4748 gateAnd<nodep>:
4749 gateFront variable_lvalue ',' gateAndPinList ')'
4750 { $$ = new AstAssignW($<fl>1, $2, $4); DEL($1); }
4751 ;
4752 gateNand<nodep>:
4753 gateFront variable_lvalue ',' gateAndPinList ')'
4754 { $$ = new AstAssignW($<fl>1, $2, new AstNot($<fl>1, $4)); DEL($1); }
4755 ;
4756 gateOr<nodep>:
4757 gateFront variable_lvalue ',' gateOrPinList ')'
4758 { $$ = new AstAssignW($<fl>1, $2, $4); DEL($1); }
4759 ;
4760 gateNor<nodep>:
4761 gateFront variable_lvalue ',' gateOrPinList ')'
4762 { $$ = new AstAssignW($<fl>1, $2, new AstNot($<fl>1, $4)); DEL($1); }
4763 ;
4764 gateXor<nodep>:
4765 gateFront variable_lvalue ',' gateXorPinList ')'
4766 { $$ = new AstAssignW($<fl>1, $2, $4); DEL($1); }
4767 ;
4768 gateXnor<nodep>:
4769 gateFront variable_lvalue ',' gateXorPinList ')'
4770 { $$ = new AstAssignW($<fl>1, $2, new AstNot($<fl>1, $4)); DEL($1); }
4771 ;
4772 gatePullup<nodep>:
4773 gateFront variable_lvalue ')' { $$ = new AstPull($<fl>1, $2, true); DEL($1); }
4774 ;
4775 gatePulldown<nodep>:
4776 gateFront variable_lvalue ')' { $$ = new AstPull($<fl>1, $2, false); DEL($1); }
4777 ;
4778 gateUnsup<nodep>:
4779 gateFront gateUnsupPinList ')' { $$ = new AstImplicit($<fl>1, $2); DEL($1); }
4780 ;
4781
4782 gateFront<nodep>:
4783 id/*gate*/ gateRangeE '(' { $$ = $2; $<fl>$ = $<fl>1; }
4784 | gateRangeE '(' { $$ = $1; $<fl>$ = $<fl>2; }
4785 ;
4786
4787 gateAndPinList<nodep>:
4788 gatePinExpr { $$ = $1; }
4789 | gateAndPinList ',' gatePinExpr { $$ = new AstAnd($2,$1,$3); }
4790 ;
4791 gateOrPinList<nodep>:
4792 gatePinExpr { $$ = $1; }
4793 | gateOrPinList ',' gatePinExpr { $$ = new AstOr($2,$1,$3); }
4794 ;
4795 gateXorPinList<nodep>:
4796 gatePinExpr { $$ = $1; }
4797 | gateXorPinList ',' gatePinExpr { $$ = new AstXor($2,$1,$3); }
4798 ;
4799 gateUnsupPinList<nodep>:
4800 gatePinExpr { $$ = $1; }
4801 | gateUnsupPinList ',' gatePinExpr { $$ = $1->addNext($3); }
4802 ;
4803
4804 gatePinExpr<nodep>:
4805 expr { $$ = GRAMMARP->createGatePin($1); }
4806 ;
4807
4808 // This list is also hardcoded in VParseLex.l
4809 strength: // IEEE: strength0+strength1 - plus HIGHZ/SMALL/MEDIUM/LARGE
4810 ygenSTRENGTH { BBUNSUP($1, "Unsupported: Verilog 1995 strength specifiers"); }
4811 | ySUPPLY0 { BBUNSUP($1, "Unsupported: Verilog 1995 strength specifiers"); }
4812 | ySUPPLY1 { BBUNSUP($1, "Unsupported: Verilog 1995 strength specifiers"); }
4813 ;
4814
4815 strengthSpecE: // IEEE: drive_strength + pullup_strength + pulldown_strength + charge_strength - plus empty
4816 /* empty */ { }
4817 | strengthSpec { }
4818 ;
4819
4820 strengthSpec: // IEEE: drive_strength + pullup_strength + pulldown_strength + charge_strength - plus empty
4821 yP_PAR__STRENGTH strength ')' { }
4822 | yP_PAR__STRENGTH strength ',' strength ')' { }
4823 ;
4824
4825 //************************************************
4826 // Tables
4827
4828 combinational_body<nodep>: // IEEE: combinational_body + sequential_body
4829 yTABLE tableEntryList yENDTABLE { $$ = new AstUdpTable($1,$2); }
4830 ;
4831
4832 tableEntryList<nodep>: // IEEE: { combinational_entry | sequential_entry }
4833 tableEntry { $$ = $1; }
4834 | tableEntryList tableEntry { $$ = $1->addNextNull($2); }
4835 ;
4836
4837 tableEntry<nodep>: // IEEE: combinational_entry + sequential_entry
4838 yaTABLELINE { $$ = new AstUdpTableLine($<fl>1,*$1); }
4839 | error { $$ = nullptr; }
4840 ;
4841
4842 //************************************************
4843 // Specify
4844
4845 specify_block<nodep>: // ==IEEE: specify_block
4846 ySPECIFY specifyJunkList yENDSPECIFY { $$ = nullptr; }
4847 | ySPECIFY yENDSPECIFY { $$ = nullptr; }
4848 ;
4849
4850 specifyJunkList:
4851 specifyJunk { } /* ignored */
4852 | specifyJunkList specifyJunk { } /* ignored */
4853 ;
4854
4855 specifyJunk:
4856 BISONPRE_NOT(ySPECIFY,yENDSPECIFY) { }
4857 | ySPECIFY specifyJunk yENDSPECIFY { }
4858 | error {}
4859 ;
4860
4861 specparam_declaration<nodep>: // ==IEEE: specparam_declaration
4862 ySPECPARAM junkToSemiList ';' { $$ = nullptr; }
4863 ;
4864
4865 junkToSemiList:
4866 junkToSemi { } /* ignored */
4867 | junkToSemiList junkToSemi { } /* ignored */
4868 ;
4869
4870 junkToSemi:
4871 BISONPRE_NOT(';',yENDSPECIFY,yENDMODULE) { }
4872 | error {}
4873 ;
4874
4875 //************************************************
4876 // IDs
4877
4878 id<strp>:
4879 yaID__ETC { $$ = $1; $<fl>$ = $<fl>1; }
4880 | idRandomize { $$ = $1; $<fl>$ = $<fl>1; }
4881 ;
4882
4883 idAny<strp>: // Any kind of identifier
4884 yaID__ETC { $$ = $1; $<fl>$ = $<fl>1; }
4885 | yaID__aTYPE { $$ = $1; $<fl>$ = $<fl>1; }
4886 | idRandomize { $$ = $1; $<fl>$ = $<fl>1; }
4887 ;
4888
4889 idType<strp>: // IEEE: class_identifier or other type identifier
4890 // // Used where reference is needed
4891 yaID__aTYPE { $$ = $1; $<fl>$ = $<fl>1; }
4892 ;
4893
4894 idCC<strp>: // IEEE: class/package then ::
4895 // lexer matches this: yaID_LEX [ '#' '(' ... ')' ] yP_COLONCOLON
4896 yaID__CC { $$ = $1; $<fl>$ = $<fl>1; }
4897 ;
4898
4899 idRandomize<strp>: // Keyword as an identifier
4900 yRANDOMIZE { static string s = "randomize"; $$ = &s; $<fl>$ = $<fl>1; }
4901 ;
4902
4903 idSVKwd<strp>: // Warn about non-forward compatible Verilog 2001 code
4904 // // yBIT, yBYTE won't work here as causes conflicts
4905 yDO
4906 { static string s = "do" ; $$ = &s; ERRSVKWD($1,*$$); $<fl>$ = $<fl>1; }
4907 | yFINAL
4908 { static string s = "final"; $$ = &s; ERRSVKWD($1,*$$); $<fl>$ = $<fl>1; }
4909 ;
4910
4911 variable_lvalue<nodep>: // IEEE: variable_lvalue or net_lvalue
4912 // // Note many variable_lvalue's must use exprOkLvalue when arbitrary expressions may also exist
4913 idClassSel { $$ = $1; }
4914 | '{' variable_lvalueConcList '}' { $$ = $2; }
4915 // // IEEE: [ assignment_pattern_expression_type ] assignment_pattern_variable_lvalue
4916 // // We allow more assignment_pattern_expression_types then strictly required
4917 //UNSUP data_type yP_TICKBRA variable_lvalueList '}' { UNSUP }
4918 //UNSUP idClassSel yP_TICKBRA variable_lvalueList '}' { UNSUP }
4919 //UNSUP /**/ yP_TICKBRA variable_lvalueList '}' { UNSUP }
4920 | streaming_concatenation { $$ = $1; }
4921 ;
4922
4923 variable_lvalueConcList<nodep>: // IEEE: part of variable_lvalue: '{' variable_lvalue { ',' variable_lvalue } '}'
4924 variable_lvalue { $$ = $1; }
4925 | variable_lvalueConcList ',' variable_lvalue { $$ = new AstConcat($2,$1,$3); }
4926 ;
4927
4928 //UNSUPvariable_lvalueList<nodep>: // IEEE: part of variable_lvalue: variable_lvalue { ',' variable_lvalue }
4929 //UNSUP variable_lvalue { $$ = $1; }
4930 //UNSUP | variable_lvalueList ',' variable_lvalue { $$ = AstNode::addNextNull($1, $3); }
4931 //UNSUP ;
4932
4933 // VarRef to dotted, and/or arrayed, and/or bit-ranged variable
4934 idClassSel<nodep>: // Misc Ref to dotted, and/or arrayed, and/or bit-ranged variable
4935 idDotted { $$ = $1; }
4936 // // IEEE: [ implicit_class_handle . | package_scope ] hierarchical_variable_identifier select
4937 | yTHIS '.' idDotted
4938 { $$ = new AstDot($2, false, new AstParseRef($<fl>1, VParseRefExp::PX_ROOT, "this"), $3); }
4939 | ySUPER '.' idDotted
4940 { $$ = new AstDot($2, false, new AstParseRef($<fl>1, VParseRefExp::PX_ROOT, "super"), $3); }
4941 | yTHIS '.' ySUPER '.' idDotted { $$ = $5; BBUNSUP($1, "Unsupported: this.super"); }
4942 // // Expanded: package_scope idDotted
4943 | packageClassScope idDotted { $$ = new AstDot($<fl>2, true, $1, $2); }
4944 ;
4945
4946 idClassSelForeach<nodep>:
4947 idDottedForeach { $$ = $1; }
4948 // // IEEE: [ implicit_class_handle . | package_scope ] hierarchical_variable_identifier select
4949 | yTHIS '.' idDottedForeach
4950 { $$ = new AstDot($2, false, new AstParseRef($<fl>1, VParseRefExp::PX_ROOT, "this"), $3); }
4951 | ySUPER '.' idDottedForeach
4952 { $$ = new AstDot($2, false, new AstParseRef($<fl>1, VParseRefExp::PX_ROOT, "super"), $3); }
4953 | yTHIS '.' ySUPER '.' idDottedForeach { $$ = $5; BBUNSUP($1, "Unsupported: this.super"); }
4954 // // Expanded: package_scope idForeach
4955 | packageClassScope idDottedForeach { $$ = new AstDot($<fl>2, true, $1, $2); }
4956 ;
4957
4958 idDotted<nodep>:
4959 yD_ROOT '.' idDottedMore
4960 { $$ = new AstDot($2, false, new AstParseRef($<fl>1, VParseRefExp::PX_ROOT, "$root"), $3); }
4961 | idDottedMore { $$ = $1; }
4962 ;
4963
4964 idDottedForeach<nodep>:
4965 yD_ROOT '.' idDottedMoreForeach
4966 { $$ = new AstDot($2, false, new AstParseRef($<fl>1, VParseRefExp::PX_ROOT, "$root"), $3); }
4967 | idDottedMoreForeach { $$ = $1; }
4968 ;
4969
4970 idDottedMore<nodep>:
4971 idArrayed { $$ = $1; }
4972 | idDottedMore '.' idArrayed { $$ = new AstDot($2, false, $1, $3); }
4973 ;
4974
4975 idDottedMoreForeach<nodep>:
4976 idArrayedForeach { $$ = $1; }
4977 | idDottedMoreForeach '.' idArrayedForeach { $$ = new AstDot($2, false, $1, $3); }
4978 ;
4979
4980 // Single component of dotted path, maybe [#].
4981 // Due to lookahead constraints, we can't know if [:] or [+:] are valid (last dotted part),
4982 // we'll assume so and cleanup later.
4983 // id below includes:
4984 // enum_identifier
4985 idArrayed<nodep>: // IEEE: id + select
4986 id
4987 { $$ = new AstParseRef($<fl>1, VParseRefExp::PX_TEXT, *$1, nullptr, nullptr); }
4988 // // IEEE: id + part_select_range/constant_part_select_range
4989 | idArrayed '[' expr ']' { $$ = new AstSelBit($2, $1, $3); } // Or AstArraySel, don't know yet.
4990 | idArrayed '[' constExpr ':' constExpr ']' { $$ = new AstSelExtract($2, $1, $3, $5); }
4991 // // IEEE: id + indexed_range/constant_indexed_range
4992 | idArrayed '[' expr yP_PLUSCOLON constExpr ']' { $$ = new AstSelPlus($2, $1, $3, $5); }
4993 | idArrayed '[' expr yP_MINUSCOLON constExpr ']' { $$ = new AstSelMinus($2, $1, $3, $5); }
4994 ;
4995
4996 idArrayedForeach<nodep>: // IEEE: id + select (under foreach expression)
4997 id
4998 { $$ = new AstParseRef($<fl>1, VParseRefExp::PX_TEXT, *$1, nullptr, nullptr); }
4999 // // IEEE: id + part_select_range/constant_part_select_range
5000 | idArrayed '[' expr ']' { $$ = new AstSelBit($2, $1, $3); } // Or AstArraySel, don't know yet.
5001 | idArrayed '[' constExpr ':' constExpr ']' { $$ = new AstSelExtract($2, $1, $3, $5); }
5002 // // IEEE: id + indexed_range/constant_indexed_range
5003 | idArrayed '[' expr yP_PLUSCOLON constExpr ']' { $$ = new AstSelPlus($2, $1, $3, $5); }
5004 | idArrayed '[' expr yP_MINUSCOLON constExpr ']' { $$ = new AstSelMinus($2, $1, $3, $5); }
5005 // // IEEE: loop_variables (under foreach expression)
5006 // // To avoid conflicts we allow expr as first element, must post-check
5007 | idArrayed '[' expr ',' loop_variables ']'
5008 { $3 = AstNode::addNextNull($3, $5); $$ = new AstSelLoopVars($2, $1, $3); }
5009 ;
5010
5011 // VarRef without any dots or vectorizaion
5012 varRefBase<varRefp>:
5013 id { $$ = new AstVarRef($<fl>1, *$1, VAccess::READ); }
5014 ;
5015
5016 // yaSTRING shouldn't be used directly, instead via an abstraction below
5017 str<strp>: // yaSTRING but with \{escapes} need decoded
5018 yaSTRING { $$ = PARSEP->newString(GRAMMARP->deQuote($<fl>1,*$1)); }
5019 ;
5020
5021 strAsInt<nodep>:
5022 yaSTRING
5023 { if ($1->empty()) {
5024 // else "" is not representable as number as is width 0
5025 // TODO all strings should be represented this way
5026 // until V3Width converts as/if needed to a numerical constant
5027 $$ = new AstConst{$<fl>1, AstConst::String{}, GRAMMARP->deQuote($<fl>1, *$1)};
5028 } else {
5029 $$ = new AstConst{$<fl>1, AstConst::VerilogStringLiteral(), GRAMMARP->deQuote($<fl>1, *$1)};
5030 }
5031 }
5032 ;
5033
5034 strAsIntIgnore<nodep>: // strAsInt, but never matches for when expr shouldn't parse strings
5035 yaSTRING__IGNORE { $$ = nullptr; yyerror("Impossible token"); }
5036 ;
5037
5038 strAsText<nodep>:
5039 yaSTRING { $$ = GRAMMARP->createTextQuoted($<fl>1, *$1); }
5040 ;
5041
5042 endLabelE<strp>:
5043 /* empty */ { $$ = nullptr; $<fl>$ = nullptr; }
5044 | ':' idAny { $$ = $2; $<fl>$ = $<fl>2; }
5045 | ':' yNEW__ETC { static string n = "new"; $$ = &n; $<fl>$ = $<fl>2; }
5046 ;
5047
5048 //************************************************
5049 // Clocking
5050
5051 clocking_declaration<nodep>: // IEEE: clocking_declaration (INCOMPLETE)
5052 //UNSUP: vvv remove this -- vastly simplified grammar:
5053 yDEFAULT yCLOCKING '@' '(' senitemEdge ')' ';' yENDCLOCKING
5054 { $$ = new AstClocking($2, $5, nullptr); }
5055 //UNSUP: ^^^ remove this -- vastly simplified grammar:
5056 //UNSUP clockingFront clocking_event ';'
5057 //UNSUP clocking_itemListE yENDCLOCKING endLabelE { SYMP->popScope($$); }
5058 ;
5059
5060 //UNSUPclockingFront: // IEEE: part of class_declaration
5061 //UNSUP yCLOCKING { PARSEP->symPushNewAnon(VAstType::CLOCKING); }
5062 //UNSUP | yCLOCKING idAny/*clocking_identifier*/ { SYMP->pushNew($$); }
5063 //UNSUP | yDEFAULT yCLOCKING { PARSEP->symPushNewAnon(VAstType::CLOCKING); }
5064 //UNSUP | yDEFAULT yCLOCKING idAny/*clocking_identifier*/ { SYMP->pushNew($$); }
5065 //UNSUP | yGLOBAL__CLOCKING yCLOCKING { PARSEP->symPushNewAnon(VAstType::CLOCKING); }
5066 //UNSUP | yGLOBAL__CLOCKING yCLOCKING idAny/*clocking_identifier*/ { SYMP->pushNew($$); }
5067 //UNSUP ;
5068
5069 //UNSUPclocking_event: // ==IEEE: clocking_event
5070 //UNSUP '@' id { }
5071 //UNSUP | '@' '(' event_expression ')' { }
5072 //UNSUP ;
5073
5074 //UNSUPclocking_itemListE:
5075 //UNSUP /* empty */ { $$ = nullptr; }
5076 //UNSUP | clocking_itemList { $$ = $1; }
5077 //UNSUP ;
5078
5079 //UNSUPclocking_itemList: // IEEE: [ clocking_item ]
5080 //UNSUP clocking_item { $$ = $1; }
5081 //UNSUP | clocking_itemList clocking_item { $$ = AstNode::addNextNull($1, $2); }
5082 //UNSUP ;
5083
5084 //UNSUPclocking_item: // ==IEEE: clocking_item
5085 //UNSUP yDEFAULT default_skew ';' { }
5086 //UNSUP | clocking_direction list_of_clocking_decl_assign ';' { }
5087 //UNSUP | assertion_item_declaration { }
5088 //UNSUP ;
5089
5090 //UNSUPdefault_skew: // ==IEEE: default_skew
5091 //UNSUP yINPUT clocking_skew { }
5092 //UNSUP | yOUTPUT clocking_skew { }
5093 //UNSUP | yINPUT clocking_skew yOUTPUT clocking_skew { }
5094 //UNSUP ;
5095
5096 //UNSUPclocking_direction: // ==IEEE: clocking_direction
5097 //UNSUP yINPUT clocking_skewE { }
5098 //UNSUP | yOUTPUT clocking_skewE { }
5099 //UNSUP | yINPUT clocking_skewE yOUTPUT clocking_skewE { }
5100 //UNSUP | yINOUT { }
5101 //UNSUP ;
5102
5103 //UNSUPlist_of_clocking_decl_assign: // ==IEEE: list_of_clocking_decl_assign
5104 //UNSUP clocking_decl_assign { $$ = $1; }
5105 //UNSUP | list_of_clocking_decl_assign ',' clocking_decl_assign { }
5106 //UNSUP ;
5107
5108 //UNSUPclocking_decl_assign: // ==IEEE: clocking_decl_assign
5109 //UNSUP idAny/*new-signal_identifier*/ exprEqE { $$ = $1; }
5110 //UNSUP ;
5111
5112 //UNSUPclocking_skewE: // IEEE: [clocking_skew]
5113 //UNSUP /* empty */ { $$ = nullptr; }
5114 //UNSUP | clocking_skew { $$ = $1; }
5115 //UNSUP ;
5116
5117 //UNSUPclocking_skew: // ==IEEE: clocking_skew
5118 //UNSUP yPOSEDGE { }
5119 //UNSUP | yPOSEDGE delay_control { }
5120 //UNSUP | yNEGEDGE { }
5121 //UNSUP | yNEGEDGE delay_control { }
5122 //UNSUP | yEDGE { NEED_S09($<fl>1,"edge"); }
5123 //UNSUP | yEDGE delay_control { NEED_S09($<fl>1,"edge"); }
5124 //UNSUP | delay_control { $$ = $1; }
5125 //UNSUP ;
5126
5127 //UNSUPcycle_delay: // ==IEEE: cycle_delay
5128 //UNSUP yP_POUNDPOUND yaINTNUM { }
5129 //UNSUP | yP_POUNDPOUND id { }
5130 //UNSUP | yP_POUNDPOUND '(' expr ')' { }
5131 //UNSUP ;
5132
5133 //************************************************
5134 // Asserts
5135
5136 //UNSUPassertion_item_declaration: // ==IEEE: assertion_item_declaration
5137 //UNSUP property_declaration { $$ = $1; }
5138 //UNSUP | sequence_declaration { $$ = $1; }
5139 //UNSUP | let_declaration { $$ = $1; }
5140 //UNSUP ;
5141
5142 assertion_item<nodep>: // ==IEEE: assertion_item
5143 concurrent_assertion_item { $$ = $1; }
5144 | deferred_immediate_assertion_item
5145 { $$ = $1 ? new AstAlways($1->fileline(), VAlwaysKwd::ALWAYS_COMB, nullptr, $1) : nullptr; }
5146 ;
5147
5148 deferred_immediate_assertion_item<nodep>: // ==IEEE: deferred_immediate_assertion_item
5149 deferred_immediate_assertion_statement { $$ = $1; }
5150 | id/*block_identifier*/ ':' deferred_immediate_assertion_statement
5151 { $$ = new AstBegin($<fl>1, *$1, $3, false, true); }
5152 ;
5153
5154 procedural_assertion_statement<nodep>: // ==IEEE: procedural_assertion_statement
5155 concurrent_assertion_statement { $$ = $1; }
5156 | immediate_assertion_statement { $$ = $1; }
5157 // // IEEE: checker_instantiation
5158 // // Unlike modules, checkers are the only "id id (...)" form in statements.
5159 //UNSUP checker_instantiation { $$ = $1; }
5160 ;
5161
5162 immediate_assertion_statement<nodep>: // ==IEEE: immediate_assertion_statement
5163 simple_immediate_assertion_statement { $$ = $1; }
5164 | deferred_immediate_assertion_statement { $$ = $1; }
5165 ;
5166
5167 simple_immediate_assertion_statement<nodep>: // ==IEEE: simple_immediate_assertion_statement
5168 // // action_block expanded here, for compatibility with AstAssert
5169 yASSERT '(' expr ')' stmtBlock %prec prLOWER_THAN_ELSE { $$ = new AstAssert($1, $3, $5, nullptr, true); }
5170 | yASSERT '(' expr ')' yELSE stmtBlock { $$ = new AstAssert($1, $3, nullptr, $6, true); }
5171 | yASSERT '(' expr ')' stmtBlock yELSE stmtBlock { $$ = new AstAssert($1, $3, $5, $7, true); }
5172 // // action_block expanded here, for compatibility with AstAssert
5173 | yASSUME '(' expr ')' stmtBlock %prec prLOWER_THAN_ELSE { $$ = new AstAssert($1, $3, $5, nullptr, true); }
5174 | yASSUME '(' expr ')' yELSE stmtBlock { $$ = new AstAssert($1, $3, nullptr, $6, true); }
5175 | yASSUME '(' expr ')' stmtBlock yELSE stmtBlock { $$ = new AstAssert($1, $3, $5, $7, true); }
5176 // // IEEE: simple_immediate_cover_statement
5177 | yCOVER '(' expr ')' stmt { $$ = new AstCover($1, $3, $5, true); }
5178 ;
5179
5180 final_zero: // IEEE: part of deferred_immediate_assertion_statement
5181 '#' yaINTNUM
5182 { if ($2->isNeqZero()) { $<fl>2->v3error("Deferred assertions must use '#0' (IEEE 1800-2017 16.4)"); } }
5183 // // 1800-2012:
5184 | yFINAL { }
5185 ;
5186
5187 deferred_immediate_assertion_statement<nodep>: // ==IEEE: deferred_immediate_assertion_statement
5188 // // IEEE: deferred_immediate_assert_statement
5189 yASSERT final_zero '(' expr ')' stmtBlock %prec prLOWER_THAN_ELSE { $$ = new AstAssert($1, $4, $6, nullptr, true); }
5190 | yASSERT final_zero '(' expr ')' yELSE stmtBlock { $$ = new AstAssert($1, $4, nullptr, $7, true); }
5191 | yASSERT final_zero '(' expr ')' stmtBlock yELSE stmtBlock { $$ = new AstAssert($1, $4, $6, $8, true); }
5192 // // IEEE: deferred_immediate_assume_statement
5193 | yASSUME final_zero '(' expr ')' stmtBlock %prec prLOWER_THAN_ELSE { $$ = new AstAssert($1, $4, $6, nullptr, true); }
5194 | yASSUME final_zero '(' expr ')' yELSE stmtBlock { $$ = new AstAssert($1, $4, nullptr, $7, true); }
5195 | yASSUME final_zero '(' expr ')' stmtBlock yELSE stmtBlock { $$ = new AstAssert($1, $4, $6, $8, true); }
5196 // // IEEE: deferred_immediate_cover_statement
5197 | yCOVER final_zero '(' expr ')' stmt { $$ = new AstCover($1, $4, $6, true); }
5198 ;
5199
5200 //UNSUPexpect_property_statement<nodep>: // ==IEEE: expect_property_statement
5201 //UNSUP yEXPECT '(' property_spec ')' action_block { }
5202 //UNSUP ;
5203
5204 concurrent_assertion_item<nodep>: // IEEE: concurrent_assertion_item
5205 concurrent_assertion_statement { $$ = $1; }
5206 | id/*block_identifier*/ ':' concurrent_assertion_statement
5207 { $$ = new AstBegin($<fl>1, *$1, $3, false, true); }
5208 // // IEEE: checker_instantiation
5209 // // identical to module_instantiation; see etcInst
5210 ;
5211
5212 concurrent_assertion_statement<nodep>: // ==IEEE: concurrent_assertion_statement
5213 // // IEEE: assert_property_statement
5214 //UNSUP remove below:
5215 yASSERT yPROPERTY '(' property_spec ')' elseStmtBlock { $$ = new AstAssert($1, $4, nullptr, $6, false); }
5216 //UNSUP yASSERT yPROPERTY '(' property_spec ')' action_block { }
5217 // // IEEE: assume_property_statement
5218 | yASSUME yPROPERTY '(' property_spec ')' elseStmtBlock { $$ = new AstAssert($1, $4, nullptr, $6, false); }
5219 //UNSUP yASSUME yPROPERTY '(' property_spec ')' action_block { }
5220 // // IEEE: cover_property_statement
5221 | yCOVER yPROPERTY '(' property_spec ')' stmtBlock { $$ = new AstCover($1, $4, $6, false); }
5222 // // IEEE: cover_sequence_statement
5223 //UNSUP yCOVER ySEQUENCE '(' sexpr ')' stmt { }
5224 // // IEEE: yCOVER ySEQUENCE '(' clocking_event sexpr ')' stmt
5225 // // sexpr already includes "clocking_event sexpr"
5226 //UNSUP yCOVER ySEQUENCE '(' clocking_event yDISABLE yIFF '(' expr/*expression_or_dist*/ ')' sexpr ')' stmt { }
5227 //UNSUP yCOVER ySEQUENCE '(' yDISABLE yIFF '(' expr/*expression_or_dist*/ ')' sexpr ')' stmt { }
5228 // // IEEE: restrict_property_statement
5229 | yRESTRICT yPROPERTY '(' property_spec ')' ';' { $$ = new AstRestrict($1, $4); }
5230 ;
5231
5232 elseStmtBlock<nodep>: // Part of concurrent_assertion_statement
5233 ';' { $$ = nullptr; }
5234 | yELSE stmtBlock { $$ = $2; }
5235 ;
5236
5237 //UNSUPproperty_declaration<nodep>: // ==IEEE: property_declaration
5238 //UNSUP property_declarationFront property_port_listE ';' property_declarationBody
5239 //UNSUP yENDPROPERTY endLabelE
5240 //UNSUP { SYMP->popScope($$); }
5241 //UNSUP ;
5242
5243 //UNSUPproperty_declarationFront<nodep>: // IEEE: part of property_declaration
5244 //UNSUP yPROPERTY idAny/*property_identifier*/
5245 //UNSUP { SYMP->pushNew($$); }
5246 //UNSUP ;
5247
5248 //UNSUPproperty_port_listE<nodep>: // IEEE: [ ( [ property_port_list ] ) ]
5249 //UNSUP /* empty */ { $$ = nullptr; }
5250 //UNSUP | '(' {VARRESET_LIST(""); VARIO("input"); } property_port_list ')'
5251 //UNSUP { VARRESET_NONLIST(""); }
5252 //UNSUP ;
5253
5254 //UNSUPproperty_port_list<nodep>: // ==IEEE: property_port_list
5255 //UNSUP property_port_item { $$ = $1; }
5256 //UNSUP | property_port_list ',' property_port_item { }
5257 //UNSUP ;
5258
5259 //UNSUPproperty_port_item<nodep>: // IEEE: property_port_item/sequence_port_item
5260 //UNSUP // // Merged in sequence_port_item
5261 //UNSUP // // IEEE: property_lvar_port_direction ::= yINPUT
5262 //UNSUP // // prop IEEE: [ yLOCAL [ yINPUT ] ] property_formal_type
5263 //UNSUP // // id {variable_dimension} [ '=' property_actual_arg ]
5264 //UNSUP // // seq IEEE: [ yLOCAL [ sequence_lvar_port_direction ] ] sequence_formal_type
5265 //UNSUP // // id {variable_dimension} [ '=' sequence_actual_arg ]
5266 //UNSUP property_port_itemFront property_port_itemAssignment { }
5267 //UNSUP ;
5268
5269 //UNSUPproperty_port_itemFront: // IEEE: part of property_port_item/sequence_port_item
5270 //UNSUP property_port_itemDirE property_formal_typeNoDt { VARDTYPE($2); }
5271 //UNSUP // // data_type_or_implicit
5272 //UNSUP | property_port_itemDirE data_type { VARDTYPE($2); }
5273 //UNSUP | property_port_itemDirE yVAR data_type { VARDTYPE($3); }
5274 //UNSUP | property_port_itemDirE yVAR implicit_typeE { VARDTYPE($3); }
5275 //UNSUP | property_port_itemDirE signingE rangeList { VARDTYPE(SPACED($2,$3)); }
5276 //UNSUP | property_port_itemDirE /*implicit*/ { /*VARDTYPE-same*/ }
5277 //UNSUP ;
5278
5279 //UNSUPproperty_port_itemAssignment<nodep>: // IEEE: part of property_port_item/sequence_port_item/checker_port_direction
5280 //UNSUP portSig variable_dimensionListE { VARDONE($<fl>1, $1, $2, ""); PINNUMINC(); }
5281 //UNSUP | portSig variable_dimensionListE '=' property_actual_arg
5282 //UNSUP { VARDONE($<fl>1, $1, $2, $4); PINNUMINC(); }
5283 //UNSUP ;
5284
5285 //UNSUPproperty_port_itemDirE:
5286 //UNSUP /* empty */ { $$ = nullptr; }
5287 //UNSUP | yLOCAL__ETC { }
5288 //UNSUP | yLOCAL__ETC port_direction { }
5289 //UNSUP ;
5290
5291 //UNSUPproperty_declarationBody<nodep>: // IEEE: part of property_declaration
5292 //UNSUP assertion_variable_declarationList property_statement_spec { }
5293 //UNSUP // // IEEE-2012: Incorectly hasyCOVER ySEQUENCE then property_spec here.
5294 //UNSUP // // Fixed in IEEE 1800-2017
5295 //UNSUP | property_statement_spec { $$ = $1; }
5296 //UNSUP ;
5297
5298 //UNSUPassertion_variable_declarationList: // IEEE: part of assertion_variable_declaration
5299 //UNSUP assertion_variable_declaration { $$ = $1; }
5300 //UNSUP | assertion_variable_declarationList assertion_variable_declaration { }
5301 //UNSUP ;
5302
5303 //UNSUPsequence_declaration<nodep>: // ==IEEE: sequence_declaration
5304 //UNSUP sequence_declarationFront sequence_port_listE ';' sequence_declarationBody
5305 //UNSUP yENDSEQUENCE endLabelE
5306 //UNSUP { SYMP->popScope($$); }
5307 //UNSUP ;
5308
5309 //UNSUPsequence_declarationFront<nodep>: // IEEE: part of sequence_declaration
5310 //UNSUP ySEQUENCE idAny/*new_sequence*/
5311 //UNSUP { SYMP->pushNew($$); }
5312 //UNSUP ;
5313
5314 //UNSUPsequence_port_listE<nodep>: // IEEE: [ ( [ sequence_port_list ] ) ]
5315 //UNSUP // // IEEE: sequence_lvar_port_direction ::= yINPUT | yINOUT | yOUTPUT
5316 //UNSUP // // IEEE: [ yLOCAL [ sequence_lvar_port_direction ] ] sequence_formal_type
5317 //UNSUP // // id {variable_dimension} [ '=' sequence_actual_arg ]
5318 //UNSUP // // All this is almost identically the same as a property.
5319 //UNSUP // // Difference is only yINOUT/yOUTPUT (which might be added to 1800-2012)
5320 //UNSUP // // and yPROPERTY. So save some work.
5321 //UNSUP property_port_listE { $$ = $1; }
5322 //UNSUP ;
5323
5324 //UNSUPproperty_formal_typeNoDt<nodep>: // IEEE: property_formal_type (w/o implicit)
5325 //UNSUP sequence_formal_typeNoDt { $$ = $1; }
5326 //UNSUP | yPROPERTY { }
5327 //UNSUP ;
5328
5329 //UNSUPsequence_formal_typeNoDt<nodep>: // ==IEEE: sequence_formal_type (w/o data_type_or_implicit)
5330 //UNSUP // // IEEE: data_type_or_implicit
5331 //UNSUP // // implicit expanded where used
5332 //UNSUP ySEQUENCE { }
5333 //UNSUP // // IEEE-2009: yEVENT
5334 //UNSUP // // already part of data_type. Removed in 1800-2012.
5335 //UNSUP | yUNTYPED { }
5336 //UNSUP ;
5337
5338 //UNSUPsequence_declarationBody<nodep>: // IEEE: part of sequence_declaration
5339 //UNSUP // // 1800-2012 makes ';' optional
5340 //UNSUP assertion_variable_declarationList sexpr { }
5341 //UNSUP | assertion_variable_declarationList sexpr ';' { }
5342 //UNSUP | sexpr { $$ = $1; }
5343 //UNSUP | sexpr ';' { $$ = $1; }
5344 //UNSUP ;
5345
5346 property_spec<nodep>: // IEEE: property_spec
5347 //UNSUP: This rule has been super-specialized to what is supported now
5348 //UNSUP remove below
5349 '@' '(' senitemEdge ')' yDISABLE yIFF '(' expr ')' pexpr
5350 { $$ = new AstPropClocked($1, $3, $8, $10); }
5351 | '@' '(' senitemEdge ')' pexpr { $$ = new AstPropClocked($1, $3, nullptr, $5); }
5352 //UNSUP remove above
5353 | yDISABLE yIFF '(' expr ')' pexpr { $$ = new AstPropClocked($4->fileline(), nullptr, $4, $6); }
5354 | pexpr { $$ = new AstPropClocked($1->fileline(), nullptr, nullptr, $1); }
5355 ;
5356
5357 //UNSUPproperty_statement_spec<nodep>: // ==IEEE: property_statement_spec
5358 //UNSUP // // IEEE: [ clocking_event ] [ yDISABLE yIFF '(' expression_or_dist ')' ] property_statement
5359 //UNSUP property_statement { $$ = $1; }
5360 //UNSUP | yDISABLE yIFF '(' expr/*expression_or_dist*/ ')' property_statement { }
5361 //UNSUP // // IEEE: clocking_event property_statement
5362 //UNSUP // // IEEE: clocking_event yDISABLE yIFF '(' expr/*expression_or_dist*/ ')' property_statement
5363 //UNSUP // // Both overlap pexpr:"clocking_event pexpr" the difference is
5364 //UNSUP // // property_statement:property_statementCaseIf so replicate it
5365 //UNSUP | clocking_event property_statementCaseIf { }
5366 //UNSUP | clocking_event yDISABLE yIFF '(' expr/*expression_or_dist*/ ')' property_statementCaseIf { }
5367 //UNSUP ;
5368
5369 //UNSUPproperty_statement<nodep>: // ==IEEE: property_statement
5370 //UNSUP // // Doesn't make sense to have "pexpr ;" in pexpr rule itself, so we split out case/if
5371 //UNSUP pexpr ';' { $$ = $1; }
5372 //UNSUP // // Note this term replicated in property_statement_spec
5373 //UNSUP // // If committee adds terms, they may need to be there too.
5374 //UNSUP | property_statementCaseIf { $$ = $1; }
5375 //UNSUP ;
5376
5377 //UNSUPproperty_statementCaseIf<nodep>: // IEEE: property_statement - minus pexpr
5378 //UNSUP yCASE '(' expr/*expression_or_dist*/ ')' property_case_itemList yENDCASE { }
5379 //UNSUP | yCASE '(' expr/*expression_or_dist*/ ')' yENDCASE { }
5380 //UNSUP | yIF '(' expr/*expression_or_dist*/ ')' pexpr %prec prLOWER_THAN_ELSE { }
5381 //UNSUP | yIF '(' expr/*expression_or_dist*/ ')' pexpr yELSE pexpr { }
5382 //UNSUP ;
5383
5384 //UNSUPproperty_case_itemList<nodep>: // IEEE: {property_case_item}
5385 //UNSUP property_case_item { $$ = $1; }
5386 //UNSUP | property_case_itemList ',' property_case_item { $$ = AstNode::addNextNull($1, $3); }
5387 //UNSUP ;
5388
5389 //UNSUPproperty_case_item<nodep>: // ==IEEE: property_case_item
5390 //UNSUP // // IEEE: expression_or_dist { ',' expression_or_dist } ':' property_statement
5391 //UNSUP // // IEEE 1800-2012 changed from property_statement to property_expr
5392 //UNSUP // // IEEE 1800-2017 changed to require the semicolon
5393 //UNSUP caseCondList ':' pexpr { }
5394 //UNSUP | caseCondList ':' pexpr ';' { }
5395 //UNSUP | yDEFAULT pexpr { }
5396 //UNSUP | yDEFAULT ':' pexpr ';' { }
5397 //UNSUP ;
5398
5399 //UNSUPpev_expr<nodep>: // IEEE: property_actual_arg | expr
5400 //UNSUP // // which expands to pexpr | event_expression
5401 //UNSUP // // Used in port and function calls, when we can't know yet if something
5402 //UNSUP // // is a function/sequence/property or instance/checker pin.
5403 //UNSUP //
5404 //UNSUP // // '(' pev_expr ')'
5405 //UNSUP // // Already in pexpr
5406 //UNSUP // // IEEE: event_expression ',' event_expression
5407 //UNSUP // // ','s are legal in event_expressions, but parens required to avoid conflict with port-sep-,
5408 //UNSUP // // IEEE: event_expression yOR event_expression
5409 //UNSUP // // Already in pexpr - needs removal there
5410 //UNSUP // // IEEE: event_expression yIFF expr
5411 //UNSUP // // Already in pexpr - needs removal there
5412 //UNSUP //
5413 //UNSUP senitemEdge { $$ = $1; }
5414 //UNSUP //
5415 //UNSUP //============= pexpr rules copied for pev_expr
5416 //UNSUP | BISONPRE_COPY_ONCE(pexpr,{s/~o~p/pev_/g; }) // {copied}
5417 //UNSUP //
5418 //UNSUP //============= sexpr rules copied for pev_expr
5419 //UNSUP | BISONPRE_COPY_ONCE(sexpr,{s/~p~s/pev_/g; }) // {copied}
5420 //UNSUP //
5421 //UNSUP //============= expr rules copied for pev_expr
5422 //UNSUP | BISONPRE_COPY_ONCE(expr,{s/~l~/pev_/g; s/~p~/pev_/g; s/~noPar__IGNORE~/yP_PAR__IGNORE /g; }) // {copied}
5423 //UNSUP ;
5424
5425 pexpr<nodep>: // IEEE: property_expr (The name pexpr is important as regexps just add an "p" to expr.)
5426 //UNSUP: This rule has been super-specialized to what is supported now
5427 //UNSUP remove below
5428 expr yP_ORMINUSGT pexpr { $$ = new AstLogOr($2, new AstLogNot($2, $1), $3); }
5429 | expr yP_OREQGT pexpr { $$ = new AstImplication($2, $1, $3); }
5430 | expr { $$ = $1; }
5431 //UNSUP remove above, use below:
5432 //
5433 // // IEEE: sequence_expr
5434 // // Expanded below
5435 //
5436 // // IEEE: '(' pexpr ')'
5437 // // Expanded below
5438 //
5439 //UNSUP yNOT pexpr %prec prNEGATION { }
5440 //UNSUP ySTRONG '(' sexpr ')' { }
5441 //UNSUP yWEAK '(' sexpr ')' { }
5442 // // IEEE: pexpr yOR pexpr
5443 // // IEEE: pexpr yAND pexpr
5444 // // Under ~p~sexpr and/or ~p~sexpr
5445 //
5446 // // IEEE: "sequence_expr yP_ORMINUSGT pexpr"
5447 // // Instead we use pexpr to prevent conflicts
5448 //UNSUP ~o~pexpr yP_ORMINUSGT pexpr { }
5449 //UNSUP ~o~pexpr yP_OREQGT pexpr { }
5450 //
5451 // // IEEE-2009: property_statement
5452 // // IEEE-2012: yIF and yCASE
5453 //UNSUP property_statementCaseIf { }
5454 //
5455 //UNSUP ~o~pexpr/*sexpr*/ yP_POUNDMINUSPD pexpr { }
5456 //UNSUP ~o~pexpr/*sexpr*/ yP_POUNDEQPD pexpr { }
5457 //UNSUP yNEXTTIME pexpr { }
5458 //UNSUP yS_NEXTTIME pexpr { }
5459 //UNSUP yNEXTTIME '[' expr/*const*/ ']' pexpr %prec yNEXTTIME { }
5460 //UNSUP yS_NEXTTIME '[' expr/*const*/ ']' pexpr %prec yS_NEXTTIME { }
5461 //UNSUP yALWAYS pexpr { }
5462 //UNSUP yALWAYS '[' cycle_delay_const_range_expression ']' pexpr %prec yALWAYS { }
5463 //UNSUP yS_ALWAYS '[' constant_range ']' pexpr %prec yS_ALWAYS { }
5464 //UNSUP yS_EVENTUALLY pexpr { }
5465 //UNSUP yEVENTUALLY '[' constant_range ']' pexpr %prec yEVENTUALLY { }
5466 //UNSUP yS_EVENTUALLY '[' cycle_delay_const_range_expression ']' pexpr %prec yS_EVENTUALLY { }
5467 //UNSUP ~o~pexpr yUNTIL pexpr { }
5468 //UNSUP ~o~pexpr yS_UNTIL pexpr { }
5469 //UNSUP ~o~pexpr yUNTIL_WITH pexpr { }
5470 //UNSUP ~o~pexpr yS_UNTIL_WITH pexpr { }
5471 //UNSUP ~o~pexpr yIMPLIES pexpr { }
5472 // // yIFF also used by event_expression
5473 //UNSUP ~o~pexpr yIFF ~o~pexpr { }
5474 //UNSUP yACCEPT_ON '(' expr/*expression_or_dist*/ ')' pexpr %prec yACCEPT_ON { }
5475 //UNSUP yREJECT_ON '(' expr/*expression_or_dist*/ ')' pexpr %prec yREJECT_ON { }
5476 //UNSUP ySYNC_ACCEPT_ON '(' expr/*expression_or_dist*/ ')' pexpr %prec ySYNC_ACCEPT_ON { }
5477 //UNSUP ySYNC_REJECT_ON '(' expr/*expression_or_dist*/ ')' pexpr %prec ySYNC_REJECT_ON { }
5478 //
5479 // // IEEE: "property_instance"
5480 // // Looks just like a function/method call
5481 //
5482 // // Note "clocking_event pexpr" overlaps property_statement_spec: clocking_event property_statement
5483 //
5484 // // Include property_specDisable to match property_spec rule
5485 //UNSUP clocking_event yDISABLE yIFF '(' expr ')' pexpr %prec prSEQ_CLOCKING { }
5486 //
5487 //============= sexpr rules copied for property_expr
5488 //UNSUP BISONPRE_COPY_ONCE(sexpr,{s/~p~s/p/g; }) // {copied}
5489 //
5490 //============= expr rules copied for property_expr
5491 //UNSUP BISONPRE_COPY_ONCE(expr,{s/~l~/p/g; s/~p~/p/g; s/~noPar__IGNORE~/yP_PAR__IGNORE /g; }) // {copied}
5492 ;
5493
5494 //UNSUPsexpr<nodep>: // ==IEEE: sequence_expr (The name sexpr is important as regexps just add an "s" to expr.)
5495 //UNSUP // // ********* RULES COPIED IN sequence_exprProp
5496 //UNSUP // // For precedence, see IEEE 17.7.1
5497 //UNSUP //
5498 //UNSUP // // IEEE: "cycle_delay_range sequence_expr { cycle_delay_range sequence_expr }"
5499 //UNSUP // // IEEE: "sequence_expr cycle_delay_range sequence_expr { cycle_delay_range sequence_expr }"
5500 //UNSUP // // Both rules basically mean we can repeat sequences, so make it simpler:
5501 //UNSUP cycle_delay_range sexpr %prec yP_POUNDPOUND { }
5502 //UNSUP | ~p~sexpr cycle_delay_range sexpr %prec prPOUNDPOUND_MULTI { }
5503 //UNSUP //
5504 //UNSUP // // IEEE: expression_or_dist [ boolean_abbrev ]
5505 //UNSUP // // Note expression_or_dist includes "expr"!
5506 //UNSUP // // sexpr/*sexpression_or_dist*/ --- Hardcoded below
5507 //UNSUP | ~p~sexpr/*sexpression_or_dist*/ boolean_abbrev { }
5508 //UNSUP //
5509 //UNSUP // // IEEE: "sequence_instance [ sequence_abbrev ]"
5510 //UNSUP // // version without sequence_abbrev looks just like normal function call
5511 //UNSUP // // version w/sequence_abbrev matches above; expression_or_dist:expr:func boolean_abbrev:sequence_abbrev
5512 //UNSUP //
5513 //UNSUP // // IEEE: '(' expression_or_dist {',' sequence_match_item } ')' [ boolean_abbrev ]
5514 //UNSUP // // IEEE: '(' sexpr {',' sequence_match_item } ')' [ sequence_abbrev ]
5515 //UNSUP // // As sequence_expr includes expression_or_dist, and boolean_abbrev includes sequence_abbrev:
5516 //UNSUP // // '(' sequence_expr {',' sequence_match_item } ')' [ boolean_abbrev ]
5517 //UNSUP // // "'(' sexpr ')' boolean_abbrev" matches "[sexpr:'(' expr ')'] boolean_abbrev" so we can simply drop it
5518 //UNSUP | '(' ~p~sexpr ')' { $<fl>$ = $<fl>1; $$ = ...; }
5519 //UNSUP | '(' ~p~sexpr ',' sequence_match_itemList ')' { }
5520 //UNSUP //
5521 //UNSUP // // AND/OR are between pexprs OR sexprs
5522 //UNSUP | ~p~sexpr yAND ~p~sexpr { $<fl>$ = $<fl>1; $$ = ...; }
5523 //UNSUP | ~p~sexpr yOR ~p~sexpr { $<fl>$ = $<fl>1; $$ = ...; }
5524 //UNSUP // // Intersect always has an sexpr rhs
5525 //UNSUP | ~p~sexpr yINTERSECT sexpr { $<fl>$ = $<fl>1; $$ = ...; }
5526 //UNSUP //
5527 //UNSUP | yFIRST_MATCH '(' sexpr ')' { }
5528 //UNSUP | yFIRST_MATCH '(' sexpr ',' sequence_match_itemList ')' { }
5529 //UNSUP | ~p~sexpr/*sexpression_or_dist*/ yTHROUGHOUT sexpr { }
5530 //UNSUP // // Below pexpr's are really sequence_expr, but avoid conflict
5531 //UNSUP // // IEEE: sexpr yWITHIN sexpr
5532 //UNSUP | ~p~sexpr yWITHIN sexpr { $<fl>$ = $<fl>1; $$ = ...; }
5533 //UNSUP // // Note concurrent_assertion had duplicate rule for below
5534 //UNSUP | clocking_event ~p~sexpr %prec prSEQ_CLOCKING { }
5535 //UNSUP //
5536 //UNSUP //============= expr rules copied for sequence_expr
5537 //UNSUP | BISONPRE_COPY_ONCE(expr,{s/~l~/s/g; s/~p~/s/g; s/~noPar__IGNORE~/yP_PAR__IGNORE /g; }) // {copied}
5538 //UNSUP ;
5539
5540 //UNSUPcycle_delay_range<nodep>: // IEEE: ==cycle_delay_range
5541 //UNSUP // // These three terms in 1800-2005 ONLY
5542 //UNSUP yP_POUNDPOUND yaINTNUM { }
5543 //UNSUP | yP_POUNDPOUND id { }
5544 //UNSUP | yP_POUNDPOUND '(' constExpr ')' { }
5545 //UNSUP // // In 1800-2009 ONLY:
5546 //UNSUP // // IEEE: yP_POUNDPOUND constant_primary
5547 //UNSUP // // UNSUP: This causes a big grammer ambiguity
5548 //UNSUP // // as ()'s mismatch between primary and the following statement
5549 //UNSUP // // the sv-ac committee has been asked to clarify (Mantis 1901)
5550 //UNSUP | yP_POUNDPOUND '[' cycle_delay_const_range_expression ']' { }
5551 //UNSUP | yP_POUNDPOUND yP_BRASTAR ']' { }
5552 //UNSUP | yP_POUNDPOUND yP_BRAPLUSKET { }
5553 //UNSUP ;
5554
5555 //UNSUPsequence_match_itemList<nodep>: // IEEE: [sequence_match_item] part of sequence_expr
5556 //UNSUP sequence_match_item { $$ = $1; }
5557 //UNSUP | sequence_match_itemList ',' sequence_match_item { }
5558 //UNSUP ;
5559
5560 //UNSUPsequence_match_item<nodep>: // ==IEEE: sequence_match_item
5561 //UNSUP // // IEEE says: operator_assignment
5562 //UNSUP // // IEEE says: inc_or_dec_expression
5563 //UNSUP // // IEEE says: subroutine_call
5564 //UNSUP // // This is the same list as...
5565 //UNSUP for_step_assignment { $$ = $1; }
5566 //UNSUP ;
5567
5568 //UNSUPboolean_abbrev<nodep>: // ==IEEE: boolean_abbrev
5569 //UNSUP // // IEEE: consecutive_repetition
5570 //UNSUP yP_BRASTAR const_or_range_expression ']' { }
5571 //UNSUP | yP_BRASTAR ']' { }
5572 //UNSUP | yP_BRAPLUSKET { $$ = $1; }
5573 //UNSUP // // IEEE: non_consecutive_repetition
5574 //UNSUP | yP_BRAEQ const_or_range_expression ']' { }
5575 //UNSUP // // IEEE: goto_repetition
5576 //UNSUP | yP_BRAMINUSGT const_or_range_expression ']' { }
5577 //UNSUP ;
5578
5579 //UNSUPconst_or_range_expression<nodep>: // ==IEEE: const_or_range_expression
5580 //UNSUP constExpr { $$ = $1; }
5581 //UNSUP | cycle_delay_const_range_expression { }
5582 //UNSUP ;
5583
5584 //UNSUPconstant_range<nodep>: // ==IEEE: constant_range
5585 //UNSUP constExpr ':' constExpr { }
5586 //UNSUP ;
5587
5588 //UNSUPcycle_delay_const_range_expression<nodep>: // ==IEEE: cycle_delay_const_range_expression
5589 //UNSUP // // Note '$' is part of constExpr
5590 //UNSUP constExpr ':' constExpr { }
5591 //UNSUP ;
5592
5593 //************************************************
5594 // Let
5595
5596 //************************************************
5597 // Covergroup
5598
5599 //UNSUPcovergroup_declaration<nodep>: // ==IEEE: covergroup_declaration
5600 //UNSUP covergroup_declarationFront coverage_eventE ';' coverage_spec_or_optionListE
5601 //UNSUP yENDGROUP endLabelE
5602 //UNSUP { PARSEP->endgroupCb($<fl>5,$5);
5603 //UNSUP SYMP->popScope($$); }
5604 //UNSUP | covergroup_declarationFront '(' tf_port_listE ')' coverage_eventE ';' coverage_spec_or_optionListE
5605 //UNSUP yENDGROUP endLabelE
5606 //UNSUP { PARSEP->endgroupCb($<fl>8,$8);
5607 //UNSUP SYMP->popScope($$); }
5608 //UNSUP ;
5609
5610 //UNSUPcovergroup_declarationFront: // IEEE: part of covergroup_declaration
5611 //UNSUP yCOVERGROUP idAny
5612 //UNSUP { SYMP->pushNew($$);
5613 //UNSUP PARSEP->covergroupCb($<fl>1,$1,$2); }
5614 //UNSUP ;
5615
5616 //UNSUPcgexpr<nodep>: // IEEE-2012: covergroup_expression, before that just expression
5617 //UNSUP expr { $$ = $1; }
5618 //UNSUP ;
5619
5620 //UNSUPcoverage_spec_or_optionListE<nodep>: // IEEE: [{coverage_spec_or_option}]
5621 //UNSUP /* empty */ { $$ = nullptr; }
5622 //UNSUP | coverage_spec_or_optionList { $$ = $1; }
5623 //UNSUP ;
5624
5625 //UNSUPcoverage_spec_or_optionList<nodep>: // IEEE: {coverage_spec_or_option}
5626 //UNSUP coverage_spec_or_option { $$ = $1; }
5627 //UNSUP | coverage_spec_or_optionList coverage_spec_or_option { $$ = AstNode::addNextNull($1, $2); }
5628 //UNSUP ;
5629
5630 //UNSUPcoverage_spec_or_option<nodep>: // ==IEEE: coverage_spec_or_option
5631 //UNSUP // // IEEE: coverage_spec
5632 //UNSUP cover_point { $$ = $1; }
5633 //UNSUP | cover_cross { $$ = $1; }
5634 //UNSUP | coverage_option ';' { $$ = $1; }
5635 //UNSUP | error { $$ = nullptr; }
5636 //UNSUP ;
5637
5638 //UNSUPcoverage_option: // ==IEEE: coverage_option
5639 //UNSUP // // option/type_option aren't really keywords
5640 //UNSUP id/*yOPTION | yTYPE_OPTION*/ '.' idAny/*member_identifier*/ '=' expr { }
5641 //UNSUP ;
5642
5643 //UNSUPcover_point: // ==IEEE: cover_point
5644 //UNSUP /**/ yCOVERPOINT expr iffE bins_or_empty { }
5645 //UNSUP // // IEEE-2012: class_scope before an ID
5646 //UNSUP | /**/ /**/ /**/ id ':' yCOVERPOINT expr iffE bins_or_empty { }
5647 //UNSUP | class_scope_id ':' yCOVERPOINT expr iffE bins_or_empty { }
5648 //UNSUP | class_scope_id id data_type id ':' yCOVERPOINT expr iffE bins_or_empty { }
5649 //UNSUP | class_scope_id id /**/ id ':' yCOVERPOINT expr iffE bins_or_empty { }
5650 //UNSUP | /**/ id /**/ id ':' yCOVERPOINT expr iffE bins_or_empty { }
5651 //UNSUP // // IEEE-2012:
5652 //UNSUP | bins_or_empty { $$ = $1; }
5653 //UNSUP ;
5654
5655 //UNSUPiffE<nodep>: // IEEE: part of cover_point, others
5656 //UNSUP /* empty */ { $$ = nullptr; }
5657 //UNSUP | yIFF '(' expr ')' { }
5658 //UNSUP ;
5659
5660 //UNSUPbins_or_empty<nodep>: // ==IEEE: bins_or_empty
5661 //UNSUP '{' bins_or_optionsList '}' { $$ = $2; }
5662 //UNSUP | '{' '}' { $$ = nullptr; }
5663 //UNSUP | ';' { $$ = nullptr; }
5664 //UNSUP ;
5665
5666 //UNSUPbins_or_optionsList<nodep>: // IEEE: { bins_or_options ';' }
5667 //UNSUP bins_or_options ';' { $$ = $1; }
5668 //UNSUP | bins_or_optionsList bins_or_options ';' { $$ = AstNode::addNextNull($1, $2); }
5669 //UNSUP ;
5670
5671 //UNSUPbins_or_options<nodep>: // ==IEEE: bins_or_options
5672 //UNSUP // // Superset of IEEE - we allow []'s in more places
5673 //UNSUP coverage_option { $$ = $1; }
5674 //UNSUP // // Can't use wildcardE as results in conflicts
5675 //UNSUP | /**/ bins_keyword id/*bin_identifier*/ bins_orBraE '=' '{' open_range_list '}' iffE { }
5676 //UNSUP | yWILDCARD bins_keyword id/*bin_identifier*/ bins_orBraE '=' '{' open_range_list '}' iffE { }
5677 //UNSUP | /**/ bins_keyword id/*bin_identifier*/ bins_orBraE '=' '{' open_range_list '}' yWITH__CUR '{' cgexpr ')' iffE { }
5678 //UNSUP | yWILDCARD bins_keyword id/*bin_identifier*/ bins_orBraE '=' '{' open_range_list '}' yWITH__CUR '{' cgexpr ')' iffE { }
5679 //UNSUP //
5680 //UNSUP // // cgexpr part of trans_list
5681 //UNSUP //
5682 //UNSUP | /**/ bins_keyword id/*bin_identifier*/ bins_orBraE '=' trans_list iffE { }
5683 //UNSUP | yWILDCARD bins_keyword id/*bin_identifier*/ bins_orBraE '=' trans_list iffE { }
5684 //UNSUP //
5685 //UNSUP | bins_keyword id/*bin_identifier*/ bins_orBraE '=' yDEFAULT iffE { }
5686 //UNSUP //
5687 //UNSUP | bins_keyword id/*bin_identifier*/ bins_orBraE '=' yDEFAULT ySEQUENCE iffE { }
5688 //UNSUP ;
5689
5690 //UNSUPbins_orBraE<nodep>: // IEEE: part of bins_or_options:
5691 //UNSUP /* empty */ { $$ = nullptr; }
5692 //UNSUP | '[' ']' { }
5693 //UNSUP | '[' cgexpr ']' { }
5694 //UNSUP ;
5695
5696 //UNSUPbins_keyword: // ==IEEE: bins_keyword
5697 //UNSUP yBINS { }
5698 //UNSUP | yILLEGAL_BINS { }
5699 //UNSUP | yIGNORE_BINS { }
5700 //UNSUP ;
5701
5702 //UNSUPcovergroup_range_list: // ==IEEE: covergroup_range_list
5703 //UNSUP covergroup_value_range { $$ = $1; }
5704 //UNSUP | covergroup_range_list ',' covergroup_value_range { $$ = AstNode::addNextNull($1, $3); }
5705 //UNSUP ;
5706
5707 //UNSUPtrans_list: // ==IEEE: trans_list
5708 //UNSUP '(' trans_set ')' { $$ = $2; }
5709 //UNSUP | trans_list ',' '(' trans_set ')' { }
5710 //UNSUP ;
5711
5712 //UNSUPtrans_set: // ==IEEE: trans_set
5713 //UNSUP trans_range_list { $$ = $1; }
5714 //UNSUP // // Note the { => } in the grammer, this is really a list
5715 //UNSUP | trans_set yP_EQGT trans_range_list { }
5716 //UNSUP ;
5717
5718 //UNSUPtrans_range_list: // ==IEEE: trans_range_list
5719 //UNSUP trans_item { $$ = $1; }
5720 //UNSUP | trans_item yP_BRASTAR repeat_range ']' { }
5721 //UNSUP | trans_item yP_BRAMINUSGT repeat_range ']' { }
5722 //UNSUP | trans_item yP_BRAEQ repeat_range ']' { }
5723 //UNSUP ;
5724
5725 //UNSUPtrans_item: // ==IEEE: range_list
5726 //UNSUP covergroup_range_list { $$ = $1; }
5727 //UNSUP ;
5728
5729 //UNSUPrepeat_range: // ==IEEE: repeat_range
5730 //UNSUP cgexpr { $$ = $1; }
5731 //UNSUP | cgexpr ':' cgexpr { $$ = AstNode::addNextNull($1, $3); }
5732 //UNSUP ;
5733
5734 //UNSUPcover_cross: // ==IEEE: cover_cross
5735 //UNSUP id/*cover_point_identifier*/ ':' yCROSS list_of_cross_items iffE cross_body { }
5736 //UNSUP | /**/ yCROSS list_of_cross_items iffE cross_body { }
5737 //UNSUP ;
5738
5739 //UNSUPlist_of_cross_items<nodep>: // ==IEEE: list_of_cross_items
5740 //UNSUP cross_item ',' cross_item { $$ = AstNode::addNextNull($1, $3); }
5741 //UNSUP | cross_item ',' cross_item ',' cross_itemList { }
5742 //UNSUP ;
5743
5744 //UNSUPcross_itemList<nodep>: // IEEE: part of list_of_cross_items
5745 //UNSUP cross_item { $$ = nullptr; }
5746 //UNSUP | cross_itemList ',' cross_item { $$ = AstNode::addNextNull($1, $3); }
5747 //UNSUP ;
5748
5749 //UNSUPcross_item<nodep>: // ==IEEE: cross_item
5750 //UNSUP idAny/*cover_point_identifier or variable_identifier*/ { $$ = $1; }
5751 //UNSUP ;
5752
5753 //UNSUPcross_body: // ==IEEE: cross_body
5754 //UNSUP '{' '}' { $$ = nullptr; }
5755 //UNSUP // // IEEE-2012: No semicolon here, mistake in spec
5756 //UNSUP | '{' cross_body_itemSemiList '}' { $$ = $1; }
5757 //UNSUP | ';' { $$ = nullptr; }
5758 //UNSUP ;
5759
5760 //UNSUPcross_body_itemSemiList: // IEEE: part of cross_body
5761 //UNSUP cross_body_item ';' { $$ = $1; }
5762 //UNSUP | cross_body_itemSemiList cross_body_item ';' { $$ = AstNode::addNextNull($1, $2); }
5763 //UNSUP ;
5764
5765 //UNSUPcross_body_item<nodep>: // ==IEEE: cross_body_item
5766 //UNSUP // // IEEE: our semicolon is in the list
5767 //UNSUP bins_selection_or_option { $$ = $1; }
5768 //UNSUP | function_declaration { $$ = $1; }
5769 //UNSUP ;
5770
5771 //UNSUPbins_selection_or_option<nodep>: // ==IEEE: bins_selection_or_option
5772 //UNSUP coverage_option { $$ = $1; }
5773 //UNSUP | bins_selection { $$ = $1; }
5774 //UNSUP ;
5775
5776 //UNSUPbins_selection: // ==IEEE: bins_selection
5777 //UNSUP bins_keyword idAny/*new-bin_identifier*/ '=' select_expression iffE { }
5778 //UNSUP ;
5779
5780 //UNSUPselect_expression: // ==IEEE: select_expression
5781 //UNSUP // // IEEE: select_condition expanded here
5782 //UNSUP yBINSOF '(' bins_expression ')' { }
5783 //UNSUP | yBINSOF '(' bins_expression ')' yINTERSECT '{' covergroup_range_list '}' { }
5784 //UNSUP | yWITH__PAREN '(' cgexpr ')' { }
5785 //UNSUP // // IEEE-2012: Need clarification as to precedence
5786 //UNSUP //UNSUP yWITH__PAREN '(' cgexpr ')' yMATCHES cgexpr { }
5787 //UNSUP | '!' yBINSOF '(' bins_expression ')' { }
5788 //UNSUP | '!' yBINSOF '(' bins_expression ')' yINTERSECT '{' covergroup_range_list '}' { }
5789 //UNSUP | '!' yWITH__PAREN '(' cgexpr ')' { }
5790 //UNSUP // // IEEE-2012: Need clarification as to precedence
5791 //UNSUP //UNSUP '!' yWITH__PAREN '(' cgexpr ')' yMATCHES cgexpr { }
5792 //UNSUP | select_expression yP_ANDAND select_expression { }
5793 //UNSUP | select_expression yP_OROR select_expression { }
5794 //UNSUP | '(' select_expression ')' { $$ = $2; }
5795 //UNSUP // // IEEE-2012: cross_identifier
5796 //UNSUP // // Part of covergroup_expression - generic identifier
5797 //UNSUP // // IEEE-2012: Need clarification as to precedence
5798 //UNSUP //UNSUP covergroup_expression [ yMATCHES covergroup_expression ]
5799 //UNSUP ;
5800
5801 //UNSUPbins_expression: // ==IEEE: bins_expression
5802 //UNSUP // // "cover_point_identifier" and "variable_identifier" look identical
5803 //UNSUP id/*variable_identifier or cover_point_identifier*/ { $$ = $1; }
5804 //UNSUP | id/*cover_point_identifier*/ '.' idAny/*bins_identifier*/ { }
5805 //UNSUP ;
5806
5807 //UNSUPcoverage_eventE: // IEEE: [ coverage_event ]
5808 //UNSUP /* empty */ { $$ = nullptr; }
5809 //UNSUP | clocking_event { $$ = $1; }
5810 //UNSUP | yWITH__ETC function idAny/*"sample"*/ '(' tf_port_listE ')' { }
5811 //UNSUP | yP_ATAT '(' block_event_expression ')' { }
5812 //UNSUP ;
5813
5814 //UNSUPblock_event_expression: // ==IEEE: block_event_expression
5815 //UNSUP block_event_expressionTerm { $$ = $1; }
5816 //UNSUP | block_event_expression yOR block_event_expressionTerm { }
5817 //UNSUP ;
5818
5819 //UNSUPblock_event_expressionTerm: // IEEE: part of block_event_expression
5820 //UNSUP yBEGIN hierarchical_btf_identifier { }
5821 //UNSUP | yEND hierarchical_btf_identifier { }
5822 //UNSUP ;
5823
5824 //UNSUPhierarchical_btf_identifier: // ==IEEE: hierarchical_btf_identifier
5825 //UNSUP // // hierarchical_tf_identifier + hierarchical_block_identifier
5826 //UNSUP hierarchical_identifier/*tf_or_block*/ { $$ = $1; }
5827 //UNSUP // // method_identifier
5828 //UNSUP | hierarchical_identifier class_scope_id { }
5829 //UNSUP | hierarchical_identifier id { }
5830 //UNSUP ;
5831
5832 //**********************************************************************
5833 // Randsequence
5834
5835 //UNSUPrandsequence_statement<nodep>: // ==IEEE: randsequence_statement
5836 //UNSUP yRANDSEQUENCE '(' ')' productionList yENDSEQUENCE { }
5837 //UNSUP | yRANDSEQUENCE '(' id/*production_identifier*/ ')' productionList yENDSEQUENCE { }
5838 //UNSUP ;
5839
5840 //UNSUPproductionList<nodep>: // IEEE: production+
5841 //UNSUP production { $$ = $1; }
5842 //UNSUP | productionList production { $$ = AstNode::addNextNull($1, $2); }
5843 //UNSUP ;
5844
5845 //UNSUPproduction<nodep>: // ==IEEE: production
5846 //UNSUP productionFront ':' rs_ruleList ';' { }
5847 //UNSUP ;
5848
5849 //UNSUPproductionFront<nodep>: // IEEE: part of production
5850 //UNSUP function_data_type id/*production_identifier*/ { }
5851 //UNSUP | /**/ id/*production_identifier*/ { $$ = $1; }
5852 //UNSUP | function_data_type id/*production_identifier*/ '(' tf_port_listE ')' { }
5853 //UNSUP | /**/ id/*production_identifier*/ '(' tf_port_listE ')' { }
5854 //UNSUP ;
5855
5856 //UNSUPrs_ruleList<nodep>: // IEEE: rs_rule+ part of production
5857 //UNSUP rs_rule { $$ = $1; }
5858 //UNSUP | rs_ruleList '|' rs_rule { $$ = AstNode::addNextNull($1, $3); }
5859 //UNSUP ;
5860
5861 //UNSUPrs_rule<nodep>: // ==IEEE: rs_rule
5862 //UNSUP rs_production_list { $$ = $1; }
5863 //UNSUP | rs_production_list yP_COLONEQ weight_specification { }
5864 //UNSUP | rs_production_list yP_COLONEQ weight_specification rs_code_block { }
5865 //UNSUP ;
5866
5867 //UNSUPrs_production_list<nodep>: // ==IEEE: rs_production_list
5868 //UNSUP rs_prodList { $$ = $1; }
5869 //UNSUP | yRAND yJOIN /**/ production_item production_itemList { }
5870 //UNSUP | yRAND yJOIN '(' expr ')' production_item production_itemList { }
5871 //UNSUP ;
5872
5873 //UNSUPweight_specification<nodep>: // ==IEEE: weight_specification
5874 //UNSUP yaINTNUM { $$ = $1; }
5875 //UNSUP | idClassSel/*ps_identifier*/ { $$ = $1; }
5876 //UNSUP | '(' expr ')' { $$ = $2; }
5877 //UNSUP ;
5878
5879 //UNSUPrs_code_block<nodep>: // ==IEEE: rs_code_block
5880 //UNSUP '{' '}' { $$ = nullptr; }
5881 //UNSUP | '{' rs_code_blockItemList '}' { $$ = $2; }
5882 //UNSUP ;
5883
5884 //UNSUPrs_code_blockItemList<nodep>: // IEEE: part of rs_code_block
5885 //UNSUP rs_code_blockItem { $$ = $1; }
5886 //UNSUP | rs_code_blockItemList rs_code_blockItem { $$ = AstNode::addNextNull($1, $2); }
5887 //UNSUP ;
5888
5889 //UNSUPrs_code_blockItem<nodep>: // IEEE: part of rs_code_block
5890 //UNSUP data_declaration { $$ = $1; }
5891 //UNSUP | stmt { $$ = $1; }
5892 //UNSUP ;
5893
5894 //UNSUPrs_prodList<nodep>: // IEEE: rs_prod+
5895 //UNSUP rs_prod { $$ = $1; }
5896 //UNSUP | rs_prodList rs_prod { $$ = AstNode::addNextNull($1, $2); }
5897 //UNSUP ;
5898
5899 //UNSUPrs_prod<nodep>: // ==IEEE: rs_prod
5900 //UNSUP production_item { $$ = $1; }
5901 //UNSUP | rs_code_block { $$ = $1; }
5902 //UNSUP // // IEEE: rs_if_else
5903 //UNSUP | yIF '(' expr ')' production_item %prec prLOWER_THAN_ELSE { }
5904 //UNSUP | yIF '(' expr ')' production_item yELSE production_item { }
5905 //UNSUP // // IEEE: rs_repeat
5906 //UNSUP | yREPEAT '(' expr ')' production_item { }
5907 //UNSUP // // IEEE: rs_case
5908 //UNSUP | yCASE '(' expr ')' rs_case_itemList yENDCASE { }
5909 //UNSUP ;
5910
5911 //UNSUPproduction_itemList<nodep>: // IEEE: production_item+
5912 //UNSUP production_item { $$ = $1; }
5913 //UNSUP | production_itemList production_item { $$ = AstNode::addNextNull($1, $2); }
5914 //UNSUP ;
5915
5916 //UNSUPproduction_item<nodep>: // ==IEEE: production_item
5917 //UNSUP id/*production_identifier*/ { $$ = $1; }
5918 //UNSUP | id/*production_identifier*/ '(' list_of_argumentsE ')' { }
5919 //UNSUP ;
5920
5921 //UNSUPrs_case_itemList<nodep>: // IEEE: rs_case_item+
5922 //UNSUP rs_case_item { $$ = $1; }
5923 //UNSUP | rs_case_itemList rs_case_item { $$ = AstNode::addNextNull($1, $2); }
5924 //UNSUP ;
5925
5926 //UNSUPrs_case_item<nodep>: // ==IEEE: rs_case_item
5927 //UNSUP caseCondList ':' production_item ';' { }
5928 //UNSUP | yDEFAULT production_item ';' { }
5929 //UNSUP | yDEFAULT ':' production_item ';' { }
5930 //UNSUP ;
5931
5932 //**********************************************************************
5933 // Checker
5934
5935 //UNSUPchecker_declaration<nodep>: // ==IEEE: part of checker_declaration
5936 //UNSUP checkerFront checker_port_listE ';'
5937 //UNSUP checker_or_generate_itemListE yENDCHECKER endLabelE
5938 //UNSUP { SYMP->popScope($$); }
5939 //UNSUP ;
5940
5941 //UNSUPcheckerFront<nodep>: // IEEE: part of checker_declaration
5942 //UNSUP yCHECKER idAny/*checker_identifier*/
5943 //UNSUP { SYMP->pushNew($$); }
5944 //UNSUP ;
5945
5946 //UNSUPchecker_port_listE<nodep>: // IEEE: [ ( [ checker_port_list ] ) ]
5947 //UNSUP // // checker_port_item is basically the same as property_port_item, minus yLOCAL::
5948 //UNSUP // // Want to bet 1800-2012 adds local to checkers?
5949 //UNSUP property_port_listE { $$ = $1; }
5950 //UNSUP ;
5951
5952 //UNSUPchecker_or_generate_itemListE<nodep>: // IEEE: [{ checker_or_generate_itemList }]
5953 //UNSUP /* empty */ { $$ = nullptr; }
5954 //UNSUP | checker_or_generate_itemList { $$ = $1; }
5955 //UNSUP ;
5956
5957 //UNSUPchecker_or_generate_itemList<nodep>: // IEEE: { checker_or_generate_itemList }
5958 //UNSUP checker_or_generate_item { $$ = $1; }
5959 //UNSUP | checker_or_generate_itemList checker_or_generate_item { $$ = AstNode::addNextNull($1, $2); }
5960 //UNSUP ;
5961
5962 //UNSUPchecker_or_generate_item<nodep>: // ==IEEE: checker_or_generate_item
5963 //UNSUP checker_or_generate_item_declaration { $$ = $1; }
5964 //UNSUP | initial_construct { $$ = $1; }
5965 //UNSUP // // IEEE: checker_construct
5966 //UNSUP | yALWAYS stmtBlock { }
5967 //UNSUP | final_construct { $$ = $1; }
5968 //UNSUP | assertion_item { $$ = $1; }
5969 //UNSUP | continuous_assign { $$ = $1; }
5970 //UNSUP | checker_generate_item { $$ = $1; }
5971 //UNSUP ;
5972
5973 //UNSUPchecker_or_generate_item_declaration<nodep>: // ==IEEE: checker_or_generate_item_declaration
5974 //UNSUP data_declaration { $$ = $1; }
5975 //UNSUP | yRAND data_declaration { }
5976 //UNSUP | function_declaration { $$ = $1; }
5977 //UNSUP | checker_declaration { $$ = $1; }
5978 //UNSUP | assertion_item_declaration { $$ = $1; }
5979 //UNSUP | covergroup_declaration { $$ = $1; }
5980 //UNSUP // // IEEE deprecated: overload_declaration
5981 //UNSUP | genvar_declaration { $$ = $1; }
5982 //UNSUP | clocking_declaration { $$ = $1; }
5983 //UNSUP | yDEFAULT yCLOCKING id/*clocking_identifier*/ ';' { }
5984 //UNSUP | yDEFAULT yDISABLE yIFF expr/*expression_or_dist*/ ';' { }
5985 //UNSUP | ';' { $$ = nullptr; }
5986 //UNSUP ;
5987
5988 //UNSUPchecker_generate_item<nodep>: // ==IEEE: checker_generate_item
5989 //UNSUP // // Specialized for checker so need "c_" prefixes here
5990 //UNSUP c_loop_generate_construct { $$ = $1; }
5991 //UNSUP | c_conditional_generate_construct { $$ = $1; }
5992 //UNSUP | c_generate_region { $$ = $1; }
5993 //UNSUP //
5994 //UNSUP | elaboration_system_task { $$ = $1; }
5995 //UNSUP ;
5996
5997 //UNSUPchecker_instantiation<nodep>:
5998 //UNSUP // // Only used for procedural_assertion_item's
5999 //UNSUP // // Version in concurrent_assertion_item looks like etcInst
6000 //UNSUP // // Thus instead of *_checker_port_connection we can use etcInst's cellpinList
6001 //UNSUP id/*checker_identifier*/ id '(' cellpinList ')' ';' { }
6002 //UNSUP ;
6003
6004 //**********************************************************************
6005 // Class
6006
6007 class_declaration<nodep>: // ==IEEE: part of class_declaration
6008 // // IEEE-2012: using this also for interface_class_declaration
6009 // // The classExtendsE rule relys on classFront having the
6010 // // new class scope correct via classFront
6011 classFront parameter_port_listE classExtendsE classImplementsE ';'
6012 /*mid*/ { // Allow resolving types declared in base extends class
6013 if ($<scp>3) SYMP->importExtends($<scp>3);
6014 }
6015 /*cont*/ class_itemListE yENDCLASS endLabelE
6016 { $$ = $1; $1->addMembersp($2);
6017 $1->extendsp($3);
6018 $1->addMembersp($4);
6019 $1->addMembersp($7);
6020 SYMP->popScope($$);
6021 GRAMMARP->endLabel($<fl>7, $1, $9); }
6022 ;
6023
6024 classFront<classp>: // IEEE: part of class_declaration
6025 classVirtualE yCLASS lifetimeE idAny/*class_identifier*/
6026 { $$ = new AstClass($2, *$4);
6027 $$->isVirtual($1);
6028 $$->lifetime($3);
6029 SYMP->pushNew($<classp>$); }
6030 // // IEEE: part of interface_class_declaration
6031 | yINTERFACE yCLASS lifetimeE idAny/*class_identifier*/
6032 { $$ = new AstClass($2, *$4);
6033 $$->lifetime($3);
6034 SYMP->pushNew($<classp>$);
6035 BBUNSUP($2, "Unsupported: interface classes"); }
6036 ;
6037
6038 classVirtualE<cbool>:
6039 /* empty */ { $$ = false; }
6040 | yVIRTUAL__CLASS { $$ = true; }
6041 ;
6042
6043 classExtendsE<nodep>: // IEEE: part of class_declaration
6044 // // The classExtendsE rule relys on classFront having the
6045 // // new class scope correct via classFront
6046 /* empty */ { $$ = nullptr; $<scp>$ = nullptr; }
6047 | yEXTENDS classExtendsList { $$ = $2; $<scp>$ = $<scp>2; }
6048 ;
6049
6050 classExtendsList<nodep>: // IEEE: part of class_declaration
6051 classExtendsOne { $$ = $1; $<scp>$ = $<scp>1; }
6052 | classExtendsList ',' classExtendsOne
6053 { $$ = $3; $<scp>$ = $<scp>3;
6054 BBUNSUP($3, "Multiple inheritance illegal on non-interface classes (IEEE 1800-2017 8.13), "
6055 "and unsupported for interface classes."); }
6056 ;
6057
6058 classExtendsOne<nodep>: // IEEE: part of class_declaration
6059 class_typeExtImpList
6060 { $$ = new AstClassExtends($1->fileline(), $1);
6061 $<scp>$ = $<scp>1; }
6062 //
6063 | class_typeExtImpList '(' list_of_argumentsE ')'
6064 { $$ = new AstClassExtends($1->fileline(), $1);
6065 $<scp>$ = $<scp>1;
6066 if ($3) BBUNSUP($3, "Unsupported: extends with parameters"); }
6067 ;
6068
6069 classImplementsE<nodep>: // IEEE: part of class_declaration
6070 // // All 1800-2012
6071 /* empty */ { $$ = nullptr; }
6072 | yIMPLEMENTS classImplementsList { $$ = $2; }
6073 ;
6074
6075 classImplementsList<nodep>: // IEEE: part of class_declaration
6076 // // All 1800-2012
6077 class_typeExtImpList { $$ = nullptr; BBUNSUP($1, "Unsupported: implements class"); }
6078 | classImplementsList ',' class_typeExtImpList { $$ = AstNode::addNextNull($1, $3); }
6079 ;
6080
6081 class_typeExtImpList<nodep>: // IEEE: class_type: "[package_scope] id [ parameter_value_assignment ]"
6082 // // but allow yaID__aTYPE for extends/implements
6083 // // If you follow the rules down, class_type is really a list via ps_class_identifier
6084 class_typeExtImpOne { $$ = $1; $<scp>$ = $<scp>1; }
6085 | class_typeExtImpList yP_COLONCOLON class_typeExtImpOne
6086 { $$ = $3; $<scp>$ = $<scp>1;
6087 // Cannot just add as next() as that breaks implements lists
6088 //UNSUP $$ = new AstDot($<fl>1, true, $1, $3);
6089 BBUNSUP($2, "Unsupported: Hierarchical class references"); }
6090 ;
6091
6092 class_typeExtImpOne<nodep>: // part of IEEE: class_type, where we either get a package_scope component or class
6093 // // If you follow the rules down, class_type is really a list via ps_class_identifier
6094 // // Not listed in IEEE, but see bug627 any parameter type maybe a class
6095 // // If idAny below is a class, parameter_value is legal
6096 // // If idAny below is a package, parameter_value is not legal
6097 // // If idAny below is otherwise, not legal
6098 idAny
6099 /*mid*/ { /* no nextId as not refing it above this*/ }
6100 /*cont*/ parameter_value_assignmentE
6101 { $$ = new AstClassOrPackageRef($<fl>1, *$1, $<scp>1, $3);
6102 $<scp>$ = $<scp>1; }
6103 //
6104 // // package_sopeIdFollows expanded
6105 | yD_UNIT yP_COLONCOLON
6106 { $$ = new AstClassOrPackageRef($<fl>1, "$unit", nullptr, nullptr);
6107 $<scp>$ = nullptr; // No purpose otherwise, every symtab can see root
6108 SYMP->nextId(PARSEP->rootp()); }
6109 //
6110 | yLOCAL__COLONCOLON yP_COLONCOLON
6111 { $$ = new AstClassOrPackageRef($<fl>1, "local::", nullptr, nullptr);
6112 $<scp>$ = nullptr; // UNSUP
6113 SYMP->nextId(PARSEP->rootp());
6114 BBUNSUP($1, "Unsupported: Randomize 'local::'"); }
6115 ;
6116
6117 //=========
6118 // Package scoping - to traverse the symbol table properly, the final identifer
6119 // must be included in the rules below.
6120 // Each of these must end with {symsPackageDone | symsClassDone}
6121
6122 //=== Below rules assume special scoping per above
6123
6124 packageClassScopeNoId<nodep>: // IEEE: [package_scope] not followed by yaID
6125 packageClassScope { $$ = $1; $<scp>$ = $<scp>1; SYMP->nextId(nullptr); }
6126 ;
6127
6128 packageClassScopeE<nodep>: // IEEE: [package_scope]
6129 // // IMPORTANT: The lexer will parse the following ID to be in the found package
6130 // // if not needed must use packageClassScopeNoId
6131 // // TODO: To support classes should return generic type, not packagep
6132 // // class_qualifier := [ yLOCAL '::' ] [ implicit_class_handle '.' class_scope ]
6133 /* empty */ { $$ = nullptr; $<scp>$ = nullptr; }
6134 | packageClassScope { $$ = $1; $<scp>$ = $<scp>1; }
6135 ;
6136
6137 packageClassScope<nodep>: // IEEE: class_scope
6138 // // IEEE: "class_type yP_COLONCOLON"
6139 // // IMPORTANT: The lexer will parse the following ID to be in the found package
6140 // // if not needed must use packageClassScopeNoId
6141 // // In this parser <package_identifier>:: and <class_identifier>:: are indistinguishible
6142 // // This copies <scp> to document it is important
6143 packageClassScopeList { $$ = $1; $<scp>$ = $<scp>1; }
6144 | localNextId yP_COLONCOLON { $$ = $1; $<scp>$ = $<scp>1; }
6145 | dollarUnitNextId yP_COLONCOLON { $$ = $1; $<scp>$ = $<scp>1; }
6146 | dollarUnitNextId yP_COLONCOLON packageClassScopeList
6147 { $$ = new AstDot($2, true, $1, $3); $<scp>$ = $<scp>3; }
6148 ;
6149
6150 packageClassScopeList<nodep>: // IEEE: class_type: "id [ parameter_value_assignment ]" but allow yaID__aTYPE
6151 // // Or IEEE: [package_scope]
6152 // // IMPORTANT: The lexer will parse the following ID to be in the found package
6153 // // if not needed must use packageClassScopeNoId
6154 // // In this parser <package_identifier>:: and <class_identifier>:: are indistinguishible
6155 // // If you follow the rules down, class_type is really a list via ps_class_identifier
6156 packageClassScopeItem { $$ = $1; $<scp>$ = $<scp>1; }
6157 | packageClassScopeList packageClassScopeItem
6158 { $$ = new AstDot($<fl>2, true, $1, $2); $<scp>$ = $<scp>2; }
6159 ;
6160
6161 packageClassScopeItem<nodep>: // IEEE: package_scope or [package_scope]::[class_scope]
6162 // // IMPORTANT: The lexer will parse the following ID to be in the found package
6163 // // if not needed must use packageClassScopeNoId
6164 // // IEEE: class_type: "id [ parameter_value_assignment ]" but allow yaID__aTYPE
6165 // //vv mid rule action needed otherwise we might not have NextId in time to parse the id token
6166 idCC
6167 /*mid*/ { SYMP->nextId($<scp>1); }
6168 /*cont*/ yP_COLONCOLON
6169 { $$ = new AstClassOrPackageRef($<fl>1, *$1, $<scp>1, nullptr); $<scp>$ = $<scp>1; }
6170 //
6171 | idCC parameter_value_assignment
6172 /*mid*/ { SYMP->nextId($<scp>1); } // Change next *after* we handle parameters, not before
6173 /*cont*/ yP_COLONCOLON
6174 { $$ = new AstClassOrPackageRef($<fl>1, *$1, $<scp>1, $2); $<scp>$ = $<scp>1; }
6175 ;
6176
6177 dollarUnitNextId<nodep>: // $unit
6178 // // IMPORTANT: The lexer will parse the following ID to be in the found package
6179 // // if not needed must use packageClassScopeNoId
6180 // // Must call nextId without any additional tokens following
6181 yD_UNIT
6182 { $$ = new AstClassOrPackageRef{$1, "$unit", PARSEP->unitPackage($<fl>1), nullptr};
6183 SYMP->nextId(PARSEP->rootp()); }
6184 ;
6185
6186 localNextId<nodep>: // local
6187 // // IMPORTANT: The lexer will parse the following ID to be in the found package
6188 // // if not needed must use packageClassScopeNoId
6189 // // Must call nextId without any additional tokens following
6190 yLOCAL__COLONCOLON
6191 { $$ = new AstClassOrPackageRef{$1, "local::", PARSEP->unitPackage($<fl>1), nullptr};
6192 SYMP->nextId(PARSEP->rootp());
6193 BBUNSUP($<fl>1, "Unsupported: Randomize 'local::'"); }
6194 ;
6195
6196 //^^^=========
6197
6198 class_itemListE<nodep>:
6199 /* empty */ { $$ = nullptr; }
6200 | class_itemList { $$ = $1; }
6201 ;
6202
6203 class_itemList<nodep>:
6204 class_item { $$ = $1; }
6205 | class_itemList class_item { $$ = AstNode::addNextNull($1, $2); }
6206 ;
6207
6208 class_item<nodep>: // ==IEEE: class_item
6209 class_property { $$ = $1; }
6210 | class_method { $$ = $1; }
6211 | class_constraint { $$ = $1; }
6212 //
6213 | class_declaration
6214 { $$ = nullptr; BBUNSUP($1, "Unsupported: class within class"); }
6215 | timeunits_declaration { $$ = $1; }
6216 //UNSUP covergroup_declaration { $$ = $1; }
6217 // // local_parameter_declaration under parameter_declaration
6218 | parameter_declaration ';'
6219 { $$ = $1; BBUNSUP($2, "Unsupported: class parameters"); } // 1800-2009
6220 | ';' { $$ = nullptr; }
6221 //
6222 | error ';' { $$ = nullptr; }
6223 ;
6224
6225 class_method<nodep>: // ==IEEE: class_method
6226 memberQualListE task_declaration { $$ = $2; $1.applyToNodes($2); }
6227 | memberQualListE function_declaration { $$ = $2; $1.applyToNodes($2); }
6228 | yPURE yVIRTUAL__ETC memberQualListE method_prototype ';'
6229 { $$ = $4; $3.applyToNodes($4); $4->pureVirtual(true); $4->isVirtual(true); }
6230 | yEXTERN memberQualListE method_prototype ';'
6231 { $$ = $3; $2.applyToNodes($3); $3->isExternProto(true); }
6232 // // IEEE: "method_qualifierE class_constructor_declaration"
6233 // // part of function_declaration
6234 | yEXTERN memberQualListE class_constructor_prototype
6235 { $$ = $3; $2.applyToNodes($3); $3->isExternProto(true); }
6236 ;
6237
6238 // IEEE: class_constructor_prototype
6239 // See function_declaration
6240
6241 memberQualListE<qualifiers>: // Called from class_property for all qualifiers before yVAR
6242 // // Also before method declarations, to prevent grammar conflict
6243 // // Thus both types of qualifiers (method/property) are here
6244 /*empty*/ { $$ = VMemberQualifiers::none(); }
6245 | memberQualList { $$ = $1; }
6246 ;
6247
6248 memberQualList<qualifiers>:
6249 memberQualOne { $$ = $1; }
6250 | memberQualList memberQualOne { $$ = VMemberQualifiers::combine($1, $2); }
6251 ;
6252
6253 memberQualOne<qualifiers>: // IEEE: property_qualifier + method_qualifier
6254 // // Part of method_qualifier and property_qualifier
6255 // // IMPORTANT: yPROTECTED | yLOCAL is in a lex rule
6256 yPROTECTED { $$ = VMemberQualifiers::none(); $$.m_protected = true; }
6257 | yLOCAL__ETC { $$ = VMemberQualifiers::none(); $$.m_local = true; }
6258 | ySTATIC__ETC { $$ = VMemberQualifiers::none(); $$.m_static = true; }
6259 // // Part of method_qualifier only
6260 | yVIRTUAL__ETC { $$ = VMemberQualifiers::none(); $$.m_virtual = true; }
6261 // // Part of property_qualifier only
6262 | random_qualifier { $$ = $1; }
6263 // // Part of lifetime, but here as ySTATIC can be in different positions
6264 | yAUTOMATIC { $$ = VMemberQualifiers::none(); $$.m_automatic = true; }
6265 // // Part of data_declaration, but not in data_declarationVarFrontClass
6266 | yCONST__ETC { $$ = VMemberQualifiers::none(); $$.m_const = true; }
6267 ;
6268
6269 //**********************************************************************
6270 // Constraints
6271
6272 class_constraint<nodep>: // ==IEEE: class_constraint
6273 // // IEEE: constraint_declaration
6274 // // UNSUP: We have the unsupported warning on the randomize() call, so don't bother on
6275 // // constraint blocks. When we support randomize we need to make AST nodes for below rules
6276 constraintStaticE yCONSTRAINT idAny constraint_block { $$ = nullptr; /*UNSUP*/ }
6277 // // IEEE: constraint_prototype + constraint_prototype_qualifier
6278 | constraintStaticE yCONSTRAINT idAny ';' { $$ = nullptr; }
6279 | yEXTERN constraintStaticE yCONSTRAINT idAny ';'
6280 { $$ = nullptr; BBUNSUP($1, "Unsupported: extern constraint"); }
6281 | yPURE constraintStaticE yCONSTRAINT idAny ';'
6282 { $$ = nullptr; BBUNSUP($1, "Unsupported: pure constraint"); }
6283 ;
6284
6285 constraint_block<nodep>: // ==IEEE: constraint_block
6286 '{' constraint_block_itemList '}' { $$ = $2; }
6287 ;
6288
6289 constraint_block_itemList<nodep>: // IEEE: { constraint_block_item }
6290 constraint_block_item { $$ = $1; }
6291 | constraint_block_itemList constraint_block_item { $$ = AstNode::addNextNull($1, $2); }
6292 ;
6293
6294 constraint_block_item<nodep>: // ==IEEE: constraint_block_item
6295 constraint_expression { $$ = $1; }
6296 | ySOLVE solve_before_list yBEFORE solve_before_list ';'
6297 { $$ = nullptr; BBUNSUP($2, "Unsupported: solve before"); }
6298 ;
6299
6300 solve_before_list<nodep>: // ==IEEE: solve_before_list
6301 constraint_primary { $$ = $1; }
6302 | solve_before_list ',' constraint_primary { $$ = AstNode::addNextNull($1, $3); }
6303 ;
6304
6305 constraint_primary<nodep>: // ==IEEE: constraint_primary
6306 // // exprScope more general than: [ implicit_class_handle '.' | class_scope ] hierarchical_identifier select
6307 exprScope { $$ = $1; }
6308 ;
6309
6310 constraint_expressionList<nodep>: // ==IEEE: { constraint_expression }
6311 constraint_expression { $$ = $1; }
6312 | constraint_expressionList constraint_expression { $$ = AstNode::addNextNull($1, $2); }
6313 ;
6314
6315 constraint_expression<nodep>: // ==IEEE: constraint_expression
6316 expr/*expression_or_dist*/ ';' { $$ = $1; }
6317 // // 1800-2012:
6318 | ySOFT expr/*expression_or_dist*/ ';' { $$ = nullptr; /*UNSUP-no-UVM*/ }
6319 // // 1800-2012:
6320 // // IEEE: uniqueness_constraint ';'
6321 | yUNIQUE '{' open_range_list '}' { $$ = nullptr; /*UNSUP-no-UVM*/ }
6322 // // IEEE: expr yP_MINUSGT constraint_set
6323 // // Conflicts with expr:"expr yP_MINUSGT expr"; rule moved there
6324 //
6325 | yIF '(' expr ')' constraint_set %prec prLOWER_THAN_ELSE { $$ = nullptr; /*UNSUP-UVM*/ }
6326 | yIF '(' expr ')' constraint_set yELSE constraint_set { $$ = nullptr; /*UNSUP-UVM*/ }
6327 // // IEEE says array_identifier here, but dotted accepted in VMM + 1800-2009
6328 | yFOREACH '(' idClassSelForeach ')' constraint_set { $$ = nullptr; /*UNSUP-UVM*/ }
6329 // // soft is 1800-2012
6330 | yDISABLE ySOFT expr/*constraint_primary*/ ';' { $$ = nullptr; /*UNSUP-no-UVM*/ }
6331 ;
6332
6333 constraint_set<nodep>: // ==IEEE: constraint_set
6334 constraint_expression { $$ = $1; }
6335 | '{' constraint_expressionList '}' { $$ = $2; }
6336 ;
6337
6338 dist_list<nodep>: // ==IEEE: dist_list
6339 dist_item { $$ = $1; }
6340 | dist_list ',' dist_item { $$ = AstNode::addNextNull($1, $3); }
6341 ;
6342
6343 dist_item<nodep>: // ==IEEE: dist_item + dist_weight
6344 value_range { $$ = $1; /* Same as := 1 */ }
6345 | value_range yP_COLONEQ expr { $$ = $1; /*UNSUP-no-UVM*/ }
6346 | value_range yP_COLONDIV expr { $$ = $1; /*UNSUP-no-UVM*/ }
6347 ;
6348
6349 //UNSUPextern_constraint_declaration: // ==IEEE: extern_constraint_declaration
6350 //UNSUP constraintStaticE yCONSTRAINT class_scope_id constraint_block { }
6351 //UNSUP ;
6352
6353 constraintStaticE<cbool>: // IEEE: part of extern_constraint_declaration
6354 /* empty */ { $$ = false; }
6355 | ySTATIC__CONSTRAINT { $$ = true; }
6356 ;
6357
6358 //**********************************************************************
6359 // Constants
6360
6361 timeNumAdjusted<nodep>: // Time constant, adjusted to module's time units/precision
6362 yaTIMENUM
6363 { $$ = new AstTimeImport($<fl>1, new AstConst($<fl>1, AstConst::RealDouble(), $1)); }
6364 ;
6365
6366 //**********************************************************************
6367 // Generic tokens
6368
6369 colon<fl>: // Generic colon that isn't making a label (e.g. in a case_item)
6370 ':' { $$ = $1; }
6371 | yP_COLON__BEGIN { $$ = $1; }
6372 | yP_COLON__FORK { $$ = $1; }
6373 ;
6374
6375 //**********************************************************************
6376 // VLT Files
6377
6378 vltItem:
6379
6380 vltOffFront { V3Config::addIgnore($1, false, "*", 0, 0); }
6381 | vltOffFront yVLT_D_FILE yaSTRING
6382 { V3Config::addIgnore($1, false, *$3, 0, 0); }
6383 | vltOffFront yVLT_D_FILE yaSTRING yVLT_D_LINES yaINTNUM
6384 { V3Config::addIgnore($1, false, *$3, $5->toUInt(), $5->toUInt()+1); }
6385 | vltOffFront yVLT_D_FILE yaSTRING yVLT_D_LINES yaINTNUM '-' yaINTNUM
6386 { V3Config::addIgnore($1, false, *$3, $5->toUInt(), $7->toUInt()+1); }
6387 | vltOffFront yVLT_D_FILE yaSTRING yVLT_D_MATCH yaSTRING
6388 { if (($1 == V3ErrorCode::I_COVERAGE) || ($1 == V3ErrorCode::I_TRACING)) {
6389 $<fl>1->v3error("Argument -match only supported for lint_off");
6390 } else {
6391 V3Config::addWaiver($1,*$3,*$5);
6392 }}
6393 | vltOnFront { V3Config::addIgnore($1, true, "*", 0, 0); }
6394 | vltOnFront yVLT_D_FILE yaSTRING
6395 { V3Config::addIgnore($1, true, *$3, 0, 0); }
6396 | vltOnFront yVLT_D_FILE yaSTRING yVLT_D_LINES yaINTNUM
6397 { V3Config::addIgnore($1, true, *$3, $5->toUInt(), $5->toUInt()+1); }
6398 | vltOnFront yVLT_D_FILE yaSTRING yVLT_D_LINES yaINTNUM '-' yaINTNUM
6399 { V3Config::addIgnore($1, true, *$3, $5->toUInt(), $7->toUInt()+1); }
6400 | vltVarAttrFront vltDModuleE vltDFTaskE vltVarAttrVarE attr_event_controlE
6401 { V3Config::addVarAttr($<fl>1, *$2, *$3, *$4, $1, $5); }
6402 | vltInlineFront vltDModuleE vltDFTaskE
6403 { V3Config::addInline($<fl>1, *$2, *$3, $1); }
6404 | yVLT_COVERAGE_BLOCK_OFF yVLT_D_FILE yaSTRING
6405 { V3Config::addCoverageBlockOff(*$3, 0); }
6406 | yVLT_COVERAGE_BLOCK_OFF yVLT_D_FILE yaSTRING yVLT_D_LINES yaINTNUM
6407 { V3Config::addCoverageBlockOff(*$3, $5->toUInt()); }
6408 | yVLT_COVERAGE_BLOCK_OFF yVLT_D_MODULE yaSTRING yVLT_D_BLOCK yaSTRING
6409 { V3Config::addCoverageBlockOff(*$3, *$5); }
6410 | yVLT_FULL_CASE yVLT_D_FILE yaSTRING
6411 { V3Config::addCaseFull(*$3, 0); }
6412 | yVLT_FULL_CASE yVLT_D_FILE yaSTRING yVLT_D_LINES yaINTNUM
6413 { V3Config::addCaseFull(*$3, $5->toUInt()); }
6414 | yVLT_HIER_BLOCK vltDModuleE
6415 { V3Config::addModulePragma(*$2, AstPragmaType::HIER_BLOCK); }
6416 | yVLT_PARALLEL_CASE yVLT_D_FILE yaSTRING
6417 { V3Config::addCaseParallel(*$3, 0); }
6418 | yVLT_PARALLEL_CASE yVLT_D_FILE yaSTRING yVLT_D_LINES yaINTNUM
6419 { V3Config::addCaseParallel(*$3, $5->toUInt()); }
6420 | yVLT_PROFILE_DATA yVLT_D_MODEL yaSTRING yVLT_D_MTASK yaSTRING yVLT_D_COST yaINTNUM
6421 { V3Config::addProfileData($<fl>1, *$3, *$5, $7->toUQuad()); }
6422 ;
6423
6424 vltOffFront<errcodeen>:
6425 yVLT_COVERAGE_OFF { $$ = V3ErrorCode::I_COVERAGE; }
6426 | yVLT_TRACING_OFF { $$ = V3ErrorCode::I_TRACING; }
6427 | yVLT_LINT_OFF { $$ = V3ErrorCode::I_LINT; }
6428 | yVLT_LINT_OFF yVLT_D_MSG idAny
6429 { $$ = V3ErrorCode((*$3).c_str());
6430 if ($$ == V3ErrorCode::EC_ERROR) { $1->v3error("Unknown Error Code: " << *$3); }
6431 $2->v3warn(DEPRECATED, "Deprecated -msg in configuration files, use -rule instead."); }
6432 | yVLT_LINT_OFF yVLT_D_RULE idAny
6433 { $$ = V3ErrorCode((*$3).c_str());
6434 if ($$ == V3ErrorCode::EC_ERROR) { $1->v3error("Unknown Error Code: " << *$3); } }
6435 ;
6436
6437 vltOnFront<errcodeen>:
6438 yVLT_COVERAGE_ON { $$ = V3ErrorCode::I_COVERAGE; }
6439 | yVLT_TRACING_ON { $$ = V3ErrorCode::I_TRACING; }
6440 | yVLT_LINT_ON { $$ = V3ErrorCode::I_LINT; }
6441 | yVLT_LINT_ON yVLT_D_MSG idAny
6442 { $$ = V3ErrorCode((*$3).c_str());
6443 if ($$ == V3ErrorCode::EC_ERROR) { $1->v3error("Unknown Error Code: " << *$3); }
6444 $2->v3warn(DEPRECATED, "Deprecated -msg in configuration files, use -rule instead."); }
6445 | yVLT_LINT_ON yVLT_D_RULE idAny
6446 { $$ = V3ErrorCode((*$3).c_str());
6447 if ($$ == V3ErrorCode::EC_ERROR) { $1->v3error("Unknown Error Code: " << *$3); } }
6448 ;
6449
6450 vltDModuleE<strp>:
6451 /* empty */ { static string unit = "__024unit"; $$ = &unit; }
6452 | yVLT_D_MODULE str { $$ = $2; }
6453 ;
6454
6455 vltDFTaskE<strp>:
6456 /* empty */ { static string empty; $$ = ∅ }
6457 | yVLT_D_FUNCTION str { $$ = $2; }
6458 | yVLT_D_TASK str { $$ = $2; }
6459 ;
6460
6461 vltInlineFront<cbool>:
6462 yVLT_INLINE { $$ = true; }
6463 | yVLT_NO_INLINE { $$ = false; }
6464 ;
6465
6466 vltVarAttrVarE<strp>:
6467 /* empty */ { static string empty; $$ = ∅ }
6468 | yVLT_D_VAR str { $$ = $2; }
6469 ;
6470
6471 vltVarAttrFront<attrtypeen>:
6472 yVLT_CLOCK_ENABLE { $$ = AstAttrType::VAR_CLOCK_ENABLE; }
6473 | yVLT_CLOCKER { $$ = AstAttrType::VAR_CLOCKER; }
6474 | yVLT_ISOLATE_ASSIGNMENTS { $$ = AstAttrType::VAR_ISOLATE_ASSIGNMENTS; }
6475 | yVLT_NO_CLOCKER { $$ = AstAttrType::VAR_NO_CLOCKER; }
6476 | yVLT_PUBLIC { $$ = AstAttrType::VAR_PUBLIC; v3Global.dpi(true); }
6477 | yVLT_PUBLIC_FLAT { $$ = AstAttrType::VAR_PUBLIC_FLAT; v3Global.dpi(true); }
6478 | yVLT_PUBLIC_FLAT_RD { $$ = AstAttrType::VAR_PUBLIC_FLAT_RD; v3Global.dpi(true); }
6479 | yVLT_PUBLIC_FLAT_RW { $$ = AstAttrType::VAR_PUBLIC_FLAT_RW; v3Global.dpi(true); }
6480 | yVLT_SC_BV { $$ = AstAttrType::VAR_SC_BV; }
6481 | yVLT_SFORMAT { $$ = AstAttrType::VAR_SFORMAT; }
6482 | yVLT_SPLIT_VAR { $$ = AstAttrType::VAR_SPLIT_VAR; }
6483 ;
6484
6485 //**********************************************************************
6486 %%
6487 // For implementation functions see V3ParseGrammar.cpp
6488
6489 //YACC = /kits/sources/bison-2.4.1/src/bison --report=lookahead
6490 // --report=lookahead
6491 // --report=itemset
6492 // --graph
6493