"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 get_body '}'
96 set_body: SET '{' chp_body_optional '}'
97 get_body: GET '{' chp_body_optional '}'
98 declare_enum: ENUM ID
99 defenum: ENUM ID '{' enum_member_list '}'
100 enum_member_list: enum_member_list ',' ID
101 | ID
102 declare_chan_proto: optional_export optional_template_specification DEFCHAN ID DEFINEOP base_chan_type optional_port_formal_decl_list_in_parens
103 defchan: declare_chan_proto '{' optional_datatype_body send_body recv_body '}'
104 send_body: SEND '{' chp_body_optional '}'
105 recv_body: RECV '{' chp_body_optional '}'
106 definition_body: definition_body definition_body_item
107 | definition_body_item
108 definition_body_item: instance_item_extended
109 | type_alias
110 optional_definition_body: definition_body
111 | /* empty */
112 optional_datatype_body: datatype_body
113 | /* empty */
114 datatype_body: datatype_body datatype_body_item
115 | datatype_body_item
116 datatype_body_item: connection_body_item
117 | lang_spec
118 connection_body: connection_body connection_body_item
119 | connection_body_item
120 connection_body_item_base: connection_statement
121 | nonempty_alias_list ';'
122 | instance_type_completion_statement
123 | instance_type_completion_connection_statement
124 connection_body_item: connection_body_item_base
125 | loop_connections
126 | conditional_connections
127 instance_management_list: instance_management_list instance_item_extended
128 | instance_item_extended
129 instance_item_extended: instance_item
130 | language_body
131 instance_item: type_instance_declaration
132 | connection_body_item_base
133 | loop_instantiation
134 | conditional_instantiation
135 loop_instantiation: '(' ';' ID ':' range ':' instance_management_list ')'
136 conditional_instantiation: '[' guarded_instance_management_list ']'
137 loop_connections: '(' ';' ID ':' range ':' connection_body ')'
138 conditional_connections: '[' guarded_connection_body ']'
139 type_instance_declaration: type_id instance_id_list ';'
140 instance_id_list: instance_id_list ',' instance_id_item
141 | instance_id_item
142 instance_id_item: ID optional_template_arguments_in_angles sparse_range_list
143 | ID optional_template_arguments_in_angles
144 | ID optional_template_arguments_in_angles connection_actuals_list
145 | ID optional_template_arguments_in_angles '=' alias_list
146 connection_statement: member_index_expr connection_actuals_list ';'
147 instance_type_completion_statement: index_expr complex_expr_optional_list_in_angles ';'
148 | generic_id complex_expr_optional_list_in_angles ';'
149 instance_type_completion_connection_statement: index_expr complex_expr_optional_list_in_angles connection_actuals_list ';'
150 | generic_id complex_expr_optional_list_in_angles connection_actuals_list ';'
151 nonempty_alias_list: nonempty_alias_list '=' complex_aggregate_reference
152 | complex_aggregate_reference '=' complex_aggregate_reference
153 alias_list: alias_list '=' complex_aggregate_reference
154 | complex_aggregate_reference
155 connection_actuals_list: '(' complex_aggregate_reference_list ')'
156 guarded_instance_management_list: guarded_instance_management_list_unmatched THICKBAR instance_management_else_clause
157 | guarded_instance_management_list_unmatched
158 guarded_instance_management_list_unmatched: guarded_instance_management_list_unmatched THICKBAR guarded_instance_management
159 | guarded_instance_management
160 guarded_instance_management: expr RARROW instance_management_list
161 instance_management_else_clause: ELSE RARROW instance_management_list
162 guarded_connection_body: guarded_connection_body_unmatched THICKBAR connection_body_else_clause
163 | guarded_connection_body_unmatched
164 guarded_connection_body_unmatched: guarded_connection_body_unmatched THICKBAR guarded_connection_body_clause
165 | guarded_connection_body_clause
166 guarded_connection_body_clause: expr RARROW connection_body
167 connection_body_else_clause: ELSE RARROW connection_body
168 language_body: CHP_LANG '{' chp_body_optional '}'
169 | HSE_LANG '{' hse_body_optional '}'
170 | PRS_LANG optional_template_arguments_in_angles '{' prs_body_optional '}'
171 | lang_spec
172 lang_spec: SPEC_LANG '{' spec_body_optional '}'
173 chp_body: full_chp_body_item_list
174 chp_body_optional: chp_body
175 | /* empty */
176 chp_body_or_skip: chp_body
177 | SKIP
178 chp_sequence_group: '{' full_chp_body_item_list '}'
179 full_chp_body_item_list: full_chp_body_item_list ';' full_chp_body_item
180 | full_chp_body_item
181 full_chp_body_item: chp_concurrent_group
182 chp_body_item: chp_statement_attributes chp_statement
183 | chp_statement
184 chp_statement_attributes: '$' '(' chp_statement_attr_list ')'
185 chp_statement_attr_list: chp_statement_attr_list ';' chp_statement_attr
186 | chp_statement_attr
187 chp_statement_attr: ID '=' expr
188 chp_statement: chp_loop
189 | chp_do_until
190 | chp_selection
191 | chp_wait
192 | chp_binary_assignment
193 | chp_bool_assignment
194 | chp_send
195 | chp_recv
196 | chp_peek
197 | LOG expr_list_in_parens
198 | chp_metaloop_selection
199 | chp_metaloop_statement
200 | function_call_expr
201 chp_loop: BEGINLOOP chp_body ']'
202 chp_do_until: BEGINLOOP chp_unmatched_det_guarded_command_list ']'
203 chp_wait: '[' chp_guard_expr ']'
204 chp_selection: '[' chp_matched_det_guarded_command_list ']'
205 | '[' chp_nondet_guarded_command_list ']'
206 chp_metaloop_selection: '[' ':' ID ':' range ':' chp_guarded_command ']'
207 | '[' THICKBAR ID ':' range ':' chp_guarded_command ']'
208 chp_metaloop_statement: '{' ',' ID ':' range ':' chp_body '}'
209 | '{' ';' ID ':' range ':' chp_body '}'
210 chp_nondet_guarded_command_list: chp_nondet_guarded_command_list ':' chp_guarded_command
211 | chp_guarded_command ':' chp_guarded_command
212 chp_matched_det_guarded_command_list: chp_unmatched_det_guarded_command_list THICKBAR chp_else_clause
213 | chp_unmatched_det_guarded_command_list
214 chp_unmatched_det_guarded_command_list: chp_unmatched_det_guarded_command_list THICKBAR chp_guarded_command
215 | chp_guarded_command
216 chp_guarded_command: chp_guard_expr RARROW chp_body_or_skip
217 chp_guard_expr: chp_logical_or_expr
218 chp_unary_bool_expr: chp_simple_bool_expr
219 | chp_not_expr
220 | '(' chp_logical_or_expr ')'
221 | chp_probe_expr
222 | function_call_expr
223 chp_probe_expr: '#' member_index_expr
224 chp_simple_bool_expr: member_index_expr
225 | BOOL_TRUE
226 | BOOL_FALSE
227 chp_unary_expr: '-' chp_unary_expr
228 | chp_unary_bool_expr
229 | loop_expr
230 | INT
231 | FLOAT
232 chp_mult_expr: chp_unary_expr
233 | chp_mult_expr muldiv_op chp_unary_expr
234 chp_add_expr: chp_mult_expr
235 | chp_add_expr_only
236 chp_add_expr_only: chp_add_expr '+' chp_mult_expr
237 | chp_add_expr '-' chp_mult_expr
238 chp_paren_add_expr: '(' chp_add_expr_only ')'
239 | chp_mult_expr
240 chp_shift_expr: chp_paren_add_expr
241 | chp_shift_expr EXTRACT chp_add_expr
242 | chp_shift_expr INSERT chp_add_expr
243 chp_relational_expr: chp_shift_expr relational_op chp_shift_expr
244 | chp_unary_bool_expr
245 chp_bitwise_and_expr: chp_relational_expr
246 | chp_bitwise_and_expr '&' chp_relational_expr
247 chp_bitwise_xor_expr: chp_bitwise_and_expr
248 | chp_bitwise_xor_expr '^' chp_bitwise_and_expr
249 chp_bitwise_or_expr: chp_bitwise_xor_expr
250 | chp_bitwise_or_expr '|' chp_bitwise_xor_expr
251 chp_logical_and_expr: chp_bitwise_or_expr
252 | chp_logical_and_expr LOGICAL_AND chp_bitwise_or_expr
253 chp_logical_or_expr: chp_logical_and_expr
254 | chp_logical_or_expr LOGICAL_OR chp_logical_and_expr
255 chp_not_expr: '~' chp_unary_bool_expr
256 chp_else_clause: ELSE RARROW chp_body_or_skip
257 chp_binary_assignment: member_index_expr ASSIGN expr
258 chp_bool_assignment: member_index_expr '+'
259 | member_index_expr '-'
260 chp_concurrent_item: chp_body_item
261 | chp_sequence_group
262 chp_concurrent_group: chp_concurrent_group ',' chp_concurrent_item
263 | chp_concurrent_item
264 chp_send: member_index_expr '!' connection_actuals_list
265 | member_index_expr '!'
266 chp_recv: member_index_expr '?' member_index_expr_list_in_parens_optional
267 chp_peek: member_index_expr '#' member_index_expr_list_in_parens
268 hse_body_optional: hse_body
269 | /* empty */
270 hse_body: full_hse_body_item_list
271 full_hse_body_item_list: full_hse_body_item_list ';' full_hse_body_item
272 | full_hse_body_item
273 full_hse_body_item: hse_body_item
274 hse_body_item: hse_loop
275 | hse_do_until
276 | hse_wait
277 | hse_selection
278 | hse_assignment
279 | SKIP
280 hse_loop: BEGINLOOP hse_body ']'
281 hse_do_until: BEGINLOOP hse_matched_det_guarded_command_list ']'
282 hse_wait: '[' expr ']'
283 hse_selection: '[' hse_matched_det_guarded_command_list ']'
284 | '[' hse_nondet_guarded_command_list ']'
285 hse_guarded_command: expr RARROW hse_body
286 hse_else_clause: ELSE RARROW hse_body
287 hse_nondet_guarded_command_list: hse_nondet_guarded_command_list ':' hse_guarded_command
288 | hse_guarded_command ':' hse_guarded_command
289 hse_matched_det_guarded_command_list: hse_unmatched_det_guarded_command_list THICKBAR hse_else_clause
290 | hse_unmatched_det_guarded_command_list
291 hse_unmatched_det_guarded_command_list: hse_unmatched_det_guarded_command_list THICKBAR hse_guarded_command
292 | hse_guarded_command
293 hse_assignment: unary_assignment
294 prs_body_optional: prs_body
295 | /* empty */
296 prs_body: prs_body prs_body_item
297 | prs_body_item
298 prs_body_item: single_prs
299 | prs_loop
300 | prs_conditional
301 | prs_macro
302 | TREE_LANG optional_template_arguments_in_angles '{' prs_body_optional '}'
303 | SUBCKT_LANG optional_template_arguments_in_angles '{' prs_body_optional '}'
304 prs_macro: prs_literal mandatory_member_index_expr_list_in_parens
305 prs_loop: '(' ':' ID ':' range ':' prs_body ')'
306 prs_conditional: '[' prs_guarded_list ']'
307 prs_guarded_list: prs_guarded_list_unmatched THICKBAR prs_else_clause
308 | prs_guarded_list_unmatched
309 prs_guarded_list_unmatched: prs_guarded_list_unmatched THICKBAR prs_guarded_body
310 | prs_guarded_body
311 prs_guarded_body: expr RARROW prs_body_optional
312 prs_else_clause: ELSE RARROW prs_body
313 single_prs: prs_rule_attribute_list_in_brackets prs_expr prs_arrow prs_literal_base dir
314 | prs_expr prs_arrow prs_literal_base dir
315 prs_rule_attribute_list_in_brackets: '[' prs_rule_attribute_list ']'
316 prs_rule_attribute_list: prs_rule_attribute_list ';' prs_rule_attribute
317 | prs_rule_attribute
318 prs_rule_attribute: ID '=' expr_list
319 prs_arrow: RARROW
320 | IMPLIES
321 | HASH_ARROW
322 dir: '+'
323 | '-'
324 prs_expr: prs_or
325 prs_paren_expr: '(' prs_expr ')'
326 prs_literal_base: relative_member_index_expr
327 | '@' ID optional_dense_range_list
328 prs_literal: prs_literal_base expr_list_in_angles_optional
329 prs_unary_expr: prs_literal
330 | prs_paren_expr
331 | prs_and_loop
332 | prs_or_loop
333 prs_not: '~' prs_unary_expr
334 | prs_unary_expr
335 prs_and: prs_and '&' prs_operator_attribute_optional prs_not
336 | prs_not
337 prs_or: prs_or '|' prs_and
338 | prs_and
339 prs_operator_attribute: '{' dir prs_expr '}'
340 prs_operator_attribute_optional: prs_operator_attribute
341 | /* empty */
342 prs_and_loop: '(' '&' ':' ID ':' range ':' prs_expr ')'
343 prs_or_loop: '(' '|' ':' ID ':' range ':' prs_expr ')'
344 spec_body_optional: spec_body
345 | /* empty */
346 spec_body: spec_body spec_item
347 | spec_item
348 spec_item: spec_directive
349 spec_directive: ID expr_list_in_angles_optional grouped_reference_list_in_parens
350 grouped_reference_list_in_parens: '(' grouped_reference_list ')'
351 grouped_reference_list: grouped_reference_list ',' grouped_reference
352 | grouped_reference
353 grouped_reference: '{' mandatory_member_index_expr_list '}'
354 | member_index_expr
355 paren_expr: '(' expr ')'
356 literal: INT
357 | FLOAT
358 | string
359 | BOOL_TRUE
360 | BOOL_FALSE
361 string: string STRING
362 | STRING
363 id_expr: generic_id
364 generic_id: relative_id
365 | absolute_id
366 absolute_id: SCOPE relative_id
367 relative_id: qualified_id
368 | ID
369 qualified_id: qualified_id SCOPE ID
370 | ID SCOPE ID
371 mandatory_member_index_expr_list_in_parens: '(' mandatory_member_index_expr_list ')'
372 mandatory_member_index_expr_list: mandatory_member_index_expr_list ',' member_index_expr
373 | member_index_expr
374 member_index_expr_list: member_index_expr_list ',' optional_member_index_expr
375 | optional_member_index_expr
376 optional_member_index_expr: member_index_expr
377 | /* empty */
378 member_index_expr: id_expr
379 | index_expr
380 | member_expr
381 relative_member_index_expr: ID
382 | local_index_expr
383 | local_member_expr
384 local_index_expr: local_member_expr sparse_range_list
385 | ID sparse_range_list
389 index_expr: member_expr sparse_range_list
390 | id_expr sparse_range_list
394 simple_expr: member_index_expr
395 | literal
396 unary_expr: simple_expr
397 | function_call_expr
398 | paren_expr
399 | loop_expr
400 | '-' unary_expr
401 | '!' unary_expr
402 | '~' unary_expr
403 function_call_expr: member_index_expr connection_actuals_list
404 multiplicative_expr: unary_expr
405 | multiplicative_expr muldiv_op unary_expr
406 muldiv_op: '*'
407 | '/'
408 | '%'
409 additive_expr: multiplicative_expr
410 | additive_expr '+' multiplicative_expr
411 | additive_expr '-' multiplicative_expr
412 shift_expr: additive_expr
413 | shift_expr EXTRACT additive_expr
414 | shift_expr INSERT additive_expr
415 relational_equality_expr: shift_expr
416 | '(' relational_equality_expr '<' shift_expr ')'
417 | '(' relational_equality_expr '>' shift_expr ')'
418 | relational_equality_expr LE shift_expr
419 | relational_equality_expr GE shift_expr
420 | relational_equality_expr EQUAL shift_expr
421 | relational_equality_expr NOTEQUAL shift_expr
422 | '(' relational_equality_expr '=' shift_expr ')'
423 relational_op: '<'
424 | '>'
425 | LE
426 | GE
427 | EQUAL
428 | NOTEQUAL
429 and_expr: relational_equality_expr
430 | and_expr '&' relational_equality_expr
431 exclusive_or_expr: and_expr
432 | exclusive_or_expr '^' and_expr
433 inclusive_or_expr: exclusive_or_expr
434 | inclusive_or_expr '|' exclusive_or_expr
435 logical_and_expr: inclusive_or_expr
436 | logical_and_expr LOGICAL_AND inclusive_or_expr
437 logical_or_expr: logical_and_expr
438 | logical_or_expr LOGICAL_OR logical_and_expr
439 unary_assignment: member_index_expr PLUSPLUS
440 | member_index_expr MINUSMINUS
441 loop_expr: '(' loop_assoc_op ':' ID ':' range ':' expr ')'
442 loop_assoc_op: '+'
443 | '*'
444 | '&'
445 | '|'
446 | '^'
447 | LOGICAL_AND
448 | LOGICAL_OR
449 expr: logical_or_expr
450 strict_relaxed_template_arguments: complex_expr_optional_list_in_angles optional_template_arguments_in_angles
451 | /* empty */
452 optional_template_arguments_in_angles: complex_expr_optional_list_in_angles
453 | /* empty */
454 expr_list_in_angles_optional: expr_list_in_angles
455 | /* empty */
456 expr_list_in_angles: '<' expr_list '>'
457 complex_expr_optional_list_in_angles: '<' complex_expr_optional_list '>'
458 complex_expr_optional_list: complex_expr_optional_list ',' optional_complex_expr
459 | optional_complex_expr
460 optional_complex_expr: array_concatenation
461 | /* empty */
462 member_index_expr_list_in_parens_optional: member_index_expr_list_in_parens
463 | /* empty */
464 member_index_expr_list_in_parens: '(' member_index_expr_list ')'
465 expr_list_in_parens: '(' expr_list ')'
466 expr_list: expr_list ',' expr
467 | expr
468 range: expr RANGE expr
469 | expr
470 optional_dense_range_list: dense_range_list
471 | /* empty */
472 dense_range_list: dense_range_list bracketed_dense_range
473 | bracketed_dense_range
474 sparse_range_list: sparse_range_list bracketed_sparse_range
475 | bracketed_sparse_range
476 bracketed_dense_range: '[' expr ']'
477 bracketed_sparse_range: '[' range ']'
478 complex_aggregate_reference: array_concatenation
479 array_concatenation: array_concatenation '#' complex_expr_term
480 | complex_expr_term
481 complex_expr_term: array_construction
482 | expr
483 array_construction: '{' mandatory_complex_aggregate_reference_list '}'
484 optional_complex_aggregate_reference: complex_aggregate_reference
485 | /* empty */
486 mandatory_complex_aggregate_reference_list: mandatory_complex_aggregate_reference_list ',' complex_aggregate_reference
487 | complex_aggregate_reference
488 complex_aggregate_reference_list: complex_aggregate_reference_list ',' optional_complex_aggregate_reference
489 | optional_complex_aggregate_reference