e7b86cf3ce8392d9f0bfdf1f8effe73a967e458a
3 # * Copyright (c) 1998-2017 Stephen Williams (steve@icarus.com)
4 # * Copyright CERN 2012-2013 / Stephen Williams (steve@icarus.com)
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.
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.
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.
22 # # include "config.h"
24 # # include "parse_misc.h"
25 # # include "compiler.h"
27 # # include "Statement.h"
35 # extern void lex_end_table();
37 # static list<pform_range_t>* param_active_range = 0;
38 # static bool param_active_signed = false;
39 # static ivl_variable_type_t param_active_type = IVL_VT_LOGIC;
41 # /* Port declaration lists use this structure for context. */
43 # NetNet::Type port_net_type;
44 # NetNet::PortType port_type;
45 # data_type_t* data_type;
46 # } port_declaration_context = {NetNet::NONE, NetNet::NOT_A_PORT, 0};
48 # /* Modport port declaration lists use this structure for context. */
49 # enum modport_port_type_t { MP_NONE, MP_SIMPLE, MP_TF, MP_CLOCKING };
51 # modport_port_type_t type;
53 # NetNet::PortType direction;
56 # } last_modport_port = { MP_NONE, {NetNet::NOT_A_PORT}};
58 # /* The task and function rules need to briefly hold the pointer to the
59 # task/function that is currently in progress. */
60 # static PTask* current_task = 0;
61 # static PFunction* current_function = 0;
62 # static stack<PBlock*> current_block_stack;
64 # /* The variable declaration rules need to know if a lifetime has been
66 # static LexicalScope::lifetime_t var_lifetime;
68 # static pform_name_t* pform_create_this(void)
70 # name_component_t name (perm_string::literal("@"));
71 # pform_name_t*res = new pform_name_t;
72 # res->push_back(name);
76 # static pform_name_t* pform_create_super(void)
78 # name_component_t name (perm_string::literal("#"));
79 # pform_name_t*res = new pform_name_t;
80 # res->push_back(name);
84 # /* This is used to keep track of the extra arguments after the notifier
85 # * in the $setuphold and $recrem timing checks. This allows us to print
86 # * a warning message that the delayed signals will not be created. We
87 # * need to do this since not driving these signals creates real
88 # * simulation issues. */
89 # static unsigned args_after_notifier;
91 # /* The rules sometimes push attributes into a global context where
92 # sub-rules may grab them. This makes parser rules a little easier to
93 # write in some cases. */
94 # static list<named_pexpr_t>*attributes_in_context = 0;
96 # /* Later version of bison (including 1.35) will not compile in stack
97 # extension if the output is compiled with C++ and either the YYSTYPE
98 # or YYLTYPE are provided by the source code. However, I can get the
99 # old behavior back by defining these symbols. */
100 # # define YYSTYPE_IS_TRIVIAL 1
101 # # define YYLTYPE_IS_TRIVIAL 1
103 # /* Recent version of bison expect that the user supply a
104 # YYLLOC_DEFAULT macro that makes up a yylloc value from existing
105 # values. I need to supply an explicit version to account for the
106 # text field, that otherwise won't be copied.
108 # The YYLLOC_DEFAULT blends the file range for the tokens of Rhs
109 # rule, which has N tokens.
111 # # define YYLLOC_DEFAULT(Current, Rhs, N) do { \
113 # (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
114 # (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
115 # (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
116 # (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
117 # (Current).text = YYRHSLOC (Rhs, 1).text; \
119 # (Current).first_line = YYRHSLOC (Rhs, 0).last_line; \
120 # (Current).first_column = YYRHSLOC (Rhs, 0).last_column; \
121 # (Current).last_line = YYRHSLOC (Rhs, 0).last_line; \
122 # (Current).last_column = YYRHSLOC (Rhs, 0).last_column; \
123 # (Current).text = YYRHSLOC (Rhs, 0).text; \
128 # * These are some common strength pairs that are used as defaults when
129 # * the user is not otherwise specific.
131 # static const struct str_pair_t pull_strength = { IVL_DR_PULL, IVL_DR_PULL };
132 # static const struct str_pair_t str_strength = { IVL_DR_STRONG, IVL_DR_STRONG };
134 # static list<pform_port_t>* make_port_list(char*id, list<pform_range_t>*udims, PExpr*expr)
136 # list<pform_port_t>*tmp = new list<pform_port_t>;
137 # tmp->push_back(pform_port_t(lex_strings.make(id), udims, expr));
141 # static list<pform_port_t>* make_port_list(list<pform_port_t>*tmp,
142 # char*id, list<pform_range_t>*udims, PExpr*expr)
144 # tmp->push_back(pform_port_t(lex_strings.make(id), udims, expr));
149 # list<pform_range_t>* make_range_from_width(uint64_t wid)
151 # pform_range_t range;
152 # range.first = new PENumber(new verinum(wid-1, integer_width));
153 # range.second = new PENumber(new verinum((uint64_t)0, integer_width));
155 # list<pform_range_t>*rlist = new list<pform_range_t>;
156 # rlist->push_back(range);
160 # static list<perm_string>* list_from_identifier(char*id)
162 # list<perm_string>*tmp = new list<perm_string>;
163 # tmp->push_back(lex_strings.make(id));
168 # static list<perm_string>* list_from_identifier(list<perm_string>*tmp, char*id)
170 # tmp->push_back(lex_strings.make(id));
175 # list<pform_range_t>* copy_range(list<pform_range_t>* orig)
177 # list<pform_range_t>*copy = 0;
180 # copy = new list<pform_range_t> (*orig);
185 # template <class T> void append(vector<T>&out, const vector<T>&in)
187 # for (size_t idx = 0 ; idx < in.size() ; idx += 1)
188 # out.push_back(in[idx]);
192 # * Look at the list and pull null pointers off the end.
194 # static void strip_tail_items(list<PExpr*>*lst)
196 # while (! lst->empty()) {
197 # if (lst->back() != 0)
204 # * This is a shorthand for making a PECallFunction that takes a single
205 # * arg. This is used by some of the code that detects built-ins.
207 # static PECallFunction*make_call_function(perm_string tn, PExpr*arg)
209 # vector<PExpr*> parms(1);
211 # PECallFunction*tmp = new PECallFunction(tn, parms);
215 # static PECallFunction*make_call_function(perm_string tn, PExpr*arg1, PExpr*arg2)
217 # vector<PExpr*> parms(2);
220 # PECallFunction*tmp = new PECallFunction(tn, parms);
224 # static list<named_pexpr_t>* make_named_numbers(perm_string name, long first, long last, PExpr*val =0)
226 # list<named_pexpr_t>*lst = new list<named_pexpr_t>;
228 # // We are counting up.
229 # if (first <= last) {
230 # for (long idx = first ; idx <= last ; idx += 1) {
232 # buf << name.str() << idx << ends;
233 # tmp.name = lex_strings.make(buf.str());
236 # lst->push_back(tmp);
238 # // We are counting down.
240 # for (long idx = first ; idx >= last ; idx -= 1) {
242 # buf << name.str() << idx << ends;
243 # tmp.name = lex_strings.make(buf.str());
246 # lst->push_back(tmp);
252 # static list<named_pexpr_t>* make_named_number(perm_string name, PExpr*val =0)
254 # list<named_pexpr_t>*lst = new list<named_pexpr_t>;
258 # lst->push_back(tmp);
262 # static long check_enum_seq_value(const YYLTYPE&loc, verinum *arg, bool zero_ok)
265 # // We can never have an undefined value in an enumeration name
266 # // declaration sequence.
267 # if (! arg->is_defined()) {
268 # yyerror(loc, "error: undefined value used in enum name sequence.");
269 # // We can never have a negative value in an enumeration name
270 # // declaration sequence.
271 # } else if (arg->is_negative()) {
272 # yyerror(loc, "error: negative value used in enum name sequence.");
274 # value = arg->as_ulong();
275 # // We cannot have a zero enumeration name declaration count.
276 # if (! zero_ok && (value == 0)) {
277 # yyerror(loc, "error: zero count used in enum name sequence.");
284 # static void current_task_set_statement(const YYLTYPE&loc, vector<Statement*>*s)
287 # /* if the statement list is null, then the parser
288 # detected the case that there are no statements in the
289 # task. If this is SystemVerilog, handle it as an
291 # if (!gn_system_verilog()) {
292 # yyerror(loc, "error: Support for empty tasks requires SystemVerilog.");
294 # PBlock*tmp = new PBlock(PBlock::BL_SEQ);
295 # FILE_NAME(tmp, loc);
296 # current_task->set_statement(tmp);
301 # /* An empty vector represents one or more null statements. Handle
302 # this as a simple null statement. */
306 # /* A vector of 1 is handled as a simple statement. */
307 # if (s->size() == 1) {
308 # current_task->set_statement((*s)[0]);
312 # if (!gn_system_verilog()) {
313 # yyerror(loc, "error: Task body with multiple statements requires SystemVerilog.");
316 # PBlock*tmp = new PBlock(PBlock::BL_SEQ);
317 # FILE_NAME(tmp, loc);
318 # tmp->set_statement(*s);
319 # current_task->set_statement(tmp);
322 # static void current_function_set_statement(const YYLTYPE&loc, vector<Statement*>*s)
325 # /* if the statement list is null, then the parser
326 # detected the case that there are no statements in the
327 # task. If this is SystemVerilog, handle it as an
329 # if (!gn_system_verilog()) {
330 # yyerror(loc, "error: Support for empty functions requires SystemVerilog.");
332 # PBlock*tmp = new PBlock(PBlock::BL_SEQ);
333 # FILE_NAME(tmp, loc);
334 # current_function->set_statement(tmp);
339 # /* An empty vector represents one or more null statements. Handle
340 # this as a simple null statement. */
344 # /* A vector of 1 is handled as a simple statement. */
345 # if (s->size() == 1) {
346 # current_function->set_statement((*s)[0]);
350 # if (!gn_system_verilog()) {
351 # yyerror(loc, "error: Function body with multiple statements requires SystemVerilog.");
354 # PBlock*tmp = new PBlock(PBlock::BL_SEQ);
355 # FILE_NAME(tmp, loc);
356 # tmp->set_statement(*s);
357 # current_function->set_statement(tmp);
361 ('tokens = ', "['IDENTIFIER', 'SYSTEM_IDENTIFIER', 'STRING', 'TIME_LITERAL', 'TYPE_IDENTIFIER', 'PACKAGE_IDENTIFIER', 'DISCIPLINE_IDENTIFIER', 'PATHPULSE_IDENTIFIER', 'BASED_NUMBER', 'DEC_NUMBER', 'UNBASED_NUMBER', 'REALTIME', 'K_PLUS_EQ', 'K_MINUS_EQ', 'K_INCR', 'K_DECR', 'K_LE', 'K_GE', 'K_EG', 'K_EQ', 'K_NE', 'K_CEQ', 'K_CNE', 'K_WEQ', 'K_WNE', 'K_LP', 'K_LS', 'K_RS', 'K_RSS', 'K_SG', 'K_CONTRIBUTE', 'K_PO_POS', 'K_PO_NEG', 'K_POW', 'K_PSTAR', 'K_STARP', 'K_DOTSTAR', 'K_LOR', 'K_LAND', 'K_NAND', 'K_NOR', 'K_NXOR', 'K_TRIGGER', 'K_SCOPE_RES', 'K_edge_descriptor', 'K_always', 'K_and', 'K_assign', 'K_begin', 'K_buf', 'K_bufif0', 'K_bufif1', 'K_case', 'K_casex', 'K_casez', 'K_cmos', 'K_deassign', 'K_default', 'K_defparam', 'K_disable', 'K_edge', 'K_else', 'K_end', 'K_endcase', 'K_endfunction', 'K_endmodule', 'K_endprimitive', 'K_endspecify', 'K_endtable', 'K_endtask', 'K_event', 'K_for', 'K_force', 'K_forever', 'K_fork', 'K_function', 'K_highz0', 'K_highz1', 'K_if', 'K_ifnone', 'K_initial', 'K_inout', 'K_input', 'K_integer', 'K_join', 'K_large', 'K_macromodule', 'K_medium', 'K_module', 'K_nand', 'K_negedge', 'K_nmos', 'K_nor', 'K_not', 'K_notif0', 'K_notif1', 'K_or', 'K_output', 'K_parameter', 'K_pmos', 'K_posedge', 'K_primitive', 'K_pull0', 'K_pull1', 'K_pulldown', 'K_pullup', 'K_rcmos', 'K_real', 'K_realtime', 'K_reg', 'K_release', 'K_repeat', 'K_rnmos', 'K_rpmos', 'K_rtran', 'K_rtranif0', 'K_rtranif1', 'K_scalared', 'K_small', 'K_specify', 'K_specparam', 'K_strong0', 'K_strong1', 'K_supply0', 'K_supply1', 'K_table', 'K_task', 'K_time', 'K_tran', 'K_tranif0', 'K_tranif1', 'K_tri', 'K_tri0', 'K_tri1', 'K_triand', 'K_trior', 'K_trireg', 'K_vectored', 'K_wait', 'K_wand', 'K_weak0', 'K_weak1', 'K_while', 'K_wire', 'K_wor', 'K_xnor', 'K_xor', 'K_Shold', 'K_Snochange', 'K_Speriod', 'K_Srecovery', 'K_Ssetup', 'K_Ssetuphold', 'K_Sskew', 'K_Swidth', 'KK_attribute', 'K_bool', 'K_logic', 'K_automatic', 'K_endgenerate', 'K_generate', 'K_genvar', 'K_localparam', 'K_noshowcancelled', 'K_pulsestyle_onevent', 'K_pulsestyle_ondetect', 'K_showcancelled', 'K_signed', 'K_unsigned', 'K_Sfullskew', 'K_Srecrem', 'K_Sremoval', 'K_Stimeskew', 'K_cell', 'K_config', 'K_design', 'K_endconfig', 'K_incdir', 'K_include', 'K_instance', 'K_liblist', 'K_library', 'K_use', 'K_wone', 'K_uwire', 'K_alias', 'K_always_comb', 'K_always_ff', 'K_always_latch', 'K_assert', 'K_assume', 'K_before', 'K_bind', 'K_bins', 'K_binsof', 'K_bit', 'K_break', 'K_byte', 'K_chandle', 'K_class', 'K_clocking', 'K_const', 'K_constraint', 'K_context', 'K_continue', 'K_cover', 'K_covergroup', 'K_coverpoint', 'K_cross', 'K_dist', 'K_do', 'K_endclass', 'K_endclocking', 'K_endgroup', 'K_endinterface', 'K_endpackage', 'K_endprogram', 'K_endproperty', 'K_endsequence', 'K_enum', 'K_expect', 'K_export', 'K_extends', 'K_extern', 'K_final', 'K_first_match', 'K_foreach', 'K_forkjoin', 'K_iff', 'K_ignore_bins', 'K_illegal_bins', 'K_import', 'K_inside', 'K_int', 'K_interface', 'K_intersect', 'K_join_any', 'K_join_none', 'K_local', 'K_longint', 'K_matches', 'K_modport', 'K_new', 'K_null', 'K_package', 'K_packed', 'K_priority', 'K_program', 'K_property', 'K_protected', 'K_pure', 'K_rand', 'K_randc', 'K_randcase', 'K_randsequence', 'K_ref', 'K_return', 'K_sequence', 'K_shortint', 'K_shortreal', 'K_solve', 'K_static', 'K_string', 'K_struct', 'K_super', 'K_tagged', 'K_this', 'K_throughout', 'K_timeprecision', 'K_timeunit', 'K_type', 'K_typedef', 'K_union', 'K_unique', 'K_var', 'K_virtual', 'K_void', 'K_wait_order', 'K_wildcard', 'K_with', 'K_within', 'K_accept_on', 'K_checker', 'K_endchecker', 'K_eventually', 'K_global', 'K_implies', 'K_let', 'K_nexttime', 'K_reject_on', 'K_restrict', 'K_s_always', 'K_s_eventually', 'K_s_nexttime', 'K_s_until', 'K_s_until_with', 'K_strong', 'K_sync_accept_on', 'K_sync_reject_on', 'K_unique0', 'K_until', 'K_until_with', 'K_untyped', 'K_weak', 'K_implements', 'K_interconnect', 'K_nettype', 'K_soft', 'K_above', 'K_abs', 'K_absdelay', 'K_abstol', 'K_access', 'K_acos', 'K_acosh', 'K_ac_stim', 'K_aliasparam', 'K_analog', 'K_analysis', 'K_asin', 'K_asinh', 'K_atan', 'K_atan2', 'K_atanh', 'K_branch', 'K_ceil', 'K_connect', 'K_connectmodule', 'K_connectrules', 'K_continuous', 'K_cos', 'K_cosh', 'K_ddt', 'K_ddt_nature', 'K_ddx', 'K_discipline', 'K_discrete', 'K_domain', 'K_driver_update', 'K_endconnectrules', 'K_enddiscipline', 'K_endnature', 'K_endparamset', 'K_exclude', 'K_exp', 'K_final_step', 'K_flicker_noise', 'K_floor', 'K_flow', 'K_from', 'K_ground', 'K_hypot', 'K_idt', 'K_idtmod', 'K_idt_nature', 'K_inf', 'K_initial_step', 'K_laplace_nd', 'K_laplace_np', 'K_laplace_zd', 'K_laplace_zp', 'K_last_crossing', 'K_limexp', 'K_ln', 'K_log', 'K_max', 'K_merged', 'K_min', 'K_nature', 'K_net_resolution', 'K_noise_table', 'K_paramset', 'K_potential', 'K_pow', 'K_resolveto', 'K_sin', 'K_sinh', 'K_slew', 'K_split', 'K_sqrt', 'K_tan', 'K_tanh', 'K_timer', 'K_transition', 'K_units', 'K_white_noise', 'K_wreal', 'K_zi_nd', 'K_zi_np', 'K_zi_zd', 'K_zi_zp', 'K_TAND', 'K_PLUS_EQ', 'K_MINUS_EQ', 'K_MUL_EQ', 'K_DIV_EQ', 'K_MOD_EQ', 'K_AND_EQ', 'K_OR_EQ', 'K_XOR_EQ', 'K_LS_EQ', 'K_RS_EQ', 'K_RSS_EQ', 'K_inside', 'K_LOR', 'K_LAND', 'K_NXOR', 'K_NOR', 'K_NAND', 'K_EQ', 'K_NE', 'K_CEQ', 'K_CNE', 'K_WEQ', 'K_WNE', 'K_GE', 'K_LE', 'K_LS', 'K_RS', 'K_RSS', 'K_POW', 'UNARY_PREC', 'less_than_K_else', 'K_else', 'K_exclude', 'no_timeunits_declaration', 'one_timeunits_declaration', 'K_timeunit', 'K_timeprecision']")
363 ('precedence = ', '[(\'right\', \'K_PLUS_EQ\', \'K_MINUS_EQ\', \'K_MUL_EQ\', \'K_DIV_EQ\', \'K_MOD_EQ\', \'K_AND_EQ\', \'K_OR_EQ\'), (\'right\', \'K_XOR_EQ\', \'K_LS_EQ\', \'K_RS_EQ\', \'K_RSS_EQ\'), (\'right\', "\'?\'", "\':\'", \'K_inside\'), (\'left\', \'K_LOR\'), (\'left\', \'K_LAND\'), (\'left\', "\'|\'"), (\'left\', "\'^\'", \'K_NXOR\', \'K_NOR\'), (\'left\', "\'&\'", \'K_NAND\'), (\'left\', \'K_EQ\', \'K_NE\', \'K_CEQ\', \'K_CNE\', \'K_WEQ\', \'K_WNE\'), (\'left\', \'K_GE\', \'K_LE\', "\'<\'", "\'>\'"), (\'left\', \'K_LS\', \'K_RS\', \'K_RSS\'), (\'left\', "\'+\'", "\'-\'"), (\'left\', "\'*\'", "\'/\'", "\'%\'"), (\'left\', \'K_POW\'), (\'left\', \'UNARY_PREC\'), (\'nonassoc\', \'less_than_K_else\'), (\'nonassoc\', \'K_else\'), (\'nonassoc\', "\'(\'"), (\'nonassoc\', \'K_exclude\'), (\'nonassoc\', \'no_timeunits_declaration\'), (\'nonassoc\', \'one_timeunits_declaration\'), (\'nonassoc\', \'K_timeunit\', \'K_timeprecision\')]')
365 # -------------- RULES ----------------
367 def p_source_text_1(p
):
368 '''source_text : timeunits_declaration_opt _embed0_source_text description_list '''
371 def p_source_text_2(p
):
375 def p__embed0_source_text(p
):
376 '''_embed0_source_text : '''
377 # { pform_set_scope_timescale(yyloc); }
379 def p_assertion_item_1(p
):
380 '''assertion_item : concurrent_assertion_item '''
383 def p_assignment_pattern_1(p
):
384 '''assignment_pattern : K_LP expression_list_proper '}' '''
386 # { PEAssignPattern*tmp = new PEAssignPattern(*$2);
387 # FILE_NAME(tmp, @1);
392 def p_assignment_pattern_2(p
):
393 '''assignment_pattern : K_LP '}' '''
395 # { PEAssignPattern*tmp = new PEAssignPattern;
396 # FILE_NAME(tmp, @1);
400 def p_block_identifier_opt_1(p
):
401 '''block_identifier_opt : IDENTIFIER ':' '''
404 def p_block_identifier_opt_2(p
):
405 '''block_identifier_opt : '''
408 def p_class_declaration_1(p
):
409 '''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 '''
411 # { // Wrap up the class.
412 # if ($11 && $4 && $4->name != $11) {
413 # yyerror(@11, "error: Class end label doesn't match class name.");
418 def p__embed0_class_declaration(p
):
419 '''_embed0_class_declaration : '''
420 # { pform_start_class_declaration(@2, $4, $5.type, $5.exprs, $3); }
422 def p__embed1_class_declaration(p
):
423 '''_embed1_class_declaration : '''
424 # { // Process a class.
425 # pform_end_class_declaration(@9);
428 def p_class_constraint_1(p
):
429 '''class_constraint : constraint_prototype '''
432 def p_class_constraint_2(p
):
433 '''class_constraint : constraint_declaration '''
436 def p_class_identifier_1(p
):
437 '''class_identifier : IDENTIFIER '''
439 # { // Create a synthetic typedef for the class name so that the
440 # // lexor detects the name as a type.
441 # perm_string name = lex_strings.make($1);
442 # class_type_t*tmp = new class_type_t(name);
443 # FILE_NAME(tmp, @1);
444 # pform_set_typedef(name, tmp, NULL);
449 def p_class_identifier_2(p
):
450 '''class_identifier : TYPE_IDENTIFIER '''
452 # { class_type_t*tmp = dynamic_cast<class_type_t*>($1.type);
454 # yyerror(@1, "Type name \"%s\"is not a predeclared class name.", $1.text);
460 def p_class_declaration_endlabel_opt_1(p
):
461 '''class_declaration_endlabel_opt : ':' TYPE_IDENTIFIER '''
463 # { class_type_t*tmp = dynamic_cast<class_type_t*> ($2.type);
465 # yyerror(@2, "error: class declaration endlabel \"%s\" is not a class name\n", $2.text);
468 # $$ = strdupnew(tmp->name.str());
473 def p_class_declaration_endlabel_opt_2(p
):
474 '''class_declaration_endlabel_opt : ':' IDENTIFIER '''
478 def p_class_declaration_endlabel_opt_3(p
):
479 '''class_declaration_endlabel_opt : '''
483 def p_class_declaration_extends_opt_1(p
):
484 '''class_declaration_extends_opt : K_extends TYPE_IDENTIFIER '''
486 # { $$.type = $2.type;
491 def p_class_declaration_extends_opt_2(p
):
492 '''class_declaration_extends_opt : K_extends TYPE_IDENTIFIER '(' expression_list_with_nuls ')' '''
494 # { $$.type = $2.type;
499 def p_class_declaration_extends_opt_3(p
):
500 '''class_declaration_extends_opt : '''
502 # { $$.type = 0; $$.exprs = 0; }
504 def p_class_items_opt_1(p
):
505 '''class_items_opt : class_items '''
508 def p_class_items_opt_2(p
):
509 '''class_items_opt : '''
512 def p_class_items_1(p
):
513 '''class_items : class_items class_item '''
516 def p_class_items_2(p
):
517 '''class_items : class_item '''
520 def p_class_item_1(p
):
521 '''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 '''
523 # { current_function->set_ports($6);
524 # pform_set_constructor_return(current_function);
525 # pform_set_this_class(@3, current_function);
526 # current_function_set_statement(@3, $10);
528 # current_function = 0;
531 def p_class_item_2(p
):
532 '''class_item : property_qualifier_opt data_type list_of_variable_decl_assignments ';' '''
534 # { pform_class_property(@2, $1, $2, $3); }
536 def p_class_item_3(p
):
537 '''class_item : K_const class_item_qualifier_opt data_type list_of_variable_decl_assignments ';' '''
539 # { pform_class_property(@1, $2 | property_qualifier_t::make_const(), $3, $4); }
541 def p_class_item_4(p
):
542 '''class_item : method_qualifier_opt task_declaration '''
544 # { /* The task_declaration rule puts this into the class */ }
546 def p_class_item_5(p
):
547 '''class_item : method_qualifier_opt function_declaration '''
549 # { /* The function_declaration rule puts this into the class */ }
551 def p_class_item_6(p
):
552 '''class_item : K_extern method_qualifier_opt K_function K_new ';' '''
554 # { yyerror(@1, "sorry: External constructors are not yet supported."); }
556 def p_class_item_7(p
):
557 '''class_item : K_extern method_qualifier_opt K_function K_new '(' tf_port_list_opt ')' ';' '''
559 # { yyerror(@1, "sorry: External constructors are not yet supported."); }
561 def p_class_item_8(p
):
562 '''class_item : K_extern method_qualifier_opt K_function data_type_or_implicit_or_void IDENTIFIER ';' '''
564 # { yyerror(@1, "sorry: External methods are not yet supported.");
568 def p_class_item_9(p
):
569 '''class_item : K_extern method_qualifier_opt K_function data_type_or_implicit_or_void IDENTIFIER '(' tf_port_list_opt ')' ';' '''
571 # { yyerror(@1, "sorry: External methods are not yet supported.");
575 def p_class_item_10(p
):
576 '''class_item : K_extern method_qualifier_opt K_task IDENTIFIER ';' '''
578 # { yyerror(@1, "sorry: External methods are not yet supported.");
582 def p_class_item_11(p
):
583 '''class_item : K_extern method_qualifier_opt K_task IDENTIFIER '(' tf_port_list_opt ')' ';' '''
585 # { yyerror(@1, "sorry: External methods are not yet supported.");
589 def p_class_item_12(p
):
590 '''class_item : class_constraint '''
593 def p_class_item_13(p
):
594 '''class_item : property_qualifier_opt data_type error ';' '''
596 # { yyerror(@3, "error: Errors in variable names after data type.");
600 def p_class_item_14(p
):
601 '''class_item : property_qualifier_opt IDENTIFIER error ';' '''
603 # { yyerror(@3, "error: %s doesn't name a type.", $2);
607 def p_class_item_15(p
):
608 '''class_item : method_qualifier_opt K_function K_new error K_endfunction endnew_opt '''
610 # { yyerror(@1, "error: I give up on this class constructor declaration.");
614 def p_class_item_16(p
):
615 '''class_item : error ';' '''
617 # { yyerror(@2, "error: invalid class item.");
621 def p__embed0_class_item(p
):
622 '''_embed0_class_item : '''
623 # { assert(current_function==0);
624 # current_function = pform_push_constructor_scope(@3);
627 def p_class_item_qualifier_1(p
):
628 '''class_item_qualifier : K_static '''
630 # { $$ = property_qualifier_t::make_static(); }
632 def p_class_item_qualifier_2(p
):
633 '''class_item_qualifier : K_protected '''
635 # { $$ = property_qualifier_t::make_protected(); }
637 def p_class_item_qualifier_3(p
):
638 '''class_item_qualifier : K_local '''
640 # { $$ = property_qualifier_t::make_local(); }
642 def p_class_item_qualifier_list_1(p
):
643 '''class_item_qualifier_list : class_item_qualifier_list class_item_qualifier '''
647 def p_class_item_qualifier_list_2(p
):
648 '''class_item_qualifier_list : class_item_qualifier '''
652 def p_class_item_qualifier_opt_1(p
):
653 '''class_item_qualifier_opt : class_item_qualifier_list '''
657 def p_class_item_qualifier_opt_2(p
):
658 '''class_item_qualifier_opt : '''
660 # { $$ = property_qualifier_t::make_none(); }
662 def p_class_new_1(p
):
663 '''class_new : K_new '(' expression_list_with_nuls ')' '''
665 # { list<PExpr*>*expr_list = $3;
666 # strip_tail_items(expr_list);
667 # PENewClass*tmp = new PENewClass(*expr_list);
668 # FILE_NAME(tmp, @1);
673 def p_class_new_2(p
):
674 '''class_new : K_new hierarchy_identifier '''
676 # { PEIdent*tmpi = new PEIdent(*$2);
677 # FILE_NAME(tmpi, @2);
678 # PENewCopy*tmp = new PENewCopy(tmpi);
679 # FILE_NAME(tmp, @1);
684 def p_class_new_3(p
):
685 '''class_new : K_new '''
687 # { PENewClass*tmp = new PENewClass;
688 # FILE_NAME(tmp, @1);
692 def p_concurrent_assertion_item_1(p
):
693 '''concurrent_assertion_item : block_identifier_opt K_assert K_property '(' property_spec ')' statement_or_null '''
696 # if (gn_assertions_flag) {
697 # yyerror(@2, "sorry: concurrent_assertion_item not supported."
698 # " Try -gno-assertion to turn this message off.");
702 def p_concurrent_assertion_item_2(p
):
703 '''concurrent_assertion_item : block_identifier_opt K_assert K_property '(' error ')' statement_or_null '''
706 # yyerror(@2, "error: Error in property_spec of concurrent assertion item.");
709 def p_constraint_block_item_1(p
):
710 '''constraint_block_item : constraint_expression '''
713 def p_constraint_block_item_list_1(p
):
714 '''constraint_block_item_list : constraint_block_item_list constraint_block_item '''
717 def p_constraint_block_item_list_2(p
):
718 '''constraint_block_item_list : constraint_block_item '''
721 def p_constraint_block_item_list_opt_1(p
):
722 '''constraint_block_item_list_opt : '''
725 def p_constraint_block_item_list_opt_2(p
):
726 '''constraint_block_item_list_opt : constraint_block_item_list '''
729 def p_constraint_declaration_1(p
):
730 '''constraint_declaration : K_static_opt K_constraint IDENTIFIER '{' constraint_block_item_list_opt '}' '''
732 # { yyerror(@2, "sorry: Constraint declarations not supported."); }
734 def p_constraint_declaration_2(p
):
735 '''constraint_declaration : K_static_opt K_constraint IDENTIFIER '{' error '}' '''
737 # { yyerror(@4, "error: Errors in the constraint block item list."); }
739 def p_constraint_expression_1(p
):
740 '''constraint_expression : expression ';' '''
743 def p_constraint_expression_2(p
):
744 '''constraint_expression : expression K_dist '{' '}' ';' '''
747 def p_constraint_expression_3(p
):
748 '''constraint_expression : expression K_TRIGGER constraint_set '''
751 def p_constraint_expression_4(p
):
752 '''constraint_expression : K_if '(' expression ')' constraint_set %prec less_than_K_else '''
755 def p_constraint_expression_5(p
):
756 '''constraint_expression : K_if '(' expression ')' constraint_set K_else constraint_set '''
759 def p_constraint_expression_6(p
):
760 '''constraint_expression : K_foreach '(' IDENTIFIER '[' loop_variables ']' ')' constraint_set '''
763 def p_constraint_expression_list_1(p
):
764 '''constraint_expression_list : constraint_expression_list constraint_expression '''
767 def p_constraint_expression_list_2(p
):
768 '''constraint_expression_list : constraint_expression '''
771 def p_constraint_prototype_1(p
):
772 '''constraint_prototype : K_static_opt K_constraint IDENTIFIER ';' '''
774 # { yyerror(@2, "sorry: Constraint prototypes not supported."); }
776 def p_constraint_set_1(p
):
777 '''constraint_set : constraint_expression '''
780 def p_constraint_set_2(p
):
781 '''constraint_set : '{' constraint_expression_list '}' '''
784 def p_data_declaration_1(p
):
785 '''data_declaration : attribute_list_opt data_type_or_implicit list_of_variable_decl_assignments ';' '''
787 # { data_type_t*data_type = $2;
788 # if (data_type == 0) {
789 # data_type = new vector_type_t(IVL_VT_LOGIC, false, 0);
790 # FILE_NAME(data_type, @2);
792 # pform_makewire(@2, 0, str_strength, $3, NetNet::IMPLICIT_REG, data_type);
795 def p_data_type_1(p
):
796 '''data_type : integer_vector_type unsigned_signed_opt dimensions_opt '''
798 # { ivl_variable_type_t use_vtype = $1;
799 # bool reg_flag = false;
800 # if (use_vtype == IVL_VT_NO_TYPE) {
801 # use_vtype = IVL_VT_LOGIC;
804 # vector_type_t*tmp = new vector_type_t(use_vtype, $2, $3);
805 # tmp->reg_flag = reg_flag;
806 # FILE_NAME(tmp, @1);
810 def p_data_type_2(p
):
811 '''data_type : non_integer_type '''
813 # { real_type_t*tmp = new real_type_t($1);
814 # FILE_NAME(tmp, @1);
818 def p_data_type_3(p
):
819 '''data_type : struct_data_type '''
821 # { if (!$1->packed_flag) {
822 # yyerror(@1, "sorry: Unpacked structs not supported.");
827 def p_data_type_4(p
):
828 '''data_type : enum_data_type '''
832 def p_data_type_5(p
):
833 '''data_type : atom2_type signed_unsigned_opt '''
835 # { atom2_type_t*tmp = new atom2_type_t($1, $2);
836 # FILE_NAME(tmp, @1);
840 def p_data_type_6(p
):
841 '''data_type : K_integer signed_unsigned_opt '''
843 # { list<pform_range_t>*pd = make_range_from_width(integer_width);
844 # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, $2, pd);
845 # tmp->reg_flag = true;
846 # tmp->integer_flag = true;
850 def p_data_type_7(p
):
851 '''data_type : K_time '''
853 # { list<pform_range_t>*pd = make_range_from_width(64);
854 # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, false, pd);
855 # tmp->reg_flag = !gn_system_verilog();
859 def p_data_type_8(p
):
860 '''data_type : TYPE_IDENTIFIER dimensions_opt '''
863 # parray_type_t*tmp = new parray_type_t($1.type, $2);
864 # FILE_NAME(tmp, @1);
866 # } else $$ = $1.type;
870 def p_data_type_9(p
):
871 '''data_type : PACKAGE_IDENTIFIER K_SCOPE_RES _embed0_data_type TYPE_IDENTIFIER '''
873 # { lex_in_package_scope(0);
878 def p_data_type_10(p
):
879 '''data_type : K_string '''
881 # { string_type_t*tmp = new string_type_t;
882 # FILE_NAME(tmp, @1);
886 def p__embed0_data_type(p
):
887 '''_embed0_data_type : '''
888 # { lex_in_package_scope($1); }
890 def p_data_type_or_implicit_1(p
):
891 '''data_type_or_implicit : data_type '''
895 def p_data_type_or_implicit_2(p
):
896 '''data_type_or_implicit : signing dimensions_opt '''
898 # { vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, $1, $2);
899 # tmp->implicit_flag = true;
900 # FILE_NAME(tmp, @1);
904 def p_data_type_or_implicit_3(p
):
905 '''data_type_or_implicit : dimensions '''
907 # { vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, false, $1);
908 # tmp->implicit_flag = true;
909 # FILE_NAME(tmp, @1);
913 def p_data_type_or_implicit_4(p
):
914 '''data_type_or_implicit : '''
918 def p_data_type_or_implicit_or_void_1(p
):
919 '''data_type_or_implicit_or_void : data_type_or_implicit '''
923 def p_data_type_or_implicit_or_void_2(p
):
924 '''data_type_or_implicit_or_void : K_void '''
926 # { void_type_t*tmp = new void_type_t;
927 # FILE_NAME(tmp, @1);
931 def p_description_1(p
):
932 '''description : module '''
935 def p_description_2(p
):
936 '''description : udp_primitive '''
939 def p_description_3(p
):
940 '''description : config_declaration '''
943 def p_description_4(p
):
944 '''description : nature_declaration '''
947 def p_description_5(p
):
948 '''description : package_declaration '''
951 def p_description_6(p
):
952 '''description : discipline_declaration '''
955 def p_description_7(p
):
956 '''description : package_item '''
959 def p_description_8(p
):
960 '''description : KK_attribute '(' IDENTIFIER ',' STRING ',' STRING ')' '''
962 # { perm_string tmp3 = lex_strings.make($3);
963 # pform_set_type_attrib(tmp3, $5, $7);
968 def p_description_list_1(p
):
969 '''description_list : description '''
972 def p_description_list_2(p
):
973 '''description_list : description_list description '''
976 def p_endnew_opt_1(p
):
977 '''endnew_opt : ':' K_new '''
980 def p_endnew_opt_2(p
):
984 def p_dynamic_array_new_1(p
):
985 '''dynamic_array_new : K_new '[' expression ']' '''
987 # { $$ = new PENewArray($3, 0);
991 def p_dynamic_array_new_2(p
):
992 '''dynamic_array_new : K_new '[' expression ']' '(' expression ')' '''
994 # { $$ = new PENewArray($3, $6);
999 '''for_step : lpvalue '=' expression '''
1001 # { PAssign*tmp = new PAssign($1,$3);
1002 # FILE_NAME(tmp, @1);
1006 def p_for_step_2(p
):
1007 '''for_step : inc_or_dec_expression '''
1009 # { $$ = pform_compressed_assign_from_inc_dec(@1, $1); }
1011 def p_for_step_3(p
):
1012 '''for_step : compressed_statement '''
1016 def p_function_declaration_1(p
):
1017 '''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 '''
1019 # { // Last step: check any closing name.
1021 # if (strcmp($4,$11) != 0) {
1022 # yyerror(@11, "error: End label doesn't match "
1025 # if (! gn_system_verilog()) {
1026 # yyerror(@11, "error: Function end labels require "
1027 # "SystemVerilog.");
1034 def p_function_declaration_2(p
):
1035 '''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 '''
1037 # { // Last step: check any closing name.
1039 # if (strcmp($4,$14) != 0) {
1040 # yyerror(@14, "error: End label doesn't match "
1043 # if (! gn_system_verilog()) {
1044 # yyerror(@14, "error: Function end labels require "
1045 # "SystemVerilog.");
1052 def p_function_declaration_3(p
):
1053 '''function_declaration : K_function lifetime_opt data_type_or_implicit_or_void IDENTIFIER error K_endfunction _embed4_function_declaration endlabel_opt '''
1055 # { // Last step: check any closing name.
1057 # if (strcmp($4,$8) != 0) {
1058 # yyerror(@8, "error: End label doesn't match function name");
1060 # if (! gn_system_verilog()) {
1061 # yyerror(@8, "error: Function end labels require "
1062 # "SystemVerilog.");
1069 def p__embed0_function_declaration(p
):
1070 '''_embed0_function_declaration : '''
1071 # { assert(current_function == 0);
1072 # current_function = pform_push_function_scope(@1, $4, $2);
1075 def p__embed1_function_declaration(p
):
1076 '''_embed1_function_declaration : '''
1077 # { current_function->set_ports($7);
1078 # current_function->set_return($3);
1079 # current_function_set_statement($8? @8 : @4, $8);
1080 # pform_set_this_class(@4, current_function);
1081 # pform_pop_scope();
1082 # current_function = 0;
1085 def p__embed2_function_declaration(p
):
1086 '''_embed2_function_declaration : '''
1087 # { assert(current_function == 0);
1088 # current_function = pform_push_function_scope(@1, $4, $2);
1091 def p__embed3_function_declaration(p
):
1092 '''_embed3_function_declaration : '''
1093 # { current_function->set_ports($7);
1094 # current_function->set_return($3);
1095 # current_function_set_statement($11? @11 : @4, $11);
1096 # pform_set_this_class(@4, current_function);
1097 # pform_pop_scope();
1098 # current_function = 0;
1099 # if ($7==0 && !gn_system_verilog()) {
1100 # yyerror(@4, "error: Empty parenthesis syntax requires SystemVerilog.");
1104 def p__embed4_function_declaration(p
):
1105 '''_embed4_function_declaration : '''
1107 # if (current_function) {
1108 # pform_pop_scope();
1109 # current_function = 0;
1111 # assert(current_function == 0);
1112 # yyerror(@1, "error: Syntax error defining function.");
1116 def p_import_export_1(p
):
1117 '''import_export : K_import '''
1121 def p_import_export_2(p
):
1122 '''import_export : K_export '''
1126 def p_implicit_class_handle_1(p
):
1127 '''implicit_class_handle : K_this '''
1129 # { $$ = pform_create_this(); }
1131 def p_implicit_class_handle_2(p
):
1132 '''implicit_class_handle : K_super '''
1134 # { $$ = pform_create_super(); }
1136 def p_inc_or_dec_expression_1(p
):
1137 '''inc_or_dec_expression : K_INCR lpvalue %prec UNARY_PREC '''
1139 # { PEUnary*tmp = new PEUnary('I', $2);
1140 # FILE_NAME(tmp, @2);
1144 def p_inc_or_dec_expression_2(p
):
1145 '''inc_or_dec_expression : lpvalue K_INCR %prec UNARY_PREC '''
1147 # { PEUnary*tmp = new PEUnary('i', $1);
1148 # FILE_NAME(tmp, @1);
1152 def p_inc_or_dec_expression_3(p
):
1153 '''inc_or_dec_expression : K_DECR lpvalue %prec UNARY_PREC '''
1155 # { PEUnary*tmp = new PEUnary('D', $2);
1156 # FILE_NAME(tmp, @2);
1160 def p_inc_or_dec_expression_4(p
):
1161 '''inc_or_dec_expression : lpvalue K_DECR %prec UNARY_PREC '''
1163 # { PEUnary*tmp = new PEUnary('d', $1);
1164 # FILE_NAME(tmp, @1);
1168 def p_inside_expression_1(p
):
1169 '''inside_expression : expression K_inside '{' open_range_list '}' '''
1171 # { yyerror(@2, "sorry: \"inside\" expressions not supported yet.");
1175 def p_integer_vector_type_1(p
):
1176 '''integer_vector_type : K_reg '''
1178 # { $$ = IVL_VT_NO_TYPE; }
1180 def p_integer_vector_type_2(p
):
1181 '''integer_vector_type : K_bit '''
1183 # { $$ = IVL_VT_BOOL; }
1185 def p_integer_vector_type_3(p
):
1186 '''integer_vector_type : K_logic '''
1188 # { $$ = IVL_VT_LOGIC; }
1190 def p_integer_vector_type_4(p
):
1191 '''integer_vector_type : K_bool '''
1193 # { $$ = IVL_VT_BOOL; }
1195 def p_join_keyword_1(p
):
1196 '''join_keyword : K_join '''
1198 # { $$ = PBlock::BL_PAR; }
1200 def p_join_keyword_2(p
):
1201 '''join_keyword : K_join_none '''
1203 # { $$ = PBlock::BL_JOIN_NONE; }
1205 def p_join_keyword_3(p
):
1206 '''join_keyword : K_join_any '''
1208 # { $$ = PBlock::BL_JOIN_ANY; }
1210 def p_jump_statement_1(p
):
1211 '''jump_statement : K_break ';' '''
1213 # { yyerror(@1, "sorry: break statements not supported.");
1217 def p_jump_statement_2(p
):
1218 '''jump_statement : K_return ';' '''
1220 # { PReturn*tmp = new PReturn(0);
1221 # FILE_NAME(tmp, @1);
1225 def p_jump_statement_3(p
):
1226 '''jump_statement : K_return expression ';' '''
1228 # { PReturn*tmp = new PReturn($2);
1229 # FILE_NAME(tmp, @1);
1233 def p_lifetime_1(p
):
1234 '''lifetime : K_automatic '''
1236 # { $$ = LexicalScope::AUTOMATIC; }
1238 def p_lifetime_2(p
):
1239 '''lifetime : K_static '''
1241 # { $$ = LexicalScope::STATIC; }
1243 def p_lifetime_opt_1(p
):
1244 '''lifetime_opt : lifetime '''
1248 def p_lifetime_opt_2(p
):
1249 '''lifetime_opt : '''
1251 # { $$ = LexicalScope::INHERITED; }
1253 def p_loop_statement_1(p
):
1254 '''loop_statement : K_for '(' lpvalue '=' expression ';' expression ';' for_step ')' statement_or_null '''
1256 # { PForStatement*tmp = new PForStatement($3, $5, $7, $9, $11);
1257 # FILE_NAME(tmp, @1);
1261 def p_loop_statement_2(p
):
1262 '''loop_statement : K_for '(' data_type IDENTIFIER '=' expression ';' expression ';' for_step ')' _embed0_loop_statement statement_or_null '''
1264 # { pform_name_t tmp_hident;
1265 # tmp_hident.push_back(name_component_t(lex_strings.make($4)));
1267 # PEIdent*tmp_ident = pform_new_ident(tmp_hident);
1268 # FILE_NAME(tmp_ident, @4);
1270 # PForStatement*tmp_for = new PForStatement(tmp_ident, $6, $8, $10, $13);
1271 # FILE_NAME(tmp_for, @1);
1273 # pform_pop_scope();
1274 # vector<Statement*>tmp_for_list (1);
1275 # tmp_for_list[0] = tmp_for;
1276 # PBlock*tmp_blk = current_block_stack.top();
1277 # current_block_stack.pop();
1278 # tmp_blk->set_statement(tmp_for_list);
1283 def p_loop_statement_3(p
):
1284 '''loop_statement : K_forever statement_or_null '''
1286 # { PForever*tmp = new PForever($2);
1287 # FILE_NAME(tmp, @1);
1291 def p_loop_statement_4(p
):
1292 '''loop_statement : K_repeat '(' expression ')' statement_or_null '''
1294 # { PRepeat*tmp = new PRepeat($3, $5);
1295 # FILE_NAME(tmp, @1);
1299 def p_loop_statement_5(p
):
1300 '''loop_statement : K_while '(' expression ')' statement_or_null '''
1302 # { PWhile*tmp = new PWhile($3, $5);
1303 # FILE_NAME(tmp, @1);
1307 def p_loop_statement_6(p
):
1308 '''loop_statement : K_do statement_or_null K_while '(' expression ')' ';' '''
1310 # { PDoWhile*tmp = new PDoWhile($5, $2);
1311 # FILE_NAME(tmp, @1);
1315 def p_loop_statement_7(p
):
1316 '''loop_statement : K_foreach '(' IDENTIFIER '[' loop_variables ']' ')' _embed1_loop_statement statement_or_null '''
1318 # { PForeach*tmp_for = pform_make_foreach(@1, $3, $5, $9);
1320 # pform_pop_scope();
1321 # vector<Statement*>tmp_for_list(1);
1322 # tmp_for_list[0] = tmp_for;
1323 # PBlock*tmp_blk = current_block_stack.top();
1324 # current_block_stack.pop();
1325 # tmp_blk->set_statement(tmp_for_list);
1329 def p_loop_statement_8(p
):
1330 '''loop_statement : K_for '(' lpvalue '=' expression ';' expression ';' error ')' statement_or_null '''
1333 # yyerror(@1, "error: Error in for loop step assignment.");
1336 def p_loop_statement_9(p
):
1337 '''loop_statement : K_for '(' lpvalue '=' expression ';' error ';' for_step ')' statement_or_null '''
1340 # yyerror(@1, "error: Error in for loop condition expression.");
1343 def p_loop_statement_10(p
):
1344 '''loop_statement : K_for '(' error ')' statement_or_null '''
1347 # yyerror(@1, "error: Incomprehensible for loop.");
1350 def p_loop_statement_11(p
):
1351 '''loop_statement : K_while '(' error ')' statement_or_null '''
1354 # yyerror(@1, "error: Error in while loop condition.");
1357 def p_loop_statement_12(p
):
1358 '''loop_statement : K_do statement_or_null K_while '(' error ')' ';' '''
1361 # yyerror(@1, "error: Error in do/while loop condition.");
1364 def p_loop_statement_13(p
):
1365 '''loop_statement : K_foreach '(' IDENTIFIER '[' error ']' ')' statement_or_null '''
1368 # yyerror(@4, "error: Errors in foreach loop variables list.");
1371 def p__embed0_loop_statement(p
):
1372 '''_embed0_loop_statement : '''
1373 # { static unsigned for_counter = 0;
1374 # char for_block_name [64];
1375 # snprintf(for_block_name, sizeof for_block_name, "$ivl_for_loop%u", for_counter);
1377 # PBlock*tmp = pform_push_block_scope(for_block_name, PBlock::BL_SEQ);
1378 # FILE_NAME(tmp, @1);
1379 # current_block_stack.push(tmp);
1381 # list<decl_assignment_t*>assign_list;
1382 # decl_assignment_t*tmp_assign = new decl_assignment_t;
1383 # tmp_assign->name = lex_strings.make($4);
1384 # assign_list.push_back(tmp_assign);
1385 # pform_makewire(@4, 0, str_strength, &assign_list, NetNet::REG, $3);
1388 def p__embed1_loop_statement(p
):
1389 '''_embed1_loop_statement : '''
1390 # { static unsigned foreach_counter = 0;
1391 # char for_block_name[64];
1392 # snprintf(for_block_name, sizeof for_block_name, "$ivl_foreach%u", foreach_counter);
1393 # foreach_counter += 1;
1395 # PBlock*tmp = pform_push_block_scope(for_block_name, PBlock::BL_SEQ);
1396 # FILE_NAME(tmp, @1);
1397 # current_block_stack.push(tmp);
1399 # pform_make_foreach_declarations(@1, $5);
1402 def p_list_of_variable_decl_assignments_1(p
):
1403 '''list_of_variable_decl_assignments : variable_decl_assignment '''
1405 # { list<decl_assignment_t*>*tmp = new list<decl_assignment_t*>;
1406 # tmp->push_back($1);
1410 def p_list_of_variable_decl_assignments_2(p
):
1411 '''list_of_variable_decl_assignments : list_of_variable_decl_assignments ',' variable_decl_assignment '''
1413 # { list<decl_assignment_t*>*tmp = $1;
1414 # tmp->push_back($3);
1418 def p_variable_decl_assignment_1(p
):
1419 '''variable_decl_assignment : IDENTIFIER dimensions_opt '''
1421 # { decl_assignment_t*tmp = new decl_assignment_t;
1422 # tmp->name = lex_strings.make($1);
1431 def p_variable_decl_assignment_2(p
):
1432 '''variable_decl_assignment : IDENTIFIER '=' expression '''
1434 # { decl_assignment_t*tmp = new decl_assignment_t;
1435 # tmp->name = lex_strings.make($1);
1436 # tmp->expr .reset($3);
1441 def p_variable_decl_assignment_3(p
):
1442 '''variable_decl_assignment : IDENTIFIER '=' K_new '(' ')' '''
1444 # { decl_assignment_t*tmp = new decl_assignment_t;
1445 # tmp->name = lex_strings.make($1);
1446 # PENewClass*expr = new PENewClass;
1447 # FILE_NAME(expr, @3);
1448 # tmp->expr .reset(expr);
1453 def p_loop_variables_1(p
):
1454 '''loop_variables : loop_variables ',' IDENTIFIER '''
1456 # { list<perm_string>*tmp = $1;
1457 # tmp->push_back(lex_strings.make($3));
1462 def p_loop_variables_2(p
):
1463 '''loop_variables : IDENTIFIER '''
1465 # { list<perm_string>*tmp = new list<perm_string>;
1466 # tmp->push_back(lex_strings.make($1));
1471 def p_method_qualifier_1(p
):
1472 '''method_qualifier : K_virtual '''
1475 def p_method_qualifier_2(p
):
1476 '''method_qualifier : class_item_qualifier '''
1479 def p_method_qualifier_opt_1(p
):
1480 '''method_qualifier_opt : method_qualifier '''
1483 def p_method_qualifier_opt_2(p
):
1484 '''method_qualifier_opt : '''
1488 if __name__
== '__main__':