"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_extended
18 | type_alias
19 namespace_management: NAMESPACE ID '{' top_root '}'
20 | OPEN namespace_id RARROW ID ';'
21 | OPEN namespace_id ';'
22 namespace_id: relative_id
23 definition: defproc
24 | defdatatype
25 | defchan
26 | defenum
27 prototype_declaration: declare_proc_proto ';'
28 | declare_datatype_proto ';'
29 | declare_chan_proto ';'
30 | declare_enum ';'
31 type_alias: optional_export optional_template_specification TYPEDEF physical_type_ref ID ';'
32 template_specification: TEMPLATE template_formal_decl_list_in_angles
33 | TEMPLATE template_formal_decl_list_optional_in_angles template_formal_decl_nodefault_list_in_angles
34 optional_template_specification: template_specification
35 | /* empty */
36 optional_export: EXPORT
37 | /* empty */
38 def_or_proc: DEFINE
39 | DEFPROC
40 declare_proc_proto: optional_export optional_template_specification def_or_proc ID optional_port_formal_decl_list_in_parens
41 defproc: declare_proc_proto '{' optional_definition_body '}'
42 optional_port_formal_decl_list_in_parens: '(' port_formal_decl_list ')'
43 | '(' ')'
44 template_formal_decl_list_in_angles: '<' template_formal_decl_list '>'
45 template_formal_decl_nodefault_list_in_angles: '<' template_formal_decl_nodefault_list '>'
46 template_formal_decl_list_optional_in_angles: template_formal_decl_list_in_angles
47 | '<' '>'
48 template_formal_decl_list: template_formal_decl_list ';' template_formal_decl
49 | template_formal_decl
50 template_formal_decl_nodefault_list: template_formal_decl_nodefault_list ';' template_formal_decl_nodefault
51 | template_formal_decl_nodefault
52 template_formal_decl: base_param_type template_formal_id_list
53 template_formal_decl_nodefault: base_param_type template_formal_id_nodefault_list
54 template_formal_id_list: template_formal_id_list ',' template_formal_id
55 | template_formal_id
56 template_formal_id_nodefault_list: template_formal_id_nodefault_list ',' template_formal_id_nodefault
57 | template_formal_id_nodefault
58 template_formal_id_default: ID optional_dense_range_list '=' expr
59 template_formal_id_nodefault: ID optional_dense_range_list
60 template_formal_id: template_formal_id_default
61 | template_formal_id_nodefault
62 port_formal_decl_list: port_formal_decl_list ';' port_formal_decl
63 | port_formal_decl
64 port_formal_decl: physical_type_ref port_formal_id_list
65 port_formal_id_list: port_formal_id_list ',' port_formal_id
66 | port_formal_id
67 port_formal_id: ID optional_dense_range_list
68 generic_type_ref: generic_id strict_relaxed_template_arguments optional_chan_dir
69 optional_chan_dir: '?'
70 | '!'
71 | '?' '?'
72 | '!' '!'
73 | /* empty */
74 physical_type_ref: generic_type_ref
75 | base_chan_type
76 | base_data_type_ref
77 base_data_type_ref: base_data_type strict_relaxed_template_arguments
78 data_type_ref: base_data_type_ref
79 | generic_type_ref
80 type_id: physical_type_ref
81 | base_param_type
82 base_param_type: PINT_TYPE
83 | PBOOL_TYPE
84 | PREAL_TYPE
85 base_chan_type: chan_or_port data_type_ref_list_optional_in_parens
86 chan_or_port: CHANNEL optional_chan_dir
87 data_type_ref_list_optional_in_parens: '(' data_type_ref_list_optional ')'
88 data_type_ref_list_optional: data_type_ref_list
89 | /* empty */
90 data_type_ref_list: data_type_ref_list ',' data_type_ref
91 | data_type_ref
92 base_data_type: INT_TYPE
93 | BOOL_TYPE
94 declare_datatype_proto: optional_export optional_template_specification DEFTYPE ID DEFINEOP data_type_ref optional_port_formal_decl_list_in_parens
95 defdatatype: declare_datatype_proto '{' optional_datatype_body set_body_optional get_body_optional '}'
96 set_body_optional: set_body
97 | /* empty */
98 get_body_optional: get_body
99 | /* empty */
100 set_body: SET '{' chp_body_optional '}'
101 get_body: GET '{' chp_body_optional '}'
102 declare_enum: ENUM ID
103 defenum: ENUM ID '{' enum_member_list '}'
104 enum_member_list: enum_member_list ',' ID
105 | ID
106 declare_chan_proto: optional_export optional_template_specification DEFCHAN ID DEFINEOP base_chan_type optional_port_formal_decl_list_in_parens
107 defchan: declare_chan_proto '{' optional_datatype_body send_body_optional recv_body_optional '}'
108 send_body_optional: send_body
109 | /* empty */
110 recv_body_optional: recv_body
111 | /* empty */
112 send_body: SEND '{' chp_body_optional '}'
113 recv_body: RECV '{' chp_body_optional '}'
114 definition_body: definition_body definition_body_item
115 | definition_body_item
116 definition_body_item: instance_item_extended
117 | type_alias
118 optional_definition_body: definition_body
119 | /* empty */
120 optional_datatype_body: datatype_body
121 | /* empty */
122 datatype_body: datatype_body datatype_body_item
123 | datatype_body_item
124 datatype_body_item: connection_body_item
125 | lang_spec
126 connection_body_optional: connection_body
127 | /* empty */
128 connection_body: connection_body connection_body_item
129 | connection_body_item
130 connection_body_item_base: connection_statement
131 | nonempty_alias_list ';'
132 | instance_type_completion_statement
133 | instance_type_completion_connection_statement
134 | instance_attribute_statement
135 connection_body_item: connection_body_item_base
136 | loop_connections
137 | conditional_connections
138 instance_management_list_optional: instance_management_list
139 | /* empty */
140 instance_management_list: instance_management_list instance_item_extended
141 | instance_item_extended
142 instance_item_extended: instance_item
143 | language_body
144 instance_item: type_instance_declaration
145 | connection_body_item_base
146 | loop_instantiation
147 | conditional_instantiation
148 loop_instantiation: '(' ';' ID ':' range ':' instance_management_list ')'
149 conditional_instantiation: '[' guarded_instance_management_list ']'
150 loop_connections: '(' ';' ID ':' range ':' connection_body ')'
151 conditional_connections: '[' guarded_connection_body ']'
152 type_instance_declaration: type_id instance_id_list ';'
153 instance_id_list: instance_id_list ',' instance_id_item
154 | instance_id_item
155 instance_id_item: ID optional_template_arguments_in_angles sparse_range_list
156 | ID optional_template_arguments_in_angles
157 | ID optional_template_arguments_in_angles connection_actuals_list
158 | ID optional_template_arguments_in_angles '=' alias_list
159 connection_statement: member_index_expr connection_actuals_list ';'
160 generic_attribute: ID '=' expr_list
161 | ID
162 generic_attribute_list: generic_attribute_list ';' generic_attribute
163 | generic_attribute
164 generic_attribute_list_in_brackets: '[' generic_attribute_list ']'
165 instance_type_completion_statement: index_expr complex_expr_optional_list_in_angles ';'
166 | generic_id complex_expr_optional_list_in_angles ';'
167 instance_attribute_statement: member_index_expr '@' generic_attribute_list_in_brackets ';'
168 instance_type_completion_connection_statement: index_expr complex_expr_optional_list_in_angles connection_actuals_list ';'
169 | generic_id complex_expr_optional_list_in_angles connection_actuals_list ';'
170 nonempty_alias_list: nonempty_alias_list '=' complex_aggregate_reference
171 | complex_aggregate_reference '=' complex_aggregate_reference
172 alias_list: alias_list '=' complex_aggregate_reference
173 | complex_aggregate_reference
174 connection_actuals_list: '(' complex_aggregate_reference_list ')'
175 guarded_instance_management_list: guarded_instance_management_list_unmatched THICKBAR instance_management_else_clause
176 | guarded_instance_management_list_unmatched
177 guarded_instance_management_list_unmatched: guarded_instance_management_list_unmatched THICKBAR guarded_instance_management
178 | guarded_instance_management
179 guarded_instance_management: expr RARROW instance_management_list_optional
180 instance_management_else_clause: ELSE RARROW instance_management_list_optional
181 guarded_connection_body: guarded_connection_body_unmatched THICKBAR connection_body_else_clause
182 | guarded_connection_body_unmatched
183 guarded_connection_body_unmatched: guarded_connection_body_unmatched THICKBAR guarded_connection_body_clause
184 | guarded_connection_body_clause
185 guarded_connection_body_clause: expr RARROW connection_body_optional
186 connection_body_else_clause: ELSE RARROW connection_body_optional
187 language_body: CHP_LANG '{' chp_body_optional '}'
188 | HSE_LANG '{' hse_body_optional '}'
189 | PRS_LANG optional_template_arguments_in_angles '{' prs_body_optional '}'
190 | lang_spec
191 lang_spec: SPEC_LANG '{' spec_body_optional '}'
192 chp_body: full_chp_body_item_list
193 chp_body_optional: chp_body
194 | /* empty */
195 chp_body_or_skip: chp_body
196 | SKIP
197 chp_sequence_group: '{' full_chp_body_item_list '}'
198 full_chp_body_item_list: full_chp_body_item_list ';' full_chp_body_item
199 | full_chp_body_item
200 full_chp_body_item: chp_concurrent_group
201 chp_body_item: chp_statement_attributes chp_statement
202 | chp_statement
203 chp_statement_attributes: '$' '(' generic_attribute_list ')'
204 chp_statement: chp_loop
205 | chp_do_until
206 | chp_selection
207 | chp_wait
208 | chp_binary_assignment
209 | chp_bool_assignment
210 | chp_send
211 | chp_recv
212 | chp_peek
213 | LOG expr_list_in_parens
214 | chp_metaloop_selection
215 | chp_metaloop_statement
216 | function_call_expr
217 chp_loop: BEGINLOOP chp_body ']'
218 chp_do_until: BEGINLOOP chp_unmatched_det_guarded_command_list ']'
219 chp_wait: '[' chp_guard_expr ']'
220 chp_selection: '[' chp_matched_det_guarded_command_list ']'
221 | '[' chp_nondet_guarded_command_list ']'
222 chp_metaloop_selection: '[' ':' ID ':' range ':' chp_guarded_command ']'
223 | '[' THICKBAR ID ':' range ':' chp_guarded_command ']'
224 chp_metaloop_statement: '{' ',' ID ':' range ':' chp_body '}'
225 | '{' ';' ID ':' range ':' chp_body '}'
226 chp_nondet_guarded_command_list: chp_nondet_guarded_command_list ':' chp_guarded_command
227 | chp_guarded_command ':' chp_guarded_command
228 chp_matched_det_guarded_command_list: chp_unmatched_det_guarded_command_list THICKBAR chp_else_clause
229 | chp_unmatched_det_guarded_command_list
230 chp_unmatched_det_guarded_command_list: chp_unmatched_det_guarded_command_list THICKBAR chp_guarded_command
231 | chp_guarded_command
232 chp_guarded_command: chp_guard_expr RARROW chp_body_or_skip
233 chp_guard_expr: chp_logical_or_expr
234 chp_unary_bool_expr: chp_simple_bool_expr
235 | chp_not_expr
236 | '(' chp_logical_or_expr ')'
237 | chp_probe_expr
238 | function_call_expr
239 chp_probe_expr: '#' member_index_expr
240 chp_simple_bool_expr: member_index_expr
241 | BOOL_TRUE
242 | BOOL_FALSE
243 chp_unary_expr: '-' chp_unary_expr
244 | chp_unary_bool_expr
245 | loop_expr
246 | INT
247 | FLOAT
248 chp_mult_expr: chp_unary_expr
249 | chp_mult_expr muldiv_op chp_unary_expr
250 chp_add_expr: chp_mult_expr
251 | chp_add_expr_only
252 chp_add_expr_only: chp_add_expr '+' chp_mult_expr
253 | chp_add_expr '-' chp_mult_expr
254 chp_paren_add_expr: '(' chp_add_expr_only ')'
255 | chp_mult_expr
256 chp_shift_expr: chp_paren_add_expr
257 | chp_shift_expr EXTRACT chp_add_expr
258 | chp_shift_expr INSERT chp_add_expr
259 chp_relational_expr: chp_shift_expr relational_op chp_shift_expr
260 | chp_paren_add_expr
261 chp_bitwise_and_expr: chp_relational_expr
262 | chp_bitwise_and_expr '&' chp_relational_expr
263 chp_bitwise_xor_expr: chp_bitwise_and_expr
264 | chp_bitwise_xor_expr '^' chp_bitwise_and_expr
265 chp_bitwise_or_expr: chp_bitwise_xor_expr
266 | chp_bitwise_or_expr '|' chp_bitwise_xor_expr
267 chp_logical_and_expr: chp_bitwise_or_expr
268 | chp_logical_and_expr LOGICAL_AND chp_bitwise_or_expr
269 chp_logical_or_expr: chp_logical_and_expr
270 | chp_logical_or_expr LOGICAL_OR chp_logical_and_expr
271 chp_not_expr: '~' chp_unary_bool_expr
272 chp_else_clause: ELSE RARROW chp_body_or_skip
273 chp_binary_assignment: member_index_expr ASSIGN expr
274 chp_bool_assignment: member_index_expr '+'
275 | member_index_expr '-'
276 chp_concurrent_item: chp_body_item
277 | chp_sequence_group
278 chp_concurrent_group: chp_concurrent_group ',' chp_concurrent_item
279 | chp_concurrent_item
280 chp_send: member_index_expr '!' connection_actuals_list
281 | member_index_expr '!'
282 chp_recv: member_index_expr '?' member_index_expr_list_in_parens_optional
283 chp_peek: member_index_expr '#' member_index_expr_list_in_parens
284 hse_body_optional: hse_body
285 | /* empty */
286 hse_body: full_hse_body_item_list
287 full_hse_body_item_list: full_hse_body_item_list ';' full_hse_body_item
288 | full_hse_body_item
289 full_hse_body_item: hse_body_item
290 hse_body_item: hse_loop
291 | hse_do_until
292 | hse_wait
293 | hse_selection
294 | hse_assignment
295 | SKIP
296 hse_loop: BEGINLOOP hse_body ']'
297 hse_do_until: BEGINLOOP hse_matched_det_guarded_command_list ']'
298 hse_wait: '[' expr ']'
299 hse_selection: '[' hse_matched_det_guarded_command_list ']'
300 | '[' hse_nondet_guarded_command_list ']'
301 hse_guarded_command: expr RARROW hse_body
302 hse_else_clause: ELSE RARROW hse_body
303 hse_nondet_guarded_command_list: hse_nondet_guarded_command_list ':' hse_guarded_command
304 | hse_guarded_command ':' hse_guarded_command
305 hse_matched_det_guarded_command_list: hse_unmatched_det_guarded_command_list THICKBAR hse_else_clause
306 | hse_unmatched_det_guarded_command_list
307 hse_unmatched_det_guarded_command_list: hse_unmatched_det_guarded_command_list THICKBAR hse_guarded_command
308 | hse_guarded_command
309 hse_assignment: unary_assignment
310 prs_body_optional: prs_body
311 | /* empty */
312 prs_body: prs_body prs_body_item
313 | prs_body_item
314 prs_body_item: single_prs
315 | prs_loop
316 | prs_conditional
317 | prs_macro
318 | TREE_LANG optional_template_arguments_in_angles '{' prs_body_optional '}'
319 | SUBCKT_LANG optional_template_arguments_in_angles '{' prs_body_optional '}'
320 prs_macro: prs_literal mandatory_member_index_expr_list_in_parens
321 | generic_attribute_list_in_brackets prs_literal mandatory_member_index_expr_list_in_parens
322 prs_loop: '(' ':' ID ':' range ':' prs_body ')'
323 prs_conditional: '[' prs_guarded_list ']'
324 prs_guarded_list: prs_guarded_list_unmatched THICKBAR prs_else_clause
325 | prs_guarded_list_unmatched
326 prs_guarded_list_unmatched: prs_guarded_list_unmatched THICKBAR prs_guarded_body
327 | prs_guarded_body
328 prs_guarded_body: expr RARROW prs_body_optional
329 prs_else_clause: ELSE RARROW prs_body_optional
330 single_prs: generic_attribute_list_in_brackets prs_expr prs_arrow prs_literal_base dir
331 | prs_expr prs_arrow prs_literal_base dir
332 prs_arrow: RARROW
333 | IMPLIES
334 | HASH_ARROW
335 dir: '+'
336 | '-'
337 prs_expr: prs_or
338 prs_paren_expr: '(' prs_expr ')'
339 prs_literal_base: relative_member_index_expr
340 | '@' ID optional_dense_range_list
341 prs_literal: prs_literal_base prs_literal_params_in_angles_optional
342 prs_literal_params_in_angles_optional: '<' prs_literal_params_optional ';' generic_attribute_list '>'
343 | '<' prs_literal_params '>'
344 | /* empty */
345 prs_literal_params_optional: prs_literal_params
346 | /* empty */
347 prs_literal_params: prs_literal_params ',' prs_literal_param
348 | prs_literal_param
349 prs_literal_param: expr
350 prs_unary_expr: prs_literal
351 | prs_paren_expr
352 | prs_and_loop
353 | prs_or_loop
354 prs_not: '~' prs_unary_expr
355 | prs_unary_expr
356 prs_and: prs_and '&' prs_operator_attribute_optional prs_not
357 | prs_not
358 prs_or: prs_or '|' prs_and
359 | prs_and
360 prs_operator_attribute: '{' dir prs_expr '}'
361 prs_operator_attribute_optional: prs_operator_attribute
362 | /* empty */
363 prs_and_loop: '(' '&' ':' ID ':' range ':' prs_expr ')'
364 prs_or_loop: '(' '|' ':' ID ':' range ':' prs_expr ')'
365 spec_body_optional: spec_body
366 | /* empty */
367 spec_body: spec_body spec_item
368 | spec_item
369 spec_item: spec_directive
370 | spec_invariant
371 spec_invariant: '$' '(' prs_expr ')'
372 spec_directive: ID expr_list_in_angles_optional grouped_reference_list_in_parens
373 grouped_reference_list_in_parens: '(' grouped_reference_list ')'
374 grouped_reference_list: grouped_reference_list ',' grouped_reference
375 | grouped_reference
376 grouped_reference: '{' mandatory_member_index_expr_list '}'
377 | member_index_expr
378 paren_expr: '(' expr ')'
379 literal: INT
380 | FLOAT
381 | string
382 | BOOL_TRUE
383 | BOOL_FALSE
384 string: string STRING
385 | STRING
386 id_expr: generic_id
387 generic_id: relative_id
388 | absolute_id
389 absolute_id: SCOPE relative_id
390 relative_id: qualified_id
391 | ID
392 qualified_id: qualified_id SCOPE ID
393 | ID SCOPE ID
394 mandatory_member_index_expr_list_in_parens: '(' mandatory_member_index_expr_list ')'
395 mandatory_member_index_expr_list: mandatory_member_index_expr_list ',' member_index_expr
396 | member_index_expr
397 member_index_expr_list: member_index_expr_list ',' optional_member_index_expr
398 | optional_member_index_expr
399 optional_member_index_expr: member_index_expr
400 | /* empty */
401 member_index_expr: id_expr
402 | index_expr
403 | member_expr
404 relative_member_index_expr: ID
405 | local_index_expr
406 | local_member_expr
407 local_index_expr: local_member_expr sparse_range_list
408 | ID sparse_range_list
412 index_expr: member_expr sparse_range_list
413 | id_expr sparse_range_list
417 simple_expr: member_index_expr
418 | literal
419 unary_expr: simple_expr
420 | function_call_expr
421 | paren_expr
422 | loop_expr
423 | '-' unary_expr
424 | '!' unary_expr
425 | '~' unary_expr
426 function_call_expr: member_index_expr connection_actuals_list
427 multiplicative_expr: unary_expr
428 | multiplicative_expr muldiv_op unary_expr
429 muldiv_op: '*'
430 | '/'
431 | '%'
432 additive_expr: multiplicative_expr
433 | additive_expr '+' multiplicative_expr
434 | additive_expr '-' multiplicative_expr
435 shift_expr: additive_expr
436 | shift_expr EXTRACT additive_expr
437 | shift_expr INSERT additive_expr
438 relational_equality_expr: shift_expr
439 | '(' relational_equality_expr '<' shift_expr ')'
440 | '(' relational_equality_expr '>' shift_expr ')'
441 | relational_equality_expr LE shift_expr
442 | relational_equality_expr GE shift_expr
443 | relational_equality_expr EQUAL shift_expr
444 | relational_equality_expr NOTEQUAL shift_expr
445 | '(' relational_equality_expr '=' shift_expr ')'
446 relational_op: '<'
447 | '>'
448 | LE
449 | GE
450 | EQUAL
451 | NOTEQUAL
452 and_expr: relational_equality_expr
453 | and_expr '&' relational_equality_expr
454 exclusive_or_expr: and_expr
455 | exclusive_or_expr '^' and_expr
456 inclusive_or_expr: exclusive_or_expr
457 | inclusive_or_expr '|' exclusive_or_expr
458 logical_and_expr: inclusive_or_expr
459 | logical_and_expr LOGICAL_AND inclusive_or_expr
460 logical_or_expr: logical_and_expr
461 | logical_or_expr LOGICAL_OR logical_and_expr
462 unary_assignment: member_index_expr PLUSPLUS
463 | member_index_expr MINUSMINUS
464 loop_expr: '(' loop_assoc_op ':' ID ':' range ':' expr ')'
465 loop_assoc_op: '+'
466 | '*'
467 | '&'
468 | '|'
469 | '^'
470 | LOGICAL_AND
471 | LOGICAL_OR
472 expr: logical_or_expr
473 strict_relaxed_template_arguments: complex_expr_optional_list_in_angles optional_template_arguments_in_angles
474 | /* empty */
475 optional_template_arguments_in_angles: complex_expr_optional_list_in_angles
476 | /* empty */
477 expr_list_in_angles_optional: expr_list_in_angles
478 | /* empty */
479 expr_list_in_angles: '<' expr_list '>'
480 complex_expr_optional_list_in_angles: '<' complex_expr_optional_list '>'
481 complex_expr_optional_list: complex_expr_optional_list ',' optional_complex_expr
482 | optional_complex_expr
483 optional_complex_expr: array_concatenation
484 | /* empty */
485 member_index_expr_list_in_parens_optional: member_index_expr_list_in_parens
486 | /* empty */
487 member_index_expr_list_in_parens: '(' member_index_expr_list ')'
488 expr_list_in_parens: '(' expr_list ')'
489 expr_list: expr_list ',' expr
490 | expr
491 range: expr RANGE expr
492 | expr
493 optional_dense_range_list: dense_range_list
494 | /* empty */
495 dense_range_list: dense_range_list bracketed_dense_range
496 | bracketed_dense_range
497 sparse_range_list: sparse_range_list bracketed_sparse_range
498 | bracketed_sparse_range
499 bracketed_dense_range: '[' expr ']'
500 bracketed_sparse_range: '[' range ']'
501 complex_aggregate_reference: array_concatenation
502 array_concatenation: array_concatenation '#' complex_expr_term
503 | complex_expr_term
504 complex_expr_term: array_construction
505 | expr
506 array_construction: '{' mandatory_complex_aggregate_reference_list '}'
507 optional_complex_aggregate_reference: complex_aggregate_reference
508 | /* empty */
509 mandatory_complex_aggregate_reference_list: mandatory_complex_aggregate_reference_list ',' complex_aggregate_reference
510 | complex_aggregate_reference
511 complex_aggregate_reference_list: complex_aggregate_reference_list ',' optional_complex_aggregate_reference
512 | optional_complex_aggregate_reference