6a153fffe282fa2aafa6f7a762e98809ef11656e
[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
22 import lexor
23 from ply import yacc, lex
24 from lib2to3.pytree import Node, Leaf
25 from lib2to3.pgen2 import token
26 from lib2to3.pygram import python_symbols as syms
27
28 yacc1_debug = 0
29 yacc2_debug = 0
30 parse_debug = 1
31
32
33 #from parse_tokens import tokens
34 tokens = lexor.tokens # list(set(lexor.tokens).union(set(tokens)))
35 literals = lexor.literals
36
37 precedence = [
38 ('right', 'K_PLUS_EQ', 'K_MINUS_EQ', 'K_MUL_EQ', 'K_DIV_EQ',
39 'K_MOD_EQ', 'K_AND_EQ', 'K_OR_EQ'),
40 ('right', 'K_XOR_EQ', 'K_LS_EQ', 'K_RS_EQ', 'K_RSS_EQ'),
41 ('right', '?', ':', 'K_inside'),
42 ('left', 'K_LOR'),
43 ('left', 'K_LAND'),
44 ('left', '|'),
45 ('left', '^', 'K_NXOR', 'K_NOR'),
46 ('left', '&', 'K_NAND'),
47 ('left', 'K_EQ', 'K_NE', 'K_CEQ', 'K_CNE', 'K_WEQ', 'K_WNE'),
48 ('left', 'K_GE', 'K_LE', '<', '>'),
49 ('left', 'K_LS', 'K_RS', 'K_RSS'),
50 ('left', '+', '-'),
51 ('left', '*', '/', '%'),
52 ('left', 'K_POW'),
53 ('left', 'UNARY_PREC'),
54 ('nonassoc', 'less_than_K_else'),
55 ('nonassoc', 'K_else'),
56 ('nonassoc', '('),
57 ('nonassoc', 'K_exclude'),
58 ('nonassoc', 'no_timeunits_declaration'),
59 ('nonassoc', 'one_timeunits_declaration'),
60 ('nonassoc', 'K_timeunit', 'K_timeprecision')
61 ]
62
63
64 IVL_VT_NO_TYPE = 'VT_NO_TYPE'
65 IVL_VT_BOOL = 'VT_BOOL'
66 IVL_VT_LOGIC = 'VT_LOGIC'
67 """
68 IVL_VT_VOID = 0, /* Not used */
69 IVL_VT_NO_TYPE = 1, /* Place holder for missing/unknown type. */
70 IVL_VT_REAL = 2,
71 IVL_VT_BOOL = 3,
72 IVL_VT_LOGIC = 4,
73 IVL_VT_STRING = 5,
74 IVL_VT_DARRAY = 6, /* Array (esp. dynamic array) */
75 IVL_VT_CLASS = 7, /* SystemVerilog class instances */
76 IVL_VT_QUEUE = 8, /* SystemVerilog queue instances */
77 IVL_VT_VECTOR = IVL_VT_LOGIC /* For compatibility */
78 """
79
80 NN_NONE = 'NONE'
81 NN_IMPLICIT = 'IMPLICIT'
82 NN_IMPLICIT_REG = 'IMPLICIT_REG'
83 NN_INTEGER = 'INTEGER'
84 NN_WIRE = 'WIRE'
85 NN_TRI = 'TRI'
86 NN_TRI1 = 'TRI1'
87 NN_SUPPLY0 = 'SUPPLY0'
88 NN_SUPPLY1 = 'SUPPLY1'
89 NN_WAND = 'WAND'
90 NN_TRIAND = 'TRIAND'
91 NN_TRI0 = 'TRI0'
92 NN_WOR = 'WOR'
93 NN_TRIOR = 'TRIOR'
94 NN_REG = 'REG'
95 NN_UNRESOLVED_WIRE = 'UNRESOLVED_WIRE'
96
97 NP_NOT_A_PORT = 'NOT_A_PORT'
98 NP_PIMPLICIT = 'PIMPLICIT'
99 NP_PINPUT = 'PINPUT'
100 NP_POUTPUT = 'POUTPUT'
101 NP_PINOUT = 'PINOUT'
102 NP_PREF = 'PREF'
103
104
105 class DataType:
106 def __init__(self, typ, signed):
107 self.typ = typ
108 self.signed = signed
109
110
111 class StatementList:
112 def __init__(self):
113 self.statements = []
114
115 def add_statement(self, s):
116 self.statements += [s]
117
118
119 # -------------- RULES ----------------
120 ()
121
122
123 def p_source_text_1(p):
124 '''source_text : timeunits_declaration_opt _embed0_source_text description_list '''
125 if(parse_debug > 2):
126 print('source_text', list(p))
127
128
129 ()
130
131
132 def p_source_text_2(p):
133 '''source_text : '''
134 if(parse_debug):
135 print('source_text', list(p))
136
137
138 ()
139
140
141 def p__embed0_source_text(p):
142 '''_embed0_source_text : '''
143
144
145 # { pform_set_scope_timescale(yyloc); }
146 ()
147
148
149 def p_assertion_item_1(p):
150 '''assertion_item : concurrent_assertion_item '''
151 if(parse_debug):
152 print('assertion_item_1', list(p))
153
154
155 ()
156
157
158 def p_assignment_pattern_1(p):
159 '''assignment_pattern : K_LP expression_list_proper '}' '''
160 if(parse_debug):
161 print('assignment_pattern_1', list(p))
162
163
164 # { PEAssignPattern*tmp = new PEAssignPattern(*p[2]);
165 # FILE_NAME(tmp, @1);
166 # delete p[2];
167 # p[0] = tmp;
168 # }
169 ()
170
171
172 def p_assignment_pattern_2(p):
173 '''assignment_pattern : K_LP '}' '''
174 if(parse_debug):
175 print('assignment_pattern_2', list(p))
176
177
178 # { PEAssignPattern*tmp = new PEAssignPattern;
179 # FILE_NAME(tmp, @1);
180 # p[0] = tmp;
181 # }
182 ()
183
184
185 def p_block_identifier_opt_1(p):
186 '''block_identifier_opt : IDENTIFIER ':' '''
187 if(parse_debug):
188 print('block_identifier_opt_1', list(p))
189
190
191 ()
192
193
194 def p_block_identifier_opt_2(p):
195 '''block_identifier_opt : '''
196 if(parse_debug):
197 print('block_identifier_opt_2', list(p))
198
199
200 ()
201
202
203 def p_class_declaration_1(p):
204 '''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 '''
205 if(parse_debug):
206 print('class_declaration_1', list(p))
207
208
209 # { // Wrap up the class.
210 # if (p[11] && p[4] && p[4]->name != p[11]) {
211 # yyerror(@11, "error: Class end label doesn't match class name.");
212 # delete[]p[11];
213 # }
214 # }
215 ()
216
217
218 def p__embed0_class_declaration(p):
219 '''_embed0_class_declaration : '''
220
221
222 # { pform_start_class_declaration(@2, p[4], p[5].type, p[5].exprs, p[3]); }
223 ()
224
225
226 def p__embed1_class_declaration(p):
227 '''_embed1_class_declaration : '''
228
229
230 # { // Process a class.
231 # pform_end_class_declaration(@9);
232 # }
233 ()
234
235
236 def p_class_constraint_1(p):
237 '''class_constraint : constraint_prototype '''
238 if(parse_debug):
239 print('class_constraint_1', list(p))
240
241
242 ()
243
244
245 def p_class_constraint_2(p):
246 '''class_constraint : constraint_declaration '''
247 if(parse_debug):
248 print('class_constraint_2', list(p))
249
250
251 ()
252
253
254 def p_class_identifier_1(p):
255 '''class_identifier : IDENTIFIER '''
256 if(parse_debug):
257 print('class_identifier_1', list(p))
258
259
260 # { // Create a synthetic typedef for the class name so that the
261 # // lexor detects the name as a type.
262 # perm_string name = lex_strings.make(p[1]);
263 # class_type_t*tmp = new class_type_t(name);
264 # FILE_NAME(tmp, @1);
265 # pform_set_typedef(name, tmp, NULL);
266 # delete[]p[1];
267 # p[0] = tmp;
268 # }
269 ()
270
271
272 def p_class_identifier_2(p):
273 '''class_identifier : TYPE_IDENTIFIER '''
274 if(parse_debug):
275 print('class_identifier_2', list(p))
276
277
278 # { class_type_t*tmp = dynamic_cast<class_type_t*>(p[1].type);
279 # if (tmp == 0) {
280 # yyerror(@1, "Type name \"%s\"is not a predeclared class name.", p[1].text);
281 # }
282 # delete[]p[1].text;
283 # p[0] = tmp;
284 # }
285 ()
286
287
288 def p_class_declaration_endlabel_opt_1(p):
289 '''class_declaration_endlabel_opt : ':' TYPE_IDENTIFIER '''
290 if(parse_debug):
291 print('class_declaration_endlabel_opt_1', list(p))
292
293
294 # { class_type_t*tmp = dynamic_cast<class_type_t*> (p[2].type);
295 # if (tmp == 0) {
296 # yyerror(@2, "error: class declaration endlabel \"%s\" is not a class name\n", p[2].text);
297 # p[0] = None
298 # } else {
299 # p[0] = strdupnew(tmp->name.str());
300 # }
301 # delete[]p[2].text;
302 # }
303 ()
304
305
306 def p_class_declaration_endlabel_opt_2(p):
307 '''class_declaration_endlabel_opt : ':' IDENTIFIER '''
308 if(parse_debug):
309 print('class_declaration_endlabel_opt_2', list(p))
310 p[0] = p[2]
311
312
313 ()
314
315
316 def p_class_declaration_endlabel_opt_3(p):
317 '''class_declaration_endlabel_opt : '''
318 if(parse_debug):
319 print('class_declaration_endlabel_opt_3', list(p))
320
321
322 # { p[0] = None }
323 ()
324
325
326 def p_class_declaration_extends_opt_1(p):
327 '''class_declaration_extends_opt : K_extends TYPE_IDENTIFIER '''
328 if(parse_debug):
329 print('class_declaration_extends_opt_1', list(p))
330
331
332 # { p[0].type = p[2].type;
333 # p[0].exprs= 0;
334 # delete[]p[2].text;
335 # }
336 ()
337
338
339 def p_class_declaration_extends_opt_2(p):
340 '''class_declaration_extends_opt : K_extends TYPE_IDENTIFIER '(' expression_list_with_nuls ')' '''
341 if(parse_debug):
342 print('class_declaration_extends_opt_2', list(p))
343
344
345 # { p[0].type = p[2].type;
346 # p[0].exprs = p[4];
347 # delete[]p[2].text;
348 # }
349 ()
350
351
352 def p_class_declaration_extends_opt_3(p):
353 '''class_declaration_extends_opt : '''
354 if(parse_debug):
355 print('class_declaration_extends_opt_3', list(p))
356
357
358 # { p[0].type = 0; p[0].exprs = 0; }
359 ()
360
361
362 def p_class_items_opt_1(p):
363 '''class_items_opt : class_items '''
364 if(parse_debug):
365 print('class_items_opt_1', list(p))
366
367
368 ()
369
370
371 def p_class_items_opt_2(p):
372 '''class_items_opt : '''
373 if(parse_debug):
374 print('class_items_opt_2', list(p))
375
376
377 ()
378
379
380 def p_class_items_1(p):
381 '''class_items : class_items class_item '''
382 if(parse_debug):
383 print('class_items_1', list(p))
384
385
386 ()
387
388
389 def p_class_items_2(p):
390 '''class_items : class_item '''
391 if(parse_debug):
392 print('class_items_2', list(p))
393
394
395 ()
396
397
398 def p_class_item_1(p):
399 '''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 '''
400 if(parse_debug):
401 print('class_item_1', list(p))
402
403
404 # { current_function->set_ports(p[6]);
405 # pform_set_constructor_return(current_function);
406 # pform_set_this_class(@3, current_function);
407 # current_function_set_statement(@3, p[10]);
408 # pform_pop_scope();
409 # current_function = 0;
410 # }
411 ()
412
413
414 def p_class_item_2(p):
415 '''class_item : property_qualifier_opt data_type list_of_variable_decl_assignments ';' '''
416 if(parse_debug):
417 print('class_item_2', list(p))
418
419
420 # { pform_class_property(@2, p[1], p[2], p[3]); }
421 ()
422
423
424 def p_class_item_3(p):
425 '''class_item : K_const class_item_qualifier_opt data_type list_of_variable_decl_assignments ';' '''
426 if(parse_debug):
427 print('class_item_3', list(p))
428
429
430 # { pform_class_property(@1, p[2] | property_qualifier_t::make_const(), p[3], p[4]); }
431 ()
432
433
434 def p_class_item_4(p):
435 '''class_item : method_qualifier_opt task_declaration '''
436 if(parse_debug):
437 print('class_item_4', list(p))
438
439
440 # { /* The task_declaration rule puts this into the class */ }
441 ()
442
443
444 def p_class_item_5(p):
445 '''class_item : method_qualifier_opt function_declaration '''
446 if(parse_debug):
447 print('class_item_5', list(p))
448
449
450 # { /* The function_declaration rule puts this into the class */ }
451 ()
452
453
454 def p_class_item_6(p):
455 '''class_item : K_extern method_qualifier_opt K_function K_new ';' '''
456 if(parse_debug):
457 print('class_item_6', list(p))
458
459
460 # { yyerror(@1, "sorry: External constructors are not yet supported."); }
461 ()
462
463
464 def p_class_item_7(p):
465 '''class_item : K_extern method_qualifier_opt K_function K_new '(' tf_port_list_opt ')' ';' '''
466 if(parse_debug):
467 print('class_item_7', list(p))
468
469
470 # { yyerror(@1, "sorry: External constructors are not yet supported."); }
471 ()
472
473
474 def p_class_item_8(p):
475 '''class_item : K_extern method_qualifier_opt K_function data_type_or_implicit_or_void IDENTIFIER ';' '''
476 if(parse_debug):
477 print('class_item_8', list(p))
478
479
480 # { yyerror(@1, "sorry: External methods are not yet supported.");
481 # delete[] p[5];
482 # }
483 ()
484
485
486 def p_class_item_9(p):
487 '''class_item : K_extern method_qualifier_opt K_function data_type_or_implicit_or_void IDENTIFIER '(' tf_port_list_opt ')' ';' '''
488 if(parse_debug):
489 print('class_item_9', list(p))
490
491
492 # { yyerror(@1, "sorry: External methods are not yet supported.");
493 # delete[] p[5];
494 # }
495 ()
496
497
498 def p_class_item_10(p):
499 '''class_item : K_extern method_qualifier_opt K_task IDENTIFIER ';' '''
500 if(parse_debug):
501 print('class_item_10', list(p))
502
503
504 # { yyerror(@1, "sorry: External methods are not yet supported.");
505 # delete[] p[4];
506 # }
507 ()
508
509
510 def p_class_item_11(p):
511 '''class_item : K_extern method_qualifier_opt K_task IDENTIFIER '(' tf_port_list_opt ')' ';' '''
512 if(parse_debug):
513 print('class_item_11', list(p))
514
515
516 # { yyerror(@1, "sorry: External methods are not yet supported.");
517 # delete[] p[4];
518 # }
519 ()
520
521
522 def p_class_item_12(p):
523 '''class_item : class_constraint '''
524 if(parse_debug):
525 print('class_item_12', list(p))
526
527
528 ()
529
530
531 def p_class_item_13(p):
532 '''class_item : property_qualifier_opt data_type error ';' '''
533 if(parse_debug):
534 print('class_item_13', list(p))
535
536
537 # { yyerror(@3, "error: Errors in variable names after data type.");
538 # yyerrok;
539 # }
540 ()
541
542
543 def p_class_item_14(p):
544 '''class_item : property_qualifier_opt IDENTIFIER error ';' '''
545 if(parse_debug):
546 print('class_item_14', list(p))
547
548
549 # { yyerror(@3, "error: %s doesn't name a type.", p[2]);
550 # yyerrok;
551 # }
552 ()
553
554
555 def p_class_item_15(p):
556 '''class_item : method_qualifier_opt K_function K_new error K_endfunction endnew_opt '''
557 if(parse_debug):
558 print('class_item_15', list(p))
559
560
561 # { yyerror(@1, "error: I give up on this class constructor declaration.");
562 # yyerrok;
563 # }
564 ()
565
566
567 def p_class_item_16(p):
568 '''class_item : error ';' '''
569 if(parse_debug):
570 print('class_item_16', list(p))
571
572
573 # { yyerror(@2, "error: invalid class item.");
574 # yyerrok;
575 # }
576 ()
577
578
579 def p__embed0_class_item(p):
580 '''_embed0_class_item : '''
581
582
583 # { assert(current_function==0);
584 # current_function = pform_push_constructor_scope(@3);
585 # }
586 ()
587
588
589 def p_class_item_qualifier_1(p):
590 '''class_item_qualifier : K_static '''
591 if(parse_debug):
592 print('class_item_qualifier_1', list(p))
593
594
595 # { p[0] = property_qualifier_t::make_static(); }
596 ()
597
598
599 def p_class_item_qualifier_2(p):
600 '''class_item_qualifier : K_protected '''
601 if(parse_debug):
602 print('class_item_qualifier_2', list(p))
603
604
605 # { p[0] = property_qualifier_t::make_protected(); }
606 ()
607
608
609 def p_class_item_qualifier_3(p):
610 '''class_item_qualifier : K_local '''
611 if(parse_debug):
612 print('class_item_qualifier_3', list(p))
613
614
615 # { p[0] = property_qualifier_t::make_local(); }
616 ()
617
618
619 def p_class_item_qualifier_list_1(p):
620 '''class_item_qualifier_list : class_item_qualifier_list class_item_qualifier '''
621 if(parse_debug):
622 print('class_item_qualifier_list_1', list(p))
623
624
625 # { p[0] = p[1] | p[2]; }
626 ()
627
628
629 def p_class_item_qualifier_list_2(p):
630 '''class_item_qualifier_list : class_item_qualifier '''
631 if(parse_debug):
632 print('class_item_qualifier_list_2', list(p))
633 p[0] = p[1]
634
635
636 ()
637
638
639 def p_class_item_qualifier_opt_1(p):
640 '''class_item_qualifier_opt : class_item_qualifier_list '''
641 if(parse_debug):
642 print('class_item_qualifier_opt_1', list(p))
643 p[0] = p[1]
644
645
646 ()
647
648
649 def p_class_item_qualifier_opt_2(p):
650 '''class_item_qualifier_opt : '''
651 if(parse_debug):
652 print('class_item_qualifier_opt_2', list(p))
653
654
655 # { p[0] = property_qualifier_t::make_none(); }
656 ()
657
658
659 def p_class_new_1(p):
660 '''class_new : K_new '(' expression_list_with_nuls ')' '''
661 if(parse_debug):
662 print('class_new_1', list(p))
663
664
665 # { list<PExpr*>*expr_list = p[3];
666 # strip_tail_items(expr_list);
667 # PENewClass*tmp = new PENewClass(*expr_list);
668 # FILE_NAME(tmp, @1);
669 # delete p[3];
670 # p[0] = tmp;
671 # }
672 ()
673
674
675 def p_class_new_2(p):
676 '''class_new : K_new hierarchy_identifier '''
677 if(parse_debug):
678 print('class_new_2', list(p))
679
680
681 # { PEIdent*tmpi = new PEIdent(*p[2]);
682 # FILE_NAME(tmpi, @2);
683 # PENewCopy*tmp = new PENewCopy(tmpi);
684 # FILE_NAME(tmp, @1);
685 # delete p[2];
686 # p[0] = tmp;
687 # }
688 ()
689
690
691 def p_class_new_3(p):
692 '''class_new : K_new '''
693 if(parse_debug):
694 print('class_new_3', list(p))
695
696
697 # { PENewClass*tmp = new PENewClass;
698 # FILE_NAME(tmp, @1);
699 # p[0] = tmp;
700 # }
701 ()
702
703
704 def p_concurrent_assertion_item_1(p):
705 '''concurrent_assertion_item : block_identifier_opt K_assert K_property '(' property_spec ')' statement_or_null '''
706 if(parse_debug):
707 print('concurrent_assertion_item_1', list(p))
708
709
710 # { /* */
711 # if (gn_assertions_flag) {
712 # yyerror(@2, "sorry: concurrent_assertion_item not supported."
713 # " Try -gno-assertion to turn this message off.");
714 # }
715 # }
716 ()
717
718
719 def p_concurrent_assertion_item_2(p):
720 '''concurrent_assertion_item : block_identifier_opt K_assert K_property '(' error ')' statement_or_null '''
721 if(parse_debug):
722 print('concurrent_assertion_item_2', list(p))
723
724
725 # { yyerrok;
726 # yyerror(@2, "error: Error in property_spec of concurrent assertion item.");
727 # }
728 ()
729
730
731 def p_constraint_block_item_1(p):
732 '''constraint_block_item : constraint_expression '''
733 if(parse_debug):
734 print('constraint_block_item_1', list(p))
735
736
737 ()
738
739
740 def p_constraint_block_item_list_1(p):
741 '''constraint_block_item_list : constraint_block_item_list constraint_block_item '''
742 if(parse_debug):
743 print('constraint_block_item_list_1', list(p))
744
745
746 ()
747
748
749 def p_constraint_block_item_list_2(p):
750 '''constraint_block_item_list : constraint_block_item '''
751 if(parse_debug):
752 print('constraint_block_item_list_2', list(p))
753
754
755 ()
756
757
758 def p_constraint_block_item_list_opt_1(p):
759 '''constraint_block_item_list_opt : '''
760 if(parse_debug):
761 print('constraint_block_item_list_opt_1', list(p))
762
763
764 ()
765
766
767 def p_constraint_block_item_list_opt_2(p):
768 '''constraint_block_item_list_opt : constraint_block_item_list '''
769 if(parse_debug):
770 print('constraint_block_item_list_opt_2', list(p))
771
772
773 ()
774
775
776 def p_constraint_declaration_1(p):
777 '''constraint_declaration : K_static_opt K_constraint IDENTIFIER '{' constraint_block_item_list_opt '}' '''
778 if(parse_debug):
779 print('constraint_declaration_1', list(p))
780
781
782 # { yyerror(@2, "sorry: Constraint declarations not supported."); }
783 ()
784
785
786 def p_constraint_declaration_2(p):
787 '''constraint_declaration : K_static_opt K_constraint IDENTIFIER '{' error '}' '''
788 if(parse_debug):
789 print('constraint_declaration_2', list(p))
790
791
792 # { yyerror(@4, "error: Errors in the constraint block item list."); }
793 ()
794
795
796 def p_constraint_expression_1(p):
797 '''constraint_expression : expression ';' '''
798 if(parse_debug):
799 print('constraint_expression_1', list(p))
800
801
802 ()
803
804
805 def p_constraint_expression_2(p):
806 '''constraint_expression : expression K_dist '{' '}' ';' '''
807 if(parse_debug):
808 print('constraint_expression_2', list(p))
809
810
811 ()
812
813
814 def p_constraint_expression_3(p):
815 '''constraint_expression : expression K_TRIGGER constraint_set '''
816 if(parse_debug):
817 print('constraint_expression_3', list(p))
818
819
820 ()
821
822
823 def p_constraint_expression_4(p):
824 '''constraint_expression : K_if '(' expression ')' constraint_set %prec less_than_K_else '''
825 if(parse_debug):
826 print('constraint_expression_4', list(p))
827
828
829 ()
830
831
832 def p_constraint_expression_5(p):
833 '''constraint_expression : K_if '(' expression ')' constraint_set K_else constraint_set '''
834 if(parse_debug):
835 print('constraint_expression_5', list(p))
836
837
838 ()
839
840
841 def p_constraint_expression_6(p):
842 '''constraint_expression : K_foreach '(' IDENTIFIER '[' loop_variables ']' ')' constraint_set '''
843 if(parse_debug):
844 print('constraint_expression_6', list(p))
845
846
847 ()
848
849
850 def p_constraint_expression_list_1(p):
851 '''constraint_expression_list : constraint_expression_list constraint_expression '''
852 if(parse_debug):
853 print('constraint_expression_list_1', list(p))
854
855
856 ()
857
858
859 def p_constraint_expression_list_2(p):
860 '''constraint_expression_list : constraint_expression '''
861 if(parse_debug):
862 print('constraint_expression_list_2', list(p))
863
864
865 ()
866
867
868 def p_constraint_prototype_1(p):
869 '''constraint_prototype : K_static_opt K_constraint IDENTIFIER ';' '''
870 if(parse_debug):
871 print('constraint_prototype_1', list(p))
872
873
874 # { yyerror(@2, "sorry: Constraint prototypes not supported."); }
875 ()
876
877
878 def p_constraint_set_1(p):
879 '''constraint_set : constraint_expression '''
880 if(parse_debug):
881 print('constraint_set_1', list(p))
882
883
884 ()
885
886
887 def p_constraint_set_2(p):
888 '''constraint_set : '{' constraint_expression_list '}' '''
889 if(parse_debug):
890 print('constraint_set_2', list(p))
891
892
893 ()
894
895
896 def p_data_declaration_1(p):
897 '''data_declaration : attribute_list_opt data_type_or_implicit list_of_variable_decl_assignments ';' '''
898 if(parse_debug):
899 print('data_declaration_1', list(p))
900
901
902 # { data_type_t*data_type = p[2];
903 # if (data_type == 0) {
904 # data_type = new vector_type_t(IVL_VT_LOGIC, false, 0);
905 # FILE_NAME(data_type, @2);
906 # }
907 # pform_makewire(@2, 0, str_strength, p[3], NetNet::IMPLICIT_REG, data_type);
908 # }
909 ()
910
911
912 def p_data_type_1(p):
913 '''data_type : integer_vector_type unsigned_signed_opt dimensions_opt '''
914 if(parse_debug):
915 print('data_type_1', list(p))
916 use_vtype = p[1]
917 reg_flag = False
918 if (use_vtype == IVL_VT_NO_TYPE):
919 use_vtype = IVL_VT_LOGIC
920 reg_flag = True
921 dt = DataType(use_vtype, signed=p[2])
922 dt.dims = p[3]
923 dt.reg_flag = reg_flag
924 p[0] = dt
925
926
927 # { ivl_variable_type_t use_vtype = p[1];
928 # bool reg_flag = false;
929 # if (use_vtype == IVL_VT_NO_TYPE) {
930 # use_vtype = IVL_VT_LOGIC;
931 # reg_flag = true;
932 # }
933 # vector_type_t*tmp = new vector_type_t(use_vtype, p[2], p[3]);
934 # tmp->reg_flag = reg_flag;
935 # FILE_NAME(tmp, @1);
936 # p[0] = tmp;
937 # }
938 ()
939
940
941 def p_data_type_2(p):
942 '''data_type : non_integer_type '''
943 if(parse_debug):
944 print('data_type_2', list(p))
945 p[0] = p[1]
946
947
948 # { real_type_t*tmp = new real_type_t(p[1]);
949 # FILE_NAME(tmp, @1);
950 # p[0] = tmp;
951 # }
952 ()
953
954
955 def p_data_type_3(p):
956 '''data_type : struct_data_type '''
957 if(parse_debug):
958 print('data_type_3', list(p))
959 p[0] = p[1]
960
961
962 # { if (!p[1]->packed_flag) {
963 # yyerror(@1, "sorry: Unpacked structs not supported.");
964 # }
965 # p[0] = p[1];
966 # }
967 ()
968
969
970 def p_data_type_4(p):
971 '''data_type : enum_data_type '''
972 if(parse_debug):
973 print('data_type_4', list(p))
974 p[0] = p[1]
975
976
977 ()
978
979
980 def p_data_type_5(p):
981 '''data_type : atom2_type signed_unsigned_opt '''
982 if(parse_debug):
983 print('data_type_5', list(p))
984
985
986 # { atom2_type_t*tmp = new atom2_type_t(p[1], p[2]);
987 # FILE_NAME(tmp, @1);
988 # p[0] = tmp;
989 # }
990 ()
991
992
993 def p_data_type_6(p):
994 '''data_type : K_integer signed_unsigned_opt '''
995 if(parse_debug):
996 print('data_type_6', list(p))
997
998
999 # { list<pform_range_t>*pd = make_range_from_width(integer_width);
1000 # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, p[2], pd);
1001 # tmp->reg_flag = true;
1002 # tmp->integer_flag = true;
1003 # p[0] = tmp;
1004 # }
1005 ()
1006
1007
1008 def p_data_type_7(p):
1009 '''data_type : K_time '''
1010 if(parse_debug):
1011 print('data_type_7', list(p))
1012
1013
1014 # { list<pform_range_t>*pd = make_range_from_width(64);
1015 # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, false, pd);
1016 # tmp->reg_flag = !gn_system_verilog();
1017 # p[0] = tmp;
1018 # }
1019 ()
1020
1021
1022 def p_data_type_8(p):
1023 '''data_type : TYPE_IDENTIFIER dimensions_opt '''
1024 if(parse_debug):
1025 print('data_type_8', list(p))
1026
1027
1028 # { if (p[2]) {
1029 # parray_type_t*tmp = new parray_type_t(p[1].type, p[2]);
1030 # FILE_NAME(tmp, @1);
1031 # p[0] = tmp;
1032 # } else p[0] = p[1].type;
1033 # delete[]p[1].text;
1034 # }
1035 ()
1036
1037
1038 def p_data_type_9(p):
1039 '''data_type : PACKAGE_IDENTIFIER K_SCOPE_RES _embed0_data_type TYPE_IDENTIFIER '''
1040 if(parse_debug):
1041 print('data_type_9', list(p))
1042
1043
1044 # { lex_in_package_scope(0);
1045 # p[0] = p[4].type;
1046 # delete[]p[4].text;
1047 # }
1048 ()
1049
1050
1051 def p_data_type_10(p):
1052 '''data_type : K_string '''
1053 if(parse_debug):
1054 print('data_type_10', list(p))
1055
1056
1057 # { string_type_t*tmp = new string_type_t;
1058 # FILE_NAME(tmp, @1);
1059 # p[0] = tmp;
1060 # }
1061 ()
1062
1063
1064 def p__embed0_data_type(p):
1065 '''_embed0_data_type : '''
1066
1067
1068 # { lex_in_package_scope(p[1]); }
1069 ()
1070
1071
1072 def p_data_type_or_implicit_1(p):
1073 '''data_type_or_implicit : data_type '''
1074 if(parse_debug):
1075 print('data_type_or_implicit_1', list(p))
1076 p[0] = p[1]
1077
1078
1079 ()
1080
1081
1082 def p_data_type_or_implicit_2(p):
1083 '''data_type_or_implicit : signing dimensions_opt '''
1084 if(parse_debug):
1085 print('data_type_or_implicit_2', list(p))
1086
1087
1088 # { vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, p[1], p[2]);
1089 # tmp->implicit_flag = true;
1090 # FILE_NAME(tmp, @1);
1091 # p[0] = tmp;
1092 # }
1093 ()
1094
1095
1096 def p_data_type_or_implicit_3(p):
1097 '''data_type_or_implicit : dimensions '''
1098 if(parse_debug):
1099 print('data_type_or_implicit_3', list(p))
1100 p[0] = list(p)
1101
1102
1103 # { vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, false, p[1]);
1104 # tmp->implicit_flag = true;
1105 # FILE_NAME(tmp, @1);
1106 # p[0] = tmp;
1107 # }
1108 ()
1109
1110
1111 def p_data_type_or_implicit_4(p):
1112 '''data_type_or_implicit : '''
1113 if(parse_debug > 2):
1114 print('data_type_or_implicit_4', list(p))
1115
1116
1117 # { p[0] = None }
1118 ()
1119
1120
1121 def p_data_type_or_implicit_or_void_1(p):
1122 '''data_type_or_implicit_or_void : data_type_or_implicit '''
1123 if(parse_debug):
1124 print('data_type_or_implicit_or_void_1', list(p))
1125 p[0] = p[1]
1126
1127
1128 ()
1129
1130
1131 def p_data_type_or_implicit_or_void_2(p):
1132 '''data_type_or_implicit_or_void : K_void '''
1133 if(parse_debug):
1134 print('data_type_or_implicit_or_void_2', list(p))
1135
1136
1137 # { void_type_t*tmp = new void_type_t;
1138 # FILE_NAME(tmp, @1);
1139 # p[0] = tmp;
1140 # }
1141 ()
1142
1143
1144 def p_description_1(p):
1145 '''description : module '''
1146 if(parse_debug > 2):
1147 print('description_1', list(p))
1148
1149
1150 ()
1151
1152
1153 def p_description_2(p):
1154 '''description : udp_primitive '''
1155 if(parse_debug):
1156 print('description_2', list(p))
1157
1158
1159 ()
1160
1161
1162 def p_description_3(p):
1163 '''description : config_declaration '''
1164 if(parse_debug):
1165 print('description_3', list(p))
1166
1167
1168 ()
1169
1170
1171 def p_description_4(p):
1172 '''description : nature_declaration '''
1173 if(parse_debug):
1174 print('description_4', list(p))
1175
1176
1177 ()
1178
1179
1180 def p_description_5(p):
1181 '''description : package_declaration '''
1182 if(parse_debug):
1183 print('description_5', list(p))
1184
1185
1186 ()
1187
1188
1189 def p_description_6(p):
1190 '''description : discipline_declaration '''
1191 if(parse_debug):
1192 print('description_6', list(p))
1193
1194
1195 ()
1196
1197
1198 def p_description_7(p):
1199 '''description : package_item '''
1200 if(parse_debug):
1201 print('description_7', list(p))
1202
1203
1204 ()
1205
1206
1207 def p_description_8(p):
1208 '''description : KK_attribute '(' IDENTIFIER ',' STRING ',' STRING ')' '''
1209 if(parse_debug):
1210 print('description_8', list(p))
1211
1212
1213 # { perm_string tmp3 = lex_strings.make(p[3]);
1214 # pform_set_type_attrib(tmp3, p[5], p[7]);
1215 # delete[] p[3];
1216 # delete[] p[5];
1217 # }
1218 ()
1219
1220
1221 def p_description_list_1(p):
1222 '''description_list : description '''
1223 if(parse_debug > 2):
1224 print('description_list_1', list(p))
1225
1226
1227 ()
1228
1229
1230 def p_description_list_2(p):
1231 '''description_list : description_list description '''
1232 if(parse_debug):
1233 print('description_list_2', list(p))
1234
1235
1236 ()
1237
1238
1239 def p_endnew_opt_1(p):
1240 '''endnew_opt : ':' K_new '''
1241 if(parse_debug):
1242 print('endnew_opt_1', list(p))
1243
1244
1245 ()
1246
1247
1248 def p_endnew_opt_2(p):
1249 '''endnew_opt : '''
1250 if(parse_debug):
1251 print('endnew_opt_2', list(p))
1252
1253
1254 ()
1255
1256
1257 def p_dynamic_array_new_1(p):
1258 '''dynamic_array_new : K_new '[' expression ']' '''
1259 if(parse_debug):
1260 print('dynamic_array_new_1', list(p))
1261
1262
1263 # { p[0] = new PENewArray(p[3], 0);
1264 # FILE_NAME(p[0], @1);
1265 # }
1266 ()
1267
1268
1269 def p_dynamic_array_new_2(p):
1270 '''dynamic_array_new : K_new '[' expression ']' '(' expression ')' '''
1271 if(parse_debug):
1272 print('dynamic_array_new_2', list(p))
1273
1274
1275 # { p[0] = new PENewArray(p[3], p[6]);
1276 # FILE_NAME(p[0], @1);
1277 # }
1278 ()
1279
1280
1281 def p_for_step_1(p):
1282 '''for_step : lpvalue '=' expression '''
1283 if(parse_debug):
1284 print('for_step_1', list(p))
1285
1286
1287 # { PAssign*tmp = new PAssign(p[1],p[3]);
1288 # FILE_NAME(tmp, @1);
1289 # p[0] = tmp;
1290 # }
1291 ()
1292
1293
1294 def p_for_step_2(p):
1295 '''for_step : inc_or_dec_expression '''
1296 if(parse_debug):
1297 print('for_step_2', list(p))
1298
1299
1300 # { p[0] = pform_compressed_assign_from_inc_dec(@1, p[1]); }
1301 ()
1302
1303
1304 def p_for_step_3(p):
1305 '''for_step : compressed_statement '''
1306 if(parse_debug):
1307 print('for_step_3', list(p))
1308 p[0] = p[1]
1309
1310
1311 ()
1312
1313
1314 def p_function_declaration_1(p):
1315 '''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 '''
1316 if(parse_debug):
1317 print('function_declaration_1', list(p))
1318
1319
1320 # { // Last step: check any closing name.
1321 # if (p[11]) {
1322 # if (strcmp(p[4],p[11]) != 0) {
1323 # yyerror(@11, "error: End label doesn't match "
1324 # "function name");
1325 # }
1326 # if (! gn_system_verilog()) {
1327 # yyerror(@11, "error: Function end labels require "
1328 # "SystemVerilog.");
1329 # }
1330 # delete[]p[11];
1331 # }
1332 # delete[]p[4];
1333 # }
1334 ()
1335
1336
1337 def p_function_declaration_2(p):
1338 '''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 '''
1339 if(parse_debug):
1340 print('function_declaration_2', list(p))
1341
1342
1343 # { // Last step: check any closing name.
1344 # if (p[14]) {
1345 # if (strcmp(p[4],p[14]) != 0) {
1346 # yyerror(@14, "error: End label doesn't match "
1347 # "function name");
1348 # }
1349 # if (! gn_system_verilog()) {
1350 # yyerror(@14, "error: Function end labels require "
1351 # "SystemVerilog.");
1352 # }
1353 # delete[]p[14];
1354 # }
1355 # delete[]p[4];
1356 # }
1357 ()
1358
1359
1360 def p_function_declaration_3(p):
1361 '''function_declaration : K_function lifetime_opt data_type_or_implicit_or_void IDENTIFIER error K_endfunction _embed4_function_declaration endlabel_opt '''
1362 if(parse_debug):
1363 print('function_declaration_3', list(p))
1364
1365
1366 # { // Last step: check any closing name.
1367 # if (p[8]) {
1368 # if (strcmp(p[4],p[8]) != 0) {
1369 # yyerror(@8, "error: End label doesn't match function name");
1370 # }
1371 # if (! gn_system_verilog()) {
1372 # yyerror(@8, "error: Function end labels require "
1373 # "SystemVerilog.");
1374 # }
1375 # delete[]p[8];
1376 # }
1377 # delete[]p[4];
1378 # }
1379 ()
1380
1381
1382 def p__embed0_function_declaration(p):
1383 '''_embed0_function_declaration : '''
1384
1385
1386 # { assert(current_function == 0);
1387 # current_function = pform_push_function_scope(@1, p[4], p[2]);
1388 # }
1389 ()
1390
1391
1392 def p__embed1_function_declaration(p):
1393 '''_embed1_function_declaration : '''
1394
1395
1396 # { current_function->set_ports(p[7]);
1397 # current_function->set_return(p[3]);
1398 # current_function_set_statement(p[8]? @8 : @4, p[8]);
1399 # pform_set_this_class(@4, current_function);
1400 # pform_pop_scope();
1401 # current_function = 0;
1402 # }
1403 ()
1404
1405
1406 def p__embed2_function_declaration(p):
1407 '''_embed2_function_declaration : '''
1408
1409
1410 # { assert(current_function == 0);
1411 # current_function = pform_push_function_scope(@1, p[4], p[2]);
1412 # }
1413 ()
1414
1415
1416 def p__embed3_function_declaration(p):
1417 '''_embed3_function_declaration : '''
1418
1419
1420 # { current_function->set_ports(p[7]);
1421 # current_function->set_return(p[3]);
1422 # current_function_set_statement(p[11]? @11 : @4, p[11]);
1423 # pform_set_this_class(@4, current_function);
1424 # pform_pop_scope();
1425 # current_function = 0;
1426 # if (p[7]==0 && !gn_system_verilog()) {
1427 # yyerror(@4, "error: Empty parenthesis syntax requires SystemVerilog.");
1428 # }
1429 # }
1430 ()
1431
1432
1433 def p__embed4_function_declaration(p):
1434 '''_embed4_function_declaration : '''
1435
1436
1437 # { /* */
1438 # if (current_function) {
1439 # pform_pop_scope();
1440 # current_function = 0;
1441 # }
1442 # assert(current_function == 0);
1443 # yyerror(@1, "error: Syntax error defining function.");
1444 # yyerrok;
1445 # }
1446 ()
1447
1448
1449 def p_import_export_1(p):
1450 '''import_export : K_import '''
1451 if(parse_debug):
1452 print('import_export_1', list(p))
1453 p[0] = True
1454
1455
1456 ()
1457
1458
1459 def p_import_export_2(p):
1460 '''import_export : K_export '''
1461 if(parse_debug):
1462 print('import_export_2', list(p))
1463 p[0] = False
1464
1465
1466 ()
1467
1468
1469 def p_implicit_class_handle_1(p):
1470 '''implicit_class_handle : K_this '''
1471 if(parse_debug):
1472 print('implicit_class_handle_1', list(p))
1473
1474
1475 # { p[0] = pform_create_this(); }
1476 ()
1477
1478
1479 def p_implicit_class_handle_2(p):
1480 '''implicit_class_handle : K_super '''
1481 if(parse_debug):
1482 print('implicit_class_handle_2', list(p))
1483
1484
1485 # { p[0] = pform_create_super(); }
1486 ()
1487
1488
1489 def p_inc_or_dec_expression_1(p):
1490 '''inc_or_dec_expression : K_INCR lpvalue %prec UNARY_PREC '''
1491 if(parse_debug):
1492 print('inc_or_dec_expression_1', list(p))
1493
1494
1495 # { PEUnary*tmp = new PEUnary('I', p[2]);
1496 # FILE_NAME(tmp, @2);
1497 # p[0] = tmp;
1498 # }
1499 ()
1500
1501
1502 def p_inc_or_dec_expression_2(p):
1503 '''inc_or_dec_expression : lpvalue K_INCR %prec UNARY_PREC '''
1504 if(parse_debug):
1505 print('inc_or_dec_expression_2', list(p))
1506
1507
1508 # { PEUnary*tmp = new PEUnary('i', p[1]);
1509 # FILE_NAME(tmp, @1);
1510 # p[0] = tmp;
1511 # }
1512 ()
1513
1514
1515 def p_inc_or_dec_expression_3(p):
1516 '''inc_or_dec_expression : K_DECR lpvalue %prec UNARY_PREC '''
1517 if(parse_debug):
1518 print('inc_or_dec_expression_3', list(p))
1519
1520
1521 # { PEUnary*tmp = new PEUnary('D', p[2]);
1522 # FILE_NAME(tmp, @2);
1523 # p[0] = tmp;
1524 # }
1525 ()
1526
1527
1528 def p_inc_or_dec_expression_4(p):
1529 '''inc_or_dec_expression : lpvalue K_DECR %prec UNARY_PREC '''
1530 if(parse_debug):
1531 print('inc_or_dec_expression_4', list(p))
1532
1533
1534 # { PEUnary*tmp = new PEUnary('d', p[1]);
1535 # FILE_NAME(tmp, @1);
1536 # p[0] = tmp;
1537 # }
1538 ()
1539
1540
1541 def p_inside_expression_1(p):
1542 '''inside_expression : expression K_inside '{' open_range_list '}' '''
1543 if(parse_debug):
1544 print('inside_expression_1', list(p))
1545
1546
1547 # { yyerror(@2, "sorry: \"inside\" expressions not supported yet.");
1548 # p[0] = None
1549 # }
1550 ()
1551
1552
1553 def p_integer_vector_type_1(p):
1554 '''integer_vector_type : K_reg '''
1555 if(parse_debug):
1556 print('integer_vector_type_1', list(p))
1557 p[0] = IVL_VT_NO_TYPE
1558
1559
1560 ()
1561
1562
1563 def p_integer_vector_type_2(p):
1564 '''integer_vector_type : K_bit '''
1565 if(parse_debug):
1566 print('integer_vector_type_2', list(p))
1567 p[0] = IVL_VT_BOOL
1568
1569
1570 ()
1571
1572
1573 def p_integer_vector_type_3(p):
1574 '''integer_vector_type : K_logic '''
1575 if(parse_debug):
1576 print('integer_vector_type_3', list(p))
1577 p[0] = IVL_VT_LOGIC
1578
1579
1580 ()
1581
1582
1583 def p_integer_vector_type_4(p):
1584 '''integer_vector_type : K_bool '''
1585 if(parse_debug):
1586 print('integer_vector_type_4', list(p))
1587
1588
1589 # { p[0] = IVL_VT_BOOL; }
1590 ()
1591
1592
1593 def p_join_keyword_1(p):
1594 '''join_keyword : K_join '''
1595 if(parse_debug):
1596 print('join_keyword_1', list(p))
1597
1598
1599 # { p[0] = PBlock::BL_PAR; }
1600 ()
1601
1602
1603 def p_join_keyword_2(p):
1604 '''join_keyword : K_join_none '''
1605 if(parse_debug):
1606 print('join_keyword_2', list(p))
1607
1608
1609 # { p[0] = PBlock::BL_JOIN_NONE; }
1610 ()
1611
1612
1613 def p_join_keyword_3(p):
1614 '''join_keyword : K_join_any '''
1615 if(parse_debug):
1616 print('join_keyword_3', list(p))
1617
1618
1619 # { p[0] = PBlock::BL_JOIN_ANY; }
1620 ()
1621
1622
1623 def p_jump_statement_1(p):
1624 '''jump_statement : K_break ';' '''
1625 if(parse_debug):
1626 print('jump_statement_1', list(p))
1627
1628
1629 # { yyerror(@1, "sorry: break statements not supported.");
1630 # p[0] = None
1631 # }
1632 ()
1633
1634
1635 def p_jump_statement_2(p):
1636 '''jump_statement : K_return ';' '''
1637 if(parse_debug):
1638 print('jump_statement_2', list(p))
1639
1640
1641 # { PReturn*tmp = new PReturn(0);
1642 # FILE_NAME(tmp, @1);
1643 # p[0] = tmp;
1644 # }
1645 ()
1646
1647
1648 def p_jump_statement_3(p):
1649 '''jump_statement : K_return expression ';' '''
1650 if(parse_debug):
1651 print('jump_statement_3', list(p))
1652
1653
1654 # { PReturn*tmp = new PReturn(p[2]);
1655 # FILE_NAME(tmp, @1);
1656 # p[0] = tmp;
1657 # }
1658 ()
1659
1660
1661 def p_lifetime_1(p):
1662 '''lifetime : K_automatic '''
1663 if(parse_debug):
1664 print('lifetime_1', list(p))
1665
1666
1667 # { p[0] = LexicalScope::AUTOMATIC; }
1668 ()
1669
1670
1671 def p_lifetime_2(p):
1672 '''lifetime : K_static '''
1673 if(parse_debug):
1674 print('lifetime_2', list(p))
1675
1676
1677 # { p[0] = LexicalScope::STATIC; }
1678 ()
1679
1680
1681 def p_lifetime_opt_1(p):
1682 '''lifetime_opt : lifetime '''
1683 if(parse_debug):
1684 print('lifetime_opt_1', list(p))
1685 p[0] = p[1]
1686
1687
1688 ()
1689
1690
1691 def p_lifetime_opt_2(p):
1692 '''lifetime_opt : '''
1693 if(parse_debug > 2):
1694 print('lifetime_opt_2', list(p))
1695
1696
1697 # { p[0] = LexicalScope::INHERITED; }
1698 ()
1699
1700
1701 def p_loop_statement_1(p):
1702 '''loop_statement : K_for '(' lpvalue '=' expression ';' expression ';' for_step ')' statement_or_null '''
1703 if(parse_debug):
1704 print('loop_statement_1', list(p))
1705
1706
1707 # { PForStatement*tmp = new PForStatement(p[3], p[5], p[7], p[9], p[11]);
1708 # FILE_NAME(tmp, @1);
1709 # p[0] = tmp;
1710 # }
1711 ()
1712
1713
1714 def p_loop_statement_2(p):
1715 '''loop_statement : K_for '(' data_type IDENTIFIER '=' expression ';' expression ';' for_step ')' _embed0_loop_statement statement_or_null '''
1716 if(parse_debug):
1717 print('loop_statement_2', list(p))
1718
1719
1720 # { pform_name_t tmp_hident;
1721 # tmp_hident.push_back(name_component_t(lex_strings.make(p[4])));
1722 #
1723 # PEIdent*tmp_ident = pform_new_ident(tmp_hident);
1724 # FILE_NAME(tmp_ident, @4);
1725 #
1726 # PForStatement*tmp_for = new PForStatement(tmp_ident, p[6], p[8], p[10], p[13]);
1727 # FILE_NAME(tmp_for, @1);
1728 #
1729 # pform_pop_scope();
1730 # vector<Statement*>tmp_for_list (1);
1731 # tmp_for_list[0] = tmp_for;
1732 # PBlock*tmp_blk = current_block_stack.top();
1733 # current_block_stack.pop();
1734 # tmp_blk->set_statement(tmp_for_list);
1735 # p[0] = tmp_blk;
1736 # delete[]p[4];
1737 # }
1738 ()
1739
1740
1741 def p_loop_statement_3(p):
1742 '''loop_statement : K_forever statement_or_null '''
1743 if(parse_debug):
1744 print('loop_statement_3', list(p))
1745
1746
1747 # { PForever*tmp = new PForever(p[2]);
1748 # FILE_NAME(tmp, @1);
1749 # p[0] = tmp;
1750 # }
1751 ()
1752
1753
1754 def p_loop_statement_4(p):
1755 '''loop_statement : K_repeat '(' expression ')' statement_or_null '''
1756 if(parse_debug):
1757 print('loop_statement_4', list(p))
1758
1759
1760 # { PRepeat*tmp = new PRepeat(p[3], p[5]);
1761 # FILE_NAME(tmp, @1);
1762 # p[0] = tmp;
1763 # }
1764 ()
1765
1766
1767 def p_loop_statement_5(p):
1768 '''loop_statement : K_while '(' expression ')' statement_or_null '''
1769 if(parse_debug):
1770 print('loop_statement_5', list(p))
1771
1772
1773 # { PWhile*tmp = new PWhile(p[3], p[5]);
1774 # FILE_NAME(tmp, @1);
1775 # p[0] = tmp;
1776 # }
1777 ()
1778
1779
1780 def p_loop_statement_6(p):
1781 '''loop_statement : K_do statement_or_null K_while '(' expression ')' ';' '''
1782 if(parse_debug):
1783 print('loop_statement_6', list(p))
1784
1785
1786 # { PDoWhile*tmp = new PDoWhile(p[5], p[2]);
1787 # FILE_NAME(tmp, @1);
1788 # p[0] = tmp;
1789 # }
1790 ()
1791
1792
1793 def p_loop_statement_7(p):
1794 '''loop_statement : K_foreach '(' IDENTIFIER '[' loop_variables ']' ')' _embed1_loop_statement statement_or_null '''
1795 if(parse_debug):
1796 print('loop_statement_7', list(p))
1797
1798
1799 # { PForeach*tmp_for = pform_make_foreach(@1, p[3], p[5], p[9]);
1800 #
1801 # pform_pop_scope();
1802 # vector<Statement*>tmp_for_list(1);
1803 # tmp_for_list[0] = tmp_for;
1804 # PBlock*tmp_blk = current_block_stack.top();
1805 # current_block_stack.pop();
1806 # tmp_blk->set_statement(tmp_for_list);
1807 # p[0] = tmp_blk;
1808 # }
1809 ()
1810
1811
1812 def p_loop_statement_8(p):
1813 '''loop_statement : K_for '(' lpvalue '=' expression ';' expression ';' error ')' statement_or_null '''
1814 if(parse_debug):
1815 print('loop_statement_8', list(p))
1816
1817
1818 # { p[0] = None
1819 # yyerror(@1, "error: Error in for loop step assignment.");
1820 # }
1821 ()
1822
1823
1824 def p_loop_statement_9(p):
1825 '''loop_statement : K_for '(' lpvalue '=' expression ';' error ';' for_step ')' statement_or_null '''
1826 if(parse_debug):
1827 print('loop_statement_9', list(p))
1828
1829
1830 # { p[0] = None
1831 # yyerror(@1, "error: Error in for loop condition expression.");
1832 # }
1833 ()
1834
1835
1836 def p_loop_statement_10(p):
1837 '''loop_statement : K_for '(' error ')' statement_or_null '''
1838 if(parse_debug):
1839 print('loop_statement_10', list(p))
1840
1841
1842 # { p[0] = None
1843 # yyerror(@1, "error: Incomprehensible for loop.");
1844 # }
1845 ()
1846
1847
1848 def p_loop_statement_11(p):
1849 '''loop_statement : K_while '(' error ')' statement_or_null '''
1850 if(parse_debug):
1851 print('loop_statement_11', list(p))
1852
1853
1854 # { p[0] = None
1855 # yyerror(@1, "error: Error in while loop condition.");
1856 # }
1857 ()
1858
1859
1860 def p_loop_statement_12(p):
1861 '''loop_statement : K_do statement_or_null K_while '(' error ')' ';' '''
1862 if(parse_debug):
1863 print('loop_statement_12', list(p))
1864
1865
1866 # { p[0] = None
1867 # yyerror(@1, "error: Error in do/while loop condition.");
1868 # }
1869 ()
1870
1871
1872 def p_loop_statement_13(p):
1873 '''loop_statement : K_foreach '(' IDENTIFIER '[' error ']' ')' statement_or_null '''
1874 if(parse_debug):
1875 print('loop_statement_13', list(p))
1876
1877
1878 # { p[0] = None
1879 # yyerror(@4, "error: Errors in foreach loop variables list.");
1880 # }
1881 ()
1882
1883
1884 def p__embed0_loop_statement(p):
1885 '''_embed0_loop_statement : '''
1886
1887
1888 # { static unsigned for_counter = 0;
1889 # char for_block_name [64];
1890 # snif(parse_debug): printf(for_block_name, sizeof for_block_name, "$ivl_for_loop%u", for_counter);
1891 # for_counter += 1;
1892 # PBlock*tmp = pform_push_block_scope(for_block_name, PBlock::BL_SEQ);
1893 # FILE_NAME(tmp, @1);
1894 # current_block_stack.push(tmp);
1895 #
1896 # list<decl_assignment_t*>assign_list;
1897 # decl_assignment_t*tmp_assign = new decl_assignment_t;
1898 # tmp_assign->name = lex_strings.make(p[4]);
1899 # assign_list.push_back(tmp_assign);
1900 # pform_makewire(@4, 0, str_strength, &assign_list, NetNet::REG, p[3]);
1901 # }
1902 ()
1903
1904
1905 def p__embed1_loop_statement(p):
1906 '''_embed1_loop_statement : '''
1907
1908
1909 # { static unsigned foreach_counter = 0;
1910 # char for_block_name[64];
1911 # snif(parse_debug): printf(for_block_name, sizeof for_block_name, "$ivl_foreach%u", foreach_counter);
1912 # foreach_counter += 1;
1913 #
1914 # PBlock*tmp = pform_push_block_scope(for_block_name, PBlock::BL_SEQ);
1915 # FILE_NAME(tmp, @1);
1916 # current_block_stack.push(tmp);
1917 #
1918 # pform_make_foreach_declarations(@1, p[5]);
1919 # }
1920 ()
1921
1922
1923 def p_list_of_variable_decl_assignments_1(p):
1924 '''list_of_variable_decl_assignments : variable_decl_assignment '''
1925 if(parse_debug):
1926 print('list_of_variable_decl_assignments_1', list(p))
1927
1928
1929 # { list<decl_assignment_t*>*tmp = new list<decl_assignment_t*>;
1930 # tmp->push_back(p[1]);
1931 # p[0] = tmp;
1932 # }
1933 ()
1934
1935
1936 def p_list_of_variable_decl_assignments_2(p):
1937 '''list_of_variable_decl_assignments : list_of_variable_decl_assignments ',' variable_decl_assignment '''
1938 if(parse_debug):
1939 print('list_of_variable_decl_assignments_2', list(p))
1940
1941
1942 # { list<decl_assignment_t*>*tmp = p[1];
1943 # tmp->push_back(p[3]);
1944 # p[0] = tmp;
1945 # }
1946 ()
1947
1948
1949 def p_variable_decl_assignment_1(p):
1950 '''variable_decl_assignment : IDENTIFIER dimensions_opt '''
1951 if(parse_debug):
1952 print('variable_decl_assignment_1', list(p))
1953
1954
1955 # { decl_assignment_t*tmp = new decl_assignment_t;
1956 # tmp->name = lex_strings.make(p[1]);
1957 # if (p[2]) {
1958 # tmp->index = *p[2];
1959 # delete p[2];
1960 # }
1961 # delete[]p[1];
1962 # p[0] = tmp;
1963 # }
1964 ()
1965
1966
1967 def p_variable_decl_assignment_2(p):
1968 '''variable_decl_assignment : IDENTIFIER '=' expression '''
1969 if(parse_debug):
1970 print('variable_decl_assignment_2', list(p))
1971
1972
1973 # { decl_assignment_t*tmp = new decl_assignment_t;
1974 # tmp->name = lex_strings.make(p[1]);
1975 # tmp->expr .reset(p[3]);
1976 # delete[]p[1];
1977 # p[0] = tmp;
1978 # }
1979 ()
1980
1981
1982 def p_variable_decl_assignment_3(p):
1983 '''variable_decl_assignment : IDENTIFIER '=' K_new '(' ')' '''
1984 if(parse_debug):
1985 print('variable_decl_assignment_3', list(p))
1986
1987
1988 # { decl_assignment_t*tmp = new decl_assignment_t;
1989 # tmp->name = lex_strings.make(p[1]);
1990 # PENewClass*expr = new PENewClass;
1991 # FILE_NAME(expr, @3);
1992 # tmp->expr .reset(expr);
1993 # delete[]p[1];
1994 # p[0] = tmp;
1995 # }
1996 ()
1997
1998
1999 def p_loop_variables_1(p):
2000 '''loop_variables : loop_variables ',' IDENTIFIER '''
2001 if(parse_debug):
2002 print('loop_variables_1', list(p))
2003
2004
2005 # { list<perm_string>*tmp = p[1];
2006 # tmp->push_back(lex_strings.make(p[3]));
2007 # delete[]p[3];
2008 # p[0] = tmp;
2009 # }
2010 ()
2011
2012
2013 def p_loop_variables_2(p):
2014 '''loop_variables : IDENTIFIER '''
2015 if(parse_debug):
2016 print('loop_variables_2', list(p))
2017
2018
2019 # { list<perm_string>*tmp = new list<perm_string>;
2020 # tmp->push_back(lex_strings.make(p[1]));
2021 # delete[]p[1];
2022 # p[0] = tmp;
2023 # }
2024 ()
2025
2026
2027 def p_method_qualifier_1(p):
2028 '''method_qualifier : K_virtual '''
2029 if(parse_debug):
2030 print('method_qualifier_1', list(p))
2031
2032
2033 ()
2034
2035
2036 def p_method_qualifier_2(p):
2037 '''method_qualifier : class_item_qualifier '''
2038 if(parse_debug):
2039 print('method_qualifier_2', list(p))
2040
2041
2042 ()
2043
2044
2045 def p_method_qualifier_opt_1(p):
2046 '''method_qualifier_opt : method_qualifier '''
2047 if(parse_debug):
2048 print('method_qualifier_opt_1', list(p))
2049
2050
2051 ()
2052
2053
2054 def p_method_qualifier_opt_2(p):
2055 '''method_qualifier_opt : '''
2056 if(parse_debug):
2057 print('method_qualifier_opt_2', list(p))
2058
2059
2060 ()
2061
2062
2063 def p_modport_declaration_1(p):
2064 '''modport_declaration : K_modport _embed0_modport_declaration modport_item_list ';' '''
2065 if(parse_debug):
2066 print('modport_declaration_1', list(p))
2067
2068
2069 ()
2070
2071
2072 def p__embed0_modport_declaration(p):
2073 '''_embed0_modport_declaration : '''
2074
2075
2076 # { if (!pform_in_interface())
2077 # yyerror(@1, "error: modport declarations are only allowed "
2078 # "in interfaces.");
2079 # }
2080 ()
2081
2082
2083 def p_modport_item_list_1(p):
2084 '''modport_item_list : modport_item '''
2085 if(parse_debug):
2086 print('modport_item_list_1', list(p))
2087
2088
2089 ()
2090
2091
2092 def p_modport_item_list_2(p):
2093 '''modport_item_list : modport_item_list ',' modport_item '''
2094 if(parse_debug):
2095 print('modport_item_list_2', list(p))
2096
2097
2098 ()
2099
2100
2101 def p_modport_item_1(p):
2102 '''modport_item : IDENTIFIER _embed0_modport_item '(' modport_ports_list ')' '''
2103 if(parse_debug):
2104 print('modport_item_1', list(p))
2105
2106
2107 # { pform_end_modport_item(@1); }
2108 ()
2109
2110
2111 def p__embed0_modport_item(p):
2112 '''_embed0_modport_item : '''
2113
2114
2115 # { pform_start_modport_item(@1, p[1]); }
2116 ()
2117
2118
2119 def p_modport_ports_list_1(p):
2120 '''modport_ports_list : modport_ports_declaration '''
2121 if(parse_debug):
2122 print('modport_ports_list_1', list(p))
2123
2124
2125 ()
2126
2127
2128 def p_modport_ports_list_2(p):
2129 '''modport_ports_list : modport_ports_list ',' modport_ports_declaration '''
2130 if(parse_debug):
2131 print('modport_ports_list_2', list(p))
2132
2133
2134 ()
2135
2136
2137 def p_modport_ports_list_3(p):
2138 '''modport_ports_list : modport_ports_list ',' modport_simple_port '''
2139 if(parse_debug):
2140 print('modport_ports_list_3', list(p))
2141
2142
2143 # { if (last_modport_port.type == MP_SIMPLE) {
2144 # pform_add_modport_port(@3, last_modport_port.direction,
2145 # p[3]->name, p[3]->parm);
2146 # } else {
2147 # yyerror(@3, "error: modport expression not allowed here.");
2148 # }
2149 # delete p[3];
2150 # }
2151 ()
2152
2153
2154 def p_modport_ports_list_4(p):
2155 '''modport_ports_list : modport_ports_list ',' modport_tf_port '''
2156 if(parse_debug):
2157 print('modport_ports_list_4', list(p))
2158
2159
2160 # { if (last_modport_port.type != MP_TF)
2161 # yyerror(@3, "error: task/function declaration not allowed here.");
2162 # }
2163 ()
2164
2165
2166 def p_modport_ports_list_5(p):
2167 '''modport_ports_list : modport_ports_list ',' IDENTIFIER '''
2168 if(parse_debug):
2169 print('modport_ports_list_5', list(p))
2170
2171
2172 # { if (last_modport_port.type == MP_SIMPLE) {
2173 # pform_add_modport_port(@3, last_modport_port.direction,
2174 # lex_strings.make(p[3]), 0);
2175 # } else if (last_modport_port.type != MP_TF) {
2176 # yyerror(@3, "error: list of identifiers not allowed here.");
2177 # }
2178 # delete[] p[3];
2179 # }
2180 ()
2181
2182
2183 def p_modport_ports_list_6(p):
2184 '''modport_ports_list : modport_ports_list ',' '''
2185 if(parse_debug):
2186 print('modport_ports_list_6', list(p))
2187
2188
2189 # { yyerror(@2, "error: NULL port declarations are not allowed"); }
2190 ()
2191
2192
2193 def p_modport_ports_declaration_1(p):
2194 '''modport_ports_declaration : attribute_list_opt port_direction IDENTIFIER '''
2195 if(parse_debug):
2196 print('modport_ports_declaration_1', list(p))
2197
2198
2199 # { last_modport_port.type = MP_SIMPLE;
2200 # last_modport_port.direction = p[2];
2201 # pform_add_modport_port(@3, p[2], lex_strings.make(p[3]), 0);
2202 # delete[] p[3];
2203 # delete p[1];
2204 # }
2205 ()
2206
2207
2208 def p_modport_ports_declaration_2(p):
2209 '''modport_ports_declaration : attribute_list_opt port_direction modport_simple_port '''
2210 if(parse_debug):
2211 print('modport_ports_declaration_2', list(p))
2212
2213
2214 # { last_modport_port.type = MP_SIMPLE;
2215 # last_modport_port.direction = p[2];
2216 # pform_add_modport_port(@3, p[2], p[3]->name, p[3]->parm);
2217 # delete p[3];
2218 # delete p[1];
2219 # }
2220 ()
2221
2222
2223 def p_modport_ports_declaration_3(p):
2224 '''modport_ports_declaration : attribute_list_opt import_export IDENTIFIER '''
2225 if(parse_debug):
2226 print('modport_ports_declaration_3', list(p))
2227
2228
2229 # { last_modport_port.type = MP_TF;
2230 # last_modport_port.is_import = p[2];
2231 # yyerror(@3, "sorry: modport task/function ports are not yet supported.");
2232 # delete[] p[3];
2233 # delete p[1];
2234 # }
2235 ()
2236
2237
2238 def p_modport_ports_declaration_4(p):
2239 '''modport_ports_declaration : attribute_list_opt import_export modport_tf_port '''
2240 if(parse_debug):
2241 print('modport_ports_declaration_4', list(p))
2242
2243
2244 # { last_modport_port.type = MP_TF;
2245 # last_modport_port.is_import = p[2];
2246 # yyerror(@3, "sorry: modport task/function ports are not yet supported.");
2247 # delete p[1];
2248 # }
2249 ()
2250
2251
2252 def p_modport_ports_declaration_5(p):
2253 '''modport_ports_declaration : attribute_list_opt K_clocking IDENTIFIER '''
2254 if(parse_debug):
2255 print('modport_ports_declaration_5', list(p))
2256
2257
2258 # { last_modport_port.type = MP_CLOCKING;
2259 # last_modport_port.direction = NetNet::NOT_A_PORT;
2260 # yyerror(@3, "sorry: modport clocking declaration is not yet supported.");
2261 # delete[] p[3];
2262 # delete p[1];
2263 # }
2264 ()
2265
2266
2267 def p_modport_simple_port_1(p):
2268 '''modport_simple_port : '.' IDENTIFIER '(' expression ')' '''
2269 if(parse_debug):
2270 print('modport_simple_port_1', list(p))
2271
2272
2273 # { named_pexpr_t*tmp = new named_pexpr_t;
2274 # tmp->name = lex_strings.make(p[2]);
2275 # tmp->parm = p[4];
2276 # delete[]p[2];
2277 # p[0] = tmp;
2278 # }
2279 ()
2280
2281
2282 def p_modport_tf_port_1(p):
2283 '''modport_tf_port : K_task IDENTIFIER '''
2284 if(parse_debug):
2285 print('modport_tf_port_1', list(p))
2286
2287
2288 ()
2289
2290
2291 def p_modport_tf_port_2(p):
2292 '''modport_tf_port : K_task IDENTIFIER '(' tf_port_list_opt ')' '''
2293 if(parse_debug):
2294 print('modport_tf_port_2', list(p))
2295
2296
2297 ()
2298
2299
2300 def p_modport_tf_port_3(p):
2301 '''modport_tf_port : K_function data_type_or_implicit_or_void IDENTIFIER '''
2302 if(parse_debug):
2303 print('modport_tf_port_3', list(p))
2304
2305
2306 ()
2307
2308
2309 def p_modport_tf_port_4(p):
2310 '''modport_tf_port : K_function data_type_or_implicit_or_void IDENTIFIER '(' tf_port_list_opt ')' '''
2311 if(parse_debug):
2312 print('modport_tf_port_4', list(p))
2313
2314
2315 ()
2316
2317
2318 def p_non_integer_type_1(p):
2319 '''non_integer_type : K_real '''
2320 if(parse_debug):
2321 print('non_integer_type_1', list(p))
2322
2323
2324 # { p[0] = real_type_t::REAL; }
2325 ()
2326
2327
2328 def p_non_integer_type_2(p):
2329 '''non_integer_type : K_realtime '''
2330 if(parse_debug):
2331 print('non_integer_type_2', list(p))
2332
2333
2334 # { p[0] = real_type_t::REAL; }
2335 ()
2336
2337
2338 def p_non_integer_type_3(p):
2339 '''non_integer_type : K_shortreal '''
2340 if(parse_debug):
2341 print('non_integer_type_3', list(p))
2342
2343
2344 # { p[0] = real_type_t::SHORTREAL; }
2345 ()
2346
2347
2348 def p_number_1(p):
2349 '''number : BASED_NUMBER '''
2350 if(parse_debug):
2351 print('number_1', list(p))
2352
2353
2354 # { p[0] = p[1]; based_size = 0;}
2355 ()
2356
2357
2358 def p_number_2(p):
2359 '''number : DEC_NUMBER '''
2360 if(parse_debug):
2361 print('number_2', list(p))
2362 num = Leaf(token.NUMBER, "%s" % (p[1]))
2363 p[0] = num
2364
2365
2366 # { p[0] = p[1]; based_size = 0;}
2367 ()
2368
2369
2370 def p_number_3(p):
2371 '''number : DEC_NUMBER BASED_NUMBER '''
2372 if(parse_debug):
2373 print('number_3', list(p))
2374 num = Leaf(token.NUMBER, "%s:%s" % (p[1], p[2]))
2375 p[0] = num
2376
2377
2378 # { p[0] = pform_verinum_with_size(p[1],p[2], @2.text, @2.first_line);
2379 # based_size = 0; }
2380 ()
2381
2382
2383 def p_number_4(p):
2384 '''number : UNBASED_NUMBER '''
2385 if(parse_debug):
2386 print('number_4', list(p))
2387
2388
2389 # { p[0] = p[1]; based_size = 0;}
2390 ()
2391
2392
2393 def p_number_5(p):
2394 '''number : DEC_NUMBER UNBASED_NUMBER '''
2395 if(parse_debug):
2396 print('number_5', list(p))
2397
2398
2399 # { yyerror(@1, "error: Unbased SystemVerilog literal cannot have "
2400 # "a size.");
2401 # p[0] = p[1]; based_size = 0;}
2402 ()
2403
2404
2405 def p_open_range_list_1(p):
2406 '''open_range_list : open_range_list ',' value_range '''
2407 if(parse_debug):
2408 print('open_range_list_1', list(p))
2409
2410
2411 ()
2412
2413
2414 def p_open_range_list_2(p):
2415 '''open_range_list : value_range '''
2416 if(parse_debug):
2417 print('open_range_list_2', list(p))
2418
2419
2420 ()
2421
2422
2423 def p_package_declaration_1(p):
2424 '''package_declaration : K_package lifetime_opt IDENTIFIER ';' _embed0_package_declaration timeunits_declaration_opt _embed1_package_declaration package_item_list_opt K_endpackage endlabel_opt '''
2425 if(parse_debug):
2426 print('package_declaration_1', list(p))
2427
2428
2429 # { pform_end_package_declaration(@1);
2430 # // If an end label is present make sure it match the package name.
2431 # if (p[10]) {
2432 # if (strcmp(p[3],p[10]) != 0) {
2433 # yyerror(@10, "error: End label doesn't match package name");
2434 # }
2435 # delete[]p[10];
2436 # }
2437 # delete[]p[3];
2438 # }
2439 ()
2440
2441
2442 def p__embed0_package_declaration(p):
2443 '''_embed0_package_declaration : '''
2444
2445
2446 # { pform_start_package_declaration(@1, p[3], p[2]); }
2447 ()
2448
2449
2450 def p__embed1_package_declaration(p):
2451 '''_embed1_package_declaration : '''
2452
2453
2454 # { pform_set_scope_timescale(@1); }
2455 ()
2456
2457
2458 def p_module_package_import_list_opt_1(p):
2459 '''module_package_import_list_opt : '''
2460 if(parse_debug > 1):
2461 print('module_package_import_list_opt_1', list(p))
2462
2463
2464 ()
2465
2466
2467 def p_module_package_import_list_opt_2(p):
2468 '''module_package_import_list_opt : package_import_list '''
2469 if(parse_debug):
2470 print('module_package_import_list_opt_2', list(p))
2471
2472
2473 ()
2474
2475
2476 def p_package_import_list_1(p):
2477 '''package_import_list : package_import_declaration '''
2478 if(parse_debug):
2479 print('package_import_list_1', list(p))
2480
2481
2482 ()
2483
2484
2485 def p_package_import_list_2(p):
2486 '''package_import_list : package_import_list package_import_declaration '''
2487 if(parse_debug):
2488 print('package_import_list_2', list(p))
2489
2490
2491 ()
2492
2493
2494 def p_package_import_declaration_1(p):
2495 '''package_import_declaration : K_import package_import_item_list ';' '''
2496 if(parse_debug):
2497 print('package_import_declaration_1', list(p))
2498
2499
2500 # { }
2501 ()
2502
2503
2504 def p_package_import_item_1(p):
2505 '''package_import_item : PACKAGE_IDENTIFIER K_SCOPE_RES IDENTIFIER '''
2506 if(parse_debug):
2507 print('package_import_item_1', list(p))
2508
2509
2510 # { pform_package_import(@2, p[1], p[3]);
2511 # delete[]p[3];
2512 # }
2513 ()
2514
2515
2516 def p_package_import_item_2(p):
2517 '''package_import_item : PACKAGE_IDENTIFIER K_SCOPE_RES '*' '''
2518 if(parse_debug):
2519 print('package_import_item_2', list(p))
2520
2521
2522 # { pform_package_import(@2, p[1], 0);
2523 # }
2524 ()
2525
2526
2527 def p_package_import_item_list_1(p):
2528 '''package_import_item_list : package_import_item_list ',' package_import_item '''
2529 if(parse_debug):
2530 print('package_import_item_list_1', list(p))
2531
2532
2533 ()
2534
2535
2536 def p_package_import_item_list_2(p):
2537 '''package_import_item_list : package_import_item '''
2538 if(parse_debug):
2539 print('package_import_item_list_2', list(p))
2540
2541
2542 ()
2543
2544
2545 def p_package_item_1(p):
2546 '''package_item : timeunits_declaration '''
2547 if(parse_debug):
2548 print('package_item_1', list(p))
2549
2550
2551 ()
2552
2553
2554 def p_package_item_2(p):
2555 '''package_item : K_parameter param_type parameter_assign_list ';' '''
2556 if(parse_debug):
2557 print('package_item_2', list(p))
2558
2559
2560 ()
2561
2562
2563 def p_package_item_3(p):
2564 '''package_item : K_localparam param_type localparam_assign_list ';' '''
2565 if(parse_debug):
2566 print('package_item_3', list(p))
2567
2568
2569 ()
2570
2571
2572 def p_package_item_4(p):
2573 '''package_item : type_declaration '''
2574 if(parse_debug):
2575 print('package_item_4', list(p))
2576
2577
2578 ()
2579
2580
2581 def p_package_item_5(p):
2582 '''package_item : function_declaration '''
2583 if(parse_debug):
2584 print('package_item_5', list(p))
2585
2586
2587 ()
2588
2589
2590 def p_package_item_6(p):
2591 '''package_item : task_declaration '''
2592 if(parse_debug):
2593 print('package_item_6', list(p))
2594
2595
2596 ()
2597
2598
2599 def p_package_item_7(p):
2600 '''package_item : data_declaration '''
2601 if(parse_debug):
2602 print('package_item_7', list(p))
2603
2604
2605 ()
2606
2607
2608 def p_package_item_8(p):
2609 '''package_item : class_declaration '''
2610 if(parse_debug):
2611 print('package_item_8', list(p))
2612
2613
2614 ()
2615
2616
2617 def p_package_item_list_1(p):
2618 '''package_item_list : package_item_list package_item '''
2619 if(parse_debug):
2620 print('package_item_list_1', list(p))
2621
2622
2623 ()
2624
2625
2626 def p_package_item_list_2(p):
2627 '''package_item_list : package_item '''
2628 if(parse_debug):
2629 print('package_item_list_2', list(p))
2630
2631
2632 ()
2633
2634
2635 def p_package_item_list_opt_1(p):
2636 '''package_item_list_opt : package_item_list '''
2637 if(parse_debug):
2638 print('package_item_list_opt_1', list(p))
2639
2640
2641 ()
2642
2643
2644 def p_package_item_list_opt_2(p):
2645 '''package_item_list_opt : '''
2646 if(parse_debug):
2647 print('package_item_list_opt_2', list(p))
2648
2649
2650 ()
2651
2652
2653 def p_port_direction_1(p):
2654 '''port_direction : K_input '''
2655 if(parse_debug):
2656 print('port_direction_1', list(p))
2657
2658
2659 # { p[0] = NetNet::PINPUT; }
2660 ()
2661
2662
2663 def p_port_direction_2(p):
2664 '''port_direction : K_output '''
2665 if(parse_debug):
2666 print('port_direction_2', list(p))
2667
2668
2669 # { p[0] = NetNet::POUTPUT; }
2670 ()
2671
2672
2673 def p_port_direction_3(p):
2674 '''port_direction : K_inout '''
2675 if(parse_debug):
2676 print('port_direction_3', list(p))
2677
2678
2679 # { p[0] = NetNet::PINOUT; }
2680 ()
2681
2682
2683 def p_port_direction_4(p):
2684 '''port_direction : K_ref '''
2685 if(parse_debug):
2686 print('port_direction_4', list(p))
2687
2688
2689 # { p[0] = NetNet::PREF;
2690 # if (!gn_system_verilog()) {
2691 # yyerror(@1, "error: Reference ports (ref) require SystemVerilog.");
2692 # p[0] = NetNet::PINPUT;
2693 # }
2694 # }
2695 ()
2696
2697
2698 def p_port_direction_opt_1(p):
2699 '''port_direction_opt : port_direction '''
2700 if(parse_debug):
2701 print('port_direction_opt_1', list(p))
2702 p[0] = p[1]
2703
2704
2705 ()
2706
2707
2708 def p_port_direction_opt_2(p):
2709 '''port_direction_opt : '''
2710 if(parse_debug):
2711 print('port_direction_opt_2', list(p))
2712
2713
2714 # { p[0] = NetNet::PIMPLICIT; }
2715 ()
2716
2717
2718 def p_property_expr_1(p):
2719 '''property_expr : expression '''
2720 if(parse_debug):
2721 print('property_expr_1', list(p))
2722
2723
2724 ()
2725
2726
2727 def p_procedural_assertion_statement_1(p):
2728 '''procedural_assertion_statement : K_assert '(' expression ')' statement %prec less_than_K_else '''
2729 if(parse_debug):
2730 print('procedural_assertion_statement_1', list(p))
2731
2732
2733 # { yyerror(@1, "sorry: Simple immediate assertion statements not implemented.");
2734 # p[0] = None
2735 # }
2736 ()
2737
2738
2739 def p_procedural_assertion_statement_2(p):
2740 '''procedural_assertion_statement : K_assert '(' expression ')' K_else statement '''
2741 if(parse_debug):
2742 print('procedural_assertion_statement_2', list(p))
2743
2744
2745 # { yyerror(@1, "sorry: Simple immediate assertion statements not implemented.");
2746 # p[0] = None
2747 # }
2748 ()
2749
2750
2751 def p_procedural_assertion_statement_3(p):
2752 '''procedural_assertion_statement : K_assert '(' expression ')' statement K_else statement '''
2753 if(parse_debug):
2754 print('procedural_assertion_statement_3', list(p))
2755
2756
2757 # { yyerror(@1, "sorry: Simple immediate assertion statements not implemented.");
2758 # p[0] = None
2759 # }
2760 ()
2761
2762
2763 def p_property_qualifier_1(p):
2764 '''property_qualifier : class_item_qualifier '''
2765 if(parse_debug):
2766 print('property_qualifier_1', list(p))
2767
2768
2769 ()
2770
2771
2772 def p_property_qualifier_2(p):
2773 '''property_qualifier : random_qualifier '''
2774 if(parse_debug):
2775 print('property_qualifier_2', list(p))
2776
2777
2778 ()
2779
2780
2781 def p_property_qualifier_opt_1(p):
2782 '''property_qualifier_opt : property_qualifier_list '''
2783 if(parse_debug):
2784 print('property_qualifier_opt_1', list(p))
2785 p[0] = p[1]
2786
2787
2788 ()
2789
2790
2791 def p_property_qualifier_opt_2(p):
2792 '''property_qualifier_opt : '''
2793 if(parse_debug):
2794 print('property_qualifier_opt_2', list(p))
2795
2796
2797 # { p[0] = property_qualifier_t::make_none(); }
2798 ()
2799
2800
2801 def p_property_qualifier_list_1(p):
2802 '''property_qualifier_list : property_qualifier_list property_qualifier '''
2803 if(parse_debug):
2804 print('property_qualifier_list_1', list(p))
2805
2806
2807 # { p[0] = p[1] | p[2]; }
2808 ()
2809
2810
2811 def p_property_qualifier_list_2(p):
2812 '''property_qualifier_list : property_qualifier '''
2813 if(parse_debug):
2814 print('property_qualifier_list_2', list(p))
2815 p[0] = p[1]
2816
2817
2818 ()
2819
2820
2821 def p_property_spec_1(p):
2822 '''property_spec : clocking_event_opt property_spec_disable_iff_opt property_expr '''
2823 if(parse_debug):
2824 print('property_spec_1', list(p))
2825
2826
2827 ()
2828
2829
2830 def p_property_spec_disable_iff_opt_1(p):
2831 '''property_spec_disable_iff_opt : K_disable K_iff '(' expression ')' '''
2832 if(parse_debug):
2833 print('property_spec_disable_iff_opt_1', list(p))
2834
2835
2836 ()
2837
2838
2839 def p_property_spec_disable_iff_opt_2(p):
2840 '''property_spec_disable_iff_opt : '''
2841 if(parse_debug):
2842 print('property_spec_disable_iff_opt_2', list(p))
2843
2844
2845 ()
2846
2847
2848 def p_random_qualifier_1(p):
2849 '''random_qualifier : K_rand '''
2850 if(parse_debug):
2851 print('random_qualifier_1', list(p))
2852
2853
2854 # { p[0] = property_qualifier_t::make_rand(); }
2855 ()
2856
2857
2858 def p_random_qualifier_2(p):
2859 '''random_qualifier : K_randc '''
2860 if(parse_debug):
2861 print('random_qualifier_2', list(p))
2862
2863
2864 # { p[0] = property_qualifier_t::make_randc(); }
2865 ()
2866
2867
2868 def p_real_or_realtime_1(p):
2869 '''real_or_realtime : K_real '''
2870 if(parse_debug):
2871 print('real_or_realtime_1', list(p))
2872
2873
2874 ()
2875
2876
2877 def p_real_or_realtime_2(p):
2878 '''real_or_realtime : K_realtime '''
2879 if(parse_debug):
2880 print('real_or_realtime_2', list(p))
2881
2882
2883 ()
2884
2885
2886 def p_signing_1(p):
2887 '''signing : K_signed '''
2888 if(parse_debug):
2889 print('signing_1', list(p))
2890 p[0] = True
2891
2892
2893 ()
2894
2895
2896 def p_signing_2(p):
2897 '''signing : K_unsigned '''
2898 if(parse_debug):
2899 print('signing_2', list(p))
2900 p[0] = False
2901
2902
2903 ()
2904
2905
2906 def p_simple_type_or_string_1(p):
2907 '''simple_type_or_string : integer_vector_type '''
2908 if(parse_debug):
2909 print('simple_type_or_string_1', list(p))
2910
2911
2912 # { ivl_variable_type_t use_vtype = p[1];
2913 # bool reg_flag = false;
2914 # if (use_vtype == IVL_VT_NO_TYPE) {
2915 # use_vtype = IVL_VT_LOGIC;
2916 # reg_flag = true;
2917 # }
2918 # vector_type_t*tmp = new vector_type_t(use_vtype, false, 0);
2919 # tmp->reg_flag = reg_flag;
2920 # FILE_NAME(tmp, @1);
2921 # p[0] = tmp;
2922 # }
2923 ()
2924
2925
2926 def p_simple_type_or_string_2(p):
2927 '''simple_type_or_string : non_integer_type '''
2928 if(parse_debug):
2929 print('simple_type_or_string_2', list(p))
2930
2931
2932 # { real_type_t*tmp = new real_type_t(p[1]);
2933 # FILE_NAME(tmp, @1);
2934 # p[0] = tmp;
2935 # }
2936 ()
2937
2938
2939 def p_simple_type_or_string_3(p):
2940 '''simple_type_or_string : atom2_type '''
2941 if(parse_debug):
2942 print('simple_type_or_string_3', list(p))
2943
2944
2945 # { atom2_type_t*tmp = new atom2_type_t(p[1], true);
2946 # FILE_NAME(tmp, @1);
2947 # p[0] = tmp;
2948 # }
2949 ()
2950
2951
2952 def p_simple_type_or_string_4(p):
2953 '''simple_type_or_string : K_integer '''
2954 if(parse_debug):
2955 print('simple_type_or_string_4', list(p))
2956
2957
2958 # { list<pform_range_t>*pd = make_range_from_width(integer_width);
2959 # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, true, pd);
2960 # tmp->reg_flag = true;
2961 # tmp->integer_flag = true;
2962 # p[0] = tmp;
2963 # }
2964 ()
2965
2966
2967 def p_simple_type_or_string_5(p):
2968 '''simple_type_or_string : K_time '''
2969 if(parse_debug):
2970 print('simple_type_or_string_5', list(p))
2971
2972
2973 # { list<pform_range_t>*pd = make_range_from_width(64);
2974 # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, false, pd);
2975 # tmp->reg_flag = !gn_system_verilog();
2976 # p[0] = tmp;
2977 # }
2978 ()
2979
2980
2981 def p_simple_type_or_string_6(p):
2982 '''simple_type_or_string : TYPE_IDENTIFIER '''
2983 if(parse_debug):
2984 print('simple_type_or_string_6', list(p))
2985
2986
2987 # { p[0] = p[1].type;
2988 # delete[]p[1].text;
2989 # }
2990 ()
2991
2992
2993 def p_simple_type_or_string_7(p):
2994 '''simple_type_or_string : PACKAGE_IDENTIFIER K_SCOPE_RES _embed0_simple_type_or_string TYPE_IDENTIFIER '''
2995 if(parse_debug):
2996 print('simple_type_or_string_7', list(p))
2997
2998
2999 # { lex_in_package_scope(0);
3000 # p[0] = p[4].type;
3001 # delete[]p[4].text;
3002 # }
3003 ()
3004
3005
3006 def p_simple_type_or_string_8(p):
3007 '''simple_type_or_string : K_string '''
3008 if(parse_debug):
3009 print('simple_type_or_string_8', list(p))
3010
3011
3012 # { string_type_t*tmp = new string_type_t;
3013 # FILE_NAME(tmp, @1);
3014 # p[0] = tmp;
3015 # }
3016 ()
3017
3018
3019 def p__embed0_simple_type_or_string(p):
3020 '''_embed0_simple_type_or_string : '''
3021
3022
3023 # { lex_in_package_scope(p[1]); }
3024 ()
3025
3026
3027 def p_statement_1(p):
3028 '''statement : attribute_list_opt statement_item '''
3029 if(parse_debug):
3030 print('statement_1', list(p))
3031
3032 # { pform_bind_attributes(p[2]->attributes, p[1]);
3033 p[0] = p[2]
3034
3035 # }
3036 ()
3037
3038
3039 def p_statement_or_null_1(p):
3040 '''statement_or_null : statement '''
3041 if(parse_debug):
3042 print('statement_or_null_1', list(p))
3043 p[0] = p[1]
3044
3045
3046 ()
3047
3048
3049 def p_statement_or_null_2(p):
3050 '''statement_or_null : attribute_list_opt ';' '''
3051 if(parse_debug):
3052 print('statement_or_null_2', list(p))
3053
3054 raise(Exception("p_statement_or_null_2"))
3055
3056
3057 # { p[0] = None }
3058 ()
3059
3060
3061 def p_stream_expression_1(p):
3062 '''stream_expression : expression '''
3063 if(parse_debug):
3064 print('stream_expression_1', list(p))
3065
3066
3067 ()
3068
3069
3070 def p_stream_expression_list_1(p):
3071 '''stream_expression_list : stream_expression_list ',' stream_expression '''
3072 if(parse_debug):
3073 print('stream_expression_list_1', list(p))
3074
3075
3076 ()
3077
3078
3079 def p_stream_expression_list_2(p):
3080 '''stream_expression_list : stream_expression '''
3081 if(parse_debug):
3082 print('stream_expression_list_2', list(p))
3083
3084
3085 ()
3086
3087
3088 def p_stream_operator_1(p):
3089 '''stream_operator : K_LS '''
3090 if(parse_debug):
3091 print('stream_operator_1', list(p))
3092
3093
3094 ()
3095
3096
3097 def p_stream_operator_2(p):
3098 '''stream_operator : K_RS '''
3099 if(parse_debug):
3100 print('stream_operator_2', list(p))
3101
3102
3103 ()
3104
3105
3106 def p_streaming_concatenation_1(p):
3107 '''streaming_concatenation : '{' stream_operator '{' stream_expression_list '}' '}' '''
3108 if(parse_debug):
3109 print('streaming_concatenation_1', list(p))
3110
3111
3112 # { /* streaming concatenation is a SystemVerilog thing. */
3113 # if (gn_system_verilog()) {
3114 # yyerror(@2, "sorry: Streaming concatenation not supported.");
3115 # p[0] = None
3116 # } else {
3117 # yyerror(@2, "error: Streaming concatenation requires SystemVerilog");
3118 # p[0] = None
3119 # }
3120 # }
3121 ()
3122
3123
3124 def p_task_declaration_1(p):
3125 '''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 '''
3126 if(parse_debug):
3127 print('task_declaration_1', list(p))
3128
3129
3130 # { // Last step: check any closing name. This is done late so
3131 # // that the parser can look ahead to detect the present
3132 # // endlabel_opt but still have the pform_endmodule() called
3133 # // early enough that the lexor can know we are outside the
3134 # // module.
3135 # if (p[10]) {
3136 # if (strcmp(p[3],p[10]) != 0) {
3137 # yyerror(@10, "error: End label doesn't match task name");
3138 # }
3139 # if (! gn_system_verilog()) {
3140 # yyerror(@10, "error: Task end labels require "
3141 # "SystemVerilog.");
3142 # }
3143 # delete[]p[10];
3144 # }
3145 # delete[]p[3];
3146 # }
3147 ()
3148
3149
3150 def p_task_declaration_2(p):
3151 '''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 '''
3152 if(parse_debug):
3153 print('task_declaration_2', list(p))
3154
3155
3156 # { // Last step: check any closing name. This is done late so
3157 # // that the parser can look ahead to detect the present
3158 # // endlabel_opt but still have the pform_endmodule() called
3159 # // early enough that the lexor can know we are outside the
3160 # // module.
3161 # if (p[13]) {
3162 # if (strcmp(p[3],p[13]) != 0) {
3163 # yyerror(@13, "error: End label doesn't match task name");
3164 # }
3165 # if (! gn_system_verilog()) {
3166 # yyerror(@13, "error: Task end labels require "
3167 # "SystemVerilog.");
3168 # }
3169 # delete[]p[13];
3170 # }
3171 # delete[]p[3];
3172 # }
3173 ()
3174
3175
3176 def p_task_declaration_3(p):
3177 '''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 '''
3178 if(parse_debug):
3179 print('task_declaration_3', list(p))
3180
3181
3182 # { // Last step: check any closing name. This is done late so
3183 # // that the parser can look ahead to detect the present
3184 # // endlabel_opt but still have the pform_endmodule() called
3185 # // early enough that the lexor can know we are outside the
3186 # // module.
3187 # if (p[12]) {
3188 # if (strcmp(p[3],p[12]) != 0) {
3189 # yyerror(@12, "error: End label doesn't match task name");
3190 # }
3191 # if (! gn_system_verilog()) {
3192 # yyerror(@12, "error: Task end labels require "
3193 # "SystemVerilog.");
3194 # }
3195 # delete[]p[12];
3196 # }
3197 # delete[]p[3];
3198 # }
3199 ()
3200
3201
3202 def p_task_declaration_4(p):
3203 '''task_declaration : K_task lifetime_opt IDENTIFIER error K_endtask _embed6_task_declaration endlabel_opt '''
3204 if(parse_debug):
3205 print('task_declaration_4', list(p))
3206
3207
3208 # { // Last step: check any closing name. This is done late so
3209 # // that the parser can look ahead to detect the present
3210 # // endlabel_opt but still have the pform_endmodule() called
3211 # // early enough that the lexor can know we are outside the
3212 # // module.
3213 # if (p[7]) {
3214 # if (strcmp(p[3],p[7]) != 0) {
3215 # yyerror(@7, "error: End label doesn't match task name");
3216 # }
3217 # if (! gn_system_verilog()) {
3218 # yyerror(@7, "error: Task end labels require "
3219 # "SystemVerilog.");
3220 # }
3221 # delete[]p[7];
3222 # }
3223 # delete[]p[3];
3224 # }
3225 ()
3226
3227
3228 def p__embed0_task_declaration(p):
3229 '''_embed0_task_declaration : '''
3230
3231
3232 # { assert(current_task == 0);
3233 # current_task = pform_push_task_scope(@1, p[3], p[2]);
3234 # }
3235 ()
3236
3237
3238 def p__embed1_task_declaration(p):
3239 '''_embed1_task_declaration : '''
3240
3241
3242 # { current_task->set_ports(p[6]);
3243 # current_task_set_statement(@3, p[7]);
3244 # pform_set_this_class(@3, current_task);
3245 # pform_pop_scope();
3246 # current_task = 0;
3247 # if (p[7] && p[7]->size() > 1 && !gn_system_verilog()) {
3248 # yyerror(@7, "error: Task body with multiple statements requires SystemVerilog.");
3249 # }
3250 # delete p[7];
3251 # }
3252 ()
3253
3254
3255 def p__embed2_task_declaration(p):
3256 '''_embed2_task_declaration : '''
3257
3258
3259 # { assert(current_task == 0);
3260 # current_task = pform_push_task_scope(@1, p[3], p[2]);
3261 # }
3262 ()
3263
3264
3265 def p__embed3_task_declaration(p):
3266 '''_embed3_task_declaration : '''
3267
3268
3269 # { current_task->set_ports(p[6]);
3270 # current_task_set_statement(@3, p[10]);
3271 # pform_set_this_class(@3, current_task);
3272 # pform_pop_scope();
3273 # current_task = 0;
3274 # if (p[10]) delete p[10];
3275 # }
3276 ()
3277
3278
3279 def p__embed4_task_declaration(p):
3280 '''_embed4_task_declaration : '''
3281
3282
3283 # { assert(current_task == 0);
3284 # current_task = pform_push_task_scope(@1, p[3], p[2]);
3285 # }
3286 ()
3287
3288
3289 def p__embed5_task_declaration(p):
3290 '''_embed5_task_declaration : '''
3291
3292
3293 # { current_task->set_ports(0);
3294 # current_task_set_statement(@3, p[9]);
3295 # pform_set_this_class(@3, current_task);
3296 # if (! current_task->method_of()) {
3297 # cerr << @3 << ": warning: task definition for \"" << p[3]
3298 # << "\" has an empty port declaration list!" << endl;
3299 # }
3300 # pform_pop_scope();
3301 # current_task = 0;
3302 # if (p[9]->size() > 1 && !gn_system_verilog()) {
3303 # yyerror(@9, "error: Task body with multiple statements requires SystemVerilog.");
3304 # }
3305 # delete p[9];
3306 # }
3307 ()
3308
3309
3310 def p__embed6_task_declaration(p):
3311 '''_embed6_task_declaration : '''
3312
3313
3314 # {
3315 # if (current_task) {
3316 # pform_pop_scope();
3317 # current_task = 0;
3318 # }
3319 # }
3320 ()
3321
3322
3323 def p_tf_port_declaration_1(p):
3324 '''tf_port_declaration : port_direction K_reg_opt unsigned_signed_opt dimensions_opt list_of_identifiers ';' '''
3325 if(parse_debug):
3326 print('tf_port_declaration_1', list(p))
3327
3328
3329 # { vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, p[1],
3330 # p[2] ? IVL_VT_LOGIC :
3331 # IVL_VT_NO_TYPE,
3332 # p[3], p[4], p[5]);
3333 # p[0] = tmp;
3334 # }
3335 ()
3336
3337
3338 def p_tf_port_declaration_2(p):
3339 '''tf_port_declaration : port_direction K_integer list_of_identifiers ';' '''
3340 if(parse_debug):
3341 print('tf_port_declaration_2', list(p))
3342
3343
3344 # { list<pform_range_t>*range_stub = make_range_from_width(integer_width);
3345 # vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, p[1], IVL_VT_LOGIC, true,
3346 # range_stub, p[3], true);
3347 # p[0] = tmp;
3348 # }
3349 ()
3350
3351
3352 def p_tf_port_declaration_3(p):
3353 '''tf_port_declaration : port_direction K_time list_of_identifiers ';' '''
3354 if(parse_debug):
3355 print('tf_port_declaration_3', list(p))
3356
3357
3358 # { list<pform_range_t>*range_stub = make_range_from_width(64);
3359 # vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, p[1], IVL_VT_LOGIC, false,
3360 # range_stub, p[3]);
3361 # p[0] = tmp;
3362 # }
3363 ()
3364
3365
3366 def p_tf_port_declaration_4(p):
3367 '''tf_port_declaration : port_direction real_or_realtime list_of_identifiers ';' '''
3368 if(parse_debug):
3369 print('tf_port_declaration_4', list(p))
3370
3371
3372 # { vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, p[1], IVL_VT_REAL, true,
3373 # 0, p[3]);
3374 # p[0] = tmp;
3375 # }
3376 ()
3377
3378
3379 def p_tf_port_declaration_5(p):
3380 '''tf_port_declaration : port_direction K_string list_of_identifiers ';' '''
3381 if(parse_debug):
3382 print('tf_port_declaration_5', list(p))
3383
3384
3385 # { vector<pform_tf_port_t>*tmp = pform_make_task_ports(@1, p[1], IVL_VT_STRING, true,
3386 # 0, p[3]);
3387 # p[0] = tmp;
3388 # }
3389 ()
3390
3391
3392 def p_tf_port_item_1(p):
3393 '''tf_port_item : port_direction_opt data_type_or_implicit IDENTIFIER dimensions_opt tf_port_item_expr_opt '''
3394 if(parse_debug):
3395 print('tf_port_item_1', list(p))
3396
3397
3398 # { vector<pform_tf_port_t>*tmp;
3399 # NetNet::PortType use_port_type = p[1];
3400 # if ((use_port_type == NetNet::PIMPLICIT) && (gn_system_verilog() || (p[2] == 0)))
3401 # use_port_type = port_declaration_context.port_type;
3402 # perm_string name = lex_strings.make(p[3]);
3403 # list<perm_string>* ilist = list_from_identifier(p[3]);
3404 #
3405 # if (use_port_type == NetNet::PIMPLICIT) {
3406 # yyerror(@1, "error: missing task/function port direction.");
3407 # use_port_type = NetNet::PINPUT; // for error recovery
3408 # }
3409 # if ((p[2] == 0) && (p[1]==NetNet::PIMPLICIT)) {
3410 # // Detect special case this is an undecorated
3411 # // identifier and we need to get the declaration from
3412 # // left context.
3413 # if (p[4] != 0) {
3414 # yyerror(@4, "internal error: How can there be an unpacked range here?\n");
3415 # }
3416 # tmp = pform_make_task_ports(@3, use_port_type,
3417 # port_declaration_context.data_type,
3418 # ilist);
3419 #
3420 # } else {
3421 # // Otherwise, the decorations for this identifier
3422 # // indicate the type. Save the type for any right
3423 # // context that may come later.
3424 # port_declaration_context.port_type = use_port_type;
3425 # if (p[2] == 0) {
3426 # p[2] = new vector_type_t(IVL_VT_LOGIC, false, 0);
3427 # FILE_NAME(p[2], @3);
3428 # }
3429 # port_declaration_context.data_type = p[2];
3430 # tmp = pform_make_task_ports(@3, use_port_type, p[2], ilist);
3431 # }
3432 # if (p[4] != 0) {
3433 # pform_set_reg_idx(name, p[4]);
3434 # }
3435 #
3436 # p[0] = tmp;
3437 # if (p[5]) {
3438 # assert(tmp->size()==1);
3439 # tmp->front().defe = p[5];
3440 # }
3441 # }
3442 ()
3443
3444
3445 def p_tf_port_item_2(p):
3446 '''tf_port_item : port_direction_opt data_type_or_implicit IDENTIFIER error '''
3447 if(parse_debug):
3448 print('tf_port_item_2', list(p))
3449
3450
3451 # { yyerror(@3, "error: Error in task/function port item after port name %s.", p[3]);
3452 # yyerrok;
3453 # p[0] = None
3454 # }
3455 ()
3456
3457
3458 def p_tf_port_item_expr_opt_1(p):
3459 '''tf_port_item_expr_opt : '=' expression '''
3460 if(parse_debug):
3461 print('tf_port_item_expr_opt_1', list(p))
3462
3463
3464 # { if (! gn_system_verilog()) {
3465 # yyerror(@1, "error: Task/function default arguments require "
3466 # "SystemVerilog.");
3467 # }
3468 # p[0] = p[2];
3469 # }
3470 ()
3471
3472
3473 def p_tf_port_item_expr_opt_2(p):
3474 '''tf_port_item_expr_opt : '''
3475 if(parse_debug):
3476 print('tf_port_item_expr_opt_2', list(p))
3477
3478
3479 # { p[0] = None }
3480 ()
3481
3482
3483 def p_tf_port_list_1(p):
3484 '''tf_port_list : _embed0_tf_port_list tf_port_item_list '''
3485 if(parse_debug):
3486 print('tf_port_list_1', list(p))
3487 p[0] = p[2]
3488
3489
3490 ()
3491
3492
3493 def p__embed0_tf_port_list(p):
3494 '''_embed0_tf_port_list : '''
3495
3496
3497 # { port_declaration_context.port_type = gn_system_verilog() ? NetNet::PINPUT : NetNet::PIMPLICIT;
3498 # port_declaration_context.data_type = 0;
3499 # }
3500 ()
3501
3502
3503 def p_tf_port_item_list_1(p):
3504 '''tf_port_item_list : tf_port_item_list ',' tf_port_item '''
3505 if(parse_debug):
3506 print('tf_port_item_list_1', list(p))
3507
3508
3509 # { vector<pform_tf_port_t>*tmp;
3510 # if (p[1] && p[3]) {
3511 # size_t s1 = p[1]->size();
3512 # tmp = p[1];
3513 # tmp->resize(tmp->size()+p[3]->size());
3514 # for (size_t idx = 0 ; idx < p[3]->size() ; idx += 1)
3515 # tmp->at(s1+idx) = p[3]->at(idx);
3516 # delete p[3];
3517 # } else if (p[1]) {
3518 # tmp = p[1];
3519 # } else {
3520 # tmp = p[3];
3521 # }
3522 # p[0] = tmp;
3523 # }
3524 ()
3525
3526
3527 def p_tf_port_item_list_2(p):
3528 '''tf_port_item_list : tf_port_item '''
3529 if(parse_debug):
3530 print('tf_port_item_list_2', list(p))
3531 p[0] = p[1]
3532
3533
3534 ()
3535
3536
3537 def p_tf_port_item_list_3(p):
3538 '''tf_port_item_list : error ',' tf_port_item '''
3539 if(parse_debug):
3540 print('tf_port_item_list_3', list(p))
3541
3542
3543 # { yyerror(@2, "error: Syntax error in task/function port declaration.");
3544 # p[0] = p[3];
3545 # }
3546 ()
3547
3548
3549 def p_tf_port_item_list_4(p):
3550 '''tf_port_item_list : tf_port_item_list ',' '''
3551 if(parse_debug):
3552 print('tf_port_item_list_4', list(p))
3553
3554
3555 # { yyerror(@2, "error: NULL port declarations are not allowed.");
3556 # p[0] = p[1];
3557 # }
3558 ()
3559
3560
3561 def p_tf_port_item_list_5(p):
3562 '''tf_port_item_list : tf_port_item_list ';' '''
3563 if(parse_debug):
3564 print('tf_port_item_list_5', list(p))
3565
3566
3567 # { yyerror(@2, "error: ';' is an invalid port declaration separator.");
3568 # p[0] = p[1];
3569 # }
3570 ()
3571
3572
3573 def p_timeunits_declaration_1(p):
3574 '''timeunits_declaration : K_timeunit TIME_LITERAL ';' '''
3575 if(parse_debug):
3576 print('timeunits_declaration_1', list(p))
3577
3578
3579 # { pform_set_timeunit(p[2], allow_timeunit_decl); }
3580 ()
3581
3582
3583 def p_timeunits_declaration_2(p):
3584 '''timeunits_declaration : K_timeunit TIME_LITERAL '/' TIME_LITERAL ';' '''
3585 if(parse_debug):
3586 print('timeunits_declaration_2', list(p))
3587
3588
3589 # { bool initial_decl = allow_timeunit_decl && allow_timeprec_decl;
3590 # pform_set_timeunit(p[2], initial_decl);
3591 # pform_set_timeprec(p[4], initial_decl);
3592 # }
3593 ()
3594
3595
3596 def p_timeunits_declaration_3(p):
3597 '''timeunits_declaration : K_timeprecision TIME_LITERAL ';' '''
3598 if(parse_debug):
3599 print('timeunits_declaration_3', list(p))
3600
3601
3602 # { pform_set_timeprec(p[2], allow_timeprec_decl); }
3603 ()
3604
3605
3606 def p_timeunits_declaration_opt_1(p):
3607 '''timeunits_declaration_opt : %prec no_timeunits_declaration '''
3608 if(parse_debug > 2):
3609 print('timeunits_declaration_opt_1', list(p))
3610
3611
3612 ()
3613
3614
3615 def p_timeunits_declaration_opt_2(p):
3616 '''timeunits_declaration_opt : timeunits_declaration %prec one_timeunits_declaration '''
3617 if(parse_debug):
3618 print('timeunits_declaration_opt_2', list(p))
3619
3620
3621 ()
3622
3623
3624 def p_timeunits_declaration_opt_3(p):
3625 '''timeunits_declaration_opt : timeunits_declaration timeunits_declaration '''
3626 if(parse_debug):
3627 print('timeunits_declaration_opt_3', list(p))
3628
3629
3630 ()
3631
3632
3633 def p_value_range_1(p):
3634 '''value_range : expression '''
3635 if(parse_debug):
3636 print('value_range_1', list(p))
3637
3638
3639 # { }
3640 ()
3641
3642
3643 def p_value_range_2(p):
3644 '''value_range : '[' expression ':' expression ']' '''
3645 if(parse_debug):
3646 print('value_range_2', list(p))
3647
3648
3649 # { }
3650 ()
3651
3652
3653 def p_variable_dimension_1(p):
3654 '''variable_dimension : '[' expression ':' expression ']' '''
3655 if(parse_debug):
3656 print('variable_dimension_1', list(p))
3657 # { list<pform_range_t> *tmp = new list<pform_range_t>;
3658 # pform_range_t index (p[2],p[4]);
3659 # tmp->push_back(index);
3660 # p[0] = tmp;
3661 # }
3662 # XXX TODO: subscriptlist
3663 start = str(p[4])
3664 end = str(p[2])
3665 if end.endswith("-1"):
3666 end = end[:-2]
3667 elif end.isdigit():
3668 end = str(int(end)+1)
3669 else:
3670 end = "1+%s" % end
3671 p[0] = '[%s:%s]' % (start, end) # python slice is LO:HI+1
3672
3673
3674 ()
3675
3676
3677 def p_variable_dimension_2(p):
3678 '''variable_dimension : '[' expression ']' '''
3679 if(parse_debug):
3680 print('variable_dimension_2', list(p))
3681
3682
3683 # { // SystemVerilog canonical range
3684 # if (!gn_system_verilog()) {
3685 # warn_count += 1;
3686 # cerr << @2 << ": warning: Use of SystemVerilog [size] dimension. "
3687 # << "Use at least -g2005-sv to remove this warning." << endl;
3688 # }
3689 # list<pform_range_t> *tmp = new list<pform_range_t>;
3690 # pform_range_t index;
3691 # index.first = new PENumber(new verinum((uint64_t)0, integer_width));
3692 # index.second = new PEBinary('-', p[2], new PENumber(new verinum((uint64_t)1, integer_width)));
3693 # tmp->push_back(index);
3694 # p[0] = tmp;
3695 # }
3696 ()
3697
3698
3699 def p_variable_dimension_3(p):
3700 '''variable_dimension : '[' ']' '''
3701 if(parse_debug):
3702 print('variable_dimension_3', list(p))
3703
3704
3705 # { list<pform_range_t> *tmp = new list<pform_range_t>;
3706 # pform_range_t index (0,0);
3707 # tmp->push_back(index);
3708 # p[0] = tmp;
3709 # }
3710 ()
3711
3712
3713 def p_variable_dimension_4(p):
3714 '''variable_dimension : '[' '$' ']' '''
3715 if(parse_debug):
3716 print('variable_dimension_4', list(p))
3717
3718
3719 # { // SystemVerilog queue
3720 # list<pform_range_t> *tmp = new list<pform_range_t>;
3721 # pform_range_t index (new PENull,0);
3722 # if (!gn_system_verilog()) {
3723 # yyerror("error: Queue declarations require SystemVerilog.");
3724 # }
3725 # tmp->push_back(index);
3726 # p[0] = tmp;
3727 # }
3728 ()
3729
3730
3731 def p_variable_lifetime_1(p):
3732 '''variable_lifetime : lifetime '''
3733 if(parse_debug):
3734 print('variable_lifetime_1', list(p))
3735
3736
3737 # { if (!gn_system_verilog()) {
3738 # yyerror(@1, "error: overriding the default variable lifetime "
3739 # "requires SystemVerilog.");
3740 # } else if (p[1] != pform_peek_scope()->default_lifetime) {
3741 # yyerror(@1, "sorry: overriding the default variable lifetime "
3742 # "is not yet supported.");
3743 # }
3744 # var_lifetime = p[1];
3745 # }
3746 ()
3747
3748
3749 def p_attribute_list_opt_1(p):
3750 '''attribute_list_opt : attribute_instance_list '''
3751 if(parse_debug):
3752 print('attribute_list_opt_1', list(p))
3753 p[0] = p[1]
3754
3755
3756 ()
3757
3758
3759 def p_attribute_list_opt_2(p):
3760 '''attribute_list_opt : '''
3761 if(parse_debug > 2):
3762 print('attribute_list_opt_2', list(p))
3763
3764
3765 # { p[0] = None }
3766 ()
3767
3768
3769 def p_attribute_instance_list_1(p):
3770 '''attribute_instance_list : K_PSTAR K_STARP '''
3771 if(parse_debug):
3772 print('attribute_instance_list_1', list(p))
3773
3774
3775 # { p[0] = None }
3776 ()
3777
3778
3779 def p_attribute_instance_list_2(p):
3780 '''attribute_instance_list : K_PSTAR attribute_list K_STARP '''
3781 if(parse_debug):
3782 print('attribute_instance_list_2', list(p))
3783 p[0] = p[2]
3784
3785
3786 ()
3787
3788
3789 def p_attribute_instance_list_3(p):
3790 '''attribute_instance_list : attribute_instance_list K_PSTAR K_STARP '''
3791 if(parse_debug):
3792 print('attribute_instance_list_3', list(p))
3793 p[0] = p[1]
3794
3795
3796 ()
3797
3798
3799 def p_attribute_instance_list_4(p):
3800 '''attribute_instance_list : attribute_instance_list K_PSTAR attribute_list K_STARP '''
3801 if(parse_debug):
3802 print('attribute_instance_list_4', list(p))
3803
3804
3805 # { list<named_pexpr_t>*tmp = p[1];
3806 # if (tmp) {
3807 # tmp->splice(tmp->end(), *p[3]);
3808 # delete p[3];
3809 # p[0] = tmp;
3810 # } else p[0] = p[3];
3811 # }
3812 ()
3813
3814
3815 def p_attribute_list_1(p):
3816 '''attribute_list : attribute_list ',' attribute '''
3817 if(parse_debug):
3818 print('attribute_list_1', list(p))
3819
3820
3821 # { list<named_pexpr_t>*tmp = p[1];
3822 # tmp->push_back(*p[3]);
3823 # delete p[3];
3824 # p[0] = tmp;
3825 # }
3826 ()
3827
3828
3829 def p_attribute_list_2(p):
3830 '''attribute_list : attribute '''
3831 if(parse_debug):
3832 print('attribute_list_2', list(p))
3833
3834
3835 # { list<named_pexpr_t>*tmp = new list<named_pexpr_t>;
3836 # tmp->push_back(*p[1]);
3837 # delete p[1];
3838 # p[0] = tmp;
3839 # }
3840 ()
3841
3842
3843 def p_attribute_1(p):
3844 '''attribute : IDENTIFIER '''
3845 if(parse_debug):
3846 print('attribute_1', list(p))
3847
3848
3849 # { named_pexpr_t*tmp = new named_pexpr_t;
3850 # tmp->name = lex_strings.make(p[1]);
3851 # tmp->parm = 0;
3852 # delete[]p[1];
3853 # p[0] = tmp;
3854 # }
3855 ()
3856
3857
3858 def p_attribute_2(p):
3859 '''attribute : IDENTIFIER '=' expression '''
3860 if(parse_debug):
3861 print('attribute_2', list(p))
3862
3863
3864 # { PExpr*tmp = p[3];
3865 # named_pexpr_t*tmp2 = new named_pexpr_t;
3866 # tmp2->name = lex_strings.make(p[1]);
3867 # tmp2->parm = tmp;
3868 # delete[]p[1];
3869 # p[0] = tmp2;
3870 # }
3871 ()
3872
3873
3874 def p_block_item_decl_1(p):
3875 '''block_item_decl : data_type register_variable_list ';' '''
3876 if(parse_debug):
3877 print('block_item_decl_1', list(p))
3878
3879
3880 # { if (p[1]) pform_set_data_type(@1, p[1], p[2], NetNet::REG, attributes_in_context);
3881 # }
3882 ()
3883
3884
3885 def p_block_item_decl_2(p):
3886 '''block_item_decl : variable_lifetime data_type register_variable_list ';' '''
3887 if(parse_debug):
3888 print('block_item_decl_2', list(p))
3889
3890
3891 # { if (p[2]) pform_set_data_type(@2, p[2], p[3], NetNet::REG, attributes_in_context);
3892 # var_lifetime = LexicalScope::INHERITED;
3893 # }
3894 ()
3895
3896
3897 def p_block_item_decl_3(p):
3898 '''block_item_decl : K_reg data_type register_variable_list ';' '''
3899 if(parse_debug):
3900 print('block_item_decl_3', list(p))
3901
3902
3903 # { if (p[2]) pform_set_data_type(@2, p[2], p[3], NetNet::REG, attributes_in_context);
3904 # }
3905 ()
3906
3907
3908 def p_block_item_decl_4(p):
3909 '''block_item_decl : variable_lifetime K_reg data_type register_variable_list ';' '''
3910 if(parse_debug):
3911 print('block_item_decl_4', list(p))
3912
3913
3914 # { if (p[3]) pform_set_data_type(@3, p[3], p[4], NetNet::REG, attributes_in_context);
3915 # var_lifetime = LexicalScope::INHERITED;
3916 # }
3917 ()
3918
3919
3920 def p_block_item_decl_5(p):
3921 '''block_item_decl : K_event event_variable_list ';' '''
3922 if(parse_debug):
3923 print('block_item_decl_5', list(p))
3924
3925
3926 # { if (p[2]) pform_make_events(p[2], @1.text, @1.first_line);
3927 # }
3928 ()
3929
3930
3931 def p_block_item_decl_6(p):
3932 '''block_item_decl : K_parameter param_type parameter_assign_list ';' '''
3933 if(parse_debug):
3934 print('block_item_decl_6', list(p))
3935
3936
3937 ()
3938
3939
3940 def p_block_item_decl_7(p):
3941 '''block_item_decl : K_localparam param_type localparam_assign_list ';' '''
3942 if(parse_debug):
3943 print('block_item_decl_7', list(p))
3944
3945
3946 ()
3947
3948
3949 def p_block_item_decl_8(p):
3950 '''block_item_decl : type_declaration '''
3951 if(parse_debug):
3952 print('block_item_decl_8', list(p))
3953
3954
3955 ()
3956
3957
3958 def p_block_item_decl_9(p):
3959 '''block_item_decl : K_integer error ';' '''
3960 if(parse_debug):
3961 print('block_item_decl_9', list(p))
3962
3963
3964 # { yyerror(@1, "error: syntax error in integer variable list.");
3965 # yyerrok;
3966 # }
3967 ()
3968
3969
3970 def p_block_item_decl_10(p):
3971 '''block_item_decl : K_time error ';' '''
3972 if(parse_debug):
3973 print('block_item_decl_10', list(p))
3974
3975
3976 # { yyerror(@1, "error: syntax error in time variable list.");
3977 # yyerrok;
3978 # }
3979 ()
3980
3981
3982 def p_block_item_decl_11(p):
3983 '''block_item_decl : K_parameter error ';' '''
3984 if(parse_debug):
3985 print('block_item_decl_11', list(p))
3986
3987
3988 # { yyerror(@1, "error: syntax error in parameter list.");
3989 # yyerrok;
3990 # }
3991 ()
3992
3993
3994 def p_block_item_decl_12(p):
3995 '''block_item_decl : K_localparam error ';' '''
3996 if(parse_debug):
3997 print('block_item_decl_12', list(p))
3998
3999
4000 # { yyerror(@1, "error: syntax error localparam list.");
4001 # yyerrok;
4002 # }
4003 ()
4004
4005
4006 def p_block_item_decls_1(p):
4007 '''block_item_decls : block_item_decl '''
4008 if(parse_debug):
4009 print('block_item_decls_1', list(p))
4010
4011
4012 ()
4013
4014
4015 def p_block_item_decls_2(p):
4016 '''block_item_decls : block_item_decls block_item_decl '''
4017 if(parse_debug):
4018 print('block_item_decls_2', list(p))
4019
4020
4021 ()
4022
4023
4024 def p_block_item_decls_opt_1(p):
4025 '''block_item_decls_opt : block_item_decls '''
4026 if(parse_debug):
4027 print('block_item_decls_opt_1', list(p))
4028 p[0] = True
4029
4030
4031 ()
4032
4033
4034 def p_block_item_decls_opt_2(p):
4035 '''block_item_decls_opt : '''
4036 if(parse_debug):
4037 print('block_item_decls_opt_2', list(p))
4038 p[0] = False
4039
4040
4041 ()
4042
4043
4044 def p_type_declaration_1(p):
4045 '''type_declaration : K_typedef data_type IDENTIFIER dimensions_opt ';' '''
4046 if(parse_debug):
4047 print('type_declaration_1', list(p))
4048
4049
4050 # { perm_string name = lex_strings.make(p[3]);
4051 # pform_set_typedef(name, p[2], p[4]);
4052 # delete[]p[3];
4053 # }
4054 ()
4055
4056
4057 def p_type_declaration_2(p):
4058 '''type_declaration : K_typedef data_type TYPE_IDENTIFIER ';' '''
4059 if(parse_debug):
4060 print('type_declaration_2', list(p))
4061
4062
4063 # { perm_string name = lex_strings.make(p[3].text);
4064 # if (pform_test_type_identifier_local(name)) {
4065 # yyerror(@3, "error: Typedef identifier \"%s\" is already a type name.", p[3].text);
4066 #
4067 # } else {
4068 # pform_set_typedef(name, p[2], NULL);
4069 # }
4070 # delete[]p[3].text;
4071 # }
4072 ()
4073
4074
4075 def p_type_declaration_3(p):
4076 '''type_declaration : K_typedef K_class IDENTIFIER ';' '''
4077 if(parse_debug):
4078 print('type_declaration_3', list(p))
4079
4080
4081 # { // Create a synthetic typedef for the class name so that the
4082 # // lexor detects the name as a type.
4083 # perm_string name = lex_strings.make(p[3]);
4084 # class_type_t*tmp = new class_type_t(name);
4085 # FILE_NAME(tmp, @3);
4086 # pform_set_typedef(name, tmp, NULL);
4087 # delete[]p[3];
4088 # }
4089 ()
4090
4091
4092 def p_type_declaration_4(p):
4093 '''type_declaration : K_typedef K_enum IDENTIFIER ';' '''
4094 if(parse_debug):
4095 print('type_declaration_4', list(p))
4096
4097
4098 # { yyerror(@1, "sorry: Enum forward declarations not supported yet."); }
4099 ()
4100
4101
4102 def p_type_declaration_5(p):
4103 '''type_declaration : K_typedef K_struct IDENTIFIER ';' '''
4104 if(parse_debug):
4105 print('type_declaration_5', list(p))
4106
4107
4108 # { yyerror(@1, "sorry: Struct forward declarations not supported yet."); }
4109 ()
4110
4111
4112 def p_type_declaration_6(p):
4113 '''type_declaration : K_typedef K_union IDENTIFIER ';' '''
4114 if(parse_debug):
4115 print('type_declaration_6', list(p))
4116
4117
4118 # { yyerror(@1, "sorry: Union forward declarations not supported yet."); }
4119 ()
4120
4121
4122 def p_type_declaration_7(p):
4123 '''type_declaration : K_typedef IDENTIFIER ';' '''
4124 if(parse_debug):
4125 print('type_declaration_7', list(p))
4126
4127
4128 # { // Create a synthetic typedef for the class name so that the
4129 # // lexor detects the name as a type.
4130 # perm_string name = lex_strings.make(p[2]);
4131 # class_type_t*tmp = new class_type_t(name);
4132 # FILE_NAME(tmp, @2);
4133 # pform_set_typedef(name, tmp, NULL);
4134 # delete[]p[2];
4135 # }
4136 ()
4137
4138
4139 def p_type_declaration_8(p):
4140 '''type_declaration : K_typedef error ';' '''
4141 if(parse_debug):
4142 print('type_declaration_8', list(p))
4143
4144
4145 # { yyerror(@2, "error: Syntax error in typedef clause.");
4146 # yyerrok;
4147 # }
4148 ()
4149
4150
4151 def p_enum_data_type_1(p):
4152 '''enum_data_type : K_enum '{' enum_name_list '}' '''
4153 if(parse_debug):
4154 print('enum_data_type_1', list(p))
4155
4156
4157 # { enum_type_t*enum_type = new enum_type_t;
4158 # FILE_NAME(enum_type, @1);
4159 # enum_type->names .reset(p[3]);
4160 # enum_type->base_type = IVL_VT_BOOL;
4161 # enum_type->signed_flag = true;
4162 # enum_type->integer_flag = false;
4163 # enum_type->range.reset(make_range_from_width(32));
4164 # p[0] = enum_type;
4165 # }
4166 ()
4167
4168
4169 def p_enum_data_type_2(p):
4170 '''enum_data_type : K_enum atom2_type signed_unsigned_opt '{' enum_name_list '}' '''
4171 if(parse_debug):
4172 print('enum_data_type_2', list(p))
4173
4174
4175 # { enum_type_t*enum_type = new enum_type_t;
4176 # FILE_NAME(enum_type, @1);
4177 # enum_type->names .reset(p[5]);
4178 # enum_type->base_type = IVL_VT_BOOL;
4179 # enum_type->signed_flag = p[3];
4180 # enum_type->integer_flag = false;
4181 # enum_type->range.reset(make_range_from_width(p[2]));
4182 # p[0] = enum_type;
4183 # }
4184 ()
4185
4186
4187 def p_enum_data_type_3(p):
4188 '''enum_data_type : K_enum K_integer signed_unsigned_opt '{' enum_name_list '}' '''
4189 if(parse_debug):
4190 print('enum_data_type_3', list(p))
4191
4192
4193 # { enum_type_t*enum_type = new enum_type_t;
4194 # FILE_NAME(enum_type, @1);
4195 # enum_type->names .reset(p[5]);
4196 # enum_type->base_type = IVL_VT_LOGIC;
4197 # enum_type->signed_flag = p[3];
4198 # enum_type->integer_flag = true;
4199 # enum_type->range.reset(make_range_from_width(integer_width));
4200 # p[0] = enum_type;
4201 # }
4202 ()
4203
4204
4205 def p_enum_data_type_4(p):
4206 '''enum_data_type : K_enum K_logic unsigned_signed_opt dimensions_opt '{' enum_name_list '}' '''
4207 if(parse_debug):
4208 print('enum_data_type_4', list(p))
4209
4210
4211 # { enum_type_t*enum_type = new enum_type_t;
4212 # FILE_NAME(enum_type, @1);
4213 # enum_type->names .reset(p[6]);
4214 # enum_type->base_type = IVL_VT_LOGIC;
4215 # enum_type->signed_flag = p[3];
4216 # enum_type->integer_flag = false;
4217 # enum_type->range.reset(p[4] ? p[4] : make_range_from_width(1));
4218 # p[0] = enum_type;
4219 # }
4220 ()
4221
4222
4223 def p_enum_data_type_5(p):
4224 '''enum_data_type : K_enum K_reg unsigned_signed_opt dimensions_opt '{' enum_name_list '}' '''
4225 if(parse_debug):
4226 print('enum_data_type_5', list(p))
4227
4228
4229 # { enum_type_t*enum_type = new enum_type_t;
4230 # FILE_NAME(enum_type, @1);
4231 # enum_type->names .reset(p[6]);
4232 # enum_type->base_type = IVL_VT_LOGIC;
4233 # enum_type->signed_flag = p[3];
4234 # enum_type->integer_flag = false;
4235 # enum_type->range.reset(p[4] ? p[4] : make_range_from_width(1));
4236 # p[0] = enum_type;
4237 # }
4238 ()
4239
4240
4241 def p_enum_data_type_6(p):
4242 '''enum_data_type : K_enum K_bit unsigned_signed_opt dimensions_opt '{' enum_name_list '}' '''
4243 if(parse_debug):
4244 print('enum_data_type_6', list(p))
4245
4246
4247 # { enum_type_t*enum_type = new enum_type_t;
4248 # FILE_NAME(enum_type, @1);
4249 # enum_type->names .reset(p[6]);
4250 # enum_type->base_type = IVL_VT_BOOL;
4251 # enum_type->signed_flag = p[3];
4252 # enum_type->integer_flag = false;
4253 # enum_type->range.reset(p[4] ? p[4] : make_range_from_width(1));
4254 # p[0] = enum_type;
4255 # }
4256 ()
4257
4258
4259 def p_enum_name_list_1(p):
4260 '''enum_name_list : enum_name '''
4261 if(parse_debug):
4262 print('enum_name_list_1', list(p))
4263
4264
4265 # { p[0] = p[1];
4266 # }
4267 ()
4268
4269
4270 def p_enum_name_list_2(p):
4271 '''enum_name_list : enum_name_list ',' enum_name '''
4272 if(parse_debug):
4273 print('enum_name_list_2', list(p))
4274
4275
4276 # { list<named_pexpr_t>*lst = p[1];
4277 # lst->splice(lst->end(), *p[3]);
4278 # delete p[3];
4279 # p[0] = lst;
4280 # }
4281 ()
4282
4283
4284 def p_pos_neg_number_1(p):
4285 '''pos_neg_number : number '''
4286 if(parse_debug):
4287 print('pos_neg_number_1', list(p))
4288
4289
4290 # { p[0] = p[1];
4291 # }
4292 ()
4293
4294
4295 def p_pos_neg_number_2(p):
4296 '''pos_neg_number : '-' number '''
4297 if(parse_debug):
4298 print('pos_neg_number_2', list(p))
4299
4300
4301 # { verinum tmp = -(*(p[2]));
4302 # *(p[2]) = tmp;
4303 # p[0] = p[2];
4304 # }
4305 ()
4306
4307
4308 def p_enum_name_1(p):
4309 '''enum_name : IDENTIFIER '''
4310 if(parse_debug):
4311 print('enum_name_1', list(p))
4312
4313
4314 # { perm_string name = lex_strings.make(p[1]);
4315 # delete[]p[1];
4316 # p[0] = make_named_number(name);
4317 # }
4318 ()
4319
4320
4321 def p_enum_name_2(p):
4322 '''enum_name : IDENTIFIER '[' pos_neg_number ']' '''
4323 if(parse_debug):
4324 print('enum_name_2', list(p))
4325
4326
4327 # { perm_string name = lex_strings.make(p[1]);
4328 # long count = check_enum_seq_value(@1, p[3], false);
4329 # delete[]p[1];
4330 # p[0] = make_named_numbers(name, 0, count-1);
4331 # delete p[3];
4332 # }
4333 ()
4334
4335
4336 def p_enum_name_3(p):
4337 '''enum_name : IDENTIFIER '[' pos_neg_number ':' pos_neg_number ']' '''
4338 if(parse_debug):
4339 print('enum_name_3', list(p))
4340
4341
4342 # { perm_string name = lex_strings.make(p[1]);
4343 # p[0] = make_named_numbers(name, check_enum_seq_value(@1, p[3], true),
4344 # check_enum_seq_value(@1, p[5], true));
4345 # delete[]p[1];
4346 # delete p[3];
4347 # delete p[5];
4348 # }
4349 ()
4350
4351
4352 def p_enum_name_4(p):
4353 '''enum_name : IDENTIFIER '=' expression '''
4354 if(parse_debug):
4355 print('enum_name_4', list(p))
4356
4357
4358 # { perm_string name = lex_strings.make(p[1]);
4359 # delete[]p[1];
4360 # p[0] = make_named_number(name, p[3]);
4361 # }
4362 ()
4363
4364
4365 def p_enum_name_5(p):
4366 '''enum_name : IDENTIFIER '[' pos_neg_number ']' '=' expression '''
4367 if(parse_debug):
4368 print('enum_name_5', list(p))
4369
4370
4371 # { perm_string name = lex_strings.make(p[1]);
4372 # long count = check_enum_seq_value(@1, p[3], false);
4373 # p[0] = make_named_numbers(name, 0, count-1, p[6]);
4374 # delete[]p[1];
4375 # delete p[3];
4376 # }
4377 ()
4378
4379
4380 def p_enum_name_6(p):
4381 '''enum_name : IDENTIFIER '[' pos_neg_number ':' pos_neg_number ']' '=' expression '''
4382 if(parse_debug):
4383 print('enum_name_6', list(p))
4384
4385
4386 # { perm_string name = lex_strings.make(p[1]);
4387 # p[0] = make_named_numbers(name, check_enum_seq_value(@1, p[3], true),
4388 # check_enum_seq_value(@1, p[5], true), p[8]);
4389 # delete[]p[1];
4390 # delete p[3];
4391 # delete p[5];
4392 # }
4393 ()
4394
4395
4396 def p_struct_data_type_1(p):
4397 '''struct_data_type : K_struct K_packed_opt '{' struct_union_member_list '}' '''
4398 if(parse_debug):
4399 print('struct_data_type_1', list(p))
4400
4401
4402 # { struct_type_t*tmp = new struct_type_t;
4403 # FILE_NAME(tmp, @1);
4404 # tmp->packed_flag = p[2];
4405 # tmp->union_flag = false;
4406 # tmp->members .reset(p[4]);
4407 # p[0] = tmp;
4408 # }
4409 ()
4410
4411
4412 def p_struct_data_type_2(p):
4413 '''struct_data_type : K_union K_packed_opt '{' struct_union_member_list '}' '''
4414 if(parse_debug):
4415 print('struct_data_type_2', list(p))
4416
4417
4418 # { struct_type_t*tmp = new struct_type_t;
4419 # FILE_NAME(tmp, @1);
4420 # tmp->packed_flag = p[2];
4421 # tmp->union_flag = true;
4422 # tmp->members .reset(p[4]);
4423 # p[0] = tmp;
4424 # }
4425 ()
4426
4427
4428 def p_struct_data_type_3(p):
4429 '''struct_data_type : K_struct K_packed_opt '{' error '}' '''
4430 if(parse_debug):
4431 print('struct_data_type_3', list(p))
4432
4433
4434 # { yyerror(@3, "error: Errors in struct member list.");
4435 # yyerrok;
4436 # struct_type_t*tmp = new struct_type_t;
4437 # FILE_NAME(tmp, @1);
4438 # tmp->packed_flag = p[2];
4439 # tmp->union_flag = false;
4440 # p[0] = tmp;
4441 # }
4442 ()
4443
4444
4445 def p_struct_data_type_4(p):
4446 '''struct_data_type : K_union K_packed_opt '{' error '}' '''
4447 if(parse_debug):
4448 print('struct_data_type_4', list(p))
4449
4450
4451 # { yyerror(@3, "error: Errors in union member list.");
4452 # yyerrok;
4453 # struct_type_t*tmp = new struct_type_t;
4454 # FILE_NAME(tmp, @1);
4455 # tmp->packed_flag = p[2];
4456 # tmp->union_flag = true;
4457 # p[0] = tmp;
4458 # }
4459 ()
4460
4461
4462 def p_struct_union_member_list_1(p):
4463 '''struct_union_member_list : struct_union_member_list struct_union_member '''
4464 if(parse_debug):
4465 print('struct_union_member_list_1', list(p))
4466
4467
4468 # { list<struct_member_t*>*tmp = p[1];
4469 # tmp->push_back(p[2]);
4470 # p[0] = tmp;
4471 # }
4472 ()
4473
4474
4475 def p_struct_union_member_list_2(p):
4476 '''struct_union_member_list : struct_union_member '''
4477 if(parse_debug):
4478 print('struct_union_member_list_2', list(p))
4479
4480
4481 # { list<struct_member_t*>*tmp = new list<struct_member_t*>;
4482 # tmp->push_back(p[1]);
4483 # p[0] = tmp;
4484 # }
4485 ()
4486
4487
4488 def p_struct_union_member_1(p):
4489 '''struct_union_member : attribute_list_opt data_type list_of_variable_decl_assignments ';' '''
4490 if(parse_debug):
4491 print('struct_union_member_1', list(p))
4492
4493
4494 # { struct_member_t*tmp = new struct_member_t;
4495 # FILE_NAME(tmp, @2);
4496 # tmp->type .reset(p[2]);
4497 # tmp->names .reset(p[3]);
4498 # p[0] = tmp;
4499 # }
4500 ()
4501
4502
4503 def p_struct_union_member_2(p):
4504 '''struct_union_member : error ';' '''
4505 if(parse_debug):
4506 print('struct_union_member_2', list(p))
4507
4508
4509 # { yyerror(@2, "Error in struct/union member.");
4510 # yyerrok;
4511 # p[0] = None
4512 # }
4513 ()
4514
4515
4516 def p_case_item_1(p):
4517 '''case_item : expression_list_proper ':' statement_or_null '''
4518 if(parse_debug):
4519 print('case_item_1', list(p))
4520
4521
4522 # { PCase::Item*tmp = new PCase::Item;
4523 # tmp->expr = *p[1];
4524 # tmp->stat = p[3];
4525 # delete p[1];
4526 # p[0] = tmp;
4527 # }
4528 ()
4529
4530
4531 def p_case_item_2(p):
4532 '''case_item : K_default ':' statement_or_null '''
4533 if(parse_debug):
4534 print('case_item_2', list(p))
4535
4536
4537 # { PCase::Item*tmp = new PCase::Item;
4538 # tmp->stat = p[3];
4539 # p[0] = tmp;
4540 # }
4541 ()
4542
4543
4544 def p_case_item_3(p):
4545 '''case_item : K_default statement_or_null '''
4546 if(parse_debug):
4547 print('case_item_3', list(p))
4548
4549
4550 # { PCase::Item*tmp = new PCase::Item;
4551 # tmp->stat = p[2];
4552 # p[0] = tmp;
4553 # }
4554 ()
4555
4556
4557 def p_case_item_4(p):
4558 '''case_item : error ':' statement_or_null '''
4559 if(parse_debug):
4560 print('case_item_4', list(p))
4561
4562
4563 # { yyerror(@2, "error: Incomprehensible case expression.");
4564 # yyerrok;
4565 # }
4566 ()
4567
4568
4569 def p_case_items_1(p):
4570 '''case_items : case_items case_item '''
4571 if(parse_debug):
4572 print('case_items_1', list(p))
4573
4574
4575 # { svector<PCase::Item*>*tmp;
4576 # tmp = new svector<PCase::Item*>(*p[1], p[2]);
4577 # delete p[1];