lustrec / src / backends / VHDL / vhdl_ast_deriving.ml @ 1f593d5d
History | View | Annotate | Download (249 KB)
1 |
let base_types = |
---|---|
2 |
["integer"; |
3 |
"character"; |
4 |
"bit"; |
5 |
"real"; |
6 |
"natural"; |
7 |
"positive"; |
8 |
"std_logic"; |
9 |
"std_logic_vector"] |
10 |
let std_logic_cst = ["U"; "X"; "0"; "1"; "Z"; "W"; "L"; "H"; "-"] |
11 |
let literal_base = ["B"; "O"; "X"; "UB"; "UO"; "UX"; "SB"; "SO"; "SX"; "D"] |
12 |
type vhdl_cst_val_t = |
13 |
| CstInt of int |
14 |
| CstStdLogic of string |
15 |
| CstLiteral of string [@name "CST_LITERAL"] |
16 |
|
17 |
let rec (pp_vhdl_cst_val_t : |
18 |
Format.formatter -> vhdl_cst_val_t -> Ppx_deriving_runtime.unit) |
19 |
= |
20 |
((let open! Ppx_deriving_runtime in |
21 |
fun fmt -> |
22 |
function |
23 |
| CstInt a0 -> |
24 |
(Format.fprintf fmt "%d") a0; |
25 |
| CstStdLogic a0 -> |
26 |
(Format.fprintf fmt "%S") a0; |
27 |
| CstLiteral a0 -> |
28 |
(Format.fprintf fmt "%s") a0;) |
29 |
[@ocaml.warning "-A"]) |
30 |
|
31 |
and show_vhdl_cst_val_t : vhdl_cst_val_t -> Ppx_deriving_runtime.string = |
32 |
fun x -> Format.asprintf "%a" pp_vhdl_cst_val_t x |
33 |
|
34 |
let rec (vhdl_cst_val_t_to_yojson : vhdl_cst_val_t -> Yojson.Safe.json) = |
35 |
((let open! Ppx_deriving_yojson_runtime in |
36 |
function |
37 |
| CstInt arg0 -> |
38 |
`List |
39 |
[`String "CstInt"; |
40 |
((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg0] |
41 |
| CstStdLogic arg0 -> |
42 |
`List |
43 |
[`String "CstStdLogic"; |
44 |
((fun (x : Ppx_deriving_runtime.string) -> `String x)) arg0] |
45 |
| CstLiteral arg0 -> |
46 |
`List |
47 |
[`String "CST_LITERAL"; |
48 |
((fun (x : Ppx_deriving_runtime.string) -> `String x)) arg0]) |
49 |
[@ocaml.warning "-A"]) |
50 |
|
51 |
and (vhdl_cst_val_t_of_yojson : |
52 |
Yojson.Safe.json -> vhdl_cst_val_t Ppx_deriving_yojson_runtime.error_or) |
53 |
= |
54 |
((let open! Ppx_deriving_yojson_runtime in |
55 |
function |
56 |
| `List ((`String "CstInt")::arg0::[]) -> |
57 |
((function |
58 |
| `Int x -> Result.Ok x |
59 |
| _ -> Result.Error "Vhdl_ast.vhdl_cst_val_t") arg0) >>= |
60 |
((fun arg0 -> Result.Ok (CstInt arg0))) |
61 |
| `List ((`String "CstStdLogic")::arg0::[]) -> |
62 |
((function |
63 |
| `String x -> Result.Ok x |
64 |
| _ -> Result.Error "Vhdl_ast.vhdl_cst_val_t") arg0) >>= |
65 |
((fun arg0 -> Result.Ok (CstStdLogic arg0))) |
66 |
| `List ((`String "CST_LITERAL")::arg0::[]) -> |
67 |
((function |
68 |
| `String x -> Result.Ok x |
69 |
| _ -> Result.Error "Vhdl_ast.vhdl_cst_val_t") arg0) >>= |
70 |
((fun arg0 -> Result.Ok (CstLiteral arg0))) |
71 |
| _ -> Result.Error "Vhdl_ast.vhdl_cst_val_t") |
72 |
[@ocaml.warning "-A"]) |
73 |
|
74 |
type vhdl_type_t = |
75 |
| Base of string |
76 |
| Range of string option * int * int |
77 |
| Bit_vector of int * int |
78 |
| Array of |
79 |
{ |
80 |
indexes: vhdl_name_t list [@default []]; |
81 |
const: vhdl_constraint_t option [@default None]; |
82 |
definition: vhdl_subtype_indication_t } [@name "ARRAY_TYPE_DEFINITION"] |
83 |
| Record of vhdl_element_declaration_t list |
84 |
[@name "RECORD_TYPE_DEFINITION"] |
85 |
| Enumerated of vhdl_name_t list [@name "ENUMERATION_TYPE_DEFINITION"] |
86 |
| Void |
87 |
and vhdl_element_declaration_t = |
88 |
{ |
89 |
names: vhdl_name_t list ; |
90 |
definition: vhdl_subtype_indication_t } |
91 |
and vhdl_subtype_indication_t = |
92 |
{ |
93 |
name: vhdl_name_t [@default NoName]; |
94 |
functionName: vhdl_name_t [@default NoName]; |
95 |
const: vhdl_constraint_t [@default NoConstraint]} |
96 |
and vhdl_discrete_range_t = |
97 |
| SubDiscreteRange of vhdl_subtype_indication_t |
98 |
[@name "SUB_DISCRETE_RANGE"] |
99 |
| NamedRange of vhdl_name_t [@name "NAMED_RANGE"] |
100 |
| DirectedRange of |
101 |
{ |
102 |
direction: string ; |
103 |
from: vhdl_expr_t ; |
104 |
_to: vhdl_expr_t } [@name "RANGE_WITH_DIRECTION"] |
105 |
and vhdl_constraint_t = |
106 |
| RefConstraint of { |
107 |
ref_name: vhdl_name_t } |
108 |
| RangeConstraint of { |
109 |
range: vhdl_discrete_range_t } [@name "RANGE_CONSTRAINT"] |
110 |
| IndexConstraint of { |
111 |
ranges: vhdl_discrete_range_t list } [@name "INDEX_CONSTRAINT"] |
112 |
| ArrayConstraint of |
113 |
{ |
114 |
ranges: vhdl_discrete_range_t list ; |
115 |
sub: vhdl_constraint_t } [@name "ARRAY_CONSTRAINT"] |
116 |
| RecordConstraint |
117 |
| NoConstraint |
118 |
and vhdl_definition_t = |
119 |
| Type of { |
120 |
name: vhdl_name_t ; |
121 |
definition: vhdl_type_t } [@name "TYPE_DECLARATION"] |
122 |
| Subtype of { |
123 |
name: vhdl_name_t ; |
124 |
typ: vhdl_subtype_indication_t } [@name "SUBTYPE_DECLARATION"] |
125 |
and vhdl_expr_t = |
126 |
| Call of vhdl_name_t [@name "CALL"] |
127 |
| Cst of |
128 |
{ |
129 |
value: vhdl_cst_val_t ; |
130 |
unit_name: vhdl_name_t option [@default None]} [@name "CONSTANT_VALUE"] |
131 |
| Op of { |
132 |
id: string [@default ""]; |
133 |
args: vhdl_expr_t list [@default []]} [@name "EXPRESSION"] |
134 |
| IsNull [@name "IsNull"] |
135 |
| Time of { |
136 |
value: int ; |
137 |
phy_unit: string [@default ""]} |
138 |
| Sig of { |
139 |
name: vhdl_name_t ; |
140 |
att: vhdl_signal_attributes_t option } |
141 |
| SuffixMod of { |
142 |
expr: vhdl_expr_t ; |
143 |
selection: vhdl_suffix_selection_t } |
144 |
| Aggregate of { |
145 |
elems: vhdl_element_assoc_t list } [@name "AGGREGATE"] |
146 |
| QualifiedExpression of |
147 |
{ |
148 |
type_mark: vhdl_name_t ; |
149 |
aggregate: vhdl_element_assoc_t list ; |
150 |
expression: vhdl_expr_t option } [@name "QUALIFIED_EXPRESSION"] |
151 |
| Others [@name "OTHERS"] |
152 |
and vhdl_name_t = |
153 |
| Simple of string [@name "SIMPLE_NAME"] |
154 |
| Identifier of string [@name "IDENTIFIER"] |
155 |
| Selected of vhdl_name_t list [@name "SELECTED_NAME"] |
156 |
| Index of { |
157 |
id: vhdl_name_t ; |
158 |
exprs: vhdl_expr_t list } [@name "INDEXED_NAME"] |
159 |
| Slice of { |
160 |
id: vhdl_name_t ; |
161 |
range: vhdl_discrete_range_t } [@name "SLICE_NAME"] |
162 |
| Attribute of |
163 |
{ |
164 |
id: vhdl_name_t ; |
165 |
designator: vhdl_name_t ; |
166 |
expr: vhdl_expr_t [@default IsNull]} [@name "ATTRIBUTE_NAME"] |
167 |
| Function of { |
168 |
id: vhdl_name_t ; |
169 |
assoc_list: vhdl_assoc_element_t list } [@name "FUNCTION_CALL"] |
170 |
| NoName |
171 |
and vhdl_assoc_element_t = |
172 |
{ |
173 |
formal_name: vhdl_name_t option [@default None]; |
174 |
formal_arg: vhdl_name_t option [@default None]; |
175 |
actual_name: vhdl_name_t option [@default None]; |
176 |
actual_designator: vhdl_name_t option [@default None]; |
177 |
actual_expr: vhdl_expr_t option [@default None]} |
178 |
and vhdl_element_assoc_t = { |
179 |
choices: vhdl_expr_t list [@default []]; |
180 |
expr: vhdl_expr_t } |
181 |
and vhdl_array_attributes_t = |
182 |
| AAttInt of { |
183 |
id: string ; |
184 |
arg: int } |
185 |
| AAttAscending |
186 |
and vhdl_signal_attributes_t = |
187 |
| SigAtt of string |
188 |
and vhdl_string_attributes_t = |
189 |
| StringAtt of string |
190 |
and vhdl_suffix_selection_t = |
191 |
| Idx of int |
192 |
| SuffixRange of int * int |
193 |
|
194 |
let rec pp_vhdl_type_t : |
195 |
Format.formatter -> vhdl_type_t -> Ppx_deriving_runtime.unit = |
196 |
let __4 () = pp_vhdl_name_t |
197 |
|
198 |
and __3 () = pp_vhdl_element_declaration_t |
199 |
|
200 |
and __2 () = pp_vhdl_subtype_indication_t |
201 |
|
202 |
and __1 () = pp_vhdl_constraint_t |
203 |
|
204 |
and __0 () = pp_vhdl_name_t |
205 |
in |
206 |
((let open! Ppx_deriving_runtime in |
207 |
fun fmt -> |
208 |
function |
209 |
| Base a0 -> |
210 |
(Format.fprintf fmt "%s") a0; |
211 |
| Range (a0,a1,a2) -> |
212 |
(( |
213 |
(Format.fprintf fmt "%d") a1); |
214 |
((function |
215 |
| None -> Format.pp_print_string fmt "" |
216 |
| Some x -> |
217 |
(Format.fprintf fmt "%s") x; |
218 |
)) a0; |
219 |
(Format.fprintf fmt "%d") a2); |
220 |
| Bit_vector (a0,a1) -> |
221 |
(Format.fprintf fmt "array (%d,%d) of bit") a0 a1; |
222 |
| Array |
223 |
{ indexes = aindexes; const = aconst; definition = adefinition } |
224 |
-> |
225 |
Format.fprintf fmt "array"; |
226 |
(match aindexes with |
227 |
| [] -> Format.fprintf fmt ""; |
228 |
| _ -> |
229 |
Format.fprintf fmt "(@[<v>"; |
230 |
((fun x -> |
231 |
ignore |
232 |
(List.fold_left |
233 |
(fun sep -> |
234 |
fun x -> |
235 |
if sep then Format.fprintf fmt ",@ "; |
236 |
((__0 ()) fmt) x; |
237 |
Format.fprintf fmt " range <>"; |
238 |
true) false x)) aindexes); |
239 |
Format.fprintf fmt ")@]"); |
240 |
(function |
241 |
| None -> Format.pp_print_string fmt "" |
242 |
| Some x -> |
243 |
((__1 ()) fmt) x) aconst; |
244 |
Format.fprintf fmt " of "; |
245 |
((__2 ()) fmt) adefinition; |
246 |
| Record a0 -> |
247 |
Format.fprintf fmt "@[<v 2>record@;"; |
248 |
(fun x -> |
249 |
ignore |
250 |
(List.fold_left |
251 |
(fun sep -> |
252 |
fun x -> |
253 |
if sep then Format.fprintf fmt ";@;"; |
254 |
((__3 ()) fmt) x; |
255 |
true) false x); |
256 |
Format.fprintf fmt "@]@;end record") a0; |
257 |
| Enumerated a0 -> |
258 |
(Format.fprintf fmt "("; |
259 |
((fun x -> |
260 |
ignore |
261 |
(List.fold_left |
262 |
(fun sep -> |
263 |
fun x -> |
264 |
if sep then Format.fprintf fmt ",@ "; |
265 |
((__4 ()) fmt) x; |
266 |
true) false x))) a0; |
267 |
Format.fprintf fmt ")"); |
268 |
| Void -> Format.pp_print_string fmt "") |
269 |
[@ocaml.warning "-A"]) |
270 |
|
271 |
and show_vhdl_type_t : vhdl_type_t -> Ppx_deriving_runtime.string = |
272 |
fun x -> Format.asprintf "%a" pp_vhdl_type_t x |
273 |
|
274 |
and pp_vhdl_element_declaration_t : |
275 |
Format.formatter -> vhdl_element_declaration_t -> Ppx_deriving_runtime.unit |
276 |
= |
277 |
let __1 () = pp_vhdl_subtype_indication_t |
278 |
|
279 |
and __0 () = pp_vhdl_name_t |
280 |
in |
281 |
((let open! Ppx_deriving_runtime in |
282 |
fun fmt -> |
283 |
fun x -> |
284 |
(fun x -> |
285 |
ignore |
286 |
(List.fold_left |
287 |
(fun sep -> |
288 |
fun x -> |
289 |
if sep then Format.fprintf fmt ",@ "; |
290 |
((__0 ()) fmt) x; |
291 |
true) false x)) x.names; |
292 |
Format.fprintf fmt ":@ "; |
293 |
((__1 ()) fmt) x.definition) |
294 |
[@ocaml.warning "-A"]) |
295 |
|
296 |
and show_vhdl_element_declaration_t : |
297 |
vhdl_element_declaration_t -> Ppx_deriving_runtime.string = |
298 |
fun x -> Format.asprintf "%a" pp_vhdl_element_declaration_t x |
299 |
|
300 |
and pp_vhdl_subtype_indication_t : |
301 |
Format.formatter -> vhdl_subtype_indication_t -> Ppx_deriving_runtime.unit |
302 |
= |
303 |
let __2 () = pp_vhdl_constraint_t |
304 |
|
305 |
and __1 () = pp_vhdl_name_t |
306 |
|
307 |
and __0 () = pp_vhdl_name_t |
308 |
in |
309 |
((let open! Ppx_deriving_runtime in |
310 |
fun fmt -> |
311 |
fun x -> |
312 |
((__0 ()) fmt) x.name; |
313 |
((__1 ()) fmt) x.functionName; |
314 |
(match x.const with |
315 |
| NoConstraint -> Format.fprintf fmt ""; |
316 |
| _ -> Format.fprintf fmt " "; |
317 |
((__2 ()) fmt) x.const)) |
318 |
[@ocaml.warning "-A"]) |
319 |
|
320 |
and show_vhdl_subtype_indication_t : |
321 |
vhdl_subtype_indication_t -> Ppx_deriving_runtime.string = |
322 |
fun x -> Format.asprintf "%a" pp_vhdl_subtype_indication_t x |
323 |
|
324 |
and pp_vhdl_discrete_range_t : |
325 |
Format.formatter -> vhdl_discrete_range_t -> Ppx_deriving_runtime.unit = |
326 |
let __3 () = pp_vhdl_expr_t |
327 |
|
328 |
and __2 () = pp_vhdl_expr_t |
329 |
|
330 |
and __1 () = pp_vhdl_name_t |
331 |
|
332 |
and __0 () = pp_vhdl_subtype_indication_t |
333 |
in |
334 |
((let open! Ppx_deriving_runtime in |
335 |
fun fmt -> |
336 |
function |
337 |
| SubDiscreteRange a0 -> |
338 |
((__0 ()) fmt) a0; |
339 |
| NamedRange a0 -> |
340 |
((__1 ()) fmt) a0; |
341 |
| DirectedRange { direction = adirection; from = afrom; _to = a_to } |
342 |
-> |
343 |
((__2 ()) fmt) afrom; |
344 |
(Format.fprintf fmt " %s ") adirection; |
345 |
((__3 ()) fmt) a_to; |
346 |
) |
347 |
[@ocaml.warning "-A"]) |
348 |
|
349 |
and show_vhdl_discrete_range_t : |
350 |
vhdl_discrete_range_t -> Ppx_deriving_runtime.string = |
351 |
fun x -> Format.asprintf "%a" pp_vhdl_discrete_range_t x |
352 |
|
353 |
(* TODO Adapt for: ArrayConstraint, RecordConstraint *) |
354 |
and pp_vhdl_constraint_t : |
355 |
Format.formatter -> vhdl_constraint_t -> Ppx_deriving_runtime.unit = |
356 |
let __4 () = pp_vhdl_constraint_t |
357 |
|
358 |
and __3 () = pp_vhdl_discrete_range_t |
359 |
|
360 |
and __2 () = pp_vhdl_discrete_range_t |
361 |
|
362 |
and __1 () = pp_vhdl_discrete_range_t |
363 |
|
364 |
and __0 () = pp_vhdl_name_t |
365 |
in |
366 |
((let open! Ppx_deriving_runtime in |
367 |
fun fmt -> |
368 |
function |
369 |
| RefConstraint { ref_name = aref_name } -> |
370 |
(Format.fprintf fmt "("; |
371 |
((__0 ()) fmt) aref_name; |
372 |
Format.fprintf fmt ")"); |
373 |
| RangeConstraint { range = arange } -> |
374 |
(Format.fprintf fmt "("; |
375 |
((__1 ()) fmt) arange; |
376 |
Format.fprintf fmt ")"); |
377 |
| IndexConstraint { ranges = aranges } -> |
378 |
Format.fprintf fmt "("; |
379 |
((fun x -> |
380 |
ignore |
381 |
(List.fold_left |
382 |
(fun sep -> |
383 |
fun x -> |
384 |
if sep then Format.fprintf fmt ", "; |
385 |
((__2 ()) fmt) x; |
386 |
true) false x))) aranges; |
387 |
Format.fprintf fmt ")"; |
388 |
| ArrayConstraint { ranges = aranges; sub = asub } -> |
389 |
(Format.fprintf fmt "@[<2>ArrayConstraint {@,"; |
390 |
((Format.fprintf fmt "@[%s =@ " "ranges"; |
391 |
((fun x -> |
392 |
Format.fprintf fmt "@[<2>["; |
393 |
ignore |
394 |
(List.fold_left |
395 |
(fun sep -> |
396 |
fun x -> |
397 |
if sep then Format.fprintf fmt ";@ "; |
398 |
((__3 ()) fmt) x; |
399 |
true) false x); |
400 |
Format.fprintf fmt "@,]@]")) aranges; |
401 |
Format.fprintf fmt "@]"); |
402 |
Format.fprintf fmt ";@ "; |
403 |
Format.fprintf fmt "@[%s =@ " "sub"; |
404 |
((__4 ()) fmt) asub; |
405 |
Format.fprintf fmt "@]"); |
406 |
Format.fprintf fmt "@]}") |
407 |
| RecordConstraint -> Format.pp_print_string fmt "" |
408 |
| NoConstraint -> Format.pp_print_string fmt "") |
409 |
[@ocaml.warning "-A"]) |
410 |
|
411 |
and show_vhdl_constraint_t : vhdl_constraint_t -> Ppx_deriving_runtime.string |
412 |
= fun x -> Format.asprintf "%a" pp_vhdl_constraint_t x |
413 |
|
414 |
and pp_vhdl_definition_t : |
415 |
Format.formatter -> vhdl_definition_t -> Ppx_deriving_runtime.unit = |
416 |
let __3 () = pp_vhdl_subtype_indication_t |
417 |
|
418 |
and __2 () = pp_vhdl_name_t |
419 |
|
420 |
and __1 () = pp_vhdl_type_t |
421 |
|
422 |
and __0 () = pp_vhdl_name_t |
423 |
in |
424 |
((let open! Ppx_deriving_runtime in |
425 |
fun fmt -> |
426 |
function |
427 |
| Type { name = aname; definition = adefinition } -> |
428 |
Format.fprintf fmt "type "; |
429 |
((__0 ()) fmt) aname; |
430 |
Format.fprintf fmt " is "; |
431 |
((__1 ()) fmt) adefinition; |
432 |
| Subtype { name = aname; typ = atyp } -> |
433 |
Format.fprintf fmt "subtype "; |
434 |
((__2 ()) fmt) aname; |
435 |
Format.fprintf fmt " is "; |
436 |
((__3 ()) fmt) atyp; |
437 |
) |
438 |
[@ocaml.warning "-A"]) |
439 |
|
440 |
and show_vhdl_definition_t : vhdl_definition_t -> Ppx_deriving_runtime.string |
441 |
= fun x -> Format.asprintf "%a" pp_vhdl_definition_t x |
442 |
|
443 |
(* TODO adapt for Op (more than 2 operand), Time, Sig, suffixMod *) |
444 |
and pp_vhdl_expr_t : |
445 |
Format.formatter -> vhdl_expr_t -> Ppx_deriving_runtime.unit = |
446 |
let __11 () = pp_vhdl_expr_t |
447 |
|
448 |
and __10 () = pp_vhdl_element_assoc_t |
449 |
|
450 |
and __9 () = pp_vhdl_name_t |
451 |
|
452 |
and __8 () = pp_vhdl_element_assoc_t |
453 |
|
454 |
and __7 () = pp_vhdl_suffix_selection_t |
455 |
|
456 |
and __6 () = pp_vhdl_expr_t |
457 |
|
458 |
and __5 () = pp_vhdl_signal_attributes_t |
459 |
|
460 |
and __4 () = pp_vhdl_name_t |
461 |
|
462 |
and __3 () = pp_vhdl_expr_t |
463 |
|
464 |
and __2 () = pp_vhdl_name_t |
465 |
|
466 |
and __1 () = pp_vhdl_cst_val_t |
467 |
|
468 |
and __0 () = pp_vhdl_name_t |
469 |
in |
470 |
((let open! Ppx_deriving_runtime in |
471 |
fun fmt -> |
472 |
function |
473 |
| Call a0 -> |
474 |
((__0 ()) fmt) a0; |
475 |
| Cst { value = avalue; unit_name = aunit_name } -> |
476 |
((__1 ()) fmt) avalue; |
477 |
(function |
478 |
| None -> Format.pp_print_string fmt "" |
479 |
| Some x -> |
480 |
Format.fprintf fmt " "; |
481 |
((__2 ()) fmt) x) aunit_name; |
482 |
| Op { id = aid; args = aargs } -> |
483 |
(match aargs with |
484 |
| [] -> (Format.fprintf fmt "%s") aid; |
485 |
| hd::[] -> |
486 |
(Format.fprintf fmt "%s") aid; |
487 |
((__3 ()) fmt) hd |
488 |
| hd::(hd2::[]) -> |
489 |
((__3 ()) fmt) hd; |
490 |
(Format.fprintf fmt " %s ") aid; |
491 |
((__3 ()) fmt) hd2 |
492 |
| _ -> |
493 |
(Format.fprintf fmt "@[<2>Op {@,"; |
494 |
((Format.fprintf fmt "@[%s =@ " "id"; |
495 |
(Format.fprintf fmt "%S") aid; |
496 |
Format.fprintf fmt "@]"); |
497 |
Format.fprintf fmt ";@ "; |
498 |
Format.fprintf fmt "@[%s =@ " "args"; |
499 |
((fun x -> |
500 |
Format.fprintf fmt "@[<2>["; |
501 |
ignore |
502 |
(List.fold_left |
503 |
(fun sep -> |
504 |
fun x -> |
505 |
if sep then Format.fprintf fmt ";@ "; |
506 |
((__3 ()) fmt) x; |
507 |
true) false x); |
508 |
Format.fprintf fmt "@,]@]")) aargs; |
509 |
Format.fprintf fmt "@]"); |
510 |
Format.fprintf fmt "@]}")) |
511 |
| IsNull -> Format.pp_print_string fmt "" |
512 |
| Time { value = avalue; phy_unit = aphy_unit } -> |
513 |
(Format.fprintf fmt "@[<2>Time {@,"; |
514 |
((Format.fprintf fmt "@[%s =@ " "value"; |
515 |
(Format.fprintf fmt "%d") avalue; |
516 |
Format.fprintf fmt "@]"); |
517 |
Format.fprintf fmt ";@ "; |
518 |
Format.fprintf fmt "@[%s =@ " "phy_unit"; |
519 |
(Format.fprintf fmt "%S") aphy_unit; |
520 |
Format.fprintf fmt "@]"); |
521 |
Format.fprintf fmt "@]}") |
522 |
| Sig { name = aname; att = aatt } -> |
523 |
(Format.fprintf fmt "--@[<2>Sig {@,"; |
524 |
((Format.fprintf fmt "@[%s =@ " "name"; |
525 |
((__4 ()) fmt) aname; |
526 |
Format.fprintf fmt "@]"); |
527 |
Format.fprintf fmt ";@ "; |
528 |
Format.fprintf fmt "@[%s =@ " "att"; |
529 |
((function |
530 |
| None -> Format.pp_print_string fmt "None" |
531 |
| Some x -> |
532 |
(Format.pp_print_string fmt "(Some "; |
533 |
((__5 ()) fmt) x; |
534 |
Format.pp_print_string fmt ")"))) aatt; |
535 |
Format.fprintf fmt "@]"); |
536 |
Format.fprintf fmt "@]}") |
537 |
| SuffixMod { expr = aexpr; selection = aselection } -> |
538 |
(Format.fprintf fmt "--@[<2>SuffixMod {@,"; |
539 |
((Format.fprintf fmt "@[%s =@ " "expr"; |
540 |
((__6 ()) fmt) aexpr; |
541 |
Format.fprintf fmt "@]"); |
542 |
Format.fprintf fmt ";@ "; |
543 |
Format.fprintf fmt "@[%s =@ " "selection"; |
544 |
((__7 ()) fmt) aselection; |
545 |
Format.fprintf fmt "@]"); |
546 |
Format.fprintf fmt "@]}") |
547 |
| Aggregate { elems = aelems } -> |
548 |
(match aelems with |
549 |
| [] -> Format.fprintf fmt ""; |
550 |
| _ -> |
551 |
(Format.fprintf fmt "(@["; |
552 |
((fun x -> |
553 |
ignore |
554 |
(List.fold_left |
555 |
(fun sep -> |
556 |
fun x -> |
557 |
if sep then Format.fprintf fmt ", "; |
558 |
((__8 ()) fmt) x; |
559 |
true) false x))) aelems; |
560 |
Format.fprintf fmt ")@]");) |
561 |
| QualifiedExpression |
562 |
{ type_mark = atype_mark; aggregate = aaggregate; |
563 |
expression = aexpression } |
564 |
-> |
565 |
((__9 ()) fmt) atype_mark; |
566 |
Format.fprintf fmt "'"; |
567 |
(match aaggregate with |
568 |
| [] -> Format.fprintf fmt ""; |
569 |
| _ -> |
570 |
Format.fprintf fmt "(@[<v>"; |
571 |
((fun x -> |
572 |
ignore |
573 |
(List.fold_left |
574 |
(fun sep -> |
575 |
fun x -> |
576 |
if sep then Format.fprintf fmt ",@ "; |
577 |
((__10 ()) fmt) x; |
578 |
true) false x))) aaggregate; |
579 |
Format.fprintf fmt ")@]"); |
580 |
(match aexpression with |
581 |
| None -> Format.pp_print_string fmt "" |
582 |
| Some x -> |
583 |
((__11 ()) fmt) x;); |
584 |
| Others -> Format.pp_print_string fmt "others") |
585 |
[@ocaml.warning "-A"]) |
586 |
|
587 |
and show_vhdl_expr_t : vhdl_expr_t -> Ppx_deriving_runtime.string = |
588 |
fun x -> Format.asprintf "%a" pp_vhdl_expr_t x |
589 |
|
590 |
and pp_vhdl_name_t : |
591 |
Format.formatter -> vhdl_name_t -> Ppx_deriving_runtime.unit = |
592 |
let __9 () = pp_vhdl_assoc_element_t |
593 |
|
594 |
and __8 () = pp_vhdl_name_t |
595 |
|
596 |
and __7 () = pp_vhdl_expr_t |
597 |
|
598 |
and __6 () = pp_vhdl_name_t |
599 |
|
600 |
and __5 () = pp_vhdl_name_t |
601 |
|
602 |
and __4 () = pp_vhdl_discrete_range_t |
603 |
|
604 |
and __3 () = pp_vhdl_name_t |
605 |
|
606 |
and __2 () = pp_vhdl_expr_t |
607 |
|
608 |
and __1 () = pp_vhdl_name_t |
609 |
|
610 |
and __0 () = pp_vhdl_name_t |
611 |
in |
612 |
((let open! Ppx_deriving_runtime in |
613 |
fun fmt -> |
614 |
function |
615 |
| Simple a0 -> |
616 |
(Format.fprintf fmt "%s") a0; |
617 |
| Identifier a0 -> |
618 |
(Format.fprintf fmt "%s") a0; |
619 |
| Selected a0 -> |
620 |
((fun x -> |
621 |
ignore |
622 |
(List.fold_left |
623 |
(fun sep -> |
624 |
fun x -> |
625 |
if sep then Format.fprintf fmt "."; |
626 |
((__0 ()) fmt) x; |
627 |
true) false x);) a0;) |
628 |
| Index { id = aid; exprs = aexprs } -> |
629 |
((__1 ()) fmt) aid; |
630 |
Format.fprintf fmt "("; |
631 |
(fun x -> |
632 |
ignore |
633 |
(List.fold_left |
634 |
(fun sep -> |
635 |
fun x -> |
636 |
if sep then Format.fprintf fmt ",@ "; |
637 |
((__2 ()) fmt) x; |
638 |
true |
639 |
) false x); |
640 |
) aexprs; |
641 |
Format.fprintf fmt ")"; |
642 |
| Slice { id = aid; range = arange } -> |
643 |
((__3 ()) fmt) aid; |
644 |
Format.fprintf fmt "("; |
645 |
((__4 ()) fmt) arange; |
646 |
Format.fprintf fmt ")"; |
647 |
| Attribute { id = aid; designator = adesignator; expr = aexpr } -> |
648 |
((__5 ()) fmt) aid; |
649 |
Format.fprintf fmt "\'"; |
650 |
((__6 ()) fmt) adesignator; |
651 |
(match aexpr with |
652 |
| IsNull -> Format.fprintf fmt ""; |
653 |
| _ -> |
654 |
Format.fprintf fmt "("; |
655 |
((__7 ()) fmt) aexpr; |
656 |
Format.fprintf fmt ")") |
657 |
| Function { id = aid; assoc_list = aassoc_list } -> |
658 |
(((__8 ()) fmt) aid; |
659 |
Format.fprintf fmt "("; |
660 |
((fun x -> |
661 |
Format.fprintf fmt "@["; |
662 |
ignore |
663 |
(List.fold_left |
664 |
(fun sep -> |
665 |
fun x -> |
666 |
if sep then Format.fprintf fmt ";@ "; |
667 |
((__9 ()) fmt) x; |
668 |
true) false x); |
669 |
Format.fprintf fmt "@]")) aassoc_list; |
670 |
Format.fprintf fmt ")";) |
671 |
| NoName -> Format.pp_print_string fmt "") |
672 |
[@ocaml.warning "-A"]) |
673 |
|
674 |
and show_vhdl_name_t : vhdl_name_t -> Ppx_deriving_runtime.string = |
675 |
fun x -> Format.asprintf "%a" pp_vhdl_name_t x |
676 |
|
677 |
and pp_vhdl_assoc_element_t : |
678 |
Format.formatter -> vhdl_assoc_element_t -> Ppx_deriving_runtime.unit = |
679 |
let __4 () = pp_vhdl_expr_t |
680 |
|
681 |
and __3 () = pp_vhdl_name_t |
682 |
|
683 |
and __2 () = pp_vhdl_name_t |
684 |
|
685 |
and __1 () = pp_vhdl_name_t |
686 |
|
687 |
and __0 () = pp_vhdl_name_t |
688 |
in |
689 |
((let open! Ppx_deriving_runtime in |
690 |
fun fmt -> |
691 |
fun x -> |
692 |
(match x.formal_name with |
693 |
| None -> Format.pp_print_string fmt "" |
694 |
| Some NoName -> Format.pp_print_string fmt "" |
695 |
| Some a -> |
696 |
(((__0 ()) fmt) a; |
697 |
(match x.formal_arg with |
698 |
| None -> Format.pp_print_string fmt "" |
699 |
| Some b -> ((__1 ()) fmt) b); |
700 |
Format.fprintf fmt " => ")); |
701 |
(match x.actual_name with |
702 |
| None -> |
703 |
((match x.actual_designator with |
704 |
| None -> Format.pp_print_string fmt "" |
705 |
| Some NoName -> Format.pp_print_string fmt "" |
706 |
| Some b -> ((__3 ()) fmt) b); |
707 |
(match x.actual_expr with |
708 |
| None -> Format.pp_print_string fmt "" |
709 |
| Some IsNull -> Format.pp_print_string fmt "" |
710 |
| Some c -> ((__4 ()) fmt) c);) |
711 |
| Some a -> |
712 |
(((__2 ()) fmt) a; |
713 |
(match a with |
714 |
| NoName -> () |
715 |
| _ -> Format.fprintf fmt "("); |
716 |
(match x.actual_designator with |
717 |
| None -> Format.pp_print_string fmt "" |
718 |
| Some b -> ((__3 ()) fmt) b); |
719 |
(match x.actual_expr with |
720 |
| None -> Format.pp_print_string fmt "" |
721 |
| Some IsNull -> Format.pp_print_string fmt "" |
722 |
| Some c -> ((__4 ()) fmt) c); |
723 |
(match a with |
724 |
| NoName -> () |
725 |
| _ -> Format.fprintf fmt ")")));) |
726 |
[@ocaml.warning "-A"]) |
727 |
|
728 |
and show_vhdl_assoc_element_t : |
729 |
vhdl_assoc_element_t -> Ppx_deriving_runtime.string = |
730 |
fun x -> Format.asprintf "%a" pp_vhdl_assoc_element_t x |
731 |
|
732 |
and pp_vhdl_element_assoc_t : |
733 |
Format.formatter -> vhdl_element_assoc_t -> Ppx_deriving_runtime.unit = |
734 |
let __1 () = pp_vhdl_expr_t |
735 |
|
736 |
and __0 () = pp_vhdl_expr_t |
737 |
in |
738 |
((let open! Ppx_deriving_runtime in |
739 |
fun fmt -> |
740 |
fun x -> |
741 |
(match x.choices with |
742 |
| [] -> Format.fprintf fmt ""; |
743 |
| _ -> |
744 |
(((fun x -> |
745 |
ignore |
746 |
(List.fold_left |
747 |
(fun sep -> |
748 |
fun x -> |
749 |
if sep then Format.fprintf fmt "|@ "; |
750 |
((__0 ()) fmt) x; |
751 |
true) false x))) x.choices; |
752 |
Format.fprintf fmt " => ";)); |
753 |
((__1 ()) fmt) x.expr) |
754 |
[@ocaml.warning "-A"]) |
755 |
|
756 |
and show_vhdl_element_assoc_t : |
757 |
vhdl_element_assoc_t -> Ppx_deriving_runtime.string = |
758 |
fun x -> Format.asprintf "%a" pp_vhdl_element_assoc_t x |
759 |
|
760 |
(* TODO *) |
761 |
and (pp_vhdl_array_attributes_t : |
762 |
Format.formatter -> |
763 |
vhdl_array_attributes_t -> Ppx_deriving_runtime.unit) |
764 |
= |
765 |
((let open! Ppx_deriving_runtime in |
766 |
fun fmt -> |
767 |
function |
768 |
| AAttInt { id = aid; arg = aarg } -> |
769 |
(Format.fprintf fmt "@[<2>AAttInt {@,"; |
770 |
((Format.fprintf fmt "@[%s =@ " "id"; |
771 |
(Format.fprintf fmt "%S") aid; |
772 |
Format.fprintf fmt "@]"); |
773 |
Format.fprintf fmt ";@ "; |
774 |
Format.fprintf fmt "@[%s =@ " "arg"; |
775 |
(Format.fprintf fmt "%d") aarg; |
776 |
Format.fprintf fmt "@]"); |
777 |
Format.fprintf fmt "@]}") |
778 |
| AAttAscending -> Format.pp_print_string fmt "AAttAscending") |
779 |
[@ocaml.warning "-A"]) |
780 |
|
781 |
and show_vhdl_array_attributes_t : |
782 |
vhdl_array_attributes_t -> Ppx_deriving_runtime.string = |
783 |
fun x -> Format.asprintf "%a" pp_vhdl_array_attributes_t x |
784 |
|
785 |
(* TODO *) |
786 |
and (pp_vhdl_signal_attributes_t : |
787 |
Format.formatter -> |
788 |
vhdl_signal_attributes_t -> Ppx_deriving_runtime.unit) |
789 |
= |
790 |
((let open! Ppx_deriving_runtime in |
791 |
fun fmt -> |
792 |
function |
793 |
| SigAtt a0 -> |
794 |
(Format.fprintf fmt "(@[<2>SigAtt@ "; |
795 |
(Format.fprintf fmt "%S") a0; |
796 |
Format.fprintf fmt "@])")) |
797 |
[@ocaml.warning "-A"]) |
798 |
|
799 |
and show_vhdl_signal_attributes_t : |
800 |
vhdl_signal_attributes_t -> Ppx_deriving_runtime.string = |
801 |
fun x -> Format.asprintf "%a" pp_vhdl_signal_attributes_t x |
802 |
|
803 |
(* TODO *) |
804 |
and (pp_vhdl_string_attributes_t : |
805 |
Format.formatter -> |
806 |
vhdl_string_attributes_t -> Ppx_deriving_runtime.unit) |
807 |
= |
808 |
((let open! Ppx_deriving_runtime in |
809 |
fun fmt -> |
810 |
function |
811 |
| StringAtt a0 -> |
812 |
(Format.fprintf fmt "(@[<2>StringAtt@ "; |
813 |
(Format.fprintf fmt "%S") a0; |
814 |
Format.fprintf fmt "@])")) |
815 |
[@ocaml.warning "-A"]) |
816 |
|
817 |
and show_vhdl_string_attributes_t : |
818 |
vhdl_string_attributes_t -> Ppx_deriving_runtime.string = |
819 |
fun x -> Format.asprintf "%a" pp_vhdl_string_attributes_t x |
820 |
|
821 |
(* TODO *) |
822 |
and (pp_vhdl_suffix_selection_t : |
823 |
Format.formatter -> |
824 |
vhdl_suffix_selection_t -> Ppx_deriving_runtime.unit) |
825 |
= |
826 |
((let open! Ppx_deriving_runtime in |
827 |
fun fmt -> |
828 |
function |
829 |
| Idx a0 -> |
830 |
(Format.fprintf fmt "(@[<2>Idx@ "; |
831 |
(Format.fprintf fmt "%d") a0; |
832 |
Format.fprintf fmt "@])") |
833 |
| SuffixRange (a0,a1) -> |
834 |
(Format.fprintf fmt "(@[<2>SuffixRange (@,"; |
835 |
((Format.fprintf fmt "%d") a0; |
836 |
Format.fprintf fmt ",@ "; |
837 |
(Format.fprintf fmt "%d") a1); |
838 |
Format.fprintf fmt "@,))@]")) |
839 |
[@ocaml.warning "-A"]) |
840 |
|
841 |
and show_vhdl_suffix_selection_t : |
842 |
vhdl_suffix_selection_t -> Ppx_deriving_runtime.string = |
843 |
fun x -> Format.asprintf "%a" pp_vhdl_suffix_selection_t x |
844 |
|
845 |
let rec (vhdl_type_t_to_yojson : vhdl_type_t -> Yojson.Safe.json) = |
846 |
((let open! Ppx_deriving_yojson_runtime in |
847 |
function |
848 |
| Base arg0 -> |
849 |
`List |
850 |
[`String "Base"; |
851 |
((fun (x : Ppx_deriving_runtime.string) -> `String x)) arg0] |
852 |
| Range (arg0,arg1,arg2) -> |
853 |
`List |
854 |
[`String "Range"; |
855 |
((function |
856 |
| None -> `Null |
857 |
| Some x -> |
858 |
((fun (x : Ppx_deriving_runtime.string) -> `String x)) x)) |
859 |
arg0; |
860 |
((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg1; |
861 |
((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg2] |
862 |
| Bit_vector (arg0,arg1) -> |
863 |
`List |
864 |
[`String "Bit_vector"; |
865 |
((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg0; |
866 |
((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg1] |
867 |
| Array arg0 -> |
868 |
`List |
869 |
[`String "ARRAY_TYPE_DEFINITION"; |
870 |
(let fields = [] in |
871 |
let fields = |
872 |
("definition", |
873 |
((fun x -> vhdl_subtype_indication_t_to_yojson x) |
874 |
arg0.definition)) |
875 |
:: fields in |
876 |
let fields = |
877 |
if arg0.const = None |
878 |
then fields |
879 |
else |
880 |
("const", |
881 |
(((function |
882 |
| None -> `Null |
883 |
| Some x -> |
884 |
((fun x -> vhdl_constraint_t_to_yojson x)) x)) |
885 |
arg0.const)) |
886 |
:: fields |
887 |
in |
888 |
let fields = |
889 |
if arg0.indexes = [] |
890 |
then fields |
891 |
else |
892 |
("indexes", |
893 |
(((fun x -> |
894 |
`List |
895 |
(List.map (fun x -> vhdl_name_t_to_yojson x) x))) |
896 |
arg0.indexes)) |
897 |
:: fields |
898 |
in |
899 |
`Assoc fields)] |
900 |
| Record arg0 -> |
901 |
`List |
902 |
[`String "RECORD_TYPE_DEFINITION"; |
903 |
((fun x -> |
904 |
`List |
905 |
(List.map |
906 |
(fun x -> vhdl_element_declaration_t_to_yojson x) x))) |
907 |
arg0] |
908 |
| Enumerated arg0 -> |
909 |
`List |
910 |
[`String "ENUMERATION_TYPE_DEFINITION"; |
911 |
((fun x -> |
912 |
`List (List.map (fun x -> vhdl_name_t_to_yojson x) x))) arg0] |
913 |
| Void -> `List [`String "Void"]) |
914 |
[@ocaml.warning "-A"]) |
915 |
|
916 |
and (vhdl_type_t_of_yojson : |
917 |
Yojson.Safe.json -> vhdl_type_t Ppx_deriving_yojson_runtime.error_or) |
918 |
= |
919 |
((let open! Ppx_deriving_yojson_runtime in |
920 |
function |
921 |
| `List ((`String "Base")::arg0::[]) -> |
922 |
((function |
923 |
| `String x -> Result.Ok x |
924 |
| _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>= |
925 |
((fun arg0 -> Result.Ok (Base arg0))) |
926 |
| `List ((`String "Range")::arg0::arg1::arg2::[]) -> |
927 |
((function |
928 |
| `Int x -> Result.Ok x |
929 |
| _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg2) >>= |
930 |
((fun arg2 -> |
931 |
((function |
932 |
| `Int x -> Result.Ok x |
933 |
| _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg1) >>= |
934 |
(fun arg1 -> |
935 |
((function |
936 |
| `Null -> Result.Ok None |
937 |
| x -> |
938 |
((function |
939 |
| `String x -> Result.Ok x |
940 |
| _ -> Result.Error "Vhdl_ast.vhdl_type_t") x) |
941 |
>>= ((fun x -> Result.Ok (Some x)))) arg0) |
942 |
>>= |
943 |
(fun arg0 -> Result.Ok (Range (arg0, arg1, arg2)))))) |
944 |
| `List ((`String "Bit_vector")::arg0::arg1::[]) -> |
945 |
((function |
946 |
| `Int x -> Result.Ok x |
947 |
| _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg1) >>= |
948 |
((fun arg1 -> |
949 |
((function |
950 |
| `Int x -> Result.Ok x |
951 |
| _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>= |
952 |
(fun arg0 -> Result.Ok (Bit_vector (arg0, arg1))))) |
953 |
| `List ((`String "ARRAY_TYPE_DEFINITION")::arg0::[]) -> |
954 |
((function |
955 |
| `Assoc xs -> |
956 |
let rec loop xs ((arg0,arg1,arg2) as _state) = |
957 |
match xs with |
958 |
| ("indexes",x)::xs -> |
959 |
loop xs |
960 |
(((function |
961 |
| `List xs -> |
962 |
map_bind (fun x -> vhdl_name_t_of_yojson x) |
963 |
[] xs |
964 |
| _ -> Result.Error "Vhdl_ast.vhdl_type_t.indexes") |
965 |
x), arg1, arg2) |
966 |
| ("const",x)::xs -> |
967 |
loop xs |
968 |
(arg0, |
969 |
((function |
970 |
| `Null -> Result.Ok None |
971 |
| x -> |
972 |
((fun x -> vhdl_constraint_t_of_yojson x) x) |
973 |
>>= ((fun x -> Result.Ok (Some x)))) x), |
974 |
arg2) |
975 |
| ("definition",x)::xs -> |
976 |
loop xs |
977 |
(arg0, arg1, |
978 |
((fun x -> vhdl_subtype_indication_t_of_yojson x) |
979 |
x)) |
980 |
| [] -> |
981 |
arg2 >>= |
982 |
((fun arg2 -> |
983 |
arg1 >>= |
984 |
(fun arg1 -> |
985 |
arg0 >>= |
986 |
(fun arg0 -> |
987 |
Result.Ok |
988 |
(Array |
989 |
{ |
990 |
indexes = arg0; |
991 |
const = arg1; |
992 |
definition = arg2 |
993 |
}))))) |
994 |
| _::xs -> loop xs _state in |
995 |
loop xs |
996 |
((Result.Ok []), (Result.Ok None), |
997 |
(Result.Error "Vhdl_ast.vhdl_type_t.definition")) |
998 |
| _ -> Result.Error "Vhdl_ast.vhdl_type_t")) arg0 |
999 |
| `List ((`String "RECORD_TYPE_DEFINITION")::arg0::[]) -> |
1000 |
((function |
1001 |
| `List xs -> |
1002 |
map_bind (fun x -> vhdl_element_declaration_t_of_yojson x) |
1003 |
[] xs |
1004 |
| _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>= |
1005 |
((fun arg0 -> Result.Ok (Record arg0))) |
1006 |
| `List ((`String "ENUMERATION_TYPE_DEFINITION")::arg0::[]) -> |
1007 |
((function |
1008 |
| `List xs -> map_bind (fun x -> vhdl_name_t_of_yojson x) [] xs |
1009 |
| _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>= |
1010 |
((fun arg0 -> Result.Ok (Enumerated arg0))) |
1011 |
| `List ((`String "Void")::[]) -> Result.Ok Void |
1012 |
| _ -> Result.Error "Vhdl_ast.vhdl_type_t") |
1013 |
[@ocaml.warning "-A"]) |
1014 |
|
1015 |
and (vhdl_element_declaration_t_to_yojson : |
1016 |
vhdl_element_declaration_t -> Yojson.Safe.json) |
1017 |
= |
1018 |
((let open! Ppx_deriving_yojson_runtime in |
1019 |
fun x -> |
1020 |
let fields = [] in |
1021 |
let fields = |
1022 |
("definition", |
1023 |
((fun x -> vhdl_subtype_indication_t_to_yojson x) x.definition)) |
1024 |
:: fields in |
1025 |
let fields = |
1026 |
("names", |
1027 |
((fun x -> |
1028 |
`List (List.map (fun x -> vhdl_name_t_to_yojson x) x)) |
1029 |
x.names)) |
1030 |
:: fields in |
1031 |
`Assoc fields) |
1032 |
[@ocaml.warning "-A"]) |
1033 |
|
1034 |
and (vhdl_element_declaration_t_of_yojson : |
1035 |
Yojson.Safe.json -> |
1036 |
vhdl_element_declaration_t Ppx_deriving_yojson_runtime.error_or) |
1037 |
= |
1038 |
((let open! Ppx_deriving_yojson_runtime in |
1039 |
function |
1040 |
| `Assoc xs -> |
1041 |
let rec loop xs ((arg0,arg1) as _state) = |
1042 |
match xs with |
1043 |
| ("names",x)::xs -> |
1044 |
loop xs |
1045 |
(((function |
1046 |
| `List xs -> |
1047 |
map_bind (fun x -> vhdl_name_t_of_yojson x) [] xs |
1048 |
| _ -> |
1049 |
Result.Error |
1050 |
"Vhdl_ast.vhdl_element_declaration_t.names") x), |
1051 |
arg1) |
1052 |
| ("definition",x)::xs -> |
1053 |
loop xs |
1054 |
(arg0, |
1055 |
((fun x -> vhdl_subtype_indication_t_of_yojson x) x)) |
1056 |
| [] -> |
1057 |
arg1 >>= |
1058 |
((fun arg1 -> |
1059 |
arg0 >>= |
1060 |
(fun arg0 -> |
1061 |
Result.Ok { names = arg0; definition = arg1 }))) |
1062 |
| _::xs -> loop xs _state in |
1063 |
loop xs |
1064 |
((Result.Error "Vhdl_ast.vhdl_element_declaration_t.names"), |
1065 |
(Result.Error "Vhdl_ast.vhdl_element_declaration_t.definition")) |
1066 |
| _ -> Result.Error "Vhdl_ast.vhdl_element_declaration_t") |
1067 |
[@ocaml.warning "-A"]) |
1068 |
|
1069 |
and (vhdl_subtype_indication_t_to_yojson : |
1070 |
vhdl_subtype_indication_t -> Yojson.Safe.json) |
1071 |
= |
1072 |
((let open! Ppx_deriving_yojson_runtime in |
1073 |
fun x -> |
1074 |
let fields = [] in |
1075 |
let fields = |
1076 |
if x.const = NoConstraint |
1077 |
then fields |
1078 |
else |
1079 |
("const", (((fun x -> vhdl_constraint_t_to_yojson x)) x.const)) |
1080 |
:: fields |
1081 |
in |
1082 |
let fields = |
1083 |
if x.functionName = NoName |
1084 |
then fields |
1085 |
else |
1086 |
("functionName", |
1087 |
(((fun x -> vhdl_name_t_to_yojson x)) x.functionName)) |
1088 |
:: fields |
1089 |
in |
1090 |
let fields = |
1091 |
if x.name = NoName |
1092 |
then fields |
1093 |
else ("name", (((fun x -> vhdl_name_t_to_yojson x)) x.name)) :: |
1094 |
fields |
1095 |
in |
1096 |
`Assoc fields) |
1097 |
[@ocaml.warning "-A"]) |
1098 |
|
1099 |
and (vhdl_subtype_indication_t_of_yojson : |
1100 |
Yojson.Safe.json -> |
1101 |
vhdl_subtype_indication_t Ppx_deriving_yojson_runtime.error_or) |
1102 |
= |
1103 |
((let open! Ppx_deriving_yojson_runtime in |
1104 |
function |
1105 |
| `Assoc xs -> |
1106 |
let rec loop xs ((arg0,arg1,arg2) as _state) = |
1107 |
match xs with |
1108 |
| ("name",x)::xs -> |
1109 |
loop xs (((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2) |
1110 |
| ("functionName",x)::xs -> |
1111 |
loop xs (arg0, ((fun x -> vhdl_name_t_of_yojson x) x), arg2) |
1112 |
| ("const",x)::xs -> |
1113 |
loop xs |
1114 |
(arg0, arg1, ((fun x -> vhdl_constraint_t_of_yojson x) x)) |
1115 |
| [] -> |
1116 |
arg2 >>= |
1117 |
((fun arg2 -> |
1118 |
arg1 >>= |
1119 |
(fun arg1 -> |
1120 |
arg0 >>= |
1121 |
(fun arg0 -> |
1122 |
Result.Ok |
1123 |
{ |
1124 |
name = arg0; |
1125 |
functionName = arg1; |
1126 |
const = arg2 |
1127 |
})))) |
1128 |
| _::xs -> loop xs _state in |
1129 |
loop xs |
1130 |
((Result.Ok NoName), (Result.Ok NoName), |
1131 |
(Result.Ok NoConstraint)) |
1132 |
| _ -> Result.Error "Vhdl_ast.vhdl_subtype_indication_t") |
1133 |
[@ocaml.warning "-A"]) |
1134 |
|
1135 |
and (vhdl_discrete_range_t_to_yojson : |
1136 |
vhdl_discrete_range_t -> Yojson.Safe.json) |
1137 |
= |
1138 |
((let open! Ppx_deriving_yojson_runtime in |
1139 |
function |
1140 |
| SubDiscreteRange arg0 -> |
1141 |
`List |
1142 |
[`String "SUB_DISCRETE_RANGE"; |
1143 |
((fun x -> vhdl_subtype_indication_t_to_yojson x)) arg0] |
1144 |
| NamedRange arg0 -> |
1145 |
`List |
1146 |
[`String "NAMED_RANGE"; |
1147 |
((fun x -> vhdl_name_t_to_yojson x)) arg0] |
1148 |
| DirectedRange arg0 -> |
1149 |
`List |
1150 |
[`String "RANGE_WITH_DIRECTION"; |
1151 |
(let fields = [] in |
1152 |
let fields = |
1153 |
("_to", ((fun x -> vhdl_expr_t_to_yojson x) arg0._to)) :: |
1154 |
fields in |
1155 |
let fields = |
1156 |
("from", ((fun x -> vhdl_expr_t_to_yojson x) arg0.from)) :: |
1157 |
fields in |
1158 |
let fields = |
1159 |
("direction", |
1160 |
((fun (x : Ppx_deriving_runtime.string) -> `String x) |
1161 |
arg0.direction)) |
1162 |
:: fields in |
1163 |
`Assoc fields)]) |
1164 |
[@ocaml.warning "-A"]) |
1165 |
|
1166 |
and (vhdl_discrete_range_t_of_yojson : |
1167 |
Yojson.Safe.json -> |
1168 |
vhdl_discrete_range_t Ppx_deriving_yojson_runtime.error_or) |
1169 |
= |
1170 |
((let open! Ppx_deriving_yojson_runtime in |
1171 |
function |
1172 |
| `List ((`String "SUB_DISCRETE_RANGE")::arg0::[]) -> |
1173 |
((fun x -> vhdl_subtype_indication_t_of_yojson x) arg0) >>= |
1174 |
((fun arg0 -> Result.Ok (SubDiscreteRange arg0))) |
1175 |
| `List ((`String "NAMED_RANGE")::arg0::[]) -> |
1176 |
((fun x -> vhdl_name_t_of_yojson x) arg0) >>= |
1177 |
((fun arg0 -> Result.Ok (NamedRange arg0))) |
1178 |
| `List ((`String "RANGE_WITH_DIRECTION")::arg0::[]) -> |
1179 |
((function |
1180 |
| `Assoc xs -> |
1181 |
let rec loop xs ((arg0,arg1,arg2) as _state) = |
1182 |
match xs with |
1183 |
| ("direction",x)::xs -> |
1184 |
loop xs |
1185 |
(((function |
1186 |
| `String x -> Result.Ok x |
1187 |
| _ -> |
1188 |
Result.Error |
1189 |
"Vhdl_ast.vhdl_discrete_range_t.direction") |
1190 |
x), arg1, arg2) |
1191 |
| ("from",x)::xs -> |
1192 |
loop xs |
1193 |
(arg0, ((fun x -> vhdl_expr_t_of_yojson x) x), arg2) |
1194 |
| ("_to",x)::xs -> |
1195 |
loop xs |
1196 |
(arg0, arg1, ((fun x -> vhdl_expr_t_of_yojson x) x)) |
1197 |
| [] -> |
1198 |
arg2 >>= |
1199 |
((fun arg2 -> |
1200 |
arg1 >>= |
1201 |
(fun arg1 -> |
1202 |
arg0 >>= |
1203 |
(fun arg0 -> |
1204 |
Result.Ok |
1205 |
(DirectedRange |
1206 |
{ |
1207 |
direction = arg0; |
1208 |
from = arg1; |
1209 |
_to = arg2 |
1210 |
}))))) |
1211 |
| _::xs -> loop xs _state in |
1212 |
loop xs |
1213 |
((Result.Error "Vhdl_ast.vhdl_discrete_range_t.direction"), |
1214 |
(Result.Error "Vhdl_ast.vhdl_discrete_range_t.from"), |
1215 |
(Result.Error "Vhdl_ast.vhdl_discrete_range_t._to")) |
1216 |
| _ -> Result.Error "Vhdl_ast.vhdl_discrete_range_t")) arg0 |
1217 |
| _ -> Result.Error "Vhdl_ast.vhdl_discrete_range_t") |
1218 |
[@ocaml.warning "-A"]) |
1219 |
|
1220 |
and (vhdl_constraint_t_to_yojson : vhdl_constraint_t -> Yojson.Safe.json) = |
1221 |
((let open! Ppx_deriving_yojson_runtime in |
1222 |
function |
1223 |
| RefConstraint arg0 -> |
1224 |
`List |
1225 |
[`String "RefConstraint"; |
1226 |
(let fields = [] in |
1227 |
let fields = |
1228 |
("ref_name", |
1229 |
((fun x -> vhdl_name_t_to_yojson x) arg0.ref_name)) |
1230 |
:: fields in |
1231 |
`Assoc fields)] |
1232 |
| RangeConstraint arg0 -> |
1233 |
`List |
1234 |
[`String "RANGE_CONSTRAINT"; |
1235 |
(let fields = [] in |
1236 |
let fields = |
1237 |
("range", |
1238 |
((fun x -> vhdl_discrete_range_t_to_yojson x) arg0.range)) |
1239 |
:: fields in |
1240 |
`Assoc fields)] |
1241 |
| IndexConstraint arg0 -> |
1242 |
`List |
1243 |
[`String "INDEX_CONSTRAINT"; |
1244 |
(let fields = [] in |
1245 |
let fields = |
1246 |
("ranges", |
1247 |
((fun x -> |
1248 |
`List |
1249 |
(List.map |
1250 |
(fun x -> vhdl_discrete_range_t_to_yojson x) x)) |
1251 |
arg0.ranges)) |
1252 |
:: fields in |
1253 |
`Assoc fields)] |
1254 |
| ArrayConstraint arg0 -> |
1255 |
`List |
1256 |
[`String "ARRAY_CONSTRAINT"; |
1257 |
(let fields = [] in |
1258 |
let fields = |
1259 |
("sub", ((fun x -> vhdl_constraint_t_to_yojson x) arg0.sub)) |
1260 |
:: fields in |
1261 |
let fields = |
1262 |
("ranges", |
1263 |
((fun x -> |
1264 |
`List |
1265 |
(List.map |
1266 |
(fun x -> vhdl_discrete_range_t_to_yojson x) x)) |
1267 |
arg0.ranges)) |
1268 |
:: fields in |
1269 |
`Assoc fields)] |
1270 |
| RecordConstraint -> `List [`String "RecordConstraint"] |
1271 |
| NoConstraint -> `List [`String "NoConstraint"]) |
1272 |
[@ocaml.warning "-A"]) |
1273 |
|
1274 |
and (vhdl_constraint_t_of_yojson : |
1275 |
Yojson.Safe.json -> |
1276 |
vhdl_constraint_t Ppx_deriving_yojson_runtime.error_or) |
1277 |
= |
1278 |
((let open! Ppx_deriving_yojson_runtime in |
1279 |
function |
1280 |
| `List ((`String "RefConstraint")::arg0::[]) -> |
1281 |
((function |
1282 |
| `Assoc xs -> |
1283 |
let rec loop xs (arg0 as _state) = |
1284 |
match xs with |
1285 |
| ("ref_name",x)::xs -> |
1286 |
loop xs ((fun x -> vhdl_name_t_of_yojson x) x) |
1287 |
| [] -> |
1288 |
arg0 >>= |
1289 |
((fun arg0 -> |
1290 |
Result.Ok (RefConstraint { ref_name = arg0 }))) |
1291 |
| _::xs -> loop xs _state in |
1292 |
loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.ref_name") |
1293 |
| _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0 |
1294 |
| `List ((`String "RANGE_CONSTRAINT")::arg0::[]) -> |
1295 |
((function |
1296 |
| `Assoc xs -> |
1297 |
let rec loop xs (arg0 as _state) = |
1298 |
match xs with |
1299 |
| ("range",x)::xs -> |
1300 |
loop xs |
1301 |
((fun x -> vhdl_discrete_range_t_of_yojson x) x) |
1302 |
| [] -> |
1303 |
arg0 >>= |
1304 |
((fun arg0 -> |
1305 |
Result.Ok (RangeConstraint { range = arg0 }))) |
1306 |
| _::xs -> loop xs _state in |
1307 |
loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.range") |
1308 |
| _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0 |
1309 |
| `List ((`String "INDEX_CONSTRAINT")::arg0::[]) -> |
1310 |
((function |
1311 |
| `Assoc xs -> |
1312 |
let rec loop xs (arg0 as _state) = |
1313 |
match xs with |
1314 |
| ("ranges",x)::xs -> |
1315 |
loop xs |
1316 |
((function |
1317 |
| `List xs -> |
1318 |
map_bind |
1319 |
(fun x -> vhdl_discrete_range_t_of_yojson x) |
1320 |
[] xs |
1321 |
| _ -> |
1322 |
Result.Error |
1323 |
"Vhdl_ast.vhdl_constraint_t.ranges") x) |
1324 |
| [] -> |
1325 |
arg0 >>= |
1326 |
((fun arg0 -> |
1327 |
Result.Ok (IndexConstraint { ranges = arg0 }))) |
1328 |
| _::xs -> loop xs _state in |
1329 |
loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.ranges") |
1330 |
| _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0 |
1331 |
| `List ((`String "ARRAY_CONSTRAINT")::arg0::[]) -> |
1332 |
((function |
1333 |
| `Assoc xs -> |
1334 |
let rec loop xs ((arg0,arg1) as _state) = |
1335 |
match xs with |
1336 |
| ("ranges",x)::xs -> |
1337 |
loop xs |
1338 |
(((function |
1339 |
| `List xs -> |
1340 |
map_bind |
1341 |
(fun x -> vhdl_discrete_range_t_of_yojson x) |
1342 |
[] xs |
1343 |
| _ -> |
1344 |
Result.Error |
1345 |
"Vhdl_ast.vhdl_constraint_t.ranges") x), |
1346 |
arg1) |
1347 |
| ("sub",x)::xs -> |
1348 |
loop xs |
1349 |
(arg0, ((fun x -> vhdl_constraint_t_of_yojson x) x)) |
1350 |
| [] -> |
1351 |
arg1 >>= |
1352 |
((fun arg1 -> |
1353 |
arg0 >>= |
1354 |
(fun arg0 -> |
1355 |
Result.Ok |
1356 |
(ArrayConstraint |
1357 |
{ ranges = arg0; sub = arg1 })))) |
1358 |
| _::xs -> loop xs _state in |
1359 |
loop xs |
1360 |
((Result.Error "Vhdl_ast.vhdl_constraint_t.ranges"), |
1361 |
(Result.Error "Vhdl_ast.vhdl_constraint_t.sub")) |
1362 |
| _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0 |
1363 |
| `List ((`String "RecordConstraint")::[]) -> |
1364 |
Result.Ok RecordConstraint |
1365 |
| `List ((`String "NoConstraint")::[]) -> Result.Ok NoConstraint |
1366 |
| _ -> Result.Error "Vhdl_ast.vhdl_constraint_t") |
1367 |
[@ocaml.warning "-A"]) |
1368 |
|
1369 |
and (vhdl_definition_t_to_yojson : vhdl_definition_t -> Yojson.Safe.json) = |
1370 |
((let open! Ppx_deriving_yojson_runtime in |
1371 |
function |
1372 |
| Type arg0 -> |
1373 |
`List |
1374 |
[`String "TYPE_DECLARATION"; |
1375 |
(let fields = [] in |
1376 |
let fields = |
1377 |
("definition", |
1378 |
((fun x -> vhdl_type_t_to_yojson x) arg0.definition)) |
1379 |
:: fields in |
1380 |
let fields = |
1381 |
("name", ((fun x -> vhdl_name_t_to_yojson x) arg0.name)) :: |
1382 |
fields in |
1383 |
`Assoc fields)] |
1384 |
| Subtype arg0 -> |
1385 |
`List |
1386 |
[`String "SUBTYPE_DECLARATION"; |
1387 |
(let fields = [] in |
1388 |
let fields = |
1389 |
("typ", |
1390 |
((fun x -> vhdl_subtype_indication_t_to_yojson x) arg0.typ)) |
1391 |
:: fields in |
1392 |
let fields = |
1393 |
("name", ((fun x -> vhdl_name_t_to_yojson x) arg0.name)) :: |
1394 |
fields in |
1395 |
`Assoc fields)]) |
1396 |
[@ocaml.warning "-A"]) |
1397 |
|
1398 |
and (vhdl_definition_t_of_yojson : |
1399 |
Yojson.Safe.json -> |
1400 |
vhdl_definition_t Ppx_deriving_yojson_runtime.error_or) |
1401 |
= |
1402 |
((let open! Ppx_deriving_yojson_runtime in |
1403 |
function |
1404 |
| `List ((`String "TYPE_DECLARATION")::arg0::[]) -> |
1405 |
((function |
1406 |
| `Assoc xs -> |
1407 |
let rec loop xs ((arg0,arg1) as _state) = |
1408 |
match xs with |
1409 |
| ("name",x)::xs -> |
1410 |
loop xs (((fun x -> vhdl_name_t_of_yojson x) x), arg1) |
1411 |
| ("definition",x)::xs -> |
1412 |
loop xs (arg0, ((fun x -> vhdl_type_t_of_yojson x) x)) |
1413 |
| [] -> |
1414 |
arg1 >>= |
1415 |
((fun arg1 -> |
1416 |
arg0 >>= |
1417 |
(fun arg0 -> |
1418 |
Result.Ok |
1419 |
(Type { name = arg0; definition = arg1 })))) |
1420 |
| _::xs -> loop xs _state in |
1421 |
loop xs |
1422 |
((Result.Error "Vhdl_ast.vhdl_definition_t.name"), |
1423 |
(Result.Error "Vhdl_ast.vhdl_definition_t.definition")) |
1424 |
| _ -> Result.Error "Vhdl_ast.vhdl_definition_t")) arg0 |
1425 |
| `List ((`String "SUBTYPE_DECLARATION")::arg0::[]) -> |
1426 |
((function |
1427 |
| `Assoc xs -> |
1428 |
let rec loop xs ((arg0,arg1) as _state) = |
1429 |
match xs with |
1430 |
| ("name",x)::xs -> |
1431 |
loop xs (((fun x -> vhdl_name_t_of_yojson x) x), arg1) |
1432 |
| ("typ",x)::xs -> |
1433 |
loop xs |
1434 |
(arg0, |
1435 |
((fun x -> vhdl_subtype_indication_t_of_yojson x) |
1436 |
x)) |
1437 |
| [] -> |
1438 |
arg1 >>= |
1439 |
((fun arg1 -> |
1440 |
arg0 >>= |
1441 |
(fun arg0 -> |
1442 |
Result.Ok |
1443 |
(Subtype { name = arg0; typ = arg1 })))) |
1444 |
| _::xs -> loop xs _state in |
1445 |
loop xs |
1446 |
((Result.Error "Vhdl_ast.vhdl_definition_t.name"), |
1447 |
(Result.Error "Vhdl_ast.vhdl_definition_t.typ")) |
1448 |
| _ -> Result.Error "Vhdl_ast.vhdl_definition_t")) arg0 |
1449 |
| _ -> Result.Error "Vhdl_ast.vhdl_definition_t") |
1450 |
[@ocaml.warning "-A"]) |
1451 |
|
1452 |
and (vhdl_expr_t_to_yojson : vhdl_expr_t -> Yojson.Safe.json) = |
1453 |
((let open! Ppx_deriving_yojson_runtime in |
1454 |
function |
1455 |
| Call arg0 -> |
1456 |
`List [`String "CALL"; ((fun x -> vhdl_name_t_to_yojson x)) arg0] |
1457 |
| Cst arg0 -> |
1458 |
`List |
1459 |
[`String "CONSTANT_VALUE"; |
1460 |
(let fields = [] in |
1461 |
let fields = |
1462 |
if arg0.unit_name = None |
1463 |
then fields |
1464 |
else |
1465 |
("unit_name", |
1466 |
(((function |
1467 |
| None -> `Null |
1468 |
| Some x -> ((fun x -> vhdl_name_t_to_yojson x)) x)) |
1469 |
arg0.unit_name)) |
1470 |
:: fields |
1471 |
in |
1472 |
let fields = |
1473 |
("value", ((fun x -> vhdl_cst_val_t_to_yojson x) arg0.value)) |
1474 |
:: fields in |
1475 |
`Assoc fields)] |
1476 |
| Op arg0 -> |
1477 |
`List |
1478 |
[`String "EXPRESSION"; |
1479 |
(let fields = [] in |
1480 |
let fields = |
1481 |
if arg0.args = [] |
1482 |
then fields |
1483 |
else |
1484 |
("args", |
1485 |
(((fun x -> |
1486 |
`List |
1487 |
(List.map (fun x -> vhdl_expr_t_to_yojson x) x))) |
1488 |
arg0.args)) |
1489 |
:: fields |
1490 |
in |
1491 |
let fields = |
1492 |
if arg0.id = "" |
1493 |
then fields |
1494 |
else |
1495 |
("id", |
1496 |
(((fun (x : Ppx_deriving_runtime.string) -> `String x)) |
1497 |
arg0.id)) |
1498 |
:: fields |
1499 |
in |
1500 |
`Assoc fields)] |
1501 |
| IsNull -> `List [`String "IsNull"] |
1502 |
| Time arg0 -> |
1503 |
`List |
1504 |
[`String "Time"; |
1505 |
(let fields = [] in |
1506 |
let fields = |
1507 |
if arg0.phy_unit = "" |
1508 |
then fields |
1509 |
else |
1510 |
("phy_unit", |
1511 |
(((fun (x : Ppx_deriving_runtime.string) -> `String x)) |
1512 |
arg0.phy_unit)) |
1513 |
:: fields |
1514 |
in |
1515 |
let fields = |
1516 |
("value", |
1517 |
((fun (x : Ppx_deriving_runtime.int) -> `Int x) arg0.value)) |
1518 |
:: fields in |
1519 |
`Assoc fields)] |
1520 |
| Sig arg0 -> |
1521 |
`List |
1522 |
[`String "Sig"; |
1523 |
(let fields = [] in |
1524 |
let fields = |
1525 |
if arg0.att = None |
1526 |
then fields |
1527 |
else |
1528 |
("att", |
1529 |
(((function |
1530 |
| None -> `Null |
1531 |
| Some x -> |
1532 |
((fun x -> vhdl_signal_attributes_t_to_yojson x)) |
1533 |
x)) arg0.att)) |
1534 |
:: fields |
1535 |
in |
1536 |
let fields = |
1537 |
("name", ((fun x -> vhdl_name_t_to_yojson x) arg0.name)) :: |
1538 |
fields in |
1539 |
`Assoc fields)] |
1540 |
| SuffixMod arg0 -> |
1541 |
`List |
1542 |
[`String "SuffixMod"; |
1543 |
(let fields = [] in |
1544 |
let fields = |
1545 |
("selection", |
1546 |
((fun x -> vhdl_suffix_selection_t_to_yojson x) |
1547 |
arg0.selection)) |
1548 |
:: fields in |
1549 |
let fields = |
1550 |
("expr", ((fun x -> vhdl_expr_t_to_yojson x) arg0.expr)) :: |
1551 |
fields in |
1552 |
`Assoc fields)] |
1553 |
| Aggregate arg0 -> |
1554 |
`List |
1555 |
[`String "AGGREGATE"; |
1556 |
(let fields = [] in |
1557 |
let fields = |
1558 |
if arg0.elems = [] |
1559 |
then fields |
1560 |
else |
1561 |
("elems", |
1562 |
(((fun x -> |
1563 |
`List |
1564 |
(List.map |
1565 |
(fun x -> vhdl_element_assoc_t_to_yojson x) x))) |
1566 |
arg0.elems)) |
1567 |
:: fields |
1568 |
in |
1569 |
`Assoc fields)] |
1570 |
| QualifiedExpression arg0 -> |
1571 |
`List |
1572 |
[`String "QUALIFIED_EXPRESSION"; |
1573 |
(let fields = [] in |
1574 |
let fields = |
1575 |
if arg0.expression = None |
1576 |
then fields |
1577 |
else |
1578 |
("expression", |
1579 |
(((function |
1580 |
| None -> `Null |
1581 |
| Some x -> ((fun x -> vhdl_expr_t_to_yojson x)) x)) |
1582 |
arg0.expression)) |
1583 |
:: fields |
1584 |
in |
1585 |
let fields = |
1586 |
if arg0.aggregate = [] |
1587 |
then fields |
1588 |
else |
1589 |
("aggregate", |
1590 |
(((fun x -> |
1591 |
`List |
1592 |
(List.map |
1593 |
(fun x -> vhdl_element_assoc_t_to_yojson x) x))) |
1594 |
arg0.aggregate)) |
1595 |
:: fields |
1596 |
in |
1597 |
let fields = |
1598 |
("type_mark", |
1599 |
((fun x -> vhdl_name_t_to_yojson x) arg0.type_mark)) |
1600 |
:: fields in |
1601 |
`Assoc fields)] |
1602 |
| Others -> `List [`String "OTHERS"]) |
1603 |
[@ocaml.warning "-A"]) |
1604 |
|
1605 |
and (vhdl_expr_t_of_yojson : |
1606 |
Yojson.Safe.json -> vhdl_expr_t Ppx_deriving_yojson_runtime.error_or) |
1607 |
= |
1608 |
((let open! Ppx_deriving_yojson_runtime in |
1609 |
function |
1610 |
| `List ((`String "CALL")::arg0::[]) -> |
1611 |
((fun x -> vhdl_name_t_of_yojson x) arg0) >>= |
1612 |
((fun arg0 -> Result.Ok (Call arg0))) |
1613 |
| `List ((`String "CONSTANT_VALUE")::arg0::[]) -> |
1614 |
((function |
1615 |
| `Assoc xs -> |
1616 |
let rec loop xs ((arg0,arg1) as _state) = |
1617 |
match xs with |
1618 |
| ("value",x)::xs -> |
1619 |
loop xs |
1620 |
(((fun x -> vhdl_cst_val_t_of_yojson x) x), arg1) |
1621 |
| ("unit_name",x)::xs -> |
1622 |
loop xs |
1623 |
(arg0, |
1624 |
((function |
1625 |
| `Null -> Result.Ok None |
1626 |
| x -> |
1627 |
((fun x -> vhdl_name_t_of_yojson x) x) >>= |
1628 |
((fun x -> Result.Ok (Some x)))) x)) |
1629 |
| [] -> |
1630 |
arg1 >>= |
1631 |
((fun arg1 -> |
1632 |
arg0 >>= |
1633 |
(fun arg0 -> |
1634 |
Result.Ok |
1635 |
(Cst { value = arg0; unit_name = arg1 })))) |
1636 |
| _::xs -> loop xs _state in |
1637 |
loop xs |
1638 |
((Result.Error "Vhdl_ast.vhdl_expr_t.value"), |
1639 |
(Result.Ok None)) |
1640 |
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0 |
1641 |
| `List ((`String "EXPRESSION")::arg0::[]) -> |
1642 |
((function |
1643 |
| `Assoc xs -> |
1644 |
let rec loop xs ((arg0,arg1) as _state) = |
1645 |
match xs with |
1646 |
| ("id",x)::xs -> |
1647 |
loop xs |
1648 |
(((function |
1649 |
| `String x -> Result.Ok x |
1650 |
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t.id") x), |
1651 |
arg1) |
1652 |
| ("args",x)::xs -> |
1653 |
loop xs |
1654 |
(arg0, |
1655 |
((function |
1656 |
| `List xs -> |
1657 |
map_bind (fun x -> vhdl_expr_t_of_yojson x) |
1658 |
[] xs |
1659 |
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t.args") |
1660 |
x)) |
1661 |
| [] -> |
1662 |
arg1 >>= |
1663 |
((fun arg1 -> |
1664 |
arg0 >>= |
1665 |
(fun arg0 -> |
1666 |
Result.Ok (Op { id = arg0; args = arg1 })))) |
1667 |
| _::xs -> loop xs _state in |
1668 |
loop xs ((Result.Ok ""), (Result.Ok [])) |
1669 |
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0 |
1670 |
| `List ((`String "IsNull")::[]) -> Result.Ok IsNull |
1671 |
| `List ((`String "Time")::arg0::[]) -> |
1672 |
((function |
1673 |
| `Assoc xs -> |
1674 |
let rec loop xs ((arg0,arg1) as _state) = |
1675 |
match xs with |
1676 |
| ("value",x)::xs -> |
1677 |
loop xs |
1678 |
(((function |
1679 |
| `Int x -> Result.Ok x |
1680 |
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t.value") |
1681 |
x), arg1) |
1682 |
| ("phy_unit",x)::xs -> |
1683 |
loop xs |
1684 |
(arg0, |
1685 |
((function |
1686 |
| `String x -> Result.Ok x |
1687 |
| _ -> |
1688 |
Result.Error "Vhdl_ast.vhdl_expr_t.phy_unit") |
1689 |
x)) |
1690 |
| [] -> |
1691 |
arg1 >>= |
1692 |
((fun arg1 -> |
1693 |
arg0 >>= |
1694 |
(fun arg0 -> |
1695 |
Result.Ok |
1696 |
(Time { value = arg0; phy_unit = arg1 })))) |
1697 |
| _::xs -> loop xs _state in |
1698 |
loop xs |
1699 |
((Result.Error "Vhdl_ast.vhdl_expr_t.value"), |
1700 |
(Result.Ok "")) |
1701 |
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0 |
1702 |
| `List ((`String "Sig")::arg0::[]) -> |
1703 |
((function |
1704 |
| `Assoc xs -> |
1705 |
let rec loop xs ((arg0,arg1) as _state) = |
1706 |
match xs with |
1707 |
| ("name",x)::xs -> |
1708 |
loop xs (((fun x -> vhdl_name_t_of_yojson x) x), arg1) |
1709 |
| ("att",x)::xs -> |
1710 |
loop xs |
1711 |
(arg0, |
1712 |
((function |
1713 |
| `Null -> Result.Ok None |
1714 |
| x -> |
1715 |
((fun x -> |
1716 |
vhdl_signal_attributes_t_of_yojson x) x) |
1717 |
>>= ((fun x -> Result.Ok (Some x)))) x)) |
1718 |
| [] -> |
1719 |
arg1 >>= |
1720 |
((fun arg1 -> |
1721 |
arg0 >>= |
1722 |
(fun arg0 -> |
1723 |
Result.Ok (Sig { name = arg0; att = arg1 })))) |
1724 |
| _::xs -> loop xs _state in |
1725 |
loop xs |
1726 |
((Result.Error "Vhdl_ast.vhdl_expr_t.name"), |
1727 |
(Result.Ok None)) |
1728 |
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0 |
1729 |
| `List ((`String "SuffixMod")::arg0::[]) -> |
1730 |
((function |
1731 |
| `Assoc xs -> |
1732 |
let rec loop xs ((arg0,arg1) as _state) = |
1733 |
match xs with |
1734 |
| ("expr",x)::xs -> |
1735 |
loop xs (((fun x -> vhdl_expr_t_of_yojson x) x), arg1) |
1736 |
| ("selection",x)::xs -> |
1737 |
loop xs |
1738 |
(arg0, |
1739 |
((fun x -> vhdl_suffix_selection_t_of_yojson x) x)) |
1740 |
| [] -> |
1741 |
arg1 >>= |
1742 |
((fun arg1 -> |
1743 |
arg0 >>= |
1744 |
(fun arg0 -> |
1745 |
Result.Ok |
1746 |
(SuffixMod |
1747 |
{ expr = arg0; selection = arg1 })))) |
1748 |
| _::xs -> loop xs _state in |
1749 |
loop xs |
1750 |
((Result.Error "Vhdl_ast.vhdl_expr_t.expr"), |
1751 |
(Result.Error "Vhdl_ast.vhdl_expr_t.selection")) |
1752 |
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0 |
1753 |
| `List ((`String "AGGREGATE")::arg0::[]) -> |
1754 |
((function |
1755 |
| `Assoc xs -> |
1756 |
let rec loop xs (arg0 as _state) = |
1757 |
match xs with |
1758 |
| ("elems",x)::xs -> |
1759 |
loop xs |
1760 |
((function |
1761 |
| `List xs -> |
1762 |
map_bind |
1763 |
(fun x -> vhdl_element_assoc_t_of_yojson x) |
1764 |
[] xs |
1765 |
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t.elems") x) |
1766 |
| [] -> |
1767 |
arg0 >>= |
1768 |
((fun arg0 -> Result.Ok (Aggregate { elems = arg0 }))) |
1769 |
| _::xs -> loop xs _state in |
1770 |
loop xs (Result.Ok []) |
1771 |
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0 |
1772 |
| `List ((`String "QUALIFIED_EXPRESSION")::arg0::[]) -> |
1773 |
((function |
1774 |
| `Assoc xs -> |
1775 |
let rec loop xs ((arg0,arg1,arg2) as _state) = |
1776 |
match xs with |
1777 |
| ("type_mark",x)::xs -> |
1778 |
loop xs |
1779 |
(((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2) |
1780 |
| ("aggregate",x)::xs -> |
1781 |
loop xs |
1782 |
(arg0, |
1783 |
((function |
1784 |
| `List xs -> |
1785 |
map_bind |
1786 |
(fun x -> vhdl_element_assoc_t_of_yojson x) |
1787 |
[] xs |
1788 |
| _ -> |
1789 |
Result.Error "Vhdl_ast.vhdl_expr_t.aggregate") |
1790 |
x), arg2) |
1791 |
| ("expression",x)::xs -> |
1792 |
loop xs |
1793 |
(arg0, arg1, |
1794 |
((function |
1795 |
| `Null -> Result.Ok None |
1796 |
| x -> |
1797 |
((fun x -> vhdl_expr_t_of_yojson x) x) >>= |
1798 |
((fun x -> Result.Ok (Some x)))) x)) |
1799 |
| [] -> |
1800 |
arg2 >>= |
1801 |
((fun arg2 -> |
1802 |
arg1 >>= |
1803 |
(fun arg1 -> |
1804 |
arg0 >>= |
1805 |
(fun arg0 -> |
1806 |
Result.Ok |
1807 |
(QualifiedExpression |
1808 |
{ |
1809 |
type_mark = arg0; |
1810 |
aggregate = arg1; |
1811 |
expression = arg2 |
1812 |
}))))) |
1813 |
| _::xs -> loop xs _state in |
1814 |
loop xs |
1815 |
((Result.Error "Vhdl_ast.vhdl_expr_t.type_mark"), |
1816 |
(Result.Ok []), (Result.Ok None)) |
1817 |
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0 |
1818 |
| `List ((`String "OTHERS")::[]) -> Result.Ok Others |
1819 |
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t") |
1820 |
[@ocaml.warning "-A"]) |
1821 |
|
1822 |
and (vhdl_name_t_to_yojson : vhdl_name_t -> Yojson.Safe.json) = |
1823 |
((let open! Ppx_deriving_yojson_runtime in |
1824 |
function |
1825 |
| Simple arg0 -> |
1826 |
`List |
1827 |
[`String "SIMPLE_NAME"; |
1828 |
((fun (x : Ppx_deriving_runtime.string) -> `String x)) arg0] |
1829 |
| Identifier arg0 -> |
1830 |
`List |
1831 |
[`String "IDENTIFIER"; |
1832 |
((fun (x : Ppx_deriving_runtime.string) -> `String x)) arg0] |
1833 |
| Selected arg0 -> |
1834 |
`List |
1835 |
[`String "SELECTED_NAME"; |
1836 |
((fun x -> |
1837 |
`List (List.map (fun x -> vhdl_name_t_to_yojson x) x))) arg0] |
1838 |
| Index arg0 -> |
1839 |
`List |
1840 |
[`String "INDEXED_NAME"; |
1841 |
(let fields = [] in |
1842 |
let fields = |
1843 |
("exprs", |
1844 |
((fun x -> |
1845 |
`List (List.map (fun x -> vhdl_expr_t_to_yojson x) x)) |
1846 |
arg0.exprs)) |
1847 |
:: fields in |
1848 |
let fields = |
1849 |
("id", ((fun x -> vhdl_name_t_to_yojson x) arg0.id)) :: |
1850 |
fields in |
1851 |
`Assoc fields)] |
1852 |
| Slice arg0 -> |
1853 |
`List |
1854 |
[`String "SLICE_NAME"; |
1855 |
(let fields = [] in |
1856 |
let fields = |
1857 |
("range", |
1858 |
((fun x -> vhdl_discrete_range_t_to_yojson x) arg0.range)) |
1859 |
:: fields in |
1860 |
let fields = |
1861 |
("id", ((fun x -> vhdl_name_t_to_yojson x) arg0.id)) :: |
1862 |
fields in |
1863 |
`Assoc fields)] |
1864 |
| Attribute arg0 -> |
1865 |
`List |
1866 |
[`String "ATTRIBUTE_NAME"; |
1867 |
(let fields = [] in |
1868 |
let fields = |
1869 |
if arg0.expr = IsNull |
1870 |
then fields |
1871 |
else |
1872 |
("expr", (((fun x -> vhdl_expr_t_to_yojson x)) arg0.expr)) |
1873 |
:: fields |
1874 |
in |
1875 |
let fields = |
1876 |
("designator", |
1877 |
((fun x -> vhdl_name_t_to_yojson x) arg0.designator)) |
1878 |
:: fields in |
1879 |
let fields = |
1880 |
("id", ((fun x -> vhdl_name_t_to_yojson x) arg0.id)) :: |
1881 |
fields in |
1882 |
`Assoc fields)] |
1883 |
| Function arg0 -> |
1884 |
`List |
1885 |
[`String "FUNCTION_CALL"; |
1886 |
(let fields = [] in |
1887 |
let fields = |
1888 |
("assoc_list", |
1889 |
((fun x -> |
1890 |
`List |
1891 |
(List.map (fun x -> vhdl_assoc_element_t_to_yojson x) |
1892 |
x)) arg0.assoc_list)) |
1893 |
:: fields in |
1894 |
let fields = |
1895 |
("id", ((fun x -> vhdl_name_t_to_yojson x) arg0.id)) :: |
1896 |
fields in |
1897 |
`Assoc fields)] |
1898 |
| NoName -> `List [`String "NoName"]) |
1899 |
[@ocaml.warning "-A"]) |
1900 |
|
1901 |
and (vhdl_name_t_of_yojson : |
1902 |
Yojson.Safe.json -> vhdl_name_t Ppx_deriving_yojson_runtime.error_or) |
1903 |
= |
1904 |
((let open! Ppx_deriving_yojson_runtime in |
1905 |
function |
1906 |
| `List ((`String "SIMPLE_NAME")::arg0::[]) -> |
1907 |
((function |
1908 |
| `String x -> Result.Ok x |
1909 |
| _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>= |
1910 |
((fun arg0 -> Result.Ok (Simple arg0))) |
1911 |
| `List ((`String "IDENTIFIER")::arg0::[]) -> |
1912 |
((function |
1913 |
| `String x -> Result.Ok x |
1914 |
| _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>= |
1915 |
((fun arg0 -> Result.Ok (Identifier arg0))) |
1916 |
| `List ((`String "SELECTED_NAME")::arg0::[]) -> |
1917 |
((function |
1918 |
| `List xs -> map_bind (fun x -> vhdl_name_t_of_yojson x) [] xs |
1919 |
| _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>= |
1920 |
((fun arg0 -> Result.Ok (Selected arg0))) |
1921 |
| `List ((`String "INDEXED_NAME")::arg0::[]) -> |
1922 |
((function |
1923 |
| `Assoc xs -> |
1924 |
let rec loop xs ((arg0,arg1) as _state) = |
1925 |
match xs with |
1926 |
| ("id",x)::xs -> |
1927 |
loop xs (((fun x -> vhdl_name_t_of_yojson x) x), arg1) |
1928 |
| ("exprs",x)::xs -> |
1929 |
loop xs |
1930 |
(arg0, |
1931 |
((function |
1932 |
| `List xs -> |
1933 |
map_bind (fun x -> vhdl_expr_t_of_yojson x) |
1934 |
[] xs |
1935 |
| _ -> Result.Error "Vhdl_ast.vhdl_name_t.exprs") |
1936 |
x)) |
1937 |
| [] -> |
1938 |
arg1 >>= |
1939 |
((fun arg1 -> |
1940 |
arg0 >>= |
1941 |
(fun arg0 -> |
1942 |
Result.Ok |
1943 |
(Index { id = arg0; exprs = arg1 })))) |
1944 |
| _::xs -> loop xs _state in |
1945 |
loop xs |
1946 |
((Result.Error "Vhdl_ast.vhdl_name_t.id"), |
1947 |
(Result.Error "Vhdl_ast.vhdl_name_t.exprs")) |
1948 |
| _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0 |
1949 |
| `List ((`String "SLICE_NAME")::arg0::[]) -> |
1950 |
((function |
1951 |
| `Assoc xs -> |
1952 |
let rec loop xs ((arg0,arg1) as _state) = |
1953 |
match xs with |
1954 |
| ("id",x)::xs -> |
1955 |
loop xs (((fun x -> vhdl_name_t_of_yojson x) x), arg1) |
1956 |
| ("range",x)::xs -> |
1957 |
loop xs |
1958 |
(arg0, |
1959 |
((fun x -> vhdl_discrete_range_t_of_yojson x) x)) |
1960 |
| [] -> |
1961 |
arg1 >>= |
1962 |
((fun arg1 -> |
1963 |
arg0 >>= |
1964 |
(fun arg0 -> |
1965 |
Result.Ok |
1966 |
(Slice { id = arg0; range = arg1 })))) |
1967 |
| _::xs -> loop xs _state in |
1968 |
loop xs |
1969 |
((Result.Error "Vhdl_ast.vhdl_name_t.id"), |
1970 |
(Result.Error "Vhdl_ast.vhdl_name_t.range")) |
1971 |
| _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0 |
1972 |
| `List ((`String "ATTRIBUTE_NAME")::arg0::[]) -> |
1973 |
((function |
1974 |
| `Assoc xs -> |
1975 |
let rec loop xs ((arg0,arg1,arg2) as _state) = |
1976 |
match xs with |
1977 |
| ("id",x)::xs -> |
1978 |
loop xs |
1979 |
(((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2) |
1980 |
| ("designator",x)::xs -> |
1981 |
loop xs |
1982 |
(arg0, ((fun x -> vhdl_name_t_of_yojson x) x), arg2) |
1983 |
| ("expr",x)::xs -> |
1984 |
loop xs |
1985 |
(arg0, arg1, ((fun x -> vhdl_expr_t_of_yojson x) x)) |
1986 |
| [] -> |
1987 |
arg2 >>= |
1988 |
((fun arg2 -> |
1989 |
arg1 >>= |
1990 |
(fun arg1 -> |
1991 |
arg0 >>= |
1992 |
(fun arg0 -> |
1993 |
Result.Ok |
1994 |
(Attribute |
1995 |
{ |
1996 |
id = arg0; |
1997 |
designator = arg1; |
1998 |
expr = arg2 |
1999 |
}))))) |
2000 |
| _::xs -> loop xs _state in |
2001 |
loop xs |
2002 |
((Result.Error "Vhdl_ast.vhdl_name_t.id"), |
2003 |
(Result.Error "Vhdl_ast.vhdl_name_t.designator"), |
2004 |
(Result.Ok IsNull)) |
2005 |
| _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0 |
2006 |
| `List ((`String "FUNCTION_CALL")::arg0::[]) -> |
2007 |
((function |
2008 |
| `Assoc xs -> |
2009 |
let rec loop xs ((arg0,arg1) as _state) = |
2010 |
match xs with |
2011 |
| ("id",x)::xs -> |
2012 |
loop xs (((fun x -> vhdl_name_t_of_yojson x) x), arg1) |
2013 |
| ("assoc_list",x)::xs -> |
2014 |
loop xs |
2015 |
(arg0, |
2016 |
((function |
2017 |
| `List xs -> |
2018 |
map_bind |
2019 |
(fun x -> vhdl_assoc_element_t_of_yojson x) |
2020 |
[] xs |
2021 |
| _ -> |
2022 |
Result.Error |
2023 |
"Vhdl_ast.vhdl_name_t.assoc_list") x)) |
2024 |
| [] -> |
2025 |
arg1 >>= |
2026 |
((fun arg1 -> |
2027 |
arg0 >>= |
2028 |
(fun arg0 -> |
2029 |
Result.Ok |
2030 |
(Function { id = arg0; assoc_list = arg1 })))) |
2031 |
| _::xs -> loop xs _state in |
2032 |
loop xs |
2033 |
((Result.Error "Vhdl_ast.vhdl_name_t.id"), |
2034 |
(Result.Error "Vhdl_ast.vhdl_name_t.assoc_list")) |
2035 |
| _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0 |
2036 |
| `List ((`String "NoName")::[]) -> Result.Ok NoName |
2037 |
| _ -> Result.Error "Vhdl_ast.vhdl_name_t") |
2038 |
[@ocaml.warning "-A"]) |
2039 |
|
2040 |
and (vhdl_assoc_element_t_to_yojson : |
2041 |
vhdl_assoc_element_t -> Yojson.Safe.json) |
2042 |
= |
2043 |
((let open! Ppx_deriving_yojson_runtime in |
2044 |
fun x -> |
2045 |
let fields = [] in |
2046 |
let fields = |
2047 |
if x.actual_expr = None |
2048 |
then fields |
2049 |
else |
2050 |
("actual_expr", |
2051 |
(((function |
2052 |
| None -> `Null |
2053 |
| Some x -> ((fun x -> vhdl_expr_t_to_yojson x)) x)) |
2054 |
x.actual_expr)) |
2055 |
:: fields |
2056 |
in |
2057 |
let fields = |
2058 |
if x.actual_designator = None |
2059 |
then fields |
2060 |
else |
2061 |
("actual_designator", |
2062 |
(((function |
2063 |
| None -> `Null |
2064 |
| Some x -> ((fun x -> vhdl_name_t_to_yojson x)) x)) |
2065 |
x.actual_designator)) |
2066 |
:: fields |
2067 |
in |
2068 |
let fields = |
2069 |
if x.actual_name = None |
2070 |
then fields |
2071 |
else |
2072 |
("actual_name", |
2073 |
(((function |
2074 |
| None -> `Null |
2075 |
| Some x -> ((fun x -> vhdl_name_t_to_yojson x)) x)) |
2076 |
x.actual_name)) |
2077 |
:: fields |
2078 |
in |
2079 |
let fields = |
2080 |
if x.formal_arg = None |
2081 |
then fields |
2082 |
else |
2083 |
("formal_arg", |
2084 |
(((function |
2085 |
| None -> `Null |
2086 |
| Some x -> ((fun x -> vhdl_name_t_to_yojson x)) x)) |
2087 |
x.formal_arg)) |
2088 |
:: fields |
2089 |
in |
2090 |
let fields = |
2091 |
if x.formal_name = None |
2092 |
then fields |
2093 |
else |
2094 |
("formal_name", |
2095 |
(((function |
2096 |
| None -> `Null |
2097 |
| Some x -> ((fun x -> vhdl_name_t_to_yojson x)) x)) |
2098 |
x.formal_name)) |
2099 |
:: fields |
2100 |
in |
2101 |
`Assoc fields) |
2102 |
[@ocaml.warning "-A"]) |
2103 |
|
2104 |
and (vhdl_assoc_element_t_of_yojson : |
2105 |
Yojson.Safe.json -> |
2106 |
vhdl_assoc_element_t Ppx_deriving_yojson_runtime.error_or) |
2107 |
= |
2108 |
((let open! Ppx_deriving_yojson_runtime in |
2109 |
function |
2110 |
| `Assoc xs -> |
2111 |
let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) = |
2112 |
match xs with |
2113 |
| ("formal_name",x)::xs -> |
2114 |
loop xs |
2115 |
(((function |
2116 |
| `Null -> Result.Ok None |
2117 |
| x -> |
2118 |
((fun x -> vhdl_name_t_of_yojson x) x) >>= |
2119 |
((fun x -> Result.Ok (Some x)))) x), arg1, arg2, |
2120 |
arg3, arg4) |
2121 |
| ("formal_arg",x)::xs -> |
2122 |
loop xs |
2123 |
(arg0, |
2124 |
((function |
2125 |
| `Null -> Result.Ok None |
2126 |
| x -> |
2127 |
((fun x -> vhdl_name_t_of_yojson x) x) >>= |
2128 |
((fun x -> Result.Ok (Some x)))) x), arg2, arg3, |
2129 |
arg4) |
2130 |
| ("actual_name",x)::xs -> |
2131 |
loop xs |
2132 |
(arg0, arg1, |
2133 |
((function |
2134 |
| `Null -> Result.Ok None |
2135 |
| x -> |
2136 |
((fun x -> vhdl_name_t_of_yojson x) x) >>= |
2137 |
((fun x -> Result.Ok (Some x)))) x), arg3, arg4) |
2138 |
| ("actual_designator",x)::xs -> |
2139 |
loop xs |
2140 |
(arg0, arg1, arg2, |
2141 |
((function |
2142 |
| `Null -> Result.Ok None |
2143 |
| x -> |
2144 |
((fun x -> vhdl_name_t_of_yojson x) x) >>= |
2145 |
((fun x -> Result.Ok (Some x)))) x), arg4) |
2146 |
| ("actual_expr",x)::xs -> |
2147 |
loop xs |
2148 |
(arg0, arg1, arg2, arg3, |
2149 |
((function |
2150 |
| `Null -> Result.Ok None |
2151 |
| x -> |
2152 |
((fun x -> vhdl_expr_t_of_yojson x) x) >>= |
2153 |
((fun x -> Result.Ok (Some x)))) x)) |
2154 |
| [] -> |
2155 |
arg4 >>= |
2156 |
((fun arg4 -> |
2157 |
arg3 >>= |
2158 |
(fun arg3 -> |
2159 |
arg2 >>= |
2160 |
(fun arg2 -> |
2161 |
arg1 >>= |
2162 |
(fun arg1 -> |
2163 |
arg0 >>= |
2164 |
(fun arg0 -> |
2165 |
Result.Ok |
2166 |
{ |
2167 |
formal_name = arg0; |
2168 |
formal_arg = arg1; |
2169 |
actual_name = arg2; |
2170 |
actual_designator = arg3; |
2171 |
actual_expr = arg4 |
2172 |
})))))) |
2173 |
| _::xs -> loop xs _state in |
2174 |
loop xs |
2175 |
((Result.Ok (Some NoName)), (Result.Ok (Some NoName)), |
2176 |
(Result.Ok (Some NoName)), (Result.Ok (Some NoName)), |
2177 |
(Result.Ok (Some IsNull))) |
2178 |
| _ -> Result.Error "Vhdl_ast.vhdl_assoc_element_t") |
2179 |
[@ocaml.warning "-A"]) |
2180 |
|
2181 |
and (vhdl_element_assoc_t_to_yojson : |
2182 |
vhdl_element_assoc_t -> Yojson.Safe.json) |
2183 |
= |
2184 |
((let open! Ppx_deriving_yojson_runtime in |
2185 |
fun x -> |
2186 |
let fields = [] in |
2187 |
let fields = ("expr", ((fun x -> vhdl_expr_t_to_yojson x) x.expr)) |
2188 |
:: fields in |
2189 |
let fields = |
2190 |
if x.choices = [] |
2191 |
then fields |
2192 |
else |
2193 |
("choices", |
2194 |
(((fun x -> |
2195 |
`List (List.map (fun x -> vhdl_expr_t_to_yojson x) x))) |
2196 |
x.choices)) |
2197 |
:: fields |
2198 |
in |
2199 |
`Assoc fields) |
2200 |
[@ocaml.warning "-A"]) |
2201 |
|
2202 |
and (vhdl_element_assoc_t_of_yojson : |
2203 |
Yojson.Safe.json -> |
2204 |
vhdl_element_assoc_t Ppx_deriving_yojson_runtime.error_or) |
2205 |
= |
2206 |
((let open! Ppx_deriving_yojson_runtime in |
2207 |
function |
2208 |
| `Assoc xs -> |
2209 |
let rec loop xs ((arg0,arg1) as _state) = |
2210 |
match xs with |
2211 |
| ("choices",x)::xs -> |
2212 |
loop xs |
2213 |
(((function |
2214 |
| `List xs -> |
2215 |
map_bind (fun x -> vhdl_expr_t_of_yojson x) [] xs |
2216 |
| _ -> |
2217 |
Result.Error "Vhdl_ast.vhdl_element_assoc_t.choices") |
2218 |
x), arg1) |
2219 |
| ("expr",x)::xs -> |
2220 |
loop xs (arg0, ((fun x -> vhdl_expr_t_of_yojson x) x)) |
2221 |
| [] -> |
2222 |
arg1 >>= |
2223 |
((fun arg1 -> |
2224 |
arg0 >>= |
2225 |
(fun arg0 -> |
2226 |
Result.Ok { choices = arg0; expr = arg1 }))) |
2227 |
| _::xs -> loop xs _state in |
2228 |
loop xs |
2229 |
((Result.Ok []), |
2230 |
(Result.Error "Vhdl_ast.vhdl_element_assoc_t.expr")) |
2231 |
| _ -> Result.Error "Vhdl_ast.vhdl_element_assoc_t") |
2232 |
[@ocaml.warning "-A"]) |
2233 |
|
2234 |
and (vhdl_array_attributes_t_to_yojson : |
2235 |
vhdl_array_attributes_t -> Yojson.Safe.json) |
2236 |
= |
2237 |
((let open! Ppx_deriving_yojson_runtime in |
2238 |
function |
2239 |
| AAttInt arg0 -> |
2240 |
`List |
2241 |
[`String "AAttInt"; |
2242 |
(let fields = [] in |
2243 |
let fields = |
2244 |
("arg", |
2245 |
((fun (x : Ppx_deriving_runtime.int) -> `Int x) arg0.arg)) |
2246 |
:: fields in |
2247 |
let fields = |
2248 |
("id", |
2249 |
((fun (x : Ppx_deriving_runtime.string) -> `String x) |
2250 |
arg0.id)) |
2251 |
:: fields in |
2252 |
`Assoc fields)] |
2253 |
| AAttAscending -> `List [`String "AAttAscending"]) |
2254 |
[@ocaml.warning "-A"]) |
2255 |
|
2256 |
and (vhdl_array_attributes_t_of_yojson : |
2257 |
Yojson.Safe.json -> |
2258 |
vhdl_array_attributes_t Ppx_deriving_yojson_runtime.error_or) |
2259 |
= |
2260 |
((let open! Ppx_deriving_yojson_runtime in |
2261 |
function |
2262 |
| `List ((`String "AAttInt")::arg0::[]) -> |
2263 |
((function |
2264 |
| `Assoc xs -> |
2265 |
let rec loop xs ((arg0,arg1) as _state) = |
2266 |
match xs with |
2267 |
| ("id",x)::xs -> |
2268 |
loop xs |
2269 |
(((function |
2270 |
| `String x -> Result.Ok x |
2271 |
| _ -> |
2272 |
Result.Error |
2273 |
"Vhdl_ast.vhdl_array_attributes_t.id") x), |
2274 |
arg1) |
2275 |
| ("arg",x)::xs -> |
2276 |
loop xs |
2277 |
(arg0, |
2278 |
((function |
2279 |
| `Int x -> Result.Ok x |
2280 |
| _ -> |
2281 |
Result.Error |
2282 |
"Vhdl_ast.vhdl_array_attributes_t.arg") x)) |
2283 |
| [] -> |
2284 |
arg1 >>= |
2285 |
((fun arg1 -> |
2286 |
arg0 >>= |
2287 |
(fun arg0 -> |
2288 |
Result.Ok |
2289 |
(AAttInt { id = arg0; arg = arg1 })))) |
2290 |
| _::xs -> loop xs _state in |
2291 |
loop xs |
2292 |
((Result.Error "Vhdl_ast.vhdl_array_attributes_t.id"), |
2293 |
(Result.Error "Vhdl_ast.vhdl_array_attributes_t.arg")) |
2294 |
| _ -> Result.Error "Vhdl_ast.vhdl_array_attributes_t")) arg0 |
2295 |
| `List ((`String "AAttAscending")::[]) -> Result.Ok AAttAscending |
2296 |
| _ -> Result.Error "Vhdl_ast.vhdl_array_attributes_t") |
2297 |
[@ocaml.warning "-A"]) |
2298 |
|
2299 |
and (vhdl_signal_attributes_t_to_yojson : |
2300 |
vhdl_signal_attributes_t -> Yojson.Safe.json) |
2301 |
= |
2302 |
((let open! Ppx_deriving_yojson_runtime in |
2303 |
function |
2304 |
| SigAtt arg0 -> |
2305 |
`List |
2306 |
[`String "SigAtt"; |
2307 |
((fun (x : Ppx_deriving_runtime.string) -> `String x)) arg0]) |
2308 |
[@ocaml.warning "-A"]) |
2309 |
|
2310 |
and (vhdl_signal_attributes_t_of_yojson : |
2311 |
Yojson.Safe.json -> |
2312 |
vhdl_signal_attributes_t Ppx_deriving_yojson_runtime.error_or) |
2313 |
= |
2314 |
((let open! Ppx_deriving_yojson_runtime in |
2315 |
function |
2316 |
| `List ((`String "SigAtt")::arg0::[]) -> |
2317 |
((function |
2318 |
| `String x -> Result.Ok x |
2319 |
| _ -> Result.Error "Vhdl_ast.vhdl_signal_attributes_t") arg0) |
2320 |
>>= ((fun arg0 -> Result.Ok (SigAtt arg0))) |
2321 |
| _ -> Result.Error "Vhdl_ast.vhdl_signal_attributes_t") |
2322 |
[@ocaml.warning "-A"]) |
2323 |
|
2324 |
and (vhdl_string_attributes_t_to_yojson : |
2325 |
vhdl_string_attributes_t -> Yojson.Safe.json) |
2326 |
= |
2327 |
((let open! Ppx_deriving_yojson_runtime in |
2328 |
function |
2329 |
| StringAtt arg0 -> |
2330 |
`List |
2331 |
[`String "StringAtt"; |
2332 |
((fun (x : Ppx_deriving_runtime.string) -> `String x)) arg0]) |
2333 |
[@ocaml.warning "-A"]) |
2334 |
|
2335 |
and (vhdl_string_attributes_t_of_yojson : |
2336 |
Yojson.Safe.json -> |
2337 |
vhdl_string_attributes_t Ppx_deriving_yojson_runtime.error_or) |
2338 |
= |
2339 |
((let open! Ppx_deriving_yojson_runtime in |
2340 |
function |
2341 |
| `List ((`String "StringAtt")::arg0::[]) -> |
2342 |
((function |
2343 |
| `String x -> Result.Ok x |
2344 |
| _ -> Result.Error "Vhdl_ast.vhdl_string_attributes_t") arg0) |
2345 |
>>= ((fun arg0 -> Result.Ok (StringAtt arg0))) |
2346 |
| _ -> Result.Error "Vhdl_ast.vhdl_string_attributes_t") |
2347 |
[@ocaml.warning "-A"]) |
2348 |
|
2349 |
and (vhdl_suffix_selection_t_to_yojson : |
2350 |
vhdl_suffix_selection_t -> Yojson.Safe.json) |
2351 |
= |
2352 |
((let open! Ppx_deriving_yojson_runtime in |
2353 |
function |
2354 |
| Idx arg0 -> |
2355 |
`List |
2356 |
[`String "Idx"; |
2357 |
((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg0] |
2358 |
| SuffixRange (arg0,arg1) -> |
2359 |
`List |
2360 |
[`String "SuffixRange"; |
2361 |
((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg0; |
2362 |
((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg1]) |
2363 |
[@ocaml.warning "-A"]) |
2364 |
|
2365 |
and (vhdl_suffix_selection_t_of_yojson : |
2366 |
Yojson.Safe.json -> |
2367 |
vhdl_suffix_selection_t Ppx_deriving_yojson_runtime.error_or) |
2368 |
= |
2369 |
((let open! Ppx_deriving_yojson_runtime in |
2370 |
function |
2371 |
| `List ((`String "Idx")::arg0::[]) -> |
2372 |
((function |
2373 |
| `Int x -> Result.Ok x |
2374 |
| _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") arg0) >>= |
2375 |
((fun arg0 -> Result.Ok (Idx arg0))) |
2376 |
| `List ((`String "SuffixRange")::arg0::arg1::[]) -> |
2377 |
((function |
2378 |
| `Int x -> Result.Ok x |
2379 |
| _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") arg1) >>= |
2380 |
((fun arg1 -> |
2381 |
((function |
2382 |
| `Int x -> Result.Ok x |
2383 |
| _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") |
2384 |
arg0) |
2385 |
>>= (fun arg0 -> Result.Ok (SuffixRange (arg0, arg1))))) |
2386 |
| _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") |
2387 |
[@ocaml.warning "-A"]) |
2388 |
|
2389 |
type 'basetype vhdl_type_attributes_t = |
2390 |
| TAttNoArg of { |
2391 |
id: string } |
2392 |
| TAttIntArg of { |
2393 |
id: string ; |
2394 |
arg: int } |
2395 |
| TAttValArg of { |
2396 |
id: string ; |
2397 |
arg: 'basetype } |
2398 |
| TAttStringArg of { |
2399 |
id: string ; |
2400 |
arg: string } |
2401 |
|
2402 |
(* TODO *) |
2403 |
let rec pp_vhdl_type_attributes_t |
2404 |
= |
2405 |
((let open! Ppx_deriving_runtime in |
2406 |
fun poly_basetype -> |
2407 |
fun fmt -> |
2408 |
function |
2409 |
| TAttNoArg { id = aid } -> |
2410 |
(Format.fprintf fmt "@[<2>TAttNoArg {@,"; |
2411 |
(Format.fprintf fmt "@[%s =@ " "id"; |
2412 |
(Format.fprintf fmt "%S") aid; |
2413 |
Format.fprintf fmt "@]"); |
2414 |
Format.fprintf fmt "@]}") |
2415 |
| TAttIntArg { id = aid; arg = aarg } -> |
2416 |
(Format.fprintf fmt "@[<2>TAttIntArg {@,"; |
2417 |
((Format.fprintf fmt "@[%s =@ " "id"; |
2418 |
(Format.fprintf fmt "%S") aid; |
2419 |
Format.fprintf fmt "@]"); |
2420 |
Format.fprintf fmt ";@ "; |
2421 |
Format.fprintf fmt "@[%s =@ " "arg"; |
2422 |
(Format.fprintf fmt "%d") aarg; |
2423 |
Format.fprintf fmt "@]"); |
2424 |
Format.fprintf fmt "@]}") |
2425 |
| TAttValArg { id = aid; arg = aarg } -> |
2426 |
(Format.fprintf fmt "@[<2>TAttValArg {@,"; |
2427 |
((Format.fprintf fmt "@[%s =@ " "id"; |
2428 |
(Format.fprintf fmt "%S") aid; |
2429 |
Format.fprintf fmt "@]"); |
2430 |
Format.fprintf fmt ";@ "; |
2431 |
Format.fprintf fmt "@[%s =@ " "arg"; |
2432 |
(poly_basetype fmt) aarg; |
2433 |
Format.fprintf fmt "@]"); |
2434 |
Format.fprintf fmt "@]}") |
2435 |
| TAttStringArg { id = aid; arg = aarg } -> |
2436 |
(Format.fprintf fmt "@[<2>TAttStringArg {@,"; |
2437 |
((Format.fprintf fmt "@[%s =@ " "id"; |
2438 |
(Format.fprintf fmt "%S") aid; |
2439 |
Format.fprintf fmt "@]"); |
2440 |
Format.fprintf fmt ";@ "; |
2441 |
Format.fprintf fmt "@[%s =@ " "arg"; |
2442 |
(Format.fprintf fmt "%S") aarg; |
2443 |
Format.fprintf fmt "@]"); |
2444 |
Format.fprintf fmt "@]}")) |
2445 |
[@ocaml.warning "-A"]) |
2446 |
|
2447 |
and show_vhdl_type_attributes_t = |
2448 |
fun poly_basetype -> |
2449 |
fun x -> |
2450 |
Format.asprintf "%a" (pp_vhdl_type_attributes_t poly_basetype) x |
2451 |
|
2452 |
let rec vhdl_type_attributes_t_to_yojson : |
2453 |
'basetype . |
2454 |
('basetype -> Yojson.Safe.json) -> |
2455 |
'basetype vhdl_type_attributes_t -> Yojson.Safe.json |
2456 |
= |
2457 |
fun poly_basetype -> |
2458 |
((let open! Ppx_deriving_yojson_runtime in |
2459 |
function |
2460 |
| TAttNoArg arg0 -> |
2461 |
`List |
2462 |
[`String "TAttNoArg"; |
2463 |
(let fields = [] in |
2464 |
let fields = |
2465 |
("id", |
2466 |
((fun (x : Ppx_deriving_runtime.string) -> `String x) |
2467 |
arg0.id)) |
2468 |
:: fields in |
2469 |
`Assoc fields)] |
2470 |
| TAttIntArg arg0 -> |
2471 |
`List |
2472 |
[`String "TAttIntArg"; |
2473 |
(let fields = [] in |
2474 |
let fields = |
2475 |
("arg", |
2476 |
((fun (x : Ppx_deriving_runtime.int) -> `Int x) arg0.arg)) |
2477 |
:: fields in |
2478 |
let fields = |
2479 |
("id", |
2480 |
((fun (x : Ppx_deriving_runtime.string) -> `String x) |
2481 |
arg0.id)) |
2482 |
:: fields in |
2483 |
`Assoc fields)] |
2484 |
| TAttValArg arg0 -> |
2485 |
`List |
2486 |
[`String "TAttValArg"; |
2487 |
(let fields = [] in |
2488 |
let fields = |
2489 |
("arg", ((poly_basetype : _ -> Yojson.Safe.json) arg0.arg)) |
2490 |
:: fields in |
2491 |
let fields = |
2492 |
("id", |
2493 |
((fun (x : Ppx_deriving_runtime.string) -> `String x) |
2494 |
arg0.id)) |
2495 |
:: fields in |
2496 |
`Assoc fields)] |
2497 |
| TAttStringArg arg0 -> |
2498 |
`List |
2499 |
[`String "TAttStringArg"; |
2500 |
(let fields = [] in |
2501 |
let fields = |
2502 |
("arg", |
2503 |
((fun (x : Ppx_deriving_runtime.string) -> `String x) |
2504 |
arg0.arg)) |
2505 |
:: fields in |
2506 |
let fields = |
2507 |
("id", |
2508 |
((fun (x : Ppx_deriving_runtime.string) -> `String x) |
2509 |
arg0.id)) |
2510 |
:: fields in |
2511 |
`Assoc fields)]) |
2512 |
[@ocaml.warning "-A"]) |
2513 |
|
2514 |
and vhdl_type_attributes_t_of_yojson : |
2515 |
'basetype . |
2516 |
(Yojson.Safe.json -> 'basetype Ppx_deriving_yojson_runtime.error_or) -> |
2517 |
Yojson.Safe.json -> |
2518 |
'basetype vhdl_type_attributes_t Ppx_deriving_yojson_runtime.error_or |
2519 |
= |
2520 |
fun poly_basetype -> |
2521 |
((let open! Ppx_deriving_yojson_runtime in |
2522 |
function |
2523 |
| `List ((`String "TAttNoArg")::arg0::[]) -> |
2524 |
((function |
2525 |
| `Assoc xs -> |
2526 |
let rec loop xs (arg0 as _state) = |
2527 |
match xs with |
2528 |
| ("id",x)::xs -> |
2529 |
loop xs |
2530 |
((function |
2531 |
| `String x -> Result.Ok x |
2532 |
| _ -> |
2533 |
Result.Error |
2534 |
"Vhdl_ast.vhdl_type_attributes_t.id") x) |
2535 |
| [] -> |
2536 |
arg0 >>= |
2537 |
((fun arg0 -> Result.Ok (TAttNoArg { id = arg0 }))) |
2538 |
| _::xs -> loop xs _state in |
2539 |
loop xs (Result.Error "Vhdl_ast.vhdl_type_attributes_t.id") |
2540 |
| _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0 |
2541 |
| `List ((`String "TAttIntArg")::arg0::[]) -> |
2542 |
((function |
2543 |
| `Assoc xs -> |
2544 |
let rec loop xs ((arg0,arg1) as _state) = |
2545 |
match xs with |
2546 |
| ("id",x)::xs -> |
2547 |
loop xs |
2548 |
(((function |
2549 |
| `String x -> Result.Ok x |
2550 |
| _ -> |
2551 |
Result.Error |
2552 |
"Vhdl_ast.vhdl_type_attributes_t.id") x), |
2553 |
arg1) |
2554 |
| ("arg",x)::xs -> |
2555 |
loop xs |
2556 |
(arg0, |
2557 |
((function |
2558 |
| `Int x -> Result.Ok x |
2559 |
| _ -> |
2560 |
Result.Error |
2561 |
"Vhdl_ast.vhdl_type_attributes_t.arg") x)) |
2562 |
| [] -> |
2563 |
arg1 >>= |
2564 |
((fun arg1 -> |
2565 |
arg0 >>= |
2566 |
(fun arg0 -> |
2567 |
Result.Ok |
2568 |
(TAttIntArg { id = arg0; arg = arg1 })))) |
2569 |
| _::xs -> loop xs _state in |
2570 |
loop xs |
2571 |
((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"), |
2572 |
(Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg")) |
2573 |
| _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0 |
2574 |
| `List ((`String "TAttValArg")::arg0::[]) -> |
2575 |
((function |
2576 |
| `Assoc xs -> |
2577 |
let rec loop xs ((arg0,arg1) as _state) = |
2578 |
match xs with |
2579 |
| ("id",x)::xs -> |
2580 |
loop xs |
2581 |
(((function |
2582 |
| `String x -> Result.Ok x |
2583 |
| _ -> |
2584 |
Result.Error |
2585 |
"Vhdl_ast.vhdl_type_attributes_t.id") x), |
2586 |
arg1) |
2587 |
| ("arg",x)::xs -> |
2588 |
loop xs |
2589 |
(arg0, |
2590 |
((poly_basetype : Yojson.Safe.json -> _ error_or) |
2591 |
x)) |
2592 |
| [] -> |
2593 |
arg1 >>= |
2594 |
((fun arg1 -> |
2595 |
arg0 >>= |
2596 |
(fun arg0 -> |
2597 |
Result.Ok |
2598 |
(TAttValArg { id = arg0; arg = arg1 })))) |
2599 |
| _::xs -> loop xs _state in |
2600 |
loop xs |
2601 |
((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"), |
2602 |
(Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg")) |
2603 |
| _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0 |
2604 |
| `List ((`String "TAttStringArg")::arg0::[]) -> |
2605 |
((function |
2606 |
| `Assoc xs -> |
2607 |
let rec loop xs ((arg0,arg1) as _state) = |
2608 |
match xs with |
2609 |
| ("id",x)::xs -> |
2610 |
loop xs |
2611 |
(((function |
2612 |
| `String x -> Result.Ok x |
2613 |
| _ -> |
2614 |
Result.Error |
2615 |
"Vhdl_ast.vhdl_type_attributes_t.id") x), |
2616 |
arg1) |
2617 |
| ("arg",x)::xs -> |
2618 |
loop xs |
2619 |
(arg0, |
2620 |
((function |
2621 |
| `String x -> Result.Ok x |
2622 |
| _ -> |
2623 |
Result.Error |
2624 |
"Vhdl_ast.vhdl_type_attributes_t.arg") x)) |
2625 |
| [] -> |
2626 |
arg1 >>= |
2627 |
((fun arg1 -> |
2628 |
arg0 >>= |
2629 |
(fun arg0 -> |
2630 |
Result.Ok |
2631 |
(TAttStringArg { id = arg0; arg = arg1 })))) |
2632 |
| _::xs -> loop xs _state in |
2633 |
loop xs |
2634 |
((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"), |
2635 |
(Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg")) |
2636 |
| _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0 |
2637 |
| _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t") |
2638 |
[@ocaml.warning "-A"]) |
2639 |
|
2640 |
let typ_att_noarg = ["base"; "left"; "right"; "high"; "low"] |
2641 |
let typ_att_intarg = ["pos"; "val"; "succ"; "pred"; "leftof"; "rightof"] |
2642 |
let typ_att_valarg = ["image"] |
2643 |
let typ_att_stringarg = ["value"] |
2644 |
let array_att_intarg = |
2645 |
["left"; "right"; "high"; "low"; "range"; "reverse_range"; "length"] |
2646 |
type vhdl_parameter_t = |
2647 |
{ |
2648 |
names: vhdl_name_t list ; |
2649 |
mode: string list [@default []]; |
2650 |
typ: vhdl_subtype_indication_t ; |
2651 |
init_val: vhdl_cst_val_t option [@default None]} |
2652 |
|
2653 |
let rec pp_vhdl_parameter_t : |
2654 |
Format.formatter -> vhdl_parameter_t -> Ppx_deriving_runtime.unit = |
2655 |
let __2 () = pp_vhdl_cst_val_t |
2656 |
|
2657 |
and __1 () = pp_vhdl_subtype_indication_t |
2658 |
|
2659 |
and __0 () = pp_vhdl_name_t |
2660 |
in |
2661 |
((let open! Ppx_deriving_runtime in |
2662 |
fun fmt -> |
2663 |
fun x -> |
2664 |
((fun x -> |
2665 |
ignore |
2666 |
(List.fold_left |
2667 |
(fun sep -> |
2668 |
fun x -> |
2669 |
if sep then Format.fprintf fmt ", "; |
2670 |
((__0 ()) fmt) x; |
2671 |
true) false x))) x.names; |
2672 |
((fun x -> |
2673 |
ignore |
2674 |
(List.fold_left |
2675 |
(fun sep -> |
2676 |
fun x -> |
2677 |
if sep then Format.fprintf fmt ""; |
2678 |
Format.fprintf fmt ": %s" x; |
2679 |
true) false x))) x.mode; |
2680 |
((__1 ()) fmt) x.typ; |
2681 |
(match x.init_val with |
2682 |
| None -> Format.pp_print_string fmt "" |
2683 |
| Some x -> |
2684 |
(Format.pp_print_string fmt " := "; |
2685 |
((__2 ()) fmt) x));) |
2686 |
[@ocaml.warning "-A"]) |
2687 |
|
2688 |
and show_vhdl_parameter_t : vhdl_parameter_t -> Ppx_deriving_runtime.string = |
2689 |
fun x -> Format.asprintf "%a" pp_vhdl_parameter_t x |
2690 |
|
2691 |
let rec (vhdl_parameter_t_to_yojson : vhdl_parameter_t -> Yojson.Safe.json) = |
2692 |
((let open! Ppx_deriving_yojson_runtime in |
2693 |
fun x -> |
2694 |
let fields = [] in |
2695 |
let fields = |
2696 |
if x.init_val = None |
2697 |
then fields |
2698 |
else |
2699 |
("init_val", |
2700 |
(((function |
2701 |
| None -> `Null |
2702 |
| Some x -> ((fun x -> vhdl_cst_val_t_to_yojson x)) x)) |
2703 |
x.init_val)) |
2704 |
:: fields |
2705 |
in |
2706 |
let fields = |
2707 |
("typ", ((fun x -> vhdl_subtype_indication_t_to_yojson x) x.typ)) |
2708 |
:: fields in |
2709 |
let fields = |
2710 |
if x.mode = [] |
2711 |
then fields |
2712 |
else |
2713 |
("mode", |
2714 |
(((fun x -> |
2715 |
`List |
2716 |
(List.map |
2717 |
(fun (x : Ppx_deriving_runtime.string) -> `String x) |
2718 |
x))) x.mode)) |
2719 |
:: fields |
2720 |
in |
2721 |
let fields = |
2722 |
("names", |
2723 |
((fun x -> |
2724 |
`List (List.map (fun x -> vhdl_name_t_to_yojson x) x)) |
2725 |
x.names)) |
2726 |
:: fields in |
2727 |
`Assoc fields) |
2728 |
[@ocaml.warning "-A"]) |
2729 |
|
2730 |
and (vhdl_parameter_t_of_yojson : |
2731 |
Yojson.Safe.json -> |
2732 |
vhdl_parameter_t Ppx_deriving_yojson_runtime.error_or) |
2733 |
= |
2734 |
((let open! Ppx_deriving_yojson_runtime in |
2735 |
function |
2736 |
| `Assoc xs -> |
2737 |
let rec loop xs ((arg0,arg1,arg2,arg3) as _state) = |
2738 |
match xs with |
2739 |
| ("names",x)::xs -> |
2740 |
loop xs |
2741 |
(((function |
2742 |
| `List xs -> |
2743 |
map_bind (fun x -> vhdl_name_t_of_yojson x) [] xs |
2744 |
| _ -> Result.Error "Vhdl_ast.vhdl_parameter_t.names") x), |
2745 |
arg1, arg2, arg3) |
2746 |
| ("mode",x)::xs -> |
2747 |
loop xs |
2748 |
(arg0, |
2749 |
((function |
2750 |
| `List xs -> |
2751 |
map_bind |
2752 |
(function |
2753 |
| `String x -> Result.Ok x |
2754 |
| _ -> |
2755 |
Result.Error |
2756 |
"Vhdl_ast.vhdl_parameter_t.mode") [] xs |
2757 |
| _ -> Result.Error "Vhdl_ast.vhdl_parameter_t.mode") x), |
2758 |
arg2, arg3) |
2759 |
| ("typ",x)::xs -> |
2760 |
loop xs |
2761 |
(arg0, arg1, |
2762 |
((fun x -> vhdl_subtype_indication_t_of_yojson x) x), |
2763 |
arg3) |
2764 |
| ("init_val",x)::xs -> |
2765 |
loop xs |
2766 |
(arg0, arg1, arg2, |
2767 |
((function |
2768 |
| `Null -> Result.Ok None |
2769 |
| x -> |
2770 |
((fun x -> vhdl_cst_val_t_of_yojson x) x) >>= |
2771 |
((fun x -> Result.Ok (Some x)))) x)) |
2772 |
| [] -> |
2773 |
arg3 >>= |
2774 |
((fun arg3 -> |
2775 |
arg2 >>= |
2776 |
(fun arg2 -> |
2777 |
arg1 >>= |
2778 |
(fun arg1 -> |
2779 |
arg0 >>= |
2780 |
(fun arg0 -> |
2781 |
Result.Ok |
2782 |
{ |
2783 |
names = arg0; |
2784 |
mode = arg1; |
2785 |
typ = arg2; |
2786 |
init_val = arg3 |
2787 |
}))))) |
2788 |
| _::xs -> loop xs _state in |
2789 |
loop xs |
2790 |
((Result.Error "Vhdl_ast.vhdl_parameter_t.names"), |
2791 |
(Result.Ok []), (Result.Error "Vhdl_ast.vhdl_parameter_t.typ"), |
2792 |
(Result.Ok (Some (CstInt 0)))) |
2793 |
| _ -> Result.Error "Vhdl_ast.vhdl_parameter_t") |
2794 |
[@ocaml.warning "-A"]) |
2795 |
|
2796 |
type vhdl_subprogram_spec_t = |
2797 |
{ |
2798 |
name: string [@default ""]; |
2799 |
subprogram_type: string [@default ""]; |
2800 |
typeMark: vhdl_name_t [@default NoName]; |
2801 |
parameters: vhdl_parameter_t list ; |
2802 |
isPure: bool [@default false]} |
2803 |
|
2804 |
let rec pp_vhdl_subprogram_spec_t : |
2805 |
Format.formatter -> vhdl_subprogram_spec_t -> Ppx_deriving_runtime.unit = |
2806 |
let __1 () = pp_vhdl_parameter_t |
2807 |
|
2808 |
and __0 () = pp_vhdl_name_t |
2809 |
in |
2810 |
((let open! Ppx_deriving_runtime in |
2811 |
fun fmt -> |
2812 |
fun x -> |
2813 |
(match x.subprogram_type with |
2814 |
| "function" -> |
2815 |
if (x.isPure) then |
2816 |
Format.fprintf fmt "pure %s %s" x.subprogram_type x.name |
2817 |
else |
2818 |
Format.fprintf fmt "impure %s %s" x.subprogram_type x.name |
2819 |
| "procedure" -> |
2820 |
Format.fprintf fmt "%s %s" x.subprogram_type x.name); |
2821 |
(match x.parameters with |
2822 |
| [] -> Format.fprintf fmt ""; |
2823 |
| _ -> |
2824 |
Format.fprintf fmt "(@["; |
2825 |
((fun x -> |
2826 |
ignore |
2827 |
(List.fold_left |
2828 |
(fun sep -> |
2829 |
fun x -> |
2830 |
if sep then Format.fprintf fmt ",@ "; |
2831 |
((__1 ()) fmt) x; |
2832 |
true) false x))) x.parameters; |
2833 |
Format.fprintf fmt "@])"); |
2834 |
(match x.typeMark with |
2835 |
| NoName -> Format.fprintf fmt ""; |
2836 |
| _ -> |
2837 |
Format.fprintf fmt "return "; |
2838 |
((__0 ()) fmt) x.typeMark)) |
2839 |
[@ocaml.warning "-A"]) |
2840 |
|
2841 |
and show_vhdl_subprogram_spec_t : |
2842 |
vhdl_subprogram_spec_t -> Ppx_deriving_runtime.string = |
2843 |
fun x -> Format.asprintf "%a" pp_vhdl_subprogram_spec_t x |
2844 |
|
2845 |
let rec (vhdl_subprogram_spec_t_to_yojson : |
2846 |
vhdl_subprogram_spec_t -> Yojson.Safe.json) |
2847 |
= |
2848 |
((let open! Ppx_deriving_yojson_runtime in |
2849 |
fun x -> |
2850 |
let fields = [] in |
2851 |
let fields = |
2852 |
if x.isPure = false |
2853 |
then fields |
2854 |
else |
2855 |
("isPure", |
2856 |
(((fun (x : Ppx_deriving_runtime.bool) -> `Bool x)) x.isPure)) |
2857 |
:: fields |
2858 |
in |
2859 |
let fields = |
2860 |
if x.parameters = [] |
2861 |
then fields |
2862 |
else |
2863 |
("parameters", |
2864 |
(((fun x -> |
2865 |
`List |
2866 |
(List.map (fun x -> vhdl_parameter_t_to_yojson x) x))) |
2867 |
x.parameters)) |
2868 |
:: fields |
2869 |
in |
2870 |
let fields = |
2871 |
if x.typeMark = NoName |
2872 |
then fields |
2873 |
else |
2874 |
("typeMark", (((fun x -> vhdl_name_t_to_yojson x)) x.typeMark)) |
2875 |
:: fields |
2876 |
in |
2877 |
let fields = |
2878 |
if x.subprogram_type = "" |
2879 |
then fields |
2880 |
else |
2881 |
("subprogram_type", |
2882 |
(((fun (x : Ppx_deriving_runtime.string) -> `String x)) |
2883 |
x.subprogram_type)) |
2884 |
:: fields |
2885 |
in |
2886 |
let fields = |
2887 |
if x.name = "" |
2888 |
then fields |
2889 |
else |
2890 |
("name", |
2891 |
(((fun (x : Ppx_deriving_runtime.string) -> `String x)) x.name)) |
2892 |
:: fields |
2893 |
in |
2894 |
`Assoc fields) |
2895 |
[@ocaml.warning "-A"]) |
2896 |
|
2897 |
and (vhdl_subprogram_spec_t_of_yojson : |
2898 |
Yojson.Safe.json -> |
2899 |
vhdl_subprogram_spec_t Ppx_deriving_yojson_runtime.error_or) |
2900 |
= |
2901 |
((let open! Ppx_deriving_yojson_runtime in |
2902 |
function |
2903 |
| `Assoc xs -> |
2904 |
let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) = |
2905 |
match xs with |
2906 |
| ("name",x)::xs -> |
2907 |
loop xs |
2908 |
(((function |
2909 |
| `String x -> Result.Ok x |
2910 |
| _ -> |
2911 |
Result.Error "Vhdl_ast.vhdl_subprogram_spec_t.name") |
2912 |
x), arg1, arg2, arg3, arg4) |
2913 |
| ("subprogram_type",x)::xs -> |
2914 |
loop xs |
2915 |
(arg0, |
2916 |
((function |
2917 |
| `String x -> Result.Ok x |
2918 |
| _ -> |
2919 |
Result.Error |
2920 |
"Vhdl_ast.vhdl_subprogram_spec_t.subprogram_type") |
2921 |
x), arg2, arg3, arg4) |
2922 |
| ("typeMark",x)::xs -> |
2923 |
loop xs |
2924 |
(arg0, arg1, ((fun x -> vhdl_name_t_of_yojson x) x), arg3, |
2925 |
arg4) |
2926 |
| ("parameters",x)::xs -> |
2927 |
loop xs |
2928 |
(arg0, arg1, arg2, |
2929 |
((function |
2930 |
| `List xs -> |
2931 |
map_bind (fun x -> vhdl_parameter_t_of_yojson x) |
2932 |
[] xs |
2933 |
| _ -> |
2934 |
Result.Error |
2935 |
"Vhdl_ast.vhdl_subprogram_spec_t.parameters") x), |
2936 |
arg4) |
2937 |
| ("isPure",x)::xs -> |
2938 |
loop xs |
2939 |
(arg0, arg1, arg2, arg3, |
2940 |
((function |
2941 |
| `Bool x -> Result.Ok x |
2942 |
| _ -> |
2943 |
Result.Error |
2944 |
"Vhdl_ast.vhdl_subprogram_spec_t.isPure") x)) |
2945 |
| [] -> |
2946 |
arg4 >>= |
2947 |
((fun arg4 -> |
2948 |
arg3 >>= |
2949 |
(fun arg3 -> |
2950 |
arg2 >>= |
2951 |
(fun arg2 -> |
2952 |
arg1 >>= |
2953 |
(fun arg1 -> |
2954 |
arg0 >>= |
2955 |
(fun arg0 -> |
2956 |
Result.Ok |
2957 |
{ |
2958 |
name = arg0; |
2959 |
subprogram_type = arg1; |
2960 |
typeMark = arg2; |
2961 |
parameters = arg3; |
2962 |
isPure = arg4 |
2963 |
})))))) |
2964 |
| _::xs -> loop xs _state in |
2965 |
loop xs |
2966 |
((Result.Ok ""), (Result.Ok ""), (Result.Ok NoName), |
2967 |
(Result.Ok []), (Result.Ok false)) |
2968 |
| _ -> Result.Error "Vhdl_ast.vhdl_subprogram_spec_t") |
2969 |
[@ocaml.warning "-A"]) |
2970 |
|
2971 |
let arith_funs = ["+"; "-"; "*"; "/"; "mod"; "rem"; "abs"; "**"; "&"] |
2972 |
let bool_funs = ["and"; "or"; "nand"; "nor"; "xor"; "not"] |
2973 |
let rel_funs = |
2974 |
["<"; |
2975 |
">"; |
2976 |
"<="; |
2977 |
">="; |
2978 |
"/="; |
2979 |
"="; |
2980 |
"?="; |
2981 |
"?/="; |
2982 |
"?<"; |
2983 |
"?<="; |
2984 |
"?>"; |
2985 |
"?>="; |
2986 |
"??"] |
2987 |
let shift_funs = ["sll"; "srl"; "sla"; "sra"; "rol"; "ror"] |
2988 |
|
2989 |
type vhdl_waveform_element_t = |
2990 |
{ |
2991 |
value: vhdl_expr_t option [@default None]; |
2992 |
delay: vhdl_expr_t option [@default None]}[@@deriving |
2993 |
((show { with_path = false }), |
2994 |
(yojson { strict = false }))] |
2995 |
|
2996 |
let rec pp_vhdl_waveform_element_t : |
2997 |
Format.formatter -> vhdl_waveform_element_t -> Ppx_deriving_runtime.unit = |
2998 |
let __1 () = pp_vhdl_expr_t |
2999 |
|
3000 |
and __0 () = pp_vhdl_expr_t |
3001 |
in |
3002 |
((let open! Ppx_deriving_runtime in |
3003 |
fun fmt -> |
3004 |
fun x -> |
3005 |
(match x.value with |
3006 |
| None -> Format.fprintf fmt ""; |
3007 |
| Some IsNull -> Format.fprintf fmt "null"; |
3008 |
| Some v -> ((__0 ()) fmt) v); |
3009 |
(match x.delay with |
3010 |
| None -> Format.fprintf fmt ""; |
3011 |
| Some v -> |
3012 |
Format.fprintf fmt " after "; |
3013 |
((__1 ()) fmt) v)) |
3014 |
[@ocaml.warning "-A"]) |
3015 |
|
3016 |
and show_vhdl_waveform_element_t : |
3017 |
vhdl_waveform_element_t -> Ppx_deriving_runtime.string = |
3018 |
fun x -> Format.asprintf "%a" pp_vhdl_waveform_element_t x |
3019 |
|
3020 |
let rec (vhdl_waveform_element_t_to_yojson : |
3021 |
vhdl_waveform_element_t -> Yojson.Safe.json) |
3022 |
= |
3023 |
((let open! Ppx_deriving_yojson_runtime in |
3024 |
fun x -> |
3025 |
let fields = [] in |
3026 |
let fields = |
3027 |
if x.delay = None |
3028 |
then fields |
3029 |
else |
3030 |
("delay", |
3031 |
(((function |
3032 |
| None -> `Null |
3033 |
| Some x -> ((fun x -> vhdl_expr_t_to_yojson x)) x)) |
3034 |
x.delay)) |
3035 |
:: fields |
3036 |
in |
3037 |
let fields = |
3038 |
if x.value = None |
3039 |
then fields |
3040 |
else |
3041 |
("value", |
3042 |
(((function |
3043 |
| None -> `Null |
3044 |
| Some x -> ((fun x -> vhdl_expr_t_to_yojson x)) x)) |
3045 |
x.value)) |
3046 |
:: fields |
3047 |
in |
3048 |
`Assoc fields) |
3049 |
[@ocaml.warning "-A"]) |
3050 |
|
3051 |
and (vhdl_waveform_element_t_of_yojson : |
3052 |
Yojson.Safe.json -> |
3053 |
vhdl_waveform_element_t Ppx_deriving_yojson_runtime.error_or) |
3054 |
= |
3055 |
((let open! Ppx_deriving_yojson_runtime in |
3056 |
function |
3057 |
| `Assoc xs -> |
3058 |
let rec loop xs ((arg0,arg1) as _state) = |
3059 |
match xs with |
3060 |
| ("value",x)::xs -> |
3061 |
loop xs |
3062 |
(((function |
3063 |
| `Null -> Result.Ok None |
3064 |
| x -> |
3065 |
((fun x -> vhdl_expr_t_of_yojson x) x) >>= |
3066 |
((fun x -> Result.Ok (Some x)))) x), arg1) |
3067 |
| ("delay",x)::xs -> |
3068 |
loop xs |
3069 |
(arg0, |
3070 |
((function |
3071 |
| `Null -> Result.Ok None |
3072 |
| x -> |
3073 |
((fun x -> vhdl_expr_t_of_yojson x) x) >>= |
3074 |
((fun x -> Result.Ok (Some x)))) x)) |
3075 |
| [] -> |
3076 |
arg1 >>= |
3077 |
((fun arg1 -> |
3078 |
arg0 >>= |
3079 |
(fun arg0 -> |
3080 |
Result.Ok { value = arg0; delay = arg1 }))) |
3081 |
| _::xs -> loop xs _state in |
3082 |
loop xs ((Result.Ok None), (Result.Ok None)) |
3083 |
| _ -> Result.Error "Vhdl_ast.vhdl_waveform_element_t") |
3084 |
[@ocaml.warning "-A"]) |
3085 |
|
3086 |
type vhdl_sequential_stmt_t = |
3087 |
| VarAssign of |
3088 |
{ |
3089 |
label: vhdl_name_t [@default NoName]; |
3090 |
lhs: vhdl_name_t ; |
3091 |
rhs: vhdl_expr_t } [@name "VARIABLE_ASSIGNMENT_STATEMENT"] |
3092 |
| SigSeqAssign of |
3093 |
{ |
3094 |
label: vhdl_name_t [@default NoName]; |
3095 |
lhs: vhdl_name_t ; |
3096 |
rhs: vhdl_waveform_element_t list } [@name "SIGNAL_ASSIGNMENT_STATEMENT"] |
3097 |
| If of |
3098 |
{ |
3099 |
label: vhdl_name_t [@default NoName]; |
3100 |
if_cases: vhdl_if_case_t list ; |
3101 |
default: vhdl_sequential_stmt_t list [@default []]} [@name "IF_STATEMENT"] |
3102 |
| Case of |
3103 |
{ |
3104 |
label: vhdl_name_t [@default NoName]; |
3105 |
guard: vhdl_expr_t ; |
3106 |
branches: vhdl_case_item_t list } [@name "CASE_STATEMENT_TREE"] |
3107 |
| Exit of |
3108 |
{ |
3109 |
label: vhdl_name_t [@default NoName]; |
3110 |
loop_label: string option [@default Some ""]; |
3111 |
condition: vhdl_expr_t option [@default Some IsNull]} |
3112 |
[@name "EXIT_STATEMENT"] |
3113 |
| Assert of |
3114 |
{ |
3115 |
label: vhdl_name_t [@default NoName]; |
3116 |
cond: vhdl_expr_t ; |
3117 |
report: vhdl_expr_t [@default IsNull]; |
3118 |
severity: vhdl_expr_t [@default IsNull]} [@name "ASSERTION_STATEMENT"] |
3119 |
| ProcedureCall of |
3120 |
{ |
3121 |
label: vhdl_name_t [@default NoName]; |
3122 |
name: vhdl_name_t ; |
3123 |
assocs: vhdl_assoc_element_t list } [@name "PROCEDURE_CALL_STATEMENT"] |
3124 |
| Wait [@name "WAIT_STATEMENT"] |
3125 |
| Null of { |
3126 |
label: vhdl_name_t [@default NoName]} [@name "NULL_STATEMENT"] |
3127 |
| Return of { |
3128 |
label: vhdl_name_t [@default NoName]} [@name "RETURN_STATEMENT"] |
3129 |
and vhdl_if_case_t = |
3130 |
{ |
3131 |
if_cond: vhdl_expr_t ; |
3132 |
if_block: vhdl_sequential_stmt_t list } |
3133 |
and vhdl_case_item_t = |
3134 |
{ |
3135 |
when_cond: vhdl_expr_t list ; |
3136 |
when_stmt: vhdl_sequential_stmt_t list } |
3137 |
|
3138 |
let rec pp_vhdl_sequential_stmt_t : |
3139 |
Format.formatter -> vhdl_sequential_stmt_t -> Ppx_deriving_runtime.unit = |
3140 |
let __22 () = pp_vhdl_name_t |
3141 |
|
3142 |
and __21 () = pp_vhdl_name_t |
3143 |
|
3144 |
and __20 () = pp_vhdl_assoc_element_t |
3145 |
|
3146 |
and __19 () = pp_vhdl_name_t |
3147 |
|
3148 |
and __18 () = pp_vhdl_name_t |
3149 |
|
3150 |
and __17 () = pp_vhdl_expr_t |
3151 |
|
3152 |
and __16 () = pp_vhdl_expr_t |
3153 |
|
3154 |
and __15 () = pp_vhdl_expr_t |
3155 |
|
3156 |
and __14 () = pp_vhdl_name_t |
3157 |
|
3158 |
and __13 () = pp_vhdl_expr_t |
3159 |
|
3160 |
and __12 () = pp_vhdl_name_t |
3161 |
|
3162 |
and __11 () = pp_vhdl_case_item_t |
3163 |
|
3164 |
and __10 () = pp_vhdl_expr_t |
3165 |
|
3166 |
and __9 () = pp_vhdl_name_t |
3167 |
|
3168 |
and __8 () = pp_vhdl_sequential_stmt_t |
3169 |
|
3170 |
and __7 () = pp_vhdl_if_case_t |
3171 |
|
3172 |
and __6 () = pp_vhdl_name_t |
3173 |
|
3174 |
and __5 () = pp_vhdl_waveform_element_t |
3175 |
|
3176 |
and __4 () = pp_vhdl_name_t |
3177 |
|
3178 |
and __3 () = pp_vhdl_name_t |
3179 |
|
3180 |
and __2 () = pp_vhdl_expr_t |
3181 |
|
3182 |
and __1 () = pp_vhdl_name_t |
3183 |
|
3184 |
and __0 () = pp_vhdl_name_t |
3185 |
in |
3186 |
((let open! Ppx_deriving_runtime in |
3187 |
fun fmt -> |
3188 |
function |
3189 |
| VarAssign { label = alabel; lhs = alhs; rhs = arhs } -> |
3190 |
(match alabel with |
3191 |
| NoName -> Format.fprintf fmt ""; |
3192 |
| _ -> (((__0 ()) fmt) alabel; |
3193 |
Format.fprintf fmt ": ") |
3194 |
); |
3195 |
((__1 ()) fmt) alhs; |
3196 |
Format.fprintf fmt " := "; |
3197 |
((__2 ()) fmt) arhs; |
3198 |
(* TODO: Check |
3199 |
(Format.fprintf fmt "@[<2>VarAssign {@,"; |
3200 |
(((Format.fprintf fmt "@[%s =@ " "label"; |
3201 |
((__0 ()) fmt) alabel; |
3202 |
Format.fprintf fmt "@]"); |
3203 |
Format.fprintf fmt ";@ "; |
3204 |
Format.fprintf fmt "@[%s =@ " "lhs"; |
3205 |
((__1 ()) fmt) alhs; |
3206 |
Format.fprintf fmt "@]"); |
3207 |
Format.fprintf fmt ";@ "; |
3208 |
Format.fprintf fmt "@[%s =@ " "rhs"; |
3209 |
((__2 ()) fmt) arhs; |
3210 |
Format.fprintf fmt "@]"); |
3211 |
Format.fprintf fmt "@]}") *) |
3212 |
| SigSeqAssign { label = alabel; lhs = alhs; rhs = arhs } -> |
3213 |
(match alabel with |
3214 |
| NoName -> Format.fprintf fmt ""; |
3215 |
| _ -> (((__3 ()) fmt) alabel; |
3216 |
Format.fprintf fmt ":@ ") |
3217 |
); |
3218 |
Format.fprintf fmt "@[<2>"; |
3219 |
((__4 ()) fmt) alhs; |
3220 |
Format.fprintf fmt "@ <=@ "; |
3221 |
((fun x -> |
3222 |
Format.fprintf fmt "@["; |
3223 |
ignore |
3224 |
(List.fold_left |
3225 |
(fun sep -> |
3226 |
fun x -> |
3227 |
if sep then Format.fprintf fmt ""; |
3228 |
((__5 ()) fmt) x; |
3229 |
true) false x); |
3230 |
Format.fprintf fmt "@]@]")) arhs; |
3231 |
| If { label = alabel; if_cases = aif_cases; default = adefault } -> |
3232 |
(match alabel with |
3233 |
| NoName -> Format.fprintf fmt ""; |
3234 |
| _ -> (((__6 ()) fmt) alabel; |
3235 |
Format.fprintf fmt ":@ ") |
3236 |
); |
3237 |
Format.fprintf fmt "@[<v>if"; |
3238 |
((fun x -> |
3239 |
ignore |
3240 |
(List.fold_left |
3241 |
(fun sep -> |
3242 |
fun x -> |
3243 |
if sep then Format.fprintf fmt "@;elsif"; |
3244 |
((__7 ()) fmt) x; |
3245 |
true |
3246 |
) false x); |
3247 |
)) aif_cases; |
3248 |
(match adefault with |
3249 |
| [] -> Format.fprintf fmt ""; |
3250 |
| _ -> (Format.fprintf fmt "@;else"; |
3251 |
((fun x -> |
3252 |
Format.fprintf fmt "@;<0 2>"; |
3253 |
ignore |
3254 |
(List.fold_left |
3255 |
(fun sep -> |
3256 |
fun x -> |
3257 |
if sep then Format.fprintf fmt ""; |
3258 |
((__8 ()) fmt) x; |
3259 |
Format.fprintf fmt ";"; |
3260 |
true) false x))) adefault)); |
3261 |
Format.fprintf fmt "@;end if@]" |
3262 |
| Case { label = alabel; guard = aguard; branches = abranches } -> |
3263 |
(match alabel with |
3264 |
| NoName -> Format.fprintf fmt ""; |
3265 |
| _ -> (((__9 ()) fmt) alabel; |
3266 |
Format.fprintf fmt ":@ ") |
3267 |
); |
3268 |
Format.fprintf fmt "@[<v>case "; |
3269 |
((__10 ()) fmt) aguard; |
3270 |
Format.fprintf fmt " is"; |
3271 |
((fun x -> |
3272 |
ignore |
3273 |
(List.fold_left |
3274 |
(fun sep -> |
3275 |
fun x -> |
3276 |
if sep then Format.fprintf fmt ""; |
3277 |
((__11 ()) fmt) x; |
3278 |
true) false x);)) abranches; |
3279 |
Format.fprintf fmt "@;end case@]"; |
3280 |
| Exit |
3281 |
{ label = alabel; loop_label = aloop_label; |
3282 |
condition = acondition } |
3283 |
-> |
3284 |
(match alabel with |
3285 |
| NoName -> Format.fprintf fmt ""; |
3286 |
| _ -> (((__12 ()) fmt) alabel; |
3287 |
Format.fprintf fmt ":@ ") |
3288 |
); |
3289 |
Format.fprintf fmt "exit"; |
3290 |
(match aloop_label with |
3291 |
| None -> Format.pp_print_string fmt "" |
3292 |
| Some x -> (Format.fprintf fmt "@ %s@ ") x); |
3293 |
((function |
3294 |
| None -> Format.pp_print_string fmt "" |
3295 |
| Some x -> |
3296 |
(Format.pp_print_string fmt "when@ "; |
3297 |
((__13 ()) fmt) x;))) acondition; |
3298 |
| Assert |
3299 |
{ label = alabel; cond = acond; report = areport; |
3300 |
severity = aseverity } |
3301 |
-> |
3302 |
Format.fprintf fmt "@[<v 2>"; |
3303 |
(match alabel with |
3304 |
| NoName -> Format.fprintf fmt ""; |
3305 |
| _ -> (((__14 ()) fmt) alabel; |
3306 |
Format.fprintf fmt ":@ ") |
3307 |
); |
3308 |
Format.fprintf fmt "assert "; |
3309 |
((__15 ()) fmt) acond; |
3310 |
(match areport with |
3311 |
| IsNull -> Format.fprintf fmt ""; |
3312 |
| _ -> |
3313 |
Format.fprintf fmt "@;report "; |
3314 |
((__16 ()) fmt) areport); |
3315 |
(match aseverity with |
3316 |
| IsNull -> Format.fprintf fmt ""; |
3317 |
| _ -> |
3318 |
Format.fprintf fmt "@;severity "; |
3319 |
((__17 ()) fmt) aseverity); |
3320 |
Format.fprintf fmt "@]"; |
3321 |
| ProcedureCall { label = alabel; name = aname; assocs = aassocs } -> |
3322 |
(match alabel with |
3323 |
| NoName -> Format.fprintf fmt ""; |
3324 |
| _ -> (((__18 ()) fmt) alabel; |
3325 |
Format.fprintf fmt ":@ ") |
3326 |
); |
3327 |
((__19 ()) fmt) aname; |
3328 |
(match aassocs with |
3329 |
| [] -> Format.fprintf fmt ""; |
3330 |
| _ -> |
3331 |
Format.fprintf fmt "(@[<v>"; |
3332 |
((fun x -> |
3333 |
ignore |
3334 |
(List.fold_left |
3335 |
(fun sep -> |
3336 |
fun x -> |
3337 |
if sep then Format.fprintf fmt ",@ "; |
3338 |
((__20 ()) fmt) x; |
3339 |
true) false x))) aassocs; |
3340 |
Format.fprintf fmt "@])"); |
3341 |
| Wait -> Format.pp_print_string fmt "wait" |
3342 |
| Null { label = alabel } -> |
3343 |
(match alabel with |
3344 |
| NoName -> Format.fprintf fmt ""; |
3345 |
| _ -> (((__18 ()) fmt) alabel; |
3346 |
Format.fprintf fmt ":@ ") |
3347 |
); |
3348 |
Format.fprintf fmt "null"; |
3349 |
| Return { label = alabel } -> |
3350 |
(match alabel with |
3351 |
| NoName -> Format.fprintf fmt ""; |
3352 |
| _ -> (((__19 ()) fmt) alabel; |
3353 |
Format.fprintf fmt ":@ ") |
3354 |
); |
3355 |
Format.fprintf fmt "return";) |
3356 |
[@ocaml.warning "-A"]) |
3357 |
|
3358 |
and show_vhdl_sequential_stmt_t : |
3359 |
vhdl_sequential_stmt_t -> Ppx_deriving_runtime.string = |
3360 |
fun x -> Format.asprintf "%a" pp_vhdl_sequential_stmt_t x |
3361 |
|
3362 |
and pp_vhdl_if_case_t : |
3363 |
Format.formatter -> vhdl_if_case_t -> Ppx_deriving_runtime.unit = |
3364 |
let __1 () = pp_vhdl_sequential_stmt_t |
3365 |
|
3366 |
and __0 () = pp_vhdl_expr_t |
3367 |
in |
3368 |
((let open! Ppx_deriving_runtime in |
3369 |
fun fmt -> |
3370 |
fun x -> |
3371 |
Format.fprintf fmt " ("; |
3372 |
((__0 ()) fmt) x.if_cond; |
3373 |
Format.fprintf fmt ") then@;<0 2>"; |
3374 |
((fun x -> |
3375 |
ignore |
3376 |
(List.fold_left |
3377 |
(fun sep -> |
3378 |
fun x -> |
3379 |
if sep then Format.fprintf fmt "@;<0 2>"; |
3380 |
((__1 ()) fmt) x; |
3381 |
Format.fprintf fmt ";"; |
3382 |
true) false x); |
3383 |
)) x.if_block;) |
3384 |
[@ocaml.warning "-A"]) |
3385 |
|
3386 |
and show_vhdl_if_case_t : vhdl_if_case_t -> Ppx_deriving_runtime.string = |
3387 |
fun x -> Format.asprintf "%a" pp_vhdl_if_case_t x |
3388 |
|
3389 |
and pp_vhdl_case_item_t : |
3390 |
Format.formatter -> vhdl_case_item_t -> Ppx_deriving_runtime.unit = |
3391 |
let __1 () = pp_vhdl_sequential_stmt_t |
3392 |
|
3393 |
and __0 () = pp_vhdl_expr_t |
3394 |
in |
3395 |
((let open! Ppx_deriving_runtime in |
3396 |
fun fmt -> |
3397 |
fun x -> |
3398 |
Format.fprintf fmt "@;@[<v 2>when "; |
3399 |
((fun x -> |
3400 |
ignore |
3401 |
(List.fold_left |
3402 |
(fun sep -> |
3403 |
fun x -> |
3404 |
if sep then Format.fprintf fmt "@ |@ "; |
3405 |
((__0 ()) fmt) x; |
3406 |
true) false x);)) x.when_cond; |
3407 |
Format.fprintf fmt " => "; |
3408 |
(fun x -> |
3409 |
ignore |
3410 |
(List.fold_left |
3411 |
(fun sep -> |
3412 |
fun x -> |
3413 |
if sep then Format.fprintf fmt "@;"; |
3414 |
((__1 ()) fmt) x; |
3415 |
Format.fprintf fmt ";"; |
3416 |
true) ((List.length x) > 1) x);) x.when_stmt; |
3417 |
Format.fprintf fmt "@]") |
3418 |
[@ocaml.warning "-A"]) |
3419 |
|
3420 |
and show_vhdl_case_item_t : vhdl_case_item_t -> Ppx_deriving_runtime.string = |
3421 |
fun x -> Format.asprintf "%a" pp_vhdl_case_item_t x |
3422 |
|
3423 |
let rec (vhdl_sequential_stmt_t_to_yojson : |
3424 |
vhdl_sequential_stmt_t -> Yojson.Safe.json) |
3425 |
= |
3426 |
((let open! Ppx_deriving_yojson_runtime in |
3427 |
function |
3428 |
| VarAssign arg0 -> |
3429 |
`List |
3430 |
[`String "VARIABLE_ASSIGNMENT_STATEMENT"; |
3431 |
(let fields = [] in |
3432 |
let fields = |
3433 |
("rhs", ((fun x -> vhdl_expr_t_to_yojson x) arg0.rhs)) :: |
3434 |
fields in |
3435 |
let fields = |
3436 |
("lhs", ((fun x -> vhdl_name_t_to_yojson x) arg0.lhs)) :: |
3437 |
fields in |
3438 |
let fields = |
3439 |
if arg0.label = NoName |
3440 |
then fields |
3441 |
else |
3442 |
("label", |
3443 |
(((fun x -> vhdl_name_t_to_yojson x)) arg0.label)) |
3444 |
:: fields |
3445 |
in |
3446 |
`Assoc fields)] |
3447 |
| SigSeqAssign arg0 -> |
3448 |
`List |
3449 |
[`String "SIGNAL_ASSIGNMENT_STATEMENT"; |
3450 |
(let fields = [] in |
3451 |
let fields = |
3452 |
("rhs", |
3453 |
((fun x -> |
3454 |
`List |
3455 |
(List.map |
3456 |
(fun x -> vhdl_waveform_element_t_to_yojson x) x)) |
3457 |
arg0.rhs)) |
3458 |
:: fields in |
3459 |
let fields = |
3460 |
("lhs", ((fun x -> vhdl_name_t_to_yojson x) arg0.lhs)) :: |
3461 |
fields in |
3462 |
let fields = |
3463 |
if arg0.label = NoName |
3464 |
then fields |
3465 |
else |
3466 |
("label", |
3467 |
(((fun x -> vhdl_name_t_to_yojson x)) arg0.label)) |
3468 |
:: fields |
3469 |
in |
3470 |
`Assoc fields)] |
3471 |
| If arg0 -> |
3472 |
`List |
3473 |
[`String "IF_STATEMENT"; |
3474 |
(let fields = [] in |
3475 |
let fields = |
3476 |
if arg0.default = [] |
3477 |
then fields |
3478 |
else |
3479 |
("default", |
3480 |
(((fun x -> |
3481 |
`List |
3482 |
(List.map |
3483 |
(fun x -> vhdl_sequential_stmt_t_to_yojson x) x))) |
3484 |
arg0.default)) |
3485 |
:: fields |
3486 |
in |
3487 |
let fields = |
3488 |
("if_cases", |
3489 |
((fun x -> |
3490 |
`List |
3491 |
(List.map (fun x -> vhdl_if_case_t_to_yojson x) x)) |
3492 |
arg0.if_cases)) |
3493 |
:: fields in |
3494 |
let fields = |
3495 |
if arg0.label = NoName |
3496 |
then fields |
3497 |
else |
3498 |
("label", |
3499 |
(((fun x -> vhdl_name_t_to_yojson x)) arg0.label)) |
3500 |
:: fields |
3501 |
in |
3502 |
`Assoc fields)] |
3503 |
| Case arg0 -> |
3504 |
`List |
3505 |
[`String "CASE_STATEMENT_TREE"; |
3506 |
(let fields = [] in |
3507 |
let fields = |
3508 |
("branches", |
3509 |
((fun x -> |
3510 |
`List |
3511 |
(List.map (fun x -> vhdl_case_item_t_to_yojson x) x)) |
3512 |
arg0.branches)) |
3513 |
:: fields in |
3514 |
let fields = |
3515 |
("guard", ((fun x -> vhdl_expr_t_to_yojson x) arg0.guard)) :: |
3516 |
fields in |
3517 |
let fields = |
3518 |
if arg0.label = NoName |
3519 |
then fields |
3520 |
else |
3521 |
("label", |
3522 |
(((fun x -> vhdl_name_t_to_yojson x)) arg0.label)) |
3523 |
:: fields |
3524 |
in |
3525 |
`Assoc fields)] |
3526 |
| Exit arg0 -> |
3527 |
`List |
3528 |
[`String "EXIT_STATEMENT"; |
3529 |
(let fields = [] in |
3530 |
let fields = |
3531 |
if arg0.condition = (Some IsNull) |
3532 |
then fields |
3533 |
else |
3534 |
("condition", |
3535 |
(((function |
3536 |
| None -> `Null |
3537 |
| Some x -> ((fun x -> vhdl_expr_t_to_yojson x)) x)) |
3538 |
arg0.condition)) |
3539 |
:: fields |
3540 |
in |
3541 |
let fields = |
3542 |
if arg0.loop_label = (Some "") |
3543 |
then fields |
3544 |
else |
3545 |
("loop_label", |
3546 |
(((function |
3547 |
| None -> `Null |
3548 |
| Some x -> |
3549 |
((fun (x : Ppx_deriving_runtime.string) -> |
3550 |
`String x)) x)) arg0.loop_label)) |
3551 |
:: fields |
3552 |
in |
3553 |
let fields = |
3554 |
if arg0.label = NoName |
3555 |
then fields |
3556 |
else |
3557 |
("label", |
3558 |
(((fun x -> vhdl_name_t_to_yojson x)) arg0.label)) |
3559 |
:: fields |
3560 |
in |
3561 |
`Assoc fields)] |
3562 |
| Assert arg0 -> |
3563 |
`List |
3564 |
[`String "ASSERTION_STATEMENT"; |
3565 |
(let fields = [] in |
3566 |
let fields = |
3567 |
if arg0.severity = IsNull |
3568 |
then fields |
3569 |
else |
3570 |
("severity", |
3571 |
(((fun x -> vhdl_expr_t_to_yojson x)) arg0.severity)) |
3572 |
:: fields |
3573 |
in |
3574 |
let fields = |
3575 |
if arg0.report = IsNull |
3576 |
then fields |
3577 |
else |
3578 |
("report", |
3579 |
(((fun x -> vhdl_expr_t_to_yojson x)) arg0.report)) |
3580 |
:: fields |
3581 |
in |
3582 |
let fields = |
3583 |
("cond", ((fun x -> vhdl_expr_t_to_yojson x) arg0.cond)) :: |
3584 |
fields in |
3585 |
let fields = |
3586 |
if arg0.label = NoName |
3587 |
then fields |
3588 |
else |
3589 |
("label", |
3590 |
(((fun x -> vhdl_name_t_to_yojson x)) arg0.label)) |
3591 |
:: fields |
3592 |
in |
3593 |
`Assoc fields)] |
3594 |
| ProcedureCall arg0 -> |
3595 |
`List |
3596 |
[`String "PROCEDURE_CALL_STATEMENT"; |
3597 |
(let fields = [] in |
3598 |
let fields = |
3599 |
if arg0.assocs = [] |
3600 |
then fields |
3601 |
else |
3602 |
("assocs", |
3603 |
(((fun x -> |
3604 |
`List |
3605 |
(List.map |
3606 |
(fun x -> vhdl_assoc_element_t_to_yojson x) x))) |
3607 |
arg0.assocs)) |
3608 |
:: fields |
3609 |
in |
3610 |
let fields = |
3611 |
("name", ((fun x -> vhdl_name_t_to_yojson x) arg0.name)) :: |
3612 |
fields in |
3613 |
let fields = |
3614 |
if arg0.label = NoName |
3615 |
then fields |
3616 |
else |
3617 |
("label", |
3618 |
(((fun x -> vhdl_name_t_to_yojson x)) arg0.label)) |
3619 |
:: fields |
3620 |
in |
3621 |
`Assoc fields)] |
3622 |
| Wait -> `List [`String "WAIT_STATEMENT"] |
3623 |
| Null arg0 -> |
3624 |
`List |
3625 |
[`String "NULL_STATEMENT"; |
3626 |
(let fields = [] in |
3627 |
let fields = |
3628 |
if arg0.label = NoName |
3629 |
then fields |
3630 |
else |
3631 |
("label", |
3632 |
(((fun x -> vhdl_name_t_to_yojson x)) arg0.label)) |
3633 |
:: fields |
3634 |
in |
3635 |
`Assoc fields)] |
3636 |
| Return arg0 -> |
3637 |
`List |
3638 |
[`String "RETURN_STATEMENT"; |
3639 |
(let fields = [] in |
3640 |
let fields = |
3641 |
if arg0.label = NoName |
3642 |
then fields |
3643 |
else |
3644 |
("label", |
3645 |
(((fun x -> vhdl_name_t_to_yojson x)) arg0.label)) |
3646 |
:: fields |
3647 |
in |
3648 |
`Assoc fields)]) |
3649 |
[@ocaml.warning "-A"]) |
3650 |
|
3651 |
and (vhdl_sequential_stmt_t_of_yojson : |
3652 |
Yojson.Safe.json -> |
3653 |
vhdl_sequential_stmt_t Ppx_deriving_yojson_runtime.error_or) |
3654 |
= |
3655 |
((let open! Ppx_deriving_yojson_runtime in |
3656 |
function |
3657 |
| `List ((`String "VARIABLE_ASSIGNMENT_STATEMENT")::arg0::[]) -> |
3658 |
((function |
3659 |
| `Assoc xs -> |
3660 |
let rec loop xs ((arg0,arg1,arg2) as _state) = |
3661 |
match xs with |
3662 |
| ("label",x)::xs -> |
3663 |
loop xs |
3664 |
(((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2) |
3665 |
| ("lhs",x)::xs -> |
3666 |
loop xs |
3667 |
(arg0, ((fun x -> vhdl_name_t_of_yojson x) x), arg2) |
3668 |
| ("rhs",x)::xs -> |
3669 |
loop xs |
3670 |
(arg0, arg1, ((fun x -> vhdl_expr_t_of_yojson x) x)) |
3671 |
| [] -> |
3672 |
arg2 >>= |
3673 |
((fun arg2 -> |
3674 |
arg1 >>= |
3675 |
(fun arg1 -> |
3676 |
arg0 >>= |
3677 |
(fun arg0 -> |
3678 |
Result.Ok |
3679 |
(VarAssign |
3680 |
{ |
3681 |
label = arg0; |
3682 |
lhs = arg1; |
3683 |
rhs = arg2 |
3684 |
}))))) |
3685 |
| _::xs -> loop xs _state in |
3686 |
loop xs |
3687 |
((Result.Ok NoName), |
3688 |
(Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.lhs"), |
3689 |
(Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.rhs")) |
3690 |
| _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0 |
3691 |
| `List ((`String "SIGNAL_ASSIGNMENT_STATEMENT")::arg0::[]) -> |
3692 |
((function |
3693 |
| `Assoc xs -> |
3694 |
let rec loop xs ((arg0,arg1,arg2) as _state) = |
3695 |
match xs with |
3696 |
| ("label",x)::xs -> |
3697 |
loop xs |
3698 |
(((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2) |
3699 |
| ("lhs",x)::xs -> |
3700 |
loop xs |
3701 |
(arg0, ((fun x -> vhdl_name_t_of_yojson x) x), arg2) |
3702 |
| ("rhs",x)::xs -> |
3703 |
loop xs |
3704 |
(arg0, arg1, |
3705 |
((function |
3706 |
| `List xs -> |
3707 |
map_bind |
3708 |
(fun x -> |
3709 |
vhdl_waveform_element_t_of_yojson x) [] |
3710 |
xs |
3711 |
| _ -> |
3712 |
Result.Error |
3713 |
"Vhdl_ast.vhdl_sequential_stmt_t.rhs") x)) |
3714 |
| [] -> |
3715 |
arg2 >>= |
3716 |
((fun arg2 -> |
3717 |
arg1 >>= |
3718 |
(fun arg1 -> |
3719 |
arg0 >>= |
3720 |
(fun arg0 -> |
3721 |
Result.Ok |
3722 |
(SigSeqAssign |
3723 |
{ |
3724 |
label = arg0; |
3725 |
lhs = arg1; |
3726 |
rhs = arg2 |
3727 |
}))))) |
3728 |
| _::xs -> loop xs _state in |
3729 |
loop xs |
3730 |
((Result.Ok NoName), |
3731 |
(Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.lhs"), |
3732 |
(Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.rhs")) |
3733 |
| _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0 |
3734 |
| `List ((`String "IF_STATEMENT")::arg0::[]) -> |
3735 |
((function |
3736 |
| `Assoc xs -> |
3737 |
let rec loop xs ((arg0,arg1,arg2) as _state) = |
3738 |
match xs with |
3739 |
| ("label",x)::xs -> |
3740 |
loop xs |
3741 |
(((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2) |
3742 |
| ("if_cases",x)::xs -> |
3743 |
loop xs |
3744 |
(arg0, |
3745 |
((function |
3746 |
| `List xs -> |
3747 |
map_bind |
3748 |
(fun x -> vhdl_if_case_t_of_yojson x) [] |
3749 |
xs |
3750 |
| _ -> |
3751 |
Result.Error |
3752 |
"Vhdl_ast.vhdl_sequential_stmt_t.if_cases") |
3753 |
x), arg2) |
3754 |
| ("default",x)::xs -> |
3755 |
loop xs |
3756 |
(arg0, arg1, |
3757 |
((function |
3758 |
| `List xs -> |
3759 |
map_bind |
3760 |
(fun x -> |
3761 |
vhdl_sequential_stmt_t_of_yojson x) [] |
3762 |
xs |
3763 |
| _ -> |
3764 |
Result.Error |
3765 |
"Vhdl_ast.vhdl_sequential_stmt_t.default") |
3766 |
x)) |
3767 |
| [] -> |
3768 |
arg2 >>= |
3769 |
((fun arg2 -> |
3770 |
arg1 >>= |
3771 |
(fun arg1 -> |
3772 |
arg0 >>= |
3773 |
(fun arg0 -> |
3774 |
Result.Ok |
3775 |
(If |
3776 |
{ |
3777 |
label = arg0; |
3778 |
if_cases = arg1; |
3779 |
default = arg2 |
3780 |
}))))) |
3781 |
| _::xs -> loop xs _state in |
3782 |
loop xs |
3783 |
((Result.Ok NoName), |
3784 |
(Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.if_cases"), |
3785 |
(Result.Ok [])) |
3786 |
| _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0 |
3787 |
| `List ((`String "CASE_STATEMENT_TREE")::arg0::[]) -> |
3788 |
((function |
3789 |
| `Assoc xs -> |
3790 |
let rec loop xs ((arg0,arg1,arg2) as _state) = |
3791 |
match xs with |
3792 |
| ("label",x)::xs -> |
3793 |
loop xs |
3794 |
(((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2) |
3795 |
| ("guard",x)::xs -> |
3796 |
loop xs |
3797 |
(arg0, ((fun x -> vhdl_expr_t_of_yojson x) x), arg2) |
3798 |
| ("branches",x)::xs -> |
3799 |
loop xs |
3800 |
(arg0, arg1, |
3801 |
((function |
3802 |
| `List xs -> |
3803 |
map_bind |
3804 |
(fun x -> vhdl_case_item_t_of_yojson x) [] |
3805 |
xs |
3806 |
| _ -> |
3807 |
Result.Error |
3808 |
"Vhdl_ast.vhdl_sequential_stmt_t.branches") |
3809 |
x)) |
3810 |
| [] -> |
3811 |
arg2 >>= |
3812 |
((fun arg2 -> |
3813 |
arg1 >>= |
3814 |
(fun arg1 -> |
3815 |
arg0 >>= |
3816 |
(fun arg0 -> |
3817 |
Result.Ok |
3818 |
(Case |
3819 |
{ |
3820 |
label = arg0; |
3821 |
guard = arg1; |
3822 |
branches = arg2 |
3823 |
}))))) |
3824 |
| _::xs -> loop xs _state in |
3825 |
loop xs |
3826 |
((Result.Ok NoName), |
3827 |
(Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.guard"), |
3828 |
(Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.branches")) |
3829 |
| _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0 |
3830 |
| `List ((`String "EXIT_STATEMENT")::arg0::[]) -> |
3831 |
((function |
3832 |
| `Assoc xs -> |
3833 |
let rec loop xs ((arg0,arg1,arg2) as _state) = |
3834 |
match xs with |
3835 |
| ("label",x)::xs -> |
3836 |
loop xs |
3837 |
(((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2) |
3838 |
| ("loop_label",x)::xs -> |
3839 |
loop xs |
3840 |
(arg0, |
3841 |
((function |
3842 |
| `Null -> Result.Ok None |
3843 |
| x -> |
3844 |
((function |
3845 |
| `String x -> Result.Ok x |
3846 |
| _ -> |
3847 |
Result.Error |
3848 |
"Vhdl_ast.vhdl_sequential_stmt_t.loop_label") |
3849 |
x) |
3850 |
>>= ((fun x -> Result.Ok (Some x)))) x), |
3851 |
arg2) |
3852 |
| ("condition",x)::xs -> |
3853 |
loop xs |
3854 |
(arg0, arg1, |
3855 |
((function |
3856 |
| `Null -> Result.Ok None |
3857 |
| x -> |
3858 |
((fun x -> vhdl_expr_t_of_yojson x) x) >>= |
3859 |
((fun x -> Result.Ok (Some x)))) x)) |
3860 |
| [] -> |
3861 |
arg2 >>= |
3862 |
((fun arg2 -> |
3863 |
arg1 >>= |
3864 |
(fun arg1 -> |
3865 |
arg0 >>= |
3866 |
(fun arg0 -> |
3867 |
Result.Ok |
3868 |
(Exit |
3869 |
{ |
3870 |
label = arg0; |
3871 |
loop_label = arg1; |
3872 |
condition = arg2 |
3873 |
}))))) |
3874 |
| _::xs -> loop xs _state in |
3875 |
loop xs |
3876 |
((Result.Ok NoName), (Result.Ok (Some "")), |
3877 |
(Result.Ok (Some IsNull))) |
3878 |
| _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0 |
3879 |
| `List ((`String "ASSERTION_STATEMENT")::arg0::[]) -> |
3880 |
((function |
3881 |
| `Assoc xs -> |
3882 |
let rec loop xs ((arg0,arg1,arg2,arg3) as _state) = |
3883 |
match xs with |
3884 |
| ("label",x)::xs -> |
3885 |
loop xs |
3886 |
(((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2, |
3887 |
arg3) |
3888 |
| ("cond",x)::xs -> |
3889 |
loop xs |
3890 |
(arg0, ((fun x -> vhdl_expr_t_of_yojson x) x), arg2, |
3891 |
arg3) |
3892 |
| ("report",x)::xs -> |
3893 |
loop xs |
3894 |
(arg0, arg1, ((fun x -> vhdl_expr_t_of_yojson x) x), |
3895 |
arg3) |
3896 |
| ("severity",x)::xs -> |
3897 |
loop xs |
3898 |
(arg0, arg1, arg2, |
3899 |
((fun x -> vhdl_expr_t_of_yojson x) x)) |
3900 |
| [] -> |
3901 |
arg3 >>= |
3902 |
((fun arg3 -> |
3903 |
arg2 >>= |
3904 |
(fun arg2 -> |
3905 |
arg1 >>= |
3906 |
(fun arg1 -> |
3907 |
arg0 >>= |
3908 |
(fun arg0 -> |
3909 |
Result.Ok |
3910 |
(Assert |
3911 |
{ |
3912 |
label = arg0; |
3913 |
cond = arg1; |
3914 |
report = arg2; |
3915 |
severity = arg3 |
3916 |
})))))) |
3917 |
| _::xs -> loop xs _state in |
3918 |
loop xs |
3919 |
((Result.Ok NoName), |
3920 |
(Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.cond"), |
3921 |
(Result.Ok IsNull), (Result.Ok IsNull)) |
3922 |
| _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0 |
3923 |
| `List ((`String "PROCEDURE_CALL_STATEMENT")::arg0::[]) -> |
3924 |
((function |
3925 |
| `Assoc xs -> |
3926 |
let rec loop xs ((arg0,arg1,arg2) as _state) = |
3927 |
match xs with |
3928 |
| ("label",x)::xs -> |
3929 |
loop xs |
3930 |
(((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2) |
3931 |
| ("name",x)::xs -> |
3932 |
loop xs |
3933 |
(arg0, ((fun x -> vhdl_name_t_of_yojson x) x), arg2) |
3934 |
| ("assocs",x)::xs -> |
3935 |
loop xs |
3936 |
(arg0, arg1, |
3937 |
((function |
3938 |
| `List xs -> |
3939 |
map_bind |
3940 |
(fun x -> vhdl_assoc_element_t_of_yojson x) |
3941 |
[] xs |
3942 |
| _ -> |
3943 |
Result.Error |
3944 |
"Vhdl_ast.vhdl_sequential_stmt_t.assocs") x)) |
3945 |
| [] -> |
3946 |
arg2 >>= |
3947 |
((fun arg2 -> |
3948 |
arg1 >>= |
3949 |
(fun arg1 -> |
3950 |
arg0 >>= |
3951 |
(fun arg0 -> |
3952 |
Result.Ok |
3953 |
(ProcedureCall |
3954 |
{ |
3955 |
label = arg0; |
3956 |
name = arg1; |
3957 |
assocs = arg2 |
3958 |
}))))) |
3959 |
| _::xs -> loop xs _state in |
3960 |
loop xs |
3961 |
((Result.Ok NoName), |
3962 |
(Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.name"), |
3963 |
(Result.Ok [])) |
3964 |
| _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0 |
3965 |
| `List ((`String "WAIT_STATEMENT")::[]) -> Result.Ok Wait |
3966 |
| `List ((`String "NULL_STATEMENT")::arg0::[]) -> |
3967 |
((function |
3968 |
| `Assoc xs -> |
3969 |
let rec loop xs (arg0 as _state) = |
3970 |
match xs with |
3971 |
| ("label",x)::xs -> |
3972 |
loop xs ((fun x -> vhdl_name_t_of_yojson x) x) |
3973 |
| [] -> |
3974 |
arg0 >>= |
3975 |
((fun arg0 -> Result.Ok (Null { label = arg0 }))) |
3976 |
| _::xs -> loop xs _state in |
3977 |
loop xs (Result.Ok NoName) |
3978 |
| _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0 |
3979 |
| `List ((`String "RETURN_STATEMENT")::arg0::[]) -> |
3980 |
((function |
3981 |
| `Assoc xs -> |
3982 |
let rec loop xs (arg0 as _state) = |
3983 |
match xs with |
3984 |
| ("label",x)::xs -> |
3985 |
loop xs ((fun x -> vhdl_name_t_of_yojson x) x) |
3986 |
| [] -> |
3987 |
arg0 >>= |
3988 |
((fun arg0 -> Result.Ok (Return { label = arg0 }))) |
3989 |
| _::xs -> loop xs _state in |
3990 |
loop xs (Result.Ok NoName) |
3991 |
| _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0 |
3992 |
| _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t") |
3993 |
[@ocaml.warning "-A"]) |
3994 |
|
3995 |
and (vhdl_if_case_t_to_yojson : vhdl_if_case_t -> Yojson.Safe.json) = |
3996 |
((let open! Ppx_deriving_yojson_runtime in |
3997 |
fun x -> |
3998 |
let fields = [] in |
3999 |
let fields = |
4000 |
("if_block", |
4001 |
((fun x -> |
4002 |
`List |
4003 |
(List.map (fun x -> vhdl_sequential_stmt_t_to_yojson x) x)) |
4004 |
x.if_block)) |
4005 |
:: fields in |
4006 |
let fields = |
4007 |
("if_cond", ((fun x -> vhdl_expr_t_to_yojson x) x.if_cond)) :: |
4008 |
fields in |
4009 |
`Assoc fields) |
4010 |
[@ocaml.warning "-A"]) |
4011 |
|
4012 |
and (vhdl_if_case_t_of_yojson : |
4013 |
Yojson.Safe.json -> vhdl_if_case_t Ppx_deriving_yojson_runtime.error_or) |
4014 |
= |
4015 |
((let open! Ppx_deriving_yojson_runtime in |
4016 |
function |
4017 |
| `Assoc xs -> |
4018 |
let rec loop xs ((arg0,arg1) as _state) = |
4019 |
match xs with |
4020 |
| ("if_cond",x)::xs -> |
4021 |
loop xs (((fun x -> vhdl_expr_t_of_yojson x) x), arg1) |
4022 |
| ("if_block",x)::xs -> |
4023 |
loop xs |
4024 |
(arg0, |
4025 |
((function |
4026 |
| `List xs -> |
4027 |
map_bind |
4028 |
(fun x -> vhdl_sequential_stmt_t_of_yojson x) [] |
4029 |
xs |
4030 |
| _ -> Result.Error "Vhdl_ast.vhdl_if_case_t.if_block") |
4031 |
x)) |
4032 |
| [] -> |
4033 |
arg1 >>= |
4034 |
((fun arg1 -> |
4035 |
arg0 >>= |
4036 |
(fun arg0 -> |
4037 |
Result.Ok { if_cond = arg0; if_block = arg1 }))) |
4038 |
| _::xs -> loop xs _state in |
4039 |
loop xs |
4040 |
((Result.Error "Vhdl_ast.vhdl_if_case_t.if_cond"), |
4041 |
(Result.Error "Vhdl_ast.vhdl_if_case_t.if_block")) |
4042 |
| _ -> Result.Error "Vhdl_ast.vhdl_if_case_t") |
4043 |
[@ocaml.warning "-A"]) |
4044 |
|
4045 |
and (vhdl_case_item_t_to_yojson : vhdl_case_item_t -> Yojson.Safe.json) = |
4046 |
((let open! Ppx_deriving_yojson_runtime in |
4047 |
fun x -> |
4048 |
let fields = [] in |
4049 |
let fields = |
4050 |
("when_stmt", |
4051 |
((fun x -> |
4052 |
`List |
4053 |
(List.map (fun x -> vhdl_sequential_stmt_t_to_yojson x) x)) |
4054 |
x.when_stmt)) |
4055 |
:: fields in |
4056 |
let fields = |
4057 |
("when_cond", |
4058 |
((fun x -> |
4059 |
`List (List.map (fun x -> vhdl_expr_t_to_yojson x) x)) |
4060 |
x.when_cond)) |
4061 |
:: fields in |
4062 |
`Assoc fields) |
4063 |
[@ocaml.warning "-A"]) |
4064 |
|
4065 |
and (vhdl_case_item_t_of_yojson : |
4066 |
Yojson.Safe.json -> |
4067 |
vhdl_case_item_t Ppx_deriving_yojson_runtime.error_or) |
4068 |
= |
4069 |
((let open! Ppx_deriving_yojson_runtime in |
4070 |
function |
4071 |
| `Assoc xs -> |
4072 |
let rec loop xs ((arg0,arg1) as _state) = |
4073 |
match xs with |
4074 |
| ("when_cond",x)::xs -> |
4075 |
loop xs |
4076 |
(((function |
4077 |
| `List xs -> |
4078 |
map_bind (fun x -> vhdl_expr_t_of_yojson x) [] xs |
4079 |
| _ -> |
4080 |
Result.Error "Vhdl_ast.vhdl_case_item_t.when_cond") |
4081 |
x), arg1) |
4082 |
| ("when_stmt",x)::xs -> |
4083 |
loop xs |
4084 |
(arg0, |
4085 |
((function |
4086 |
| `List xs -> |
4087 |
map_bind |
4088 |
(fun x -> vhdl_sequential_stmt_t_of_yojson x) [] |
4089 |
xs |
4090 |
| _ -> |
4091 |
Result.Error "Vhdl_ast.vhdl_case_item_t.when_stmt") |
4092 |
x)) |
4093 |
| [] -> |
4094 |
arg1 >>= |
4095 |
((fun arg1 -> |
4096 |
arg0 >>= |
4097 |
(fun arg0 -> |
4098 |
Result.Ok { when_cond = arg0; when_stmt = arg1 }))) |
4099 |
| _::xs -> loop xs _state in |
4100 |
loop xs |
4101 |
((Result.Error "Vhdl_ast.vhdl_case_item_t.when_cond"), |
4102 |
(Result.Error "Vhdl_ast.vhdl_case_item_t.when_stmt")) |
4103 |
| _ -> Result.Error "Vhdl_ast.vhdl_case_item_t") |
4104 |
[@ocaml.warning "-A"]) |
4105 |
|
4106 |
type vhdl_port_mode_t = |
4107 |
| InPort [@name "in"] |
4108 |
| OutPort [@name "out"] |
4109 |
| InoutPort [@name "inout"] |
4110 |
| BufferPort [@name "buffer"] |
4111 |
|
4112 |
let rec (pp_vhdl_port_mode_t : |
4113 |
Format.formatter -> vhdl_port_mode_t -> Ppx_deriving_runtime.unit) |
4114 |
= |
4115 |
((let open! Ppx_deriving_runtime in |
4116 |
fun fmt -> |
4117 |
function |
4118 |
| InPort -> Format.pp_print_string fmt "in" |
4119 |
| OutPort -> Format.pp_print_string fmt "out" |
4120 |
| InoutPort -> Format.pp_print_string fmt "inout" |
4121 |
| BufferPort -> Format.pp_print_string fmt "buffer") |
4122 |
[@ocaml.warning "-A"]) |
4123 |
|
4124 |
and show_vhdl_port_mode_t : vhdl_port_mode_t -> Ppx_deriving_runtime.string = |
4125 |
fun x -> Format.asprintf "%a" pp_vhdl_port_mode_t x |
4126 |
|
4127 |
let rec (vhdl_port_mode_t_to_yojson : vhdl_port_mode_t -> Yojson.Safe.json) = |
4128 |
((let open! Ppx_deriving_yojson_runtime in |
4129 |
function |
4130 |
| InPort -> `List [`String "in"] |
4131 |
| OutPort -> `List [`String "out"] |
4132 |
| InoutPort -> `List [`String "inout"] |
4133 |
| BufferPort -> `List [`String "buffer"]) |
4134 |
[@ocaml.warning "-A"]) |
4135 |
|
4136 |
and (vhdl_port_mode_t_of_yojson : |
4137 |
Yojson.Safe.json -> |
4138 |
vhdl_port_mode_t Ppx_deriving_yojson_runtime.error_or) |
4139 |
= |
4140 |
((let open! Ppx_deriving_yojson_runtime in |
4141 |
function |
4142 |
| `List ((`String "in")::[]) -> Result.Ok InPort |
4143 |
| `List ((`String "out")::[]) -> Result.Ok OutPort |
4144 |
| `List ((`String "inout")::[]) -> Result.Ok InoutPort |
4145 |
| `List ((`String "buffer")::[]) -> Result.Ok BufferPort |
4146 |
| _ -> Result.Error "Vhdl_ast.vhdl_port_mode_t") |
4147 |
[@ocaml.warning "-A"]) |
4148 |
|
4149 |
type vhdl_port_t = |
4150 |
{ |
4151 |
names: vhdl_name_t list [@default []]; |
4152 |
mode: vhdl_port_mode_t [@default InPort]; |
4153 |
typ: vhdl_subtype_indication_t ; |
4154 |
expr: vhdl_expr_t [@default IsNull]} |
4155 |
|
4156 |
let rec pp_vhdl_port_t : |
4157 |
Format.formatter -> vhdl_port_t -> Ppx_deriving_runtime.unit = |
4158 |
let __3 () = pp_vhdl_expr_t |
4159 |
|
4160 |
and __2 () = pp_vhdl_subtype_indication_t |
4161 |
|
4162 |
and __1 () = pp_vhdl_port_mode_t |
4163 |
|
4164 |
and __0 () = pp_vhdl_name_t |
4165 |
in |
4166 |
((let open! Ppx_deriving_runtime in |
4167 |
fun fmt -> |
4168 |
fun x -> |
4169 |
Format.fprintf fmt "@["; |
4170 |
(((( |
4171 |
((fun x -> |
4172 |
Format.fprintf fmt "@["; |
4173 |
ignore |
4174 |
(List.fold_left |
4175 |
(fun sep -> |
4176 |
fun x -> |
4177 |
if sep then Format.fprintf fmt ",@ "; |
4178 |
((__0 ()) fmt) x; |
4179 |
true) false x); |
4180 |
Format.fprintf fmt "@,@]")) x.names; |
4181 |
); |
4182 |
Format.fprintf fmt ": "; |
4183 |
((__1 ()) fmt) x.mode; |
4184 |
); |
4185 |
Format.fprintf fmt " "; |
4186 |
((__2 ()) fmt) x.typ; |
4187 |
); |
4188 |
(match x.expr with |
4189 |
| IsNull -> Format.fprintf fmt ""; |
4190 |
| _ -> (Format.fprintf fmt "@[:= "; |
4191 |
((__3 ()) fmt) x.expr; |
4192 |
Format.fprintf fmt "@]")); |
4193 |
Format.fprintf fmt "@]")) |
4194 |
[@ocaml.warning "-A"]) |
4195 |
|
4196 |
and show_vhdl_port_t : vhdl_port_t -> Ppx_deriving_runtime.string = |
4197 |
fun x -> Format.asprintf "%a" pp_vhdl_port_t x |
4198 |
|
4199 |
let rec (vhdl_port_t_to_yojson : vhdl_port_t -> Yojson.Safe.json) = |
4200 |
((let open! Ppx_deriving_yojson_runtime in |
4201 |
fun x -> |
4202 |
let fields = [] in |
4203 |
let fields = |
4204 |
if x.expr = IsNull |
4205 |
then fields |
4206 |
else ("expr", (((fun x -> vhdl_expr_t_to_yojson x)) x.expr)) :: |
4207 |
fields |
4208 |
in |
4209 |
let fields = |
4210 |
("typ", ((fun x -> vhdl_subtype_indication_t_to_yojson x) x.typ)) |
4211 |
:: fields in |
4212 |
let fields = |
4213 |
if x.mode = InPort |
4214 |
then fields |
4215 |
else ("mode", (((fun x -> vhdl_port_mode_t_to_yojson x)) x.mode)) |
4216 |
:: fields |
4217 |
in |
4218 |
let fields = |
4219 |
if x.names = [] |
4220 |
then fields |
4221 |
else |
4222 |
("names", |
4223 |
(((fun x -> |
4224 |
`List (List.map (fun x -> vhdl_name_t_to_yojson x) x))) |
4225 |
x.names)) |
4226 |
:: fields |
4227 |
in |
4228 |
`Assoc fields) |
4229 |
[@ocaml.warning "-A"]) |
4230 |
|
4231 |
and (vhdl_port_t_of_yojson : |
4232 |
Yojson.Safe.json -> vhdl_port_t Ppx_deriving_yojson_runtime.error_or) |
4233 |
= |
4234 |
((let open! Ppx_deriving_yojson_runtime in |
4235 |
function |
4236 |
| `Assoc xs -> |
4237 |
let rec loop xs ((arg0,arg1,arg2,arg3) as _state) = |
4238 |
match xs with |
4239 |
| ("names",x)::xs -> |
4240 |
loop xs |
4241 |
(((function |
4242 |
| `List xs -> |
4243 |
map_bind (fun x -> vhdl_name_t_of_yojson x) [] xs |
4244 |
| _ -> Result.Error "Vhdl_ast.vhdl_port_t.names") x), |
4245 |
arg1, arg2, arg3) |
4246 |
| ("mode",x)::xs -> |
4247 |
loop xs |
4248 |
(arg0, ((fun x -> vhdl_port_mode_t_of_yojson x) x), arg2, |
4249 |
arg3) |
4250 |
| ("typ",x)::xs -> |
4251 |
loop xs |
4252 |
(arg0, arg1, |
4253 |
((fun x -> vhdl_subtype_indication_t_of_yojson x) x), |
4254 |
arg3) |
4255 |
| ("expr",x)::xs -> |
4256 |
loop xs |
4257 |
(arg0, arg1, arg2, ((fun x -> vhdl_expr_t_of_yojson x) x)) |
4258 |
| [] -> |
4259 |
arg3 >>= |
4260 |
((fun arg3 -> |
4261 |
arg2 >>= |
4262 |
(fun arg2 -> |
4263 |
arg1 >>= |
4264 |
(fun arg1 -> |
4265 |
arg0 >>= |
4266 |
(fun arg0 -> |
4267 |
Result.Ok |
4268 |
{ |
4269 |
names = arg0; |
4270 |
mode = arg1; |
4271 |
typ = arg2; |
4272 |
expr = arg3 |
4273 |
}))))) |
4274 |
| _::xs -> loop xs _state in |
4275 |
loop xs |
4276 |
((Result.Ok []), (Result.Ok InPort), |
4277 |
(Result.Error "Vhdl_ast.vhdl_port_t.typ"), (Result.Ok IsNull)) |
4278 |
| _ -> Result.Error "Vhdl_ast.vhdl_port_t") |
4279 |
[@ocaml.warning "-A"]) |
4280 |
type vhdl_declaration_t = |
4281 |
| VarDecl of |
4282 |
{ |
4283 |
names: vhdl_name_t list ; |
4284 |
typ: vhdl_subtype_indication_t ; |
4285 |
init_val: vhdl_expr_t [@default IsNull]} [@name "VARIABLE_DECLARATION"] |
4286 |
| CstDecl of |
4287 |
{ |
4288 |
names: vhdl_name_t list ; |
4289 |
typ: vhdl_subtype_indication_t ; |
4290 |
init_val: vhdl_expr_t } [@name "CONSTANT_DECLARATION"] |
4291 |
| SigDecl of |
4292 |
{ |
4293 |
names: vhdl_name_t list ; |
4294 |
typ: vhdl_subtype_indication_t ; |
4295 |
init_val: vhdl_expr_t [@default IsNull]} [@name "SIGNAL_DECLARATION"] |
4296 |
| ComponentDecl of |
4297 |
{ |
4298 |
name: vhdl_name_t [@default NoName]; |
4299 |
generics: vhdl_port_t list [@default []]; |
4300 |
ports: vhdl_port_t list [@default []]} [@name "COMPONENT_DECLARATION"] |
4301 |
| Subprogram of |
4302 |
{ |
4303 |
spec: vhdl_subprogram_spec_t ; |
4304 |
decl_part: vhdl_declaration_t list [@default []]; |
4305 |
stmts: vhdl_sequential_stmt_t list [@default []]} [@name "SUBPROGRAM_BODY"] |
4306 |
|
4307 |
let rec pp_vhdl_declaration_t : |
4308 |
Format.formatter -> vhdl_declaration_t -> Ppx_deriving_runtime.unit = |
4309 |
let __14 () = pp_vhdl_sequential_stmt_t |
4310 |
|
4311 |
and __13 () = pp_vhdl_declaration_t |
4312 |
|
4313 |
and __12 () = pp_vhdl_subprogram_spec_t |
4314 |
|
4315 |
and __11 () = pp_vhdl_port_t |
4316 |
|
4317 |
and __10 () = pp_vhdl_port_t |
4318 |
|
4319 |
and __9 () = pp_vhdl_name_t |
4320 |
|
4321 |
and __8 () = pp_vhdl_expr_t |
4322 |
|
4323 |
and __7 () = pp_vhdl_subtype_indication_t |
4324 |
|
4325 |
and __6 () = pp_vhdl_name_t |
4326 |
|
4327 |
and __5 () = pp_vhdl_expr_t |
4328 |
|
4329 |
and __4 () = pp_vhdl_subtype_indication_t |
4330 |
|
4331 |
and __3 () = pp_vhdl_name_t |
4332 |
|
4333 |
and __2 () = pp_vhdl_expr_t |
4334 |
|
4335 |
and __1 () = pp_vhdl_subtype_indication_t |
4336 |
|
4337 |
and __0 () = pp_vhdl_name_t |
4338 |
in |
4339 |
((let open! Ppx_deriving_runtime in |
4340 |
fun fmt -> |
4341 |
function |
4342 |
| VarDecl { names = anames; typ = atyp; init_val = ainit_val } -> |
4343 |
(Format.fprintf fmt "variable "; |
4344 |
((((fun x -> |
4345 |
ignore |
4346 |
(List.fold_left |
4347 |
(fun sep -> |
4348 |
fun x -> |
4349 |
if sep then Format.fprintf fmt ","; |
4350 |
((__0 ()) fmt) x; |
4351 |
true) false x);)) anames; |
4352 |
Format.fprintf fmt " : "; |
4353 |
((__1 ()) fmt) atyp; |
4354 |
(match ainit_val with |
4355 |
| IsNull -> Format.pp_print_string fmt "" |
4356 |
| _ -> |
4357 |
(Format.fprintf fmt ":="; |
4358 |
((__2 ()) fmt) ainit_val;))));) |
4359 |
| CstDecl { names = anames; typ = atyp; init_val = ainit_val } -> |
4360 |
(Format.fprintf fmt "constant "; |
4361 |
((((fun x -> |
4362 |
ignore |
4363 |
(List.fold_left |
4364 |
(fun sep -> |
4365 |
fun x -> |
4366 |
if sep then Format.fprintf fmt ","; |
4367 |
((__3 ()) fmt) x; |
4368 |
true) false x);)) anames; |
4369 |
Format.fprintf fmt " : "; |
4370 |
((__4 ()) fmt) atyp; |
4371 |
Format.fprintf fmt " := "; |
4372 |
((__5 ()) fmt) ainit_val))) |
4373 |
| SigDecl { names = anames; typ = atyp; init_val = ainit_val } -> |
4374 |
(Format.fprintf fmt "signal "; |
4375 |
((fun x -> |
4376 |
ignore |
4377 |
(List.fold_left |
4378 |
(fun sep -> |
4379 |
fun x -> |
4380 |
if sep then Format.fprintf fmt ","; |
4381 |
((__6 ()) fmt) x; |
4382 |
true) false x); |
4383 |
)) anames; |
4384 |
Format.fprintf fmt " : "; |
4385 |
((__7 ()) fmt) atyp; |
4386 |
(match ainit_val with |
4387 |
| IsNull -> Format.pp_print_string fmt "" |
4388 |
| _ -> |
4389 |
(Format.fprintf fmt ":="; |
4390 |
((__8 ()) fmt) ainit_val;))) |
4391 |
| ComponentDecl |
4392 |
{ name = aname; generics = agenerics; ports = aports } -> |
4393 |
Format.fprintf fmt "@[<v 2>component "; |
4394 |
((__9 ()) fmt) aname; |
4395 |
Format.fprintf fmt " is@;"; |
4396 |
((fun x -> |
4397 |
ignore |
4398 |
(List.fold_left |
4399 |
(fun sep -> |
4400 |
fun x -> |
4401 |
if sep then Format.fprintf fmt "@;"; |
4402 |
((__10 ()) fmt) x; |
4403 |
true) false x))) agenerics; |
4404 |
((fun x -> |
4405 |
ignore |
4406 |
(List.fold_left |
4407 |
(fun sep -> |
4408 |
fun x -> |
4409 |
if sep then Format.fprintf fmt "@;"; |
4410 |
((__11 ()) fmt) x; |
4411 |
true) false x))) aports; |
4412 |
Format.fprintf fmt "@]@;end component"; |
4413 |
| Subprogram |
4414 |
{ spec = aspec; decl_part = adecl_part; stmts = astmts } |
4415 |
-> |
4416 |
Format.fprintf fmt "@[<v 2>"; |
4417 |
((__12 ()) fmt) aspec; |
4418 |
Format.fprintf fmt " is"; |
4419 |
(match adecl_part with |
4420 |
| [] -> Format.fprintf fmt ""; |
4421 |
| _ -> |
4422 |
((fun x -> |
4423 |
ignore |
4424 |
(List.fold_left |
4425 |
(fun sep -> |
4426 |
fun x -> |
4427 |
if sep then Format.fprintf fmt ""; |
4428 |
Format.fprintf fmt "@;"; |
4429 |
((__13 ()) fmt) x; |
4430 |
Format.fprintf fmt ";"; |
4431 |
true) false x))) adecl_part); |
4432 |
Format.fprintf fmt "@]@;"; |
4433 |
Format.fprintf fmt "@[<v 2>begin@;"; |
4434 |
((fun x -> |
4435 |
ignore |
4436 |
(List.fold_left |
4437 |
(fun sep -> |
4438 |
fun x -> |
4439 |
if sep then Format.fprintf fmt "@;"; |
4440 |
((__14 ()) fmt) x; |
4441 |
Format.fprintf fmt ";"; |
4442 |
true) false x))) astmts; |
4443 |
Format.fprintf fmt "@]@;end";) |
4444 |
[@ocaml.warning "-A"]) |
4445 |
|
4446 |
and show_vhdl_declaration_t : |
4447 |
vhdl_declaration_t -> Ppx_deriving_runtime.string = |
4448 |
fun x -> Format.asprintf "%a" pp_vhdl_declaration_t x |
4449 |
|
4450 |
let rec (vhdl_declaration_t_to_yojson : |
4451 |
vhdl_declaration_t -> Yojson.Safe.json) |
4452 |
= |
4453 |
((let open! Ppx_deriving_yojson_runtime in |
4454 |
function |
4455 |
| VarDecl arg0 -> |
4456 |
`List |
4457 |
[`String "VARIABLE_DECLARATION"; |
4458 |
(let fields = [] in |
4459 |
let fields = |
4460 |
if arg0.init_val = IsNull |
4461 |
then fields |
4462 |
else |
4463 |
("init_val", |
4464 |
(((fun x -> vhdl_expr_t_to_yojson x)) arg0.init_val)) |
4465 |
:: fields |
4466 |
in |
4467 |
let fields = |
4468 |
("typ", |
4469 |
((fun x -> vhdl_subtype_indication_t_to_yojson x) arg0.typ)) |
4470 |
:: fields in |
4471 |
let fields = |
4472 |
("names", |
4473 |
((fun x -> |
4474 |
`List (List.map (fun x -> vhdl_name_t_to_yojson x) x)) |
4475 |
arg0.names)) |
4476 |
:: fields in |
4477 |
`Assoc fields)] |
4478 |
| CstDecl arg0 -> |
4479 |
`List |
4480 |
[`String "CONSTANT_DECLARATION"; |
4481 |
(let fields = [] in |
4482 |
let fields = |
4483 |
("init_val", |
4484 |
((fun x -> vhdl_expr_t_to_yojson x) arg0.init_val)) |
4485 |
:: fields in |
4486 |
let fields = |
4487 |
("typ", |
4488 |
((fun x -> vhdl_subtype_indication_t_to_yojson x) arg0.typ)) |
4489 |
:: fields in |
4490 |
let fields = |
4491 |
("names", |
4492 |
((fun x -> |
4493 |
`List (List.map (fun x -> vhdl_name_t_to_yojson x) x)) |
4494 |
arg0.names)) |
4495 |
:: fields in |
4496 |
`Assoc fields)] |
4497 |
| SigDecl arg0 -> |
4498 |
`List |
4499 |
[`String "SIGNAL_DECLARATION"; |
4500 |
(let fields = [] in |
4501 |
let fields = |
4502 |
if arg0.init_val = IsNull |
4503 |
then fields |
4504 |
else |
4505 |
("init_val", |
4506 |
(((fun x -> vhdl_expr_t_to_yojson x)) arg0.init_val)) |
4507 |
:: fields |
4508 |
in |
4509 |
let fields = |
4510 |
("typ", |
4511 |
((fun x -> vhdl_subtype_indication_t_to_yojson x) arg0.typ)) |
4512 |
:: fields in |
4513 |
let fields = |
4514 |
("names", |
4515 |
((fun x -> |
4516 |
`List (List.map (fun x -> vhdl_name_t_to_yojson x) x)) |
4517 |
arg0.names)) |
4518 |
:: fields in |
4519 |
`Assoc fields)] |
4520 |
| ComponentDecl arg0 -> |
4521 |
`List |
4522 |
[`String "COMPONENT_DECLARATION"; |
4523 |
(let fields = [] in |
4524 |
let fields = |
4525 |
if arg0.ports = [] |
4526 |
then fields |
4527 |
else |
4528 |
("ports", |
4529 |
(((fun x -> |
4530 |
`List |
4531 |
(List.map (fun x -> vhdl_port_t_to_yojson x) x))) |
4532 |
arg0.ports)) |
4533 |
:: fields |
4534 |
in |
4535 |
let fields = |
4536 |
if arg0.generics = [] |
4537 |
then fields |
4538 |
else |
4539 |
("generics", |
4540 |
(((fun x -> |
4541 |
`List |
4542 |
(List.map (fun x -> vhdl_port_t_to_yojson x) x))) |
4543 |
arg0.generics)) |
4544 |
:: fields |
4545 |
in |
4546 |
let fields = |
4547 |
if arg0.name = NoName |
4548 |
then fields |
4549 |
else |
4550 |
("name", (((fun x -> vhdl_name_t_to_yojson x)) arg0.name)) |
4551 |
:: fields |
4552 |
in |
4553 |
`Assoc fields)] |
4554 |
| Subprogram arg0 -> |
4555 |
`List |
4556 |
[`String "SUBPROGRAM_BODY"; |
4557 |
(let fields = [] in |
4558 |
let fields = |
4559 |
if arg0.stmts = [] |
4560 |
then fields |
4561 |
else |
4562 |
("stmts", |
4563 |
(((fun x -> |
4564 |
`List |
4565 |
(List.map |
4566 |
(fun x -> vhdl_sequential_stmt_t_to_yojson x) x))) |
4567 |
arg0.stmts)) |
4568 |
:: fields |
4569 |
in |
4570 |
let fields = |
4571 |
if arg0.decl_part = [] |
4572 |
then fields |
4573 |
else |
4574 |
("decl_part", |
4575 |
(((fun x -> |
4576 |
`List |
4577 |
(List.map |
4578 |
(fun x -> vhdl_declaration_t_to_yojson x) x))) |
4579 |
arg0.decl_part)) |
4580 |
:: fields |
4581 |
in |
4582 |
let fields = |
4583 |
("spec", |
4584 |
((fun x -> vhdl_subprogram_spec_t_to_yojson x) arg0.spec)) |
4585 |
:: fields in |
4586 |
`Assoc fields)]) |
4587 |
[@ocaml.warning "-A"]) |
4588 |
|
4589 |
and (vhdl_declaration_t_of_yojson : |
4590 |
Yojson.Safe.json -> |
4591 |
vhdl_declaration_t Ppx_deriving_yojson_runtime.error_or) |
4592 |
= |
4593 |
((let open! Ppx_deriving_yojson_runtime in |
4594 |
function |
4595 |
| `List ((`String "VARIABLE_DECLARATION")::arg0::[]) -> |
4596 |
((function |
4597 |
| `Assoc xs -> |
4598 |
let rec loop xs ((arg0,arg1,arg2) as _state) = |
4599 |
match xs with |
4600 |
| ("names",x)::xs -> |
4601 |
loop xs |
4602 |
(((function |
4603 |
| `List xs -> |
4604 |
map_bind (fun x -> vhdl_name_t_of_yojson x) |
4605 |
[] xs |
4606 |
| _ -> |
4607 |
Result.Error |
4608 |
"Vhdl_ast.vhdl_declaration_t.names") x), |
4609 |
arg1, arg2) |
4610 |
| ("typ",x)::xs -> |
4611 |
loop xs |
4612 |
(arg0, |
4613 |
((fun x -> vhdl_subtype_indication_t_of_yojson x) |
4614 |
x), arg2) |
4615 |
| ("init_val",x)::xs -> |
4616 |
loop xs |
4617 |
(arg0, arg1, ((fun x -> vhdl_expr_t_of_yojson x) x)) |
4618 |
| [] -> |
4619 |
arg2 >>= |
4620 |
((fun arg2 -> |
4621 |
arg1 >>= |
4622 |
(fun arg1 -> |
4623 |
arg0 >>= |
4624 |
(fun arg0 -> |
4625 |
Result.Ok |
4626 |
(VarDecl |
4627 |
{ |
4628 |
names = arg0; |
4629 |
typ = arg1; |
4630 |
init_val = arg2 |
4631 |
}))))) |
4632 |
| _::xs -> loop xs _state in |
4633 |
loop xs |
4634 |
((Result.Error "Vhdl_ast.vhdl_declaration_t.names"), |
4635 |
(Result.Error "Vhdl_ast.vhdl_declaration_t.typ"), |
4636 |
(Result.Ok IsNull)) |
4637 |
| _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0 |
4638 |
| `List ((`String "CONSTANT_DECLARATION")::arg0::[]) -> |
4639 |
((function |
4640 |
| `Assoc xs -> |
4641 |
let rec loop xs ((arg0,arg1,arg2) as _state) = |
4642 |
match xs with |
4643 |
| ("names",x)::xs -> |
4644 |
loop xs |
4645 |
(((function |
4646 |
| `List xs -> |
4647 |
map_bind (fun x -> vhdl_name_t_of_yojson x) |
4648 |
[] xs |
4649 |
| _ -> |
4650 |
Result.Error |
4651 |
"Vhdl_ast.vhdl_declaration_t.names") x), |
4652 |
arg1, arg2) |
4653 |
| ("typ",x)::xs -> |
4654 |
loop xs |
4655 |
(arg0, |
4656 |
((fun x -> vhdl_subtype_indication_t_of_yojson x) |
4657 |
x), arg2) |
4658 |
| ("init_val",x)::xs -> |
4659 |
loop xs |
4660 |
(arg0, arg1, ((fun x -> vhdl_expr_t_of_yojson x) x)) |
4661 |
| [] -> |
4662 |
arg2 >>= |
4663 |
((fun arg2 -> |
4664 |
arg1 >>= |
4665 |
(fun arg1 -> |
4666 |
arg0 >>= |
4667 |
(fun arg0 -> |
4668 |
Result.Ok |
4669 |
(CstDecl |
4670 |
{ |
4671 |
names = arg0; |
4672 |
typ = arg1; |
4673 |
init_val = arg2 |
4674 |
}))))) |
4675 |
| _::xs -> loop xs _state in |
4676 |
loop xs |
4677 |
((Result.Error "Vhdl_ast.vhdl_declaration_t.names"), |
4678 |
(Result.Error "Vhdl_ast.vhdl_declaration_t.typ"), |
4679 |
(Result.Error "Vhdl_ast.vhdl_declaration_t.init_val")) |
4680 |
| _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0 |
4681 |
| `List ((`String "SIGNAL_DECLARATION")::arg0::[]) -> |
4682 |
((function |
4683 |
| `Assoc xs -> |
4684 |
let rec loop xs ((arg0,arg1,arg2) as _state) = |
4685 |
match xs with |
4686 |
| ("names",x)::xs -> |
4687 |
loop xs |
4688 |
(((function |
4689 |
| `List xs -> |
4690 |
map_bind (fun x -> vhdl_name_t_of_yojson x) |
4691 |
[] xs |
4692 |
| _ -> |
4693 |
Result.Error |
4694 |
"Vhdl_ast.vhdl_declaration_t.names") x), |
4695 |
arg1, arg2) |
4696 |
| ("typ",x)::xs -> |
4697 |
loop xs |
4698 |
(arg0, |
4699 |
((fun x -> vhdl_subtype_indication_t_of_yojson x) |
4700 |
x), arg2) |
4701 |
| ("init_val",x)::xs -> |
4702 |
loop xs |
4703 |
(arg0, arg1, ((fun x -> vhdl_expr_t_of_yojson x) x)) |
4704 |
| [] -> |
4705 |
arg2 >>= |
4706 |
((fun arg2 -> |
4707 |
arg1 >>= |
4708 |
(fun arg1 -> |
4709 |
arg0 >>= |
4710 |
(fun arg0 -> |
4711 |
Result.Ok |
4712 |
(SigDecl |
4713 |
{ |
4714 |
names = arg0; |
4715 |
typ = arg1; |
4716 |
init_val = arg2 |
4717 |
}))))) |
4718 |
| _::xs -> loop xs _state in |
4719 |
loop xs |
4720 |
((Result.Error "Vhdl_ast.vhdl_declaration_t.names"), |
4721 |
(Result.Error "Vhdl_ast.vhdl_declaration_t.typ"), |
4722 |
(Result.Ok IsNull)) |
4723 |
| _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0 |
4724 |
| `List ((`String "COMPONENT_DECLARATION")::arg0::[]) -> |
4725 |
((function |
4726 |
| `Assoc xs -> |
4727 |
let rec loop xs ((arg0,arg1,arg2) as _state) = |
4728 |
match xs with |
4729 |
| ("name",x)::xs -> |
4730 |
loop xs |
4731 |
(((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2) |
4732 |
| ("generics",x)::xs -> |
4733 |
loop xs |
4734 |
(arg0, |
4735 |
((function |
4736 |
| `List xs -> |
4737 |
map_bind (fun x -> vhdl_port_t_of_yojson x) |
4738 |
[] xs |
4739 |
| _ -> |
4740 |
Result.Error |
4741 |
"Vhdl_ast.vhdl_declaration_t.generics") x), |
4742 |
arg2) |
4743 |
| ("ports",x)::xs -> |
4744 |
loop xs |
4745 |
(arg0, arg1, |
4746 |
((function |
4747 |
| `List xs -> |
4748 |
map_bind (fun x -> vhdl_port_t_of_yojson x) |
4749 |
[] xs |
4750 |
| _ -> |
4751 |
Result.Error |
4752 |
"Vhdl_ast.vhdl_declaration_t.ports") x)) |
4753 |
| [] -> |
4754 |
arg2 >>= |
4755 |
((fun arg2 -> |
4756 |
arg1 >>= |
4757 |
(fun arg1 -> |
4758 |
arg0 >>= |
4759 |
(fun arg0 -> |
4760 |
Result.Ok |
4761 |
(ComponentDecl |
4762 |
{ |
4763 |
name = arg0; |
4764 |
generics = arg1; |
4765 |
ports = arg2 |
4766 |
}))))) |
4767 |
| _::xs -> loop xs _state in |
4768 |
loop xs ((Result.Ok NoName), (Result.Ok []), (Result.Ok [])) |
4769 |
| _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0 |
4770 |
| `List ((`String "SUBPROGRAM_BODY")::arg0::[]) -> |
4771 |
((function |
4772 |
| `Assoc xs -> |
4773 |
let rec loop xs ((arg0,arg1,arg2) as _state) = |
4774 |
match xs with |
4775 |
| ("spec",x)::xs -> |
4776 |
loop xs |
4777 |
(((fun x -> vhdl_subprogram_spec_t_of_yojson x) x), |
4778 |
arg1, arg2) |
4779 |
| ("decl_part",x)::xs -> |
4780 |
loop xs |
4781 |
(arg0, |
4782 |
((function |
4783 |
| `List xs -> |
4784 |
map_bind |
4785 |
(fun x -> vhdl_declaration_t_of_yojson x) |
4786 |
[] xs |
4787 |
| _ -> |
4788 |
Result.Error |
4789 |
"Vhdl_ast.vhdl_declaration_t.decl_part") x), |
4790 |
arg2) |
4791 |
| ("stmts",x)::xs -> |
4792 |
loop xs |
4793 |
(arg0, arg1, |
4794 |
((function |
4795 |
| `List xs -> |
4796 |
map_bind |
4797 |
(fun x -> |
4798 |
vhdl_sequential_stmt_t_of_yojson x) [] |
4799 |
xs |
4800 |
| _ -> |
4801 |
Result.Error |
4802 |
"Vhdl_ast.vhdl_declaration_t.stmts") x)) |
4803 |
| [] -> |
4804 |
arg2 >>= |
4805 |
((fun arg2 -> |
4806 |
arg1 >>= |
4807 |
(fun arg1 -> |
4808 |
arg0 >>= |
4809 |
(fun arg0 -> |
4810 |
Result.Ok |
4811 |
(Subprogram |
4812 |
{ |
4813 |
spec = arg0; |
4814 |
decl_part = arg1; |
4815 |
stmts = arg2 |
4816 |
}))))) |
4817 |
| _::xs -> loop xs _state in |
4818 |
loop xs |
4819 |
((Result.Error "Vhdl_ast.vhdl_declaration_t.spec"), |
4820 |
(Result.Ok []), (Result.Ok [])) |
4821 |
| _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0 |
4822 |
| _ -> Result.Error "Vhdl_ast.vhdl_declaration_t") |
4823 |
[@ocaml.warning "-A"]) |
4824 |
|
4825 |
type vhdl_load_t = |
4826 |
| Library of vhdl_name_t list [@name "LIBRARY_CLAUSE"][@default []] |
4827 |
| Use of vhdl_name_t list [@name "USE_CLAUSE"][@default []] |
4828 |
|
4829 |
(* Adapted. TODO: check indentation *) |
4830 |
let rec pp_vhdl_load_t : |
4831 |
Format.formatter -> vhdl_load_t -> Ppx_deriving_runtime.unit = |
4832 |
let __1 () = pp_vhdl_name_t |
4833 |
|
4834 |
and __0 () = pp_vhdl_name_t |
4835 |
in |
4836 |
((let open! Ppx_deriving_runtime in |
4837 |
fun fmt -> |
4838 |
function |
4839 |
| Library a0 -> |
4840 |
(Format.fprintf fmt "library "; |
4841 |
((fun x -> |
4842 |
ignore |
4843 |
(List.fold_left |
4844 |
(fun sep -> |
4845 |
fun x -> |
4846 |
if sep then Format.fprintf fmt "."; |
4847 |
((__0 ()) fmt) x; |
4848 |
true) false x))) a0); |
4849 |
| Use a0 -> |
4850 |
(Format.fprintf fmt "use "; |
4851 |
((fun x -> |
4852 |
ignore |
4853 |
(List.fold_left |
4854 |
(fun sep -> |
4855 |
fun x -> |
4856 |
if sep then Format.fprintf fmt "."; |
4857 |
((__1 ()) fmt) x; |
4858 |
true) false x))) a0)) |
4859 |
[@ocaml.warning "-A"]) |
4860 |
|
4861 |
and show_vhdl_load_t : vhdl_load_t -> Ppx_deriving_runtime.string = |
4862 |
fun x -> Format.asprintf "%a" pp_vhdl_load_t x |
4863 |
|
4864 |
let rec (vhdl_load_t_to_yojson : vhdl_load_t -> Yojson.Safe.json) = |
4865 |
((let open! Ppx_deriving_yojson_runtime in |
4866 |
function |
4867 |
| Library arg0 -> |
4868 |
`List |
4869 |
[`String "LIBRARY_CLAUSE"; |
4870 |
((fun x -> |
4871 |
`List (List.map (fun x -> vhdl_name_t_to_yojson x) x))) arg0] |
4872 |
| Use arg0 -> |
4873 |
`List |
4874 |
[`String "USE_CLAUSE"; |
4875 |
((fun x -> |
4876 |
`List (List.map (fun x -> vhdl_name_t_to_yojson x) x))) arg0]) |
4877 |
[@ocaml.warning "-A"]) |
4878 |
|
4879 |
and (vhdl_load_t_of_yojson : |
4880 |
Yojson.Safe.json -> vhdl_load_t Ppx_deriving_yojson_runtime.error_or) |
4881 |
= |
4882 |
((let open! Ppx_deriving_yojson_runtime in |
4883 |
function |
4884 |
| `List ((`String "LIBRARY_CLAUSE")::arg0::[]) -> |
4885 |
((function |
4886 |
| `List xs -> map_bind (fun x -> vhdl_name_t_of_yojson x) [] xs |
4887 |
| _ -> Result.Error "Vhdl_ast.vhdl_load_t") arg0) >>= |
4888 |
((fun arg0 -> Result.Ok (Library arg0))) |
4889 |
| `List ((`String "USE_CLAUSE")::arg0::[]) -> |
4890 |
((function |
4891 |
| `List xs -> map_bind (fun x -> vhdl_name_t_of_yojson x) [] xs |
4892 |
| _ -> Result.Error "Vhdl_ast.vhdl_load_t") arg0) >>= |
4893 |
((fun arg0 -> Result.Ok (Use arg0))) |
4894 |
| _ -> Result.Error "Vhdl_ast.vhdl_load_t") |
4895 |
[@ocaml.warning "-A"]) |
4896 |
|
4897 |
type vhdl_declarative_item_t = |
4898 |
{ |
4899 |
use_clause: vhdl_load_t option [@default None]; |
4900 |
declaration: vhdl_declaration_t option [@default None]; |
4901 |
definition: vhdl_definition_t option [@default None]}[@@deriving |
4902 |
((show |
4903 |
{ |
4904 |
with_path = |
4905 |
false |
4906 |
}), |
4907 |
(yojson |
4908 |
{ |
4909 |
strict = |
4910 |
false |
4911 |
}))] |
4912 |
let rec pp_vhdl_declarative_item_t : |
4913 |
Format.formatter -> vhdl_declarative_item_t -> Ppx_deriving_runtime.unit = |
4914 |
let __2 () = pp_vhdl_definition_t |
4915 |
|
4916 |
and __1 () = pp_vhdl_declaration_t |
4917 |
|
4918 |
and __0 () = pp_vhdl_load_t |
4919 |
in |
4920 |
((let open! Ppx_deriving_runtime in |
4921 |
fun fmt -> |
4922 |
fun x -> |
4923 |
(match x.use_clause with |
4924 |
| None -> Format.fprintf fmt ""; |
4925 |
| Some e -> ((__0 ()) fmt) e); |
4926 |
(match x.declaration with |
4927 |
| None -> Format.fprintf fmt ""; |
4928 |
| Some e -> ((__1 ()) fmt) e); |
4929 |
(match x.definition with |
4930 |
| None -> Format.fprintf fmt ""; |
4931 |
| Some e -> ((__2 ()) fmt) e);) |
4932 |
[@ocaml.warning "-A"]) |
4933 |
|
4934 |
and show_vhdl_declarative_item_t : |
4935 |
vhdl_declarative_item_t -> Ppx_deriving_runtime.string = |
4936 |
fun x -> Format.asprintf "%a" pp_vhdl_declarative_item_t x |
4937 |
|
4938 |
let rec (vhdl_declarative_item_t_to_yojson : |
4939 |
vhdl_declarative_item_t -> Yojson.Safe.json) |
4940 |
= |
4941 |
((let open! Ppx_deriving_yojson_runtime in |
4942 |
fun x -> |
4943 |
let fields = [] in |
4944 |
let fields = |
4945 |
if x.definition = None |
4946 |
then fields |
4947 |
else |
4948 |
("definition", |
4949 |
(((function |
4950 |
| None -> `Null |
4951 |
| Some x -> ((fun x -> vhdl_definition_t_to_yojson x)) x)) |
4952 |
x.definition)) |
4953 |
:: fields |
4954 |
in |
4955 |
let fields = |
4956 |
if x.declaration = None |
4957 |
then fields |
4958 |
else |
4959 |
("declaration", |
4960 |
(((function |
4961 |
| None -> `Null |
4962 |
| Some x -> ((fun x -> vhdl_declaration_t_to_yojson x)) x)) |
4963 |
x.declaration)) |
4964 |
:: fields |
4965 |
in |
4966 |
let fields = |
4967 |
if x.use_clause = None |
4968 |
then fields |
4969 |
else |
4970 |
("use_clause", |
4971 |
(((function |
4972 |
| None -> `Null |
4973 |
| Some x -> ((fun x -> vhdl_load_t_to_yojson x)) x)) |
4974 |
x.use_clause)) |
4975 |
:: fields |
4976 |
in |
4977 |
`Assoc fields) |
4978 |
[@ocaml.warning "-A"]) |
4979 |
|
4980 |
and (vhdl_declarative_item_t_of_yojson : |
4981 |
Yojson.Safe.json -> |
4982 |
vhdl_declarative_item_t Ppx_deriving_yojson_runtime.error_or) |
4983 |
= |
4984 |
((let open! Ppx_deriving_yojson_runtime in |
4985 |
function |
4986 |
| `Assoc xs -> |
4987 |
let rec loop xs ((arg0,arg1,arg2) as _state) = |
4988 |
match xs with |
4989 |
| ("use_clause",x)::xs -> |
4990 |
loop xs |
4991 |
(((function |
4992 |
| `Null -> Result.Ok None |
4993 |
| x -> |
4994 |
((fun x -> vhdl_load_t_of_yojson x) x) >>= |
4995 |
((fun x -> Result.Ok (Some x)))) x), arg1, arg2) |
4996 |
| ("declaration",x)::xs -> |
4997 |
loop xs |
4998 |
(arg0, |
4999 |
((function |
5000 |
| `Null -> Result.Ok None |
5001 |
| x -> |
5002 |
((fun x -> vhdl_declaration_t_of_yojson x) x) >>= |
5003 |
((fun x -> Result.Ok (Some x)))) x), arg2) |
5004 |
| ("definition",x)::xs -> |
5005 |
loop xs |
5006 |
(arg0, arg1, |
5007 |
((function |
5008 |
| `Null -> Result.Ok None |
5009 |
| x -> |
5010 |
((fun x -> vhdl_definition_t_of_yojson x) x) >>= |
5011 |
((fun x -> Result.Ok (Some x)))) x)) |
5012 |
| [] -> |
5013 |
arg2 >>= |
5014 |
((fun arg2 -> |
5015 |
arg1 >>= |
5016 |
(fun arg1 -> |
5017 |
arg0 >>= |
5018 |
(fun arg0 -> |
5019 |
Result.Ok |
5020 |
{ |
5021 |
use_clause = arg0; |
5022 |
declaration = arg1; |
5023 |
definition = arg2 |
5024 |
})))) |
5025 |
| _::xs -> loop xs _state in |
5026 |
loop xs ((Result.Ok None), (Result.Ok None), (Result.Ok None)) |
5027 |
| _ -> Result.Error "Vhdl_ast.vhdl_declarative_item_t") |
5028 |
[@ocaml.warning "-A"]) |
5029 |
|
5030 |
type vhdl_signal_condition_t = |
5031 |
{ |
5032 |
expr: vhdl_waveform_element_t list [@default []]; |
5033 |
cond: vhdl_expr_t option [@default None]}[@@deriving |
5034 |
((show { with_path = false }), |
5035 |
(yojson { strict = false }))] |
5036 |
let rec pp_vhdl_signal_condition_t : |
5037 |
Format.formatter -> vhdl_signal_condition_t -> Ppx_deriving_runtime.unit = |
5038 |
let __1 () = pp_vhdl_expr_t |
5039 |
|
5040 |
and __0 () = pp_vhdl_waveform_element_t |
5041 |
in |
5042 |
((let open! Ppx_deriving_runtime in |
5043 |
fun fmt -> |
5044 |
fun x -> |
5045 |
((fun x -> |
5046 |
ignore |
5047 |
(List.fold_left |
5048 |
(fun sep -> |
5049 |
fun x -> |
5050 |
if sep then Format.fprintf fmt " else "; |
5051 |
((__0 ()) fmt) x; |
5052 |
true) false x))) x.expr; |
5053 |
(match x.cond with |
5054 |
| None -> Format.fprintf fmt ""; |
5055 |
| Some e -> Format.fprintf fmt " when "; |
5056 |
((__1 ()) fmt) e);) |
5057 |
[@ocaml.warning "-A"]) |
5058 |
|
5059 |
and show_vhdl_signal_condition_t : |
5060 |
vhdl_signal_condition_t -> Ppx_deriving_runtime.string = |
5061 |
fun x -> Format.asprintf "%a" pp_vhdl_signal_condition_t x |
5062 |
|
5063 |
let rec (vhdl_signal_condition_t_to_yojson : |
5064 |
vhdl_signal_condition_t -> Yojson.Safe.json) |
5065 |
= |
5066 |
((let open! Ppx_deriving_yojson_runtime in |
5067 |
fun x -> |
5068 |
let fields = [] in |
5069 |
let fields = |
5070 |
if x.cond = None |
5071 |
then fields |
5072 |
else |
5073 |
("cond", |
5074 |
(((function |
5075 |
| None -> `Null |
5076 |
| Some x -> ((fun x -> vhdl_expr_t_to_yojson x)) x)) |
5077 |
x.cond)) |
5078 |
:: fields |
5079 |
in |
5080 |
let fields = |
5081 |
if x.expr = [] |
5082 |
then fields |
5083 |
else |
5084 |
("expr", |
5085 |
(((fun x -> |
5086 |
`List |
5087 |
(List.map |
5088 |
(fun x -> vhdl_waveform_element_t_to_yojson x) x))) |
5089 |
x.expr)) |
5090 |
:: fields |
5091 |
in |
5092 |
`Assoc fields) |
5093 |
[@ocaml.warning "-A"]) |
5094 |
|
5095 |
and (vhdl_signal_condition_t_of_yojson : |
5096 |
Yojson.Safe.json -> |
5097 |
vhdl_signal_condition_t Ppx_deriving_yojson_runtime.error_or) |
5098 |
= |
5099 |
((let open! Ppx_deriving_yojson_runtime in |
5100 |
function |
5101 |
| `Assoc xs -> |
5102 |
let rec loop xs ((arg0,arg1) as _state) = |
5103 |
match xs with |
5104 |
| ("expr",x)::xs -> |
5105 |
loop xs |
5106 |
(((function |
5107 |
| `List xs -> |
5108 |
map_bind |
5109 |
(fun x -> vhdl_waveform_element_t_of_yojson x) [] |
5110 |
xs |
5111 |
| _ -> |
5112 |
Result.Error "Vhdl_ast.vhdl_signal_condition_t.expr") |
5113 |
x), arg1) |
5114 |
| ("cond",x)::xs -> |
5115 |
loop xs |
5116 |
(arg0, |
5117 |
((function |
5118 |
| `Null -> Result.Ok None |
5119 |
| x -> |
5120 |
((fun x -> vhdl_expr_t_of_yojson x) x) >>= |
5121 |
((fun x -> Result.Ok (Some x)))) x)) |
5122 |
| [] -> |
5123 |
arg1 >>= |
5124 |
((fun arg1 -> |
5125 |
arg0 >>= |
5126 |
(fun arg0 -> Result.Ok { expr = arg0; cond = arg1 }))) |
5127 |
| _::xs -> loop xs _state in |
5128 |
loop xs ((Result.Ok []), (Result.Ok None)) |
5129 |
| _ -> Result.Error "Vhdl_ast.vhdl_signal_condition_t") |
5130 |
[@ocaml.warning "-A"]) |
5131 |
|
5132 |
type vhdl_signal_selection_t = |
5133 |
{ |
5134 |
expr: vhdl_waveform_element_t list [@default []]; |
5135 |
when_sel: vhdl_expr_t list [@default []]}[@@deriving |
5136 |
((show { with_path = false }), |
5137 |
(yojson { strict = false }))] |
5138 |
|
5139 |
let rec pp_vhdl_signal_selection_t : |
5140 |
Format.formatter -> vhdl_signal_selection_t -> Ppx_deriving_runtime.unit = |
5141 |
let __1 () = pp_vhdl_expr_t |
5142 |
|
5143 |
and __0 () = pp_vhdl_waveform_element_t |
5144 |
in |
5145 |
((let open! Ppx_deriving_runtime in |
5146 |
fun fmt -> |
5147 |
fun x -> |
5148 |
((fun x -> |
5149 |
ignore |
5150 |
(List.fold_left |
5151 |
(fun sep -> |
5152 |
fun x -> |
5153 |
if sep then Format.fprintf fmt "@ "; |
5154 |
((__0 ()) fmt) x; |
5155 |
true) false x))) x.expr; |
5156 |
Format.fprintf fmt " when "; |
5157 |
((fun x -> |
5158 |
ignore |
5159 |
(List.fold_left |
5160 |
(fun sep -> |
5161 |
fun x -> |
5162 |
if sep then Format.fprintf fmt "|@ "; |
5163 |
((__1 ()) fmt) x; |
5164 |
true) false x))) x.when_sel) |
5165 |
[@ocaml.warning "-A"]) |
5166 |
|
5167 |
and show_vhdl_signal_selection_t : |
5168 |
vhdl_signal_selection_t -> Ppx_deriving_runtime.string = |
5169 |
fun x -> Format.asprintf "%a" pp_vhdl_signal_selection_t x |
5170 |
|
5171 |
let rec (vhdl_signal_selection_t_to_yojson : |
5172 |
vhdl_signal_selection_t -> Yojson.Safe.json) |
5173 |
= |
5174 |
((let open! Ppx_deriving_yojson_runtime in |
5175 |
fun x -> |
5176 |
let fields = [] in |
5177 |
let fields = |
5178 |
if x.when_sel = [] |
5179 |
then fields |
5180 |
else |
5181 |
("when_sel", |
5182 |
(((fun x -> |
5183 |
`List (List.map (fun x -> vhdl_expr_t_to_yojson x) x))) |
5184 |
x.when_sel)) |
5185 |
:: fields |
5186 |
in |
5187 |
let fields = |
5188 |
if x.expr = [] |
5189 |
then fields |
5190 |
else |
5191 |
("expr", |
5192 |
(((fun x -> |
5193 |
`List |
5194 |
(List.map |
5195 |
(fun x -> vhdl_waveform_element_t_to_yojson x) x))) |
5196 |
x.expr)) |
5197 |
:: fields |
5198 |
in |
5199 |
`Assoc fields) |
5200 |
[@ocaml.warning "-A"]) |
5201 |
|
5202 |
and (vhdl_signal_selection_t_of_yojson : |
5203 |
Yojson.Safe.json -> |
5204 |
vhdl_signal_selection_t Ppx_deriving_yojson_runtime.error_or) |
5205 |
= |
5206 |
((let open! Ppx_deriving_yojson_runtime in |
5207 |
function |
5208 |
| `Assoc xs -> |
5209 |
let rec loop xs ((arg0,arg1) as _state) = |
5210 |
match xs with |
5211 |
| ("expr",x)::xs -> |
5212 |
loop xs |
5213 |
(((function |
5214 |
| `List xs -> |
5215 |
map_bind |
5216 |
(fun x -> vhdl_waveform_element_t_of_yojson x) [] |
5217 |
xs |
5218 |
| _ -> |
5219 |
Result.Error "Vhdl_ast.vhdl_signal_selection_t.expr") |
5220 |
x), arg1) |
5221 |
| ("when_sel",x)::xs -> |
5222 |
loop xs |
5223 |
(arg0, |
5224 |
((function |
5225 |
| `List xs -> |
5226 |
map_bind (fun x -> vhdl_expr_t_of_yojson x) [] xs |
5227 |
| _ -> |
5228 |
Result.Error |
5229 |
"Vhdl_ast.vhdl_signal_selection_t.when_sel") x)) |
5230 |
| [] -> |
5231 |
arg1 >>= |
5232 |
((fun arg1 -> |
5233 |
arg0 >>= |
5234 |
(fun arg0 -> |
5235 |
Result.Ok { expr = arg0; when_sel = arg1 }))) |
5236 |
| _::xs -> loop xs _state in |
5237 |
loop xs ((Result.Ok []), (Result.Ok [])) |
5238 |
| _ -> Result.Error "Vhdl_ast.vhdl_signal_selection_t") |
5239 |
[@ocaml.warning "-A"]) |
5240 |
|
5241 |
type vhdl_conditional_signal_t = |
5242 |
{ |
5243 |
postponed: bool [@default false]; |
5244 |
label: vhdl_name_t [@default NoName]; |
5245 |
lhs: vhdl_name_t ; |
5246 |
rhs: vhdl_signal_condition_t list ; |
5247 |
delay: vhdl_expr_t [@default IsNull]}[@@deriving |
5248 |
((show { with_path = false }), |
5249 |
(yojson { strict = false }))] |
5250 |
let rec pp_vhdl_conditional_signal_t : |
5251 |
Format.formatter -> vhdl_conditional_signal_t -> Ppx_deriving_runtime.unit |
5252 |
= |
5253 |
let __3 () = pp_vhdl_expr_t |
5254 |
|
5255 |
and __2 () = pp_vhdl_signal_condition_t |
5256 |
|
5257 |
and __1 () = pp_vhdl_name_t |
5258 |
|
5259 |
and __0 () = pp_vhdl_name_t |
5260 |
in |
5261 |
((let open! Ppx_deriving_runtime in |
5262 |
fun fmt -> |
5263 |
fun x -> |
5264 |
(match x.label with |
5265 |
| NoName -> Format.fprintf fmt ""; |
5266 |
| _ -> (((__0 ()) fmt) x.label; |
5267 |
Format.fprintf fmt ":@ ") |
5268 |
); |
5269 |
if (x.postponed) then Format.fprintf fmt "postponed@ "; |
5270 |
((__1 ()) fmt) x.lhs; |
5271 |
Format.fprintf fmt " <= "; |
5272 |
(match x.delay with |
5273 |
| IsNull -> Format.fprintf fmt ""; |
5274 |
| _ -> ((__3 ()) fmt) x.delay; |
5275 |
Format.fprintf fmt " "); |
5276 |
((fun x -> |
5277 |
Format.fprintf fmt "@["; |
5278 |
ignore |
5279 |
(List.fold_left |
5280 |
(fun sep -> |
5281 |
fun x -> |
5282 |
if sep then Format.fprintf fmt " else "; |
5283 |
((__2 ()) fmt) x; |
5284 |
true) false x); |
5285 |
Format.fprintf fmt "@]")) x.rhs; |
5286 |
Format.fprintf fmt ";") |
5287 |
[@ocaml.warning "-A"]) |
5288 |
|
5289 |
and show_vhdl_conditional_signal_t : |
5290 |
vhdl_conditional_signal_t -> Ppx_deriving_runtime.string = |
5291 |
fun x -> Format.asprintf "%a" pp_vhdl_conditional_signal_t x |
5292 |
|
5293 |
let rec (vhdl_conditional_signal_t_to_yojson : |
5294 |
vhdl_conditional_signal_t -> Yojson.Safe.json) |
5295 |
= |
5296 |
((let open! Ppx_deriving_yojson_runtime in |
5297 |
fun x -> |
5298 |
let fields = [] in |
5299 |
let fields = |
5300 |
if x.delay = IsNull |
5301 |
then fields |
5302 |
else ("delay", (((fun x -> vhdl_expr_t_to_yojson x)) x.delay)) :: |
5303 |
fields |
5304 |
in |
5305 |
let fields = |
5306 |
("rhs", |
5307 |
((fun x -> |
5308 |
`List |
5309 |
(List.map (fun x -> vhdl_signal_condition_t_to_yojson x) x)) |
5310 |
x.rhs)) |
5311 |
:: fields in |
5312 |
let fields = ("lhs", ((fun x -> vhdl_name_t_to_yojson x) x.lhs)) :: |
5313 |
fields in |
5314 |
let fields = |
5315 |
if x.label = NoName |
5316 |
then fields |
5317 |
else ("label", (((fun x -> vhdl_name_t_to_yojson x)) x.label)) :: |
5318 |
fields |
5319 |
in |
5320 |
let fields = |
5321 |
if x.postponed = false |
5322 |
then fields |
5323 |
else |
5324 |
("postponed", |
5325 |
(((fun (x : Ppx_deriving_runtime.bool) -> `Bool x)) |
5326 |
x.postponed)) |
5327 |
:: fields |
5328 |
in |
5329 |
`Assoc fields) |
5330 |
[@ocaml.warning "-A"]) |
5331 |
|
5332 |
and (vhdl_conditional_signal_t_of_yojson : |
5333 |
Yojson.Safe.json -> |
5334 |
vhdl_conditional_signal_t Ppx_deriving_yojson_runtime.error_or) |
5335 |
= |
5336 |
((let open! Ppx_deriving_yojson_runtime in |
5337 |
function |
5338 |
| `Assoc xs -> |
5339 |
let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) = |
5340 |
match xs with |
5341 |
| ("postponed",x)::xs -> |
5342 |
loop xs |
5343 |
(((function |
5344 |
| `Bool x -> Result.Ok x |
5345 |
| _ -> |
5346 |
Result.Error |
5347 |
"Vhdl_ast.vhdl_conditional_signal_t.postponed") x), |
5348 |
arg1, arg2, arg3, arg4) |
5349 |
| ("label",x)::xs -> |
5350 |
loop xs |
5351 |
(arg0, ((fun x -> vhdl_name_t_of_yojson x) x), arg2, arg3, |
5352 |
arg4) |
5353 |
| ("lhs",x)::xs -> |
5354 |
loop xs |
5355 |
(arg0, arg1, ((fun x -> vhdl_name_t_of_yojson x) x), arg3, |
5356 |
arg4) |
5357 |
| ("rhs",x)::xs -> |
5358 |
loop xs |
5359 |
(arg0, arg1, arg2, |
5360 |
((function |
5361 |
| `List xs -> |
5362 |
map_bind |
5363 |
(fun x -> vhdl_signal_condition_t_of_yojson x) |
5364 |
[] xs |
5365 |
| _ -> |
5366 |
Result.Error |
5367 |
"Vhdl_ast.vhdl_conditional_signal_t.rhs") x), |
5368 |
arg4) |
5369 |
| ("delay",x)::xs -> |
5370 |
loop xs |
5371 |
(arg0, arg1, arg2, arg3, |
5372 |
((fun x -> vhdl_expr_t_of_yojson x) x)) |
5373 |
| [] -> |
5374 |
arg4 >>= |
5375 |
((fun arg4 -> |
5376 |
arg3 >>= |
5377 |
(fun arg3 -> |
5378 |
arg2 >>= |
5379 |
(fun arg2 -> |
5380 |
arg1 >>= |
5381 |
(fun arg1 -> |
5382 |
arg0 >>= |
5383 |
(fun arg0 -> |
5384 |
Result.Ok |
5385 |
{ |
5386 |
postponed = arg0; |
5387 |
label = arg1; |
5388 |
lhs = arg2; |
5389 |
rhs = arg3; |
5390 |
delay = arg4 |
5391 |
})))))) |
5392 |
| _::xs -> loop xs _state in |
5393 |
loop xs |
5394 |
((Result.Ok false), (Result.Ok NoName), |
5395 |
(Result.Error "Vhdl_ast.vhdl_conditional_signal_t.lhs"), |
5396 |
(Result.Error "Vhdl_ast.vhdl_conditional_signal_t.rhs"), |
5397 |
(Result.Ok IsNull)) |
5398 |
| _ -> Result.Error "Vhdl_ast.vhdl_conditional_signal_t") |
5399 |
[@ocaml.warning "-A"]) |
5400 |
|
5401 |
type vhdl_process_t = |
5402 |
{ |
5403 |
id: vhdl_name_t [@default NoName]; |
5404 |
declarations: vhdl_declarative_item_t list |
5405 |
[@key "PROCESS_DECLARATIVE_PART"][@default Some []]; |
5406 |
active_sigs: vhdl_name_t list [@default []]; |
5407 |
body: vhdl_sequential_stmt_t list |
5408 |
[@key "PROCESS_STATEMENT_PART"][@default []]} |
5409 |
|
5410 |
let rec pp_vhdl_process_t : |
5411 |
Format.formatter -> vhdl_process_t -> Ppx_deriving_runtime.unit = |
5412 |
let __3 () = pp_vhdl_sequential_stmt_t |
5413 |
|
5414 |
and __2 () = pp_vhdl_name_t |
5415 |
|
5416 |
and __1 () = pp_vhdl_declarative_item_t |
5417 |
|
5418 |
and __0 () = pp_vhdl_name_t |
5419 |
in |
5420 |
((let open! Ppx_deriving_runtime in |
5421 |
fun fmt -> |
5422 |
fun x -> |
5423 |
Format.fprintf fmt "@[<v 2>"; |
5424 |
(match x.id with |
5425 |
| NoName -> Format.fprintf fmt ""; |
5426 |
| _ -> |
5427 |
((__0 ()) fmt) x.id; |
5428 |
Format.fprintf fmt ": "); |
5429 |
Format.fprintf fmt "process "; |
5430 |
(match x.active_sigs with |
5431 |
| [] -> Format.fprintf fmt ""; |
5432 |
| _ -> Format.fprintf fmt "("; |
5433 |
((fun x -> |
5434 |
ignore |
5435 |
(List.fold_left |
5436 |
(fun sep -> |
5437 |
fun x -> |
5438 |
if sep then Format.fprintf fmt ","; |
5439 |
((__2 ()) fmt) x; |
5440 |
true) false x))) x.active_sigs; |
5441 |
Format.fprintf fmt ")"); |
5442 |
Format.fprintf fmt " is@;"; |
5443 |
((fun x -> |
5444 |
ignore |
5445 |
(List.fold_left |
5446 |
(fun sep -> |
5447 |
fun x -> |
5448 |
if sep then Format.fprintf fmt "@;"; |
5449 |
((__1 ()) fmt) x; |
5450 |
Format.fprintf fmt ";"; |
5451 |
true) false x))) x.declarations; |
5452 |
Format.fprintf fmt "@]@;@[<v 2>begin@;"; |
5453 |
((fun x -> |
5454 |
ignore |
5455 |
(List.fold_left |
5456 |
(fun sep -> |
5457 |
fun x -> |
5458 |
if sep then Format.fprintf fmt "@;"; |
5459 |
((__3 ()) fmt) x; |
5460 |
Format.fprintf fmt ";"; |
5461 |
true) false x);)) x.body; |
5462 |
Format.fprintf fmt "@]@;end process;@;") |
5463 |
[@ocaml.warning "-A"]) |
5464 |
|
5465 |
and show_vhdl_process_t : vhdl_process_t -> Ppx_deriving_runtime.string = |
5466 |
fun x -> Format.asprintf "%a" pp_vhdl_process_t x |
5467 |
|
5468 |
let rec (vhdl_process_t_to_yojson : vhdl_process_t -> Yojson.Safe.json) = |
5469 |
((let open! Ppx_deriving_yojson_runtime in |
5470 |
fun x -> |
5471 |
let fields = [] in |
5472 |
let fields = |
5473 |
if x.body = [] |
5474 |
then fields |
5475 |
else |
5476 |
("PROCESS_STATEMENT_PART", |
5477 |
(((fun x -> |
5478 |
`List |
5479 |
(List.map (fun x -> vhdl_sequential_stmt_t_to_yojson x) |
5480 |
x))) x.body)) |
5481 |
:: fields |
5482 |
in |
5483 |
let fields = |
5484 |
if x.active_sigs = [] |
5485 |
then fields |
5486 |
else |
5487 |
("active_sigs", |
5488 |
(((fun x -> |
5489 |
`List (List.map (fun x -> vhdl_name_t_to_yojson x) x))) |
5490 |
x.active_sigs)) |
5491 |
:: fields |
5492 |
in |
5493 |
let fields = |