Project

General

Profile

« Previous | Next » 

Revision 58f8ddf5

Added by Arnaud Dieumegard almost 6 years ago

Split PP and Yojson in separate ml for vhdl ast

View differences:

src/backends/VHDL/vhdl_ast_deriving.ml
1
let base_types =
2
  ["integer";
3
  "character";
4
  "bit";
5
  "real";
6
  "natural";
7
  "positive";
8
  "std_logic";
9
  "std_logic_vector"] 
10
let std_logic_cst = ["U"; "X"; "0"; "1"; "Z"; "W"; "L"; "H"; "-"] 
11
let literal_base = ["B"; "O"; "X"; "UB"; "UO"; "UX"; "SB"; "SO"; "SX"; "D"] 
12
type vhdl_cst_val_t =
13
  | CstInt of int 
14
  | CstStdLogic of string 
15
  | CstLiteral of string [@name "CST_LITERAL"]
16

  
17
let rec (pp_vhdl_cst_val_t :
18
          Format.formatter -> vhdl_cst_val_t -> Ppx_deriving_runtime.unit)
19
  =
20
  ((let open! Ppx_deriving_runtime in
21
      fun fmt  ->
22
        function
23
        | CstInt a0 ->
24
             (Format.fprintf fmt "%d") a0;
25
        | CstStdLogic a0 ->
26
             (Format.fprintf fmt "%S") a0;
27
        | CstLiteral a0 ->
28
             (Format.fprintf fmt "%s") a0;)
29
  [@ocaml.warning "-A"])
30

  
31
and show_vhdl_cst_val_t : vhdl_cst_val_t -> Ppx_deriving_runtime.string =
32
  fun x  -> Format.asprintf "%a" pp_vhdl_cst_val_t x
33

  
34
let rec (vhdl_cst_val_t_to_yojson : vhdl_cst_val_t -> Yojson.Safe.json) =
35
  ((let open! Ppx_deriving_yojson_runtime in
36
      function
37
      | CstInt arg0 ->
38
          `List
39
            [`String "CstInt";
40
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0]
41
      | CstStdLogic arg0 ->
42
          `List
43
            [`String "CstStdLogic";
44
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
45
      | CstLiteral arg0 ->
46
          `List
47
            [`String "CST_LITERAL";
48
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0])
49
  [@ocaml.warning "-A"])
50

  
51
and (vhdl_cst_val_t_of_yojson :
52
      Yojson.Safe.json -> vhdl_cst_val_t Ppx_deriving_yojson_runtime.error_or)
53
  =
54
  ((let open! Ppx_deriving_yojson_runtime in
55
      function
56
      | `List ((`String "CstInt")::arg0::[]) ->
57
          ((function
58
            | `Int x -> Result.Ok x
59
            | _ -> Result.Error "Vhdl_ast.vhdl_cst_val_t") arg0) >>=
60
            ((fun arg0  -> Result.Ok (CstInt arg0)))
61
      | `List ((`String "CstStdLogic")::arg0::[]) ->
62
          ((function
63
            | `String x -> Result.Ok x
64
            | _ -> Result.Error "Vhdl_ast.vhdl_cst_val_t") arg0) >>=
65
            ((fun arg0  -> Result.Ok (CstStdLogic arg0)))
66
      | `List ((`String "CST_LITERAL")::arg0::[]) ->
67
          ((function
68
            | `String x -> Result.Ok x
69
            | _ -> Result.Error "Vhdl_ast.vhdl_cst_val_t") arg0) >>=
70
            ((fun arg0  -> Result.Ok (CstLiteral arg0)))
71
      | _ -> Result.Error "Vhdl_ast.vhdl_cst_val_t")
72
  [@ocaml.warning "-A"])
73

  
74
type vhdl_type_t =
75
  | Base of string 
76
  | Range of string option * int * int 
77
  | Bit_vector of int * int 
78
  | Array of
79
  {
80
  indexes: vhdl_name_t list [@default []];
81
  const: vhdl_constraint_t option [@default None];
82
  definition: vhdl_subtype_indication_t } [@name "ARRAY_TYPE_DEFINITION"]
83
  | Record of vhdl_element_declaration_t list
84
  [@name "RECORD_TYPE_DEFINITION"]
85
  | Enumerated of vhdl_name_t list [@name "ENUMERATION_TYPE_DEFINITION"]
86
  | Void 
87
and vhdl_element_declaration_t =
88
  {
89
  names: vhdl_name_t list ;
90
  definition: vhdl_subtype_indication_t }
91
and vhdl_subtype_indication_t =
92
  {
93
  name: vhdl_name_t [@default NoName];
94
  functionName: vhdl_name_t [@default NoName];
95
  const: vhdl_constraint_t [@default NoConstraint]}
96
and vhdl_discrete_range_t =
97
  | SubDiscreteRange of vhdl_subtype_indication_t
98
  [@name "SUB_DISCRETE_RANGE"]
99
  | NamedRange of vhdl_name_t [@name "NAMED_RANGE"]
100
  | DirectedRange of
101
  {
102
  direction: string ;
103
  from: vhdl_expr_t ;
104
  _to: vhdl_expr_t } [@name "RANGE_WITH_DIRECTION"]
105
and vhdl_constraint_t =
106
  | RefConstraint of {
107
  ref_name: vhdl_name_t } 
108
  | RangeConstraint of {
109
  range: vhdl_discrete_range_t } [@name "RANGE_CONSTRAINT"]
110
  | IndexConstraint of {
111
  ranges: vhdl_discrete_range_t list } [@name "INDEX_CONSTRAINT"]
112
  | ArrayConstraint of
113
  {
114
  ranges: vhdl_discrete_range_t list ;
115
  sub: vhdl_constraint_t } [@name "ARRAY_CONSTRAINT"]
116
  | RecordConstraint 
117
  | NoConstraint 
118
and vhdl_definition_t =
119
  | Type of {
120
  name: vhdl_name_t ;
121
  definition: vhdl_type_t } [@name "TYPE_DECLARATION"]
122
  | Subtype of {
123
  name: vhdl_name_t ;
124
  typ: vhdl_subtype_indication_t } [@name "SUBTYPE_DECLARATION"]
125
and vhdl_expr_t =
126
  | Call of vhdl_name_t [@name "CALL"]
127
  | Cst of
128
  {
129
  value: vhdl_cst_val_t ;
130
  unit_name: vhdl_name_t option [@default None]} [@name "CONSTANT_VALUE"]
131
  | Op of {
132
  id: string [@default ""];
133
  args: vhdl_expr_t list [@default []]} [@name "EXPRESSION"]
134
  | IsNull [@name "IsNull"]
135
  | Time of {
136
  value: int ;
137
  phy_unit: string [@default ""]} 
138
  | Sig of {
139
  name: vhdl_name_t ;
140
  att: vhdl_signal_attributes_t option } 
141
  | SuffixMod of {
142
  expr: vhdl_expr_t ;
143
  selection: vhdl_suffix_selection_t } 
144
  | Aggregate of {
145
  elems: vhdl_element_assoc_t list } [@name "AGGREGATE"]
146
  | QualifiedExpression of
147
  {
148
  type_mark: vhdl_name_t ;
149
  aggregate: vhdl_element_assoc_t list ;
150
  expression: vhdl_expr_t option } [@name "QUALIFIED_EXPRESSION"]
151
  | Others [@name "OTHERS"]
152
and vhdl_name_t =
153
  | Simple of string [@name "SIMPLE_NAME"]
154
  | Identifier of string [@name "IDENTIFIER"]
155
  | Selected of vhdl_name_t list [@name "SELECTED_NAME"]
156
  | Index of {
157
  id: vhdl_name_t ;
158
  exprs: vhdl_expr_t list } [@name "INDEXED_NAME"]
159
  | Slice of {
160
  id: vhdl_name_t ;
161
  range: vhdl_discrete_range_t } [@name "SLICE_NAME"]
162
  | Attribute of
163
  {
164
  id: vhdl_name_t ;
165
  designator: vhdl_name_t ;
166
  expr: vhdl_expr_t [@default IsNull]} [@name "ATTRIBUTE_NAME"]
167
  | Function of {
168
  id: vhdl_name_t ;
169
  assoc_list: vhdl_assoc_element_t list } [@name "FUNCTION_CALL"]
170
  | NoName 
171
and vhdl_assoc_element_t =
172
  {
173
  formal_name: vhdl_name_t option [@default None];
174
  formal_arg: vhdl_name_t option [@default None];
175
  actual_name: vhdl_name_t option [@default None];
176
  actual_designator: vhdl_name_t option [@default None];
177
  actual_expr: vhdl_expr_t option [@default None]}
178
and vhdl_element_assoc_t = {
179
  choices: vhdl_expr_t list [@default []];
180
  expr: vhdl_expr_t }
181
and vhdl_array_attributes_t =
182
  | AAttInt of {
183
  id: string ;
184
  arg: int } 
185
  | AAttAscending 
186
and vhdl_signal_attributes_t =
187
  | SigAtt of string 
188
and vhdl_string_attributes_t =
189
  | StringAtt of string 
190
and vhdl_suffix_selection_t =
191
  | Idx of int 
192
  | SuffixRange of int * int
193

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

  
272
and show_vhdl_type_t : vhdl_type_t -> Ppx_deriving_runtime.string =
273
  fun x  -> Format.asprintf "%a" pp_vhdl_type_t x
274

  
275
and pp_vhdl_element_declaration_t :
276
  Format.formatter -> vhdl_element_declaration_t -> Ppx_deriving_runtime.unit
277
  =
278
  let __1 () = pp_vhdl_subtype_indication_t
279
  
280
  and __0 () = pp_vhdl_name_t
281
   in
282
  ((let open! Ppx_deriving_runtime in
283
      fun fmt  ->
284
        fun x  ->
285
            (fun x  ->
286
                ignore
287
                  (List.fold_left
288
                     (fun sep  ->
289
                        fun x  ->
290
                          if sep then Format.fprintf fmt ", ";
291
                          ((__0 ()) fmt) x;
292
                          true) false x)) x.names;
293
           Format.fprintf fmt ": ";
294
           ((__1 ()) fmt) x.definition)
295
    [@ocaml.warning "-A"])
296

  
297
and show_vhdl_element_declaration_t :
298
  vhdl_element_declaration_t -> Ppx_deriving_runtime.string =
299
  fun x  -> Format.asprintf "%a" pp_vhdl_element_declaration_t x
300

  
301
and pp_vhdl_subtype_indication_t :
302
  Format.formatter -> vhdl_subtype_indication_t -> Ppx_deriving_runtime.unit
303
  =
304
  let __2 () = pp_vhdl_constraint_t
305
  
306
  and __1 () = pp_vhdl_name_t
307
  
308
  and __0 () = pp_vhdl_name_t
309
   in
310
  ((let open! Ppx_deriving_runtime in
311
      fun fmt  ->
312
        fun x  ->
313
          ((__0 ()) fmt) x.name;
314
          ((__1 ()) fmt) x.functionName;
315
          (match x.const with
316
            | NoConstraint -> Format.fprintf fmt "";
317
            | _ -> Format.fprintf fmt " ";
318
                   ((__2 ()) fmt) x.const))
319
    [@ocaml.warning "-A"])
320

  
321
and show_vhdl_subtype_indication_t :
322
  vhdl_subtype_indication_t -> Ppx_deriving_runtime.string =
323
  fun x  -> Format.asprintf "%a" pp_vhdl_subtype_indication_t x
324

  
325
and pp_vhdl_discrete_range_t :
326
  Format.formatter -> vhdl_discrete_range_t -> Ppx_deriving_runtime.unit =
327
  let __3 () = pp_vhdl_expr_t
328
  
329
  and __2 () = pp_vhdl_expr_t
330
  
331
  and __1 () = pp_vhdl_name_t
332
  
333
  and __0 () = pp_vhdl_subtype_indication_t
334
   in
335
  ((let open! Ppx_deriving_runtime in
336
      fun fmt  ->
337
        function
338
        | SubDiscreteRange a0 ->
339
             ((__0 ()) fmt) a0;
340
        | NamedRange a0 ->
341
             ((__1 ()) fmt) a0;
342
        | DirectedRange { direction = adirection; from = afrom; _to = a_to }
343
            ->
344
               ((__2 ()) fmt) afrom;
345
               (Format.fprintf fmt " %s ") adirection;
346
               ((__3 ()) fmt) a_to;
347
    )
348
    [@ocaml.warning "-A"])
349

  
350
and show_vhdl_discrete_range_t :
351
  vhdl_discrete_range_t -> Ppx_deriving_runtime.string =
352
  fun x  -> Format.asprintf "%a" pp_vhdl_discrete_range_t x
353

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

  
412
and show_vhdl_constraint_t : vhdl_constraint_t -> Ppx_deriving_runtime.string
413
  = fun x  -> Format.asprintf "%a" pp_vhdl_constraint_t x
414

  
415
and pp_vhdl_definition_t :
416
  Format.formatter -> vhdl_definition_t -> Ppx_deriving_runtime.unit =
417
  let __3 () = pp_vhdl_subtype_indication_t
418
  
419
  and __2 () = pp_vhdl_name_t
420
  
421
  and __1 () = pp_vhdl_type_t
422
  
423
  and __0 () = pp_vhdl_name_t
424
   in
425
  ((let open! Ppx_deriving_runtime in
426
      fun fmt  ->
427
        function
428
        | Type { name = aname; definition = adefinition } ->
429
            Format.fprintf fmt "type ";
430
            ((__0 ()) fmt) aname;
431
            Format.fprintf fmt " is ";
432
            ((__1 ()) fmt) adefinition;
433
        | Subtype { name = aname; typ = atyp } ->
434
            Format.fprintf fmt "subtype ";
435
            ((__2 ()) fmt) aname;
436
            Format.fprintf fmt " is ";
437
            ((__3 ()) fmt) atyp;
438
   )
439
    [@ocaml.warning "-A"])
440

  
441
and show_vhdl_definition_t : vhdl_definition_t -> Ppx_deriving_runtime.string
442
  = fun x  -> Format.asprintf "%a" pp_vhdl_definition_t x
443

  
444
(* TODO adapt for Op (more than 2 operand), Time, Sig, suffixMod *)
445
and pp_vhdl_expr_t :
446
  Format.formatter -> vhdl_expr_t -> Ppx_deriving_runtime.unit =
447
  let __11 () = pp_vhdl_expr_t
448
  
449
  and __10 () = pp_vhdl_element_assoc_t
450
  
451
  and __9 () = pp_vhdl_name_t
452
  
453
  and __8 () = pp_vhdl_element_assoc_t
454
  
455
  and __7 () = pp_vhdl_suffix_selection_t
456
  
457
  and __6 () = pp_vhdl_expr_t
458
  
459
  and __5 () = pp_vhdl_signal_attributes_t
460
  
461
  and __4 () = pp_vhdl_name_t
462
  
463
  and __3 () = pp_vhdl_expr_t
464
  
465
  and __2 () = pp_vhdl_name_t
466
  
467
  and __1 () = pp_vhdl_cst_val_t
468
  
469
  and __0 () = pp_vhdl_name_t
470
   in
471
  ((let open! Ppx_deriving_runtime in
472
      fun fmt  ->
473
        function
474
        | Call a0 ->
475
             ((__0 ()) fmt) a0;
476
        | Cst { value = avalue; unit_name = aunit_name } ->
477
             ((__1 ()) fmt) avalue;
478
             (function
479
                | None  -> Format.pp_print_string fmt ""
480
                | Some x ->
481
                    Format.fprintf fmt " ";
482
                    ((__2 ()) fmt) x) aunit_name;
483
        | Op { id = aid; args = aargs } ->
484
            (match aargs with
485
            | [] -> (Format.fprintf fmt "%s") aid;
486
            | hd::[] ->
487
               (Format.fprintf fmt "%s") aid;
488
               ((__3 ()) fmt) hd
489
            | hd::(hd2::[]) ->
490
               Format.fprintf fmt "(";
491
               ((__3 ()) fmt) hd;
492
               (Format.fprintf fmt " %s ") aid;
493
               ((__3 ()) fmt) hd2;
494
               Format.fprintf fmt ")"
495
            | _ ->
496
            (Format.fprintf fmt "@[<2>Op {@,";
497
             ((Format.fprintf fmt "@[%s =@ " "id";
498
               (Format.fprintf fmt "%S") aid;
499
               Format.fprintf fmt "@]");
500
              Format.fprintf fmt ";@ ";
501
              Format.fprintf fmt "@[%s =@ " "args";
502
              ((fun x  ->
503
                  Format.fprintf fmt "@[<2>[";
504
                  ignore
505
                    (List.fold_left
506
                       (fun sep  ->
507
                          fun x  ->
508
                            if sep then Format.fprintf fmt ";@ ";
509
                            ((__3 ()) fmt) x;
510
                            true) false x);
511
                  Format.fprintf fmt "@,]@]")) aargs;
512
              Format.fprintf fmt "@]");
513
             Format.fprintf fmt "@]}"))
514
        | IsNull  -> Format.pp_print_string fmt ""
515
        | Time { value = avalue; phy_unit = aphy_unit } ->
516
            (Format.fprintf fmt "@[<2>Time {@,";
517
             ((Format.fprintf fmt "@[%s =@ " "value";
518
               (Format.fprintf fmt "%d") avalue;
519
               Format.fprintf fmt "@]");
520
              Format.fprintf fmt ";@ ";
521
              Format.fprintf fmt "@[%s =@ " "phy_unit";
522
              (Format.fprintf fmt "%S") aphy_unit;
523
              Format.fprintf fmt "@]");
524
             Format.fprintf fmt "@]}")
525
        | Sig { name = aname; att = aatt } ->
526
            (Format.fprintf fmt "--@[<2>Sig {@,";
527
             ((Format.fprintf fmt "@[%s =@ " "name";
528
               ((__4 ()) fmt) aname;
529
               Format.fprintf fmt "@]");
530
              Format.fprintf fmt ";@ ";
531
              Format.fprintf fmt "@[%s =@ " "att";
532
              ((function
533
                | None  -> Format.pp_print_string fmt "None"
534
                | Some x ->
535
                    (Format.pp_print_string fmt "(Some ";
536
                     ((__5 ()) fmt) x;
537
                     Format.pp_print_string fmt ")"))) aatt;
538
              Format.fprintf fmt "@]");
539
             Format.fprintf fmt "@]}")
540
        | SuffixMod { expr = aexpr; selection = aselection } ->
541
            (Format.fprintf fmt "--@[<2>SuffixMod {@,";
542
             ((Format.fprintf fmt "@[%s =@ " "expr";
543
               ((__6 ()) fmt) aexpr;
544
               Format.fprintf fmt "@]");
545
              Format.fprintf fmt ";@ ";
546
              Format.fprintf fmt "@[%s =@ " "selection";
547
              ((__7 ()) fmt) aselection;
548
              Format.fprintf fmt "@]");
549
             Format.fprintf fmt "@]}")
550
        | Aggregate { elems = aelems } ->
551
            (match aelems with
552
            | [] -> Format.fprintf fmt "";
553
            | _ ->
554
              (Format.fprintf fmt "(@[";
555
              ((fun x  ->
556
                  ignore
557
                    (List.fold_left
558
                       (fun sep  ->
559
                          fun x  ->
560
                            if sep then Format.fprintf fmt ", ";
561
                            ((__8 ()) fmt) x;
562
                            true) false x))) aelems;
563
              Format.fprintf fmt ")@]");)
564
        | QualifiedExpression
565
            { type_mark = atype_mark; aggregate = aaggregate;
566
              expression = aexpression }
567
            ->
568
              ((__9 ()) fmt) atype_mark;
569
              Format.fprintf fmt "'";
570
              (match aaggregate with
571
              | [] -> Format.fprintf fmt "";
572
              | _ -> 
573
                Format.fprintf fmt "(@[<v>";
574
                ((fun x  ->
575
                   ignore
576
                     (List.fold_left
577
                        (fun sep  ->
578
                           fun x  ->
579
                             if sep then Format.fprintf fmt ",@ ";
580
                             ((__10 ()) fmt) x;
581
                             true) false x))) aaggregate;
582
              Format.fprintf fmt ")@]");
583
              (match aexpression with
584
              | None  -> Format.pp_print_string fmt ""
585
              | Some x ->
586
                  Format.fprintf fmt "(@[<v>";
587
                  ((__11 ()) fmt) x;
588
                  Format.fprintf fmt ")@]");
589
        | Others  -> Format.pp_print_string fmt "others")
590
    [@ocaml.warning "-A"])
591

  
592
and show_vhdl_expr_t : vhdl_expr_t -> Ppx_deriving_runtime.string =
593
  fun x  -> Format.asprintf "%a" pp_vhdl_expr_t x
594

  
595
and pp_vhdl_name_t :
596
  Format.formatter -> vhdl_name_t -> Ppx_deriving_runtime.unit =
597
  let __9 () = pp_vhdl_assoc_element_t
598
  
599
  and __8 () = pp_vhdl_name_t
600
  
601
  and __7 () = pp_vhdl_expr_t
602
  
603
  and __6 () = pp_vhdl_name_t
604
  
605
  and __5 () = pp_vhdl_name_t
606
  
607
  and __4 () = pp_vhdl_discrete_range_t
608
  
609
  and __3 () = pp_vhdl_name_t
610
  
611
  and __2 () = pp_vhdl_expr_t
612
  
613
  and __1 () = pp_vhdl_name_t
614
  
615
  and __0 () = pp_vhdl_name_t
616
   in
617
  ((let open! Ppx_deriving_runtime in
618
      fun fmt  ->
619
        function
620
        | Simple a0 ->
621
             (Format.fprintf fmt "%s") a0;
622
        | Identifier a0 ->
623
             (Format.fprintf fmt "%s") a0;
624
        | Selected a0 ->
625
             ((fun x  ->
626
                 ignore
627
                   (List.fold_left
628
                      (fun sep  ->
629
                         fun x  ->
630
                           if sep then Format.fprintf fmt ".";
631
                           ((__0 ()) fmt) x;
632
                           true) false x);) a0;)
633
        | Index { id = aid; exprs = aexprs } ->
634
            ((__1 ()) fmt) aid;
635
            Format.fprintf fmt "(";
636
            (fun x  ->
637
                ignore
638
                (List.fold_left
639
                  (fun sep  ->
640
                    fun x  ->
641
                      if sep then Format.fprintf fmt ",@ ";
642
                                  ((__2 ()) fmt) x;
643
                                  true
644
                  ) false x);
645
            ) aexprs;
646
            Format.fprintf fmt ")";
647
        | Slice { id = aid; range = arange } ->
648
              ((__3 ()) fmt) aid;
649
              Format.fprintf fmt "(";
650
              ((__4 ()) fmt) arange;
651
              Format.fprintf fmt ")";
652
        | Attribute { id = aid; designator = adesignator; expr = aexpr } ->
653
              ((__5 ()) fmt) aid;
654
              Format.fprintf fmt "\'";
655
              ((__6 ()) fmt) adesignator;
656
              (match aexpr with
657
              | IsNull -> Format.fprintf fmt "";
658
              | _ ->
659
                Format.fprintf fmt "(";
660
                ((__7 ()) fmt) aexpr;
661
                Format.fprintf fmt ")")
662
        | Function { id = aid; assoc_list = aassoc_list } ->
663
            (((__8 ()) fmt) aid;
664
            Format.fprintf fmt "(";
665
            ((fun x  ->
666
              Format.fprintf fmt "@[";
667
              ignore
668
                (List.fold_left
669
                   (fun sep  ->
670
                      fun x  ->
671
                        if sep then Format.fprintf fmt ",@ ";
672
                        ((__9 ()) fmt) x;
673
                        true) false x);
674
            Format.fprintf fmt "@]")) aassoc_list;
675
            Format.fprintf fmt ")";)
676
        | NoName  -> Format.pp_print_string fmt "")
677
    [@ocaml.warning "-A"])
678

  
679
and show_vhdl_name_t : vhdl_name_t -> Ppx_deriving_runtime.string =
680
  fun x  -> Format.asprintf "%a" pp_vhdl_name_t x
681

  
682
and pp_vhdl_assoc_element_t :
683
  Format.formatter -> vhdl_assoc_element_t -> Ppx_deriving_runtime.unit =
684
  let __4 () = pp_vhdl_expr_t
685
  
686
  and __3 () = pp_vhdl_name_t
687
  
688
  and __2 () = pp_vhdl_name_t
689
  
690
  and __1 () = pp_vhdl_name_t
691
  
692
  and __0 () = pp_vhdl_name_t
693
   in
694
  ((let open! Ppx_deriving_runtime in
695
      fun fmt  ->
696
        fun x  ->
697
          (match x.formal_name with
698
          | None -> Format.pp_print_string fmt ""
699
          | Some NoName -> Format.pp_print_string fmt ""
700
          | Some a -> 
701
              (((__0 ()) fmt) a;
702
              (match x.formal_arg with
703
              | None -> Format.pp_print_string fmt ""
704
              | Some b -> ((__1 ()) fmt) b);
705
              Format.fprintf fmt " => "));
706
          (match x.actual_name with
707
          | None -> 
708
              ((match x.actual_designator with
709
              | None -> Format.pp_print_string fmt ""
710
              | Some NoName -> Format.pp_print_string fmt ""
711
              | Some b -> ((__3 ()) fmt) b);
712
              (match x.actual_expr with
713
              | None -> Format.pp_print_string fmt ""
714
              | Some IsNull -> Format.pp_print_string fmt ""
715
              | Some c -> ((__4 ()) fmt) c);)
716
          | Some a -> 
717
              (((__2 ()) fmt) a;
718
              (match a with
719
              | NoName -> ()
720
              | _ -> Format.fprintf fmt "(");
721
              (match x.actual_designator with
722
              | None -> Format.pp_print_string fmt ""
723
              | Some b -> ((__3 ()) fmt) b);
724
              (match x.actual_expr with
725
              | None -> Format.pp_print_string fmt ""
726
              | Some IsNull -> Format.pp_print_string fmt ""
727
              | Some c -> ((__4 ()) fmt) c);
728
              (match a with
729
              | NoName -> ()
730
              | _ -> Format.fprintf fmt ")")));)
731
    [@ocaml.warning "-A"])
732

  
733
and show_vhdl_assoc_element_t :
734
  vhdl_assoc_element_t -> Ppx_deriving_runtime.string =
735
  fun x  -> Format.asprintf "%a" pp_vhdl_assoc_element_t x
736

  
737
and pp_vhdl_element_assoc_t :
738
  Format.formatter -> vhdl_element_assoc_t -> Ppx_deriving_runtime.unit =
739
  let __1 () = pp_vhdl_expr_t
740
  
741
  and __0 () = pp_vhdl_expr_t
742
   in
743
  ((let open! Ppx_deriving_runtime in
744
      fun fmt  ->
745
        fun x  ->
746
            (match x.choices with
747
            | [] -> Format.fprintf fmt "";
748
            | _ -> 
749
              (((fun x  ->
750
                ignore
751
                  (List.fold_left
752
                     (fun sep  ->
753
                        fun x  ->
754
                          if sep then Format.fprintf fmt "|@ ";
755
                          ((__0 ()) fmt) x;
756
                          true) false x))) x.choices;
757
              Format.fprintf fmt " => ";));
758
           ((__1 ()) fmt) x.expr)
759
    [@ocaml.warning "-A"])
760

  
761
and show_vhdl_element_assoc_t :
762
  vhdl_element_assoc_t -> Ppx_deriving_runtime.string =
763
  fun x  -> Format.asprintf "%a" pp_vhdl_element_assoc_t x
764

  
765
(* TODO *)
766
and (pp_vhdl_array_attributes_t :
767
      Format.formatter ->
768
        vhdl_array_attributes_t -> Ppx_deriving_runtime.unit)
769
  =
770
  ((let open! Ppx_deriving_runtime in
771
      fun fmt  ->
772
        function
773
        | AAttInt { id = aid; arg = aarg } ->
774
            (Format.fprintf fmt "@[<2>AAttInt {@,";
775
             ((Format.fprintf fmt "@[%s =@ " "id";
776
               (Format.fprintf fmt "%S") aid;
777
               Format.fprintf fmt "@]");
778
              Format.fprintf fmt ";@ ";
779
              Format.fprintf fmt "@[%s =@ " "arg";
780
              (Format.fprintf fmt "%d") aarg;
781
              Format.fprintf fmt "@]");
782
             Format.fprintf fmt "@]}")
783
        | AAttAscending  -> Format.pp_print_string fmt "AAttAscending")
784
  [@ocaml.warning "-A"])
785

  
786
and show_vhdl_array_attributes_t :
787
  vhdl_array_attributes_t -> Ppx_deriving_runtime.string =
788
  fun x  -> Format.asprintf "%a" pp_vhdl_array_attributes_t x
789

  
790
(* TODO *)
791
and (pp_vhdl_signal_attributes_t :
792
      Format.formatter ->
793
        vhdl_signal_attributes_t -> Ppx_deriving_runtime.unit)
794
  =
795
  ((let open! Ppx_deriving_runtime in
796
      fun fmt  ->
797
        function
798
        | SigAtt a0 ->
799
            (Format.fprintf fmt "(@[<2>SigAtt@ ";
800
             (Format.fprintf fmt "%S") a0;
801
             Format.fprintf fmt "@])"))
802
  [@ocaml.warning "-A"])
803

  
804
and show_vhdl_signal_attributes_t :
805
  vhdl_signal_attributes_t -> Ppx_deriving_runtime.string =
806
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_attributes_t x
807

  
808
(* TODO *)
809
and (pp_vhdl_string_attributes_t :
810
      Format.formatter ->
811
        vhdl_string_attributes_t -> Ppx_deriving_runtime.unit)
812
  =
813
  ((let open! Ppx_deriving_runtime in
814
      fun fmt  ->
815
        function
816
        | StringAtt a0 ->
817
            (Format.fprintf fmt "(@[<2>StringAtt@ ";
818
             (Format.fprintf fmt "%S") a0;
819
             Format.fprintf fmt "@])"))
820
  [@ocaml.warning "-A"])
821

  
822
and show_vhdl_string_attributes_t :
823
  vhdl_string_attributes_t -> Ppx_deriving_runtime.string =
824
  fun x  -> Format.asprintf "%a" pp_vhdl_string_attributes_t x
825

  
826
(* TODO *)
827
and (pp_vhdl_suffix_selection_t :
828
      Format.formatter ->
829
        vhdl_suffix_selection_t -> Ppx_deriving_runtime.unit)
830
  =
831
  ((let open! Ppx_deriving_runtime in
832
      fun fmt  ->
833
        function
834
        | Idx a0 ->
835
            (Format.fprintf fmt "(@[<2>Idx@ ";
836
             (Format.fprintf fmt "%d") a0;
837
             Format.fprintf fmt "@])")
838
        | SuffixRange (a0,a1) ->
839
            (Format.fprintf fmt "(@[<2>SuffixRange (@,";
840
             ((Format.fprintf fmt "%d") a0;
841
              Format.fprintf fmt ",@ ";
842
              (Format.fprintf fmt "%d") a1);
843
             Format.fprintf fmt "@,))@]"))
844
  [@ocaml.warning "-A"])
845

  
846
and show_vhdl_suffix_selection_t :
847
  vhdl_suffix_selection_t -> Ppx_deriving_runtime.string =
848
  fun x  -> Format.asprintf "%a" pp_vhdl_suffix_selection_t x
849

  
850
let rec (vhdl_type_t_to_yojson : vhdl_type_t -> Yojson.Safe.json) =
851
  ((let open! Ppx_deriving_yojson_runtime in
852
      function
853
      | Base arg0 ->
854
          `List
855
            [`String "Base";
856
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
857
      | Range (arg0,arg1,arg2) ->
858
          `List
859
            [`String "Range";
860
            ((function
861
              | None  -> `Null
862
              | Some x ->
863
                  ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) x))
864
              arg0;
865
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1;
866
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg2]
867
      | Bit_vector (arg0,arg1) ->
868
          `List
869
            [`String "Bit_vector";
870
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0;
871
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1]
872
      | Array arg0 ->
873
          `List
874
            [`String "ARRAY_TYPE_DEFINITION";
875
            (let fields = []  in
876
             let fields =
877
               ("definition",
878
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x)
879
                    arg0.definition))
880
               :: fields  in
881
             let fields =
882
               if arg0.const = None
883
               then fields
884
               else
885
                 ("const",
886
                   (((function
887
                      | None  -> `Null
888
                      | Some x ->
889
                          ((fun x  -> vhdl_constraint_t_to_yojson x)) x))
890
                      arg0.const))
891
                 :: fields
892
                in
893
             let fields =
894
               if arg0.indexes = []
895
               then fields
896
               else
897
                 ("indexes",
898
                   (((fun x  ->
899
                        `List
900
                          (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
901
                      arg0.indexes))
902
                 :: fields
903
                in
904
             `Assoc fields)]
905
      | Record arg0 ->
906
          `List
907
            [`String "RECORD_TYPE_DEFINITION";
908
            ((fun x  ->
909
                `List
910
                  (List.map
911
                     (fun x  -> vhdl_element_declaration_t_to_yojson x) x)))
912
              arg0]
913
      | Enumerated arg0 ->
914
          `List
915
            [`String "ENUMERATION_TYPE_DEFINITION";
916
            ((fun x  ->
917
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0]
918
      | Void  -> `List [`String "Void"])
919
  [@ocaml.warning "-A"])
920

  
921
and (vhdl_type_t_of_yojson :
922
      Yojson.Safe.json -> vhdl_type_t Ppx_deriving_yojson_runtime.error_or)
923
  =
924
  ((let open! Ppx_deriving_yojson_runtime in
925
      function
926
      | `List ((`String "Base")::arg0::[]) ->
927
          ((function
928
            | `String x -> Result.Ok x
929
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
930
            ((fun arg0  -> Result.Ok (Base arg0)))
931
      | `List ((`String "Range")::arg0::arg1::arg2::[]) ->
932
          ((function
933
            | `Int x -> Result.Ok x
934
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg2) >>=
935
            ((fun arg2  ->
936
                ((function
937
                  | `Int x -> Result.Ok x
938
                  | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg1) >>=
939
                  (fun arg1  ->
940
                     ((function
941
                       | `Null -> Result.Ok None
942
                       | x ->
943
                           ((function
944
                             | `String x -> Result.Ok x
945
                             | _ -> Result.Error "Vhdl_ast.vhdl_type_t") x)
946
                             >>= ((fun x  -> Result.Ok (Some x)))) arg0)
947
                       >>=
948
                       (fun arg0  -> Result.Ok (Range (arg0, arg1, arg2))))))
949
      | `List ((`String "Bit_vector")::arg0::arg1::[]) ->
950
          ((function
951
            | `Int x -> Result.Ok x
952
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg1) >>=
953
            ((fun arg1  ->
954
                ((function
955
                  | `Int x -> Result.Ok x
956
                  | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
957
                  (fun arg0  -> Result.Ok (Bit_vector (arg0, arg1)))))
958
      | `List ((`String "ARRAY_TYPE_DEFINITION")::arg0::[]) ->
959
          ((function
960
            | `Assoc xs ->
961
                let rec loop xs ((arg0,arg1,arg2) as _state) =
962
                  match xs with
963
                  | ("indexes",x)::xs ->
964
                      loop xs
965
                        (((function
966
                           | `List xs ->
967
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
968
                                 [] xs
969
                           | _ -> Result.Error "Vhdl_ast.vhdl_type_t.indexes")
970
                            x), arg1, arg2)
971
                  | ("const",x)::xs ->
972
                      loop xs
973
                        (arg0,
974
                          ((function
975
                            | `Null -> Result.Ok None
976
                            | x ->
977
                                ((fun x  -> vhdl_constraint_t_of_yojson x) x)
978
                                  >>= ((fun x  -> Result.Ok (Some x)))) x),
979
                          arg2)
980
                  | ("definition",x)::xs ->
981
                      loop xs
982
                        (arg0, arg1,
983
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
984
                             x))
985
                  | [] ->
986
                      arg2 >>=
987
                        ((fun arg2  ->
988
                            arg1 >>=
989
                              (fun arg1  ->
990
                                 arg0 >>=
991
                                   (fun arg0  ->
992
                                      Result.Ok
993
                                        (Array
994
                                           {
995
                                             indexes = arg0;
996
                                             const = arg1;
997
                                             definition = arg2
998
                                           })))))
999
                  | _::xs -> loop xs _state  in
1000
                loop xs
1001
                  ((Result.Ok []), (Result.Ok None),
1002
                    (Result.Error "Vhdl_ast.vhdl_type_t.definition"))
1003
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t")) arg0
1004
      | `List ((`String "RECORD_TYPE_DEFINITION")::arg0::[]) ->
1005
          ((function
1006
            | `List xs ->
1007
                map_bind (fun x  -> vhdl_element_declaration_t_of_yojson x)
1008
                  [] xs
1009
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
1010
            ((fun arg0  -> Result.Ok (Record arg0)))
1011
      | `List ((`String "ENUMERATION_TYPE_DEFINITION")::arg0::[]) ->
1012
          ((function
1013
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
1014
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
1015
            ((fun arg0  -> Result.Ok (Enumerated arg0)))
1016
      | `List ((`String "Void")::[]) -> Result.Ok Void
1017
      | _ -> Result.Error "Vhdl_ast.vhdl_type_t")
1018
  [@ocaml.warning "-A"])
1019

  
1020
and (vhdl_element_declaration_t_to_yojson :
1021
      vhdl_element_declaration_t -> Yojson.Safe.json)
1022
  =
1023
  ((let open! Ppx_deriving_yojson_runtime in
1024
      fun x  ->
1025
        let fields = []  in
1026
        let fields =
1027
          ("definition",
1028
            ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.definition))
1029
          :: fields  in
1030
        let fields =
1031
          ("names",
1032
            ((fun x  ->
1033
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
1034
               x.names))
1035
          :: fields  in
1036
        `Assoc fields)
1037
  [@ocaml.warning "-A"])
1038

  
1039
and (vhdl_element_declaration_t_of_yojson :
1040
      Yojson.Safe.json ->
1041
        vhdl_element_declaration_t Ppx_deriving_yojson_runtime.error_or)
1042
  =
1043
  ((let open! Ppx_deriving_yojson_runtime in
1044
      function
1045
      | `Assoc xs ->
1046
          let rec loop xs ((arg0,arg1) as _state) =
1047
            match xs with
1048
            | ("names",x)::xs ->
1049
                loop xs
1050
                  (((function
1051
                     | `List xs ->
1052
                         map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
1053
                     | _ ->
1054
                         Result.Error
1055
                           "Vhdl_ast.vhdl_element_declaration_t.names") x),
1056
                    arg1)
1057
            | ("definition",x)::xs ->
1058
                loop xs
1059
                  (arg0,
1060
                    ((fun x  -> vhdl_subtype_indication_t_of_yojson x) x))
1061
            | [] ->
1062
                arg1 >>=
1063
                  ((fun arg1  ->
1064
                      arg0 >>=
1065
                        (fun arg0  ->
1066
                           Result.Ok { names = arg0; definition = arg1 })))
1067
            | _::xs -> loop xs _state  in
1068
          loop xs
1069
            ((Result.Error "Vhdl_ast.vhdl_element_declaration_t.names"),
1070
              (Result.Error "Vhdl_ast.vhdl_element_declaration_t.definition"))
1071
      | _ -> Result.Error "Vhdl_ast.vhdl_element_declaration_t")
1072
  [@ocaml.warning "-A"])
1073

  
1074
and (vhdl_subtype_indication_t_to_yojson :
1075
      vhdl_subtype_indication_t -> Yojson.Safe.json)
1076
  =
1077
  ((let open! Ppx_deriving_yojson_runtime in
1078
      fun x  ->
1079
        let fields = []  in
1080
        let fields =
1081
          if x.const = NoConstraint
1082
          then fields
1083
          else
1084
            ("const", (((fun x  -> vhdl_constraint_t_to_yojson x)) x.const))
1085
            :: fields
1086
           in
1087
        let fields =
1088
          if x.functionName = NoName
1089
          then fields
1090
          else
1091
            ("functionName",
1092
              (((fun x  -> vhdl_name_t_to_yojson x)) x.functionName))
1093
            :: fields
1094
           in
1095
        let fields =
1096
          if x.name = NoName
1097
          then fields
1098
          else ("name", (((fun x  -> vhdl_name_t_to_yojson x)) x.name)) ::
1099
            fields
1100
           in
1101
        `Assoc fields)
1102
  [@ocaml.warning "-A"])
1103

  
1104
and (vhdl_subtype_indication_t_of_yojson :
1105
      Yojson.Safe.json ->
1106
        vhdl_subtype_indication_t Ppx_deriving_yojson_runtime.error_or)
1107
  =
1108
  ((let open! Ppx_deriving_yojson_runtime in
1109
      function
1110
      | `Assoc xs ->
1111
          let rec loop xs ((arg0,arg1,arg2) as _state) =
1112
            match xs with
1113
            | ("name",x)::xs ->
1114
                loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
1115
            | ("functionName",x)::xs ->
1116
                loop xs (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
1117
            | ("const",x)::xs ->
1118
                loop xs
1119
                  (arg0, arg1, ((fun x  -> vhdl_constraint_t_of_yojson x) x))
1120
            | [] ->
1121
                arg2 >>=
1122
                  ((fun arg2  ->
1123
                      arg1 >>=
1124
                        (fun arg1  ->
1125
                           arg0 >>=
1126
                             (fun arg0  ->
1127
                                Result.Ok
1128
                                  {
1129
                                    name = arg0;
1130
                                    functionName = arg1;
1131
                                    const = arg2
1132
                                  }))))
1133
            | _::xs -> loop xs _state  in
1134
          loop xs
1135
            ((Result.Ok NoName), (Result.Ok NoName),
1136
              (Result.Ok NoConstraint))
1137
      | _ -> Result.Error "Vhdl_ast.vhdl_subtype_indication_t")
1138
  [@ocaml.warning "-A"])
1139

  
1140
and (vhdl_discrete_range_t_to_yojson :
1141
      vhdl_discrete_range_t -> Yojson.Safe.json)
1142
  =
1143
  ((let open! Ppx_deriving_yojson_runtime in
1144
      function
1145
      | SubDiscreteRange arg0 ->
1146
          `List
1147
            [`String "SUB_DISCRETE_RANGE";
1148
            ((fun x  -> vhdl_subtype_indication_t_to_yojson x)) arg0]
1149
      | NamedRange arg0 ->
1150
          `List
1151
            [`String "NAMED_RANGE";
1152
            ((fun x  -> vhdl_name_t_to_yojson x)) arg0]
1153
      | DirectedRange arg0 ->
1154
          `List
1155
            [`String "RANGE_WITH_DIRECTION";
1156
            (let fields = []  in
1157
             let fields =
1158
               ("_to", ((fun x  -> vhdl_expr_t_to_yojson x) arg0._to)) ::
1159
               fields  in
1160
             let fields =
1161
               ("from", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.from)) ::
1162
               fields  in
1163
             let fields =
1164
               ("direction",
1165
                 ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
1166
                    arg0.direction))
1167
               :: fields  in
1168
             `Assoc fields)])
1169
  [@ocaml.warning "-A"])
1170

  
1171
and (vhdl_discrete_range_t_of_yojson :
1172
      Yojson.Safe.json ->
1173
        vhdl_discrete_range_t Ppx_deriving_yojson_runtime.error_or)
1174
  =
1175
  ((let open! Ppx_deriving_yojson_runtime in
1176
      function
1177
      | `List ((`String "SUB_DISCRETE_RANGE")::arg0::[]) ->
1178
          ((fun x  -> vhdl_subtype_indication_t_of_yojson x) arg0) >>=
1179
            ((fun arg0  -> Result.Ok (SubDiscreteRange arg0)))
1180
      | `List ((`String "NAMED_RANGE")::arg0::[]) ->
1181
          ((fun x  -> vhdl_name_t_of_yojson x) arg0) >>=
1182
            ((fun arg0  -> Result.Ok (NamedRange arg0)))
1183
      | `List ((`String "RANGE_WITH_DIRECTION")::arg0::[]) ->
1184
          ((function
1185
            | `Assoc xs ->
1186
                let rec loop xs ((arg0,arg1,arg2) as _state) =
1187
                  match xs with
1188
                  | ("direction",x)::xs ->
1189
                      loop xs
1190
                        (((function
1191
                           | `String x -> Result.Ok x
1192
                           | _ ->
1193
                               Result.Error
1194
                                 "Vhdl_ast.vhdl_discrete_range_t.direction")
1195
                            x), arg1, arg2)
1196
                  | ("from",x)::xs ->
1197
                      loop xs
1198
                        (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x), arg2)
1199
                  | ("_to",x)::xs ->
1200
                      loop xs
1201
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
1202
                  | [] ->
1203
                      arg2 >>=
1204
                        ((fun arg2  ->
1205
                            arg1 >>=
1206
                              (fun arg1  ->
1207
                                 arg0 >>=
1208
                                   (fun arg0  ->
1209
                                      Result.Ok
1210
                                        (DirectedRange
1211
                                           {
1212
                                             direction = arg0;
1213
                                             from = arg1;
1214
                                             _to = arg2
1215
                                           })))))
1216
                  | _::xs -> loop xs _state  in
1217
                loop xs
1218
                  ((Result.Error "Vhdl_ast.vhdl_discrete_range_t.direction"),
1219
                    (Result.Error "Vhdl_ast.vhdl_discrete_range_t.from"),
1220
                    (Result.Error "Vhdl_ast.vhdl_discrete_range_t._to"))
1221
            | _ -> Result.Error "Vhdl_ast.vhdl_discrete_range_t")) arg0
1222
      | _ -> Result.Error "Vhdl_ast.vhdl_discrete_range_t")
1223
  [@ocaml.warning "-A"])
1224

  
1225
and (vhdl_constraint_t_to_yojson : vhdl_constraint_t -> Yojson.Safe.json) =
1226
  ((let open! Ppx_deriving_yojson_runtime in
1227
      function
1228
      | RefConstraint arg0 ->
1229
          `List
1230
            [`String "RefConstraint";
1231
            (let fields = []  in
1232
             let fields =
1233
               ("ref_name",
1234
                 ((fun x  -> vhdl_name_t_to_yojson x) arg0.ref_name))
1235
               :: fields  in
1236
             `Assoc fields)]
1237
      | RangeConstraint arg0 ->
1238
          `List
1239
            [`String "RANGE_CONSTRAINT";
1240
            (let fields = []  in
1241
             let fields =
1242
               ("range",
1243
                 ((fun x  -> vhdl_discrete_range_t_to_yojson x) arg0.range))
1244
               :: fields  in
1245
             `Assoc fields)]
1246
      | IndexConstraint arg0 ->
1247
          `List
1248
            [`String "INDEX_CONSTRAINT";
1249
            (let fields = []  in
1250
             let fields =
1251
               ("ranges",
1252
                 ((fun x  ->
1253
                     `List
1254
                       (List.map
1255
                          (fun x  -> vhdl_discrete_range_t_to_yojson x) x))
1256
                    arg0.ranges))
1257
               :: fields  in
1258
             `Assoc fields)]
1259
      | ArrayConstraint arg0 ->
1260
          `List
1261
            [`String "ARRAY_CONSTRAINT";
1262
            (let fields = []  in
1263
             let fields =
1264
               ("sub", ((fun x  -> vhdl_constraint_t_to_yojson x) arg0.sub))
1265
               :: fields  in
1266
             let fields =
1267
               ("ranges",
1268
                 ((fun x  ->
1269
                     `List
1270
                       (List.map
1271
                          (fun x  -> vhdl_discrete_range_t_to_yojson x) x))
1272
                    arg0.ranges))
1273
               :: fields  in
1274
             `Assoc fields)]
1275
      | RecordConstraint  -> `List [`String "RecordConstraint"]
1276
      | NoConstraint  -> `List [`String "NoConstraint"])
1277
  [@ocaml.warning "-A"])
1278

  
1279
and (vhdl_constraint_t_of_yojson :
1280
      Yojson.Safe.json ->
1281
        vhdl_constraint_t Ppx_deriving_yojson_runtime.error_or)
1282
  =
1283
  ((let open! Ppx_deriving_yojson_runtime in
1284
      function
1285
      | `List ((`String "RefConstraint")::arg0::[]) ->
1286
          ((function
1287
            | `Assoc xs ->
1288
                let rec loop xs (arg0 as _state) =
1289
                  match xs with
1290
                  | ("ref_name",x)::xs ->
1291
                      loop xs ((fun x  -> vhdl_name_t_of_yojson x) x)
1292
                  | [] ->
1293
                      arg0 >>=
1294
                        ((fun arg0  ->
1295
                            Result.Ok (RefConstraint { ref_name = arg0 })))
1296
                  | _::xs -> loop xs _state  in
1297
                loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.ref_name")
1298
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1299
      | `List ((`String "RANGE_CONSTRAINT")::arg0::[]) ->
1300
          ((function
1301
            | `Assoc xs ->
1302
                let rec loop xs (arg0 as _state) =
1303
                  match xs with
1304
                  | ("range",x)::xs ->
1305
                      loop xs
1306
                        ((fun x  -> vhdl_discrete_range_t_of_yojson x) x)
1307
                  | [] ->
1308
                      arg0 >>=
1309
                        ((fun arg0  ->
1310
                            Result.Ok (RangeConstraint { range = arg0 })))
1311
                  | _::xs -> loop xs _state  in
1312
                loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.range")
1313
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1314
      | `List ((`String "INDEX_CONSTRAINT")::arg0::[]) ->
1315
          ((function
1316
            | `Assoc xs ->
1317
                let rec loop xs (arg0 as _state) =
1318
                  match xs with
1319
                  | ("ranges",x)::xs ->
1320
                      loop xs
1321
                        ((function
1322
                          | `List xs ->
1323
                              map_bind
1324
                                (fun x  -> vhdl_discrete_range_t_of_yojson x)
1325
                                [] xs
1326
                          | _ ->
1327
                              Result.Error
1328
                                "Vhdl_ast.vhdl_constraint_t.ranges") x)
1329
                  | [] ->
1330
                      arg0 >>=
1331
                        ((fun arg0  ->
1332
                            Result.Ok (IndexConstraint { ranges = arg0 })))
1333
                  | _::xs -> loop xs _state  in
1334
                loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.ranges")
1335
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1336
      | `List ((`String "ARRAY_CONSTRAINT")::arg0::[]) ->
1337
          ((function
1338
            | `Assoc xs ->
1339
                let rec loop xs ((arg0,arg1) as _state) =
1340
                  match xs with
1341
                  | ("ranges",x)::xs ->
1342
                      loop xs
1343
                        (((function
1344
                           | `List xs ->
1345
                               map_bind
1346
                                 (fun x  -> vhdl_discrete_range_t_of_yojson x)
1347
                                 [] xs
1348
                           | _ ->
1349
                               Result.Error
1350
                                 "Vhdl_ast.vhdl_constraint_t.ranges") x),
1351
                          arg1)
1352
                  | ("sub",x)::xs ->
1353
                      loop xs
1354
                        (arg0, ((fun x  -> vhdl_constraint_t_of_yojson x) x))
1355
                  | [] ->
1356
                      arg1 >>=
1357
                        ((fun arg1  ->
1358
                            arg0 >>=
1359
                              (fun arg0  ->
1360
                                 Result.Ok
1361
                                   (ArrayConstraint
1362
                                      { ranges = arg0; sub = arg1 }))))
1363
                  | _::xs -> loop xs _state  in
1364
                loop xs
1365
                  ((Result.Error "Vhdl_ast.vhdl_constraint_t.ranges"),
1366
                    (Result.Error "Vhdl_ast.vhdl_constraint_t.sub"))
1367
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1368
      | `List ((`String "RecordConstraint")::[]) ->
1369
          Result.Ok RecordConstraint
1370
      | `List ((`String "NoConstraint")::[]) -> Result.Ok NoConstraint
1371
      | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")
1372
  [@ocaml.warning "-A"])
1373

  
1374
and (vhdl_definition_t_to_yojson : vhdl_definition_t -> Yojson.Safe.json) =
1375
  ((let open! Ppx_deriving_yojson_runtime in
1376
      function
1377
      | Type arg0 ->
1378
          `List
1379
            [`String "TYPE_DECLARATION";
1380
            (let fields = []  in
1381
             let fields =
1382
               ("definition",
1383
                 ((fun x  -> vhdl_type_t_to_yojson x) arg0.definition))
1384
               :: fields  in
1385
             let fields =
1386
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
1387
               fields  in
1388
             `Assoc fields)]
1389
      | Subtype arg0 ->
1390
          `List
1391
            [`String "SUBTYPE_DECLARATION";
1392
            (let fields = []  in
1393
             let fields =
1394
               ("typ",
1395
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
1396
               :: fields  in
1397
             let fields =
1398
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
1399
               fields  in
1400
             `Assoc fields)])
1401
  [@ocaml.warning "-A"])
1402

  
1403
and (vhdl_definition_t_of_yojson :
1404
      Yojson.Safe.json ->
1405
        vhdl_definition_t Ppx_deriving_yojson_runtime.error_or)
1406
  =
1407
  ((let open! Ppx_deriving_yojson_runtime in
1408
      function
1409
      | `List ((`String "TYPE_DECLARATION")::arg0::[]) ->
1410
          ((function
1411
            | `Assoc xs ->
1412
                let rec loop xs ((arg0,arg1) as _state) =
1413
                  match xs with
1414
                  | ("name",x)::xs ->
1415
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1416
                  | ("definition",x)::xs ->
1417
                      loop xs (arg0, ((fun x  -> vhdl_type_t_of_yojson x) x))
1418
                  | [] ->
1419
                      arg1 >>=
1420
                        ((fun arg1  ->
1421
                            arg0 >>=
1422
                              (fun arg0  ->
1423
                                 Result.Ok
1424
                                   (Type { name = arg0; definition = arg1 }))))
1425
                  | _::xs -> loop xs _state  in
1426
                loop xs
1427
                  ((Result.Error "Vhdl_ast.vhdl_definition_t.name"),
1428
                    (Result.Error "Vhdl_ast.vhdl_definition_t.definition"))
1429
            | _ -> Result.Error "Vhdl_ast.vhdl_definition_t")) arg0
1430
      | `List ((`String "SUBTYPE_DECLARATION")::arg0::[]) ->
1431
          ((function
1432
            | `Assoc xs ->
1433
                let rec loop xs ((arg0,arg1) as _state) =
1434
                  match xs with
1435
                  | ("name",x)::xs ->
1436
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1437
                  | ("typ",x)::xs ->
1438
                      loop xs
1439
                        (arg0,
1440
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
1441
                             x))
1442
                  | [] ->
1443
                      arg1 >>=
1444
                        ((fun arg1  ->
1445
                            arg0 >>=
1446
                              (fun arg0  ->
1447
                                 Result.Ok
1448
                                   (Subtype { name = arg0; typ = arg1 }))))
1449
                  | _::xs -> loop xs _state  in
1450
                loop xs
1451
                  ((Result.Error "Vhdl_ast.vhdl_definition_t.name"),
1452
                    (Result.Error "Vhdl_ast.vhdl_definition_t.typ"))
1453
            | _ -> Result.Error "Vhdl_ast.vhdl_definition_t")) arg0
1454
      | _ -> Result.Error "Vhdl_ast.vhdl_definition_t")
1455
  [@ocaml.warning "-A"])
1456

  
1457
and (vhdl_expr_t_to_yojson : vhdl_expr_t -> Yojson.Safe.json) =
1458
  ((let open! Ppx_deriving_yojson_runtime in
1459
      function
1460
      | Call arg0 ->
1461
          `List [`String "CALL"; ((fun x  -> vhdl_name_t_to_yojson x)) arg0]
1462
      | Cst arg0 ->
1463
          `List
1464
            [`String "CONSTANT_VALUE";
1465
            (let fields = []  in
1466
             let fields =
1467
               if arg0.unit_name = None
1468
               then fields
1469
               else
1470
                 ("unit_name",
1471
                   (((function
1472
                      | None  -> `Null
1473
                      | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1474
                      arg0.unit_name))
1475
                 :: fields
1476
                in
1477
             let fields =
1478
               ("value", ((fun x  -> vhdl_cst_val_t_to_yojson x) arg0.value))
1479
               :: fields  in
1480
             `Assoc fields)]
1481
      | Op arg0 ->
1482
          `List
1483
            [`String "EXPRESSION";
1484
            (let fields = []  in
1485
             let fields =
1486
               if arg0.args = []
1487
               then fields
1488
               else
1489
                 ("args",
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff