From f191fe6775e3500de642746c02d86faca3f647d2 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Wed, 24 Apr 2019 16:01:19 +0100 Subject: [PATCH] first version of parser --- parse.py | 1491 ------------------------------------------------------ parse.y | 3 + 2 files changed, 3 insertions(+), 1491 deletions(-) delete mode 100644 parse.py diff --git a/parse.py b/parse.py deleted file mode 100644 index e7b86cf..0000000 --- a/parse.py +++ /dev/null @@ -1,1491 +0,0 @@ -# %{ -# /* -# * Copyright (c) 1998-2017 Stephen Williams (steve@icarus.com) -# * Copyright CERN 2012-2013 / Stephen Williams (steve@icarus.com) -# * -# * This source code is free software; you can redistribute it -# * and/or modify it in source code form under the terms of the GNU -# * General Public License as published by the Free Software -# * Foundation; either version 2 of the License, or (at your option) -# * any later version. -# * -# * This program is distributed in the hope that it will be useful, -# * but WITHOUT ANY WARRANTY; without even the implied warranty of -# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# * GNU General Public License for more details. -# * -# * You should have received a copy of the GNU General Public License -# * along with this program; if not, write to the Free Software -# * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# */ -# -# # include "config.h" -# -# # include "parse_misc.h" -# # include "compiler.h" -# # include "pform.h" -# # include "Statement.h" -# # include "PSpec.h" -# # include -# # include -# # include -# -# class PSpecPath; -# -# extern void lex_end_table(); -# -# static list* param_active_range = 0; -# static bool param_active_signed = false; -# static ivl_variable_type_t param_active_type = IVL_VT_LOGIC; -# -# /* Port declaration lists use this structure for context. */ -# static struct { -# NetNet::Type port_net_type; -# NetNet::PortType port_type; -# data_type_t* data_type; -# } port_declaration_context = {NetNet::NONE, NetNet::NOT_A_PORT, 0}; -# -# /* Modport port declaration lists use this structure for context. */ -# enum modport_port_type_t { MP_NONE, MP_SIMPLE, MP_TF, MP_CLOCKING }; -# static struct { -# modport_port_type_t type; -# union { -# NetNet::PortType direction; -# bool is_import; -# }; -# } last_modport_port = { MP_NONE, {NetNet::NOT_A_PORT}}; -# -# /* The task and function rules need to briefly hold the pointer to the -# task/function that is currently in progress. */ -# static PTask* current_task = 0; -# static PFunction* current_function = 0; -# static stack current_block_stack; -# -# /* The variable declaration rules need to know if a lifetime has been -# specified. */ -# static LexicalScope::lifetime_t var_lifetime; -# -# static pform_name_t* pform_create_this(void) -# { -# name_component_t name (perm_string::literal("@")); -# pform_name_t*res = new pform_name_t; -# res->push_back(name); -# return res; -# } -# -# static pform_name_t* pform_create_super(void) -# { -# name_component_t name (perm_string::literal("#")); -# pform_name_t*res = new pform_name_t; -# res->push_back(name); -# return res; -# } -# -# /* This is used to keep track of the extra arguments after the notifier -# * in the $setuphold and $recrem timing checks. This allows us to print -# * a warning message that the delayed signals will not be created. We -# * need to do this since not driving these signals creates real -# * simulation issues. */ -# static unsigned args_after_notifier; -# -# /* The rules sometimes push attributes into a global context where -# sub-rules may grab them. This makes parser rules a little easier to -# write in some cases. */ -# static list*attributes_in_context = 0; -# -# /* Later version of bison (including 1.35) will not compile in stack -# extension if the output is compiled with C++ and either the YYSTYPE -# or YYLTYPE are provided by the source code. However, I can get the -# old behavior back by defining these symbols. */ -# # define YYSTYPE_IS_TRIVIAL 1 -# # define YYLTYPE_IS_TRIVIAL 1 -# -# /* Recent version of bison expect that the user supply a -# YYLLOC_DEFAULT macro that makes up a yylloc value from existing -# values. I need to supply an explicit version to account for the -# text field, that otherwise won't be copied. -# -# The YYLLOC_DEFAULT blends the file range for the tokens of Rhs -# rule, which has N tokens. -# */ -# # define YYLLOC_DEFAULT(Current, Rhs, N) do { \ -# if (N) { \ -# (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ -# (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ -# (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ -# (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ -# (Current).text = YYRHSLOC (Rhs, 1).text; \ -# } else { \ -# (Current).first_line = YYRHSLOC (Rhs, 0).last_line; \ -# (Current).first_column = YYRHSLOC (Rhs, 0).last_column; \ -# (Current).last_line = YYRHSLOC (Rhs, 0).last_line; \ -# (Current).last_column = YYRHSLOC (Rhs, 0).last_column; \ -# (Current).text = YYRHSLOC (Rhs, 0).text; \ -# } \ -# } while (0) -# -# /* -# * These are some common strength pairs that are used as defaults when -# * the user is not otherwise specific. -# */ -# static const struct str_pair_t pull_strength = { IVL_DR_PULL, IVL_DR_PULL }; -# static const struct str_pair_t str_strength = { IVL_DR_STRONG, IVL_DR_STRONG }; -# -# static list* make_port_list(char*id, list*udims, PExpr*expr) -# { -# list*tmp = new list; -# tmp->push_back(pform_port_t(lex_strings.make(id), udims, expr)); -# delete[]id; -# return tmp; -# } -# static list* make_port_list(list*tmp, -# char*id, list*udims, PExpr*expr) -# { -# tmp->push_back(pform_port_t(lex_strings.make(id), udims, expr)); -# delete[]id; -# return tmp; -# } -# -# list* make_range_from_width(uint64_t wid) -# { -# pform_range_t range; -# range.first = new PENumber(new verinum(wid-1, integer_width)); -# range.second = new PENumber(new verinum((uint64_t)0, integer_width)); -# -# list*rlist = new list; -# rlist->push_back(range); -# return rlist; -# } -# -# static list* list_from_identifier(char*id) -# { -# list*tmp = new list; -# tmp->push_back(lex_strings.make(id)); -# delete[]id; -# return tmp; -# } -# -# static list* list_from_identifier(list*tmp, char*id) -# { -# tmp->push_back(lex_strings.make(id)); -# delete[]id; -# return tmp; -# } -# -# list* copy_range(list* orig) -# { -# list*copy = 0; -# -# if (orig) -# copy = new list (*orig); -# -# return copy; -# } -# -# template void append(vector&out, const vector&in) -# { -# for (size_t idx = 0 ; idx < in.size() ; idx += 1) -# out.push_back(in[idx]); -# } -# -# /* -# * Look at the list and pull null pointers off the end. -# */ -# static void strip_tail_items(list*lst) -# { -# while (! lst->empty()) { -# if (lst->back() != 0) -# return; -# lst->pop_back(); -# } -# } -# -# /* -# * This is a shorthand for making a PECallFunction that takes a single -# * arg. This is used by some of the code that detects built-ins. -# */ -# static PECallFunction*make_call_function(perm_string tn, PExpr*arg) -# { -# vector parms(1); -# parms[0] = arg; -# PECallFunction*tmp = new PECallFunction(tn, parms); -# return tmp; -# } -# -# static PECallFunction*make_call_function(perm_string tn, PExpr*arg1, PExpr*arg2) -# { -# vector parms(2); -# parms[0] = arg1; -# parms[1] = arg2; -# PECallFunction*tmp = new PECallFunction(tn, parms); -# return tmp; -# } -# -# static list* make_named_numbers(perm_string name, long first, long last, PExpr*val =0) -# { -# list*lst = new list; -# named_pexpr_t tmp; -# // We are counting up. -# if (first <= last) { -# for (long idx = first ; idx <= last ; idx += 1) { -# ostringstream buf; -# buf << name.str() << idx << ends; -# tmp.name = lex_strings.make(buf.str()); -# tmp.parm = val; -# val = 0; -# lst->push_back(tmp); -# } -# // We are counting down. -# } else { -# for (long idx = first ; idx >= last ; idx -= 1) { -# ostringstream buf; -# buf << name.str() << idx << ends; -# tmp.name = lex_strings.make(buf.str()); -# tmp.parm = val; -# val = 0; -# lst->push_back(tmp); -# } -# } -# return lst; -# } -# -# static list* make_named_number(perm_string name, PExpr*val =0) -# { -# list*lst = new list; -# named_pexpr_t tmp; -# tmp.name = name; -# tmp.parm = val; -# lst->push_back(tmp); -# return lst; -# } -# -# static long check_enum_seq_value(const YYLTYPE&loc, verinum *arg, bool zero_ok) -# { -# long value = 1; -# // We can never have an undefined value in an enumeration name -# // declaration sequence. -# if (! arg->is_defined()) { -# yyerror(loc, "error: undefined value used in enum name sequence."); -# // We can never have a negative value in an enumeration name -# // declaration sequence. -# } else if (arg->is_negative()) { -# yyerror(loc, "error: negative value used in enum name sequence."); -# } else { -# value = arg->as_ulong(); -# // We cannot have a zero enumeration name declaration count. -# if (! zero_ok && (value == 0)) { -# yyerror(loc, "error: zero count used in enum name sequence."); -# value = 1; -# } -# } -# return value; -# } -# -# static void current_task_set_statement(const YYLTYPE&loc, vector*s) -# { -# if (s == 0) { -# /* if the statement list is null, then the parser -# detected the case that there are no statements in the -# task. If this is SystemVerilog, handle it as an -# an empty block. */ -# if (!gn_system_verilog()) { -# yyerror(loc, "error: Support for empty tasks requires SystemVerilog."); -# } -# PBlock*tmp = new PBlock(PBlock::BL_SEQ); -# FILE_NAME(tmp, loc); -# current_task->set_statement(tmp); -# return; -# } -# assert(s); -# -# /* An empty vector represents one or more null statements. Handle -# this as a simple null statement. */ -# if (s->empty()) -# return; -# -# /* A vector of 1 is handled as a simple statement. */ -# if (s->size() == 1) { -# current_task->set_statement((*s)[0]); -# return; -# } -# -# if (!gn_system_verilog()) { -# yyerror(loc, "error: Task body with multiple statements requires SystemVerilog."); -# } -# -# PBlock*tmp = new PBlock(PBlock::BL_SEQ); -# FILE_NAME(tmp, loc); -# tmp->set_statement(*s); -# current_task->set_statement(tmp); -# } -# -# static void current_function_set_statement(const YYLTYPE&loc, vector*s) -# { -# if (s == 0) { -# /* if the statement list is null, then the parser -# detected the case that there are no statements in the -# task. If this is SystemVerilog, handle it as an -# an empty block. */ -# if (!gn_system_verilog()) { -# yyerror(loc, "error: Support for empty functions requires SystemVerilog."); -# } -# PBlock*tmp = new PBlock(PBlock::BL_SEQ); -# FILE_NAME(tmp, loc); -# current_function->set_statement(tmp); -# return; -# } -# assert(s); -# -# /* An empty vector represents one or more null statements. Handle -# this as a simple null statement. */ -# if (s->empty()) -# return; -# -# /* A vector of 1 is handled as a simple statement. */ -# if (s->size() == 1) { -# current_function->set_statement((*s)[0]); -# return; -# } -# -# if (!gn_system_verilog()) { -# yyerror(loc, "error: Function body with multiple statements requires SystemVerilog."); -# } -# -# PBlock*tmp = new PBlock(PBlock::BL_SEQ); -# FILE_NAME(tmp, loc); -# tmp->set_statement(*s); -# current_function->set_statement(tmp); -# } -# -# %} -('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']") -() -('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\')]') -() -# -------------- RULES ---------------- -() -def p_source_text_1(p): - '''source_text : timeunits_declaration_opt _embed0_source_text description_list ''' - print(p) -() -def p_source_text_2(p): - '''source_text : ''' - print(p) -() -def p__embed0_source_text(p): - '''_embed0_source_text : ''' - # { pform_set_scope_timescale(yyloc); } -() -def p_assertion_item_1(p): - '''assertion_item : concurrent_assertion_item ''' - print(p) -() -def p_assignment_pattern_1(p): - '''assignment_pattern : K_LP expression_list_proper '}' ''' - print(p) - # { PEAssignPattern*tmp = new PEAssignPattern(*$2); - # FILE_NAME(tmp, @1); - # delete $2; - # $$ = tmp; - # } -() -def p_assignment_pattern_2(p): - '''assignment_pattern : K_LP '}' ''' - print(p) - # { PEAssignPattern*tmp = new PEAssignPattern; - # FILE_NAME(tmp, @1); - # $$ = tmp; - # } -() -def p_block_identifier_opt_1(p): - '''block_identifier_opt : IDENTIFIER ':' ''' - print(p) -() -def p_block_identifier_opt_2(p): - '''block_identifier_opt : ''' - print(p) -() -def p_class_declaration_1(p): - '''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 ''' - print(p) - # { // Wrap up the class. - # if ($11 && $4 && $4->name != $11) { - # yyerror(@11, "error: Class end label doesn't match class name."); - # delete[]$11; - # } - # } -() -def p__embed0_class_declaration(p): - '''_embed0_class_declaration : ''' - # { pform_start_class_declaration(@2, $4, $5.type, $5.exprs, $3); } -() -def p__embed1_class_declaration(p): - '''_embed1_class_declaration : ''' - # { // Process a class. - # pform_end_class_declaration(@9); - # } -() -def p_class_constraint_1(p): - '''class_constraint : constraint_prototype ''' - print(p) -() -def p_class_constraint_2(p): - '''class_constraint : constraint_declaration ''' - print(p) -() -def p_class_identifier_1(p): - '''class_identifier : IDENTIFIER ''' - print(p) - # { // Create a synthetic typedef for the class name so that the - # // lexor detects the name as a type. - # perm_string name = lex_strings.make($1); - # class_type_t*tmp = new class_type_t(name); - # FILE_NAME(tmp, @1); - # pform_set_typedef(name, tmp, NULL); - # delete[]$1; - # $$ = tmp; - # } -() -def p_class_identifier_2(p): - '''class_identifier : TYPE_IDENTIFIER ''' - print(p) - # { class_type_t*tmp = dynamic_cast($1.type); - # if (tmp == 0) { - # yyerror(@1, "Type name \"%s\"is not a predeclared class name.", $1.text); - # } - # delete[]$1.text; - # $$ = tmp; - # } -() -def p_class_declaration_endlabel_opt_1(p): - '''class_declaration_endlabel_opt : ':' TYPE_IDENTIFIER ''' - print(p) - # { class_type_t*tmp = dynamic_cast ($2.type); - # if (tmp == 0) { - # yyerror(@2, "error: class declaration endlabel \"%s\" is not a class name\n", $2.text); - # $$ = 0; - # } else { - # $$ = strdupnew(tmp->name.str()); - # } - # delete[]$2.text; - # } -() -def p_class_declaration_endlabel_opt_2(p): - '''class_declaration_endlabel_opt : ':' IDENTIFIER ''' - print(p) - # { $$ = $2; } -() -def p_class_declaration_endlabel_opt_3(p): - '''class_declaration_endlabel_opt : ''' - print(p) - # { $$ = 0; } -() -def p_class_declaration_extends_opt_1(p): - '''class_declaration_extends_opt : K_extends TYPE_IDENTIFIER ''' - print(p) - # { $$.type = $2.type; - # $$.exprs= 0; - # delete[]$2.text; - # } -() -def p_class_declaration_extends_opt_2(p): - '''class_declaration_extends_opt : K_extends TYPE_IDENTIFIER '(' expression_list_with_nuls ')' ''' - print(p) - # { $$.type = $2.type; - # $$.exprs = $4; - # delete[]$2.text; - # } -() -def p_class_declaration_extends_opt_3(p): - '''class_declaration_extends_opt : ''' - print(p) - # { $$.type = 0; $$.exprs = 0; } -() -def p_class_items_opt_1(p): - '''class_items_opt : class_items ''' - print(p) -() -def p_class_items_opt_2(p): - '''class_items_opt : ''' - print(p) -() -def p_class_items_1(p): - '''class_items : class_items class_item ''' - print(p) -() -def p_class_items_2(p): - '''class_items : class_item ''' - print(p) -() -def p_class_item_1(p): - '''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 ''' - print(p) - # { current_function->set_ports($6); - # pform_set_constructor_return(current_function); - # pform_set_this_class(@3, current_function); - # current_function_set_statement(@3, $10); - # pform_pop_scope(); - # current_function = 0; - # } -() -def p_class_item_2(p): - '''class_item : property_qualifier_opt data_type list_of_variable_decl_assignments ';' ''' - print(p) - # { pform_class_property(@2, $1, $2, $3); } -() -def p_class_item_3(p): - '''class_item : K_const class_item_qualifier_opt data_type list_of_variable_decl_assignments ';' ''' - print(p) - # { pform_class_property(@1, $2 | property_qualifier_t::make_const(), $3, $4); } -() -def p_class_item_4(p): - '''class_item : method_qualifier_opt task_declaration ''' - print(p) - # { /* The task_declaration rule puts this into the class */ } -() -def p_class_item_5(p): - '''class_item : method_qualifier_opt function_declaration ''' - print(p) - # { /* The function_declaration rule puts this into the class */ } -() -def p_class_item_6(p): - '''class_item : K_extern method_qualifier_opt K_function K_new ';' ''' - print(p) - # { yyerror(@1, "sorry: External constructors are not yet supported."); } -() -def p_class_item_7(p): - '''class_item : K_extern method_qualifier_opt K_function K_new '(' tf_port_list_opt ')' ';' ''' - print(p) - # { yyerror(@1, "sorry: External constructors are not yet supported."); } -() -def p_class_item_8(p): - '''class_item : K_extern method_qualifier_opt K_function data_type_or_implicit_or_void IDENTIFIER ';' ''' - print(p) - # { yyerror(@1, "sorry: External methods are not yet supported."); - # delete[] $5; - # } -() -def p_class_item_9(p): - '''class_item : K_extern method_qualifier_opt K_function data_type_or_implicit_or_void IDENTIFIER '(' tf_port_list_opt ')' ';' ''' - print(p) - # { yyerror(@1, "sorry: External methods are not yet supported."); - # delete[] $5; - # } -() -def p_class_item_10(p): - '''class_item : K_extern method_qualifier_opt K_task IDENTIFIER ';' ''' - print(p) - # { yyerror(@1, "sorry: External methods are not yet supported."); - # delete[] $4; - # } -() -def p_class_item_11(p): - '''class_item : K_extern method_qualifier_opt K_task IDENTIFIER '(' tf_port_list_opt ')' ';' ''' - print(p) - # { yyerror(@1, "sorry: External methods are not yet supported."); - # delete[] $4; - # } -() -def p_class_item_12(p): - '''class_item : class_constraint ''' - print(p) -() -def p_class_item_13(p): - '''class_item : property_qualifier_opt data_type error ';' ''' - print(p) - # { yyerror(@3, "error: Errors in variable names after data type."); - # yyerrok; - # } -() -def p_class_item_14(p): - '''class_item : property_qualifier_opt IDENTIFIER error ';' ''' - print(p) - # { yyerror(@3, "error: %s doesn't name a type.", $2); - # yyerrok; - # } -() -def p_class_item_15(p): - '''class_item : method_qualifier_opt K_function K_new error K_endfunction endnew_opt ''' - print(p) - # { yyerror(@1, "error: I give up on this class constructor declaration."); - # yyerrok; - # } -() -def p_class_item_16(p): - '''class_item : error ';' ''' - print(p) - # { yyerror(@2, "error: invalid class item."); - # yyerrok; - # } -() -def p__embed0_class_item(p): - '''_embed0_class_item : ''' - # { assert(current_function==0); - # current_function = pform_push_constructor_scope(@3); - # } -() -def p_class_item_qualifier_1(p): - '''class_item_qualifier : K_static ''' - print(p) - # { $$ = property_qualifier_t::make_static(); } -() -def p_class_item_qualifier_2(p): - '''class_item_qualifier : K_protected ''' - print(p) - # { $$ = property_qualifier_t::make_protected(); } -() -def p_class_item_qualifier_3(p): - '''class_item_qualifier : K_local ''' - print(p) - # { $$ = property_qualifier_t::make_local(); } -() -def p_class_item_qualifier_list_1(p): - '''class_item_qualifier_list : class_item_qualifier_list class_item_qualifier ''' - print(p) - # { $$ = $1 | $2; } -() -def p_class_item_qualifier_list_2(p): - '''class_item_qualifier_list : class_item_qualifier ''' - print(p) - # { $$ = $1; } -() -def p_class_item_qualifier_opt_1(p): - '''class_item_qualifier_opt : class_item_qualifier_list ''' - print(p) - # { $$ = $1; } -() -def p_class_item_qualifier_opt_2(p): - '''class_item_qualifier_opt : ''' - print(p) - # { $$ = property_qualifier_t::make_none(); } -() -def p_class_new_1(p): - '''class_new : K_new '(' expression_list_with_nuls ')' ''' - print(p) - # { list*expr_list = $3; - # strip_tail_items(expr_list); - # PENewClass*tmp = new PENewClass(*expr_list); - # FILE_NAME(tmp, @1); - # delete $3; - # $$ = tmp; - # } -() -def p_class_new_2(p): - '''class_new : K_new hierarchy_identifier ''' - print(p) - # { PEIdent*tmpi = new PEIdent(*$2); - # FILE_NAME(tmpi, @2); - # PENewCopy*tmp = new PENewCopy(tmpi); - # FILE_NAME(tmp, @1); - # delete $2; - # $$ = tmp; - # } -() -def p_class_new_3(p): - '''class_new : K_new ''' - print(p) - # { PENewClass*tmp = new PENewClass; - # FILE_NAME(tmp, @1); - # $$ = tmp; - # } -() -def p_concurrent_assertion_item_1(p): - '''concurrent_assertion_item : block_identifier_opt K_assert K_property '(' property_spec ')' statement_or_null ''' - print(p) - # { /* */ - # if (gn_assertions_flag) { - # yyerror(@2, "sorry: concurrent_assertion_item not supported." - # " Try -gno-assertion to turn this message off."); - # } - # } -() -def p_concurrent_assertion_item_2(p): - '''concurrent_assertion_item : block_identifier_opt K_assert K_property '(' error ')' statement_or_null ''' - print(p) - # { yyerrok; - # yyerror(@2, "error: Error in property_spec of concurrent assertion item."); - # } -() -def p_constraint_block_item_1(p): - '''constraint_block_item : constraint_expression ''' - print(p) -() -def p_constraint_block_item_list_1(p): - '''constraint_block_item_list : constraint_block_item_list constraint_block_item ''' - print(p) -() -def p_constraint_block_item_list_2(p): - '''constraint_block_item_list : constraint_block_item ''' - print(p) -() -def p_constraint_block_item_list_opt_1(p): - '''constraint_block_item_list_opt : ''' - print(p) -() -def p_constraint_block_item_list_opt_2(p): - '''constraint_block_item_list_opt : constraint_block_item_list ''' - print(p) -() -def p_constraint_declaration_1(p): - '''constraint_declaration : K_static_opt K_constraint IDENTIFIER '{' constraint_block_item_list_opt '}' ''' - print(p) - # { yyerror(@2, "sorry: Constraint declarations not supported."); } -() -def p_constraint_declaration_2(p): - '''constraint_declaration : K_static_opt K_constraint IDENTIFIER '{' error '}' ''' - print(p) - # { yyerror(@4, "error: Errors in the constraint block item list."); } -() -def p_constraint_expression_1(p): - '''constraint_expression : expression ';' ''' - print(p) -() -def p_constraint_expression_2(p): - '''constraint_expression : expression K_dist '{' '}' ';' ''' - print(p) -() -def p_constraint_expression_3(p): - '''constraint_expression : expression K_TRIGGER constraint_set ''' - print(p) -() -def p_constraint_expression_4(p): - '''constraint_expression : K_if '(' expression ')' constraint_set %prec less_than_K_else ''' - print(p) -() -def p_constraint_expression_5(p): - '''constraint_expression : K_if '(' expression ')' constraint_set K_else constraint_set ''' - print(p) -() -def p_constraint_expression_6(p): - '''constraint_expression : K_foreach '(' IDENTIFIER '[' loop_variables ']' ')' constraint_set ''' - print(p) -() -def p_constraint_expression_list_1(p): - '''constraint_expression_list : constraint_expression_list constraint_expression ''' - print(p) -() -def p_constraint_expression_list_2(p): - '''constraint_expression_list : constraint_expression ''' - print(p) -() -def p_constraint_prototype_1(p): - '''constraint_prototype : K_static_opt K_constraint IDENTIFIER ';' ''' - print(p) - # { yyerror(@2, "sorry: Constraint prototypes not supported."); } -() -def p_constraint_set_1(p): - '''constraint_set : constraint_expression ''' - print(p) -() -def p_constraint_set_2(p): - '''constraint_set : '{' constraint_expression_list '}' ''' - print(p) -() -def p_data_declaration_1(p): - '''data_declaration : attribute_list_opt data_type_or_implicit list_of_variable_decl_assignments ';' ''' - print(p) - # { data_type_t*data_type = $2; - # if (data_type == 0) { - # data_type = new vector_type_t(IVL_VT_LOGIC, false, 0); - # FILE_NAME(data_type, @2); - # } - # pform_makewire(@2, 0, str_strength, $3, NetNet::IMPLICIT_REG, data_type); - # } -() -def p_data_type_1(p): - '''data_type : integer_vector_type unsigned_signed_opt dimensions_opt ''' - print(p) - # { ivl_variable_type_t use_vtype = $1; - # bool reg_flag = false; - # if (use_vtype == IVL_VT_NO_TYPE) { - # use_vtype = IVL_VT_LOGIC; - # reg_flag = true; - # } - # vector_type_t*tmp = new vector_type_t(use_vtype, $2, $3); - # tmp->reg_flag = reg_flag; - # FILE_NAME(tmp, @1); - # $$ = tmp; - # } -() -def p_data_type_2(p): - '''data_type : non_integer_type ''' - print(p) - # { real_type_t*tmp = new real_type_t($1); - # FILE_NAME(tmp, @1); - # $$ = tmp; - # } -() -def p_data_type_3(p): - '''data_type : struct_data_type ''' - print(p) - # { if (!$1->packed_flag) { - # yyerror(@1, "sorry: Unpacked structs not supported."); - # } - # $$ = $1; - # } -() -def p_data_type_4(p): - '''data_type : enum_data_type ''' - print(p) - # { $$ = $1; } -() -def p_data_type_5(p): - '''data_type : atom2_type signed_unsigned_opt ''' - print(p) - # { atom2_type_t*tmp = new atom2_type_t($1, $2); - # FILE_NAME(tmp, @1); - # $$ = tmp; - # } -() -def p_data_type_6(p): - '''data_type : K_integer signed_unsigned_opt ''' - print(p) - # { list*pd = make_range_from_width(integer_width); - # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, $2, pd); - # tmp->reg_flag = true; - # tmp->integer_flag = true; - # $$ = tmp; - # } -() -def p_data_type_7(p): - '''data_type : K_time ''' - print(p) - # { list*pd = make_range_from_width(64); - # vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, false, pd); - # tmp->reg_flag = !gn_system_verilog(); - # $$ = tmp; - # } -() -def p_data_type_8(p): - '''data_type : TYPE_IDENTIFIER dimensions_opt ''' - print(p) - # { if ($2) { - # parray_type_t*tmp = new parray_type_t($1.type, $2); - # FILE_NAME(tmp, @1); - # $$ = tmp; - # } else $$ = $1.type; - # delete[]$1.text; - # } -() -def p_data_type_9(p): - '''data_type : PACKAGE_IDENTIFIER K_SCOPE_RES _embed0_data_type TYPE_IDENTIFIER ''' - print(p) - # { lex_in_package_scope(0); - # $$ = $4.type; - # delete[]$4.text; - # } -() -def p_data_type_10(p): - '''data_type : K_string ''' - print(p) - # { string_type_t*tmp = new string_type_t; - # FILE_NAME(tmp, @1); - # $$ = tmp; - # } -() -def p__embed0_data_type(p): - '''_embed0_data_type : ''' - # { lex_in_package_scope($1); } -() -def p_data_type_or_implicit_1(p): - '''data_type_or_implicit : data_type ''' - print(p) - # { $$ = $1; } -() -def p_data_type_or_implicit_2(p): - '''data_type_or_implicit : signing dimensions_opt ''' - print(p) - # { vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, $1, $2); - # tmp->implicit_flag = true; - # FILE_NAME(tmp, @1); - # $$ = tmp; - # } -() -def p_data_type_or_implicit_3(p): - '''data_type_or_implicit : dimensions ''' - print(p) - # { vector_type_t*tmp = new vector_type_t(IVL_VT_LOGIC, false, $1); - # tmp->implicit_flag = true; - # FILE_NAME(tmp, @1); - # $$ = tmp; - # } -() -def p_data_type_or_implicit_4(p): - '''data_type_or_implicit : ''' - print(p) - # { $$ = 0; } -() -def p_data_type_or_implicit_or_void_1(p): - '''data_type_or_implicit_or_void : data_type_or_implicit ''' - print(p) - # { $$ = $1; } -() -def p_data_type_or_implicit_or_void_2(p): - '''data_type_or_implicit_or_void : K_void ''' - print(p) - # { void_type_t*tmp = new void_type_t; - # FILE_NAME(tmp, @1); - # $$ = tmp; - # } -() -def p_description_1(p): - '''description : module ''' - print(p) -() -def p_description_2(p): - '''description : udp_primitive ''' - print(p) -() -def p_description_3(p): - '''description : config_declaration ''' - print(p) -() -def p_description_4(p): - '''description : nature_declaration ''' - print(p) -() -def p_description_5(p): - '''description : package_declaration ''' - print(p) -() -def p_description_6(p): - '''description : discipline_declaration ''' - print(p) -() -def p_description_7(p): - '''description : package_item ''' - print(p) -() -def p_description_8(p): - '''description : KK_attribute '(' IDENTIFIER ',' STRING ',' STRING ')' ''' - print(p) - # { perm_string tmp3 = lex_strings.make($3); - # pform_set_type_attrib(tmp3, $5, $7); - # delete[] $3; - # delete[] $5; - # } -() -def p_description_list_1(p): - '''description_list : description ''' - print(p) -() -def p_description_list_2(p): - '''description_list : description_list description ''' - print(p) -() -def p_endnew_opt_1(p): - '''endnew_opt : ':' K_new ''' - print(p) -() -def p_endnew_opt_2(p): - '''endnew_opt : ''' - print(p) -() -def p_dynamic_array_new_1(p): - '''dynamic_array_new : K_new '[' expression ']' ''' - print(p) - # { $$ = new PENewArray($3, 0); - # FILE_NAME($$, @1); - # } -() -def p_dynamic_array_new_2(p): - '''dynamic_array_new : K_new '[' expression ']' '(' expression ')' ''' - print(p) - # { $$ = new PENewArray($3, $6); - # FILE_NAME($$, @1); - # } -() -def p_for_step_1(p): - '''for_step : lpvalue '=' expression ''' - print(p) - # { PAssign*tmp = new PAssign($1,$3); - # FILE_NAME(tmp, @1); - # $$ = tmp; - # } -() -def p_for_step_2(p): - '''for_step : inc_or_dec_expression ''' - print(p) - # { $$ = pform_compressed_assign_from_inc_dec(@1, $1); } -() -def p_for_step_3(p): - '''for_step : compressed_statement ''' - print(p) - # { $$ = $1; } -() -def p_function_declaration_1(p): - '''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 ''' - print(p) - # { // Last step: check any closing name. - # if ($11) { - # if (strcmp($4,$11) != 0) { - # yyerror(@11, "error: End label doesn't match " - # "function name"); - # } - # if (! gn_system_verilog()) { - # yyerror(@11, "error: Function end labels require " - # "SystemVerilog."); - # } - # delete[]$11; - # } - # delete[]$4; - # } -() -def p_function_declaration_2(p): - '''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 ''' - print(p) - # { // Last step: check any closing name. - # if ($14) { - # if (strcmp($4,$14) != 0) { - # yyerror(@14, "error: End label doesn't match " - # "function name"); - # } - # if (! gn_system_verilog()) { - # yyerror(@14, "error: Function end labels require " - # "SystemVerilog."); - # } - # delete[]$14; - # } - # delete[]$4; - # } -() -def p_function_declaration_3(p): - '''function_declaration : K_function lifetime_opt data_type_or_implicit_or_void IDENTIFIER error K_endfunction _embed4_function_declaration endlabel_opt ''' - print(p) - # { // Last step: check any closing name. - # if ($8) { - # if (strcmp($4,$8) != 0) { - # yyerror(@8, "error: End label doesn't match function name"); - # } - # if (! gn_system_verilog()) { - # yyerror(@8, "error: Function end labels require " - # "SystemVerilog."); - # } - # delete[]$8; - # } - # delete[]$4; - # } -() -def p__embed0_function_declaration(p): - '''_embed0_function_declaration : ''' - # { assert(current_function == 0); - # current_function = pform_push_function_scope(@1, $4, $2); - # } -() -def p__embed1_function_declaration(p): - '''_embed1_function_declaration : ''' - # { current_function->set_ports($7); - # current_function->set_return($3); - # current_function_set_statement($8? @8 : @4, $8); - # pform_set_this_class(@4, current_function); - # pform_pop_scope(); - # current_function = 0; - # } -() -def p__embed2_function_declaration(p): - '''_embed2_function_declaration : ''' - # { assert(current_function == 0); - # current_function = pform_push_function_scope(@1, $4, $2); - # } -() -def p__embed3_function_declaration(p): - '''_embed3_function_declaration : ''' - # { current_function->set_ports($7); - # current_function->set_return($3); - # current_function_set_statement($11? @11 : @4, $11); - # pform_set_this_class(@4, current_function); - # pform_pop_scope(); - # current_function = 0; - # if ($7==0 && !gn_system_verilog()) { - # yyerror(@4, "error: Empty parenthesis syntax requires SystemVerilog."); - # } - # } -() -def p__embed4_function_declaration(p): - '''_embed4_function_declaration : ''' - # { /* */ - # if (current_function) { - # pform_pop_scope(); - # current_function = 0; - # } - # assert(current_function == 0); - # yyerror(@1, "error: Syntax error defining function."); - # yyerrok; - # } -() -def p_import_export_1(p): - '''import_export : K_import ''' - print(p) - # { $$ = true; } -() -def p_import_export_2(p): - '''import_export : K_export ''' - print(p) - # { $$ = false; } -() -def p_implicit_class_handle_1(p): - '''implicit_class_handle : K_this ''' - print(p) - # { $$ = pform_create_this(); } -() -def p_implicit_class_handle_2(p): - '''implicit_class_handle : K_super ''' - print(p) - # { $$ = pform_create_super(); } -() -def p_inc_or_dec_expression_1(p): - '''inc_or_dec_expression : K_INCR lpvalue %prec UNARY_PREC ''' - print(p) - # { PEUnary*tmp = new PEUnary('I', $2); - # FILE_NAME(tmp, @2); - # $$ = tmp; - # } -() -def p_inc_or_dec_expression_2(p): - '''inc_or_dec_expression : lpvalue K_INCR %prec UNARY_PREC ''' - print(p) - # { PEUnary*tmp = new PEUnary('i', $1); - # FILE_NAME(tmp, @1); - # $$ = tmp; - # } -() -def p_inc_or_dec_expression_3(p): - '''inc_or_dec_expression : K_DECR lpvalue %prec UNARY_PREC ''' - print(p) - # { PEUnary*tmp = new PEUnary('D', $2); - # FILE_NAME(tmp, @2); - # $$ = tmp; - # } -() -def p_inc_or_dec_expression_4(p): - '''inc_or_dec_expression : lpvalue K_DECR %prec UNARY_PREC ''' - print(p) - # { PEUnary*tmp = new PEUnary('d', $1); - # FILE_NAME(tmp, @1); - # $$ = tmp; - # } -() -def p_inside_expression_1(p): - '''inside_expression : expression K_inside '{' open_range_list '}' ''' - print(p) - # { yyerror(@2, "sorry: \"inside\" expressions not supported yet."); - # $$ = 0; - # } -() -def p_integer_vector_type_1(p): - '''integer_vector_type : K_reg ''' - print(p) - # { $$ = IVL_VT_NO_TYPE; } -() -def p_integer_vector_type_2(p): - '''integer_vector_type : K_bit ''' - print(p) - # { $$ = IVL_VT_BOOL; } -() -def p_integer_vector_type_3(p): - '''integer_vector_type : K_logic ''' - print(p) - # { $$ = IVL_VT_LOGIC; } -() -def p_integer_vector_type_4(p): - '''integer_vector_type : K_bool ''' - print(p) - # { $$ = IVL_VT_BOOL; } -() -def p_join_keyword_1(p): - '''join_keyword : K_join ''' - print(p) - # { $$ = PBlock::BL_PAR; } -() -def p_join_keyword_2(p): - '''join_keyword : K_join_none ''' - print(p) - # { $$ = PBlock::BL_JOIN_NONE; } -() -def p_join_keyword_3(p): - '''join_keyword : K_join_any ''' - print(p) - # { $$ = PBlock::BL_JOIN_ANY; } -() -def p_jump_statement_1(p): - '''jump_statement : K_break ';' ''' - print(p) - # { yyerror(@1, "sorry: break statements not supported."); - # $$ = 0; - # } -() -def p_jump_statement_2(p): - '''jump_statement : K_return ';' ''' - print(p) - # { PReturn*tmp = new PReturn(0); - # FILE_NAME(tmp, @1); - # $$ = tmp; - # } -() -def p_jump_statement_3(p): - '''jump_statement : K_return expression ';' ''' - print(p) - # { PReturn*tmp = new PReturn($2); - # FILE_NAME(tmp, @1); - # $$ = tmp; - # } -() -def p_lifetime_1(p): - '''lifetime : K_automatic ''' - print(p) - # { $$ = LexicalScope::AUTOMATIC; } -() -def p_lifetime_2(p): - '''lifetime : K_static ''' - print(p) - # { $$ = LexicalScope::STATIC; } -() -def p_lifetime_opt_1(p): - '''lifetime_opt : lifetime ''' - print(p) - # { $$ = $1; } -() -def p_lifetime_opt_2(p): - '''lifetime_opt : ''' - print(p) - # { $$ = LexicalScope::INHERITED; } -() -def p_loop_statement_1(p): - '''loop_statement : K_for '(' lpvalue '=' expression ';' expression ';' for_step ')' statement_or_null ''' - print(p) - # { PForStatement*tmp = new PForStatement($3, $5, $7, $9, $11); - # FILE_NAME(tmp, @1); - # $$ = tmp; - # } -() -def p_loop_statement_2(p): - '''loop_statement : K_for '(' data_type IDENTIFIER '=' expression ';' expression ';' for_step ')' _embed0_loop_statement statement_or_null ''' - print(p) - # { pform_name_t tmp_hident; - # tmp_hident.push_back(name_component_t(lex_strings.make($4))); - # - # PEIdent*tmp_ident = pform_new_ident(tmp_hident); - # FILE_NAME(tmp_ident, @4); - # - # PForStatement*tmp_for = new PForStatement(tmp_ident, $6, $8, $10, $13); - # FILE_NAME(tmp_for, @1); - # - # pform_pop_scope(); - # vectortmp_for_list (1); - # tmp_for_list[0] = tmp_for; - # PBlock*tmp_blk = current_block_stack.top(); - # current_block_stack.pop(); - # tmp_blk->set_statement(tmp_for_list); - # $$ = tmp_blk; - # delete[]$4; - # } -() -def p_loop_statement_3(p): - '''loop_statement : K_forever statement_or_null ''' - print(p) - # { PForever*tmp = new PForever($2); - # FILE_NAME(tmp, @1); - # $$ = tmp; - # } -() -def p_loop_statement_4(p): - '''loop_statement : K_repeat '(' expression ')' statement_or_null ''' - print(p) - # { PRepeat*tmp = new PRepeat($3, $5); - # FILE_NAME(tmp, @1); - # $$ = tmp; - # } -() -def p_loop_statement_5(p): - '''loop_statement : K_while '(' expression ')' statement_or_null ''' - print(p) - # { PWhile*tmp = new PWhile($3, $5); - # FILE_NAME(tmp, @1); - # $$ = tmp; - # } -() -def p_loop_statement_6(p): - '''loop_statement : K_do statement_or_null K_while '(' expression ')' ';' ''' - print(p) - # { PDoWhile*tmp = new PDoWhile($5, $2); - # FILE_NAME(tmp, @1); - # $$ = tmp; - # } -() -def p_loop_statement_7(p): - '''loop_statement : K_foreach '(' IDENTIFIER '[' loop_variables ']' ')' _embed1_loop_statement statement_or_null ''' - print(p) - # { PForeach*tmp_for = pform_make_foreach(@1, $3, $5, $9); - # - # pform_pop_scope(); - # vectortmp_for_list(1); - # tmp_for_list[0] = tmp_for; - # PBlock*tmp_blk = current_block_stack.top(); - # current_block_stack.pop(); - # tmp_blk->set_statement(tmp_for_list); - # $$ = tmp_blk; - # } -() -def p_loop_statement_8(p): - '''loop_statement : K_for '(' lpvalue '=' expression ';' expression ';' error ')' statement_or_null ''' - print(p) - # { $$ = 0; - # yyerror(@1, "error: Error in for loop step assignment."); - # } -() -def p_loop_statement_9(p): - '''loop_statement : K_for '(' lpvalue '=' expression ';' error ';' for_step ')' statement_or_null ''' - print(p) - # { $$ = 0; - # yyerror(@1, "error: Error in for loop condition expression."); - # } -() -def p_loop_statement_10(p): - '''loop_statement : K_for '(' error ')' statement_or_null ''' - print(p) - # { $$ = 0; - # yyerror(@1, "error: Incomprehensible for loop."); - # } -() -def p_loop_statement_11(p): - '''loop_statement : K_while '(' error ')' statement_or_null ''' - print(p) - # { $$ = 0; - # yyerror(@1, "error: Error in while loop condition."); - # } -() -def p_loop_statement_12(p): - '''loop_statement : K_do statement_or_null K_while '(' error ')' ';' ''' - print(p) - # { $$ = 0; - # yyerror(@1, "error: Error in do/while loop condition."); - # } -() -def p_loop_statement_13(p): - '''loop_statement : K_foreach '(' IDENTIFIER '[' error ']' ')' statement_or_null ''' - print(p) - # { $$ = 0; - # yyerror(@4, "error: Errors in foreach loop variables list."); - # } -() -def p__embed0_loop_statement(p): - '''_embed0_loop_statement : ''' - # { static unsigned for_counter = 0; - # char for_block_name [64]; - # snprintf(for_block_name, sizeof for_block_name, "$ivl_for_loop%u", for_counter); - # for_counter += 1; - # PBlock*tmp = pform_push_block_scope(for_block_name, PBlock::BL_SEQ); - # FILE_NAME(tmp, @1); - # current_block_stack.push(tmp); - # - # listassign_list; - # decl_assignment_t*tmp_assign = new decl_assignment_t; - # tmp_assign->name = lex_strings.make($4); - # assign_list.push_back(tmp_assign); - # pform_makewire(@4, 0, str_strength, &assign_list, NetNet::REG, $3); - # } -() -def p__embed1_loop_statement(p): - '''_embed1_loop_statement : ''' - # { static unsigned foreach_counter = 0; - # char for_block_name[64]; - # snprintf(for_block_name, sizeof for_block_name, "$ivl_foreach%u", foreach_counter); - # foreach_counter += 1; - # - # PBlock*tmp = pform_push_block_scope(for_block_name, PBlock::BL_SEQ); - # FILE_NAME(tmp, @1); - # current_block_stack.push(tmp); - # - # pform_make_foreach_declarations(@1, $5); - # } -() -def p_list_of_variable_decl_assignments_1(p): - '''list_of_variable_decl_assignments : variable_decl_assignment ''' - print(p) - # { list*tmp = new list; - # tmp->push_back($1); - # $$ = tmp; - # } -() -def p_list_of_variable_decl_assignments_2(p): - '''list_of_variable_decl_assignments : list_of_variable_decl_assignments ',' variable_decl_assignment ''' - print(p) - # { list*tmp = $1; - # tmp->push_back($3); - # $$ = tmp; - # } -() -def p_variable_decl_assignment_1(p): - '''variable_decl_assignment : IDENTIFIER dimensions_opt ''' - print(p) - # { decl_assignment_t*tmp = new decl_assignment_t; - # tmp->name = lex_strings.make($1); - # if ($2) { - # tmp->index = *$2; - # delete $2; - # } - # delete[]$1; - # $$ = tmp; - # } -() -def p_variable_decl_assignment_2(p): - '''variable_decl_assignment : IDENTIFIER '=' expression ''' - print(p) - # { decl_assignment_t*tmp = new decl_assignment_t; - # tmp->name = lex_strings.make($1); - # tmp->expr .reset($3); - # delete[]$1; - # $$ = tmp; - # } -() -def p_variable_decl_assignment_3(p): - '''variable_decl_assignment : IDENTIFIER '=' K_new '(' ')' ''' - print(p) - # { decl_assignment_t*tmp = new decl_assignment_t; - # tmp->name = lex_strings.make($1); - # PENewClass*expr = new PENewClass; - # FILE_NAME(expr, @3); - # tmp->expr .reset(expr); - # delete[]$1; - # $$ = tmp; - # } -() -def p_loop_variables_1(p): - '''loop_variables : loop_variables ',' IDENTIFIER ''' - print(p) - # { list*tmp = $1; - # tmp->push_back(lex_strings.make($3)); - # delete[]$3; - # $$ = tmp; - # } -() -def p_loop_variables_2(p): - '''loop_variables : IDENTIFIER ''' - print(p) - # { list*tmp = new list; - # tmp->push_back(lex_strings.make($1)); - # delete[]$1; - # $$ = tmp; - # } -() -def p_method_qualifier_1(p): - '''method_qualifier : K_virtual ''' - print(p) -() -def p_method_qualifier_2(p): - '''method_qualifier : class_item_qualifier ''' - print(p) -() -def p_method_qualifier_opt_1(p): - '''method_qualifier_opt : method_qualifier ''' - print(p) -() -def p_method_qualifier_opt_2(p): - '''method_qualifier_opt : ''' - print(p) -() - -if __name__ == '__main__': - from ply import * - yacc.yacc() - diff --git a/parse.y b/parse.y index 3533f79..cdfe8d3 100644 --- a/parse.y +++ b/parse.y @@ -1597,6 +1597,7 @@ modport_declaration /* IEEE1800-2012: A.2.9 */ "in interfaces."); } modport_item_list ';' + ; modport_item_list : modport_item @@ -5836,6 +5837,7 @@ specify_item_list_opt { } | specify_item_list { } + ; specify_edge_path_decl : specify_edge_path '=' '(' delay_value_list ')' @@ -6991,3 +6993,4 @@ K_packed_opt : K_packed { $$ = true; } | { $$ = false; } ; K_reg_opt : K_reg { $$ = true; } | { $$ = false; } ; K_static_opt : K_static { $$ = true; } | { $$ = false; } ; K_virtual_opt : K_virtual { $$ = true; } | { $$ = false; } ; + -- 2.30.2