"Yacc" owes much to a most stimulating collection of users, who have goaded me beyond my inclination, and frequently beyond my ability in their endless search for "one more feature". Their irritating unwillingness to learn how to do things my way has usually led to my doing things their way; most of the time, they have been right.– S. C. Johnson, "Yacc guide acknowledgements
This appendix describes the HAC language's grammar. The grammar is context-free and LR(1), so traditional yacc and bison (LALR(1)) parser generators will work with it.
0 $accept: module $end 1 module: embedded_module 2 embedded_module: imports_optional top_root 3 imports_optional: imports 4 | /* empty */ 5 imports: imports import_item 6 | import_item 7 import_item: IMPORT 8 | EMBEDFILE '{' embedded_module '}' 9 top_root: body 10 | /* empty */ 11 body: body body_item 12 | body_item 13 body_item: namespace_item 14 | definition 15 | prototype_declaration 16 namespace_item: namespace_management 17 | instance_item 18 | type_alias 19 | language_body 20 namespace_management: NAMESPACE ID '{' top_root '}' 21 | OPEN namespace_id AS ID ';' 22 | OPEN namespace_id ';' 23 namespace_id: relative_id 24 definition: defproc 25 | defdatatype 26 | defchan 27 | defenum 28 prototype_declaration: declare_proc_proto 29 | declare_datatype_proto 30 | declare_chan_proto 31 | declare_enum 32 type_alias: optional_template_specification TYPEDEF physical_type_ref ID ';' 33 template_specification: TEMPLATE template_formal_decl_list_in_angles 34 | TEMPLATE template_formal_decl_list_optional_in_angles template_formal_decl_nodefault_list_in_angles 35 optional_template_specification: template_specification 36 | /* empty */ 37 def_or_proc: DEFINE 38 | DEFPROC 39 declare_proc_proto: optional_template_specification def_or_proc ID optional_port_formal_decl_list_in_parens ';' 40 defproc: optional_template_specification def_or_proc ID optional_port_formal_decl_list_in_parens '{' optional_definition_body '}' 41 optional_port_formal_decl_list_in_parens: '(' port_formal_decl_list ')' 42 | '(' ')' 43 template_formal_decl_list_in_angles: '<' template_formal_decl_list '>' 44 template_formal_decl_nodefault_list_in_angles: '<' template_formal_decl_nodefault_list '>' 45 template_formal_decl_list_optional_in_angles: template_formal_decl_list_in_angles 46 | '<' '>' 47 template_formal_decl_list: template_formal_decl_list ';' template_formal_decl 48 | template_formal_decl 49 template_formal_decl_nodefault_list: template_formal_decl_nodefault_list ';' template_formal_decl_nodefault 50 | template_formal_decl_nodefault 51 template_formal_decl: base_param_type template_formal_id_list 52 template_formal_decl_nodefault: base_param_type template_formal_id_nodefault_list 53 template_formal_id_list: template_formal_id_list ',' template_formal_id 54 | template_formal_id 55 template_formal_id_nodefault_list: template_formal_id_nodefault_list ',' template_formal_id_nodefault 56 | template_formal_id_nodefault 57 template_formal_id_default: ID optional_dense_range_list '=' expr 58 template_formal_id_nodefault: ID optional_dense_range_list 59 template_formal_id: template_formal_id_default 60 | template_formal_id_nodefault 61 port_formal_decl_list: port_formal_decl_list ';' port_formal_decl 62 | port_formal_decl 63 port_formal_decl: physical_type_ref port_formal_id_list 64 port_formal_id_list: port_formal_id_list ',' port_formal_id 65 | port_formal_id 66 port_formal_id: ID optional_dense_range_list 67 generic_type_ref: generic_id strict_relaxed_template_arguments optional_chan_dir 68 optional_chan_dir: '?' 69 | '!' 70 | /* empty */ 71 physical_type_ref: generic_type_ref 72 | base_chan_type 73 | base_data_type_ref 74 base_data_type_ref: base_data_type strict_relaxed_template_arguments 75 data_type_ref: base_data_type_ref 76 | generic_type_ref 77 type_id: physical_type_ref 78 | base_param_type 79 base_param_type: PINT_TYPE 80 | PBOOL_TYPE 81 | PREAL_TYPE 82 base_chan_type: chan_or_port data_type_ref_list_optional_in_parens 83 chan_or_port: CHANNEL optional_chan_dir 84 data_type_ref_list_optional_in_parens: '(' data_type_ref_list_optional ')' 85 data_type_ref_list_optional: data_type_ref_list 86 | /* empty */ 87 data_type_ref_list: data_type_ref_list ',' data_type_ref 88 | data_type_ref 89 base_data_type: INT_TYPE 90 | BOOL_TYPE 91 declare_datatype_proto: optional_template_specification DEFTYPE ID DEFINEOP data_type_ref data_param_decl_list_in_parens ';' 92 defdatatype: optional_template_specification DEFTYPE ID DEFINEOP data_type_ref data_param_decl_list_in_parens '{' optional_definition_body set_body get_body '}' 93 set_body: SET '{' chp_body_optional '}' 94 get_body: GET '{' chp_body_optional '}' 95 declare_enum: ENUM ID ';' 96 defenum: ENUM ID '{' enum_member_list '}' 97 enum_member_list: enum_member_list ',' ID 98 | ID 99 declare_chan_proto: optional_template_specification DEFCHAN ID DEFINEOP base_chan_type data_param_decl_list_in_parens ';' 100 defchan: optional_template_specification DEFCHAN ID DEFINEOP base_chan_type data_param_decl_list_in_parens '{' optional_definition_body send_body recv_body '}' 101 send_body: SEND '{' chp_body_optional '}' 102 recv_body: RECV '{' chp_body_optional '}' 103 data_param_decl_list_in_parens: '(' data_param_decl_list ')' 104 data_param_decl_list: data_param_decl_list ';' data_param_decl 105 | data_param_decl 106 data_param_decl: data_type_ref data_param_id_list 107 data_param_id_list: data_param_id_list ',' data_param_id 108 | data_param_id 109 data_param_id: ID optional_dense_range_list 110 definition_body: definition_body definition_body_item 111 | definition_body_item 112 definition_body_item: instance_item 113 | language_body 114 | type_alias 115 optional_definition_body: definition_body 116 | /* empty */ 117 instance_management_list: instance_management_list instance_item 118 | instance_item 119 instance_item: type_instance_declaration 120 | connection_statement 121 | instance_type_completion_statement 122 | instance_type_completion_connection_statement 123 | nonempty_alias_list ';' 124 | loop_instantiation 125 | conditional_instantiation 126 loop_instantiation: '(' ';' ID ':' range ':' instance_management_list ')' 127 conditional_instantiation: '[' guarded_instance_management_list ']' 128 type_instance_declaration: type_id instance_id_list ';' 129 instance_id_list: instance_id_list ',' instance_id_item 130 | instance_id_item 131 instance_id_item: ID optional_template_arguments_in_angles sparse_range_list 132 | ID optional_template_arguments_in_angles 133 | ID optional_template_arguments_in_angles connection_actuals_list 134 | ID optional_template_arguments_in_angles '=' alias_list 135 connection_statement: member_index_expr connection_actuals_list ';' 136 instance_type_completion_statement: index_expr complex_expr_optional_list_in_angles ';' 137 | generic_id complex_expr_optional_list_in_angles ';' 138 instance_type_completion_connection_statement: index_expr complex_expr_optional_list_in_angles connection_actuals_list ';' 139 | generic_id complex_expr_optional_list_in_angles connection_actuals_list ';' 140 nonempty_alias_list: nonempty_alias_list '=' complex_aggregate_reference 141 | complex_aggregate_reference '=' complex_aggregate_reference 142 alias_list: alias_list '=' complex_aggregate_reference 143 | complex_aggregate_reference 144 connection_actuals_list: '(' complex_aggregate_reference_list ')' 145 guarded_instance_management_list: guarded_instance_management_list_unmatched THICKBAR instance_management_else_clause 146 | guarded_instance_management_list_unmatched 147 guarded_instance_management_list_unmatched: guarded_instance_management_list_unmatched THICKBAR guarded_instance_management 148 | guarded_instance_management 149 guarded_instance_management: expr RARROW instance_management_list 150 instance_management_else_clause: ELSE RARROW instance_management_list 151 language_body: CHP_LANG '{' chp_body '}' 152 | HSE_LANG '{' hse_body '}' 153 | PRS_LANG '{' prs_body '}' 154 | SPEC_LANG '{' spec_body '}' 155 chp_body: full_chp_body_item_list 156 chp_body_optional: chp_body 157 | /* empty */ 158 chp_body_or_skip: chp_body 159 | SKIP 160 chp_sequence_group: '{' full_chp_body_item_list '}' 161 full_chp_body_item_list: full_chp_body_item_list ';' full_chp_body_item 162 | full_chp_body_item 163 full_chp_body_item: chp_concurrent_group 164 chp_body_item: chp_statement_attributes chp_statement 165 | chp_statement 166 chp_statement_attributes: '$' '(' chp_statement_attr_list ')' 167 chp_statement_attr_list: chp_statement_attr_list ';' chp_statement_attr 168 | chp_statement_attr 169 chp_statement_attr: ID '=' expr 170 chp_statement: chp_loop 171 | chp_do_until 172 | chp_selection 173 | chp_wait 174 | chp_binary_assignment 175 | chp_bool_assignment 176 | chp_send 177 | chp_recv 178 | chp_peek 179 | LOG expr_list_in_parens 180 | chp_metaloop_selection 181 | chp_metaloop_statement 182 | function_call_expr 183 chp_loop: BEGINLOOP chp_body ']' 184 chp_do_until: BEGINLOOP chp_unmatched_det_guarded_command_list ']' 185 chp_wait: '[' chp_guard_expr ']' 186 chp_selection: '[' chp_matched_det_guarded_command_list ']' 187 | '[' chp_nondet_guarded_command_list ']' 188 chp_metaloop_selection: '[' ':' ID ':' range ':' chp_guarded_command ']' 189 | '[' THICKBAR ID ':' range ':' chp_guarded_command ']' 190 chp_metaloop_statement: '{' ',' ID ':' range ':' chp_body '}' 191 | '{' ';' ID ':' range ':' chp_body '}' 192 chp_nondet_guarded_command_list: chp_nondet_guarded_command_list ':' chp_guarded_command 193 | chp_guarded_command ':' chp_guarded_command 194 chp_matched_det_guarded_command_list: chp_unmatched_det_guarded_command_list THICKBAR chp_else_clause 195 | chp_unmatched_det_guarded_command_list 196 chp_unmatched_det_guarded_command_list: chp_unmatched_det_guarded_command_list THICKBAR chp_guarded_command 197 | chp_guarded_command 198 chp_guarded_command: chp_guard_expr RARROW chp_body_or_skip 199 chp_guard_expr: chp_logical_or_expr 200 chp_unary_bool_expr: chp_simple_bool_expr 201 | chp_not_expr 202 | '(' chp_logical_or_expr ')' 203 | chp_probe_expr 204 | function_call_expr 205 chp_probe_expr: '#' member_index_expr 206 chp_simple_bool_expr: member_index_expr 207 | BOOL_TRUE 208 | BOOL_FALSE 209 chp_unary_expr: '-' chp_unary_expr 210 | chp_unary_bool_expr 211 | loop_expr 212 | INT 213 | FLOAT 214 chp_mult_expr: chp_unary_expr 215 | chp_mult_expr muldiv_op chp_unary_expr 216 chp_add_expr: chp_mult_expr 217 | chp_add_expr_only 218 chp_add_expr_only: chp_add_expr '+' chp_mult_expr 219 | chp_add_expr '-' chp_mult_expr 220 chp_paren_add_expr: '(' chp_add_expr_only ')' 221 | chp_mult_expr 222 chp_shift_expr: chp_paren_add_expr 223 | chp_shift_expr EXTRACT chp_add_expr 224 | chp_shift_expr INSERT chp_add_expr 225 chp_relational_expr: chp_shift_expr relational_op chp_shift_expr 226 | chp_unary_bool_expr 227 chp_bitwise_and_expr: chp_relational_expr 228 | chp_bitwise_and_expr '&' chp_relational_expr 229 chp_bitwise_xor_expr: chp_bitwise_and_expr 230 | chp_bitwise_xor_expr '^' chp_bitwise_and_expr 231 chp_bitwise_or_expr: chp_bitwise_xor_expr 232 | chp_bitwise_or_expr '|' chp_bitwise_xor_expr 233 chp_logical_and_expr: chp_bitwise_or_expr 234 | chp_logical_and_expr LOGICAL_AND chp_bitwise_or_expr 235 chp_logical_or_expr: chp_logical_and_expr 236 | chp_logical_or_expr LOGICAL_OR chp_logical_and_expr 237 chp_not_expr: '~' chp_unary_bool_expr 238 chp_else_clause: ELSE RARROW chp_body_or_skip 239 chp_binary_assignment: member_index_expr ASSIGN expr 240 chp_bool_assignment: member_index_expr '+' 241 | member_index_expr '-' 242 chp_concurrent_item: chp_body_item 243 | chp_sequence_group 244 chp_concurrent_group: chp_concurrent_group ',' chp_concurrent_item 245 | chp_concurrent_item 246 chp_send: member_index_expr '!' connection_actuals_list 247 | member_index_expr '!' 248 chp_recv: member_index_expr '?' member_index_expr_list_in_parens_optional 249 chp_peek: member_index_expr '#' member_index_expr_list_in_parens 250 hse_body: full_hse_body_item_list 251 full_hse_body_item_list: full_hse_body_item_list ';' full_hse_body_item 252 | full_hse_body_item 253 full_hse_body_item: hse_body_item 254 hse_body_item: hse_loop 255 | hse_do_until 256 | hse_wait 257 | hse_selection 258 | hse_assignment 259 | SKIP 260 hse_loop: BEGINLOOP hse_body ']' 261 hse_do_until: BEGINLOOP hse_matched_det_guarded_command_list ']' 262 hse_wait: '[' expr ']' 263 hse_selection: '[' hse_matched_det_guarded_command_list ']' 264 | '[' hse_nondet_guarded_command_list ']' 265 hse_guarded_command: expr RARROW hse_body 266 hse_else_clause: ELSE RARROW hse_body 267 hse_nondet_guarded_command_list: hse_nondet_guarded_command_list ':' hse_guarded_command 268 | hse_guarded_command ':' hse_guarded_command 269 hse_matched_det_guarded_command_list: hse_unmatched_det_guarded_command_list THICKBAR hse_else_clause 270 | hse_unmatched_det_guarded_command_list 271 hse_unmatched_det_guarded_command_list: hse_unmatched_det_guarded_command_list THICKBAR hse_guarded_command 272 | hse_guarded_command 273 hse_assignment: unary_assignment 274 prs_body: prs_body prs_body_item 275 | prs_body_item 276 prs_body_item: single_prs 277 | prs_loop 278 | prs_conditional 279 | prs_macro 280 prs_macro: prs_literal mandatory_member_index_expr_list_in_parens 281 prs_loop: '(' ':' ID ':' range ':' prs_body ')' 282 prs_conditional: '[' prs_guarded_body prs_else_clause_optional ']' 283 prs_guarded_body: expr RARROW prs_body 284 prs_else_clause_optional: prs_else_clause 285 | /* empty */ 286 prs_else_clause: THICKBAR ELSE RARROW prs_body 287 single_prs: prs_rule_attribute_list_in_brackets prs_expr prs_arrow relative_member_index_expr dir 288 | prs_expr prs_arrow relative_member_index_expr dir 289 prs_rule_attribute_list_in_brackets: '[' prs_rule_attribute_list ']' 290 prs_rule_attribute_list: prs_rule_attribute_list ';' prs_rule_attribute 291 | prs_rule_attribute 292 prs_rule_attribute: ID '=' expr_list 293 prs_arrow: RARROW 294 | IMPLIES 295 dir: '+' 296 | '-' 297 prs_expr: prs_or 298 prs_paren_expr: '(' prs_expr ')' 299 prs_literal: relative_member_index_expr expr_list_in_angles_optional 300 prs_unary_expr: prs_literal 301 | prs_paren_expr 302 | prs_and_loop 303 | prs_or_loop 304 prs_not: '~' prs_unary_expr 305 | prs_unary_expr 306 prs_and: prs_and '&' prs_not 307 | prs_not 308 prs_or: prs_or '|' prs_and 309 | prs_and 310 prs_and_loop: '(' '&' ':' ID ':' range ':' prs_expr ')' 311 prs_or_loop: '(' '|' ':' ID ':' range ':' prs_expr ')' 312 spec_body: spec_body spec_item 313 | spec_item 314 spec_item: spec_directive 315 spec_directive: ID expr_list_in_angles_optional grouped_reference_list_in_parens 316 grouped_reference_list_in_parens: '(' grouped_reference_list ')' 317 grouped_reference_list: grouped_reference_list ',' grouped_reference 318 | grouped_reference 319 grouped_reference: '{' mandatory_member_index_expr_list '}' 320 | member_index_expr 321 paren_expr: '(' expr ')' 322 literal: INT 323 | FLOAT 324 | string 325 | BOOL_TRUE 326 | BOOL_FALSE 327 string: string STRING 328 | STRING 329 id_expr: generic_id 330 generic_id: relative_id 331 | absolute_id 332 absolute_id: SCOPE relative_id 333 relative_id: qualified_id 334 | ID 335 qualified_id: qualified_id SCOPE ID 336 | ID SCOPE ID 337 mandatory_member_index_expr_list_in_parens: '(' mandatory_member_index_expr_list ')' 338 mandatory_member_index_expr_list: mandatory_member_index_expr_list ',' member_index_expr 339 | member_index_expr 340 member_index_expr_list: member_index_expr_list ',' optional_member_index_expr 341 | optional_member_index_expr 342 optional_member_index_expr: member_index_expr 343 | /* empty */ 344 member_index_expr: id_expr 345 | index_expr 346 | member_expr 347 relative_member_index_expr: ID 348 | local_index_expr 349 | local_member_expr 350 local_index_expr: local_member_expr sparse_range_list 351 | ID sparse_range_list 355 index_expr: member_expr sparse_range_list 356 | id_expr sparse_range_list 360 simple_expr: member_index_expr 361 | literal 362 unary_expr: simple_expr 363 | function_call_expr 364 | paren_expr 365 | loop_expr 366 | '-' unary_expr 367 | '!' unary_expr 368 | '~' unary_expr 369 function_call_expr: member_index_expr connection_actuals_list 370 multiplicative_expr: unary_expr 371 | multiplicative_expr muldiv_op unary_expr 372 muldiv_op: '*' 373 | '/' 374 | '%' 375 additive_expr: multiplicative_expr 376 | additive_expr '+' multiplicative_expr 377 | additive_expr '-' multiplicative_expr 378 shift_expr: additive_expr 379 | shift_expr EXTRACT additive_expr 380 | shift_expr INSERT additive_expr 381 relational_equality_expr: shift_expr 382 | '(' relational_equality_expr '<' shift_expr ')' 383 | '(' relational_equality_expr '>' shift_expr ')' 384 | relational_equality_expr LE shift_expr 385 | relational_equality_expr GE shift_expr 386 | relational_equality_expr EQUAL shift_expr 387 | relational_equality_expr NOTEQUAL shift_expr 388 relational_op: '<' 389 | '>' 390 | LE 391 | GE 392 | EQUAL 393 | NOTEQUAL 394 and_expr: relational_equality_expr 395 | and_expr '&' relational_equality_expr 396 exclusive_or_expr: and_expr 397 | exclusive_or_expr '^' and_expr 398 inclusive_or_expr: exclusive_or_expr 399 | inclusive_or_expr '|' exclusive_or_expr 400 logical_and_expr: inclusive_or_expr 401 | logical_and_expr LOGICAL_AND inclusive_or_expr 402 logical_or_expr: logical_and_expr 403 | logical_or_expr LOGICAL_OR logical_and_expr 404 unary_assignment: member_index_expr PLUSPLUS 405 | member_index_expr MINUSMINUS 406 loop_expr: '(' loop_assoc_op ':' ID ':' range ':' expr ')' 407 loop_assoc_op: '+' 408 | '*' 409 | '&' 410 | '|' 411 | '^' 412 | LOGICAL_AND 413 | LOGICAL_OR 414 expr: logical_or_expr 415 strict_relaxed_template_arguments: complex_expr_optional_list_in_angles optional_template_arguments_in_angles 416 | /* empty */ 417 optional_template_arguments_in_angles: complex_expr_optional_list_in_angles 418 | /* empty */ 419 expr_list_in_angles_optional: expr_list_in_angles 420 | /* empty */ 421 expr_list_in_angles: '<' expr_list '>' 422 complex_expr_optional_list_in_angles: '<' complex_expr_optional_list '>' 423 complex_expr_optional_list: complex_expr_optional_list ',' optional_complex_expr 424 | optional_complex_expr 425 optional_complex_expr: array_concatenation 426 | /* empty */ 427 member_index_expr_list_in_parens_optional: member_index_expr_list_in_parens 428 | /* empty */ 429 member_index_expr_list_in_parens: '(' member_index_expr_list ')' 430 expr_list_in_parens: '(' expr_list ')' 431 expr_list: expr_list ',' expr 432 | expr 433 range: expr RANGE expr 434 | expr 435 optional_dense_range_list: dense_range_list 436 | /* empty */ 437 dense_range_list: dense_range_list bracketed_dense_range 438 | bracketed_dense_range 439 sparse_range_list: sparse_range_list bracketed_sparse_range 440 | bracketed_sparse_range 441 bracketed_dense_range: '[' expr ']' 442 bracketed_sparse_range: '[' range ']' 443 complex_aggregate_reference: array_concatenation 444 array_concatenation: array_concatenation '#' complex_expr_term 445 | complex_expr_term 446 complex_expr_term: array_construction 447 | expr 448 array_construction: '{' mandatory_complex_aggregate_reference_list '}' 449 optional_complex_aggregate_reference: complex_aggregate_reference 450 | /* empty */ 451 mandatory_complex_aggregate_reference_list: mandatory_complex_aggregate_reference_list ',' complex_aggregate_reference 452 | complex_aggregate_reference 453 complex_aggregate_reference_list: complex_aggregate_reference_list ',' optional_complex_aggregate_reference 454 | optional_complex_aggregate_reference