first version of parser
[sv2nmigen.git] / parse_sv.py
1 # %{
2 # /*
3 # * Copyright (c) 1998-2017 Stephen Williams (steve@icarus.com)
4 # * Copyright CERN 2012-2013 / Stephen Williams (steve@icarus.com)
5 # *
6 # * This source code is free software; you can redistribute it
7 # * and/or modify it in source code form under the terms of the GNU
8 # * General Public License as published by the Free Software
9 # * Foundation; either version 2 of the License, or (at your option)
10 # * any later version.
11 # *
12 # * This program is distributed in the hope that it will be useful,
13 # * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # * GNU General Public License for more details.
16 # *
17 # * You should have received a copy of the GNU General Public License
18 # * along with this program; if not, write to the Free Software
19 # * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # */
21 from ply import *
22
23 #from parse_tokens import tokens
24 import lexor
25 tokens = lexor.tokens # list(set(lexor.tokens).union(set(tokens)))
26 literals = lexor.literals
27
28 precedence = [\
29 ('right', 'K_PLUS_EQ', 'K_MINUS_EQ', 'K_MUL_EQ', 'K_DIV_EQ',
30 'K_MOD_EQ', 'K_AND_EQ', 'K_OR_EQ'),
31 ('right', 'K_XOR_EQ', 'K_LS_EQ', 'K_RS_EQ', 'K_RSS_EQ'),
32 ('right', '?', ':', 'K_inside'),
33 ('left', 'K_LOR'),
34 ('left', 'K_LAND'),
35 ('left', '|'),
36 ('left', '^', 'K_NXOR', 'K_NOR'),
37 ('left', '&', 'K_NAND'),
38 ('left', 'K_EQ', 'K_NE', 'K_CEQ', 'K_CNE', 'K_WEQ', 'K_WNE'),
39 ('left', 'K_GE', 'K_LE', '<', '>'),
40 ('left', 'K_LS', 'K_RS', 'K_RSS'),
41 ('left', '+', '-'),
42 ('left', '*', '/', '%'),
43 ('left', 'K_POW'),
44 ('left', 'UNARY_PREC'),
45 ('nonassoc', 'less_than_K_else'),
46 ('nonassoc', 'K_else'),
47 ('nonassoc', '('),
48 ('nonassoc', 'K_exclude'),
49 ('nonassoc', 'no_timeunits_declaration'),
50 ('nonassoc', 'one_timeunits_declaration'),
51 ('nonassoc', 'K_timeunit', 'K_timeprecision')
52 ]
53 ()
54 # -------------- RULES ----------------
55 ()
56 #'''source_text : timeunits_declaration_opt _embed0_source_text description_list
57 def p_source_text(p):
58 '''source_text : timeunits_declaration_opt _embed0_source_text description_list
59 '''
60 print(p)
61 ()
62 def p__embed0_source_text(p):
63 '''_embed0_source_text : '''
64 # { pform_set_scope_timescale(yyloc); }
65 ()
66 def p_assertion_item_1(p):
67 '''assertion_item : concurrent_assertion_item '''
68 print(p)
69 ()
70 def p_assignment_pattern_1(p):
71 '''assignment_pattern : K_LP expression_list_proper '}' '''
72 print(p)
73 # { PEAssignPattern*tmp = new PEAssignPattern(*$2);
74 # FILE_NAME(tmp, @1);
75 # delete $2;
76 # $$ = tmp;
77 # }
78 ()
79 def p_assignment_pattern_2(p):
80 '''assignment_pattern : K_LP '}' '''
81 print(p)
82 # { PEAssignPattern*tmp = new PEAssignPattern;
83 # FILE_NAME(tmp, @1);
84 # $$ = tmp;
85 # }
86 ()
87 def p_block_identifier_opt_1(p):
88 '''block_identifier_opt : IDENTIFIER ':' '''
89 print(p)
90 ()
91 def p_block_identifier_opt_2(p):
92 '''block_identifier_opt : '''
93 print(p)
94 ()
95 def p_class_declaration_1(p):
96 '''class_declaration : K_virtual_opt K_class lifetime_opt class_identifier class_declaration_extends_opt ';' _embed0_class_declaration class_items_opt K_endclass _embed1_class_declaration class_declaration_endlabel_opt '''
97 print(p)
98 # { // Wrap up the class.
99 # if ($11 && $4 && $4->name != $11) {
100 # yyerror(@11, "error: Class end label doesn't match class name.");
101 # delete[]$11;
102 # }
103 # }
104 ()
105 def p__embed0_class_declaration(p):
106 '''_embed0_class_declaration : '''
107 # { pform_start_class_declaration(@2, $4, $5.type, $5.exprs, $3); }
108 ()
109 def p__embed1_class_declaration(p):
110 '''_embed1_class_declaration : '''
111 # { // Process a class.
112 # pform_end_class_declaration(@9);
113 # }
114 ()
115 def p_class_constraint_1(p):
116 '''class_constraint : constraint_prototype '''
117 print(p)
118 ()
119 def p_class_constraint_2(p):
120 '''class_constraint : constraint_declaration '''
121 print(p)
122 ()
123 def p_class_identifier_1(p):
124 '''class_identifier : IDENTIFIER '''
125 print(p)
126 # { // Create a synthetic typedef for the class name so that the
127 # // lexor detects the name as a type.
128 # perm_string name = lex_strings.make($1);
129 # class_type_t*tmp = new class_type_t(name);
130 # FILE_NAME(tmp, @1);
131 # pform_set_typedef(name, tmp, NULL);
132 # delete[]$1;
133 # $$ = tmp;
134 # }
135 ()
136 def p_class_identifier_2(p):
137 '''class_identifier : TYPE_IDENTIFIER '''
138 print(p)
139 # { class_type_t*tmp = dynamic_cast<class_type_t*>($1.type);
140 # if (tmp == 0) {
141 # yyerror(@1, "Type name \"%s\"is not a predeclared class name.", $1.text);
142 # }
143 # delete[]$1.text;
144 # $$ = tmp;
145 # }
146 ()
147 def p_class_declaration_endlabel_opt_1(p):
148 '''class_declaration_endlabel_opt : ':' TYPE_IDENTIFIER '''
149 print(p)
150 # { class_type_t*tmp = dynamic_cast<class_type_t*> ($2.type);
151 # if (tmp == 0) {
152 # yyerror(@2, "error: class declaration endlabel \"%s\" is not a class name\n", $2.text);
153 # $$ = 0;
154 # } else {
155 # $$ = strdupnew(tmp->name.str());
156 # }
157 # delete[]$2.text;
158 # }
159 ()
160 def p_class_declaration_endlabel_opt_2(p):
161 '''class_declaration_endlabel_opt : ':' IDENTIFIER '''
162 print(p)
163 # { $$ = $2; }
164 ()
165 def p_class_declaration_endlabel_opt_3(p):
166 '''class_declaration_endlabel_opt : '''
167 print(p)
168 # { $$ = 0; }
169 ()
170 def p_class_declaration_extends_opt_1(p):
171 '''class_declaration_extends_opt : K_extends TYPE_IDENTIFIER '''
172 print(p)
173 # { $$.type = $2.type;
174 # $$.exprs= 0;
175 # delete[]$2.text;
176 # }
177 ()
178 def p_class_declaration_extends_opt_2(p):
179 '''class_declaration_extends_opt : K_extends TYPE_IDENTIFIER '(' expression_list_with_nuls ')' '''
180 print(p)
181 # { $$.type = $2.type;
182 # $$.exprs = $4;
183 # delete[]$2.text;
184 # }
185 ()
186 def p_class_declaration_extends_opt_3(p):
187 '''class_declaration_extends_opt : '''
188 print(p)
189 # { $$.type = 0; $$.exprs = 0; }
190 ()
191 def p_class_items_opt_1(p):
192 '''class_items_opt : class_items '''
193 print(p)
194 ()
195 def p_class_items_opt_2(p):
196 '''class_items_opt : '''
197 print(p)
198 ()
199 def p_class_items_1(p):
200 '''class_items : class_items class_item '''
201 print(p)
202 ()
203 def p_class_items_2(p):
204 '''class_items : class_item '''
205 print(p)
206 ()
207 def p_class_item_1(p):
208 '''class_item : method_qualifier_opt K_function K_new _embed0_class_item '(' tf_port_list_opt ')' ';' function_item_list_opt statement_or_null_list_opt K_endfunction endnew_opt '''
209 print(p)
210 # { current_function->set_ports($6);
211 # pform_set_constructor_return(current_function);
212 # pform_set_this_class(@3, current_function);
213 # current_function_set_statement(@3, $10);
214 # pform_pop_scope();
215 # current_function = 0;
216 # }
217 ()
218 def p_class_item_2(p):
219 '''class_item : property_qualifier_opt data_type list_of_variable_decl_assignments ';' '''
220 print(p)
221 # { pform_class_property(@2, $1, $2, $3); }
222 ()
223 def p_class_item_3(p):
224 '''class_item : K_const class_item_qualifier_opt data_type list_of_variable_decl_assignments ';' '''
225 print(p)
226 # { pform_class_property(@1, $2 | property_qualifier_t::make_const(), $3, $4); }
227 ()
228 def p_class_item_4(p):
229 '''class_item : method_qualifier_opt task_declaration '''
230 print(p)
231 # { /* The task_declaration rule puts this into the class */ }
232 ()
233 def p_class_item_5(p):
234 '''class_item : method_qualifier_opt function_declaration '''
235 print(p)
236 # { /* The function_declaration rule puts this into the class */ }
237 ()
238 def p_class_item_6(p):
239 '''class_item : K_extern method_qualifier_opt K_function K_new ';' '''
240 print(p)
241 # { yyerror(@1, "sorry: External constructors are not yet supported."); }
242 ()
243 def p_class_item_7(p):
244 '''class_item : K_extern method_qualifier_opt K_function K_new '(' tf_port_list_opt ')' ';' '''
245 print(p)
246 # { yyerror(@1, "sorry: External constructors are not yet supported."); }
247 ()
248 def p_class_item_8(p):
249 '''class_item : K_extern method_qualifier_opt K_function data_type_or_implicit_or_void IDENTIFIER ';' '''
250 print(p)
251 # { yyerror(@1, "sorry: External methods are not yet supported.");
252 # delete[] $5;
253 # }
254 ()
255 def p_class_item_9(p):
256 '''class_item : K_extern method_qualifier_opt K_function data_type_or_implicit_or_void IDENTIFIER '(' tf_port_list_opt ')' ';' '''
257 print(p)
258 # { yyerror(@1, "sorry: External methods are not yet supported.");
259 # delete[] $5;
260 # }
261 ()
262 def p_class_item_10(p):
263 '''class_item : K_extern method_qualifier_opt K_task IDENTIFIER ';' '''
264 print(p)
265 # { yyerror(@1, "sorry: External methods are not yet supported.");
266 # delete[] $4;
267 # }
268 ()
269 def p_class_item_11(p):
270 '''class_item : K_extern method_qualifier_opt K_task IDENTIFIER '(' tf_port_list_opt ')' ';' '''
271 print(p)
272 # { yyerror(@1, "sorry: External methods are not yet supported.");
273 # delete[] $4;
274 # }
275 ()
276 def p_class_item_12(p):
277 '''class_item : class_constraint '''
278 print(p)
279 ()
280 def p_class_item_13(p):
281 '''class_item : property_qualifier_opt data_type error ';' '''
282 print(p)
283 # { yyerror(@3, "error: Errors in variable names after data type.");
284 # yyerrok;
285 # }
286 ()
287 def p_class_item_14(p):
288 '''class_item : property_qualifier_opt IDENTIFIER error ';' '''
289 print(p)
290 # { yyerror(@3, "error: %s doesn't name a type.", $2);
291 # yyerrok;
292 # }
293 ()
294 def p_class_item_15(p):
295 '''class_item : method_qualifier_opt K_function K_new error K_endfunction endnew_opt '''
296 print(p)
297 # { yyerror(@1, "error: I give up on this class constructor declaration.");
298 # yyerrok;
299 # }
300 ()
301 def p_class_item_16(p):
302 '''class_item : error ';' '''
303 print(p)
304 # { yyerror(@2, "error: invalid class item.");
305 # yyerrok;
306 # }
307 ()
308 def p__embed0_class_item(p):
309 '''_embed0_class_item : '''
310 # { assert(current_function==0);
311 # current_function = pform_push_constructor_scope(@3);
312 # }
313 ()
314 def p_class_item_qualifier_1(p):
315 '''class_item_qualifier : K_static '''
316 print(p)
317 # { $$ = property_qualifier_t::make_static(); }
318 ()
319 def p_class_item_qualifier_2(p):
320 '''class_item_qualifier : K_protected '''
321 print(p)
322 # { $$ = property_qualifier_t::make_protected(); }
323 ()
324 def p_class_item_qualifier_3(p):
325 '''class_item_qualifier : K_local '''
326 print(p)
327 # { $$ = property_qualifier_t::make_local(); }
328 ()
329 def p_class_item_qualifier_list_1(p):
330 '''class_item_qualifier_list : class_item_qualifier_list class_item_qualifier '''
331 print(p)
332 # { $$ = $1 | $2; }
333 ()
334 def p_class_item_qualifier_list_2(p):
335 '''class_item_qualifier_list : class_item_qualifier '''
336 print(p)
337 # { $$ = $1; }
338 ()
339 def p_class_item_qualifier_opt_1(p):
340 '''class_item_qualifier_opt : class_item_qualifier_list '''
341 print(p)
342 # { $$ = $1; }
343 ()
344 def p_class_item_qualifier_opt_2(p):
345 '''class_item_qualifier_opt : '''
346 print(p)
347 # { $$ = property_qualifier_t::make_none(); }
348 ()
349 def p_class_new_1(p):
350 '''class_new : K_new '(' expression_list_with_nuls ')' '''
351 print(p)
352 # { list<PExpr*>*expr_list = $3;
353 # strip_tail_items(expr_list);
354 # PENewClass*tmp = new PENewClass(*expr_list);
355 # FILE_NAME(tmp, @1);
356 # delete $3;
357 # $$ = tmp;
358 # }
359 ()
360 def p_class_new_2(p):
361 '''class_new : K_new hierarchy_identifier '''
362 print(p)
363 # { PEIdent*tmpi = new PEIdent(*$2);
364 # FILE_NAME(tmpi, @2);
365 # PENewCopy*tmp = new PENewCopy(tmpi);
366 # FILE_NAME(tmp, @1);
367 # delete $2;
368 # $$ = tmp;
369 # }
370 ()
371 def p_class_new_3(p):
372 '''class_new : K_new '''
373 print(p)
374 # { PENewClass*tmp = new PENewClass;
375 # FILE_NAME(tmp, @1);
376 # $$ = tmp;
377 # }
378 ()
379 def p_concurrent_assertion_item_1(p):
380 '''concurrent_assertion_item : block_identifier_opt K_assert K_property '(' property_spec ')' statement_or_null '''
381 print(p)
382 # { /* */
383 # if (gn_assertions_flag) {
384 # yyerror(@2, "sorry: concurrent_assertion_item not supported."
385 # " Try -gno-assertion to turn this message off.");
386 # }
387 # }
388 ()
389 def p_concurrent_assertion_item_2(p):
390 '''concurrent_assertion_item : block_identifier_opt K_assert K_property '(' error ')' statement_or_null '''
391 print(p)
392 # { yyerrok;
393 # yyerror(@2, "error: Error in property_spec of concurrent assertion item.");
394 # }
395 ()
396 def p_constraint_block_item_1(p):
397 '''constraint_block_item : constraint_expression '''
398 print(p)
399 ()
400 def p_constraint_block_item_list_1(p):
401 '''constraint_block_item_list : constraint_block_item_list constraint_block_item '''
402 print(p)
403 ()
404 def p_constraint_block_item_list_2(p):
405 '''constraint_block_item_list : constraint_block_item '''
406 print(p)
407 ()
408 def p_constraint_block_item_list_opt_1(p):
409 '''constraint_block_item_list_opt : '''
410 print(p)
411 ()
412 def p_constraint_block_item_list_opt_2(p):
413 '''constraint_block_item_list_opt : constraint_block_item_list '''
414 print(p)
415 ()
416 def p_constraint_declaration_1(p):
417 '''constraint_declaration : K_static_opt K_constraint IDENTIFIER '{' constraint_block_item_list_opt '}' '''
418 print(p)
419 # { yyerror(@2, "sorry: Constraint declarations not supported."); }
420 ()
421 def p_constraint_declaration_2(p):
422 '''constraint_declaration : K_static_opt K_constraint IDENTIFIER '{' error '}' '''
423 print(p)
424 # { yyerror(@4, "error: Errors in the constraint block item list."); }
425 ()
426 def p_constraint_expression_1(p):
427 '''constraint_expression : expression ';' '''
428 print(p)
429 ()
430 def p_constraint_expression_2(p):
431 '''constraint_expression : expression K_dist '{' '}' ';' '''
432 print(p)
433 ()
434 def p_constraint_expression_3(p):
435 '''constraint_expression : expression K_TRIGGER constraint_set '''
436 print(p)
437 ()
438 def p_constraint_expression_4(p):
439 '''constraint_expression : K_if '(' expression ')' constraint_set %prec less_than_K_else '''
440 print(p)
441 ()
442 def p_constraint_expression_5(p):
443 '''constraint_expression : K_if '(' expression ')' constraint_set K_else constraint_set '''
444 print(p)
445 ()
446 def p_constraint_expression_6(p):
447 '''constraint_expression : K_foreach '(' IDENTIFIER '[' loop_variables ']' ')' constraint_set '''
448 print(p)
449 ()
450 def p_constraint_expression_list_1(p):
451 '''constraint_expression_list : constraint_expression_list constraint_expression '''
452 print(p)
453 ()
454 def p_constraint_expression_list_2(p):
455 '''constraint_expression_list : constraint_expression '''
456 print(p)
457 ()
458 def p_constraint_prototype_1(p):
459 '''constraint_prototype : K_static_opt K_constraint IDENTIFIER ';' '''
460 print(p)
461 # { yyerror(@2, "sorry: Constraint prototypes not supported."); }
462 ()
463 def p_constraint_set_1(p):
464 '''constraint_set : constraint_expression '''
465 print(p)
466 ()
467 def p_constraint_set_2(p):
468 '''constraint_set : '{' constraint_expression_list '}' '''
469 print(p)
470 ()
471 def p_data_declaration_1(p):
472 '''data_declaration : attribute_list_opt data_type_or_implicit list_of_variable_decl_assignments ';' '''
473 print(p)
474 # { data_type_t*data_type = $2;
475 # if (data_type == 0) {
476 # data_type = new vector_type_t(IVL_VT_LOGIC, false, 0);
477 # FILE_NAME(data_type, @2);
478 # }
479 # pform_makewire(@2, 0, str_strength, $3, NetNet::IMPLICIT_REG, data_type);
480 # }
481 ()
482 def p_data_type_1(p):
483 '''data_type : integer_vector_type unsigned_signed_opt dimensions_opt '''
484 print(p)
485 # { ivl_variable_type_t use_vtype = $1;
486 # bool reg_flag = false;
487 # if (use_vtype == IVL_VT_NO_TYPE) {
488 # use_vtype = IVL_VT_LOGIC;
489 # reg_flag = true;
490 # }
491 # vector_type_t*tmp = new vector_type_t(use_vtype, $2, $3);
492 # tmp->reg_flag = reg_flag;
493 # FILE_NAME(tmp, @1);
494 # $$ = tmp;
495 # }
496 ()
497 def p_data_type_2(p):
498 '''data_type : non_integer_type '''
499 print(p)
500 # { real_type_t*tmp = new real_type_t($1);
501 # FILE_NAME(tmp, @1);
502 # $$ = tmp;
503 # }
504 ()
505 def p_data_type_3(p):
506 '''data_type : struct_data_type '''
507 print(p)
508 # { if (!$1->packed_flag) {
509 # yyerror(@1, "sorry: Unpacked structs not supported.");
510 # }
511 # $$ = $1;
512 # }
513 ()
514 def p_data_type_4(p):
515 '''data_type : enum_data_type '''
516 print(p)
517 # { $$ = $1; }
518 ()
519 def p_data_type_5(p):
520 '''data_type : atom2_type signed_unsigned_opt '''
521 print(p)
522 # { atom2_type_t*tmp = new atom2_type_t($1, $2);
523 # FILE_NAME(tmp, @1);
524 # $$ = tmp;
525 # }
526 ()
527 def p_data_type_6(p):
528 '''data_type : K_integer signed_unsigned_opt '''
529 print(p)
530 # { list<pform_range_t>*pd = make_range_from_width(integer_width);
531 # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, $2, pd);
532 # tmp->reg_flag = true;
533 # tmp->integer_flag = true;
534 # $$ = tmp;
535 # }
536 ()
537 def p_data_type_7(p):
538 '''data_type : K_time '''
539 print(p)
540 # { list<pform_range_t>*pd = make_range_from_width(64);
541 # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, false, pd);
542 # tmp->reg_flag = !gn_system_verilog();
543 # $$ = tmp;
544 # }
545 ()
546 def p_data_type_8(p):
547 '''data_type : TYPE_IDENTIFIER dimensions_opt '''
548 print(p)
549 # { if ($2) {
550 # parray_type_t*tmp = new parray_type_t($1.type, $2);
551 # FILE_NAME(tmp, @1);
552 # $$ = tmp;
553 # } else $$ = $1.type;
554 # delete[]$1.text;
555 # }
556 ()
557 def p_data_type_9(p):
558 '''data_type : PACKAGE_IDENTIFIER K_SCOPE_RES _embed0_data_type TYPE_IDENTIFIER '''
559 print(p)
560 # { lex_in_package_scope(0);
561 # $$ = $4.type;
562 # delete[]$4.text;
563 # }
564 ()
565 def p_data_type_10(p):
566 '''data_type : K_string '''
567 print(p)
568 # { string_type_t*tmp = new string_type_t;
569 # FILE_NAME(tmp, @1);
570 # $$ = tmp;
571 # }
572 ()
573 def p__embed0_data_type(p):
574 '''_embed0_data_type : '''
575 # { lex_in_package_scope($1); }
576 ()
577 def p_data_type_or_implicit_1(p):
578 '''data_type_or_implicit : data_type '''
579 print(p)
580 # { $$ = $1; }
581 ()
582 def p_data_type_or_implicit_2(p):
583 '''data_type_or_implicit : signing dimensions_opt '''
584 print(p)
585 # { vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, $1, $2);
586 # tmp->implicit_flag = true;
587 # FILE_NAME(tmp, @1);
588 # $$ = tmp;
589 # }
590 ()
591 def p_data_type_or_implicit_3(p):
592 '''data_type_or_implicit : dimensions '''
593 print(p)
594 # { vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, false, $1);
595 # tmp->implicit_flag = true;
596 # FILE_NAME(tmp, @1);
597 # $$ = tmp;
598 # }
599 ()
600 def p_data_type_or_implicit_4(p):
601 '''data_type_or_implicit : '''
602 print(p)
603 # { $$ = 0; }
604 ()
605 def p_data_type_or_implicit_or_void_1(p):
606 '''data_type_or_implicit_or_void : data_type_or_implicit '''
607 print(p)
608 # { $$ = $1; }
609 ()
610 def p_data_type_or_implicit_or_void_2(p):
611 '''data_type_or_implicit_or_void : K_void '''
612 print(p)
613 # { void_type_t*tmp = new void_type_t;
614 # FILE_NAME(tmp, @1);
615 # $$ = tmp;
616 # }
617 ()
618 def p_description_1(p):
619 '''description : module '''
620 print(p)
621 ()
622 def p_description_2(p):
623 '''description : udp_primitive '''
624 print(p)
625 ()
626 def p_description_3(p):
627 '''description : config_declaration '''
628 print(p)
629 ()
630 def p_description_4(p):
631 '''description : nature_declaration '''
632 print(p)
633 ()
634 def p_description_5(p):
635 '''description : package_declaration '''
636 print(p)
637 ()
638 def p_description_6(p):
639 '''description : discipline_declaration '''
640 print(p)
641 ()
642 def p_description_7(p):
643 '''description : package_item '''
644 print(p)
645 ()
646 def p_description_8(p):
647 '''description : KK_attribute '(' IDENTIFIER ',' STRING ',' STRING ')' '''
648 print(p)
649 # { perm_string tmp3 = lex_strings.make($3);
650 # pform_set_type_attrib(tmp3, $5, $7);
651 # delete[] $3;
652 # delete[] $5;
653 # }
654 ()
655 def p_description_list_1(p):
656 '''description_list : description '''
657 print(p)
658 ()
659 def p_description_list_2(p):
660 '''description_list : description_list description '''
661 print(p)
662 ()
663 def p_endnew_opt_1(p):
664 '''endnew_opt : ':' K_new '''
665 print(p)
666 ()
667 def p_endnew_opt_2(p):
668 '''endnew_opt : '''
669 print(p)
670 ()
671 def p_dynamic_array_new_1(p):
672 '''dynamic_array_new : K_new '[' expression ']' '''
673 print(p)
674 # { $$ = new PENewArray($3, 0);
675 # FILE_NAME($$, @1);
676 # }
677 ()
678 def p_dynamic_array_new_2(p):
679 '''dynamic_array_new : K_new '[' expression ']' '(' expression ')' '''
680 print(p)
681 # { $$ = new PENewArray($3, $6);
682 # FILE_NAME($$, @1);
683 # }
684 ()
685 def p_for_step_1(p):
686 '''for_step : lpvalue '=' expression '''
687 print(p)
688 # { PAssign*tmp = new PAssign($1,$3);
689 # FILE_NAME(tmp, @1);
690 # $$ = tmp;
691 # }
692 ()
693 def p_for_step_2(p):
694 '''for_step : inc_or_dec_expression '''
695 print(p)
696 # { $$ = pform_compressed_assign_from_inc_dec(@1, $1); }
697 ()
698 def p_for_step_3(p):
699 '''for_step : compressed_statement '''
700 print(p)
701 # { $$ = $1; }
702 ()
703 def p_function_declaration_1(p):
704 '''function_declaration : K_function lifetime_opt data_type_or_implicit_or_void IDENTIFIER ';' _embed0_function_declaration function_item_list statement_or_null_list_opt K_endfunction _embed1_function_declaration endlabel_opt '''
705 print(p)
706 # { // Last step: check any closing name.
707 # if ($11) {
708 # if (strcmp($4,$11) != 0) {
709 # yyerror(@11, "error: End label doesn't match "
710 # "function name");
711 # }
712 # if (! gn_system_verilog()) {
713 # yyerror(@11, "error: Function end labels require "
714 # "SystemVerilog.");
715 # }
716 # delete[]$11;
717 # }
718 # delete[]$4;
719 # }
720 ()
721 def p_function_declaration_2(p):
722 '''function_declaration : K_function lifetime_opt data_type_or_implicit_or_void IDENTIFIER _embed2_function_declaration '(' tf_port_list_opt ')' ';' block_item_decls_opt statement_or_null_list_opt K_endfunction _embed3_function_declaration endlabel_opt '''
723 print(p)
724 # { // Last step: check any closing name.
725 # if ($14) {
726 # if (strcmp($4,$14) != 0) {
727 # yyerror(@14, "error: End label doesn't match "
728 # "function name");
729 # }
730 # if (! gn_system_verilog()) {
731 # yyerror(@14, "error: Function end labels require "
732 # "SystemVerilog.");
733 # }
734 # delete[]$14;
735 # }
736 # delete[]$4;
737 # }
738 ()
739 def p_function_declaration_3(p):
740 '''function_declaration : K_function lifetime_opt data_type_or_implicit_or_void IDENTIFIER error K_endfunction _embed4_function_declaration endlabel_opt '''
741 print(p)
742 # { // Last step: check any closing name.
743 # if ($8) {
744 # if (strcmp($4,$8) != 0) {
745 # yyerror(@8, "error: End label doesn't match function name");
746 # }
747 # if (! gn_system_verilog()) {
748 # yyerror(@8, "error: Function end labels require "
749 # "SystemVerilog.");
750 # }
751 # delete[]$8;
752 # }
753 # delete[]$4;
754 # }
755 ()
756 def p__embed0_function_declaration(p):
757 '''_embed0_function_declaration : '''
758 # { assert(current_function == 0);
759 # current_function = pform_push_function_scope(@1, $4, $2);
760 # }
761 ()
762 def p__embed1_function_declaration(p):
763 '''_embed1_function_declaration : '''
764 # { current_function->set_ports($7);
765 # current_function->set_return($3);
766 # current_function_set_statement($8? @8 : @4, $8);
767 # pform_set_this_class(@4, current_function);
768 # pform_pop_scope();
769 # current_function = 0;
770 # }
771 ()
772 def p__embed2_function_declaration(p):
773 '''_embed2_function_declaration : '''
774 # { assert(current_function == 0);
775 # current_function = pform_push_function_scope(@1, $4, $2);
776 # }
777 ()
778 def p__embed3_function_declaration(p):
779 '''_embed3_function_declaration : '''
780 # { current_function->set_ports($7);
781 # current_function->set_return($3);
782 # current_function_set_statement($11? @11 : @4, $11);
783 # pform_set_this_class(@4, current_function);
784 # pform_pop_scope();
785 # current_function = 0;
786 # if ($7==0 && !gn_system_verilog()) {
787 # yyerror(@4, "error: Empty parenthesis syntax requires SystemVerilog.");
788 # }
789 # }
790 ()
791 def p__embed4_function_declaration(p):
792 '''_embed4_function_declaration : '''
793 # { /* */
794 # if (current_function) {
795 # pform_pop_scope();
796 # current_function = 0;
797 # }
798 # assert(current_function == 0);
799 # yyerror(@1, "error: Syntax error defining function.");
800 # yyerrok;
801 # }
802 ()
803 def p_import_export_1(p):
804 '''import_export : K_import '''
805 print(p)
806 # { $$ = true; }
807 ()
808 def p_import_export_2(p):
809 '''import_export : K_export '''
810 print(p)
811 # { $$ = false; }
812 ()
813 def p_implicit_class_handle_1(p):
814 '''implicit_class_handle : K_this '''
815 print(p)
816 # { $$ = pform_create_this(); }
817 ()
818 def p_implicit_class_handle_2(p):
819 '''implicit_class_handle : K_super '''
820 print(p)
821 # { $$ = pform_create_super(); }
822 ()
823 def p_inc_or_dec_expression_1(p):
824 '''inc_or_dec_expression : K_INCR lpvalue %prec UNARY_PREC '''
825 print(p)
826 # { PEUnary*tmp = new PEUnary('I', $2);
827 # FILE_NAME(tmp, @2);
828 # $$ = tmp;
829 # }
830 ()
831 def p_inc_or_dec_expression_2(p):
832 '''inc_or_dec_expression : lpvalue K_INCR %prec UNARY_PREC '''
833 print(p)
834 # { PEUnary*tmp = new PEUnary('i', $1);
835 # FILE_NAME(tmp, @1);
836 # $$ = tmp;
837 # }
838 ()
839 def p_inc_or_dec_expression_3(p):
840 '''inc_or_dec_expression : K_DECR lpvalue %prec UNARY_PREC '''
841 print(p)
842 # { PEUnary*tmp = new PEUnary('D', $2);
843 # FILE_NAME(tmp, @2);
844 # $$ = tmp;
845 # }
846 ()
847 def p_inc_or_dec_expression_4(p):
848 '''inc_or_dec_expression : lpvalue K_DECR %prec UNARY_PREC '''
849 print(p)
850 # { PEUnary*tmp = new PEUnary('d', $1);
851 # FILE_NAME(tmp, @1);
852 # $$ = tmp;
853 # }
854 ()
855 def p_inside_expression_1(p):
856 '''inside_expression : expression K_inside '{' open_range_list '}' '''
857 print(p)
858 # { yyerror(@2, "sorry: \"inside\" expressions not supported yet.");
859 # $$ = 0;
860 # }
861 ()
862 def p_integer_vector_type_1(p):
863 '''integer_vector_type : K_reg '''
864 print(p)
865 # { $$ = IVL_VT_NO_TYPE; }
866 ()
867 def p_integer_vector_type_2(p):
868 '''integer_vector_type : K_bit '''
869 print(p)
870 # { $$ = IVL_VT_BOOL; }
871 ()
872 def p_integer_vector_type_3(p):
873 '''integer_vector_type : K_logic '''
874 print(p)
875 # { $$ = IVL_VT_LOGIC; }
876 ()
877 def p_integer_vector_type_4(p):
878 '''integer_vector_type : K_bool '''
879 print(p)
880 # { $$ = IVL_VT_BOOL; }
881 ()
882 def p_join_keyword_1(p):
883 '''join_keyword : K_join '''
884 print(p)
885 # { $$ = PBlock::BL_PAR; }
886 ()
887 def p_join_keyword_2(p):
888 '''join_keyword : K_join_none '''
889 print(p)
890 # { $$ = PBlock::BL_JOIN_NONE; }
891 ()
892 def p_join_keyword_3(p):
893 '''join_keyword : K_join_any '''
894 print(p)
895 # { $$ = PBlock::BL_JOIN_ANY; }
896 ()
897 def p_jump_statement_1(p):
898 '''jump_statement : K_break ';' '''
899 print(p)
900 # { yyerror(@1, "sorry: break statements not supported.");
901 # $$ = 0;
902 # }
903 ()
904 def p_jump_statement_2(p):
905 '''jump_statement : K_return ';' '''
906 print(p)
907 # { PReturn*tmp = new PReturn(0);
908 # FILE_NAME(tmp, @1);
909 # $$ = tmp;
910 # }
911 ()
912 def p_jump_statement_3(p):
913 '''jump_statement : K_return expression ';' '''
914 print(p)
915 # { PReturn*tmp = new PReturn($2);
916 # FILE_NAME(tmp, @1);
917 # $$ = tmp;
918 # }
919 ()
920 def p_lifetime_1(p):
921 '''lifetime : K_automatic '''
922 print(p)
923 # { $$ = LexicalScope::AUTOMATIC; }
924 ()
925 def p_lifetime_2(p):
926 '''lifetime : K_static '''
927 print(p)
928 # { $$ = LexicalScope::STATIC; }
929 ()
930 def p_lifetime_opt_1(p):
931 '''lifetime_opt : lifetime '''
932 print(p)
933 # { $$ = $1; }
934 ()
935 def p_lifetime_opt_2(p):
936 '''lifetime_opt : '''
937 print(p)
938 # { $$ = LexicalScope::INHERITED; }
939 ()
940 def p_loop_statement_1(p):
941 '''loop_statement : K_for '(' lpvalue '=' expression ';' expression ';' for_step ')' statement_or_null '''
942 print(p)
943 # { PForStatement*tmp = new PForStatement($3, $5, $7, $9, $11);
944 # FILE_NAME(tmp, @1);
945 # $$ = tmp;
946 # }
947 ()
948 def p_loop_statement_2(p):
949 '''loop_statement : K_for '(' data_type IDENTIFIER '=' expression ';' expression ';' for_step ')' _embed0_loop_statement statement_or_null '''
950 print(p)
951 # { pform_name_t tmp_hident;
952 # tmp_hident.push_back(name_component_t(lex_strings.make($4)));
953 #
954 # PEIdent*tmp_ident = pform_new_ident(tmp_hident);
955 # FILE_NAME(tmp_ident, @4);
956 #
957 # PForStatement*tmp_for = new PForStatement(tmp_ident, $6, $8, $10, $13);
958 # FILE_NAME(tmp_for, @1);
959 #
960 # pform_pop_scope();
961 # vector<Statement*>tmp_for_list (1);
962 # tmp_for_list[0] = tmp_for;
963 # PBlock*tmp_blk = current_block_stack.top();
964 # current_block_stack.pop();
965 # tmp_blk->set_statement(tmp_for_list);
966 # $$ = tmp_blk;
967 # delete[]$4;
968 # }
969 ()
970 def p_loop_statement_3(p):
971 '''loop_statement : K_forever statement_or_null '''
972 print(p)
973 # { PForever*tmp = new PForever($2);
974 # FILE_NAME(tmp, @1);
975 # $$ = tmp;
976 # }
977 ()
978 def p_loop_statement_4(p):
979 '''loop_statement : K_repeat '(' expression ')' statement_or_null '''
980 print(p)
981 # { PRepeat*tmp = new PRepeat($3, $5);
982 # FILE_NAME(tmp, @1);
983 # $$ = tmp;
984 # }
985 ()
986 def p_loop_statement_5(p):
987 '''loop_statement : K_while '(' expression ')' statement_or_null '''
988 print(p)
989 # { PWhile*tmp = new PWhile($3, $5);
990 # FILE_NAME(tmp, @1);
991 # $$ = tmp;
992 # }
993 ()
994 def p_loop_statement_6(p):
995 '''loop_statement : K_do statement_or_null K_while '(' expression ')' ';' '''
996 print(p)
997 # { PDoWhile*tmp = new PDoWhile($5, $2);
998 # FILE_NAME(tmp, @1);
999 # $$ = tmp;
1000 # }
1001 ()
1002 def p_loop_statement_7(p):
1003 '''loop_statement : K_foreach '(' IDENTIFIER '[' loop_variables ']' ')' _embed1_loop_statement statement_or_null '''
1004 print(p)
1005 # { PForeach*tmp_for = pform_make_foreach(@1, $3, $5, $9);
1006 #
1007 # pform_pop_scope();
1008 # vector<Statement*>tmp_for_list(1);
1009 # tmp_for_list[0] = tmp_for;
1010 # PBlock*tmp_blk = current_block_stack.top();
1011 # current_block_stack.pop();
1012 # tmp_blk->set_statement(tmp_for_list);
1013 # $$ = tmp_blk;
1014 # }
1015 ()
1016 def p_loop_statement_8(p):
1017 '''loop_statement : K_for '(' lpvalue '=' expression ';' expression ';' error ')' statement_or_null '''
1018 print(p)
1019 # { $$ = 0;
1020 # yyerror(@1, "error: Error in for loop step assignment.");
1021 # }
1022 ()
1023 def p_loop_statement_9(p):
1024 '''loop_statement : K_for '(' lpvalue '=' expression ';' error ';' for_step ')' statement_or_null '''
1025 print(p)
1026 # { $$ = 0;
1027 # yyerror(@1, "error: Error in for loop condition expression.");
1028 # }
1029 ()
1030 def p_loop_statement_10(p):
1031 '''loop_statement : K_for '(' error ')' statement_or_null '''
1032 print(p)
1033 # { $$ = 0;
1034 # yyerror(@1, "error: Incomprehensible for loop.");
1035 # }
1036 ()
1037 def p_loop_statement_11(p):
1038 '''loop_statement : K_while '(' error ')' statement_or_null '''
1039 print(p)
1040 # { $$ = 0;
1041 # yyerror(@1, "error: Error in while loop condition.");
1042 # }
1043 ()
1044 def p_loop_statement_12(p):
1045 '''loop_statement : K_do statement_or_null K_while '(' error ')' ';' '''
1046 print(p)
1047 # { $$ = 0;
1048 # yyerror(@1, "error: Error in do/while loop condition.");
1049 # }
1050 ()
1051 def p_loop_statement_13(p):
1052 '''loop_statement : K_foreach '(' IDENTIFIER '[' error ']' ')' statement_or_null '''
1053 print(p)
1054 # { $$ = 0;
1055 # yyerror(@4, "error: Errors in foreach loop variables list.");
1056 # }
1057 ()
1058 def p__embed0_loop_statement(p):
1059 '''_embed0_loop_statement : '''
1060 # { static unsigned for_counter = 0;
1061 # char for_block_name [64];
1062 # snprintf(for_block_name, sizeof for_block_name, "$ivl_for_loop%u", for_counter);
1063 # for_counter += 1;
1064 # PBlock*tmp = pform_push_block_scope(for_block_name, PBlock::BL_SEQ);
1065 # FILE_NAME(tmp, @1);
1066 # current_block_stack.push(tmp);
1067 #
1068 # list<decl_assignment_t*>assign_list;
1069 # decl_assignment_t*tmp_assign = new decl_assignment_t;
1070 # tmp_assign->name = lex_strings.make($4);
1071 # assign_list.push_back(tmp_assign);
1072 # pform_makewire(@4, 0, str_strength, &assign_list, NetNet::REG, $3);
1073 # }
1074 ()
1075 def p__embed1_loop_statement(p):
1076 '''_embed1_loop_statement : '''
1077 # { static unsigned foreach_counter = 0;
1078 # char for_block_name[64];
1079 # snprintf(for_block_name, sizeof for_block_name, "$ivl_foreach%u", foreach_counter);
1080 # foreach_counter += 1;
1081 #
1082 # PBlock*tmp = pform_push_block_scope(for_block_name, PBlock::BL_SEQ);
1083 # FILE_NAME(tmp, @1);
1084 # current_block_stack.push(tmp);
1085 #
1086 # pform_make_foreach_declarations(@1, $5);
1087 # }
1088 ()
1089 def p_list_of_variable_decl_assignments_1(p):
1090 '''list_of_variable_decl_assignments : variable_decl_assignment '''
1091 print(p)
1092 # { list<decl_assignment_t*>*tmp = new list<decl_assignment_t*>;
1093 # tmp->push_back($1);
1094 # $$ = tmp;
1095 # }
1096 ()
1097 def p_list_of_variable_decl_assignments_2(p):
1098 '''list_of_variable_decl_assignments : list_of_variable_decl_assignments ',' variable_decl_assignment '''
1099 print(p)
1100 # { list<decl_assignment_t*>*tmp = $1;
1101 # tmp->push_back($3);
1102 # $$ = tmp;
1103 # }
1104 ()
1105 def p_variable_decl_assignment_1(p):
1106 '''variable_decl_assignment : IDENTIFIER dimensions_opt '''
1107 print(p)
1108 # { decl_assignment_t*tmp = new decl_assignment_t;
1109 # tmp->name = lex_strings.make($1);
1110 # if ($2) {
1111 # tmp->index = *$2;
1112 # delete $2;
1113 # }
1114 # delete[]$1;
1115 # $$ = tmp;
1116 # }
1117 ()
1118 def p_variable_decl_assignment_2(p):
1119 '''variable_decl_assignment : IDENTIFIER '=' expression '''
1120 print(p)
1121 # { decl_assignment_t*tmp = new decl_assignment_t;
1122 # tmp->name = lex_strings.make($1);
1123 # tmp->expr .reset($3);
1124 # delete[]$1;
1125 # $$ = tmp;
1126 # }
1127 ()
1128 def p_variable_decl_assignment_3(p):
1129 '''variable_decl_assignment : IDENTIFIER '=' K_new '(' ')' '''
1130 print(p)
1131 # { decl_assignment_t*tmp = new decl_assignment_t;
1132 # tmp->name = lex_strings.make($1);
1133 # PENewClass*expr = new PENewClass;
1134 # FILE_NAME(expr, @3);
1135 # tmp->expr .reset(expr);
1136 # delete[]$1;
1137 # $$ = tmp;
1138 # }
1139 ()
1140 def p_loop_variables_1(p):
1141 '''loop_variables : loop_variables ',' IDENTIFIER '''
1142 print(p)
1143 # { list<perm_string>*tmp = $1;
1144 # tmp->push_back(lex_strings.make($3));
1145 # delete[]$3;
1146 # $$ = tmp;
1147 # }
1148 ()
1149 def p_loop_variables_2(p):
1150 '''loop_variables : IDENTIFIER '''
1151 print(p)
1152 # { list<perm_string>*tmp = new list<perm_string>;
1153 # tmp->push_back(lex_strings.make($1));
1154 # delete[]$1;
1155 # $$ = tmp;
1156 # }
1157 ()
1158 def p_method_qualifier_1(p):
1159 '''method_qualifier : K_virtual '''
1160 print(p)
1161 ()
1162 def p_method_qualifier_2(p):
1163 '''method_qualifier : class_item_qualifier '''
1164 print(p)
1165 ()
1166 def p_method_qualifier_opt_1(p):
1167 '''method_qualifier_opt : method_qualifier '''
1168 print(p)
1169 ()
1170 def p_method_qualifier_opt_2(p):
1171 '''method_qualifier_opt : '''
1172 print(p)
1173 ()
1174 def p_modport_declaration_1(p):
1175 '''modport_declaration : K_modport _embed0_modport_declaration modport_item_list ';' '''
1176 print(p)
1177 ()
1178 def p__embed0_modport_declaration(p):
1179 '''_embed0_modport_declaration : '''
1180 # { if (!pform_in_interface())
1181 # yyerror(@1, "error: modport declarations are only allowed "
1182 # "in interfaces.");
1183 # }
1184 ()
1185 def p_modport_item_list_1(p):
1186 '''modport_item_list : modport_item '''
1187 print(p)
1188 ()
1189 def p_modport_item_list_2(p):
1190 '''modport_item_list : modport_item_list ',' modport_item '''
1191 print(p)
1192 ()
1193 def p_modport_item_1(p):
1194 '''modport_item : IDENTIFIER _embed0_modport_item '(' modport_ports_list ')' '''
1195 print(p)
1196 # { pform_end_modport_item(@1); }
1197 ()
1198 def p__embed0_modport_item(p):
1199 '''_embed0_modport_item : '''
1200 # { pform_start_modport_item(@1, $1); }
1201 ()
1202 def p_modport_ports_list_1(p):
1203 '''modport_ports_list : modport_ports_declaration '''
1204 print(p)
1205 ()
1206 def p_modport_ports_list_2(p):
1207 '''modport_ports_list : modport_ports_list ',' modport_ports_declaration '''
1208 print(p)
1209 ()
1210 def p_modport_ports_list_3(p):
1211 '''modport_ports_list : modport_ports_list ',' modport_simple_port '''
1212 print(p)
1213 # { if (last_modport_port.type == MP_SIMPLE) {
1214 # pform_add_modport_port(@3, last_modport_port.direction,
1215 # $3->name, $3->parm);
1216 # } else {
1217 # yyerror(@3, "error: modport expression not allowed here.");
1218 # }
1219 # delete $3;
1220 # }
1221 ()
1222 def p_modport_ports_list_4(p):
1223 '''modport_ports_list : modport_ports_list ',' modport_tf_port '''
1224 print(p)
1225 # { if (last_modport_port.type != MP_TF)
1226 # yyerror(@3, "error: task/function declaration not allowed here.");
1227 # }
1228 ()
1229 def p_modport_ports_list_5(p):
1230 '''modport_ports_list : modport_ports_list ',' IDENTIFIER '''
1231 print(p)
1232 # { if (last_modport_port.type == MP_SIMPLE) {
1233 # pform_add_modport_port(@3, last_modport_port.direction,
1234 # lex_strings.make($3), 0);
1235 # } else if (last_modport_port.type != MP_TF) {
1236 # yyerror(@3, "error: list of identifiers not allowed here.");
1237 # }
1238 # delete[] $3;
1239 # }
1240 ()
1241 def p_modport_ports_list_6(p):
1242 '''modport_ports_list : modport_ports_list ',' '''
1243 print(p)
1244 # { yyerror(@2, "error: NULL port declarations are not allowed"); }
1245 ()
1246 def p_modport_ports_declaration_1(p):
1247 '''modport_ports_declaration : attribute_list_opt port_direction IDENTIFIER '''
1248 print(p)
1249 # { last_modport_port.type = MP_SIMPLE;
1250 # last_modport_port.direction = $2;
1251 # pform_add_modport_port(@3, $2, lex_strings.make($3), 0);
1252 # delete[] $3;
1253 # delete $1;
1254 # }
1255 ()
1256 def p_modport_ports_declaration_2(p):
1257 '''modport_ports_declaration : attribute_list_opt port_direction modport_simple_port '''
1258 print(p)
1259 # { last_modport_port.type = MP_SIMPLE;
1260 # last_modport_port.direction = $2;
1261 # pform_add_modport_port(@3, $2, $3->name, $3->parm);
1262 # delete $3;
1263 # delete $1;
1264 # }
1265 ()
1266 def p_modport_ports_declaration_3(p):
1267 '''modport_ports_declaration : attribute_list_opt import_export IDENTIFIER '''
1268 print(p)
1269 # { last_modport_port.type = MP_TF;
1270 # last_modport_port.is_import = $2;
1271 # yyerror(@3, "sorry: modport task/function ports are not yet supported.");
1272 # delete[] $3;
1273 # delete $1;
1274 # }
1275 ()
1276 def p_modport_ports_declaration_4(p):
1277 '''modport_ports_declaration : attribute_list_opt import_export modport_tf_port '''
1278 print(p)
1279 # { last_modport_port.type = MP_TF;
1280 # last_modport_port.is_import = $2;
1281 # yyerror(@3, "sorry: modport task/function ports are not yet supported.");
1282 # delete $1;
1283 # }
1284 ()
1285 def p_modport_ports_declaration_5(p):
1286 '''modport_ports_declaration : attribute_list_opt K_clocking IDENTIFIER '''
1287 print(p)
1288 # { last_modport_port.type = MP_CLOCKING;
1289 # last_modport_port.direction = NetNet::NOT_A_PORT;
1290 # yyerror(@3, "sorry: modport clocking declaration is not yet supported.");
1291 # delete[] $3;
1292 # delete $1;
1293 # }
1294 ()
1295 def p_modport_simple_port_1(p):
1296 '''modport_simple_port : '.' IDENTIFIER '(' expression ')' '''
1297 print(p)
1298 # { named_pexpr_t*tmp = new named_pexpr_t;
1299 # tmp->name = lex_strings.make($2);
1300 # tmp->parm = $4;
1301 # delete[]$2;
1302 # $$ = tmp;
1303 # }
1304 ()
1305 def p_modport_tf_port_1(p):
1306 '''modport_tf_port : K_task IDENTIFIER '''
1307 print(p)
1308 ()
1309 def p_modport_tf_port_2(p):
1310 '''modport_tf_port : K_task IDENTIFIER '(' tf_port_list_opt ')' '''
1311 print(p)
1312 ()
1313 def p_modport_tf_port_3(p):
1314 '''modport_tf_port : K_function data_type_or_implicit_or_void IDENTIFIER '''
1315 print(p)
1316 ()
1317 def p_modport_tf_port_4(p):
1318 '''modport_tf_port : K_function data_type_or_implicit_or_void IDENTIFIER '(' tf_port_list_opt ')' '''
1319 print(p)
1320 ()
1321 def p_non_integer_type_1(p):
1322 '''non_integer_type : K_real '''
1323 print(p)
1324 # { $$ = real_type_t::REAL; }
1325 ()
1326 def p_non_integer_type_2(p):
1327 '''non_integer_type : K_realtime '''
1328 print(p)
1329 # { $$ = real_type_t::REAL; }
1330 ()
1331 def p_non_integer_type_3(p):
1332 '''non_integer_type : K_shortreal '''
1333 print(p)
1334 # { $$ = real_type_t::SHORTREAL; }
1335 ()
1336 def p_number_1(p):
1337 '''number : BASED_NUMBER '''
1338 print(p)
1339 # { $$ = $1; based_size = 0;}
1340 ()
1341 def p_number_2(p):
1342 '''number : DEC_NUMBER '''
1343 print(p)
1344 # { $$ = $1; based_size = 0;}
1345 ()
1346 def p_number_3(p):
1347 '''number : DEC_NUMBER BASED_NUMBER '''
1348 print(p)
1349 # { $$ = pform_verinum_with_size($1,$2, @2.text, @2.first_line);
1350 # based_size = 0; }
1351 ()
1352 def p_number_4(p):
1353 '''number : UNBASED_NUMBER '''
1354 print(p)
1355 # { $$ = $1; based_size = 0;}
1356 ()
1357 def p_number_5(p):
1358 '''number : DEC_NUMBER UNBASED_NUMBER '''
1359 print(p)
1360 # { yyerror(@1, "error: Unbased SystemVerilog literal cannot have "
1361 # "a size.");
1362 # $$ = $1; based_size = 0;}
1363 ()
1364 def p_open_range_list_1(p):
1365 '''open_range_list : open_range_list ',' value_range '''
1366 print(p)
1367 ()
1368 def p_open_range_list_2(p):
1369 '''open_range_list : value_range '''
1370 print(p)
1371 ()
1372 def p_package_declaration_1(p):
1373 '''package_declaration : K_package lifetime_opt IDENTIFIER ';' _embed0_package_declaration timeunits_declaration_opt _embed1_package_declaration package_item_list_opt K_endpackage endlabel_opt '''
1374 print(p)
1375 # { pform_end_package_declaration(@1);
1376 # // If an end label is present make sure it match the package name.
1377 # if ($10) {
1378 # if (strcmp($3,$10) != 0) {
1379 # yyerror(@10, "error: End label doesn't match package name");
1380 # }
1381 # delete[]$10;
1382 # }
1383 # delete[]$3;
1384 # }
1385 ()
1386 def p__embed0_package_declaration(p):
1387 '''_embed0_package_declaration : '''
1388 # { pform_start_package_declaration(@1, $3, $2); }
1389 ()
1390 def p__embed1_package_declaration(p):
1391 '''_embed1_package_declaration : '''
1392 # { pform_set_scope_timescale(@1); }
1393 ()
1394 def p_module_package_import_list_opt_1(p):
1395 '''module_package_import_list_opt : '''
1396 print(p)
1397 ()
1398 def p_module_package_import_list_opt_2(p):
1399 '''module_package_import_list_opt : package_import_list '''
1400 print(p)
1401 ()
1402 def p_package_import_list_1(p):
1403 '''package_import_list : package_import_declaration '''
1404 print(p)
1405 ()
1406 def p_package_import_list_2(p):
1407 '''package_import_list : package_import_list package_import_declaration '''
1408 print(p)
1409 ()
1410 def p_package_import_declaration_1(p):
1411 '''package_import_declaration : K_import package_import_item_list ';' '''
1412 print(p)
1413 # { }
1414 ()
1415 def p_package_import_item_1(p):
1416 '''package_import_item : PACKAGE_IDENTIFIER K_SCOPE_RES IDENTIFIER '''
1417 print(p)
1418 # { pform_package_import(@2, $1, $3);
1419 # delete[]$3;
1420 # }
1421 ()
1422 def p_package_import_item_2(p):
1423 '''package_import_item : PACKAGE_IDENTIFIER K_SCOPE_RES '*' '''
1424 print(p)
1425 # { pform_package_import(@2, $1, 0);
1426 # }
1427 ()
1428 def p_package_import_item_list_1(p):
1429 '''package_import_item_list : package_import_item_list ',' package_import_item '''
1430 print(p)
1431 ()
1432 def p_package_import_item_list_2(p):
1433 '''package_import_item_list : package_import_item '''
1434 print(p)
1435 ()
1436 def p_package_item_1(p):
1437 '''package_item : timeunits_declaration '''
1438 print(p)
1439 ()
1440 def p_package_item_2(p):
1441 '''package_item : K_parameter param_type parameter_assign_list ';' '''
1442 print(p)
1443 ()
1444 def p_package_item_3(p):
1445 '''package_item : K_localparam param_type localparam_assign_list ';' '''
1446 print(p)
1447 ()
1448 def p_package_item_4(p):
1449 '''package_item : type_declaration '''
1450 print(p)
1451 ()
1452 def p_package_item_5(p):
1453 '''package_item : function_declaration '''
1454 print(p)
1455 ()
1456 def p_package_item_6(p):
1457 '''package_item : task_declaration '''
1458 print(p)
1459 ()
1460 def p_package_item_7(p):
1461 '''package_item : data_declaration '''
1462 print(p)
1463 ()
1464 def p_package_item_8(p):
1465 '''package_item : class_declaration '''
1466 print(p)
1467 ()
1468 def p_package_item_list_1(p):
1469 '''package_item_list : package_item_list package_item '''
1470 print(p)
1471 ()
1472 def p_package_item_list_2(p):
1473 '''package_item_list : package_item '''
1474 print(p)
1475 ()
1476 def p_package_item_list_opt_1(p):
1477 '''package_item_list_opt : package_item_list '''
1478 print(p)
1479 ()
1480 def p_package_item_list_opt_2(p):
1481 '''package_item_list_opt : '''
1482 print(p)
1483 ()
1484 def p_port_direction_1(p):
1485 '''port_direction : K_input '''
1486 print(p)
1487 # { $$ = NetNet::PINPUT; }
1488 ()
1489 def p_port_direction_2(p):
1490 '''port_direction : K_output '''
1491 print(p)
1492 # { $$ = NetNet::POUTPUT; }
1493 ()
1494 def p_port_direction_3(p):
1495 '''port_direction : K_inout '''
1496 print(p)
1497 # { $$ = NetNet::PINOUT; }
1498 ()
1499 def p_port_direction_4(p):
1500 '''port_direction : K_ref '''
1501 print(p)
1502 # { $$ = NetNet::PREF;
1503 # if (!gn_system_verilog()) {
1504 # yyerror(@1, "error: Reference ports (ref) require SystemVerilog.");
1505 # $$ = NetNet::PINPUT;
1506 # }
1507 # }
1508 ()
1509 def p_port_direction_opt_1(p):
1510 '''port_direction_opt : port_direction '''
1511 print(p)
1512 # { $$ = $1; }
1513 ()
1514 def p_port_direction_opt_2(p):
1515 '''port_direction_opt : '''
1516 print(p)
1517 # { $$ = NetNet::PIMPLICIT; }
1518 ()
1519 def p_property_expr_1(p):
1520 '''property_expr : expression '''
1521 print(p)
1522 ()
1523 def p_procedural_assertion_statement_1(p):
1524 '''procedural_assertion_statement : K_assert '(' expression ')' statement %prec less_than_K_else '''
1525 print(p)
1526 # { yyerror(@1, "sorry: Simple immediate assertion statements not implemented.");
1527 # $$ = 0;
1528 # }
1529 ()
1530 def p_procedural_assertion_statement_2(p):
1531 '''procedural_assertion_statement : K_assert '(' expression ')' K_else statement '''
1532 print(p)
1533 # { yyerror(@1, "sorry: Simple immediate assertion statements not implemented.");
1534 # $$ = 0;
1535 # }
1536 ()
1537 def p_procedural_assertion_statement_3(p):
1538 '''procedural_assertion_statement : K_assert '(' expression ')' statement K_else statement '''
1539 print(p)
1540 # { yyerror(@1, "sorry: Simple immediate assertion statements not implemented.");
1541 # $$ = 0;
1542 # }
1543 ()
1544 def p_property_qualifier_1(p):
1545 '''property_qualifier : class_item_qualifier '''
1546 print(p)
1547 ()
1548 def p_property_qualifier_2(p):
1549 '''property_qualifier : random_qualifier '''
1550 print(p)
1551 ()
1552 def p_property_qualifier_opt_1(p):
1553 '''property_qualifier_opt : property_qualifier_list '''
1554 print(p)
1555 # { $$ = $1; }
1556 ()
1557 def p_property_qualifier_opt_2(p):
1558 '''property_qualifier_opt : '''
1559 print(p)
1560 # { $$ = property_qualifier_t::make_none(); }
1561 ()
1562 def p_property_qualifier_list_1(p):
1563 '''property_qualifier_list : property_qualifier_list property_qualifier '''
1564 print(p)
1565 # { $$ = $1 | $2; }
1566 ()
1567 def p_property_qualifier_list_2(p):
1568 '''property_qualifier_list : property_qualifier '''
1569 print(p)
1570 # { $$ = $1; }
1571 ()
1572 def p_property_spec_1(p):
1573 '''property_spec : clocking_event_opt property_spec_disable_iff_opt property_expr '''
1574 print(p)
1575 ()
1576 def p_property_spec_disable_iff_opt_1(p):
1577 '''property_spec_disable_iff_opt : K_disable K_iff '(' expression ')' '''
1578 print(p)
1579 ()
1580 def p_property_spec_disable_iff_opt_2(p):
1581 '''property_spec_disable_iff_opt : '''
1582 print(p)
1583 ()
1584 def p_random_qualifier_1(p):
1585 '''random_qualifier : K_rand '''
1586 print(p)
1587 # { $$ = property_qualifier_t::make_rand(); }
1588 ()
1589 def p_random_qualifier_2(p):
1590 '''random_qualifier : K_randc '''
1591 print(p)
1592 # { $$ = property_qualifier_t::make_randc(); }
1593 ()
1594 def p_real_or_realtime_1(p):
1595 '''real_or_realtime : K_real '''
1596 print(p)
1597 ()
1598 def p_real_or_realtime_2(p):
1599 '''real_or_realtime : K_realtime '''
1600 print(p)
1601 ()
1602 def p_signing_1(p):
1603 '''signing : K_signed '''
1604 print(p)
1605 # { $$ = true; }
1606 ()
1607 def p_signing_2(p):
1608 '''signing : K_unsigned '''
1609 print(p)
1610 # { $$ = false; }
1611 ()
1612 def p_simple_type_or_string_1(p):
1613 '''simple_type_or_string : integer_vector_type '''
1614 print(p)
1615 # { ivl_variable_type_t use_vtype = $1;
1616 # bool reg_flag = false;
1617 # if (use_vtype == IVL_VT_NO_TYPE) {
1618 # use_vtype = IVL_VT_LOGIC;
1619 # reg_flag = true;
1620 # }
1621 # vector_type_t*tmp = new vector_type_t(use_vtype, false, 0);
1622 # tmp->reg_flag = reg_flag;
1623 # FILE_NAME(tmp, @1);
1624 # $$ = tmp;
1625 # }
1626 ()
1627 def p_simple_type_or_string_2(p):
1628 '''simple_type_or_string : non_integer_type '''
1629 print(p)
1630 # { real_type_t*tmp = new real_type_t($1);
1631 # FILE_NAME(tmp, @1);
1632 # $$ = tmp;
1633 # }
1634 ()
1635 def p_simple_type_or_string_3(p):
1636 '''simple_type_or_string : atom2_type '''
1637 print(p)
1638 # { atom2_type_t*tmp = new atom2_type_t($1, true);
1639 # FILE_NAME(tmp, @1);
1640 # $$ = tmp;
1641 # }
1642 ()
1643 def p_simple_type_or_string_4(p):
1644 '''simple_type_or_string : K_integer '''
1645 print(p)
1646 # { list<pform_range_t>*pd = make_range_from_width(integer_width);
1647 # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, true, pd);
1648 # tmp->reg_flag = true;
1649 # tmp->integer_flag = true;
1650 # $$ = tmp;
1651 # }
1652 ()
1653 def p_simple_type_or_string_5(p):
1654 '''simple_type_or_string : K_time '''
1655 print(p)
1656 # { list<pform_range_t>*pd = make_range_from_width(64);
1657 # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, false, pd);
1658 # tmp->reg_flag = !gn_system_verilog();
1659 # $$ = tmp;
1660 # }
1661 ()
1662 def p_simple_type_or_string_6(p):
1663 '''simple_type_or_string : TYPE_IDENTIFIER '''
1664 print(p)
1665 # { $$ = $1.type;
1666 # delete[]$1.text;
1667 # }
1668 ()
1669 def p_simple_type_or_string_7(p):
1670 '''simple_type_or_string : PACKAGE_IDENTIFIER K_SCOPE_RES _embed0_simple_type_or_string TYPE_IDENTIFIER '''
1671 print(p)
1672 # { lex_in_package_scope(0);
1673 # $$ = $4.type;
1674 # delete[]$4.text;
1675 # }
1676 ()
1677 def p_simple_type_or_string_8(p):
1678 '''simple_type_or_string : K_string '''
1679 print(p)
1680 # { string_type_t*tmp = new string_type_t;
1681 # FILE_NAME(tmp, @1);
1682 # $$ = tmp;
1683 # }
1684 ()
1685 def p__embed0_simple_type_or_string(p):
1686 '''_embed0_simple_type_or_string : '''
1687 # { lex_in_package_scope($1); }
1688 ()
1689 def p_statement_1(p):
1690 '''statement : attribute_list_opt statement_item '''
1691 print(p)
1692 # { pform_bind_attributes($2->attributes, $1);
1693 # $$ = $2;
1694 # }
1695 ()
1696 def p_statement_or_null_1(p):
1697 '''statement_or_null : statement '''
1698 print(p)
1699 # { $$ = $1; }
1700 ()
1701 def p_statement_or_null_2(p):
1702 '''statement_or_null : attribute_list_opt ';' '''
1703 print(p)
1704 # { $$ = 0; }
1705 ()
1706 def p_stream_expression_1(p):
1707 '''stream_expression : expression '''
1708 print(p)
1709 ()
1710 def p_stream_expression_list_1(p):
1711 '''stream_expression_list : stream_expression_list ',' stream_expression '''
1712 print(p)
1713 ()
1714 def p_stream_expression_list_2(p):
1715 '''stream_expression_list : stream_expression '''
1716 print(p)
1717 ()
1718 def p_stream_operator_1(p):
1719 '''stream_operator : K_LS '''
1720 print(p)
1721 ()
1722 def p_stream_operator_2(p):
1723 '''stream_operator : K_RS '''
1724 print(p)
1725 ()
1726 def p_streaming_concatenation_1(p):
1727 '''streaming_concatenation : '{' stream_operator '{' stream_expression_list '}' '}' '''
1728 print(p)
1729 # { /* streaming concatenation is a SystemVerilog thing. */
1730 # if (gn_system_verilog()) {
1731 # yyerror(@2, "sorry: Streaming concatenation not supported.");
1732 # $$ = 0;
1733 # } else {
1734 # yyerror(@2, "error: Streaming concatenation requires SystemVerilog");
1735 # $$ = 0;
1736 # }
1737 # }
1738 ()
1739 def p_task_declaration_1(p):
1740 '''task_declaration : K_task lifetime_opt IDENTIFIER ';' _embed0_task_declaration task_item_list_opt statement_or_null_list_opt K_endtask _embed1_task_declaration endlabel_opt '''
1741 print(p)
1742 # { // Last step: check any closing name. This is done late so
1743 # // that the parser can look ahead to detect the present
1744 # // endlabel_opt but still have the pform_endmodule() called
1745 # // early enough that the lexor can know we are outside the
1746 # // module.
1747 # if ($10) {
1748 # if (strcmp($3,$10) != 0) {
1749 # yyerror(@10, "error: End label doesn't match task name");
1750 # }
1751 # if (! gn_system_verilog()) {
1752 # yyerror(@10, "error: Task end labels require "
1753 # "SystemVerilog.");
1754 # }
1755 # delete[]$10;
1756 # }
1757 # delete[]$3;
1758 # }
1759 ()
1760 def p_task_declaration_2(p):
1761 '''task_declaration : K_task lifetime_opt IDENTIFIER '(' _embed2_task_declaration tf_port_list ')' ';' block_item_decls_opt statement_or_null_list_opt K_endtask _embed3_task_declaration endlabel_opt '''
1762 print(p)
1763 # { // Last step: check any closing name. This is done late so
1764 # // that the parser can look ahead to detect the present
1765 # // endlabel_opt but still have the pform_endmodule() called
1766 # // early enough that the lexor can know we are outside the
1767 # // module.
1768 # if ($13) {
1769 # if (strcmp($3,$13) != 0) {
1770 # yyerror(@13, "error: End label doesn't match task name");
1771 # }
1772 # if (! gn_system_verilog()) {
1773 # yyerror(@13, "error: Task end labels require "
1774 # "SystemVerilog.");
1775 # }
1776 # delete[]$13;
1777 # }
1778 # delete[]$3;
1779 # }
1780 ()
1781 def p_task_declaration_3(p):
1782 '''task_declaration : K_task lifetime_opt IDENTIFIER '(' ')' ';' _embed4_task_declaration block_item_decls_opt statement_or_null_list K_endtask _embed5_task_declaration endlabel_opt '''
1783 print(p)
1784 # { // Last step: check any closing name. This is done late so
1785 # // that the parser can look ahead to detect the present
1786 # // endlabel_opt but still have the pform_endmodule() called
1787 # // early enough that the lexor can know we are outside the
1788 # // module.
1789 # if ($12) {
1790 # if (strcmp($3,$12) != 0) {
1791 # yyerror(@12, "error: End label doesn't match task name");
1792 # }
1793 # if (! gn_system_verilog()) {
1794 # yyerror(@12, "error: Task end labels require "
1795 # "SystemVerilog.");
1796 # }
1797 # delete[]$12;
1798 # }
1799 # delete[]$3;
1800 # }
1801 ()
1802 def p_task_declaration_4(p):
1803 '''task_declaration : K_task lifetime_opt IDENTIFIER error K_endtask _embed6_task_declaration endlabel_opt '''
1804 print(p)
1805 # { // Last step: check any closing name. This is done late so
1806 # // that the parser can look ahead to detect the present
1807 # // endlabel_opt but still have the pform_endmodule() called
1808 # // early enough that the lexor can know we are outside the
1809 # // module.
1810 # if ($7) {
1811 # if (strcmp($3,$7) != 0) {
1812 # yyerror(@7, "error: End label doesn't match task name");
1813 # }
1814 # if (! gn_system_verilog()) {
1815 # yyerror(@7, "error: Task end labels require "
1816 # "SystemVerilog.");
1817 # }
1818 # delete[]$7;
1819 # }
1820 # delete[]$3;
1821 # }
1822 ()
1823 def p__embed0_task_declaration(p):
1824 '''_embed0_task_declaration : '''
1825 # { assert(current_task == 0);
1826 # current_task = pform_push_task_scope(@1, $3, $2);
1827 # }
1828 ()
1829 def p__embed1_task_declaration(p):
1830 '''_embed1_task_declaration : '''
1831 # { current_task->set_ports($6);
1832 # current_task_set_statement(@3, $7);
1833 # pform_set_this_class(@3, current_task);
1834 # pform_pop_scope();
1835 # current_task = 0;
1836 # if ($7 && $7->size() > 1 && !gn_system_verilog()) {
1837 # yyerror(@7, "error: Task body with multiple statements requires SystemVerilog.");
1838 # }
1839 # delete $7;
1840 # }
1841 ()
1842 def p__embed2_task_declaration(p):
1843 '''_embed2_task_declaration : '''
1844 # { assert(current_task == 0);
1845 # current_task = pform_push_task_scope(@1, $3, $2);
1846 # }
1847 ()
1848 def p__embed3_task_declaration(p):
1849 '''_embed3_task_declaration : '''
1850 # { current_task->set_ports($6);
1851 # current_task_set_statement(@3, $10);
1852 # pform_set_this_class(@3, current_task);
1853 # pform_pop_scope();
1854 # current_task = 0;
1855 # if ($10) delete $10;
1856 # }
1857 ()
1858 def p__embed4_task_declaration(p):
1859 '''_embed4_task_declaration : '''
1860 # { assert(current_task == 0);
1861 # current_task = pform_push_task_scope(@1, $3, $2);
1862 # }
1863 ()
1864 def p__embed5_task_declaration(p):
1865 '''_embed5_task_declaration : '''
1866 # { current_task->set_ports(0);
1867 # current_task_set_statement(@3, $9);
1868 # pform_set_this_class(@3, current_task);
1869 # if (! current_task->method_of()) {
1870 # cerr << @3 << ": warning: task definition for \"" << $3
1871 # << "\" has an empty port declaration list!" << endl;
1872 # }
1873 # pform_pop_scope();
1874 # current_task = 0;
1875 # if ($9->size() > 1 && !gn_system_verilog()) {
1876 # yyerror(@9, "error: Task body with multiple statements requires SystemVerilog.");
1877 # }
1878 # delete $9;
1879 # }
1880 ()
1881 def p__embed6_task_declaration(p):
1882 '''_embed6_task_declaration : '''
1883 # {
1884 # if (current_task) {
1885 # pform_pop_scope();
1886 # current_task = 0;
1887 # }
1888 # }
1889 ()
1890 def p_tf_port_declaration_1(p):
1891 '''tf_port_declaration : port_direction K_reg_opt unsigned_signed_opt dimensions_opt list_of_identifiers ';' '''
1892 print(p)
1893 # { vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, $1,
1894 # $2 ? IVL_VT_LOGIC :
1895 # IVL_VT_NO_TYPE,
1896 # $3, $4, $5);
1897 # $$ = tmp;
1898 # }
1899 ()
1900 def p_tf_port_declaration_2(p):
1901 '''tf_port_declaration : port_direction K_integer list_of_identifiers ';' '''
1902 print(p)
1903 # { list<pform_range_t>*range_stub = make_range_from_width(integer_width);
1904 # vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, $1, IVL_VT_LOGIC, true,
1905 # range_stub, $3, true);
1906 # $$ = tmp;
1907 # }
1908 ()
1909 def p_tf_port_declaration_3(p):
1910 '''tf_port_declaration : port_direction K_time list_of_identifiers ';' '''
1911 print(p)
1912 # { list<pform_range_t>*range_stub = make_range_from_width(64);
1913 # vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, $1, IVL_VT_LOGIC, false,
1914 # range_stub, $3);
1915 # $$ = tmp;
1916 # }
1917 ()
1918 def p_tf_port_declaration_4(p):
1919 '''tf_port_declaration : port_direction real_or_realtime list_of_identifiers ';' '''
1920 print(p)
1921 # { vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, $1, IVL_VT_REAL, true,
1922 # 0, $3);
1923 # $$ = tmp;
1924 # }
1925 ()
1926 def p_tf_port_declaration_5(p):
1927 '''tf_port_declaration : port_direction K_string list_of_identifiers ';' '''
1928 print(p)
1929 # { vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, $1, IVL_VT_STRING, true,
1930 # 0, $3);
1931 # $$ = tmp;
1932 # }
1933 ()
1934 def p_tf_port_item_1(p):
1935 '''tf_port_item : port_direction_opt data_type_or_implicit IDENTIFIER dimensions_opt tf_port_item_expr_opt '''
1936 print(p)
1937 # { vector<pform_tf_port_t>*tmp;
1938 # NetNet::PortType use_port_type = $1;
1939 # if ((use_port_type == NetNet::PIMPLICIT) && (gn_system_verilog() || ($2 == 0)))
1940 # use_port_type = port_declaration_context.port_type;
1941 # perm_string name = lex_strings.make($3);
1942 # list<perm_string>* ilist = list_from_identifier($3);
1943 #
1944 # if (use_port_type == NetNet::PIMPLICIT) {
1945 # yyerror(@1, "error: missing task/function port direction.");
1946 # use_port_type = NetNet::PINPUT; // for error recovery
1947 # }
1948 # if (($2 == 0) && ($1==NetNet::PIMPLICIT)) {
1949 # // Detect special case this is an undecorated
1950 # // identifier and we need to get the declaration from
1951 # // left context.
1952 # if ($4 != 0) {
1953 # yyerror(@4, "internal error: How can there be an unpacked range here?\n");
1954 # }
1955 # tmp = pform_make_task_ports(@3, use_port_type,
1956 # port_declaration_context.data_type,
1957 # ilist);
1958 #
1959 # } else {
1960 # // Otherwise, the decorations for this identifier
1961 # // indicate the type. Save the type for any right
1962 # // context that may come later.
1963 # port_declaration_context.port_type = use_port_type;
1964 # if ($2 == 0) {
1965 # $2 = new vector_type_t(IVL_VT_LOGIC, false, 0);
1966 # FILE_NAME($2, @3);
1967 # }
1968 # port_declaration_context.data_type = $2;
1969 # tmp = pform_make_task_ports(@3, use_port_type, $2, ilist);
1970 # }
1971 # if ($4 != 0) {
1972 # pform_set_reg_idx(name, $4);
1973 # }
1974 #
1975 # $$ = tmp;
1976 # if ($5) {
1977 # assert(tmp->size()==1);
1978 # tmp->front().defe = $5;
1979 # }
1980 # }
1981 ()
1982 def p_tf_port_item_2(p):
1983 '''tf_port_item : port_direction_opt data_type_or_implicit IDENTIFIER error '''
1984 print(p)
1985 # { yyerror(@3, "error: Error in task/function port item after port name %s.", $3);
1986 # yyerrok;
1987 # $$ = 0;
1988 # }
1989 ()
1990 def p_tf_port_item_expr_opt_1(p):
1991 '''tf_port_item_expr_opt : '=' expression '''
1992 print(p)
1993 # { if (! gn_system_verilog()) {
1994 # yyerror(@1, "error: Task/function default arguments require "
1995 # "SystemVerilog.");
1996 # }
1997 # $$ = $2;
1998 # }
1999 ()
2000 def p_tf_port_item_expr_opt_2(p):
2001 '''tf_port_item_expr_opt : '''
2002 print(p)
2003 # { $$ = 0; }
2004 ()
2005 def p_tf_port_list_1(p):
2006 '''tf_port_list : _embed0_tf_port_list tf_port_item_list '''
2007 print(p)
2008 # { $$ = $2; }
2009 ()
2010 def p__embed0_tf_port_list(p):
2011 '''_embed0_tf_port_list : '''
2012 # { port_declaration_context.port_type = gn_system_verilog() ? NetNet::PINPUT : NetNet::PIMPLICIT;
2013 # port_declaration_context.data_type = 0;
2014 # }
2015 ()
2016 def p_tf_port_item_list_1(p):
2017 '''tf_port_item_list : tf_port_item_list ',' tf_port_item '''
2018 print(p)
2019 # { vector<pform_tf_port_t>*tmp;
2020 # if ($1 && $3) {
2021 # size_t s1 = $1->size();
2022 # tmp = $1;
2023 # tmp->resize(tmp->size()+$3->size());
2024 # for (size_t idx = 0 ; idx < $3->size() ; idx += 1)
2025 # tmp->at(s1+idx) = $3->at(idx);
2026 # delete $3;
2027 # } else if ($1) {
2028 # tmp = $1;
2029 # } else {
2030 # tmp = $3;
2031 # }
2032 # $$ = tmp;
2033 # }
2034 ()
2035 def p_tf_port_item_list_2(p):
2036 '''tf_port_item_list : tf_port_item '''
2037 print(p)
2038 # { $$ = $1; }
2039 ()
2040 def p_tf_port_item_list_3(p):
2041 '''tf_port_item_list : error ',' tf_port_item '''
2042 print(p)
2043 # { yyerror(@2, "error: Syntax error in task/function port declaration.");
2044 # $$ = $3;
2045 # }
2046 ()
2047 def p_tf_port_item_list_4(p):
2048 '''tf_port_item_list : tf_port_item_list ',' '''
2049 print(p)
2050 # { yyerror(@2, "error: NULL port declarations are not allowed.");
2051 # $$ = $1;
2052 # }
2053 ()
2054 def p_tf_port_item_list_5(p):
2055 '''tf_port_item_list : tf_port_item_list ';' '''
2056 print(p)
2057 # { yyerror(@2, "error: ';' is an invalid port declaration separator.");
2058 # $$ = $1;
2059 # }
2060 ()
2061 def p_timeunits_declaration_1(p):
2062 '''timeunits_declaration : K_timeunit TIME_LITERAL ';' '''
2063 print(p)
2064 # { pform_set_timeunit($2, allow_timeunit_decl); }
2065 ()
2066 def p_timeunits_declaration_2(p):
2067 '''timeunits_declaration : K_timeunit TIME_LITERAL '/' TIME_LITERAL ';' '''
2068 print(p)
2069 # { bool initial_decl = allow_timeunit_decl && allow_timeprec_decl;
2070 # pform_set_timeunit($2, initial_decl);
2071 # pform_set_timeprec($4, initial_decl);
2072 # }
2073 ()
2074 def p_timeunits_declaration_3(p):
2075 '''timeunits_declaration : K_timeprecision TIME_LITERAL ';' '''
2076 print(p)
2077 # { pform_set_timeprec($2, allow_timeprec_decl); }
2078 ()
2079 def p_timeunits_declaration_opt_1(p):
2080 '''timeunits_declaration_opt : %prec no_timeunits_declaration '''
2081 print(p)
2082 ()
2083 def p_timeunits_declaration_opt_2(p):
2084 '''timeunits_declaration_opt : timeunits_declaration %prec one_timeunits_declaration '''
2085 print(p)
2086 ()
2087 def p_timeunits_declaration_opt_3(p):
2088 '''timeunits_declaration_opt : timeunits_declaration timeunits_declaration '''
2089 print(p)
2090 ()
2091 def p_value_range_1(p):
2092 '''value_range : expression '''
2093 print(p)
2094 # { }
2095 ()
2096 def p_value_range_2(p):
2097 '''value_range : '[' expression ':' expression ']' '''
2098 print(p)
2099 # { }
2100 ()
2101 def p_variable_dimension_1(p):
2102 '''variable_dimension : '[' expression ':' expression ']' '''
2103 print(p)
2104 # { list<pform_range_t> *tmp = new list<pform_range_t>;
2105 # pform_range_t index ($2,$4);
2106 # tmp->push_back(index);
2107 # $$ = tmp;
2108 # }
2109 ()
2110 def p_variable_dimension_2(p):
2111 '''variable_dimension : '[' expression ']' '''
2112 print(p)
2113 # { // SystemVerilog canonical range
2114 # if (!gn_system_verilog()) {
2115 # warn_count += 1;
2116 # cerr << @2 << ": warning: Use of SystemVerilog [size] dimension. "
2117 # << "Use at least -g2005-sv to remove this warning." << endl;
2118 # }
2119 # list<pform_range_t> *tmp = new list<pform_range_t>;
2120 # pform_range_t index;
2121 # index.first = new PENumber(new verinum((uint64_t)0, integer_width));
2122 # index.second = new PEBinary('-', $2, new PENumber(new verinum((uint64_t)1, integer_width)));
2123 # tmp->push_back(index);
2124 # $$ = tmp;
2125 # }
2126 ()
2127 def p_variable_dimension_3(p):
2128 '''variable_dimension : '[' ']' '''
2129 print(p)
2130 # { list<pform_range_t> *tmp = new list<pform_range_t>;
2131 # pform_range_t index (0,0);
2132 # tmp->push_back(index);
2133 # $$ = tmp;
2134 # }
2135 ()
2136 def p_variable_dimension_4(p):
2137 '''variable_dimension : '[' '$' ']' '''
2138 print(p)
2139 # { // SystemVerilog queue
2140 # list<pform_range_t> *tmp = new list<pform_range_t>;
2141 # pform_range_t index (new PENull,0);
2142 # if (!gn_system_verilog()) {
2143 # yyerror("error: Queue declarations require SystemVerilog.");
2144 # }
2145 # tmp->push_back(index);
2146 # $$ = tmp;
2147 # }
2148 ()
2149 def p_variable_lifetime_1(p):
2150 '''variable_lifetime : lifetime '''
2151 print(p)
2152 # { if (!gn_system_verilog()) {
2153 # yyerror(@1, "error: overriding the default variable lifetime "
2154 # "requires SystemVerilog.");
2155 # } else if ($1 != pform_peek_scope()->default_lifetime) {
2156 # yyerror(@1, "sorry: overriding the default variable lifetime "
2157 # "is not yet supported.");
2158 # }
2159 # var_lifetime = $1;
2160 # }
2161 ()
2162 def p_attribute_list_opt_1(p):
2163 '''attribute_list_opt : attribute_instance_list '''
2164 print(p)
2165 # { $$ = $1; }
2166 ()
2167 def p_attribute_list_opt_2(p):
2168 '''attribute_list_opt : '''
2169 print(p)
2170 # { $$ = 0; }
2171 ()
2172 def p_attribute_instance_list_1(p):
2173 '''attribute_instance_list : K_PSTAR K_STARP '''
2174 print(p)
2175 # { $$ = 0; }
2176 ()
2177 def p_attribute_instance_list_2(p):
2178 '''attribute_instance_list : K_PSTAR attribute_list K_STARP '''
2179 print(p)
2180 # { $$ = $2; }
2181 ()
2182 def p_attribute_instance_list_3(p):
2183 '''attribute_instance_list : attribute_instance_list K_PSTAR K_STARP '''
2184 print(p)
2185 # { $$ = $1; }
2186 ()
2187 def p_attribute_instance_list_4(p):
2188 '''attribute_instance_list : attribute_instance_list K_PSTAR attribute_list K_STARP '''
2189 print(p)
2190 # { list<named_pexpr_t>*tmp = $1;
2191 # if (tmp) {
2192 # tmp->splice(tmp->end(), *$3);
2193 # delete $3;
2194 # $$ = tmp;
2195 # } else $$ = $3;
2196 # }
2197 ()
2198 def p_attribute_list_1(p):
2199 '''attribute_list : attribute_list ',' attribute '''
2200 print(p)
2201 # { list<named_pexpr_t>*tmp = $1;
2202 # tmp->push_back(*$3);
2203 # delete $3;
2204 # $$ = tmp;
2205 # }
2206 ()
2207 def p_attribute_list_2(p):
2208 '''attribute_list : attribute '''
2209 print(p)
2210 # { list<named_pexpr_t>*tmp = new list<named_pexpr_t>;
2211 # tmp->push_back(*$1);
2212 # delete $1;
2213 # $$ = tmp;
2214 # }
2215 ()
2216 def p_attribute_1(p):
2217 '''attribute : IDENTIFIER '''
2218 print(p)
2219 # { named_pexpr_t*tmp = new named_pexpr_t;
2220 # tmp->name = lex_strings.make($1);
2221 # tmp->parm = 0;
2222 # delete[]$1;
2223 # $$ = tmp;
2224 # }
2225 ()
2226 def p_attribute_2(p):
2227 '''attribute : IDENTIFIER '=' expression '''
2228 print(p)
2229 # { PExpr*tmp = $3;
2230 # named_pexpr_t*tmp2 = new named_pexpr_t;
2231 # tmp2->name = lex_strings.make($1);
2232 # tmp2->parm = tmp;
2233 # delete[]$1;
2234 # $$ = tmp2;
2235 # }
2236 ()
2237 def p_block_item_decl_1(p):
2238 '''block_item_decl : data_type register_variable_list ';' '''
2239 print(p)
2240 # { if ($1) pform_set_data_type(@1, $1, $2, NetNet::REG, attributes_in_context);
2241 # }
2242 ()
2243 def p_block_item_decl_2(p):
2244 '''block_item_decl : variable_lifetime data_type register_variable_list ';' '''
2245 print(p)
2246 # { if ($2) pform_set_data_type(@2, $2, $3, NetNet::REG, attributes_in_context);
2247 # var_lifetime = LexicalScope::INHERITED;
2248 # }
2249 ()
2250 def p_block_item_decl_3(p):
2251 '''block_item_decl : K_reg data_type register_variable_list ';' '''
2252 print(p)
2253 # { if ($2) pform_set_data_type(@2, $2, $3, NetNet::REG, attributes_in_context);
2254 # }
2255 ()
2256 def p_block_item_decl_4(p):
2257 '''block_item_decl : variable_lifetime K_reg data_type register_variable_list ';' '''
2258 print(p)
2259 # { if ($3) pform_set_data_type(@3, $3, $4, NetNet::REG, attributes_in_context);
2260 # var_lifetime = LexicalScope::INHERITED;
2261 # }
2262 ()
2263 def p_block_item_decl_5(p):
2264 '''block_item_decl : K_event event_variable_list ';' '''
2265 print(p)
2266 # { if ($2) pform_make_events($2, @1.text, @1.first_line);
2267 # }
2268 ()
2269 def p_block_item_decl_6(p):
2270 '''block_item_decl : K_parameter param_type parameter_assign_list ';' '''
2271 print(p)
2272 ()
2273 def p_block_item_decl_7(p):
2274 '''block_item_decl : K_localparam param_type localparam_assign_list ';' '''
2275 print(p)
2276 ()
2277 def p_block_item_decl_8(p):
2278 '''block_item_decl : type_declaration '''
2279 print(p)
2280 ()
2281 def p_block_item_decl_9(p):
2282 '''block_item_decl : K_integer error ';' '''
2283 print(p)
2284 # { yyerror(@1, "error: syntax error in integer variable list.");
2285 # yyerrok;
2286 # }
2287 ()
2288 def p_block_item_decl_10(p):
2289 '''block_item_decl : K_time error ';' '''
2290 print(p)
2291 # { yyerror(@1, "error: syntax error in time variable list.");
2292 # yyerrok;
2293 # }
2294 ()
2295 def p_block_item_decl_11(p):
2296 '''block_item_decl : K_parameter error ';' '''
2297 print(p)
2298 # { yyerror(@1, "error: syntax error in parameter list.");
2299 # yyerrok;
2300 # }
2301 ()
2302 def p_block_item_decl_12(p):
2303 '''block_item_decl : K_localparam error ';' '''
2304 print(p)
2305 # { yyerror(@1, "error: syntax error localparam list.");
2306 # yyerrok;
2307 # }
2308 ()
2309 def p_block_item_decls_1(p):
2310 '''block_item_decls : block_item_decl '''
2311 print(p)
2312 ()
2313 def p_block_item_decls_2(p):
2314 '''block_item_decls : block_item_decls block_item_decl '''
2315 print(p)
2316 ()
2317 def p_block_item_decls_opt_1(p):
2318 '''block_item_decls_opt : block_item_decls '''
2319 print(p)
2320 # { $$ = true; }
2321 ()
2322 def p_block_item_decls_opt_2(p):
2323 '''block_item_decls_opt : '''
2324 print(p)
2325 # { $$ = false; }
2326 ()
2327 def p_type_declaration_1(p):
2328 '''type_declaration : K_typedef data_type IDENTIFIER dimensions_opt ';' '''
2329 print(p)
2330 # { perm_string name = lex_strings.make($3);
2331 # pform_set_typedef(name, $2, $4);
2332 # delete[]$3;
2333 # }
2334 ()
2335 def p_type_declaration_2(p):
2336 '''type_declaration : K_typedef data_type TYPE_IDENTIFIER ';' '''
2337 print(p)
2338 # { perm_string name = lex_strings.make($3.text);
2339 # if (pform_test_type_identifier_local(name)) {
2340 # yyerror(@3, "error: Typedef identifier \"%s\" is already a type name.", $3.text);
2341 #
2342 # } else {
2343 # pform_set_typedef(name, $2, NULL);
2344 # }
2345 # delete[]$3.text;
2346 # }
2347 ()
2348 def p_type_declaration_3(p):
2349 '''type_declaration : K_typedef K_class IDENTIFIER ';' '''
2350 print(p)
2351 # { // Create a synthetic typedef for the class name so that the
2352 # // lexor detects the name as a type.
2353 # perm_string name = lex_strings.make($3);
2354 # class_type_t*tmp = new class_type_t(name);
2355 # FILE_NAME(tmp, @3);
2356 # pform_set_typedef(name, tmp, NULL);
2357 # delete[]$3;
2358 # }
2359 ()
2360 def p_type_declaration_4(p):
2361 '''type_declaration : K_typedef K_enum IDENTIFIER ';' '''
2362 print(p)
2363 # { yyerror(@1, "sorry: Enum forward declarations not supported yet."); }
2364 ()
2365 def p_type_declaration_5(p):
2366 '''type_declaration : K_typedef K_struct IDENTIFIER ';' '''
2367 print(p)
2368 # { yyerror(@1, "sorry: Struct forward declarations not supported yet."); }
2369 ()
2370 def p_type_declaration_6(p):
2371 '''type_declaration : K_typedef K_union IDENTIFIER ';' '''
2372 print(p)
2373 # { yyerror(@1, "sorry: Union forward declarations not supported yet."); }
2374 ()
2375 def p_type_declaration_7(p):
2376 '''type_declaration : K_typedef IDENTIFIER ';' '''
2377 print(p)
2378 # { // Create a synthetic typedef for the class name so that the
2379 # // lexor detects the name as a type.
2380 # perm_string name = lex_strings.make($2);
2381 # class_type_t*tmp = new class_type_t(name);
2382 # FILE_NAME(tmp, @2);
2383 # pform_set_typedef(name, tmp, NULL);
2384 # delete[]$2;
2385 # }
2386 ()
2387 def p_type_declaration_8(p):
2388 '''type_declaration : K_typedef error ';' '''
2389 print(p)
2390 # { yyerror(@2, "error: Syntax error in typedef clause.");
2391 # yyerrok;
2392 # }
2393 ()
2394 def p_enum_data_type_1(p):
2395 '''enum_data_type : K_enum '{' enum_name_list '}' '''
2396 print(p)
2397 # { enum_type_t*enum_type = new enum_type_t;
2398 # FILE_NAME(enum_type, @1);
2399 # enum_type->names .reset($3);
2400 # enum_type->base_type = IVL_VT_BOOL;
2401 # enum_type->signed_flag = true;
2402 # enum_type->integer_flag = false;
2403 # enum_type->range.reset(make_range_from_width(32));
2404 # $$ = enum_type;
2405 # }
2406 ()
2407 def p_enum_data_type_2(p):
2408 '''enum_data_type : K_enum atom2_type signed_unsigned_opt '{' enum_name_list '}' '''
2409 print(p)
2410 # { enum_type_t*enum_type = new enum_type_t;
2411 # FILE_NAME(enum_type, @1);
2412 # enum_type->names .reset($5);
2413 # enum_type->base_type = IVL_VT_BOOL;
2414 # enum_type->signed_flag = $3;
2415 # enum_type->integer_flag = false;
2416 # enum_type->range.reset(make_range_from_width($2));
2417 # $$ = enum_type;
2418 # }
2419 ()
2420 def p_enum_data_type_3(p):
2421 '''enum_data_type : K_enum K_integer signed_unsigned_opt '{' enum_name_list '}' '''
2422 print(p)
2423 # { enum_type_t*enum_type = new enum_type_t;
2424 # FILE_NAME(enum_type, @1);
2425 # enum_type->names .reset($5);
2426 # enum_type->base_type = IVL_VT_LOGIC;
2427 # enum_type->signed_flag = $3;
2428 # enum_type->integer_flag = true;
2429 # enum_type->range.reset(make_range_from_width(integer_width));
2430 # $$ = enum_type;
2431 # }
2432 ()
2433 def p_enum_data_type_4(p):
2434 '''enum_data_type : K_enum K_logic unsigned_signed_opt dimensions_opt '{' enum_name_list '}' '''
2435 print(p)
2436 # { enum_type_t*enum_type = new enum_type_t;
2437 # FILE_NAME(enum_type, @1);
2438 # enum_type->names .reset($6);
2439 # enum_type->base_type = IVL_VT_LOGIC;
2440 # enum_type->signed_flag = $3;
2441 # enum_type->integer_flag = false;
2442 # enum_type->range.reset($4 ? $4 : make_range_from_width(1));
2443 # $$ = enum_type;
2444 # }
2445 ()
2446 def p_enum_data_type_5(p):
2447 '''enum_data_type : K_enum K_reg unsigned_signed_opt dimensions_opt '{' enum_name_list '}' '''
2448 print(p)
2449 # { enum_type_t*enum_type = new enum_type_t;
2450 # FILE_NAME(enum_type, @1);
2451 # enum_type->names .reset($6);
2452 # enum_type->base_type = IVL_VT_LOGIC;
2453 # enum_type->signed_flag = $3;
2454 # enum_type->integer_flag = false;
2455 # enum_type->range.reset($4 ? $4 : make_range_from_width(1));
2456 # $$ = enum_type;
2457 # }
2458 ()
2459 def p_enum_data_type_6(p):
2460 '''enum_data_type : K_enum K_bit unsigned_signed_opt dimensions_opt '{' enum_name_list '}' '''
2461 print(p)
2462 # { enum_type_t*enum_type = new enum_type_t;
2463 # FILE_NAME(enum_type, @1);
2464 # enum_type->names .reset($6);
2465 # enum_type->base_type = IVL_VT_BOOL;
2466 # enum_type->signed_flag = $3;
2467 # enum_type->integer_flag = false;
2468 # enum_type->range.reset($4 ? $4 : make_range_from_width(1));
2469 # $$ = enum_type;
2470 # }
2471 ()
2472 def p_enum_name_list_1(p):
2473 '''enum_name_list : enum_name '''
2474 print(p)
2475 # { $$ = $1;
2476 # }
2477 ()
2478 def p_enum_name_list_2(p):
2479 '''enum_name_list : enum_name_list ',' enum_name '''
2480 print(p)
2481 # { list<named_pexpr_t>*lst = $1;
2482 # lst->splice(lst->end(), *$3);
2483 # delete $3;
2484 # $$ = lst;
2485 # }
2486 ()
2487 def p_pos_neg_number_1(p):
2488 '''pos_neg_number : number '''
2489 print(p)
2490 # { $$ = $1;
2491 # }
2492 ()
2493 def p_pos_neg_number_2(p):
2494 '''pos_neg_number : '-' number '''
2495 print(p)
2496 # { verinum tmp = -(*($2));
2497 # *($2) = tmp;
2498 # $$ = $2;
2499 # }
2500 ()
2501 def p_enum_name_1(p):
2502 '''enum_name : IDENTIFIER '''
2503 print(p)
2504 # { perm_string name = lex_strings.make($1);
2505 # delete[]$1;
2506 # $$ = make_named_number(name);
2507 # }
2508 ()
2509 def p_enum_name_2(p):
2510 '''enum_name : IDENTIFIER '[' pos_neg_number ']' '''
2511 print(p)
2512 # { perm_string name = lex_strings.make($1);
2513 # long count = check_enum_seq_value(@1, $3, false);
2514 # delete[]$1;
2515 # $$ = make_named_numbers(name, 0, count-1);
2516 # delete $3;
2517 # }
2518 ()
2519 def p_enum_name_3(p):
2520 '''enum_name : IDENTIFIER '[' pos_neg_number ':' pos_neg_number ']' '''
2521 print(p)
2522 # { perm_string name = lex_strings.make($1);
2523 # $$ = make_named_numbers(name, check_enum_seq_value(@1, $3, true),
2524 # check_enum_seq_value(@1, $5, true));
2525 # delete[]$1;
2526 # delete $3;
2527 # delete $5;
2528 # }
2529 ()
2530 def p_enum_name_4(p):
2531 '''enum_name : IDENTIFIER '=' expression '''
2532 print(p)
2533 # { perm_string name = lex_strings.make($1);
2534 # delete[]$1;
2535 # $$ = make_named_number(name, $3);
2536 # }
2537 ()
2538 def p_enum_name_5(p):
2539 '''enum_name : IDENTIFIER '[' pos_neg_number ']' '=' expression '''
2540 print(p)
2541 # { perm_string name = lex_strings.make($1);
2542 # long count = check_enum_seq_value(@1, $3, false);
2543 # $$ = make_named_numbers(name, 0, count-1, $6);
2544 # delete[]$1;
2545 # delete $3;
2546 # }
2547 ()
2548 def p_enum_name_6(p):
2549 '''enum_name : IDENTIFIER '[' pos_neg_number ':' pos_neg_number ']' '=' expression '''
2550 print(p)
2551 # { perm_string name = lex_strings.make($1);
2552 # $$ = make_named_numbers(name, check_enum_seq_value(@1, $3, true),
2553 # check_enum_seq_value(@1, $5, true), $8);
2554 # delete[]$1;
2555 # delete $3;
2556 # delete $5;
2557 # }
2558 ()
2559 def p_struct_data_type_1(p):
2560 '''struct_data_type : K_struct K_packed_opt '{' struct_union_member_list '}' '''
2561 print(p)
2562 # { struct_type_t*tmp = new struct_type_t;
2563 # FILE_NAME(tmp, @1);
2564 # tmp->packed_flag = $2;
2565 # tmp->union_flag = false;
2566 # tmp->members .reset($4);
2567 # $$ = tmp;
2568 # }
2569 ()
2570 def p_struct_data_type_2(p):
2571 '''struct_data_type : K_union K_packed_opt '{' struct_union_member_list '}' '''
2572 print(p)
2573 # { struct_type_t*tmp = new struct_type_t;
2574 # FILE_NAME(tmp, @1);
2575 # tmp->packed_flag = $2;
2576 # tmp->union_flag = true;
2577 # tmp->members .reset($4);
2578 # $$ = tmp;
2579 # }
2580 ()
2581 def p_struct_data_type_3(p):
2582 '''struct_data_type : K_struct K_packed_opt '{' error '}' '''
2583 print(p)
2584 # { yyerror(@3, "error: Errors in struct member list.");
2585 # yyerrok;
2586 # struct_type_t*tmp = new struct_type_t;
2587 # FILE_NAME(tmp, @1);
2588 # tmp->packed_flag = $2;
2589 # tmp->union_flag = false;
2590 # $$ = tmp;
2591 # }
2592 ()
2593 def p_struct_data_type_4(p):
2594 '''struct_data_type : K_union K_packed_opt '{' error '}' '''
2595 print(p)
2596 # { yyerror(@3, "error: Errors in union member list.");
2597 # yyerrok;
2598 # struct_type_t*tmp = new struct_type_t;
2599 # FILE_NAME(tmp, @1);
2600 # tmp->packed_flag = $2;
2601 # tmp->union_flag = true;
2602 # $$ = tmp;
2603 # }
2604 ()
2605 def p_struct_union_member_list_1(p):
2606 '''struct_union_member_list : struct_union_member_list struct_union_member '''
2607 print(p)
2608 # { list<struct_member_t*>*tmp = $1;
2609 # tmp->push_back($2);
2610 # $$ = tmp;
2611 # }
2612 ()
2613 def p_struct_union_member_list_2(p):
2614 '''struct_union_member_list : struct_union_member '''
2615 print(p)
2616 # { list<struct_member_t*>*tmp = new list<struct_member_t*>;
2617 # tmp->push_back($1);
2618 # $$ = tmp;
2619 # }
2620 ()
2621 def p_struct_union_member_1(p):
2622 '''struct_union_member : attribute_list_opt data_type list_of_variable_decl_assignments ';' '''
2623 print(p)
2624 # { struct_member_t*tmp = new struct_member_t;
2625 # FILE_NAME(tmp, @2);
2626 # tmp->type .reset($2);
2627 # tmp->names .reset($3);
2628 # $$ = tmp;
2629 # }
2630 ()
2631 def p_struct_union_member_2(p):
2632 '''struct_union_member : error ';' '''
2633 print(p)
2634 # { yyerror(@2, "Error in struct/union member.");
2635 # yyerrok;
2636 # $$ = 0;
2637 # }
2638 ()
2639 def p_case_item_1(p):
2640 '''case_item : expression_list_proper ':' statement_or_null '''
2641 print(p)
2642 # { PCase::Item*tmp = new PCase::Item;
2643 # tmp->expr = *$1;
2644 # tmp->stat = $3;
2645 # delete $1;
2646 # $$ = tmp;
2647 # }
2648 ()
2649 def p_case_item_2(p):
2650 '''case_item : K_default ':' statement_or_null '''
2651 print(p)
2652 # { PCase::Item*tmp = new PCase::Item;
2653 # tmp->stat = $3;
2654 # $$ = tmp;
2655 # }
2656 ()
2657 def p_case_item_3(p):
2658 '''case_item : K_default statement_or_null '''
2659 print(p)
2660 # { PCase::Item*tmp = new PCase::Item;
2661 # tmp->stat = $2;
2662 # $$ = tmp;
2663 # }
2664 ()
2665 def p_case_item_4(p):
2666 '''case_item : error ':' statement_or_null '''
2667 print(p)
2668 # { yyerror(@2, "error: Incomprehensible case expression.");
2669 # yyerrok;
2670 # }
2671 ()
2672 def p_case_items_1(p):
2673 '''case_items : case_items case_item '''
2674 print(p)
2675 # { svector<PCase::Item*>*tmp;
2676 # tmp = new svector<PCase::Item*>(*$1, $2);
2677 # delete $1;
2678 # $$ = tmp;
2679 # }
2680 ()
2681 def p_case_items_2(p):
2682 '''case_items : case_item '''
2683 print(p)
2684 # { svector<PCase::Item*>*tmp = new svector<PCase::Item*>(1);
2685 # (*tmp)[0] = $1;
2686 # $$ = tmp;
2687 # }
2688 ()
2689 def p_charge_strength_1(p):
2690 '''charge_strength : '(' K_small ')' '''
2691 print(p)
2692 ()
2693 def p_charge_strength_2(p):
2694 '''charge_strength : '(' K_medium ')' '''
2695 print(p)
2696 ()
2697 def p_charge_strength_3(p):
2698 '''charge_strength : '(' K_large ')' '''
2699 print(p)
2700 ()
2701 def p_charge_strength_opt_1(p):
2702 '''charge_strength_opt : charge_strength '''
2703 print(p)
2704 ()
2705 def p_charge_strength_opt_2(p):
2706 '''charge_strength_opt : '''
2707 print(p)
2708 ()
2709 def p_defparam_assign_1(p):
2710 '''defparam_assign : hierarchy_identifier '=' expression '''
2711 print(p)
2712 # { pform_set_defparam(*$1, $3);
2713 # delete $1;
2714 # }
2715 ()
2716 def p_defparam_assign_list_1(p):
2717 '''defparam_assign_list : defparam_assign '''
2718 print(p)
2719 ()
2720 def p_defparam_assign_list_2(p):
2721 '''defparam_assign_list : dimensions defparam_assign '''
2722 print(p)
2723 # { yyerror(@1, "error: defparam may not include a range.");
2724 # delete $1;
2725 # }
2726 ()
2727 def p_defparam_assign_list_3(p):
2728 '''defparam_assign_list : defparam_assign_list ',' defparam_assign '''
2729 print(p)
2730 ()
2731 def p_delay1_1(p):
2732 '''delay1 : '#' delay_value_simple '''
2733 print(p)
2734 # { list<PExpr*>*tmp = new list<PExpr*>;
2735 # tmp->push_back($2);
2736 # $$ = tmp;
2737 # }
2738 ()
2739 def p_delay1_2(p):
2740 '''delay1 : '#' '(' delay_value ')' '''
2741 print(p)
2742 # { list<PExpr*>*tmp = new list<PExpr*>;
2743 # tmp->push_back($3);
2744 # $$ = tmp;
2745 # }
2746 ()
2747 def p_delay3_1(p):
2748 '''delay3 : '#' delay_value_simple '''
2749 print(p)
2750 # { list<PExpr*>*tmp = new list<PExpr*>;
2751 # tmp->push_back($2);
2752 # $$ = tmp;
2753 # }
2754 ()
2755 def p_delay3_2(p):
2756 '''delay3 : '#' '(' delay_value ')' '''
2757 print(p)
2758 # { list<PExpr*>*tmp = new list<PExpr*>;
2759 # tmp->push_back($3);
2760 # $$ = tmp;
2761 # }
2762 ()
2763 def p_delay3_3(p):
2764 '''delay3 : '#' '(' delay_value ',' delay_value ')' '''
2765 print(p)
2766 # { list<PExpr*>*tmp = new list<PExpr*>;
2767 # tmp->push_back($3);
2768 # tmp->push_back($5);
2769 # $$ = tmp;
2770 # }
2771 ()
2772 def p_delay3_4(p):
2773 '''delay3 : '#' '(' delay_value ',' delay_value ',' delay_value ')' '''
2774 print(p)
2775 # { list<PExpr*>*tmp = new list<PExpr*>;
2776 # tmp->push_back($3);
2777 # tmp->push_back($5);
2778 # tmp->push_back($7);
2779 # $$ = tmp;
2780 # }
2781 ()
2782 def p_delay3_opt_1(p):
2783 '''delay3_opt : delay3 '''
2784 print(p)
2785 # { $$ = $1; }
2786 ()
2787 def p_delay3_opt_2(p):
2788 '''delay3_opt : '''
2789 print(p)
2790 # { $$ = 0; }
2791 ()
2792 def p_delay_value_list_1(p):
2793 '''delay_value_list : delay_value '''
2794 print(p)
2795 # { list<PExpr*>*tmp = new list<PExpr*>;
2796 # tmp->push_back($1);
2797 # $$ = tmp;
2798 # }
2799 ()
2800 def p_delay_value_list_2(p):
2801 '''delay_value_list : delay_value_list ',' delay_value '''
2802 print(p)
2803 # { list<PExpr*>*tmp = $1;
2804 # tmp->push_back($3);
2805 # $$ = tmp;
2806 # }
2807 ()
2808 def p_delay_value_1(p):
2809 '''delay_value : expression '''
2810 print(p)
2811 # { PExpr*tmp = $1;
2812 # $$ = tmp;
2813 # }
2814 ()
2815 def p_delay_value_2(p):
2816 '''delay_value : expression ':' expression ':' expression '''
2817 print(p)
2818 # { $$ = pform_select_mtm_expr($1, $3, $5); }
2819 ()
2820 def p_delay_value_simple_1(p):
2821 '''delay_value_simple : DEC_NUMBER '''
2822 print(p)
2823 # { verinum*tmp = $1;
2824 # if (tmp == 0) {
2825 # yyerror(@1, "internal error: delay.");
2826 # $$ = 0;
2827 # } else {
2828 # $$ = new PENumber(tmp);
2829 # FILE_NAME($$, @1);
2830 # }
2831 # based_size = 0;
2832 # }
2833 ()
2834 def p_delay_value_simple_2(p):
2835 '''delay_value_simple : REALTIME '''
2836 print(p)
2837 # { verireal*tmp = $1;
2838 # if (tmp == 0) {
2839 # yyerror(@1, "internal error: delay.");
2840 # $$ = 0;
2841 # } else {
2842 # $$ = new PEFNumber(tmp);
2843 # FILE_NAME($$, @1);
2844 # }
2845 # }
2846 ()
2847 def p_delay_value_simple_3(p):
2848 '''delay_value_simple : IDENTIFIER '''
2849 print(p)
2850 # { PEIdent*tmp = new PEIdent(lex_strings.make($1));
2851 # FILE_NAME(tmp, @1);
2852 # $$ = tmp;
2853 # delete[]$1;
2854 # }
2855 ()
2856 def p_delay_value_simple_4(p):
2857 '''delay_value_simple : TIME_LITERAL '''
2858 print(p)
2859 # { int unit;
2860 #
2861 # based_size = 0;
2862 # $$ = 0;
2863 # if ($1 == 0 || !get_time_unit($1, unit))
2864 # yyerror(@1, "internal error: delay.");
2865 # else {
2866 # double p = pow(10.0,
2867 # (double)(unit - pform_get_timeunit()));
2868 # double time = atof($1) * p;
2869 #
2870 # verireal *v = new verireal(time);
2871 # $$ = new PEFNumber(v);
2872 # FILE_NAME($$, @1);
2873 # }
2874 # }
2875 ()
2876 def p_optional_semicolon_1(p):
2877 '''optional_semicolon : ';' '''
2878 print(p)
2879 ()
2880 def p_optional_semicolon_2(p):
2881 '''optional_semicolon : '''
2882 print(p)
2883 ()
2884 def p_discipline_declaration_1(p):
2885 '''discipline_declaration : K_discipline IDENTIFIER optional_semicolon _embed0_discipline_declaration discipline_items K_enddiscipline '''
2886 print(p)
2887 # { pform_end_discipline(@1); delete[] $2; }
2888 ()
2889 def p__embed0_discipline_declaration(p):
2890 '''_embed0_discipline_declaration : '''
2891 # { pform_start_discipline($2); }
2892 ()
2893 def p_discipline_items_1(p):
2894 '''discipline_items : discipline_items discipline_item '''
2895 print(p)
2896 ()
2897 def p_discipline_items_2(p):
2898 '''discipline_items : discipline_item '''
2899 print(p)
2900 ()
2901 def p_discipline_item_1(p):
2902 '''discipline_item : K_domain K_discrete ';' '''
2903 print(p)
2904 # { pform_discipline_domain(@1, IVL_DIS_DISCRETE); }
2905 ()
2906 def p_discipline_item_2(p):
2907 '''discipline_item : K_domain K_continuous ';' '''
2908 print(p)
2909 # { pform_discipline_domain(@1, IVL_DIS_CONTINUOUS); }
2910 ()
2911 def p_discipline_item_3(p):
2912 '''discipline_item : K_potential IDENTIFIER ';' '''
2913 print(p)
2914 # { pform_discipline_potential(@1, $2); delete[] $2; }
2915 ()
2916 def p_discipline_item_4(p):
2917 '''discipline_item : K_flow IDENTIFIER ';' '''
2918 print(p)
2919 # { pform_discipline_flow(@1, $2); delete[] $2; }
2920 ()
2921 def p_nature_declaration_1(p):
2922 '''nature_declaration : K_nature IDENTIFIER optional_semicolon _embed0_nature_declaration nature_items K_endnature '''
2923 print(p)
2924 # { pform_end_nature(@1); delete[] $2; }
2925 ()
2926 def p__embed0_nature_declaration(p):
2927 '''_embed0_nature_declaration : '''
2928 # { pform_start_nature($2); }
2929 ()
2930 def p_nature_items_1(p):
2931 '''nature_items : nature_items nature_item '''
2932 print(p)
2933 ()
2934 def p_nature_items_2(p):
2935 '''nature_items : nature_item '''
2936 print(p)
2937 ()
2938 def p_nature_item_1(p):
2939 '''nature_item : K_units '=' STRING ';' '''
2940 print(p)
2941 # { delete[] $3; }
2942 ()
2943 def p_nature_item_2(p):
2944 '''nature_item : K_abstol '=' expression ';' '''
2945 print(p)
2946 ()
2947 def p_nature_item_3(p):
2948 '''nature_item : K_access '=' IDENTIFIER ';' '''
2949 print(p)
2950 # { pform_nature_access(@1, $3); delete[] $3; }
2951 ()
2952 def p_nature_item_4(p):
2953 '''nature_item : K_idt_nature '=' IDENTIFIER ';' '''
2954 print(p)
2955 # { delete[] $3; }
2956 ()
2957 def p_nature_item_5(p):
2958 '''nature_item : K_ddt_nature '=' IDENTIFIER ';' '''
2959 print(p)
2960 # { delete[] $3; }
2961 ()
2962 def p_config_declaration_1(p):
2963 '''config_declaration : K_config IDENTIFIER ';' K_design lib_cell_identifiers ';' list_of_config_rule_statements K_endconfig '''
2964 print(p)
2965 # { cerr << @1 << ": sorry: config declarations are not supported and "
2966 # "will be skipped." << endl;
2967 # delete[] $2;
2968 # }
2969 ()
2970 def p_lib_cell_identifiers_1(p):
2971 '''lib_cell_identifiers : '''
2972 print(p)
2973 ()
2974 def p_lib_cell_identifiers_2(p):
2975 '''lib_cell_identifiers : lib_cell_identifiers lib_cell_id '''
2976 print(p)
2977 ()
2978 def p_list_of_config_rule_statements_1(p):
2979 '''list_of_config_rule_statements : '''
2980 print(p)
2981 ()
2982 def p_list_of_config_rule_statements_2(p):
2983 '''list_of_config_rule_statements : list_of_config_rule_statements config_rule_statement '''
2984 print(p)
2985 ()
2986 def p_config_rule_statement_1(p):
2987 '''config_rule_statement : K_default K_liblist list_of_libraries ';' '''
2988 print(p)
2989 ()
2990 def p_config_rule_statement_2(p):
2991 '''config_rule_statement : K_instance hierarchy_identifier K_liblist list_of_libraries ';' '''
2992 print(p)
2993 # { delete $2; }
2994 ()
2995 def p_config_rule_statement_3(p):
2996 '''config_rule_statement : K_instance hierarchy_identifier K_use lib_cell_id opt_config ';' '''
2997 print(p)
2998 # { delete $2; }
2999 ()
3000 def p_config_rule_statement_4(p):
3001 '''config_rule_statement : K_cell lib_cell_id K_liblist list_of_libraries ';' '''
3002 print(p)
3003 ()
3004 def p_config_rule_statement_5(p):
3005 '''config_rule_statement : K_cell lib_cell_id K_use lib_cell_id opt_config ';' '''
3006 print(p)
3007 ()
3008 def p_opt_config_1(p):
3009 '''opt_config : '''
3010 print(p)
3011 ()
3012 def p_opt_config_2(p):
3013 '''opt_config : ':' K_config '''
3014 print(p)
3015 ()
3016 def p_lib_cell_id_1(p):
3017 '''lib_cell_id : IDENTIFIER '''
3018 print(p)
3019 # { delete[] $1; }
3020 ()
3021 def p_lib_cell_id_2(p):
3022 '''lib_cell_id : IDENTIFIER '.' IDENTIFIER '''
3023 print(p)
3024 # { delete[] $1; delete[] $3; }
3025 ()
3026 def p_list_of_libraries_1(p):
3027 '''list_of_libraries : '''
3028 print(p)
3029 ()
3030 def p_list_of_libraries_2(p):
3031 '''list_of_libraries : list_of_libraries IDENTIFIER '''
3032 print(p)
3033 # { delete[] $2; }
3034 ()
3035 def p_drive_strength_1(p):
3036 '''drive_strength : '(' dr_strength0 ',' dr_strength1 ')' '''
3037 print(p)
3038 # { $$.str0 = $2.str0;
3039 # $$.str1 = $4.str1;
3040 # }
3041 ()
3042 def p_drive_strength_2(p):
3043 '''drive_strength : '(' dr_strength1 ',' dr_strength0 ')' '''
3044 print(p)
3045 # { $$.str0 = $4.str0;
3046 # $$.str1 = $2.str1;
3047 # }
3048 ()
3049 def p_drive_strength_3(p):
3050 '''drive_strength : '(' dr_strength0 ',' K_highz1 ')' '''
3051 print(p)
3052 # { $$.str0 = $2.str0;
3053 # $$.str1 = IVL_DR_HiZ;
3054 # }
3055 ()
3056 def p_drive_strength_4(p):
3057 '''drive_strength : '(' dr_strength1 ',' K_highz0 ')' '''
3058 print(p)
3059 # { $$.str0 = IVL_DR_HiZ;
3060 # $$.str1 = $2.str1;
3061 # }
3062 ()
3063 def p_drive_strength_5(p):
3064 '''drive_strength : '(' K_highz1 ',' dr_strength0 ')' '''
3065 print(p)
3066 # { $$.str0 = $4.str0;
3067 # $$.str1 = IVL_DR_HiZ;
3068 # }
3069 ()
3070 def p_drive_strength_6(p):
3071 '''drive_strength : '(' K_highz0 ',' dr_strength1 ')' '''
3072 print(p)
3073 # { $$.str0 = IVL_DR_HiZ;
3074 # $$.str1 = $4.str1;
3075 # }
3076 ()
3077 def p_drive_strength_opt_1(p):
3078 '''drive_strength_opt : drive_strength '''
3079 print(p)
3080 # { $$ = $1; }
3081 ()
3082 def p_drive_strength_opt_2(p):
3083 '''drive_strength_opt : '''
3084 print(p)
3085 # { $$.str0 = IVL_DR_STRONG; $$.str1 = IVL_DR_STRONG; }
3086 ()
3087 def p_dr_strength0_1(p):
3088 '''dr_strength0 : K_supply0 '''
3089 print(p)
3090 # { $$.str0 = IVL_DR_SUPPLY; }
3091 ()
3092 def p_dr_strength0_2(p):
3093 '''dr_strength0 : K_strong0 '''
3094 print(p)
3095 # { $$.str0 = IVL_DR_STRONG; }
3096 ()
3097 def p_dr_strength0_3(p):
3098 '''dr_strength0 : K_pull0 '''
3099 print(p)
3100 # { $$.str0 = IVL_DR_PULL; }
3101 ()
3102 def p_dr_strength0_4(p):
3103 '''dr_strength0 : K_weak0 '''
3104 print(p)
3105 # { $$.str0 = IVL_DR_WEAK; }
3106 ()
3107 def p_dr_strength1_1(p):
3108 '''dr_strength1 : K_supply1 '''
3109 print(p)
3110 # { $$.str1 = IVL_DR_SUPPLY; }
3111 ()
3112 def p_dr_strength1_2(p):
3113 '''dr_strength1 : K_strong1 '''
3114 print(p)
3115 # { $$.str1 = IVL_DR_STRONG; }
3116 ()
3117 def p_dr_strength1_3(p):
3118 '''dr_strength1 : K_pull1 '''
3119 print(p)
3120 # { $$.str1 = IVL_DR_PULL; }
3121 ()
3122 def p_dr_strength1_4(p):
3123 '''dr_strength1 : K_weak1 '''
3124 print(p)
3125 # { $$.str1 = IVL_DR_WEAK; }
3126 ()
3127 def p_clocking_event_opt_1(p):
3128 '''clocking_event_opt : event_control '''
3129 print(p)
3130 ()
3131 def p_clocking_event_opt_2(p):
3132 '''clocking_event_opt : '''
3133 print(p)
3134 ()
3135 def p_event_control_1(p):
3136 '''event_control : '@' hierarchy_identifier '''
3137 print(p)
3138 # { PEIdent*tmpi = new PEIdent(*$2);
3139 # PEEvent*tmpe = new PEEvent(PEEvent::ANYEDGE, tmpi);
3140 # PEventStatement*tmps = new PEventStatement(tmpe);
3141 # FILE_NAME(tmps, @1);
3142 # $$ = tmps;
3143 # delete $2;
3144 # }
3145 ()
3146 def p_event_control_2(p):
3147 '''event_control : '@' '(' event_expression_list ')' '''
3148 print(p)
3149 # { PEventStatement*tmp = new PEventStatement(*$3);
3150 # FILE_NAME(tmp, @1);
3151 # delete $3;
3152 # $$ = tmp;
3153 # }
3154 ()
3155 def p_event_control_3(p):
3156 '''event_control : '@' '(' error ')' '''
3157 print(p)
3158 # { yyerror(@1, "error: Malformed event control expression.");
3159 # $$ = 0;
3160 # }
3161 ()
3162 def p_event_expression_list_1(p):
3163 '''event_expression_list : event_expression '''
3164 print(p)
3165 # { $$ = $1; }
3166 ()
3167 def p_event_expression_list_2(p):
3168 '''event_expression_list : event_expression_list K_or event_expression '''
3169 print(p)
3170 # { svector<PEEvent*>*tmp = new svector<PEEvent*>(*$1, *$3);
3171 # delete $1;
3172 # delete $3;
3173 # $$ = tmp;
3174 # }
3175 ()
3176 def p_event_expression_list_3(p):
3177 '''event_expression_list : event_expression_list ',' event_expression '''
3178 print(p)
3179 # { svector<PEEvent*>*tmp = new svector<PEEvent*>(*$1, *$3);
3180 # delete $1;
3181 # delete $3;
3182 # $$ = tmp;
3183 # }
3184 ()
3185 def p_event_expression_1(p):
3186 '''event_expression : K_posedge expression '''
3187 print(p)
3188 # { PEEvent*tmp = new PEEvent(PEEvent::POSEDGE, $2);
3189 # FILE_NAME(tmp, @1);
3190 # svector<PEEvent*>*tl = new svector<PEEvent*>(1);
3191 # (*tl)[0] = tmp;
3192 # $$ = tl;
3193 # }
3194 ()
3195 def p_event_expression_2(p):
3196 '''event_expression : K_negedge expression '''
3197 print(p)
3198 # { PEEvent*tmp = new PEEvent(PEEvent::NEGEDGE, $2);
3199 # FILE_NAME(tmp, @1);
3200 # svector<PEEvent*>*tl = new svector<PEEvent*>(1);
3201 # (*tl)[0] = tmp;
3202 # $$ = tl;
3203 # }
3204 ()
3205 def p_event_expression_3(p):
3206 '''event_expression : expression '''
3207 print(p)
3208 # { PEEvent*tmp = new PEEvent(PEEvent::ANYEDGE, $1);
3209 # FILE_NAME(tmp, @1);
3210 # svector<PEEvent*>*tl = new svector<PEEvent*>(1);
3211 # (*tl)[0] = tmp;
3212 # $$ = tl;
3213 # }
3214 ()
3215 def p_branch_probe_expression_1(p):
3216 '''branch_probe_expression : IDENTIFIER '(' IDENTIFIER ',' IDENTIFIER ')' '''
3217 print(p)
3218 # { $$ = pform_make_branch_probe_expression(@1, $1, $3, $5); }
3219 ()
3220 def p_branch_probe_expression_2(p):
3221 '''branch_probe_expression : IDENTIFIER '(' IDENTIFIER ')' '''
3222 print(p)
3223 # { $$ = pform_make_branch_probe_expression(@1, $1, $3); }
3224 ()
3225 def p_expression_1(p):
3226 '''expression : expr_primary_or_typename '''
3227 print(p)
3228 # { $$ = $1; }
3229 ()
3230 def p_expression_2(p):
3231 '''expression : inc_or_dec_expression '''
3232 print(p)
3233 # { $$ = $1; }
3234 ()
3235 def p_expression_3(p):
3236 '''expression : inside_expression '''
3237 print(p)
3238 # { $$ = $1; }
3239 ()
3240 def p_expression_4(p):
3241 '''expression : '+' attribute_list_opt expr_primary %prec UNARY_PREC '''
3242 print(p)
3243 # { $$ = $3; }
3244 ()
3245 def p_expression_5(p):
3246 '''expression : '-' attribute_list_opt expr_primary %prec UNARY_PREC '''
3247 print(p)
3248 # { PEUnary*tmp = new PEUnary('-', $3);
3249 # FILE_NAME(tmp, @3);
3250 # $$ = tmp;
3251 # }
3252 ()
3253 def p_expression_6(p):
3254 '''expression : '~' attribute_list_opt expr_primary %prec UNARY_PREC '''
3255 print(p)
3256 # { PEUnary*tmp = new PEUnary('~', $3);
3257 # FILE_NAME(tmp, @3);
3258 # $$ = tmp;
3259 # }
3260 ()
3261 def p_expression_7(p):
3262 '''expression : '&' attribute_list_opt expr_primary %prec UNARY_PREC '''
3263 print(p)
3264 # { PEUnary*tmp = new PEUnary('&', $3);
3265 # FILE_NAME(tmp, @3);
3266 # $$ = tmp;
3267 # }
3268 ()
3269 def p_expression_8(p):
3270 '''expression : '!' attribute_list_opt expr_primary %prec UNARY_PREC '''
3271 print(p)
3272 # { PEUnary*tmp = new PEUnary('!', $3);
3273 # FILE_NAME(tmp, @3);
3274 # $$ = tmp;
3275 # }
3276 ()
3277 def p_expression_9(p):
3278 '''expression : '|' attribute_list_opt expr_primary %prec UNARY_PREC '''
3279 print(p)
3280 # { PEUnary*tmp = new PEUnary('|', $3);
3281 # FILE_NAME(tmp, @3);
3282 # $$ = tmp;
3283 # }
3284 ()
3285 def p_expression_10(p):
3286 '''expression : '^' attribute_list_opt expr_primary %prec UNARY_PREC '''
3287 print(p)
3288 # { PEUnary*tmp = new PEUnary('^', $3);
3289 # FILE_NAME(tmp, @3);
3290 # $$ = tmp;
3291 # }
3292 ()
3293 def p_expression_11(p):
3294 '''expression : '~' '&' attribute_list_opt expr_primary %prec UNARY_PREC '''
3295 print(p)
3296 # { yyerror(@1, "error: '~' '&' is not a valid expression. "
3297 # "Please use operator '~&' instead.");
3298 # $$ = 0;
3299 # }
3300 ()
3301 def p_expression_12(p):
3302 '''expression : '~' '|' attribute_list_opt expr_primary %prec UNARY_PREC '''
3303 print(p)
3304 # { yyerror(@1, "error: '~' '|' is not a valid expression. "
3305 # "Please use operator '~|' instead.");
3306 # $$ = 0;
3307 # }
3308 ()
3309 def p_expression_13(p):
3310 '''expression : '~' '^' attribute_list_opt expr_primary %prec UNARY_PREC '''
3311 print(p)
3312 # { yyerror(@1, "error: '~' '^' is not a valid expression. "
3313 # "Please use operator '~^' instead.");
3314 # $$ = 0;
3315 # }
3316 ()
3317 def p_expression_14(p):
3318 '''expression : K_NAND attribute_list_opt expr_primary %prec UNARY_PREC '''
3319 print(p)
3320 # { PEUnary*tmp = new PEUnary('A', $3);
3321 # FILE_NAME(tmp, @3);
3322 # $$ = tmp;
3323 # }
3324 ()
3325 def p_expression_15(p):
3326 '''expression : K_NOR attribute_list_opt expr_primary %prec UNARY_PREC '''
3327 print(p)
3328 # { PEUnary*tmp = new PEUnary('N', $3);
3329 # FILE_NAME(tmp, @3);
3330 # $$ = tmp;
3331 # }
3332 ()
3333 def p_expression_16(p):
3334 '''expression : K_NXOR attribute_list_opt expr_primary %prec UNARY_PREC '''
3335 print(p)
3336 # { PEUnary*tmp = new PEUnary('X', $3);
3337 # FILE_NAME(tmp, @3);
3338 # $$ = tmp;
3339 # }
3340 ()
3341 def p_expression_17(p):
3342 '''expression : '!' error %prec UNARY_PREC '''
3343 print(p)
3344 # { yyerror(@1, "error: Operand of unary ! "
3345 # "is not a primary expression.");
3346 # $$ = 0;
3347 # }
3348 ()
3349 def p_expression_18(p):
3350 '''expression : '^' error %prec UNARY_PREC '''
3351 print(p)
3352 # { yyerror(@1, "error: Operand of reduction ^ "
3353 # "is not a primary expression.");
3354 # $$ = 0;
3355 # }
3356 ()
3357 def p_expression_19(p):
3358 '''expression : expression '^' attribute_list_opt expression '''
3359 print(p)
3360 # { PEBinary*tmp = new PEBinary('^', $1, $4);
3361 # FILE_NAME(tmp, @2);
3362 # $$ = tmp;
3363 # }
3364 ()
3365 def p_expression_20(p):
3366 '''expression : expression K_POW attribute_list_opt expression '''
3367 print(p)
3368 # { PEBinary*tmp = new PEBPower('p', $1, $4);
3369 # FILE_NAME(tmp, @2);
3370 # $$ = tmp;
3371 # }
3372 ()
3373 def p_expression_21(p):
3374 '''expression : expression '*' attribute_list_opt expression '''
3375 print(p)
3376 # { PEBinary*tmp = new PEBinary('*', $1, $4);
3377 # FILE_NAME(tmp, @2);
3378 # $$ = tmp;
3379 # }
3380 ()
3381 def p_expression_22(p):
3382 '''expression : expression '/' attribute_list_opt expression '''
3383 print(p)
3384 # { PEBinary*tmp = new PEBinary('/', $1, $4);
3385 # FILE_NAME(tmp, @2);
3386 # $$ = tmp;
3387 # }
3388 ()
3389 def p_expression_23(p):
3390 '''expression : expression '%' attribute_list_opt expression '''
3391 print(p)
3392 # { PEBinary*tmp = new PEBinary('%', $1, $4);
3393 # FILE_NAME(tmp, @2);
3394 # $$ = tmp;
3395 # }
3396 ()
3397 def p_expression_24(p):
3398 '''expression : expression '+' attribute_list_opt expression '''
3399 print(p)
3400 # { PEBinary*tmp = new PEBinary('+', $1, $4);
3401 # FILE_NAME(tmp, @2);
3402 # $$ = tmp;
3403 # }
3404 ()
3405 def p_expression_25(p):
3406 '''expression : expression '-' attribute_list_opt expression '''
3407 print(p)
3408 # { PEBinary*tmp = new PEBinary('-', $1, $4);
3409 # FILE_NAME(tmp, @2);
3410 # $$ = tmp;
3411 # }
3412 ()
3413 def p_expression_26(p):
3414 '''expression : expression '&' attribute_list_opt expression '''
3415 print(p)
3416 # { PEBinary*tmp = new PEBinary('&', $1, $4);
3417 # FILE_NAME(tmp, @2);
3418 # $$ = tmp;
3419 # }
3420 ()
3421 def p_expression_27(p):
3422 '''expression : expression '|' attribute_list_opt expression '''
3423 print(p)
3424 # { PEBinary*tmp = new PEBinary('|', $1, $4);
3425 # FILE_NAME(tmp, @2);
3426 # $$ = tmp;
3427 # }
3428 ()
3429 def p_expression_28(p):
3430 '''expression : expression K_NAND attribute_list_opt expression '''
3431 print(p)
3432 # { PEBinary*tmp = new PEBinary('A', $1, $4);
3433 # FILE_NAME(tmp, @2);
3434 # $$ = tmp;
3435 # }
3436 ()
3437 def p_expression_29(p):
3438 '''expression : expression K_NOR attribute_list_opt expression '''
3439 print(p)
3440 # { PEBinary*tmp = new PEBinary('O', $1, $4);
3441 # FILE_NAME(tmp, @2);
3442 # $$ = tmp;
3443 # }
3444 ()
3445 def p_expression_30(p):
3446 '''expression : expression K_NXOR attribute_list_opt expression '''
3447 print(p)
3448 # { PEBinary*tmp = new PEBinary('X', $1, $4);
3449 # FILE_NAME(tmp, @2);
3450 # $$ = tmp;
3451 # }
3452 ()
3453 def p_expression_31(p):
3454 '''expression : expression '<' attribute_list_opt expression '''
3455 print(p)
3456 # { PEBinary*tmp = new PEBComp('<', $1, $4);
3457 # FILE_NAME(tmp, @2);
3458 # $$ = tmp;
3459 # }
3460 ()
3461 def p_expression_32(p):
3462 '''expression : expression '>' attribute_list_opt expression '''
3463 print(p)
3464 # { PEBinary*tmp = new PEBComp('>', $1, $4);
3465 # FILE_NAME(tmp, @2);
3466 # $$ = tmp;
3467 # }
3468 ()
3469 def p_expression_33(p):
3470 '''expression : expression K_LS attribute_list_opt expression '''
3471 print(p)
3472 # { PEBinary*tmp = new PEBShift('l', $1, $4);
3473 # FILE_NAME(tmp, @2);
3474 # $$ = tmp;
3475 # }
3476 ()
3477 def p_expression_34(p):
3478 '''expression : expression K_RS attribute_list_opt expression '''
3479 print(p)
3480 # { PEBinary*tmp = new PEBShift('r', $1, $4);
3481 # FILE_NAME(tmp, @2);
3482 # $$ = tmp;
3483 # }
3484 ()
3485 def p_expression_35(p):
3486 '''expression : expression K_RSS attribute_list_opt expression '''
3487 print(p)
3488 # { PEBinary*tmp = new PEBShift('R', $1, $4);
3489 # FILE_NAME(tmp, @2);
3490 # $$ = tmp;
3491 # }
3492 ()
3493 def p_expression_36(p):
3494 '''expression : expression K_EQ attribute_list_opt expression '''
3495 print(p)
3496 # { PEBinary*tmp = new PEBComp('e', $1, $4);
3497 # FILE_NAME(tmp, @2);
3498 # $$ = tmp;
3499 # }
3500 ()
3501 def p_expression_37(p):
3502 '''expression : expression K_CEQ attribute_list_opt expression '''
3503 print(p)
3504 # { PEBinary*tmp = new PEBComp('E', $1, $4);
3505 # FILE_NAME(tmp, @2);
3506 # $$ = tmp;
3507 # }
3508 ()
3509 def p_expression_38(p):
3510 '''expression : expression K_WEQ attribute_list_opt expression '''
3511 print(p)
3512 # { PEBinary*tmp = new PEBComp('w', $1, $4);
3513 # FILE_NAME(tmp, @2);
3514 # $$ = tmp;
3515 # }
3516 ()
3517 def p_expression_39(p):
3518 '''expression : expression K_LE attribute_list_opt expression '''
3519 print(p)
3520 # { PEBinary*tmp = new PEBComp('L', $1, $4);
3521 # FILE_NAME(tmp, @2);
3522 # $$ = tmp;
3523 # }
3524 ()
3525 def p_expression_40(p):
3526 '''expression : expression K_GE attribute_list_opt expression '''
3527 print(p)
3528 # { PEBinary*tmp = new PEBComp('G', $1, $4);
3529 # FILE_NAME(tmp, @2);
3530 # $$ = tmp;
3531 # }
3532 ()
3533 def p_expression_41(p):
3534 '''expression : expression K_NE attribute_list_opt expression '''
3535 print(p)
3536 # { PEBinary*tmp = new PEBComp('n', $1, $4);
3537 # FILE_NAME(tmp, @2);
3538 # $$ = tmp;
3539 # }
3540 ()
3541 def p_expression_42(p):
3542 '''expression : expression K_CNE attribute_list_opt expression '''
3543 print(p)
3544 # { PEBinary*tmp = new PEBComp('N', $1, $4);
3545 # FILE_NAME(tmp, @2);
3546 # $$ = tmp;
3547 # }
3548 ()
3549 def p_expression_43(p):
3550 '''expression : expression K_WNE attribute_list_opt expression '''
3551 print(p)
3552 # { PEBinary*tmp = new PEBComp('W', $1, $4);
3553 # FILE_NAME(tmp, @2);
3554 # $$ = tmp;
3555 # }
3556 ()
3557 def p_expression_44(p):
3558 '''expression : expression K_LOR attribute_list_opt expression '''
3559 print(p)
3560 # { PEBinary*tmp = new PEBLogic('o', $1, $4);
3561 # FILE_NAME(tmp, @2);
3562 # $$ = tmp;
3563 # }
3564 ()
3565 def p_expression_45(p):
3566 '''expression : expression K_LAND attribute_list_opt expression '''
3567 print(p)
3568 # { PEBinary*tmp = new PEBLogic('a', $1, $4);
3569 # FILE_NAME(tmp, @2);
3570 # $$ = tmp;
3571 # }
3572 ()
3573 def p_expression_46(p):
3574 '''expression : expression '?' attribute_list_opt expression ':' expression '''
3575 print(p)
3576 # { PETernary*tmp = new PETernary($1, $4, $6);
3577 # FILE_NAME(tmp, @2);
3578 # $$ = tmp;
3579 # }
3580 ()
3581 def p_expr_mintypmax_1(p):
3582 '''expr_mintypmax : expression '''
3583 print(p)
3584 # { $$ = $1; }
3585 ()
3586 def p_expr_mintypmax_2(p):
3587 '''expr_mintypmax : expression ':' expression ':' expression '''
3588 print(p)
3589 # { switch (min_typ_max_flag) {
3590 # case MIN:
3591 # $$ = $1;
3592 # delete $3;
3593 # delete $5;
3594 # break;
3595 # case TYP:
3596 # delete $1;
3597 # $$ = $3;
3598 # delete $5;
3599 # break;
3600 # case MAX:
3601 # delete $1;
3602 # delete $3;
3603 # $$ = $5;
3604 # break;
3605 # }
3606 # if (min_typ_max_warn > 0) {
3607 # cerr << $$->get_fileline() << ": warning: choosing ";
3608 # switch (min_typ_max_flag) {
3609 # case MIN:
3610 # cerr << "min";
3611 # break;
3612 # case TYP:
3613 # cerr << "typ";
3614 # break;
3615 # case MAX:
3616 # cerr << "max";
3617 # break;
3618 # }
3619 # cerr << " expression." << endl;
3620 # min_typ_max_warn -= 1;
3621 # }
3622 # }
3623 ()
3624 def p_expression_list_with_nuls_1(p):
3625 '''expression_list_with_nuls : expression_list_with_nuls ',' expression '''
3626 print(p)
3627 # { list<PExpr*>*tmp = $1;
3628 # tmp->push_back($3);
3629 # $$ = tmp;
3630 # }
3631 ()
3632 def p_expression_list_with_nuls_2(p):
3633 '''expression_list_with_nuls : expression '''
3634 print(p)
3635 # { list<PExpr*>*tmp = new list<PExpr*>;
3636 # tmp->push_back($1);
3637 # $$ = tmp;
3638 # }
3639 ()
3640 def p_expression_list_with_nuls_3(p):
3641 '''expression_list_with_nuls : '''
3642 print(p)
3643 # { list<PExpr*>*tmp = new list<PExpr*>;
3644 # tmp->push_back(0);
3645 # $$ = tmp;
3646 # }
3647 ()
3648 def p_expression_list_with_nuls_4(p):
3649 '''expression_list_with_nuls : expression_list_with_nuls ',' '''
3650 print(p)
3651 # { list<PExpr*>*tmp = $1;
3652 # tmp->push_back(0);
3653 # $$ = tmp;
3654 # }
3655 ()
3656 def p_expression_list_proper_1(p):
3657 '''expression_list_proper : expression_list_proper ',' expression '''
3658 print(p)
3659 # { list<PExpr*>*tmp = $1;
3660 # tmp->push_back($3);
3661 # $$ = tmp;
3662 # }
3663 ()
3664 def p_expression_list_proper_2(p):
3665 '''expression_list_proper : expression '''
3666 print(p)
3667 # { list<PExpr*>*tmp = new list<PExpr*>;
3668 # tmp->push_back($1);
3669 # $$ = tmp;
3670 # }
3671 ()
3672 def p_expr_primary_or_typename_1(p):
3673 '''expr_primary_or_typename : expr_primary '''