Clean up indentation in compiler parse.y.

Convert the remaining old-style indentation to the new style.
This commit is contained in:
Martin Whitaker 2022-12-21 14:11:47 +00:00
parent 32f66511e0
commit 01378fbdb0
1 changed files with 1358 additions and 1325 deletions

185
parse.y
View File

@ -1958,7 +1958,8 @@ non_integer_type /* IEEE1800-2005: A.2.2.1 */
| K_shortreal { $$ = real_type_t::SHORTREAL; } | K_shortreal { $$ = real_type_t::SHORTREAL; }
; ;
number : BASED_NUMBER number
: BASED_NUMBER
{ $$ = $1; based_size = 0;} { $$ = $1; based_size = 0;}
| DEC_NUMBER | DEC_NUMBER
{ $$ = $1; based_size = 0;} { $$ = $1; based_size = 0;}
@ -1968,8 +1969,7 @@ number : BASED_NUMBER
| UNBASED_NUMBER | UNBASED_NUMBER
{ $$ = $1; based_size = 0;} { $$ = $1; based_size = 0;}
| DEC_NUMBER UNBASED_NUMBER | DEC_NUMBER UNBASED_NUMBER
{ yyerror(@1, "error: Unbased SystemVerilog literal cannot have " { yyerror(@1, "error: Unbased SystemVerilog literal cannot have a size.");
"a size.");
$$ = $1; based_size = 0;} $$ = $1; based_size = 0;}
; ;
@ -3046,8 +3046,7 @@ delay_value_simple
if ($1 == 0 || !get_time_unit($1, unit)) if ($1 == 0 || !get_time_unit($1, unit))
yyerror(@1, "internal error: time literal delay."); yyerror(@1, "internal error: time literal delay.");
else { else {
double p = pow(10.0, double p = pow(10.0, (double)(unit - pform_get_timeunit()));
(double)(unit - pform_get_timeunit()));
double time = atof($1) * p; double time = atof($1) * p;
verireal *v = new verireal(time); verireal *v = new verireal(time);
@ -3189,8 +3188,10 @@ drive_strength
; ;
drive_strength_opt drive_strength_opt
: drive_strength { $$ = $1; } : drive_strength
| { $$.str0 = IVL_DR_STRONG; $$.str1 = IVL_DR_STRONG; } { $$ = $1; }
|
{ $$.str0 = IVL_DR_STRONG; $$.str1 = IVL_DR_STRONG; }
; ;
dr_strength0 dr_strength0
@ -3592,8 +3593,10 @@ expression_list_with_nuls
* an argument list in parenthesis or with just the task/function name by * an argument list in parenthesis or with just the task/function name by
* itself. When an argument list is used it might be empty. */ * itself. When an argument list is used it might be empty. */
argument_list_parens_opt argument_list_parens_opt
: '(' expression_list_with_nuls ')' { $$ = $2; } : '(' expression_list_with_nuls ')'
| { $$ = new std::list<PExpr*>; } { $$ = $2; }
|
{ $$ = new std::list<PExpr*>; }
expression_list_proper expression_list_proper
: expression_list_proper ',' expression : expression_list_proper ',' expression
@ -4050,8 +4053,10 @@ expr_primary
declarations of ports. We check later to make sure there are no declarations of ports. We check later to make sure there are no
output or inout ports actually used for functions. */ output or inout ports actually used for functions. */
tf_item_list_opt /* IEEE1800-2017: A.2.7 */ tf_item_list_opt /* IEEE1800-2017: A.2.7 */
: tf_item_list { $$ = $1; } : tf_item_list
| { $$ = 0; } { $$ = $1; }
|
{ $$ = 0; }
; ;
tf_item_list /* IEEE1800-2017: A.2.7 */ tf_item_list /* IEEE1800-2017: A.2.7 */
@ -4326,8 +4331,7 @@ list_of_variable_port_identifiers
list_of_ports list_of_ports
: port_opt : port_opt
{ std::vector<Module::port_t*>*tmp { std::vector<Module::port_t*>*tmp = new std::vector<Module::port_t*>(1);
= new std::vector<Module::port_t*>(1);
(*tmp)[0] = $1; (*tmp)[0] = $1;
$$ = tmp; $$ = tmp;
} }
@ -4340,8 +4344,7 @@ list_of_ports
list_of_port_declarations list_of_port_declarations
: port_declaration : port_declaration
{ std::vector<Module::port_t*>*tmp { std::vector<Module::port_t*>*tmp = new std::vector<Module::port_t*>(1);
= new std::vector<Module::port_t*>(1);
(*tmp)[0] = $1; (*tmp)[0] = $1;
$$ = tmp; $$ = tmp;
} }
@ -4385,14 +4388,9 @@ list_of_port_declarations
$$ = tmp; $$ = tmp;
} }
| list_of_port_declarations ',' | list_of_port_declarations ','
{ { yyerror(@2, "error: Superfluous comma in port declaration list."); }
yyerror(@2, "error: Superfluous comma in port declaration list.");
}
| list_of_port_declarations ';' | list_of_port_declarations ';'
{ { yyerror(@2, "error: ';' is an invalid port declaration separator."); }
yyerror(@2, "error: ';' is an invalid port declaration "
"separator.");
}
; ;
port_declaration port_declaration
@ -4735,9 +4733,12 @@ module_attribute_foreign
; ;
module_port_list_opt module_port_list_opt
: '(' list_of_ports ')' { $$ = $2; } : '(' list_of_ports ')'
| '(' list_of_port_declarations ')' { $$ = $2; } { $$ = $2; }
| { $$ = 0; } | '(' list_of_port_declarations ')'
{ $$ = $2; }
|
{ $$ = 0; }
| '(' error ')' | '(' error ')'
{ yyerror(@2, "Errors in port declarations."); { yyerror(@2, "Errors in port declarations.");
yyerrok; yyerrok;
@ -4780,9 +4781,7 @@ module_parameter_port_list
"list"); "list");
} }
| type_param | type_param
{ { param_is_local = false; }
param_is_local = false;
}
parameter_assign parameter_assign
| module_parameter_port_list ',' module_parameter | module_parameter_port_list ',' module_parameter
| module_parameter_port_list ',' data_type_opt | module_parameter_port_list ',' data_type_opt
@ -5282,7 +5281,10 @@ module_item_list_opt
| |
; ;
generate_if : K_if '(' expression ')' { pform_start_generate_if(@1, $3); } ; generate_if
: K_if '(' expression ')'
{ pform_start_generate_if(@1, $3); }
;
generate_case_items generate_case_items
: generate_case_items generate_case_item : generate_case_items generate_case_item
@ -5290,9 +5292,13 @@ generate_case_items
; ;
generate_case_item generate_case_item
: expression_list_proper ':' { pform_generate_case_item(@1, $1); } generate_block : expression_list_proper ':'
{ pform_generate_case_item(@1, $1); }
generate_block
{ pform_endgenerate(false); } { pform_endgenerate(false); }
| K_default ':' { pform_generate_case_item(@1, 0); } generate_block | K_default ':'
{ pform_generate_case_item(@1, 0); }
generate_block
{ pform_endgenerate(false); } { pform_endgenerate(false); }
; ;
@ -5306,9 +5312,9 @@ generate_item
cerr << @1 << ": warning: Anachronistic use of begin/end to surround generate schemes." << endl; cerr << @1 << ": warning: Anachronistic use of begin/end to surround generate schemes." << endl;
} }
} }
| K_begin ':' IDENTIFIER { | K_begin ':' IDENTIFIER
pform_start_generate_nblock(@1, $3); { pform_start_generate_nblock(@1, $3); }
} generate_item_list_opt K_end generate_item_list_opt K_end
{ /* Detect and warn about anachronistic named begin/end use */ { /* Detect and warn about anachronistic named begin/end use */
if (generation_flag > GN_VER2001 && warn_anachronisms) { if (generation_flag > GN_VER2001 && warn_anachronisms) {
warn_count += 1; warn_count += 1;
@ -5324,7 +5330,8 @@ generate_item_list
; ;
generate_item_list_opt generate_item_list_opt
: { pform_generate_single_item = false; } generate_item_list : { pform_generate_single_item = false; }
generate_item_list
| |
; ;
@ -5421,8 +5428,15 @@ param_type
} }
| type_param | type_param
parameter : K_parameter { param_is_local = false; }; parameter
localparam : K_localparam { param_is_local = true; }; : K_parameter
{ param_is_local = false; }
;
localparam
: K_localparam
{ param_is_local = true; }
;
parameter_declaration parameter_declaration
: parameter_or_localparam param_type parameter_assign_list ';' : parameter_or_localparam param_type parameter_assign_list ';'
@ -5534,8 +5548,7 @@ parameter_value_opt
$$ = lst; $$ = lst;
} }
| '#' error | '#' error
{ yyerror(@1, "error: syntax error in parameter value " { yyerror(@1, "error: syntax error in parameter value assignment list.");
"assignment list.");
$$ = 0; $$ = 0;
} }
| |
@ -5728,7 +5741,6 @@ port_conn_expression_list_with_nuls
port_t object to pass it up to the module declaration code. */ port_t object to pass it up to the module declaration code. */
port_reference port_reference
: IDENTIFIER : IDENTIFIER
{ Module::port_t*ptmp; { Module::port_t*ptmp;
perm_string name = lex_strings.make($1); perm_string name = lex_strings.make($1);
@ -5736,7 +5748,6 @@ port_reference
delete[]$1; delete[]$1;
$$ = ptmp; $$ = ptmp;
} }
| IDENTIFIER '[' expression ':' expression ']' | IDENTIFIER '[' expression ':' expression ']'
{ index_component_t itmp; { index_component_t itmp;
itmp.sel = index_component_t::SEL_PART; itmp.sel = index_component_t::SEL_PART;
@ -5760,7 +5771,6 @@ port_reference
delete[]$1; delete[]$1;
$$ = ptmp; $$ = ptmp;
} }
| IDENTIFIER '[' expression ']' | IDENTIFIER '[' expression ']'
{ index_component_t itmp; { index_component_t itmp;
itmp.sel = index_component_t::SEL_BIT; itmp.sel = index_component_t::SEL_BIT;
@ -5783,7 +5793,6 @@ port_reference
delete[]$1; delete[]$1;
$$ = ptmp; $$ = ptmp;
} }
| IDENTIFIER '[' error ']' | IDENTIFIER '[' error ']'
{ yyerror(@1, "error: invalid port bit select"); { yyerror(@1, "error: invalid port bit select");
Module::port_t*ptmp = new Module::port_t; Module::port_t*ptmp = new Module::port_t;
@ -5868,11 +5877,9 @@ event_variable_list
specify_item specify_item
: K_specparam specparam_decl ';' : K_specparam specparam_decl ';'
| specify_simple_path_decl ';' | specify_simple_path_decl ';'
{ pform_module_specify_path($1); { pform_module_specify_path($1); }
}
| specify_edge_path_decl ';' | specify_edge_path_decl ';'
{ pform_module_specify_path($1); { pform_module_specify_path($1); }
}
| K_if '(' expression ')' specify_simple_path_decl ';' | K_if '(' expression ')' specify_simple_path_decl ';'
{ PSpecPath*tmp = $5; { PSpecPath*tmp = $5;
if (tmp) { if (tmp) {
@ -5898,8 +5905,7 @@ specify_item
pform_module_specify_path(tmp); pform_module_specify_path(tmp);
} }
| K_ifnone specify_edge_path_decl ';' | K_ifnone specify_edge_path_decl ';'
{ yywarn(@1, "Sorry: ifnone with an edge-sensitive path is " { yywarn(@1, "Sorry: ifnone with an edge-sensitive path is not supported.");
"not supported.");
yyerrok; yyerrok;
} }
| K_Sfullskew '(' spec_reference_event ',' spec_reference_event | K_Sfullskew '(' spec_reference_event ',' spec_reference_event
@ -5993,25 +5999,32 @@ specify_edge_path_decl
} }
; ;
edge_operator : K_posedge { $$ = true; } | K_negedge { $$ = false; } ; edge_operator
: K_posedge { $$ = true; }
| K_negedge { $$ = false; }
;
specify_edge_path specify_edge_path
: '(' specify_path_identifiers spec_polarity : '(' specify_path_identifiers spec_polarity
K_EG '(' specify_path_identifiers polarity_operator expression ')' ')' K_EG '(' specify_path_identifiers polarity_operator expression ')' ')'
{ int edge_flag = 0; { int edge_flag = 0;
$$ = pform_make_specify_edge_path(@1, edge_flag, $2, $3, false, $6, $8); } $$ = pform_make_specify_edge_path(@1, edge_flag, $2, $3, false, $6, $8);
}
| '(' edge_operator specify_path_identifiers spec_polarity | '(' edge_operator specify_path_identifiers spec_polarity
K_EG '(' specify_path_identifiers polarity_operator expression ')' ')' K_EG '(' specify_path_identifiers polarity_operator expression ')' ')'
{ int edge_flag = $2? 1 : -1; { int edge_flag = $2? 1 : -1;
$$ = pform_make_specify_edge_path(@1, edge_flag, $3, $4, false, $7, $9);} $$ = pform_make_specify_edge_path(@1, edge_flag, $3, $4, false, $7, $9);
}
| '(' specify_path_identifiers spec_polarity | '(' specify_path_identifiers spec_polarity
K_SG '(' specify_path_identifiers polarity_operator expression ')' ')' K_SG '(' specify_path_identifiers polarity_operator expression ')' ')'
{ int edge_flag = 0; { int edge_flag = 0;
$$ = pform_make_specify_edge_path(@1, edge_flag, $2, $3, true, $6, $8); } $$ = pform_make_specify_edge_path(@1, edge_flag, $2, $3, true, $6, $8);
}
| '(' edge_operator specify_path_identifiers spec_polarity | '(' edge_operator specify_path_identifiers spec_polarity
K_SG '(' specify_path_identifiers polarity_operator expression ')' ')' K_SG '(' specify_path_identifiers polarity_operator expression ')' ')'
{ int edge_flag = $2? 1 : -1; { int edge_flag = $2? 1 : -1;
$$ = pform_make_specify_edge_path(@1, edge_flag, $3, $4, true, $7, $9); } $$ = pform_make_specify_edge_path(@1, edge_flag, $3, $4, true, $7, $9);
}
; ;
polarity_operator polarity_operator
@ -6036,11 +6049,9 @@ specify_simple_path_decl
; ;
specify_simple_path specify_simple_path
: '(' specify_path_identifiers spec_polarity : '(' specify_path_identifiers spec_polarity K_EG specify_path_identifiers ')'
K_EG specify_path_identifiers ')'
{ $$ = pform_make_specify_path(@1, $2, $3, false, $5); } { $$ = pform_make_specify_path(@1, $2, $3, false, $5); }
| '(' specify_path_identifiers spec_polarity | '(' specify_path_identifiers spec_polarity K_SG specify_path_identifiers ')'
K_SG specify_path_identifiers ')'
{ $$ = pform_make_specify_path(@1, $2, $3, true, $5); } { $$ = pform_make_specify_path(@1, $2, $3, true, $5); }
| '(' error ')' | '(' error ')'
{ yyerror(@1, "Invalid simple path"); { yyerror(@1, "Invalid simple path");
@ -6110,8 +6121,7 @@ specify_path_identifiers
specparam specparam
: IDENTIFIER '=' expression : IDENTIFIER '=' expression
{ PExpr*tmp = $3; { PExpr*tmp = $3;
pform_set_specparam(@1, lex_strings.make($1), pform_set_specparam(@1, lex_strings.make($1), specparam_active_range, tmp);
specparam_active_range, tmp);
delete[]$1; delete[]$1;
} }
| IDENTIFIER '=' expression ':' expression ':' expression | IDENTIFIER '=' expression ':' expression ':' expression
@ -6149,8 +6159,7 @@ specparam
cerr << " expression." << endl; cerr << " expression." << endl;
min_typ_max_warn -= 1; min_typ_max_warn -= 1;
} }
pform_set_specparam(@1, lex_strings.make($1), pform_set_specparam(@1, lex_strings.make($1), specparam_active_range, tmp);
specparam_active_range, tmp);
delete[]$1; delete[]$1;
} }
| PATHPULSE_IDENTIFIER '=' expression | PATHPULSE_IDENTIFIER '=' expression
@ -6239,7 +6248,8 @@ spec_notifier
"and delayed signal \"" << *$3 "and delayed signal \"" << *$3
<< "\" will not be driven." << endl; << "\" will not be driven." << endl;
} }
delete $3; } delete $3;
}
/* How do we match this path? */ /* How do we match this path? */
| IDENTIFIER | IDENTIFIER
{ args_after_notifier = 0; delete[]$1; } { args_after_notifier = 0; delete[]$1; }
@ -6443,11 +6453,14 @@ statement_item /* This is roughly statement_item in the LRM */
yywarn(@1, "Sorry: ->> with repeat event control is not currently supported."); yywarn(@1, "Sorry: ->> with repeat event control is not currently supported.");
} }
| procedural_assertion_statement { $$ = $1; } | procedural_assertion_statement
{ $$ = $1; }
| loop_statement { $$ = $1; } | loop_statement
{ $$ = $1; }
| jump_statement { $$ = $1; } | jump_statement
{ $$ = $1; }
| unique_priority K_case '(' expression ')' case_items K_endcase | unique_priority K_case '(' expression ')' case_items K_endcase
{ PCase*tmp = new PCase($1, NetCase::EQ, $4, $6); { PCase*tmp = new PCase($1, NetCase::EQ, $4, $6);
@ -6695,7 +6708,6 @@ compressed_statement
} }
; ;
statement_or_null_list_opt statement_or_null_list_opt
: statement_or_null_list : statement_or_null_list
{ $$ = $1; } { $$ = $1; }
@ -6875,7 +6887,10 @@ udp_input_sym
| 'q' { $$ = 'q'; } | 'q' { $$ = 'q'; }
| '_' { $$ = '_'; } | '_' { $$ = '_'; }
| '+' { $$ = '+'; } | '+' { $$ = '+'; }
| DEC_NUMBER { yyerror(@1, "internal error: Input digits parse as decimal number!"); $$ = '0'; } | DEC_NUMBER
{ yyerror(@1, "internal error: Input digits parse as decimal number!");
$$ = '0';
}
; ;
udp_output_sym udp_output_sym
@ -6883,7 +6898,10 @@ udp_output_sym
| '1' { $$ = '1'; } | '1' { $$ = '1'; }
| 'x' { $$ = 'x'; } | 'x' { $$ = 'x'; }
| '-' { $$ = '-'; } | '-' { $$ = '-'; }
| DEC_NUMBER { yyerror(@1, "internal error: Output digits parse as decimal number!"); $$ = '0'; } | DEC_NUMBER
{ yyerror(@1, "internal error: Output digits parse as decimal number!");
$$ = '0';
}
; ;
/* Port declarations create wires for the inputs and the output. The /* Port declarations create wires for the inputs and the output. The
@ -6947,7 +6965,9 @@ udp_port_list
} }
; ;
udp_reg_opt: K_reg { $$ = true; } | { $$ = false; }; udp_reg_opt
: K_reg { $$ = true; }
| { $$ = false; };
udp_input_declaration_list udp_input_declaration_list
: K_input IDENTIFIER : K_input IDENTIFIER
@ -6974,7 +6994,6 @@ udp_primitive
udp_init_opt udp_init_opt
udp_body udp_body
K_endprimitive label_opt K_endprimitive label_opt
{ perm_string tmp2 = lex_strings.make($2); { perm_string tmp2 = lex_strings.make($2);
pform_make_udp(@2, tmp2, $4, $7, $9, $8); pform_make_udp(@2, tmp2, $4, $7, $9, $8);
check_end_label(@11, "primitive", $2, $11); check_end_label(@11, "primitive", $2, $11);
@ -6989,7 +7008,6 @@ udp_primitive
udp_input_declaration_list ')' ';' udp_input_declaration_list ')' ';'
udp_body udp_body
K_endprimitive label_opt K_endprimitive label_opt
{ perm_string tmp2 = lex_strings.make($2); { perm_string tmp2 = lex_strings.make($2);
perm_string tmp6 = lex_strings.make($6); perm_string tmp6 = lex_strings.make($6);
pform_make_udp(@2, tmp2, $5, tmp6, $7, $9, $12); pform_make_udp(@2, tmp2, $5, tmp6, $7, $9, $12);
@ -7010,7 +7028,22 @@ unique_priority
presence is significant. This is a fairly common pattern so presence is significant. This is a fairly common pattern so
collect those rules here. */ collect those rules here. */
K_genvar_opt : K_genvar { $$ = true; } | { $$ = false; } ; K_genvar_opt
K_static_opt : K_static { $$ = true; } | { $$ = false; } ; : K_genvar { $$ = true; }
K_virtual_opt : K_virtual { $$ = true; } | { $$ = false; } ; | { $$ = false; }
K_var_opt : K_var | ; ;
K_static_opt
: K_static { $$ = true; }
| { $$ = false; }
;
K_virtual_opt
: K_virtual { $$ = true; }
| { $$ = false; }
;
K_var_opt
: K_var
|
;