Project

General

Profile

Download (242 KB) Statistics
| Branch: | Tag: | Revision:
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
  | Others [@name "OTHERS"]
147
and vhdl_name_t =
148
  | Simple of string [@name "SIMPLE_NAME"]
149
  | Identifier of string [@name "IDENTIFIER"]
150
  | Selected of vhdl_name_t list [@name "SELECTED_NAME"]
151
  | Index of {
152
  id: vhdl_name_t ;
153
  exprs: vhdl_expr_t list } [@name "INDEXED_NAME"]
154
  | Slice of {
155
  id: vhdl_name_t ;
156
  range: vhdl_discrete_range_t } [@name "SLICE_NAME"]
157
  | Attribute of
158
  {
159
  id: vhdl_name_t ;
160
  designator: vhdl_name_t ;
161
  expr: vhdl_expr_t [@default IsNull]} [@name "ATTRIBUTE_NAME"]
162
  | Function of {
163
  id: vhdl_name_t ;
164
  assoc_list: vhdl_assoc_element_t list } [@name "FUNCTION_CALL"]
165
  | NoName 
166
and vhdl_assoc_element_t =
167
  {
168
  formal_name: vhdl_name_t option [@default None];
169
  formal_arg: vhdl_name_t option [@default None];
170
  actual_name: vhdl_name_t option [@default None];
171
  actual_designator: vhdl_name_t option [@default None];
172
  actual_expr: vhdl_expr_t option [@default None]}
173
and vhdl_element_assoc_t = {
174
  choices: vhdl_expr_t list ;
175
  expr: vhdl_expr_t }
176
and vhdl_array_attributes_t =
177
  | AAttInt of {
178
  id: string ;
179
  arg: int } 
180
  | AAttAscending 
181
and vhdl_signal_attributes_t =
182
  | SigAtt of string 
183
and vhdl_string_attributes_t =
184
  | StringAtt of string 
185
and vhdl_suffix_selection_t =
186
  | Idx of int 
187
  | SuffixRange of int * int
188

    
189
let rec pp_vhdl_type_t :
190
  Format.formatter -> vhdl_type_t -> Ppx_deriving_runtime.unit =
191
  let __4 () = pp_vhdl_name_t
192
  
193
  and __3 () = pp_vhdl_element_declaration_t
194
  
195
  and __2 () = pp_vhdl_subtype_indication_t
196
  
197
  and __1 () = pp_vhdl_constraint_t
198
  
199
  and __0 () = pp_vhdl_name_t
200
in
201
  ((let open! Ppx_deriving_runtime in
202
      fun fmt  ->
203
        function
204
        | Base a0 ->
205
             (Format.fprintf fmt "%s") a0;
206
        | Range (a0,a1,a2) ->
207
             ((
208
               (Format.fprintf fmt "%d") a1);
209
               ((function
210
                 | None  -> Format.pp_print_string fmt ""
211
                 | Some x ->
212
                      (Format.fprintf fmt "%s") x;
213
                      )) a0;
214
              (Format.fprintf fmt "%d") a2);
215
        | Bit_vector (a0,a1) ->
216
             (Format.fprintf fmt "array (%d,%d) of bit") a0 a1;
217
        | Array
218
            { indexes = aindexes; const = aconst; definition = adefinition }
219
            ->
220
            Format.fprintf fmt "array";
221
            (match aindexes with
222
            | [] -> Format.fprintf fmt "";
223
            | _ ->
224
              ((fun x  ->
225
                ignore
226
                (List.fold_left
227
                  (fun sep  ->
228
                    fun x  ->
229
                      if sep then Format.fprintf fmt ",@ ";
230
                      ((__0 ()) fmt) x;
231
                      true) false x)) aindexes));
232
            (function
233
              | None  -> Format.pp_print_string fmt ""
234
              | Some x ->
235
                ((__1 ()) fmt) x) aconst;
236
            Format.fprintf fmt " of ";
237
            ((__2 ()) fmt) adefinition;
238
        | Record a0 ->
239
            Format.fprintf fmt "@[<v 2>record@;";
240
            (fun x  ->
241
              ignore
242
                (List.fold_left
243
                  (fun sep  ->
244
                    fun x  ->
245
                      if sep then Format.fprintf fmt ";@;";
246
                        ((__3 ()) fmt) x;
247
                        true) false x);
248
              Format.fprintf fmt "@]@;end record") a0;
249
        | Enumerated a0 ->
250
            (Format.fprintf fmt "(";
251
            ((fun x  ->
252
              ignore
253
              (List.fold_left
254
                (fun sep  ->
255
                  fun x  ->
256
                    if sep then Format.fprintf fmt ",@ ";
257
                      ((__4 ()) fmt) x;
258
                    true) false x))) a0;
259
             Format.fprintf fmt ")");
260
        | Void  -> Format.pp_print_string fmt "")
261
    [@ocaml.warning "-A"])
262

    
263
and show_vhdl_type_t : vhdl_type_t -> Ppx_deriving_runtime.string =
264
  fun x  -> Format.asprintf "%a" pp_vhdl_type_t x
265

    
266
and pp_vhdl_element_declaration_t :
267
  Format.formatter -> vhdl_element_declaration_t -> Ppx_deriving_runtime.unit
268
  =
269
  let __1 () = pp_vhdl_subtype_indication_t
270
  
271
  and __0 () = pp_vhdl_name_t
272
   in
273
  ((let open! Ppx_deriving_runtime in
274
      fun fmt  ->
275
        fun x  ->
276
            (fun x  ->
277
                ignore
278
                  (List.fold_left
279
                     (fun sep  ->
280
                        fun x  ->
281
                          if sep then Format.fprintf fmt ",@ ";
282
                          ((__0 ()) fmt) x;
283
                          true) false x)) x.names;
284
           Format.fprintf fmt ":@ ";
285
           ((__1 ()) fmt) x.definition)
286
    [@ocaml.warning "-A"])
287

    
288
and show_vhdl_element_declaration_t :
289
  vhdl_element_declaration_t -> Ppx_deriving_runtime.string =
290
  fun x  -> Format.asprintf "%a" pp_vhdl_element_declaration_t x
291

    
292
and pp_vhdl_subtype_indication_t :
293
  Format.formatter -> vhdl_subtype_indication_t -> Ppx_deriving_runtime.unit
294
  =
295
  let __2 () = pp_vhdl_constraint_t
296
  
297
  and __1 () = pp_vhdl_name_t
298
  
299
  and __0 () = pp_vhdl_name_t
300
   in
301
  ((let open! Ppx_deriving_runtime in
302
      fun fmt  ->
303
        fun x  ->
304
          ((__0 ()) fmt) x.name;
305
          ((__1 ()) fmt) x.functionName;
306
          (match x.const with
307
            | NoConstraint -> Format.fprintf fmt "";
308
            | _ -> Format.fprintf fmt " ";
309
                   ((__2 ()) fmt) x.const))
310
    [@ocaml.warning "-A"])
311

    
312
and show_vhdl_subtype_indication_t :
313
  vhdl_subtype_indication_t -> Ppx_deriving_runtime.string =
314
  fun x  -> Format.asprintf "%a" pp_vhdl_subtype_indication_t x
315

    
316
and pp_vhdl_discrete_range_t :
317
  Format.formatter -> vhdl_discrete_range_t -> Ppx_deriving_runtime.unit =
318
  let __3 () = pp_vhdl_expr_t
319
  
320
  and __2 () = pp_vhdl_expr_t
321
  
322
  and __1 () = pp_vhdl_name_t
323
  
324
  and __0 () = pp_vhdl_subtype_indication_t
325
   in
326
  ((let open! Ppx_deriving_runtime in
327
      fun fmt  ->
328
        function
329
        | SubDiscreteRange a0 ->
330
             ((__0 ()) fmt) a0;
331
        | NamedRange a0 ->
332
             ((__1 ()) fmt) a0;
333
        | DirectedRange { direction = adirection; from = afrom; _to = a_to }
334
            ->
335
               ((__2 ()) fmt) afrom;
336
               (Format.fprintf fmt " %s ") adirection;
337
               ((__3 ()) fmt) a_to;
338
    )
339
    [@ocaml.warning "-A"])
340

    
341
and show_vhdl_discrete_range_t :
342
  vhdl_discrete_range_t -> Ppx_deriving_runtime.string =
343
  fun x  -> Format.asprintf "%a" pp_vhdl_discrete_range_t x
344

    
345
(* TODO Adapt for: ArrayConstraint, RecordConstraint *)
346
and pp_vhdl_constraint_t :
347
  Format.formatter -> vhdl_constraint_t -> Ppx_deriving_runtime.unit =
348
  let __4 () = pp_vhdl_constraint_t
349
  
350
  and __3 () = pp_vhdl_discrete_range_t
351
  
352
  and __2 () = pp_vhdl_discrete_range_t
353
  
354
  and __1 () = pp_vhdl_discrete_range_t
355
  
356
  and __0 () = pp_vhdl_name_t
357
   in
358
  ((let open! Ppx_deriving_runtime in
359
      fun fmt  ->
360
        function
361
        | RefConstraint { ref_name = aref_name } ->
362
             (Format.fprintf fmt "(";
363
              ((__0 ()) fmt) aref_name;
364
              Format.fprintf fmt ")");
365
        | RangeConstraint { range = arange } ->
366
             (Format.fprintf fmt "(";
367
              ((__1 ()) fmt) arange;
368
              Format.fprintf fmt ")");
369
        | IndexConstraint { ranges = aranges } ->
370
            Format.fprintf fmt "(";
371
            ((fun x  ->
372
                ignore
373
                  (List.fold_left
374
                     (fun sep  ->
375
                        fun x  ->
376
                          if sep then Format.fprintf fmt ", ";
377
                          ((__2 ()) fmt) x;
378
                          true) false x))) aranges;
379
            Format.fprintf fmt ")";
380
        | ArrayConstraint { ranges = aranges; sub = asub } ->
381
            (Format.fprintf fmt "@[<2>ArrayConstraint {@,";
382
             ((Format.fprintf fmt "@[%s =@ " "ranges";
383
               ((fun x  ->
384
                   Format.fprintf fmt "@[<2>[";
385
                   ignore
386
                     (List.fold_left
387
                        (fun sep  ->
388
                           fun x  ->
389
                             if sep then Format.fprintf fmt ";@ ";
390
                             ((__3 ()) fmt) x;
391
                             true) false x);
392
                   Format.fprintf fmt "@,]@]")) aranges;
393
               Format.fprintf fmt "@]");
394
              Format.fprintf fmt ";@ ";
395
              Format.fprintf fmt "@[%s =@ " "sub";
396
              ((__4 ()) fmt) asub;
397
              Format.fprintf fmt "@]");
398
             Format.fprintf fmt "@]}")
399
        | RecordConstraint  -> Format.pp_print_string fmt ""
400
        | NoConstraint  -> Format.pp_print_string fmt "")
401
    [@ocaml.warning "-A"])
402

    
403
and show_vhdl_constraint_t : vhdl_constraint_t -> Ppx_deriving_runtime.string
404
  = fun x  -> Format.asprintf "%a" pp_vhdl_constraint_t x
405

    
406
and pp_vhdl_definition_t :
407
  Format.formatter -> vhdl_definition_t -> Ppx_deriving_runtime.unit =
408
  let __3 () = pp_vhdl_subtype_indication_t
409
  
410
  and __2 () = pp_vhdl_name_t
411
  
412
  and __1 () = pp_vhdl_type_t
413
  
414
  and __0 () = pp_vhdl_name_t
415
   in
416
  ((let open! Ppx_deriving_runtime in
417
      fun fmt  ->
418
        function
419
        | Type { name = aname; definition = adefinition } ->
420
            Format.fprintf fmt "type ";
421
            ((__0 ()) fmt) aname;
422
            Format.fprintf fmt " is ";
423
            ((__1 ()) fmt) adefinition;
424
        | Subtype { name = aname; typ = atyp } ->
425
            Format.fprintf fmt "subtype ";
426
            ((__2 ()) fmt) aname;
427
            Format.fprintf fmt " is ";
428
            ((__3 ()) fmt) atyp;
429
   )
430
    [@ocaml.warning "-A"])
431

    
432
and show_vhdl_definition_t : vhdl_definition_t -> Ppx_deriving_runtime.string
433
  = fun x  -> Format.asprintf "%a" pp_vhdl_definition_t x
434

    
435
(* TODO adapt for Op, Time, Sig, suffixMod, Aggregate *)
436
and pp_vhdl_expr_t :
437
  Format.formatter -> vhdl_expr_t -> Ppx_deriving_runtime.unit =
438
  let __8 () = pp_vhdl_element_assoc_t
439
  
440
  and __7 () = pp_vhdl_suffix_selection_t
441
  
442
  and __6 () = pp_vhdl_expr_t
443
  
444
  and __5 () = pp_vhdl_signal_attributes_t
445
  
446
  and __4 () = pp_vhdl_name_t
447
  
448
  and __3 () = pp_vhdl_expr_t
449
  
450
  and __2 () = pp_vhdl_name_t
451
  
452
  and __1 () = pp_vhdl_cst_val_t
453
  
454
  and __0 () = pp_vhdl_name_t
455
   in
456
  ((let open! Ppx_deriving_runtime in
457
      fun fmt  ->
458
        function
459
        | Call a0 ->
460
             ((__0 ()) fmt) a0;
461
        | Cst { value = avalue; unit_name = aunit_name } ->
462
             ((__1 ()) fmt) avalue;
463
             (function
464
                | None  -> Format.pp_print_string fmt ""
465
                | Some x ->
466
                    Format.fprintf fmt " ";
467
                    ((__2 ()) fmt) x) aunit_name;
468
        | Op { id = aid; args = aargs } ->
469
            (match aargs with
470
            | [] -> (Format.fprintf fmt "%s") aid;
471
            | hd::[] ->
472
               (Format.fprintf fmt "%s") aid;
473
               ((__3 ()) fmt) hd
474
            | hd::(hd2::[]) -> 
475
               ((__3 ()) fmt) hd;
476
               (Format.fprintf fmt " %s ") aid;
477
               ((__3 ()) fmt) hd2
478
            | _ ->
479
            (Format.fprintf fmt "@[<2>Op {@,";
480
             ((Format.fprintf fmt "@[%s =@ " "id";
481
               (Format.fprintf fmt "%S") aid;
482
               Format.fprintf fmt "@]");
483
              Format.fprintf fmt ";@ ";
484
              Format.fprintf fmt "@[%s =@ " "args";
485
              ((fun x  ->
486
                  Format.fprintf fmt "@[<2>[";
487
                  ignore
488
                    (List.fold_left
489
                       (fun sep  ->
490
                          fun x  ->
491
                            if sep then Format.fprintf fmt ";@ ";
492
                            ((__3 ()) fmt) x;
493
                            true) false x);
494
                  Format.fprintf fmt "@,]@]")) aargs;
495
              Format.fprintf fmt "@]");
496
             Format.fprintf fmt "@]}"))
497
        | IsNull  -> Format.pp_print_string fmt ""
498
        | Time { value = avalue; phy_unit = aphy_unit } ->
499
            (Format.fprintf fmt "@[<2>Time {@,";
500
             ((Format.fprintf fmt "@[%s =@ " "value";
501
               (Format.fprintf fmt "%d") avalue;
502
               Format.fprintf fmt "@]");
503
              Format.fprintf fmt ";@ ";
504
              Format.fprintf fmt "@[%s =@ " "phy_unit";
505
              (Format.fprintf fmt "%S") aphy_unit;
506
              Format.fprintf fmt "@]");
507
             Format.fprintf fmt "@]}")
508
        | Sig { name = aname; att = aatt } ->
509
            (Format.fprintf fmt "--@[<2>Sig {@,";
510
             ((Format.fprintf fmt "@[%s =@ " "name";
511
               ((__4 ()) fmt) aname;
512
               Format.fprintf fmt "@]");
513
              Format.fprintf fmt ";@ ";
514
              Format.fprintf fmt "@[%s =@ " "att";
515
              ((function
516
                | None  -> Format.pp_print_string fmt "None"
517
                | Some x ->
518
                    (Format.pp_print_string fmt "(Some ";
519
                     ((__5 ()) fmt) x;
520
                     Format.pp_print_string fmt ")"))) aatt;
521
              Format.fprintf fmt "@]");
522
             Format.fprintf fmt "@]}")
523
        | SuffixMod { expr = aexpr; selection = aselection } ->
524
            (Format.fprintf fmt "--@[<2>SuffixMod {@,";
525
             ((Format.fprintf fmt "@[%s =@ " "expr";
526
               ((__6 ()) fmt) aexpr;
527
               Format.fprintf fmt "@]");
528
              Format.fprintf fmt ";@ ";
529
              Format.fprintf fmt "@[%s =@ " "selection";
530
              ((__7 ()) fmt) aselection;
531
              Format.fprintf fmt "@]");
532
             Format.fprintf fmt "@]}")
533
        | Aggregate { elems = aelems } ->
534
            (Format.fprintf fmt "--@[<2>Aggregate {@,";
535
             (Format.fprintf fmt "@[%s =@ " "elems";
536
              ((fun x  ->
537
                  Format.fprintf fmt "@[<2>[";
538
                  ignore
539
                    (List.fold_left
540
                       (fun sep  ->
541
                          fun x  ->
542
                            if sep then Format.fprintf fmt ";@ ";
543
                            ((__8 ()) fmt) x;
544
                            true) false x);
545
                  Format.fprintf fmt "@,]@]")) aelems;
546
              Format.fprintf fmt "@]");
547
             Format.fprintf fmt "@]}")
548
        | Others  -> Format.pp_print_string fmt "others")
549
    [@ocaml.warning "-A"])
550

    
551
and show_vhdl_expr_t : vhdl_expr_t -> Ppx_deriving_runtime.string =
552
  fun x  -> Format.asprintf "%a" pp_vhdl_expr_t x
553

    
554
and pp_vhdl_name_t :
555
  Format.formatter -> vhdl_name_t -> Ppx_deriving_runtime.unit =
556
  let __9 () = pp_vhdl_assoc_element_t
557
  
558
  and __8 () = pp_vhdl_name_t
559
  
560
  and __7 () = pp_vhdl_expr_t
561
  
562
  and __6 () = pp_vhdl_name_t
563
  
564
  and __5 () = pp_vhdl_name_t
565
  
566
  and __4 () = pp_vhdl_discrete_range_t
567
  
568
  and __3 () = pp_vhdl_name_t
569
  
570
  and __2 () = pp_vhdl_expr_t
571
  
572
  and __1 () = pp_vhdl_name_t
573
  
574
  and __0 () = pp_vhdl_name_t
575
   in
576
  ((let open! Ppx_deriving_runtime in
577
      fun fmt  ->
578
        function
579
        | Simple a0 ->
580
             (Format.fprintf fmt "%s") a0;
581
        | Identifier a0 ->
582
             (Format.fprintf fmt "%s") a0;
583
        | Selected a0 ->
584
             ((fun x  ->
585
                 ignore
586
                   (List.fold_left
587
                      (fun sep  ->
588
                         fun x  ->
589
                           if sep then Format.fprintf fmt ".";
590
                           ((__0 ()) fmt) x;
591
                           true) false x);) a0;)
592
        | Index { id = aid; exprs = aexprs } ->
593
            ((__1 ()) fmt) aid;
594
            Format.fprintf fmt "(";
595
            (fun x  ->
596
                ignore
597
                (List.fold_left
598
                  (fun sep  ->
599
                    fun x  ->
600
                      if sep then Format.fprintf fmt ",@ ";
601
                                  ((__2 ()) fmt) x;
602
                                  true
603
                  ) false x);
604
            ) aexprs;
605
            Format.fprintf fmt ")";
606
        | Slice { id = aid; range = arange } ->
607
              ((__3 ()) fmt) aid;
608
              Format.fprintf fmt "(";
609
              ((__4 ()) fmt) arange;
610
              Format.fprintf fmt ")";
611
        | Attribute { id = aid; designator = adesignator; expr = aexpr } ->
612
              ((__5 ()) fmt) aid;
613
              Format.fprintf fmt "\'";
614
              ((__6 ()) fmt) adesignator;
615
              (match aexpr with
616
              | IsNull -> Format.fprintf fmt "";
617
              | _ ->
618
                Format.fprintf fmt "(";
619
                ((__7 ()) fmt) aexpr;
620
                Format.fprintf fmt ")")
621
        | Function { id = aid; assoc_list = aassoc_list } ->
622
            (((__8 ()) fmt) aid;
623
            Format.fprintf fmt "(";
624
            ((fun x  ->
625
              Format.fprintf fmt "@[";
626
              ignore
627
                (List.fold_left
628
                   (fun sep  ->
629
                      fun x  ->
630
                        if sep then Format.fprintf fmt ";@ ";
631
                        ((__9 ()) fmt) x;
632
                        true) false x);
633
            Format.fprintf fmt "@]")) aassoc_list;
634
            Format.fprintf fmt ")";)
635
        | NoName  -> Format.pp_print_string fmt "")
636
    [@ocaml.warning "-A"])
637

    
638
and show_vhdl_name_t : vhdl_name_t -> Ppx_deriving_runtime.string =
639
  fun x  -> Format.asprintf "%a" pp_vhdl_name_t x
640

    
641
and pp_vhdl_assoc_element_t :
642
  Format.formatter -> vhdl_assoc_element_t -> Ppx_deriving_runtime.unit =
643
  let __4 () = pp_vhdl_expr_t
644
  
645
  and __3 () = pp_vhdl_name_t
646
  
647
  and __2 () = pp_vhdl_name_t
648
  
649
  and __1 () = pp_vhdl_name_t
650
  
651
  and __0 () = pp_vhdl_name_t
652
   in
653
  ((let open! Ppx_deriving_runtime in
654
      fun fmt  ->
655
        fun x  ->
656
          (match x.formal_name with
657
          | None -> Format.pp_print_string fmt ""
658
          | Some NoName -> Format.pp_print_string fmt ""
659
          | Some a -> 
660
              (((__0 ()) fmt) a;
661
              (match x.formal_arg with
662
              | None -> ()
663
              | Some b -> Format.fprintf fmt "(";
664
                          ((__1 ()) fmt) b;
665
                          Format.fprintf fmt ")");
666
              Format.fprintf fmt " => "));
667
          (match x.actual_name with
668
          | None -> Format.pp_print_string fmt ""
669
          | Some a -> 
670
              (((__2 ()) fmt) a;
671
              (match x.actual_designator with
672
              | None -> ()
673
              | Some NoName -> Format.pp_print_string fmt ""
674
              | Some b -> (Format.fprintf fmt "(";
675
                          ((__3 ()) fmt) b;
676
                          Format.fprintf fmt ")"));
677
              (match x.actual_expr with
678
              | None -> ()
679
              | Some IsNull -> Format.pp_print_string fmt ""
680
              | Some c -> (Format.fprintf fmt "(";
681
                          ((__4 ()) fmt) c;
682
                          Format.fprintf fmt ")"))));)
683
    [@ocaml.warning "-A"])
684

    
685
and show_vhdl_assoc_element_t :
686
  vhdl_assoc_element_t -> Ppx_deriving_runtime.string =
687
  fun x  -> Format.asprintf "%a" pp_vhdl_assoc_element_t x
688

    
689
and pp_vhdl_element_assoc_t :
690
  Format.formatter -> vhdl_element_assoc_t -> Ppx_deriving_runtime.unit =
691
  let __1 () = pp_vhdl_expr_t
692
  
693
  and __0 () = pp_vhdl_expr_t
694
   in
695
  ((let open! Ppx_deriving_runtime in
696
      fun fmt  ->
697
        fun x  ->
698
            (match x.choices with
699
            | [] -> Format.fprintf fmt "";
700
            | _ -> 
701
              (((fun x  ->
702
                Format.fprintf fmt "@[<2>[";
703
                ignore
704
                  (List.fold_left
705
                     (fun sep  ->
706
                        fun x  ->
707
                          if sep then Format.fprintf fmt "|@ ";
708
                          ((__0 ()) fmt) x;
709
                          true) false x))) x.choices;
710
              Format.fprintf fmt " => ";));
711
           ((__1 ()) fmt) x.expr)
712
    [@ocaml.warning "-A"])
713

    
714
and show_vhdl_element_assoc_t :
715
  vhdl_element_assoc_t -> Ppx_deriving_runtime.string =
716
  fun x  -> Format.asprintf "%a" pp_vhdl_element_assoc_t x
717

    
718
(* TODO *)
719
and (pp_vhdl_array_attributes_t :
720
      Format.formatter ->
721
        vhdl_array_attributes_t -> Ppx_deriving_runtime.unit)
722
  =
723
  ((let open! Ppx_deriving_runtime in
724
      fun fmt  ->
725
        function
726
        | AAttInt { id = aid; arg = aarg } ->
727
            (Format.fprintf fmt "@[<2>AAttInt {@,";
728
             ((Format.fprintf fmt "@[%s =@ " "id";
729
               (Format.fprintf fmt "%S") aid;
730
               Format.fprintf fmt "@]");
731
              Format.fprintf fmt ";@ ";
732
              Format.fprintf fmt "@[%s =@ " "arg";
733
              (Format.fprintf fmt "%d") aarg;
734
              Format.fprintf fmt "@]");
735
             Format.fprintf fmt "@]}")
736
        | AAttAscending  -> Format.pp_print_string fmt "AAttAscending")
737
  [@ocaml.warning "-A"])
738

    
739
and show_vhdl_array_attributes_t :
740
  vhdl_array_attributes_t -> Ppx_deriving_runtime.string =
741
  fun x  -> Format.asprintf "%a" pp_vhdl_array_attributes_t x
742

    
743
(* TODO *)
744
and (pp_vhdl_signal_attributes_t :
745
      Format.formatter ->
746
        vhdl_signal_attributes_t -> Ppx_deriving_runtime.unit)
747
  =
748
  ((let open! Ppx_deriving_runtime in
749
      fun fmt  ->
750
        function
751
        | SigAtt a0 ->
752
            (Format.fprintf fmt "(@[<2>SigAtt@ ";
753
             (Format.fprintf fmt "%S") a0;
754
             Format.fprintf fmt "@])"))
755
  [@ocaml.warning "-A"])
756

    
757
and show_vhdl_signal_attributes_t :
758
  vhdl_signal_attributes_t -> Ppx_deriving_runtime.string =
759
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_attributes_t x
760

    
761
(* TODO *)
762
and (pp_vhdl_string_attributes_t :
763
      Format.formatter ->
764
        vhdl_string_attributes_t -> Ppx_deriving_runtime.unit)
765
  =
766
  ((let open! Ppx_deriving_runtime in
767
      fun fmt  ->
768
        function
769
        | StringAtt a0 ->
770
            (Format.fprintf fmt "(@[<2>StringAtt@ ";
771
             (Format.fprintf fmt "%S") a0;
772
             Format.fprintf fmt "@])"))
773
  [@ocaml.warning "-A"])
774

    
775
and show_vhdl_string_attributes_t :
776
  vhdl_string_attributes_t -> Ppx_deriving_runtime.string =
777
  fun x  -> Format.asprintf "%a" pp_vhdl_string_attributes_t x
778

    
779
(* TODO *)
780
and (pp_vhdl_suffix_selection_t :
781
      Format.formatter ->
782
        vhdl_suffix_selection_t -> Ppx_deriving_runtime.unit)
783
  =
784
  ((let open! Ppx_deriving_runtime in
785
      fun fmt  ->
786
        function
787
        | Idx a0 ->
788
            (Format.fprintf fmt "(@[<2>Idx@ ";
789
             (Format.fprintf fmt "%d") a0;
790
             Format.fprintf fmt "@])")
791
        | SuffixRange (a0,a1) ->
792
            (Format.fprintf fmt "(@[<2>SuffixRange (@,";
793
             ((Format.fprintf fmt "%d") a0;
794
              Format.fprintf fmt ",@ ";
795
              (Format.fprintf fmt "%d") a1);
796
             Format.fprintf fmt "@,))@]"))
797
  [@ocaml.warning "-A"])
798

    
799
and show_vhdl_suffix_selection_t :
800
  vhdl_suffix_selection_t -> Ppx_deriving_runtime.string =
801
  fun x  -> Format.asprintf "%a" pp_vhdl_suffix_selection_t x
802

    
803
let rec (vhdl_type_t_to_yojson : vhdl_type_t -> Yojson.Safe.json) =
804
  ((let open! Ppx_deriving_yojson_runtime in
805
      function
806
      | Base arg0 ->
807
          `List
808
            [`String "Base";
809
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
810
      | Range (arg0,arg1,arg2) ->
811
          `List
812
            [`String "Range";
813
            ((function
814
              | None  -> `Null
815
              | Some x ->
816
                  ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) x))
817
              arg0;
818
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1;
819
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg2]
820
      | Bit_vector (arg0,arg1) ->
821
          `List
822
            [`String "Bit_vector";
823
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0;
824
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1]
825
      | Array arg0 ->
826
          `List
827
            [`String "ARRAY_TYPE_DEFINITION";
828
            (let fields = []  in
829
             let fields =
830
               ("definition",
831
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x)
832
                    arg0.definition))
833
               :: fields  in
834
             let fields =
835
               if arg0.const = None
836
               then fields
837
               else
838
                 ("const",
839
                   (((function
840
                      | None  -> `Null
841
                      | Some x ->
842
                          ((fun x  -> vhdl_constraint_t_to_yojson x)) x))
843
                      arg0.const))
844
                 :: fields
845
                in
846
             let fields =
847
               if arg0.indexes = []
848
               then fields
849
               else
850
                 ("indexes",
851
                   (((fun x  ->
852
                        `List
853
                          (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
854
                      arg0.indexes))
855
                 :: fields
856
                in
857
             `Assoc fields)]
858
      | Record arg0 ->
859
          `List
860
            [`String "RECORD_TYPE_DEFINITION";
861
            ((fun x  ->
862
                `List
863
                  (List.map
864
                     (fun x  -> vhdl_element_declaration_t_to_yojson x) x)))
865
              arg0]
866
      | Enumerated arg0 ->
867
          `List
868
            [`String "ENUMERATION_TYPE_DEFINITION";
869
            ((fun x  ->
870
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0]
871
      | Void  -> `List [`String "Void"])
872
  [@ocaml.warning "-A"])
873

    
874
and (vhdl_type_t_of_yojson :
875
      Yojson.Safe.json -> vhdl_type_t Ppx_deriving_yojson_runtime.error_or)
876
  =
877
  ((let open! Ppx_deriving_yojson_runtime in
878
      function
879
      | `List ((`String "Base")::arg0::[]) ->
880
          ((function
881
            | `String x -> Result.Ok x
882
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
883
            ((fun arg0  -> Result.Ok (Base arg0)))
884
      | `List ((`String "Range")::arg0::arg1::arg2::[]) ->
885
          ((function
886
            | `Int x -> Result.Ok x
887
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg2) >>=
888
            ((fun arg2  ->
889
                ((function
890
                  | `Int x -> Result.Ok x
891
                  | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg1) >>=
892
                  (fun arg1  ->
893
                     ((function
894
                       | `Null -> Result.Ok None
895
                       | x ->
896
                           ((function
897
                             | `String x -> Result.Ok x
898
                             | _ -> Result.Error "Vhdl_ast.vhdl_type_t") x)
899
                             >>= ((fun x  -> Result.Ok (Some x)))) arg0)
900
                       >>=
901
                       (fun arg0  -> Result.Ok (Range (arg0, arg1, arg2))))))
902
      | `List ((`String "Bit_vector")::arg0::arg1::[]) ->
903
          ((function
904
            | `Int x -> Result.Ok x
905
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg1) >>=
906
            ((fun arg1  ->
907
                ((function
908
                  | `Int x -> Result.Ok x
909
                  | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
910
                  (fun arg0  -> Result.Ok (Bit_vector (arg0, arg1)))))
911
      | `List ((`String "ARRAY_TYPE_DEFINITION")::arg0::[]) ->
912
          ((function
913
            | `Assoc xs ->
914
                let rec loop xs ((arg0,arg1,arg2) as _state) =
915
                  match xs with
916
                  | ("indexes",x)::xs ->
917
                      loop xs
918
                        (((function
919
                           | `List xs ->
920
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
921
                                 [] xs
922
                           | _ -> Result.Error "Vhdl_ast.vhdl_type_t.indexes")
923
                            x), arg1, arg2)
924
                  | ("const",x)::xs ->
925
                      loop xs
926
                        (arg0,
927
                          ((function
928
                            | `Null -> Result.Ok None
929
                            | x ->
930
                                ((fun x  -> vhdl_constraint_t_of_yojson x) x)
931
                                  >>= ((fun x  -> Result.Ok (Some x)))) x),
932
                          arg2)
933
                  | ("definition",x)::xs ->
934
                      loop xs
935
                        (arg0, arg1,
936
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
937
                             x))
938
                  | [] ->
939
                      arg2 >>=
940
                        ((fun arg2  ->
941
                            arg1 >>=
942
                              (fun arg1  ->
943
                                 arg0 >>=
944
                                   (fun arg0  ->
945
                                      Result.Ok
946
                                        (Array
947
                                           {
948
                                             indexes = arg0;
949
                                             const = arg1;
950
                                             definition = arg2
951
                                           })))))
952
                  | _::xs -> loop xs _state  in
953
                loop xs
954
                  ((Result.Ok []), (Result.Ok None),
955
                    (Result.Error "Vhdl_ast.vhdl_type_t.definition"))
956
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t")) arg0
957
      | `List ((`String "RECORD_TYPE_DEFINITION")::arg0::[]) ->
958
          ((function
959
            | `List xs ->
960
                map_bind (fun x  -> vhdl_element_declaration_t_of_yojson x)
961
                  [] xs
962
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
963
            ((fun arg0  -> Result.Ok (Record arg0)))
964
      | `List ((`String "ENUMERATION_TYPE_DEFINITION")::arg0::[]) ->
965
          ((function
966
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
967
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
968
            ((fun arg0  -> Result.Ok (Enumerated arg0)))
969
      | `List ((`String "Void")::[]) -> Result.Ok Void
970
      | _ -> Result.Error "Vhdl_ast.vhdl_type_t")
971
  [@ocaml.warning "-A"])
972

    
973
and (vhdl_element_declaration_t_to_yojson :
974
      vhdl_element_declaration_t -> Yojson.Safe.json)
975
  =
976
  ((let open! Ppx_deriving_yojson_runtime in
977
      fun x  ->
978
        let fields = []  in
979
        let fields =
980
          ("definition",
981
            ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.definition))
982
          :: fields  in
983
        let fields =
984
          ("names",
985
            ((fun x  ->
986
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
987
               x.names))
988
          :: fields  in
989
        `Assoc fields)
990
  [@ocaml.warning "-A"])
991

    
992
and (vhdl_element_declaration_t_of_yojson :
993
      Yojson.Safe.json ->
994
        vhdl_element_declaration_t Ppx_deriving_yojson_runtime.error_or)
995
  =
996
  ((let open! Ppx_deriving_yojson_runtime in
997
      function
998
      | `Assoc xs ->
999
          let rec loop xs ((arg0,arg1) as _state) =
1000
            match xs with
1001
            | ("names",x)::xs ->
1002
                loop xs
1003
                  (((function
1004
                     | `List xs ->
1005
                         map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
1006
                     | _ ->
1007
                         Result.Error
1008
                           "Vhdl_ast.vhdl_element_declaration_t.names") x),
1009
                    arg1)
1010
            | ("definition",x)::xs ->
1011
                loop xs
1012
                  (arg0,
1013
                    ((fun x  -> vhdl_subtype_indication_t_of_yojson x) x))
1014
            | [] ->
1015
                arg1 >>=
1016
                  ((fun arg1  ->
1017
                      arg0 >>=
1018
                        (fun arg0  ->
1019
                           Result.Ok { names = arg0; definition = arg1 })))
1020
            | _::xs -> loop xs _state  in
1021
          loop xs
1022
            ((Result.Error "Vhdl_ast.vhdl_element_declaration_t.names"),
1023
              (Result.Error "Vhdl_ast.vhdl_element_declaration_t.definition"))
1024
      | _ -> Result.Error "Vhdl_ast.vhdl_element_declaration_t")
1025
  [@ocaml.warning "-A"])
1026

    
1027
and (vhdl_subtype_indication_t_to_yojson :
1028
      vhdl_subtype_indication_t -> Yojson.Safe.json)
1029
  =
1030
  ((let open! Ppx_deriving_yojson_runtime in
1031
      fun x  ->
1032
        let fields = []  in
1033
        let fields =
1034
          if x.const = NoConstraint
1035
          then fields
1036
          else
1037
            ("const", (((fun x  -> vhdl_constraint_t_to_yojson x)) x.const))
1038
            :: fields
1039
           in
1040
        let fields =
1041
          if x.functionName = NoName
1042
          then fields
1043
          else
1044
            ("functionName",
1045
              (((fun x  -> vhdl_name_t_to_yojson x)) x.functionName))
1046
            :: fields
1047
           in
1048
        let fields =
1049
          if x.name = NoName
1050
          then fields
1051
          else ("name", (((fun x  -> vhdl_name_t_to_yojson x)) x.name)) ::
1052
            fields
1053
           in
1054
        `Assoc fields)
1055
  [@ocaml.warning "-A"])
1056

    
1057
and (vhdl_subtype_indication_t_of_yojson :
1058
      Yojson.Safe.json ->
1059
        vhdl_subtype_indication_t Ppx_deriving_yojson_runtime.error_or)
1060
  =
1061
  ((let open! Ppx_deriving_yojson_runtime in
1062
      function
1063
      | `Assoc xs ->
1064
          let rec loop xs ((arg0,arg1,arg2) as _state) =
1065
            match xs with
1066
            | ("name",x)::xs ->
1067
                loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
1068
            | ("functionName",x)::xs ->
1069
                loop xs (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
1070
            | ("const",x)::xs ->
1071
                loop xs
1072
                  (arg0, arg1, ((fun x  -> vhdl_constraint_t_of_yojson x) x))
1073
            | [] ->
1074
                arg2 >>=
1075
                  ((fun arg2  ->
1076
                      arg1 >>=
1077
                        (fun arg1  ->
1078
                           arg0 >>=
1079
                             (fun arg0  ->
1080
                                Result.Ok
1081
                                  {
1082
                                    name = arg0;
1083
                                    functionName = arg1;
1084
                                    const = arg2
1085
                                  }))))
1086
            | _::xs -> loop xs _state  in
1087
          loop xs
1088
            ((Result.Ok NoName), (Result.Ok NoName),
1089
              (Result.Ok NoConstraint))
1090
      | _ -> Result.Error "Vhdl_ast.vhdl_subtype_indication_t")
1091
  [@ocaml.warning "-A"])
1092

    
1093
and (vhdl_discrete_range_t_to_yojson :
1094
      vhdl_discrete_range_t -> Yojson.Safe.json)
1095
  =
1096
  ((let open! Ppx_deriving_yojson_runtime in
1097
      function
1098
      | SubDiscreteRange arg0 ->
1099
          `List
1100
            [`String "SUB_DISCRETE_RANGE";
1101
            ((fun x  -> vhdl_subtype_indication_t_to_yojson x)) arg0]
1102
      | NamedRange arg0 ->
1103
          `List
1104
            [`String "NAMED_RANGE";
1105
            ((fun x  -> vhdl_name_t_to_yojson x)) arg0]
1106
      | DirectedRange arg0 ->
1107
          `List
1108
            [`String "RANGE_WITH_DIRECTION";
1109
            (let fields = []  in
1110
             let fields =
1111
               ("_to", ((fun x  -> vhdl_expr_t_to_yojson x) arg0._to)) ::
1112
               fields  in
1113
             let fields =
1114
               ("from", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.from)) ::
1115
               fields  in
1116
             let fields =
1117
               ("direction",
1118
                 ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
1119
                    arg0.direction))
1120
               :: fields  in
1121
             `Assoc fields)])
1122
  [@ocaml.warning "-A"])
1123

    
1124
and (vhdl_discrete_range_t_of_yojson :
1125
      Yojson.Safe.json ->
1126
        vhdl_discrete_range_t Ppx_deriving_yojson_runtime.error_or)
1127
  =
1128
  ((let open! Ppx_deriving_yojson_runtime in
1129
      function
1130
      | `List ((`String "SUB_DISCRETE_RANGE")::arg0::[]) ->
1131
          ((fun x  -> vhdl_subtype_indication_t_of_yojson x) arg0) >>=
1132
            ((fun arg0  -> Result.Ok (SubDiscreteRange arg0)))
1133
      | `List ((`String "NAMED_RANGE")::arg0::[]) ->
1134
          ((fun x  -> vhdl_name_t_of_yojson x) arg0) >>=
1135
            ((fun arg0  -> Result.Ok (NamedRange arg0)))
1136
      | `List ((`String "RANGE_WITH_DIRECTION")::arg0::[]) ->
1137
          ((function
1138
            | `Assoc xs ->
1139
                let rec loop xs ((arg0,arg1,arg2) as _state) =
1140
                  match xs with
1141
                  | ("direction",x)::xs ->
1142
                      loop xs
1143
                        (((function
1144
                           | `String x -> Result.Ok x
1145
                           | _ ->
1146
                               Result.Error
1147
                                 "Vhdl_ast.vhdl_discrete_range_t.direction")
1148
                            x), arg1, arg2)
1149
                  | ("from",x)::xs ->
1150
                      loop xs
1151
                        (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x), arg2)
1152
                  | ("_to",x)::xs ->
1153
                      loop xs
1154
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
1155
                  | [] ->
1156
                      arg2 >>=
1157
                        ((fun arg2  ->
1158
                            arg1 >>=
1159
                              (fun arg1  ->
1160
                                 arg0 >>=
1161
                                   (fun arg0  ->
1162
                                      Result.Ok
1163
                                        (DirectedRange
1164
                                           {
1165
                                             direction = arg0;
1166
                                             from = arg1;
1167
                                             _to = arg2
1168
                                           })))))
1169
                  | _::xs -> loop xs _state  in
1170
                loop xs
1171
                  ((Result.Error "Vhdl_ast.vhdl_discrete_range_t.direction"),
1172
                    (Result.Error "Vhdl_ast.vhdl_discrete_range_t.from"),
1173
                    (Result.Error "Vhdl_ast.vhdl_discrete_range_t._to"))
1174
            | _ -> Result.Error "Vhdl_ast.vhdl_discrete_range_t")) arg0
1175
      | _ -> Result.Error "Vhdl_ast.vhdl_discrete_range_t")
1176
  [@ocaml.warning "-A"])
1177

    
1178
and (vhdl_constraint_t_to_yojson : vhdl_constraint_t -> Yojson.Safe.json) =
1179
  ((let open! Ppx_deriving_yojson_runtime in
1180
      function
1181
      | RefConstraint arg0 ->
1182
          `List
1183
            [`String "RefConstraint";
1184
            (let fields = []  in
1185
             let fields =
1186
               ("ref_name",
1187
                 ((fun x  -> vhdl_name_t_to_yojson x) arg0.ref_name))
1188
               :: fields  in
1189
             `Assoc fields)]
1190
      | RangeConstraint arg0 ->
1191
          `List
1192
            [`String "RANGE_CONSTRAINT";
1193
            (let fields = []  in
1194
             let fields =
1195
               ("range",
1196
                 ((fun x  -> vhdl_discrete_range_t_to_yojson x) arg0.range))
1197
               :: fields  in
1198
             `Assoc fields)]
1199
      | IndexConstraint arg0 ->
1200
          `List
1201
            [`String "INDEX_CONSTRAINT";
1202
            (let fields = []  in
1203
             let fields =
1204
               ("ranges",
1205
                 ((fun x  ->
1206
                     `List
1207
                       (List.map
1208
                          (fun x  -> vhdl_discrete_range_t_to_yojson x) x))
1209
                    arg0.ranges))
1210
               :: fields  in
1211
             `Assoc fields)]
1212
      | ArrayConstraint arg0 ->
1213
          `List
1214
            [`String "ARRAY_CONSTRAINT";
1215
            (let fields = []  in
1216
             let fields =
1217
               ("sub", ((fun x  -> vhdl_constraint_t_to_yojson x) arg0.sub))
1218
               :: fields  in
1219
             let fields =
1220
               ("ranges",
1221
                 ((fun x  ->
1222
                     `List
1223
                       (List.map
1224
                          (fun x  -> vhdl_discrete_range_t_to_yojson x) x))
1225
                    arg0.ranges))
1226
               :: fields  in
1227
             `Assoc fields)]
1228
      | RecordConstraint  -> `List [`String "RecordConstraint"]
1229
      | NoConstraint  -> `List [`String "NoConstraint"])
1230
  [@ocaml.warning "-A"])
1231

    
1232
and (vhdl_constraint_t_of_yojson :
1233
      Yojson.Safe.json ->
1234
        vhdl_constraint_t Ppx_deriving_yojson_runtime.error_or)
1235
  =
1236
  ((let open! Ppx_deriving_yojson_runtime in
1237
      function
1238
      | `List ((`String "RefConstraint")::arg0::[]) ->
1239
          ((function
1240
            | `Assoc xs ->
1241
                let rec loop xs (arg0 as _state) =
1242
                  match xs with
1243
                  | ("ref_name",x)::xs ->
1244
                      loop xs ((fun x  -> vhdl_name_t_of_yojson x) x)
1245
                  | [] ->
1246
                      arg0 >>=
1247
                        ((fun arg0  ->
1248
                            Result.Ok (RefConstraint { ref_name = arg0 })))
1249
                  | _::xs -> loop xs _state  in
1250
                loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.ref_name")
1251
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1252
      | `List ((`String "RANGE_CONSTRAINT")::arg0::[]) ->
1253
          ((function
1254
            | `Assoc xs ->
1255
                let rec loop xs (arg0 as _state) =
1256
                  match xs with
1257
                  | ("range",x)::xs ->
1258
                      loop xs
1259
                        ((fun x  -> vhdl_discrete_range_t_of_yojson x) x)
1260
                  | [] ->
1261
                      arg0 >>=
1262
                        ((fun arg0  ->
1263
                            Result.Ok (RangeConstraint { range = arg0 })))
1264
                  | _::xs -> loop xs _state  in
1265
                loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.range")
1266
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1267
      | `List ((`String "INDEX_CONSTRAINT")::arg0::[]) ->
1268
          ((function
1269
            | `Assoc xs ->
1270
                let rec loop xs (arg0 as _state) =
1271
                  match xs with
1272
                  | ("ranges",x)::xs ->
1273
                      loop xs
1274
                        ((function
1275
                          | `List xs ->
1276
                              map_bind
1277
                                (fun x  -> vhdl_discrete_range_t_of_yojson x)
1278
                                [] xs
1279
                          | _ ->
1280
                              Result.Error
1281
                                "Vhdl_ast.vhdl_constraint_t.ranges") x)
1282
                  | [] ->
1283
                      arg0 >>=
1284
                        ((fun arg0  ->
1285
                            Result.Ok (IndexConstraint { ranges = arg0 })))
1286
                  | _::xs -> loop xs _state  in
1287
                loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.ranges")
1288
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1289
      | `List ((`String "ARRAY_CONSTRAINT")::arg0::[]) ->
1290
          ((function
1291
            | `Assoc xs ->
1292
                let rec loop xs ((arg0,arg1) as _state) =
1293
                  match xs with
1294
                  | ("ranges",x)::xs ->
1295
                      loop xs
1296
                        (((function
1297
                           | `List xs ->
1298
                               map_bind
1299
                                 (fun x  -> vhdl_discrete_range_t_of_yojson x)
1300
                                 [] xs
1301
                           | _ ->
1302
                               Result.Error
1303
                                 "Vhdl_ast.vhdl_constraint_t.ranges") x),
1304
                          arg1)
1305
                  | ("sub",x)::xs ->
1306
                      loop xs
1307
                        (arg0, ((fun x  -> vhdl_constraint_t_of_yojson x) x))
1308
                  | [] ->
1309
                      arg1 >>=
1310
                        ((fun arg1  ->
1311
                            arg0 >>=
1312
                              (fun arg0  ->
1313
                                 Result.Ok
1314
                                   (ArrayConstraint
1315
                                      { ranges = arg0; sub = arg1 }))))
1316
                  | _::xs -> loop xs _state  in
1317
                loop xs
1318
                  ((Result.Error "Vhdl_ast.vhdl_constraint_t.ranges"),
1319
                    (Result.Error "Vhdl_ast.vhdl_constraint_t.sub"))
1320
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1321
      | `List ((`String "RecordConstraint")::[]) ->
1322
          Result.Ok RecordConstraint
1323
      | `List ((`String "NoConstraint")::[]) -> Result.Ok NoConstraint
1324
      | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")
1325
  [@ocaml.warning "-A"])
1326

    
1327
and (vhdl_definition_t_to_yojson : vhdl_definition_t -> Yojson.Safe.json) =
1328
  ((let open! Ppx_deriving_yojson_runtime in
1329
      function
1330
      | Type arg0 ->
1331
          `List
1332
            [`String "TYPE_DECLARATION";
1333
            (let fields = []  in
1334
             let fields =
1335
               ("definition",
1336
                 ((fun x  -> vhdl_type_t_to_yojson x) arg0.definition))
1337
               :: fields  in
1338
             let fields =
1339
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
1340
               fields  in
1341
             `Assoc fields)]
1342
      | Subtype arg0 ->
1343
          `List
1344
            [`String "SUBTYPE_DECLARATION";
1345
            (let fields = []  in
1346
             let fields =
1347
               ("typ",
1348
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
1349
               :: fields  in
1350
             let fields =
1351
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
1352
               fields  in
1353
             `Assoc fields)])
1354
  [@ocaml.warning "-A"])
1355

    
1356
and (vhdl_definition_t_of_yojson :
1357
      Yojson.Safe.json ->
1358
        vhdl_definition_t Ppx_deriving_yojson_runtime.error_or)
1359
  =
1360
  ((let open! Ppx_deriving_yojson_runtime in
1361
      function
1362
      | `List ((`String "TYPE_DECLARATION")::arg0::[]) ->
1363
          ((function
1364
            | `Assoc xs ->
1365
                let rec loop xs ((arg0,arg1) as _state) =
1366
                  match xs with
1367
                  | ("name",x)::xs ->
1368
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1369
                  | ("definition",x)::xs ->
1370
                      loop xs (arg0, ((fun x  -> vhdl_type_t_of_yojson x) x))
1371
                  | [] ->
1372
                      arg1 >>=
1373
                        ((fun arg1  ->
1374
                            arg0 >>=
1375
                              (fun arg0  ->
1376
                                 Result.Ok
1377
                                   (Type { name = arg0; definition = arg1 }))))
1378
                  | _::xs -> loop xs _state  in
1379
                loop xs
1380
                  ((Result.Error "Vhdl_ast.vhdl_definition_t.name"),
1381
                    (Result.Error "Vhdl_ast.vhdl_definition_t.definition"))
1382
            | _ -> Result.Error "Vhdl_ast.vhdl_definition_t")) arg0
1383
      | `List ((`String "SUBTYPE_DECLARATION")::arg0::[]) ->
1384
          ((function
1385
            | `Assoc xs ->
1386
                let rec loop xs ((arg0,arg1) as _state) =
1387
                  match xs with
1388
                  | ("name",x)::xs ->
1389
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1390
                  | ("typ",x)::xs ->
1391
                      loop xs
1392
                        (arg0,
1393
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
1394
                             x))
1395
                  | [] ->
1396
                      arg1 >>=
1397
                        ((fun arg1  ->
1398
                            arg0 >>=
1399
                              (fun arg0  ->
1400
                                 Result.Ok
1401
                                   (Subtype { name = arg0; typ = arg1 }))))
1402
                  | _::xs -> loop xs _state  in
1403
                loop xs
1404
                  ((Result.Error "Vhdl_ast.vhdl_definition_t.name"),
1405
                    (Result.Error "Vhdl_ast.vhdl_definition_t.typ"))
1406
            | _ -> Result.Error "Vhdl_ast.vhdl_definition_t")) arg0
1407
      | _ -> Result.Error "Vhdl_ast.vhdl_definition_t")
1408
  [@ocaml.warning "-A"])
1409

    
1410
and (vhdl_expr_t_to_yojson : vhdl_expr_t -> Yojson.Safe.json) =
1411
  ((let open! Ppx_deriving_yojson_runtime in
1412
      function
1413
      | Call arg0 ->
1414
          `List [`String "CALL"; ((fun x  -> vhdl_name_t_to_yojson x)) arg0]
1415
      | Cst arg0 ->
1416
          `List
1417
            [`String "CONSTANT_VALUE";
1418
            (let fields = []  in
1419
             let fields =
1420
               if arg0.unit_name = None
1421
               then fields
1422
               else
1423
                 ("unit_name",
1424
                   (((function
1425
                      | None  -> `Null
1426
                      | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1427
                      arg0.unit_name))
1428
                 :: fields
1429
                in
1430
             let fields =
1431
               ("value", ((fun x  -> vhdl_cst_val_t_to_yojson x) arg0.value))
1432
               :: fields  in
1433
             `Assoc fields)]
1434
      | Op arg0 ->
1435
          `List
1436
            [`String "EXPRESSION";
1437
            (let fields = []  in
1438
             let fields =
1439
               if arg0.args = []
1440
               then fields
1441
               else
1442
                 ("args",
1443
                   (((fun x  ->
1444
                        `List
1445
                          (List.map (fun x  -> vhdl_expr_t_to_yojson x) x)))
1446
                      arg0.args))
1447
                 :: fields
1448
                in
1449
             let fields =
1450
               if arg0.id = ""
1451
               then fields
1452
               else
1453
                 ("id",
1454
                   (((fun (x : Ppx_deriving_runtime.string)  -> `String x))
1455
                      arg0.id))
1456
                 :: fields
1457
                in
1458
             `Assoc fields)]
1459
      | IsNull  -> `List [`String "IsNull"]
1460
      | Time arg0 ->
1461
          `List
1462
            [`String "Time";
1463
            (let fields = []  in
1464
             let fields =
1465
               if arg0.phy_unit = ""
1466
               then fields
1467
               else
1468
                 ("phy_unit",
1469
                   (((fun (x : Ppx_deriving_runtime.string)  -> `String x))
1470
                      arg0.phy_unit))
1471
                 :: fields
1472
                in
1473
             let fields =
1474
               ("value",
1475
                 ((fun (x : Ppx_deriving_runtime.int)  -> `Int x) arg0.value))
1476
               :: fields  in
1477
             `Assoc fields)]
1478
      | Sig arg0 ->
1479
          `List
1480
            [`String "Sig";
1481
            (let fields = []  in
1482
             let fields =
1483
               ("att",
1484
                 ((function
1485
                   | None  -> `Null
1486
                   | Some x ->
1487
                       ((fun x  -> vhdl_signal_attributes_t_to_yojson x)) x)
1488
                    arg0.att))
1489
               :: fields  in
1490
             let fields =
1491
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
1492
               fields  in
1493
             `Assoc fields)]
1494
      | SuffixMod arg0 ->
1495
          `List
1496
            [`String "SuffixMod";
1497
            (let fields = []  in
1498
             let fields =
1499
               ("selection",
1500
                 ((fun x  -> vhdl_suffix_selection_t_to_yojson x)
1501
                    arg0.selection))
1502
               :: fields  in
1503
             let fields =
1504
               ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.expr)) ::
1505
               fields  in
1506
             `Assoc fields)]
1507
      | Aggregate arg0 ->
1508
          `List
1509
            [`String "AGGREGATE";
1510
            (let fields = []  in
1511
             let fields =
1512
               ("elems",
1513
                 ((fun x  ->
1514
                     `List
1515
                       (List.map (fun x  -> vhdl_element_assoc_t_to_yojson x)
1516
                          x)) arg0.elems))
1517
               :: fields  in
1518
             `Assoc fields)]
1519
      | Others  -> `List [`String "OTHERS"])
1520
  [@ocaml.warning "-A"])
1521

    
1522
and (vhdl_expr_t_of_yojson :
1523
      Yojson.Safe.json -> vhdl_expr_t Ppx_deriving_yojson_runtime.error_or)
1524
  =
1525
  ((let open! Ppx_deriving_yojson_runtime in
1526
      function
1527
      | `List ((`String "CALL")::arg0::[]) ->
1528
          ((fun x  -> vhdl_name_t_of_yojson x) arg0) >>=
1529
            ((fun arg0  -> Result.Ok (Call arg0)))
1530
      | `List ((`String "CONSTANT_VALUE")::arg0::[]) ->
1531
          ((function
1532
            | `Assoc xs ->
1533
                let rec loop xs ((arg0,arg1) as _state) =
1534
                  match xs with
1535
                  | ("value",x)::xs ->
1536
                      loop xs
1537
                        (((fun x  -> vhdl_cst_val_t_of_yojson x) x), arg1)
1538
                  | ("unit_name",x)::xs ->
1539
                      loop xs
1540
                        (arg0,
1541
                          ((function
1542
                            | `Null -> Result.Ok None
1543
                            | x ->
1544
                                ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1545
                                  ((fun x  -> Result.Ok (Some x)))) x))
1546
                  | [] ->
1547
                      arg1 >>=
1548
                        ((fun arg1  ->
1549
                            arg0 >>=
1550
                              (fun arg0  ->
1551
                                 Result.Ok
1552
                                   (Cst { value = arg0; unit_name = arg1 }))))
1553
                  | _::xs -> loop xs _state  in
1554
                loop xs
1555
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.value"),
1556
                    (Result.Ok None))
1557
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1558
      | `List ((`String "EXPRESSION")::arg0::[]) ->
1559
          ((function
1560
            | `Assoc xs ->
1561
                let rec loop xs ((arg0,arg1) as _state) =
1562
                  match xs with
1563
                  | ("id",x)::xs ->
1564
                      loop xs
1565
                        (((function
1566
                           | `String x -> Result.Ok x
1567
                           | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.id") x),
1568
                          arg1)
1569
                  | ("args",x)::xs ->
1570
                      loop xs
1571
                        (arg0,
1572
                          ((function
1573
                            | `List xs ->
1574
                                map_bind (fun x  -> vhdl_expr_t_of_yojson x)
1575
                                  [] xs
1576
                            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.args")
1577
                             x))
1578
                  | [] ->
1579
                      arg1 >>=
1580
                        ((fun arg1  ->
1581
                            arg0 >>=
1582
                              (fun arg0  ->
1583
                                 Result.Ok (Op { id = arg0; args = arg1 }))))
1584
                  | _::xs -> loop xs _state  in
1585
                loop xs ((Result.Ok ""), (Result.Ok []))
1586
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1587
      | `List ((`String "IsNull")::[]) -> Result.Ok IsNull
1588
      | `List ((`String "Time")::arg0::[]) ->
1589
          ((function
1590
            | `Assoc xs ->
1591
                let rec loop xs ((arg0,arg1) as _state) =
1592
                  match xs with
1593
                  | ("value",x)::xs ->
1594
                      loop xs
1595
                        (((function
1596
                           | `Int x -> Result.Ok x
1597
                           | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.value")
1598
                            x), arg1)
1599
                  | ("phy_unit",x)::xs ->
1600
                      loop xs
1601
                        (arg0,
1602
                          ((function
1603
                            | `String x -> Result.Ok x
1604
                            | _ ->
1605
                                Result.Error "Vhdl_ast.vhdl_expr_t.phy_unit")
1606
                             x))
1607
                  | [] ->
1608
                      arg1 >>=
1609
                        ((fun arg1  ->
1610
                            arg0 >>=
1611
                              (fun arg0  ->
1612
                                 Result.Ok
1613
                                   (Time { value = arg0; phy_unit = arg1 }))))
1614
                  | _::xs -> loop xs _state  in
1615
                loop xs
1616
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.value"),
1617
                    (Result.Ok ""))
1618
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1619
      | `List ((`String "Sig")::arg0::[]) ->
1620
          ((function
1621
            | `Assoc xs ->
1622
                let rec loop xs ((arg0,arg1) as _state) =
1623
                  match xs with
1624
                  | ("name",x)::xs ->
1625
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1626
                  | ("att",x)::xs ->
1627
                      loop xs
1628
                        (arg0,
1629
                          ((function
1630
                            | `Null -> Result.Ok None
1631
                            | x ->
1632
                                ((fun x  ->
1633
                                    vhdl_signal_attributes_t_of_yojson x) x)
1634
                                  >>= ((fun x  -> Result.Ok (Some x)))) x))
1635
                  | [] ->
1636
                      arg1 >>=
1637
                        ((fun arg1  ->
1638
                            arg0 >>=
1639
                              (fun arg0  ->
1640
                                 Result.Ok (Sig { name = arg0; att = arg1 }))))
1641
                  | _::xs -> loop xs _state  in
1642
                loop xs
1643
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.name"),
1644
                    (Result.Error "Vhdl_ast.vhdl_expr_t.att"))
1645
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1646
      | `List ((`String "SuffixMod")::arg0::[]) ->
1647
          ((function
1648
            | `Assoc xs ->
1649
                let rec loop xs ((arg0,arg1) as _state) =
1650
                  match xs with
1651
                  | ("expr",x)::xs ->
1652
                      loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
1653
                  | ("selection",x)::xs ->
1654
                      loop xs
1655
                        (arg0,
1656
                          ((fun x  -> vhdl_suffix_selection_t_of_yojson x) x))
1657
                  | [] ->
1658
                      arg1 >>=
1659
                        ((fun arg1  ->
1660
                            arg0 >>=
1661
                              (fun arg0  ->
1662
                                 Result.Ok
1663
                                   (SuffixMod
1664
                                      { expr = arg0; selection = arg1 }))))
1665
                  | _::xs -> loop xs _state  in
1666
                loop xs
1667
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.expr"),
1668
                    (Result.Error "Vhdl_ast.vhdl_expr_t.selection"))
1669
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1670
      | `List ((`String "AGGREGATE")::arg0::[]) ->
1671
          ((function
1672
            | `Assoc xs ->
1673
                let rec loop xs (arg0 as _state) =
1674
                  match xs with
1675
                  | ("elems",x)::xs ->
1676
                      loop xs
1677
                        ((function
1678
                          | `List xs ->
1679
                              map_bind
1680
                                (fun x  -> vhdl_element_assoc_t_of_yojson x)
1681
                                [] xs
1682
                          | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.elems") x)
1683
                  | [] ->
1684
                      arg0 >>=
1685
                        ((fun arg0  -> Result.Ok (Aggregate { elems = arg0 })))
1686
                  | _::xs -> loop xs _state  in
1687
                loop xs (Result.Error "Vhdl_ast.vhdl_expr_t.elems")
1688
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1689
      | `List ((`String "OTHERS")::[]) -> Result.Ok Others
1690
      | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")
1691
  [@ocaml.warning "-A"])
1692

    
1693
and (vhdl_name_t_to_yojson : vhdl_name_t -> Yojson.Safe.json) =
1694
  ((let open! Ppx_deriving_yojson_runtime in
1695
      function
1696
      | Simple arg0 ->
1697
          `List
1698
            [`String "SIMPLE_NAME";
1699
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
1700
      | Identifier arg0 ->
1701
          `List
1702
            [`String "IDENTIFIER";
1703
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
1704
      | Selected arg0 ->
1705
          `List
1706
            [`String "SELECTED_NAME";
1707
            ((fun x  ->
1708
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0]
1709
      | Index arg0 ->
1710
          `List
1711
            [`String "INDEXED_NAME";
1712
            (let fields = []  in
1713
             let fields =
1714
               ("exprs",
1715
                 ((fun x  ->
1716
                     `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
1717
                    arg0.exprs))
1718
               :: fields  in
1719
             let fields =
1720
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1721
               fields  in
1722
             `Assoc fields)]
1723
      | Slice arg0 ->
1724
          `List
1725
            [`String "SLICE_NAME";
1726
            (let fields = []  in
1727
             let fields =
1728
               ("range",
1729
                 ((fun x  -> vhdl_discrete_range_t_to_yojson x) arg0.range))
1730
               :: fields  in
1731
             let fields =
1732
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1733
               fields  in
1734
             `Assoc fields)]
1735
      | Attribute arg0 ->
1736
          `List
1737
            [`String "ATTRIBUTE_NAME";
1738
            (let fields = []  in
1739
             let fields =
1740
               if arg0.expr = IsNull
1741
               then fields
1742
               else
1743
                 ("expr", (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.expr))
1744
                 :: fields
1745
                in
1746
             let fields =
1747
               ("designator",
1748
                 ((fun x  -> vhdl_name_t_to_yojson x) arg0.designator))
1749
               :: fields  in
1750
             let fields =
1751
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1752
               fields  in
1753
             `Assoc fields)]
1754
      | Function arg0 ->
1755
          `List
1756
            [`String "FUNCTION_CALL";
1757
            (let fields = []  in
1758
             let fields =
1759
               ("assoc_list",
1760
                 ((fun x  ->
1761
                     `List
1762
                       (List.map (fun x  -> vhdl_assoc_element_t_to_yojson x)
1763
                          x)) arg0.assoc_list))
1764
               :: fields  in
1765
             let fields =
1766
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1767
               fields  in
1768
             `Assoc fields)]
1769
      | NoName  -> `List [`String "NoName"])
1770
  [@ocaml.warning "-A"])
1771

    
1772
and (vhdl_name_t_of_yojson :
1773
      Yojson.Safe.json -> vhdl_name_t Ppx_deriving_yojson_runtime.error_or)
1774
  =
1775
  ((let open! Ppx_deriving_yojson_runtime in
1776
      function
1777
      | `List ((`String "SIMPLE_NAME")::arg0::[]) ->
1778
          ((function
1779
            | `String x -> Result.Ok x
1780
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
1781
            ((fun arg0  -> Result.Ok (Simple arg0)))
1782
      | `List ((`String "IDENTIFIER")::arg0::[]) ->
1783
          ((function
1784
            | `String x -> Result.Ok x
1785
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
1786
            ((fun arg0  -> Result.Ok (Identifier arg0)))
1787
      | `List ((`String "SELECTED_NAME")::arg0::[]) ->
1788
          ((function
1789
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
1790
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
1791
            ((fun arg0  -> Result.Ok (Selected arg0)))
1792
      | `List ((`String "INDEXED_NAME")::arg0::[]) ->
1793
          ((function
1794
            | `Assoc xs ->
1795
                let rec loop xs ((arg0,arg1) as _state) =
1796
                  match xs with
1797
                  | ("id",x)::xs ->
1798
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1799
                  | ("exprs",x)::xs ->
1800
                      loop xs
1801
                        (arg0,
1802
                          ((function
1803
                            | `List xs ->
1804
                                map_bind (fun x  -> vhdl_expr_t_of_yojson x)
1805
                                  [] xs
1806
                            | _ -> Result.Error "Vhdl_ast.vhdl_name_t.exprs")
1807
                             x))
1808
                  | [] ->
1809
                      arg1 >>=
1810
                        ((fun arg1  ->
1811
                            arg0 >>=
1812
                              (fun arg0  ->
1813
                                 Result.Ok
1814
                                   (Index { id = arg0; exprs = arg1 }))))
1815
                  | _::xs -> loop xs _state  in
1816
                loop xs
1817
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1818
                    (Result.Error "Vhdl_ast.vhdl_name_t.exprs"))
1819
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1820
      | `List ((`String "SLICE_NAME")::arg0::[]) ->
1821
          ((function
1822
            | `Assoc xs ->
1823
                let rec loop xs ((arg0,arg1) as _state) =
1824
                  match xs with
1825
                  | ("id",x)::xs ->
1826
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1827
                  | ("range",x)::xs ->
1828
                      loop xs
1829
                        (arg0,
1830
                          ((fun x  -> vhdl_discrete_range_t_of_yojson x) x))
1831
                  | [] ->
1832
                      arg1 >>=
1833
                        ((fun arg1  ->
1834
                            arg0 >>=
1835
                              (fun arg0  ->
1836
                                 Result.Ok
1837
                                   (Slice { id = arg0; range = arg1 }))))
1838
                  | _::xs -> loop xs _state  in
1839
                loop xs
1840
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1841
                    (Result.Error "Vhdl_ast.vhdl_name_t.range"))
1842
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1843
      | `List ((`String "ATTRIBUTE_NAME")::arg0::[]) ->
1844
          ((function
1845
            | `Assoc xs ->
1846
                let rec loop xs ((arg0,arg1,arg2) as _state) =
1847
                  match xs with
1848
                  | ("id",x)::xs ->
1849
                      loop xs
1850
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
1851
                  | ("designator",x)::xs ->
1852
                      loop xs
1853
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
1854
                  | ("expr",x)::xs ->
1855
                      loop xs
1856
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
1857
                  | [] ->
1858
                      arg2 >>=
1859
                        ((fun arg2  ->
1860
                            arg1 >>=
1861
                              (fun arg1  ->
1862
                                 arg0 >>=
1863
                                   (fun arg0  ->
1864
                                      Result.Ok
1865
                                        (Attribute
1866
                                           {
1867
                                             id = arg0;
1868
                                             designator = arg1;
1869
                                             expr = arg2
1870
                                           })))))
1871
                  | _::xs -> loop xs _state  in
1872
                loop xs
1873
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1874
                    (Result.Error "Vhdl_ast.vhdl_name_t.designator"),
1875
                    (Result.Ok IsNull))
1876
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1877
      | `List ((`String "FUNCTION_CALL")::arg0::[]) ->
1878
          ((function
1879
            | `Assoc xs ->
1880
                let rec loop xs ((arg0,arg1) as _state) =
1881
                  match xs with
1882
                  | ("id",x)::xs ->
1883
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1884
                  | ("assoc_list",x)::xs ->
1885
                      loop xs
1886
                        (arg0,
1887
                          ((function
1888
                            | `List xs ->
1889
                                map_bind
1890
                                  (fun x  -> vhdl_assoc_element_t_of_yojson x)
1891
                                  [] xs
1892
                            | _ ->
1893
                                Result.Error
1894
                                  "Vhdl_ast.vhdl_name_t.assoc_list") x))
1895
                  | [] ->
1896
                      arg1 >>=
1897
                        ((fun arg1  ->
1898
                            arg0 >>=
1899
                              (fun arg0  ->
1900
                                 Result.Ok
1901
                                   (Function { id = arg0; assoc_list = arg1 }))))
1902
                  | _::xs -> loop xs _state  in
1903
                loop xs
1904
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1905
                    (Result.Error "Vhdl_ast.vhdl_name_t.assoc_list"))
1906
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1907
      | `List ((`String "NoName")::[]) -> Result.Ok NoName
1908
      | _ -> Result.Error "Vhdl_ast.vhdl_name_t")
1909
  [@ocaml.warning "-A"])
1910

    
1911
and (vhdl_assoc_element_t_to_yojson :
1912
      vhdl_assoc_element_t -> Yojson.Safe.json)
1913
  =
1914
  ((let open! Ppx_deriving_yojson_runtime in
1915
      fun x  ->
1916
        let fields = []  in
1917
        let fields =
1918
          if x.actual_expr = None
1919
          then fields
1920
          else
1921
            ("actual_expr",
1922
              (((function
1923
                 | None  -> `Null
1924
                 | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x))
1925
                 x.actual_expr))
1926
            :: fields
1927
           in
1928
        let fields =
1929
          if x.actual_designator = None
1930
          then fields
1931
          else
1932
            ("actual_designator",
1933
              (((function
1934
                 | None  -> `Null
1935
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1936
                 x.actual_designator))
1937
            :: fields
1938
           in
1939
        let fields =
1940
          if x.actual_name = None
1941
          then fields
1942
          else
1943
            ("actual_name",
1944
              (((function
1945
                 | None  -> `Null
1946
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1947
                 x.actual_name))
1948
            :: fields
1949
           in
1950
        let fields =
1951
          if x.formal_arg = None
1952
          then fields
1953
          else
1954
            ("formal_arg",
1955
              (((function
1956
                 | None  -> `Null
1957
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1958
                 x.formal_arg))
1959
            :: fields
1960
           in
1961
        let fields =
1962
          if x.formal_name = None
1963
          then fields
1964
          else
1965
            ("formal_name",
1966
              (((function
1967
                 | None  -> `Null
1968
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1969
                 x.formal_name))
1970
            :: fields
1971
           in
1972
        `Assoc fields)
1973
  [@ocaml.warning "-A"])
1974

    
1975
and (vhdl_assoc_element_t_of_yojson :
1976
      Yojson.Safe.json ->
1977
        vhdl_assoc_element_t Ppx_deriving_yojson_runtime.error_or)
1978
  =
1979
  ((let open! Ppx_deriving_yojson_runtime in
1980
      function
1981
      | `Assoc xs ->
1982
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
1983
            match xs with
1984
            | ("formal_name",x)::xs ->
1985
                loop xs
1986
                  (((function
1987
                     | `Null -> Result.Ok None
1988
                     | x ->
1989
                         ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1990
                           ((fun x  -> Result.Ok (Some x)))) x), arg1, arg2,
1991
                    arg3, arg4)
1992
            | ("formal_arg",x)::xs ->
1993
                loop xs
1994
                  (arg0,
1995
                    ((function
1996
                      | `Null -> Result.Ok None
1997
                      | x ->
1998
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1999
                            ((fun x  -> Result.Ok (Some x)))) x), arg2, arg3,
2000
                    arg4)
2001
            | ("actual_name",x)::xs ->
2002
                loop xs
2003
                  (arg0, arg1,
2004
                    ((function
2005
                      | `Null -> Result.Ok None
2006
                      | x ->
2007
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
2008
                            ((fun x  -> Result.Ok (Some x)))) x), arg3, arg4)
2009
            | ("actual_designator",x)::xs ->
2010
                loop xs
2011
                  (arg0, arg1, arg2,
2012
                    ((function
2013
                      | `Null -> Result.Ok None
2014
                      | x ->
2015
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
2016
                            ((fun x  -> Result.Ok (Some x)))) x), arg4)
2017
            | ("actual_expr",x)::xs ->
2018
                loop xs
2019
                  (arg0, arg1, arg2, arg3,
2020
                    ((function
2021
                      | `Null -> Result.Ok None
2022
                      | x ->
2023
                          ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
2024
                            ((fun x  -> Result.Ok (Some x)))) x))
2025
            | [] ->
2026
                arg4 >>=
2027
                  ((fun arg4  ->
2028
                      arg3 >>=
2029
                        (fun arg3  ->
2030
                           arg2 >>=
2031
                             (fun arg2  ->
2032
                                arg1 >>=
2033
                                  (fun arg1  ->
2034
                                     arg0 >>=
2035
                                       (fun arg0  ->
2036
                                          Result.Ok
2037
                                            {
2038
                                              formal_name = arg0;
2039
                                              formal_arg = arg1;
2040
                                              actual_name = arg2;
2041
                                              actual_designator = arg3;
2042
                                              actual_expr = arg4
2043
                                            }))))))
2044
            | _::xs -> loop xs _state  in
2045
          loop xs
2046
            ((Result.Ok (Some NoName)), (Result.Ok (Some NoName)),
2047
              (Result.Ok (Some NoName)), (Result.Ok (Some NoName)),
2048
              (Result.Ok (Some IsNull)))
2049
      | _ -> Result.Error "Vhdl_ast.vhdl_assoc_element_t")
2050
  [@ocaml.warning "-A"])
2051

    
2052
and (vhdl_element_assoc_t_to_yojson :
2053
      vhdl_element_assoc_t -> Yojson.Safe.json)
2054
  =
2055
  ((let open! Ppx_deriving_yojson_runtime in
2056
      fun x  ->
2057
        let fields = []  in
2058
        let fields = ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) x.expr))
2059
          :: fields  in
2060
        let fields =
2061
          ("choices",
2062
            ((fun x  ->
2063
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
2064
               x.choices))
2065
          :: fields  in
2066
        `Assoc fields)
2067
  [@ocaml.warning "-A"])
2068

    
2069
and (vhdl_element_assoc_t_of_yojson :
2070
      Yojson.Safe.json ->
2071
        vhdl_element_assoc_t Ppx_deriving_yojson_runtime.error_or)
2072
  =
2073
  ((let open! Ppx_deriving_yojson_runtime in
2074
      function
2075
      | `Assoc xs ->
2076
          let rec loop xs ((arg0,arg1) as _state) =
2077
            match xs with
2078
            | ("choices",x)::xs ->
2079
                loop xs
2080
                  (((function
2081
                     | `List xs ->
2082
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
2083
                     | _ ->
2084
                         Result.Error "Vhdl_ast.vhdl_element_assoc_t.choices")
2085
                      x), arg1)
2086
            | ("expr",x)::xs ->
2087
                loop xs (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x))
2088
            | [] ->
2089
                arg1 >>=
2090
                  ((fun arg1  ->
2091
                      arg0 >>=
2092
                        (fun arg0  ->
2093
                           Result.Ok { choices = arg0; expr = arg1 })))
2094
            | _::xs -> loop xs _state  in
2095
          loop xs
2096
            ((Result.Error "Vhdl_ast.vhdl_element_assoc_t.choices"),
2097
              (Result.Error "Vhdl_ast.vhdl_element_assoc_t.expr"))
2098
      | _ -> Result.Error "Vhdl_ast.vhdl_element_assoc_t")
2099
  [@ocaml.warning "-A"])
2100

    
2101
and (vhdl_array_attributes_t_to_yojson :
2102
      vhdl_array_attributes_t -> Yojson.Safe.json)
2103
  =
2104
  ((let open! Ppx_deriving_yojson_runtime in
2105
      function
2106
      | AAttInt arg0 ->
2107
          `List
2108
            [`String "AAttInt";
2109
            (let fields = []  in
2110
             let fields =
2111
               ("arg",
2112
                 ((fun (x : Ppx_deriving_runtime.int)  -> `Int x) arg0.arg))
2113
               :: fields  in
2114
             let fields =
2115
               ("id",
2116
                 ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2117
                    arg0.id))
2118
               :: fields  in
2119
             `Assoc fields)]
2120
      | AAttAscending  -> `List [`String "AAttAscending"])
2121
  [@ocaml.warning "-A"])
2122

    
2123
and (vhdl_array_attributes_t_of_yojson :
2124
      Yojson.Safe.json ->
2125
        vhdl_array_attributes_t Ppx_deriving_yojson_runtime.error_or)
2126
  =
2127
  ((let open! Ppx_deriving_yojson_runtime in
2128
      function
2129
      | `List ((`String "AAttInt")::arg0::[]) ->
2130
          ((function
2131
            | `Assoc xs ->
2132
                let rec loop xs ((arg0,arg1) as _state) =
2133
                  match xs with
2134
                  | ("id",x)::xs ->
2135
                      loop xs
2136
                        (((function
2137
                           | `String x -> Result.Ok x
2138
                           | _ ->
2139
                               Result.Error
2140
                                 "Vhdl_ast.vhdl_array_attributes_t.id") x),
2141
                          arg1)
2142
                  | ("arg",x)::xs ->
2143
                      loop xs
2144
                        (arg0,
2145
                          ((function
2146
                            | `Int x -> Result.Ok x
2147
                            | _ ->
2148
                                Result.Error
2149
                                  "Vhdl_ast.vhdl_array_attributes_t.arg") x))
2150
                  | [] ->
2151
                      arg1 >>=
2152
                        ((fun arg1  ->
2153
                            arg0 >>=
2154
                              (fun arg0  ->
2155
                                 Result.Ok
2156
                                   (AAttInt { id = arg0; arg = arg1 }))))
2157
                  | _::xs -> loop xs _state  in
2158
                loop xs
2159
                  ((Result.Error "Vhdl_ast.vhdl_array_attributes_t.id"),
2160
                    (Result.Error "Vhdl_ast.vhdl_array_attributes_t.arg"))
2161
            | _ -> Result.Error "Vhdl_ast.vhdl_array_attributes_t")) arg0
2162
      | `List ((`String "AAttAscending")::[]) -> Result.Ok AAttAscending
2163
      | _ -> Result.Error "Vhdl_ast.vhdl_array_attributes_t")
2164
  [@ocaml.warning "-A"])
2165

    
2166
and (vhdl_signal_attributes_t_to_yojson :
2167
      vhdl_signal_attributes_t -> Yojson.Safe.json)
2168
  =
2169
  ((let open! Ppx_deriving_yojson_runtime in
2170
      function
2171
      | SigAtt arg0 ->
2172
          `List
2173
            [`String "SigAtt";
2174
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0])
2175
  [@ocaml.warning "-A"])
2176

    
2177
and (vhdl_signal_attributes_t_of_yojson :
2178
      Yojson.Safe.json ->
2179
        vhdl_signal_attributes_t Ppx_deriving_yojson_runtime.error_or)
2180
  =
2181
  ((let open! Ppx_deriving_yojson_runtime in
2182
      function
2183
      | `List ((`String "SigAtt")::arg0::[]) ->
2184
          ((function
2185
            | `String x -> Result.Ok x
2186
            | _ -> Result.Error "Vhdl_ast.vhdl_signal_attributes_t") arg0)
2187
            >>= ((fun arg0  -> Result.Ok (SigAtt arg0)))
2188
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_attributes_t")
2189
  [@ocaml.warning "-A"])
2190

    
2191
and (vhdl_string_attributes_t_to_yojson :
2192
      vhdl_string_attributes_t -> Yojson.Safe.json)
2193
  =
2194
  ((let open! Ppx_deriving_yojson_runtime in
2195
      function
2196
      | StringAtt arg0 ->
2197
          `List
2198
            [`String "StringAtt";
2199
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0])
2200
  [@ocaml.warning "-A"])
2201

    
2202
and (vhdl_string_attributes_t_of_yojson :
2203
      Yojson.Safe.json ->
2204
        vhdl_string_attributes_t Ppx_deriving_yojson_runtime.error_or)
2205
  =
2206
  ((let open! Ppx_deriving_yojson_runtime in
2207
      function
2208
      | `List ((`String "StringAtt")::arg0::[]) ->
2209
          ((function
2210
            | `String x -> Result.Ok x
2211
            | _ -> Result.Error "Vhdl_ast.vhdl_string_attributes_t") arg0)
2212
            >>= ((fun arg0  -> Result.Ok (StringAtt arg0)))
2213
      | _ -> Result.Error "Vhdl_ast.vhdl_string_attributes_t")
2214
  [@ocaml.warning "-A"])
2215

    
2216
and (vhdl_suffix_selection_t_to_yojson :
2217
      vhdl_suffix_selection_t -> Yojson.Safe.json)
2218
  =
2219
  ((let open! Ppx_deriving_yojson_runtime in
2220
      function
2221
      | Idx arg0 ->
2222
          `List
2223
            [`String "Idx";
2224
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0]
2225
      | SuffixRange (arg0,arg1) ->
2226
          `List
2227
            [`String "SuffixRange";
2228
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0;
2229
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1])
2230
  [@ocaml.warning "-A"])
2231

    
2232
and (vhdl_suffix_selection_t_of_yojson :
2233
      Yojson.Safe.json ->
2234
        vhdl_suffix_selection_t Ppx_deriving_yojson_runtime.error_or)
2235
  =
2236
  ((let open! Ppx_deriving_yojson_runtime in
2237
      function
2238
      | `List ((`String "Idx")::arg0::[]) ->
2239
          ((function
2240
            | `Int x -> Result.Ok x
2241
            | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") arg0) >>=
2242
            ((fun arg0  -> Result.Ok (Idx arg0)))
2243
      | `List ((`String "SuffixRange")::arg0::arg1::[]) ->
2244
          ((function
2245
            | `Int x -> Result.Ok x
2246
            | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") arg1) >>=
2247
            ((fun arg1  ->
2248
                ((function
2249
                  | `Int x -> Result.Ok x
2250
                  | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t")
2251
                   arg0)
2252
                  >>= (fun arg0  -> Result.Ok (SuffixRange (arg0, arg1)))))
2253
      | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t")
2254
  [@ocaml.warning "-A"])
2255

    
2256
type 'basetype vhdl_type_attributes_t =
2257
  | TAttNoArg of {
2258
  id: string } 
2259
  | TAttIntArg of {
2260
  id: string ;
2261
  arg: int } 
2262
  | TAttValArg of {
2263
  id: string ;
2264
  arg: 'basetype } 
2265
  | TAttStringArg of {
2266
  id: string ;
2267
  arg: string } 
2268

    
2269
(* TODO *)
2270
let rec pp_vhdl_type_attributes_t
2271
  =
2272
  ((let open! Ppx_deriving_runtime in
2273
      fun poly_basetype  ->
2274
        fun fmt  ->
2275
          function
2276
          | TAttNoArg { id = aid } ->
2277
              (Format.fprintf fmt "@[<2>TAttNoArg {@,";
2278
               (Format.fprintf fmt "@[%s =@ " "id";
2279
                (Format.fprintf fmt "%S") aid;
2280
                Format.fprintf fmt "@]");
2281
               Format.fprintf fmt "@]}")
2282
          | TAttIntArg { id = aid; arg = aarg } ->
2283
              (Format.fprintf fmt "@[<2>TAttIntArg {@,";
2284
               ((Format.fprintf fmt "@[%s =@ " "id";
2285
                 (Format.fprintf fmt "%S") aid;
2286
                 Format.fprintf fmt "@]");
2287
                Format.fprintf fmt ";@ ";
2288
                Format.fprintf fmt "@[%s =@ " "arg";
2289
                (Format.fprintf fmt "%d") aarg;
2290
                Format.fprintf fmt "@]");
2291
               Format.fprintf fmt "@]}")
2292
          | TAttValArg { id = aid; arg = aarg } ->
2293
              (Format.fprintf fmt "@[<2>TAttValArg {@,";
2294
               ((Format.fprintf fmt "@[%s =@ " "id";
2295
                 (Format.fprintf fmt "%S") aid;
2296
                 Format.fprintf fmt "@]");
2297
                Format.fprintf fmt ";@ ";
2298
                Format.fprintf fmt "@[%s =@ " "arg";
2299
                (poly_basetype fmt) aarg;
2300
                Format.fprintf fmt "@]");
2301
               Format.fprintf fmt "@]}")
2302
          | TAttStringArg { id = aid; arg = aarg } ->
2303
              (Format.fprintf fmt "@[<2>TAttStringArg {@,";
2304
               ((Format.fprintf fmt "@[%s =@ " "id";
2305
                 (Format.fprintf fmt "%S") aid;
2306
                 Format.fprintf fmt "@]");
2307
                Format.fprintf fmt ";@ ";
2308
                Format.fprintf fmt "@[%s =@ " "arg";
2309
                (Format.fprintf fmt "%S") aarg;
2310
                Format.fprintf fmt "@]");
2311
               Format.fprintf fmt "@]}"))
2312
  [@ocaml.warning "-A"])
2313

    
2314
and show_vhdl_type_attributes_t  =
2315
  fun poly_basetype  ->
2316
    fun x  ->
2317
      Format.asprintf "%a" (pp_vhdl_type_attributes_t poly_basetype) x
2318

    
2319
let rec vhdl_type_attributes_t_to_yojson :
2320
  'basetype .
2321
    ('basetype -> Yojson.Safe.json) ->
2322
      'basetype vhdl_type_attributes_t -> Yojson.Safe.json
2323
  =
2324
  fun poly_basetype  ->
2325
    ((let open! Ppx_deriving_yojson_runtime in
2326
        function
2327
        | TAttNoArg arg0 ->
2328
            `List
2329
              [`String "TAttNoArg";
2330
              (let fields = []  in
2331
               let fields =
2332
                 ("id",
2333
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2334
                      arg0.id))
2335
                 :: fields  in
2336
               `Assoc fields)]
2337
        | TAttIntArg arg0 ->
2338
            `List
2339
              [`String "TAttIntArg";
2340
              (let fields = []  in
2341
               let fields =
2342
                 ("arg",
2343
                   ((fun (x : Ppx_deriving_runtime.int)  -> `Int x) arg0.arg))
2344
                 :: fields  in
2345
               let fields =
2346
                 ("id",
2347
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2348
                      arg0.id))
2349
                 :: fields  in
2350
               `Assoc fields)]
2351
        | TAttValArg arg0 ->
2352
            `List
2353
              [`String "TAttValArg";
2354
              (let fields = []  in
2355
               let fields =
2356
                 ("arg", ((poly_basetype : _ -> Yojson.Safe.json) arg0.arg))
2357
                 :: fields  in
2358
               let fields =
2359
                 ("id",
2360
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2361
                      arg0.id))
2362
                 :: fields  in
2363
               `Assoc fields)]
2364
        | TAttStringArg arg0 ->
2365
            `List
2366
              [`String "TAttStringArg";
2367
              (let fields = []  in
2368
               let fields =
2369
                 ("arg",
2370
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2371
                      arg0.arg))
2372
                 :: fields  in
2373
               let fields =
2374
                 ("id",
2375
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2376
                      arg0.id))
2377
                 :: fields  in
2378
               `Assoc fields)])
2379
    [@ocaml.warning "-A"])
2380

    
2381
and vhdl_type_attributes_t_of_yojson :
2382
  'basetype .
2383
    (Yojson.Safe.json -> 'basetype Ppx_deriving_yojson_runtime.error_or) ->
2384
      Yojson.Safe.json ->
2385
        'basetype vhdl_type_attributes_t Ppx_deriving_yojson_runtime.error_or
2386
  =
2387
  fun poly_basetype  ->
2388
    ((let open! Ppx_deriving_yojson_runtime in
2389
        function
2390
        | `List ((`String "TAttNoArg")::arg0::[]) ->
2391
            ((function
2392
              | `Assoc xs ->
2393
                  let rec loop xs (arg0 as _state) =
2394
                    match xs with
2395
                    | ("id",x)::xs ->
2396
                        loop xs
2397
                          ((function
2398
                            | `String x -> Result.Ok x
2399
                            | _ ->
2400
                                Result.Error
2401
                                  "Vhdl_ast.vhdl_type_attributes_t.id") x)
2402
                    | [] ->
2403
                        arg0 >>=
2404
                          ((fun arg0  -> Result.Ok (TAttNoArg { id = arg0 })))
2405
                    | _::xs -> loop xs _state  in
2406
                  loop xs (Result.Error "Vhdl_ast.vhdl_type_attributes_t.id")
2407
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2408
        | `List ((`String "TAttIntArg")::arg0::[]) ->
2409
            ((function
2410
              | `Assoc xs ->
2411
                  let rec loop xs ((arg0,arg1) as _state) =
2412
                    match xs with
2413
                    | ("id",x)::xs ->
2414
                        loop xs
2415
                          (((function
2416
                             | `String x -> Result.Ok x
2417
                             | _ ->
2418
                                 Result.Error
2419
                                   "Vhdl_ast.vhdl_type_attributes_t.id") x),
2420
                            arg1)
2421
                    | ("arg",x)::xs ->
2422
                        loop xs
2423
                          (arg0,
2424
                            ((function
2425
                              | `Int x -> Result.Ok x
2426
                              | _ ->
2427
                                  Result.Error
2428
                                    "Vhdl_ast.vhdl_type_attributes_t.arg") x))
2429
                    | [] ->
2430
                        arg1 >>=
2431
                          ((fun arg1  ->
2432
                              arg0 >>=
2433
                                (fun arg0  ->
2434
                                   Result.Ok
2435
                                     (TAttIntArg { id = arg0; arg = arg1 }))))
2436
                    | _::xs -> loop xs _state  in
2437
                  loop xs
2438
                    ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
2439
                      (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
2440
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2441
        | `List ((`String "TAttValArg")::arg0::[]) ->
2442
            ((function
2443
              | `Assoc xs ->
2444
                  let rec loop xs ((arg0,arg1) as _state) =
2445
                    match xs with
2446
                    | ("id",x)::xs ->
2447
                        loop xs
2448
                          (((function
2449
                             | `String x -> Result.Ok x
2450
                             | _ ->
2451
                                 Result.Error
2452
                                   "Vhdl_ast.vhdl_type_attributes_t.id") x),
2453
                            arg1)
2454
                    | ("arg",x)::xs ->
2455
                        loop xs
2456
                          (arg0,
2457
                            ((poly_basetype : Yojson.Safe.json -> _ error_or)
2458
                               x))
2459
                    | [] ->
2460
                        arg1 >>=
2461
                          ((fun arg1  ->
2462
                              arg0 >>=
2463
                                (fun arg0  ->
2464
                                   Result.Ok
2465
                                     (TAttValArg { id = arg0; arg = arg1 }))))
2466
                    | _::xs -> loop xs _state  in
2467
                  loop xs
2468
                    ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
2469
                      (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
2470
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2471
        | `List ((`String "TAttStringArg")::arg0::[]) ->
2472
            ((function
2473
              | `Assoc xs ->
2474
                  let rec loop xs ((arg0,arg1) as _state) =
2475
                    match xs with
2476
                    | ("id",x)::xs ->
2477
                        loop xs
2478
                          (((function
2479
                             | `String x -> Result.Ok x
2480
                             | _ ->
2481
                                 Result.Error
2482
                                   "Vhdl_ast.vhdl_type_attributes_t.id") x),
2483
                            arg1)
2484
                    | ("arg",x)::xs ->
2485
                        loop xs
2486
                          (arg0,
2487
                            ((function
2488
                              | `String x -> Result.Ok x
2489
                              | _ ->
2490
                                  Result.Error
2491
                                    "Vhdl_ast.vhdl_type_attributes_t.arg") x))
2492
                    | [] ->
2493
                        arg1 >>=
2494
                          ((fun arg1  ->
2495
                              arg0 >>=
2496
                                (fun arg0  ->
2497
                                   Result.Ok
2498
                                     (TAttStringArg { id = arg0; arg = arg1 }))))
2499
                    | _::xs -> loop xs _state  in
2500
                  loop xs
2501
                    ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
2502
                      (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
2503
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2504
        | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")
2505
    [@ocaml.warning "-A"])
2506

    
2507
let typ_att_noarg = ["base"; "left"; "right"; "high"; "low"] 
2508
let typ_att_intarg = ["pos"; "val"; "succ"; "pred"; "leftof"; "rightof"] 
2509
let typ_att_valarg = ["image"] 
2510
let typ_att_stringarg = ["value"] 
2511
let array_att_intarg =
2512
  ["left"; "right"; "high"; "low"; "range"; "reverse_range"; "length"] 
2513
type vhdl_parameter_t =
2514
  {
2515
  names: vhdl_name_t list ;
2516
  mode: string list [@default []];
2517
  typ: vhdl_subtype_indication_t ;
2518
  init_val: vhdl_cst_val_t option [@default None]}
2519

    
2520
(* TODO *)
2521
let rec pp_vhdl_parameter_t :
2522
  Format.formatter -> vhdl_parameter_t -> Ppx_deriving_runtime.unit =
2523
  let __2 () = pp_vhdl_cst_val_t
2524
  
2525
  and __1 () = pp_vhdl_subtype_indication_t
2526
  
2527
  and __0 () = pp_vhdl_name_t
2528
   in
2529
  ((let open! Ppx_deriving_runtime in
2530
      fun fmt  ->
2531
        fun x  ->
2532
          Format.fprintf fmt "@[<2>{ ";
2533
          ((((Format.fprintf fmt "@[%s =@ " "names";
2534
              ((fun x  ->
2535
                  Format.fprintf fmt "@[<2>[";
2536
                  ignore
2537
                    (List.fold_left
2538
                       (fun sep  ->
2539
                          fun x  ->
2540
                            if sep then Format.fprintf fmt ";@ ";
2541
                            ((__0 ()) fmt) x;
2542
                            true) false x);
2543
                  Format.fprintf fmt "@,]@]")) x.names;
2544
              Format.fprintf fmt "@]");
2545
             Format.fprintf fmt ";@ ";
2546
             Format.fprintf fmt "@[%s =@ " "mode";
2547
             ((fun x  ->
2548
                 Format.fprintf fmt "@[<2>[";
2549
                 ignore
2550
                   (List.fold_left
2551
                      (fun sep  ->
2552
                         fun x  ->
2553
                           if sep then Format.fprintf fmt ";@ ";
2554
                           (Format.fprintf fmt "%S") x;
2555
                           true) false x);
2556
                 Format.fprintf fmt "@,]@]")) x.mode;
2557
             Format.fprintf fmt "@]");
2558
            Format.fprintf fmt ";@ ";
2559
            Format.fprintf fmt "@[%s =@ " "typ";
2560
            ((__1 ()) fmt) x.typ;
2561
            Format.fprintf fmt "@]");
2562
           Format.fprintf fmt ";@ ";
2563
           Format.fprintf fmt "@[%s =@ " "init_val";
2564
           ((function
2565
             | None  -> Format.pp_print_string fmt "None"
2566
             | Some x ->
2567
                 (Format.pp_print_string fmt "(Some ";
2568
                  ((__2 ()) fmt) x;
2569
                  Format.pp_print_string fmt ")"))) x.init_val;
2570
           Format.fprintf fmt "@]");
2571
          Format.fprintf fmt "@ }@]")
2572
    [@ocaml.warning "-A"])
2573

    
2574
and show_vhdl_parameter_t : vhdl_parameter_t -> Ppx_deriving_runtime.string =
2575
  fun x  -> Format.asprintf "%a" pp_vhdl_parameter_t x
2576

    
2577
let rec (vhdl_parameter_t_to_yojson : vhdl_parameter_t -> Yojson.Safe.json) =
2578
  ((let open! Ppx_deriving_yojson_runtime in
2579
      fun x  ->
2580
        let fields = []  in
2581
        let fields =
2582
          if x.init_val = None
2583
          then fields
2584
          else
2585
            ("init_val",
2586
              (((function
2587
                 | None  -> `Null
2588
                 | Some x -> ((fun x  -> vhdl_cst_val_t_to_yojson x)) x))
2589
                 x.init_val))
2590
            :: fields
2591
           in
2592
        let fields =
2593
          ("typ", ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.typ))
2594
          :: fields  in
2595
        let fields =
2596
          if x.mode = []
2597
          then fields
2598
          else
2599
            ("mode",
2600
              (((fun x  ->
2601
                   `List
2602
                     (List.map
2603
                        (fun (x : Ppx_deriving_runtime.string)  -> `String x)
2604
                        x))) x.mode))
2605
            :: fields
2606
           in
2607
        let fields =
2608
          ("names",
2609
            ((fun x  ->
2610
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
2611
               x.names))
2612
          :: fields  in
2613
        `Assoc fields)
2614
  [@ocaml.warning "-A"])
2615

    
2616
and (vhdl_parameter_t_of_yojson :
2617
      Yojson.Safe.json ->
2618
        vhdl_parameter_t Ppx_deriving_yojson_runtime.error_or)
2619
  =
2620
  ((let open! Ppx_deriving_yojson_runtime in
2621
      function
2622
      | `Assoc xs ->
2623
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
2624
            match xs with
2625
            | ("names",x)::xs ->
2626
                loop xs
2627
                  (((function
2628
                     | `List xs ->
2629
                         map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
2630
                     | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t.names") x),
2631
                    arg1, arg2, arg3)
2632
            | ("mode",x)::xs ->
2633
                loop xs
2634
                  (arg0,
2635
                    ((function
2636
                      | `List xs ->
2637
                          map_bind
2638
                            (function
2639
                             | `String x -> Result.Ok x
2640
                             | _ ->
2641
                                 Result.Error
2642
                                   "Vhdl_ast.vhdl_parameter_t.mode") [] xs
2643
                      | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t.mode") x),
2644
                    arg2, arg3)
2645
            | ("typ",x)::xs ->
2646
                loop xs
2647
                  (arg0, arg1,
2648
                    ((fun x  -> vhdl_subtype_indication_t_of_yojson x) x),
2649
                    arg3)
2650
            | ("init_val",x)::xs ->
2651
                loop xs
2652
                  (arg0, arg1, arg2,
2653
                    ((function
2654
                      | `Null -> Result.Ok None
2655
                      | x ->
2656
                          ((fun x  -> vhdl_cst_val_t_of_yojson x) x) >>=
2657
                            ((fun x  -> Result.Ok (Some x)))) x))
2658
            | [] ->
2659
                arg3 >>=
2660
                  ((fun arg3  ->
2661
                      arg2 >>=
2662
                        (fun arg2  ->
2663
                           arg1 >>=
2664
                             (fun arg1  ->
2665
                                arg0 >>=
2666
                                  (fun arg0  ->
2667
                                     Result.Ok
2668
                                       {
2669
                                         names = arg0;
2670
                                         mode = arg1;
2671
                                         typ = arg2;
2672
                                         init_val = arg3
2673
                                       })))))
2674
            | _::xs -> loop xs _state  in
2675
          loop xs
2676
            ((Result.Error "Vhdl_ast.vhdl_parameter_t.names"),
2677
              (Result.Ok []), (Result.Error "Vhdl_ast.vhdl_parameter_t.typ"),
2678
              (Result.Ok (Some (CstInt 0))))
2679
      | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t")
2680
  [@ocaml.warning "-A"])
2681

    
2682
type vhdl_subprogram_spec_t =
2683
  {
2684
  name: string [@default ""];
2685
  typeMark: vhdl_name_t [@default NoName];
2686
  parameters: vhdl_parameter_t list ;
2687
  isPure: bool [@default false]}
2688

    
2689
(* TODO *)
2690
let rec pp_vhdl_subprogram_spec_t :
2691
  Format.formatter -> vhdl_subprogram_spec_t -> Ppx_deriving_runtime.unit =
2692
  let __1 () = pp_vhdl_parameter_t
2693
  
2694
  and __0 () = pp_vhdl_name_t
2695
   in
2696
  ((let open! Ppx_deriving_runtime in
2697
      fun fmt  ->
2698
        fun x  ->
2699
          Format.fprintf fmt "@[<2>{ ";
2700
          ((((Format.fprintf fmt "@[%s =@ " "name";
2701
              (Format.fprintf fmt "%S") x.name;
2702
              Format.fprintf fmt "@]");
2703
             Format.fprintf fmt ";@ ";
2704
             Format.fprintf fmt "@[%s =@ " "typeMark";
2705
             ((__0 ()) fmt) x.typeMark;
2706
             Format.fprintf fmt "@]");
2707
            Format.fprintf fmt ";@ ";
2708
            Format.fprintf fmt "@[%s =@ " "parameters";
2709
            ((fun x  ->
2710
                Format.fprintf fmt "@[<2>[";
2711
                ignore
2712
                  (List.fold_left
2713
                     (fun sep  ->
2714
                        fun x  ->
2715
                          if sep then Format.fprintf fmt ";@ ";
2716
                          ((__1 ()) fmt) x;
2717
                          true) false x);
2718
                Format.fprintf fmt "@,]@]")) x.parameters;
2719
            Format.fprintf fmt "@]");
2720
           Format.fprintf fmt ";@ ";
2721
           Format.fprintf fmt "@[%s =@ " "isPure";
2722
           (Format.fprintf fmt "%B") x.isPure;
2723
           Format.fprintf fmt "@]");
2724
          Format.fprintf fmt "@ }@]")
2725
    [@ocaml.warning "-A"])
2726

    
2727
and show_vhdl_subprogram_spec_t :
2728
  vhdl_subprogram_spec_t -> Ppx_deriving_runtime.string =
2729
  fun x  -> Format.asprintf "%a" pp_vhdl_subprogram_spec_t x
2730

    
2731
let rec (vhdl_subprogram_spec_t_to_yojson :
2732
          vhdl_subprogram_spec_t -> Yojson.Safe.json)
2733
  =
2734
  ((let open! Ppx_deriving_yojson_runtime in
2735
      fun x  ->
2736
        let fields = []  in
2737
        let fields =
2738
          if x.isPure = false
2739
          then fields
2740
          else
2741
            ("isPure",
2742
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x)) x.isPure))
2743
            :: fields
2744
           in
2745
        let fields =
2746
          ("parameters",
2747
            ((fun x  ->
2748
                `List (List.map (fun x  -> vhdl_parameter_t_to_yojson x) x))
2749
               x.parameters))
2750
          :: fields  in
2751
        let fields =
2752
          if x.typeMark = NoName
2753
          then fields
2754
          else
2755
            ("typeMark", (((fun x  -> vhdl_name_t_to_yojson x)) x.typeMark))
2756
            :: fields
2757
           in
2758
        let fields =
2759
          if x.name = ""
2760
          then fields
2761
          else
2762
            ("name",
2763
              (((fun (x : Ppx_deriving_runtime.string)  -> `String x)) x.name))
2764
            :: fields
2765
           in
2766
        `Assoc fields)
2767
  [@ocaml.warning "-A"])
2768

    
2769
and (vhdl_subprogram_spec_t_of_yojson :
2770
      Yojson.Safe.json ->
2771
        vhdl_subprogram_spec_t Ppx_deriving_yojson_runtime.error_or)
2772
  =
2773
  ((let open! Ppx_deriving_yojson_runtime in
2774
      function
2775
      | `Assoc xs ->
2776
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
2777
            match xs with
2778
            | ("name",x)::xs ->
2779
                loop xs
2780
                  (((function
2781
                     | `String x -> Result.Ok x
2782
                     | _ ->
2783
                         Result.Error "Vhdl_ast.vhdl_subprogram_spec_t.name")
2784
                      x), arg1, arg2, arg3)
2785
            | ("typeMark",x)::xs ->
2786
                loop xs
2787
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3)
2788
            | ("parameters",x)::xs ->
2789
                loop xs
2790
                  (arg0, arg1,
2791
                    ((function
2792
                      | `List xs ->
2793
                          map_bind (fun x  -> vhdl_parameter_t_of_yojson x)
2794
                            [] xs
2795
                      | _ ->
2796
                          Result.Error
2797
                            "Vhdl_ast.vhdl_subprogram_spec_t.parameters") x),
2798
                    arg3)
2799
            | ("isPure",x)::xs ->
2800
                loop xs
2801
                  (arg0, arg1, arg2,
2802
                    ((function
2803
                      | `Bool x -> Result.Ok x
2804
                      | _ ->
2805
                          Result.Error
2806
                            "Vhdl_ast.vhdl_subprogram_spec_t.isPure") x))
2807
            | [] ->
2808
                arg3 >>=
2809
                  ((fun arg3  ->
2810
                      arg2 >>=
2811
                        (fun arg2  ->
2812
                           arg1 >>=
2813
                             (fun arg1  ->
2814
                                arg0 >>=
2815
                                  (fun arg0  ->
2816
                                     Result.Ok
2817
                                       {
2818
                                         name = arg0;
2819
                                         typeMark = arg1;
2820
                                         parameters = arg2;
2821
                                         isPure = arg3
2822
                                       })))))
2823
            | _::xs -> loop xs _state  in
2824
          loop xs
2825
            ((Result.Ok ""), (Result.Ok NoName),
2826
              (Result.Error "Vhdl_ast.vhdl_subprogram_spec_t.parameters"),
2827
              (Result.Ok false))
2828
      | _ -> Result.Error "Vhdl_ast.vhdl_subprogram_spec_t")
2829
  [@ocaml.warning "-A"])
2830

    
2831
let arith_funs = ["+"; "-"; "*"; "/"; "mod"; "rem"; "abs"; "**"; "&"] 
2832
let bool_funs = ["and"; "or"; "nand"; "nor"; "xor"; "not"] 
2833
let rel_funs =
2834
  ["<";
2835
  ">";
2836
  "<=";
2837
  ">=";
2838
  "/=";
2839
  "=";
2840
  "?=";
2841
  "?/=";
2842
  "?<";
2843
  "?<=";
2844
  "?>";
2845
  "?>=";
2846
  "??"] 
2847
let shift_funs = ["sll"; "srl"; "sla"; "sra"; "rol"; "ror"] 
2848
type vhdl_sequential_stmt_t =
2849
  | VarAssign of
2850
  {
2851
  label: vhdl_name_t [@default NoName];
2852
  lhs: vhdl_name_t ;
2853
  rhs: vhdl_expr_t } [@name "VARIABLE_ASSIGNMENT_STATEMENT"]
2854
  | SigSeqAssign of
2855
  {
2856
  label: vhdl_name_t [@default NoName];
2857
  lhs: vhdl_name_t ;
2858
  rhs: vhdl_expr_t list } [@name "SIGNAL_ASSIGNMENT_STATEMENT"]
2859
  | If of
2860
  {
2861
  label: vhdl_name_t [@default NoName];
2862
  if_cases: vhdl_if_case_t list ;
2863
  default: vhdl_sequential_stmt_t list [@default []]} [@name "IF_STATEMENT"]
2864
  | Case of
2865
  {
2866
  label: vhdl_name_t [@default NoName];
2867
  guard: vhdl_expr_t ;
2868
  branches: vhdl_case_item_t list } [@name "CASE_STATEMENT_TREE"]
2869
  | Exit of
2870
  {
2871
  label: vhdl_name_t [@default NoName];
2872
  loop_label: string option [@default Some ""];
2873
  condition: vhdl_expr_t option [@default Some IsNull]}
2874
  [@name "EXIT_STATEMENT"]
2875
  | Assert of
2876
  {
2877
  label: vhdl_name_t [@default NoName];
2878
  cond: vhdl_expr_t ;
2879
  report: vhdl_expr_t [@default IsNull];
2880
  severity: vhdl_expr_t [@default IsNull]} [@name "ASSERTION_STATEMENT"]
2881
  | ProcedureCall of
2882
  {
2883
  label: vhdl_name_t [@default NoName];
2884
  name: vhdl_name_t ;
2885
  assocs: vhdl_assoc_element_t list } [@name "PROCEDURE_CALL_STATEMENT"]
2886
  | Wait [@name "WAIT_STATEMENT"]
2887
  | Null of {
2888
  label: vhdl_name_t [@default NoName]} [@name "NULL_STATEMENT"]
2889
  | Return of {
2890
  label: vhdl_name_t [@default NoName]} [@name "RETURN_STATEMENT"]
2891
and vhdl_if_case_t =
2892
  {
2893
  if_cond: vhdl_expr_t ;
2894
  if_block: vhdl_sequential_stmt_t list }
2895
and vhdl_case_item_t =
2896
  {
2897
  when_cond: vhdl_expr_t list ;
2898
  when_stmt: vhdl_sequential_stmt_t list }
2899

    
2900
let rec pp_vhdl_sequential_stmt_t :
2901
  Format.formatter -> vhdl_sequential_stmt_t -> Ppx_deriving_runtime.unit =
2902
  let __22 () = pp_vhdl_name_t
2903
  
2904
  and __21 () = pp_vhdl_name_t
2905
  
2906
  and __20 () = pp_vhdl_assoc_element_t
2907
  
2908
  and __19 () = pp_vhdl_name_t
2909
  
2910
  and __18 () = pp_vhdl_name_t
2911
  
2912
  and __17 () = pp_vhdl_expr_t
2913
  
2914
  and __16 () = pp_vhdl_expr_t
2915
  
2916
  and __15 () = pp_vhdl_expr_t
2917
  
2918
  and __14 () = pp_vhdl_name_t
2919
  
2920
  and __13 () = pp_vhdl_expr_t
2921
  
2922
  and __12 () = pp_vhdl_name_t
2923
  
2924
  and __11 () = pp_vhdl_case_item_t
2925
  
2926
  and __10 () = pp_vhdl_expr_t
2927
  
2928
  and __9 () = pp_vhdl_name_t
2929
  
2930
  and __8 () = pp_vhdl_sequential_stmt_t
2931
  
2932
  and __7 () = pp_vhdl_if_case_t
2933
  
2934
  and __6 () = pp_vhdl_name_t
2935
  
2936
  and __5 () = pp_vhdl_expr_t
2937
  
2938
  and __4 () = pp_vhdl_name_t
2939
  
2940
  and __3 () = pp_vhdl_name_t
2941
  
2942
  and __2 () = pp_vhdl_expr_t
2943
  
2944
  and __1 () = pp_vhdl_name_t
2945
  
2946
  and __0 () = pp_vhdl_name_t
2947
   in
2948
  ((let open! Ppx_deriving_runtime in
2949
      fun fmt  ->
2950
        function
2951
        | VarAssign { label = alabel; lhs = alhs; rhs = arhs } ->
2952
            (match alabel with
2953
              | NoName -> Format.fprintf fmt "";
2954
              | _ -> (((__0 ()) fmt) alabel;
2955
                     Format.fprintf fmt ": ")
2956
            );
2957
            ((__1 ()) fmt) alhs;
2958
            Format.fprintf fmt " := ";
2959
            ((__2 ()) fmt) arhs;
2960
(* TODO: Check
2961
            (Format.fprintf fmt "@[<2>VarAssign {@,";
2962
             (((Format.fprintf fmt "@[%s =@ " "label";
2963
                ((__0 ()) fmt) alabel;
2964
                Format.fprintf fmt "@]");
2965
               Format.fprintf fmt ";@ ";
2966
               Format.fprintf fmt "@[%s =@ " "lhs";
2967
               ((__1 ()) fmt) alhs;
2968
               Format.fprintf fmt "@]");
2969
              Format.fprintf fmt ";@ ";
2970
              Format.fprintf fmt "@[%s =@ " "rhs";
2971
              ((__2 ()) fmt) arhs;
2972
              Format.fprintf fmt "@]");
2973
             Format.fprintf fmt "@]}") *)
2974
        | SigSeqAssign { label = alabel; lhs = alhs; rhs = arhs } ->
2975
            (match alabel with
2976
              | NoName -> Format.fprintf fmt "";
2977
              | _ -> (((__3 ()) fmt) alabel;
2978
                     Format.fprintf fmt ":@ ")
2979
            );
2980
            Format.fprintf fmt "@[<2>";
2981
            ((__4 ()) fmt) alhs;
2982
            Format.fprintf fmt "@ <=@ ";
2983
            ((fun x  ->
2984
               Format.fprintf fmt "@[";
2985
               ignore
2986
                 (List.fold_left
2987
                   (fun sep  ->
2988
                     fun x  ->
2989
                       if sep then Format.fprintf fmt "";
2990
                        ((__5 ()) fmt) x;
2991
                        true) false x);
2992
            Format.fprintf fmt "@]@]")) arhs;
2993
        | If { label = alabel; if_cases = aif_cases; default = adefault } ->
2994
            (match alabel with
2995
              | NoName -> Format.fprintf fmt "";
2996
              | _ -> (((__6 ()) fmt) alabel;
2997
                     Format.fprintf fmt ":@ ")
2998
            );
2999
            Format.fprintf fmt "@[<v>if";
3000
            ((fun x ->
3001
               ignore
3002
               (List.fold_left
3003
                 (fun sep  ->
3004
                   fun x  ->
3005
                           if sep then Format.fprintf fmt "@;elseif";
3006
                                ((__7 ()) fmt) x;
3007
                                true
3008
                 ) false x);
3009
             )) aif_cases;
3010
             (match adefault with
3011
              | [] -> Format.fprintf fmt "";
3012
              | _  -> (Format.fprintf fmt "@;else";
3013
                      ((fun x  ->
3014
                          Format.fprintf fmt "@;<0 2>";
3015
                          ignore
3016
                            (List.fold_left
3017
                              (fun sep  ->
3018
                                fun x  ->
3019
                                        if sep then Format.fprintf fmt "";
3020
                          ((__8 ()) fmt) x;
3021
                          true) false x))) adefault));
3022
            Format.fprintf fmt "@;end if;@]"
3023
        | Case { label = alabel; guard = aguard; branches = abranches } ->
3024
            (match alabel with
3025
              | NoName -> Format.fprintf fmt "";
3026
              | _ -> (((__9 ()) fmt) alabel;
3027
                     Format.fprintf fmt ":@ ")
3028
            );
3029
            Format.fprintf fmt "@[<v>case ";
3030
            ((__10 ()) fmt) aguard;
3031
            Format.fprintf fmt " is";
3032
            ((fun x  ->
3033
                ignore
3034
                  (List.fold_left
3035
                     (fun sep  ->
3036
                        fun x  ->
3037
                          if sep then Format.fprintf fmt "";
3038
                          ((__11 ()) fmt) x;
3039
                          true) false x);)) abranches;
3040
            Format.fprintf fmt "@;end case;@]";
3041
        | Exit
3042
            { label = alabel; loop_label = aloop_label;
3043
              condition = acondition }
3044
            ->
3045
            (match alabel with
3046
              | NoName -> Format.fprintf fmt "";
3047
              | _ -> (((__12 ()) fmt) alabel;
3048
                     Format.fprintf fmt ":@ ")
3049
            );
3050
            Format.fprintf fmt "exit";
3051
            (match aloop_label with
3052
               | None  -> Format.pp_print_string fmt ""
3053
               | Some x -> (Format.fprintf fmt "@ %s@ ") x);
3054
            ((function
3055
               | None  -> Format.pp_print_string fmt ""
3056
               | Some x ->
3057
                   (Format.pp_print_string fmt "when@ ";
3058
                    ((__13 ()) fmt) x;))) acondition;
3059
        | Assert
3060
            { label = alabel; cond = acond; report = areport;
3061
              severity = aseverity }
3062
            ->
3063
            Format.fprintf fmt "@[<v 2>";
3064
            (match alabel with
3065
              | NoName -> Format.fprintf fmt "";
3066
              | _ -> (((__14 ()) fmt) alabel;
3067
                     Format.fprintf fmt ":@ ")
3068
            );
3069
            Format.fprintf fmt "assert ";
3070
            ((__15 ()) fmt) acond;
3071
            (match areport with
3072
            | IsNull -> Format.fprintf fmt "";
3073
            | _ -> 
3074
                Format.fprintf fmt "@;report ";
3075
                ((__16 ()) fmt) areport);
3076
            (match aseverity with
3077
            | IsNull -> Format.fprintf fmt "";
3078
            | _ -> 
3079
                Format.fprintf fmt "@;severity ";
3080
                ((__17 ()) fmt) aseverity);
3081
            Format.fprintf fmt "@]";
3082
        | ProcedureCall { label = alabel; name = aname; assocs = aassocs } ->
3083
            (match alabel with
3084
              | NoName -> Format.fprintf fmt "";
3085
              | _ -> (((__18 ()) fmt) alabel;
3086
                     Format.fprintf fmt ":@ ")
3087
            );
3088
            ((__19 ()) fmt) aname;
3089
            ((fun x  ->
3090
                Format.fprintf fmt "(";
3091
                ignore
3092
                  (List.fold_left
3093
                     (fun sep  ->
3094
                        fun x  ->
3095
                          if sep then Format.fprintf fmt ",@ ";
3096
                          ((__20 ()) fmt) x;
3097
                          true) false x);
3098
            Format.fprintf fmt ")")) aassocs;
3099
        | Wait  -> Format.pp_print_string fmt "wait"
3100
        | Null { label = alabel } ->
3101
            (match alabel with
3102
              | NoName -> Format.fprintf fmt "";
3103
              | _ -> (((__18 ()) fmt) alabel;
3104
                     Format.fprintf fmt ":@ ")
3105
            );
3106
            Format.fprintf fmt "null";
3107
        | Return { label = alabel } ->
3108
            (match alabel with
3109
              | NoName -> Format.fprintf fmt "";
3110
              | _ -> (((__19 ()) fmt) alabel;
3111
                     Format.fprintf fmt ":@ ")
3112
            );
3113
            Format.fprintf fmt "return";)
3114
    [@ocaml.warning "-A"])
3115

    
3116
and show_vhdl_sequential_stmt_t :
3117
  vhdl_sequential_stmt_t -> Ppx_deriving_runtime.string =
3118
  fun x  -> Format.asprintf "%a" pp_vhdl_sequential_stmt_t x
3119

    
3120
and pp_vhdl_if_case_t :
3121
  Format.formatter -> vhdl_if_case_t -> Ppx_deriving_runtime.unit =
3122
  let __1 () = pp_vhdl_sequential_stmt_t
3123
  
3124
  and __0 () = pp_vhdl_expr_t
3125
   in
3126
  ((let open! Ppx_deriving_runtime in
3127
      fun fmt  ->
3128
        fun x  ->
3129
          Format.fprintf fmt " (";
3130
          ((__0 ()) fmt) x.if_cond;
3131
          Format.fprintf fmt ") then@;<0 2>";
3132
          ((fun x  ->
3133
             ignore
3134
               (List.fold_left
3135
                  (fun sep  ->
3136
                     fun x  ->
3137
                             if sep then Format.fprintf fmt "@;<0 2>";
3138
                       ((__1 ()) fmt) x;
3139
                       true) false x);
3140
          )) x.if_block;)
3141
    [@ocaml.warning "-A"])
3142

    
3143
and show_vhdl_if_case_t : vhdl_if_case_t -> Ppx_deriving_runtime.string =
3144
  fun x  -> Format.asprintf "%a" pp_vhdl_if_case_t x
3145

    
3146
and pp_vhdl_case_item_t :
3147
  Format.formatter -> vhdl_case_item_t -> Ppx_deriving_runtime.unit =
3148
  let __1 () = pp_vhdl_sequential_stmt_t
3149
  
3150
  and __0 () = pp_vhdl_expr_t
3151
   in
3152
  ((let open! Ppx_deriving_runtime in
3153
      fun fmt  ->
3154
        fun x  ->
3155
                Format.fprintf fmt "@;@[<v 2>when ";
3156
            ((fun x  ->
3157
                ignore
3158
                  (List.fold_left
3159
                     (fun sep  ->
3160
                        fun x  ->
3161
                          if sep then Format.fprintf fmt "@ |@ ";
3162
                          ((__0 ()) fmt) x;
3163
                          true) false x);)) x.when_cond;
3164
           Format.fprintf fmt " => ";
3165
           (fun x  ->
3166
               ignore
3167
                 (List.fold_left
3168
                    (fun sep  ->
3169
                       fun x  ->
3170
                         if sep then Format.fprintf fmt "@;";
3171
                         ((__1 ()) fmt) x;
3172
                         Format.fprintf fmt ";";
3173
                         true) ((List.length x) > 1) x);) x.when_stmt;
3174
           Format.fprintf fmt "@]")
3175
    [@ocaml.warning "-A"])
3176

    
3177
and show_vhdl_case_item_t : vhdl_case_item_t -> Ppx_deriving_runtime.string =
3178
  fun x  -> Format.asprintf "%a" pp_vhdl_case_item_t x
3179

    
3180
let rec (vhdl_sequential_stmt_t_to_yojson :
3181
          vhdl_sequential_stmt_t -> Yojson.Safe.json)
3182
  =
3183
  ((let open! Ppx_deriving_yojson_runtime in
3184
      function
3185
      | VarAssign arg0 ->
3186
          `List
3187
            [`String "VARIABLE_ASSIGNMENT_STATEMENT";
3188
            (let fields = []  in
3189
             let fields =
3190
               ("rhs", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.rhs)) ::
3191
               fields  in
3192
             let fields =
3193
               ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) arg0.lhs)) ::
3194
               fields  in
3195
             let fields =
3196
               if arg0.label = NoName
3197
               then fields
3198
               else
3199
                 ("label",
3200
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3201
                 :: fields
3202
                in
3203
             `Assoc fields)]
3204
      | SigSeqAssign arg0 ->
3205
          `List
3206
            [`String "SIGNAL_ASSIGNMENT_STATEMENT";
3207
            (let fields = []  in
3208
             let fields =
3209
               ("rhs",
3210
                 ((fun x  ->
3211
                     `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
3212
                    arg0.rhs))
3213
               :: fields  in
3214
             let fields =
3215
               ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) arg0.lhs)) ::
3216
               fields  in
3217
             let fields =
3218
               if arg0.label = NoName
3219
               then fields
3220
               else
3221
                 ("label",
3222
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3223
                 :: fields
3224
                in
3225
             `Assoc fields)]
3226
      | If arg0 ->
3227
          `List
3228
            [`String "IF_STATEMENT";
3229
            (let fields = []  in
3230
             let fields =
3231
               if arg0.default = []
3232
               then fields
3233
               else
3234
                 ("default",
3235
                   (((fun x  ->
3236
                        `List
3237
                          (List.map
3238
                             (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x)))
3239
                      arg0.default))
3240
                 :: fields
3241
                in
3242
             let fields =
3243
               ("if_cases",
3244
                 ((fun x  ->
3245
                     `List
3246
                       (List.map (fun x  -> vhdl_if_case_t_to_yojson x) x))
3247
                    arg0.if_cases))
3248
               :: fields  in
3249
             let fields =
3250
               if arg0.label = NoName
3251
               then fields
3252
               else
3253
                 ("label",
3254
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3255
                 :: fields
3256
                in
3257
             `Assoc fields)]
3258
      | Case arg0 ->
3259
          `List
3260
            [`String "CASE_STATEMENT_TREE";
3261
            (let fields = []  in
3262
             let fields =
3263
               ("branches",
3264
                 ((fun x  ->
3265
                     `List
3266
                       (List.map (fun x  -> vhdl_case_item_t_to_yojson x) x))
3267
                    arg0.branches))
3268
               :: fields  in
3269
             let fields =
3270
               ("guard", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.guard)) ::
3271
               fields  in
3272
             let fields =
3273
               if arg0.label = NoName
3274
               then fields
3275
               else
3276
                 ("label",
3277
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3278
                 :: fields
3279
                in
3280
             `Assoc fields)]
3281
      | Exit arg0 ->
3282
          `List
3283
            [`String "EXIT_STATEMENT";
3284
            (let fields = []  in
3285
             let fields =
3286
               if arg0.condition = (Some IsNull)
3287
               then fields
3288
               else
3289
                 ("condition",
3290
                   (((function
3291
                      | None  -> `Null
3292
                      | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x))
3293
                      arg0.condition))
3294
                 :: fields
3295
                in
3296
             let fields =
3297
               if arg0.loop_label = (Some "")
3298
               then fields
3299
               else
3300
                 ("loop_label",
3301
                   (((function
3302
                      | None  -> `Null
3303
                      | Some x ->
3304
                          ((fun (x : Ppx_deriving_runtime.string)  ->
3305
                              `String x)) x)) arg0.loop_label))
3306
                 :: fields
3307
                in
3308
             let fields =
3309
               if arg0.label = NoName
3310
               then fields
3311
               else
3312
                 ("label",
3313
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3314
                 :: fields
3315
                in
3316
             `Assoc fields)]
3317
      | Assert arg0 ->
3318
          `List
3319
            [`String "ASSERTION_STATEMENT";
3320
            (let fields = []  in
3321
             let fields =
3322
               if arg0.severity = IsNull
3323
               then fields
3324
               else
3325
                 ("severity",
3326
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.severity))
3327
                 :: fields
3328
                in
3329
             let fields =
3330
               if arg0.report = IsNull
3331
               then fields
3332
               else
3333
                 ("report",
3334
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.report))
3335
                 :: fields
3336
                in
3337
             let fields =
3338
               ("cond", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.cond)) ::
3339
               fields  in
3340
             let fields =
3341
               if arg0.label = NoName
3342
               then fields
3343
               else
3344
                 ("label",
3345
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3346
                 :: fields
3347
                in
3348
             `Assoc fields)]
3349
      | ProcedureCall arg0 ->
3350
          `List
3351
            [`String "PROCEDURE_CALL_STATEMENT";
3352
            (let fields = []  in
3353
             let fields =
3354
               ("assocs",
3355
                 ((fun x  ->
3356
                     `List
3357
                       (List.map (fun x  -> vhdl_assoc_element_t_to_yojson x)
3358
                          x)) arg0.assocs))
3359
               :: fields  in
3360
             let fields =
3361
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
3362
               fields  in
3363
             let fields =
3364
               if arg0.label = NoName
3365
               then fields
3366
               else
3367
                 ("label",
3368
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3369
                 :: fields
3370
                in
3371
             `Assoc fields)]
3372
      | Wait  -> `List [`String "WAIT_STATEMENT"]
3373
      | Null arg0 ->
3374
          `List
3375
            [`String "NULL_STATEMENT";
3376
            (let