Project

General

Profile

Download (173 KB) Statistics
| Branch: | Tag: | Revision:
1
open Vhdl_ast
2

    
3
let rec (vhdl_cst_val_t_to_yojson : vhdl_cst_val_t -> Yojson.Safe.json) =
4
  ((let open! Ppx_deriving_yojson_runtime in
5
      function
6
      | CstInt arg0 ->
7
          `List
8
            [`String "CstInt";
9
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0]
10
      | CstStdLogic arg0 ->
11
          `List
12
            [`String "CstStdLogic";
13
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
14
      | CstLiteral arg0 ->
15
          `List
16
            [`String "CST_LITERAL";
17
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0])
18
  [@ocaml.warning "-A"])
19

    
20
and (vhdl_cst_val_t_of_yojson :
21
      Yojson.Safe.json -> vhdl_cst_val_t Ppx_deriving_yojson_runtime.error_or)
22
  =
23
  ((let open! Ppx_deriving_yojson_runtime in
24
      function
25
      | `List ((`String "CstInt")::arg0::[]) ->
26
          ((function
27
            | `Int x -> Result.Ok x
28
            | _ -> Result.Error "Vhdl_ast.vhdl_cst_val_t") arg0) >>=
29
            ((fun arg0  -> Result.Ok (CstInt arg0)))
30
      | `List ((`String "CstStdLogic")::arg0::[]) ->
31
          ((function
32
            | `String x -> Result.Ok x
33
            | _ -> Result.Error "Vhdl_ast.vhdl_cst_val_t") arg0) >>=
34
            ((fun arg0  -> Result.Ok (CstStdLogic arg0)))
35
      | `List ((`String "CST_LITERAL")::arg0::[]) ->
36
          ((function
37
            | `String x -> Result.Ok x
38
            | _ -> Result.Error "Vhdl_ast.vhdl_cst_val_t") arg0) >>=
39
            ((fun arg0  -> Result.Ok (CstLiteral arg0)))
40
      | _ -> Result.Error "Vhdl_ast.vhdl_cst_val_t")
41
  [@ocaml.warning "-A"])
42

    
43
let rec (vhdl_type_t_to_yojson : vhdl_type_t -> Yojson.Safe.json) =
44
  ((let open! Ppx_deriving_yojson_runtime in
45
      function
46
      | Base arg0 ->
47
          `List
48
            [`String "Base";
49
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
50
      | Range (arg0,arg1,arg2) ->
51
          `List
52
            [`String "Range";
53
            ((function
54
              | None  -> `Null
55
              | Some x ->
56
                  ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) x))
57
              arg0;
58
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1;
59
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg2]
60
      | Bit_vector (arg0,arg1) ->
61
          `List
62
            [`String "Bit_vector";
63
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0;
64
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1]
65
      | Array arg0 ->
66
          `List
67
            [`String "ARRAY_TYPE_DEFINITION";
68
            (let fields = []  in
69
             let fields =
70
               ("definition",
71
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x)
72
                    arg0.definition))
73
               :: fields  in
74
             let fields =
75
               if arg0.const = None
76
               then fields
77
               else
78
                 ("const",
79
                   (((function
80
                      | None  -> `Null
81
                      | Some x ->
82
                          ((fun x  -> vhdl_constraint_t_to_yojson x)) x))
83
                      arg0.const))
84
                 :: fields
85
                in
86
             let fields =
87
               if arg0.indexes = []
88
               then fields
89
               else
90
                 ("indexes",
91
                   (((fun x  ->
92
                        `List
93
                          (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
94
                      arg0.indexes))
95
                 :: fields
96
                in
97
             `Assoc fields)]
98
      | Record arg0 ->
99
          `List
100
            [`String "RECORD_TYPE_DEFINITION";
101
            ((fun x  ->
102
                `List
103
                  (List.map
104
                     (fun x  -> vhdl_element_declaration_t_to_yojson x) x)))
105
              arg0]
106
      | Enumerated arg0 ->
107
          `List
108
            [`String "ENUMERATION_TYPE_DEFINITION";
109
            ((fun x  ->
110
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0]
111
      | Void  -> `List [`String "Void"])
112
  [@ocaml.warning "-A"])
113

    
114
and (vhdl_type_t_of_yojson :
115
      Yojson.Safe.json -> vhdl_type_t Ppx_deriving_yojson_runtime.error_or)
116
  =
117
  ((let open! Ppx_deriving_yojson_runtime in
118
      function
119
      | `List ((`String "Base")::arg0::[]) ->
120
          ((function
121
            | `String x -> Result.Ok x
122
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
123
            ((fun arg0  -> Result.Ok (Base arg0)))
124
      | `List ((`String "Range")::arg0::arg1::arg2::[]) ->
125
          ((function
126
            | `Int x -> Result.Ok x
127
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg2) >>=
128
            ((fun arg2  ->
129
                ((function
130
                  | `Int x -> Result.Ok x
131
                  | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg1) >>=
132
                  (fun arg1  ->
133
                     ((function
134
                       | `Null -> Result.Ok None
135
                       | x ->
136
                           ((function
137
                             | `String x -> Result.Ok x
138
                             | _ -> Result.Error "Vhdl_ast.vhdl_type_t") x)
139
                             >>= ((fun x  -> Result.Ok (Some x)))) arg0)
140
                       >>=
141
                       (fun arg0  -> Result.Ok (Range (arg0, arg1, arg2))))))
142
      | `List ((`String "Bit_vector")::arg0::arg1::[]) ->
143
          ((function
144
            | `Int x -> Result.Ok x
145
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg1) >>=
146
            ((fun arg1  ->
147
                ((function
148
                  | `Int x -> Result.Ok x
149
                  | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
150
                  (fun arg0  -> Result.Ok (Bit_vector (arg0, arg1)))))
151
      | `List ((`String "ARRAY_TYPE_DEFINITION")::arg0::[]) ->
152
          ((function
153
            | `Assoc xs ->
154
                let rec loop xs ((arg0,arg1,arg2) as _state) =
155
                  match xs with
156
                  | ("indexes",x)::xs ->
157
                      loop xs
158
                        (((function
159
                           | `List xs ->
160
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
161
                                 [] xs
162
                           | _ -> Result.Error "Vhdl_ast.vhdl_type_t.indexes")
163
                            x), arg1, arg2)
164
                  | ("const",x)::xs ->
165
                      loop xs
166
                        (arg0,
167
                          ((function
168
                            | `Null -> Result.Ok None
169
                            | x ->
170
                                ((fun x  -> vhdl_constraint_t_of_yojson x) x)
171
                                  >>= ((fun x  -> Result.Ok (Some x)))) x),
172
                          arg2)
173
                  | ("definition",x)::xs ->
174
                      loop xs
175
                        (arg0, arg1,
176
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
177
                             x))
178
                  | [] ->
179
                      arg2 >>=
180
                        ((fun arg2  ->
181
                            arg1 >>=
182
                              (fun arg1  ->
183
                                 arg0 >>=
184
                                   (fun arg0  ->
185
                                      Result.Ok
186
                                        (Array
187
                                           {
188
                                             indexes = arg0;
189
                                             const = arg1;
190
                                             definition = arg2
191
                                           })))))
192
                  | _::xs -> loop xs _state  in
193
                loop xs
194
                  ((Result.Ok []), (Result.Ok None),
195
                    (Result.Error "Vhdl_ast.vhdl_type_t.definition"))
196
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t")) arg0
197
      | `List ((`String "RECORD_TYPE_DEFINITION")::arg0::[]) ->
198
          ((function
199
            | `List xs ->
200
                map_bind (fun x  -> vhdl_element_declaration_t_of_yojson x)
201
                  [] xs
202
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
203
            ((fun arg0  -> Result.Ok (Record arg0)))
204
      | `List ((`String "ENUMERATION_TYPE_DEFINITION")::arg0::[]) ->
205
          ((function
206
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
207
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
208
            ((fun arg0  -> Result.Ok (Enumerated arg0)))
209
      | `List ((`String "Void")::[]) -> Result.Ok Void
210
      | _ -> Result.Error "Vhdl_ast.vhdl_type_t")
211
  [@ocaml.warning "-A"])
212

    
213
and (vhdl_element_declaration_t_to_yojson :
214
      vhdl_element_declaration_t -> Yojson.Safe.json)
215
  =
216
  ((let open! Ppx_deriving_yojson_runtime in
217
      fun x  ->
218
        let fields = []  in
219
        let fields =
220
          ("definition",
221
            ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.definition))
222
          :: fields  in
223
        let fields =
224
          ("names",
225
            ((fun x  ->
226
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
227
               x.names))
228
          :: fields  in
229
        `Assoc fields)
230
  [@ocaml.warning "-A"])
231

    
232
and (vhdl_element_declaration_t_of_yojson :
233
      Yojson.Safe.json ->
234
        vhdl_element_declaration_t Ppx_deriving_yojson_runtime.error_or)
235
  =
236
  ((let open! Ppx_deriving_yojson_runtime in
237
      function
238
      | `Assoc xs ->
239
          let rec loop xs ((arg0,arg1) as _state) =
240
            match xs with
241
            | ("names",x)::xs ->
242
                loop xs
243
                  (((function
244
                     | `List xs ->
245
                         map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
246
                     | _ ->
247
                         Result.Error
248
                           "Vhdl_ast.vhdl_element_declaration_t.names") x),
249
                    arg1)
250
            | ("definition",x)::xs ->
251
                loop xs
252
                  (arg0,
253
                    ((fun x  -> vhdl_subtype_indication_t_of_yojson x) x))
254
            | [] ->
255
                arg1 >>=
256
                  ((fun arg1  ->
257
                      arg0 >>=
258
                        (fun arg0  ->
259
                           Result.Ok { names = arg0; definition = arg1 })))
260
            | _::xs -> loop xs _state  in
261
          loop xs
262
            ((Result.Error "Vhdl_ast.vhdl_element_declaration_t.names"),
263
              (Result.Error "Vhdl_ast.vhdl_element_declaration_t.definition"))
264
      | _ -> Result.Error "Vhdl_ast.vhdl_element_declaration_t")
265
  [@ocaml.warning "-A"])
266

    
267
and (vhdl_subtype_indication_t_to_yojson :
268
      vhdl_subtype_indication_t -> Yojson.Safe.json)
269
  =
270
  ((let open! Ppx_deriving_yojson_runtime in
271
      fun x  ->
272
        let fields = []  in
273
        let fields =
274
          if x.const = NoConstraint
275
          then fields
276
          else
277
            ("const", (((fun x  -> vhdl_constraint_t_to_yojson x)) x.const))
278
            :: fields
279
           in
280
        let fields =
281
          if x.functionName = NoName
282
          then fields
283
          else
284
            ("functionName",
285
              (((fun x  -> vhdl_name_t_to_yojson x)) x.functionName))
286
            :: fields
287
           in
288
        let fields =
289
          if x.name = NoName
290
          then fields
291
          else ("name", (((fun x  -> vhdl_name_t_to_yojson x)) x.name)) ::
292
            fields
293
           in
294
        `Assoc fields)
295
  [@ocaml.warning "-A"])
296

    
297
and (vhdl_subtype_indication_t_of_yojson :
298
      Yojson.Safe.json ->
299
        vhdl_subtype_indication_t Ppx_deriving_yojson_runtime.error_or)
300
  =
301
  ((let open! Ppx_deriving_yojson_runtime in
302
      function
303
      | `Assoc xs ->
304
          let rec loop xs ((arg0,arg1,arg2) as _state) =
305
            match xs with
306
            | ("name",x)::xs ->
307
                loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
308
            | ("functionName",x)::xs ->
309
                loop xs (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
310
            | ("const",x)::xs ->
311
                loop xs
312
                  (arg0, arg1, ((fun x  -> vhdl_constraint_t_of_yojson x) x))
313
            | [] ->
314
                arg2 >>=
315
                  ((fun arg2  ->
316
                      arg1 >>=
317
                        (fun arg1  ->
318
                           arg0 >>=
319
                             (fun arg0  ->
320
                                Result.Ok
321
                                  {
322
                                    name = arg0;
323
                                    functionName = arg1;
324
                                    const = arg2
325
                                  }))))
326
            | _::xs -> loop xs _state  in
327
          loop xs
328
            ((Result.Ok NoName), (Result.Ok NoName),
329
              (Result.Ok NoConstraint))
330
      | _ -> Result.Error "Vhdl_ast.vhdl_subtype_indication_t")
331
  [@ocaml.warning "-A"])
332

    
333
and (vhdl_discrete_range_t_to_yojson :
334
      vhdl_discrete_range_t -> Yojson.Safe.json)
335
  =
336
  ((let open! Ppx_deriving_yojson_runtime in
337
      function
338
      | SubDiscreteRange arg0 ->
339
          `List
340
            [`String "SUB_DISCRETE_RANGE";
341
            ((fun x  -> vhdl_subtype_indication_t_to_yojson x)) arg0]
342
      | NamedRange arg0 ->
343
          `List
344
            [`String "NAMED_RANGE";
345
            ((fun x  -> vhdl_name_t_to_yojson x)) arg0]
346
      | DirectedRange arg0 ->
347
          `List
348
            [`String "RANGE_WITH_DIRECTION";
349
            (let fields = []  in
350
             let fields =
351
               ("_to", ((fun x  -> vhdl_expr_t_to_yojson x) arg0._to)) ::
352
               fields  in
353
             let fields =
354
               ("from", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.from)) ::
355
               fields  in
356
             let fields =
357
               ("direction",
358
                 ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
359
                    arg0.direction))
360
               :: fields  in
361
             `Assoc fields)])
362
  [@ocaml.warning "-A"])
363

    
364
and (vhdl_discrete_range_t_of_yojson :
365
      Yojson.Safe.json ->
366
        vhdl_discrete_range_t Ppx_deriving_yojson_runtime.error_or)
367
  =
368
  ((let open! Ppx_deriving_yojson_runtime in
369
      function
370
      | `List ((`String "SUB_DISCRETE_RANGE")::arg0::[]) ->
371
          ((fun x  -> vhdl_subtype_indication_t_of_yojson x) arg0) >>=
372
            ((fun arg0  -> Result.Ok (SubDiscreteRange arg0)))
373
      | `List ((`String "NAMED_RANGE")::arg0::[]) ->
374
          ((fun x  -> vhdl_name_t_of_yojson x) arg0) >>=
375
            ((fun arg0  -> Result.Ok (NamedRange arg0)))
376
      | `List ((`String "RANGE_WITH_DIRECTION")::arg0::[]) ->
377
          ((function
378
            | `Assoc xs ->
379
                let rec loop xs ((arg0,arg1,arg2) as _state) =
380
                  match xs with
381
                  | ("direction",x)::xs ->
382
                      loop xs
383
                        (((function
384
                           | `String x -> Result.Ok x
385
                           | _ ->
386
                               Result.Error
387
                                 "Vhdl_ast.vhdl_discrete_range_t.direction")
388
                            x), arg1, arg2)
389
                  | ("from",x)::xs ->
390
                      loop xs
391
                        (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x), arg2)
392
                  | ("_to",x)::xs ->
393
                      loop xs
394
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
395
                  | [] ->
396
                      arg2 >>=
397
                        ((fun arg2  ->
398
                            arg1 >>=
399
                              (fun arg1  ->
400
                                 arg0 >>=
401
                                   (fun arg0  ->
402
                                      Result.Ok
403
                                        (DirectedRange
404
                                           {
405
                                             direction = arg0;
406
                                             from = arg1;
407
                                             _to = arg2
408
                                           })))))
409
                  | _::xs -> loop xs _state  in
410
                loop xs
411
                  ((Result.Error "Vhdl_ast.vhdl_discrete_range_t.direction"),
412
                    (Result.Error "Vhdl_ast.vhdl_discrete_range_t.from"),
413
                    (Result.Error "Vhdl_ast.vhdl_discrete_range_t._to"))
414
            | _ -> Result.Error "Vhdl_ast.vhdl_discrete_range_t")) arg0
415
      | _ -> Result.Error "Vhdl_ast.vhdl_discrete_range_t")
416
  [@ocaml.warning "-A"])
417

    
418
and (vhdl_constraint_t_to_yojson : vhdl_constraint_t -> Yojson.Safe.json) =
419
  ((let open! Ppx_deriving_yojson_runtime in
420
      function
421
      | RefConstraint arg0 ->
422
          `List
423
            [`String "RefConstraint";
424
            (let fields = []  in
425
             let fields =
426
               ("ref_name",
427
                 ((fun x  -> vhdl_name_t_to_yojson x) arg0.ref_name))
428
               :: fields  in
429
             `Assoc fields)]
430
      | RangeConstraint arg0 ->
431
          `List
432
            [`String "RANGE_CONSTRAINT";
433
            (let fields = []  in
434
             let fields =
435
               ("range",
436
                 ((fun x  -> vhdl_discrete_range_t_to_yojson x) arg0.range))
437
               :: fields  in
438
             `Assoc fields)]
439
      | IndexConstraint arg0 ->
440
          `List
441
            [`String "INDEX_CONSTRAINT";
442
            (let fields = []  in
443
             let fields =
444
               ("ranges",
445
                 ((fun x  ->
446
                     `List
447
                       (List.map
448
                          (fun x  -> vhdl_discrete_range_t_to_yojson x) x))
449
                    arg0.ranges))
450
               :: fields  in
451
             `Assoc fields)]
452
      | ArrayConstraint arg0 ->
453
          `List
454
            [`String "ARRAY_CONSTRAINT";
455
            (let fields = []  in
456
             let fields =
457
               ("sub", ((fun x  -> vhdl_constraint_t_to_yojson x) arg0.sub))
458
               :: fields  in
459
             let fields =
460
               ("ranges",
461
                 ((fun x  ->
462
                     `List
463
                       (List.map
464
                          (fun x  -> vhdl_discrete_range_t_to_yojson x) x))
465
                    arg0.ranges))
466
               :: fields  in
467
             `Assoc fields)]
468
      | RecordConstraint  -> `List [`String "RecordConstraint"]
469
      | NoConstraint  -> `List [`String "NoConstraint"])
470
  [@ocaml.warning "-A"])
471

    
472
and (vhdl_constraint_t_of_yojson :
473
      Yojson.Safe.json ->
474
        vhdl_constraint_t Ppx_deriving_yojson_runtime.error_or)
475
  =
476
  ((let open! Ppx_deriving_yojson_runtime in
477
      function
478
      | `List ((`String "RefConstraint")::arg0::[]) ->
479
          ((function
480
            | `Assoc xs ->
481
                let rec loop xs (arg0 as _state) =
482
                  match xs with
483
                  | ("ref_name",x)::xs ->
484
                      loop xs ((fun x  -> vhdl_name_t_of_yojson x) x)
485
                  | [] ->
486
                      arg0 >>=
487
                        ((fun arg0  ->
488
                            Result.Ok (RefConstraint { ref_name = arg0 })))
489
                  | _::xs -> loop xs _state  in
490
                loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.ref_name")
491
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
492
      | `List ((`String "RANGE_CONSTRAINT")::arg0::[]) ->
493
          ((function
494
            | `Assoc xs ->
495
                let rec loop xs (arg0 as _state) =
496
                  match xs with
497
                  | ("range",x)::xs ->
498
                      loop xs
499
                        ((fun x  -> vhdl_discrete_range_t_of_yojson x) x)
500
                  | [] ->
501
                      arg0 >>=
502
                        ((fun arg0  ->
503
                            Result.Ok (RangeConstraint { range = arg0 })))
504
                  | _::xs -> loop xs _state  in
505
                loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.range")
506
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
507
      | `List ((`String "INDEX_CONSTRAINT")::arg0::[]) ->
508
          ((function
509
            | `Assoc xs ->
510
                let rec loop xs (arg0 as _state) =
511
                  match xs with
512
                  | ("ranges",x)::xs ->
513
                      loop xs
514
                        ((function
515
                          | `List xs ->
516
                              map_bind
517
                                (fun x  -> vhdl_discrete_range_t_of_yojson x)
518
                                [] xs
519
                          | _ ->
520
                              Result.Error
521
                                "Vhdl_ast.vhdl_constraint_t.ranges") x)
522
                  | [] ->
523
                      arg0 >>=
524
                        ((fun arg0  ->
525
                            Result.Ok (IndexConstraint { ranges = arg0 })))
526
                  | _::xs -> loop xs _state  in
527
                loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.ranges")
528
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
529
      | `List ((`String "ARRAY_CONSTRAINT")::arg0::[]) ->
530
          ((function
531
            | `Assoc xs ->
532
                let rec loop xs ((arg0,arg1) as _state) =
533
                  match xs with
534
                  | ("ranges",x)::xs ->
535
                      loop xs
536
                        (((function
537
                           | `List xs ->
538
                               map_bind
539
                                 (fun x  -> vhdl_discrete_range_t_of_yojson x)
540
                                 [] xs
541
                           | _ ->
542
                               Result.Error
543
                                 "Vhdl_ast.vhdl_constraint_t.ranges") x),
544
                          arg1)
545
                  | ("sub",x)::xs ->
546
                      loop xs
547
                        (arg0, ((fun x  -> vhdl_constraint_t_of_yojson x) x))
548
                  | [] ->
549
                      arg1 >>=
550
                        ((fun arg1  ->
551
                            arg0 >>=
552
                              (fun arg0  ->
553
                                 Result.Ok
554
                                   (ArrayConstraint
555
                                      { ranges = arg0; sub = arg1 }))))
556
                  | _::xs -> loop xs _state  in
557
                loop xs
558
                  ((Result.Error "Vhdl_ast.vhdl_constraint_t.ranges"),
559
                    (Result.Error "Vhdl_ast.vhdl_constraint_t.sub"))
560
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
561
      | `List ((`String "RecordConstraint")::[]) ->
562
          Result.Ok RecordConstraint
563
      | `List ((`String "NoConstraint")::[]) -> Result.Ok NoConstraint
564
      | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")
565
  [@ocaml.warning "-A"])
566

    
567
and (vhdl_definition_t_to_yojson : vhdl_definition_t -> Yojson.Safe.json) =
568
  ((let open! Ppx_deriving_yojson_runtime in
569
      function
570
      | Type arg0 ->
571
          `List
572
            [`String "TYPE_DECLARATION";
573
            (let fields = []  in
574
             let fields =
575
               ("definition",
576
                 ((fun x  -> vhdl_type_t_to_yojson x) arg0.definition))
577
               :: fields  in
578
             let fields =
579
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
580
               fields  in
581
             `Assoc fields)]
582
      | Subtype arg0 ->
583
          `List
584
            [`String "SUBTYPE_DECLARATION";
585
            (let fields = []  in
586
             let fields =
587
               ("typ",
588
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
589
               :: fields  in
590
             let fields =
591
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
592
               fields  in
593
             `Assoc fields)])
594
  [@ocaml.warning "-A"])
595

    
596
and (vhdl_definition_t_of_yojson :
597
      Yojson.Safe.json ->
598
        vhdl_definition_t Ppx_deriving_yojson_runtime.error_or)
599
  =
600
  ((let open! Ppx_deriving_yojson_runtime in
601
      function
602
      | `List ((`String "TYPE_DECLARATION")::arg0::[]) ->
603
          ((function
604
            | `Assoc xs ->
605
                let rec loop xs ((arg0,arg1) as _state) =
606
                  match xs with
607
                  | ("name",x)::xs ->
608
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
609
                  | ("definition",x)::xs ->
610
                      loop xs (arg0, ((fun x  -> vhdl_type_t_of_yojson x) x))
611
                  | [] ->
612
                      arg1 >>=
613
                        ((fun arg1  ->
614
                            arg0 >>=
615
                              (fun arg0  ->
616
                                 Result.Ok
617
                                   (Type { name = arg0; definition = arg1 }))))
618
                  | _::xs -> loop xs _state  in
619
                loop xs
620
                  ((Result.Error "Vhdl_ast.vhdl_definition_t.name"),
621
                    (Result.Error "Vhdl_ast.vhdl_definition_t.definition"))
622
            | _ -> Result.Error "Vhdl_ast.vhdl_definition_t")) arg0
623
      | `List ((`String "SUBTYPE_DECLARATION")::arg0::[]) ->
624
          ((function
625
            | `Assoc xs ->
626
                let rec loop xs ((arg0,arg1) as _state) =
627
                  match xs with
628
                  | ("name",x)::xs ->
629
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
630
                  | ("typ",x)::xs ->
631
                      loop xs
632
                        (arg0,
633
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
634
                             x))
635
                  | [] ->
636
                      arg1 >>=
637
                        ((fun arg1  ->
638
                            arg0 >>=
639
                              (fun arg0  ->
640
                                 Result.Ok
641
                                   (Subtype { name = arg0; typ = arg1 }))))
642
                  | _::xs -> loop xs _state  in
643
                loop xs
644
                  ((Result.Error "Vhdl_ast.vhdl_definition_t.name"),
645
                    (Result.Error "Vhdl_ast.vhdl_definition_t.typ"))
646
            | _ -> Result.Error "Vhdl_ast.vhdl_definition_t")) arg0
647
      | _ -> Result.Error "Vhdl_ast.vhdl_definition_t")
648
  [@ocaml.warning "-A"])
649

    
650
and (vhdl_expr_t_to_yojson : vhdl_expr_t -> Yojson.Safe.json) =
651
  ((let open! Ppx_deriving_yojson_runtime in
652
      function
653
      | Call arg0 ->
654
          `List [`String "CALL"; ((fun x  -> vhdl_name_t_to_yojson x)) arg0]
655
      | Cst arg0 ->
656
          `List
657
            [`String "CONSTANT_VALUE";
658
            (let fields = []  in
659
             let fields =
660
               if arg0.unit_name = None
661
               then fields
662
               else
663
                 ("unit_name",
664
                   (((function
665
                      | None  -> `Null
666
                      | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
667
                      arg0.unit_name))
668
                 :: fields
669
                in
670
             let fields =
671
               ("value", ((fun x  -> vhdl_cst_val_t_to_yojson x) arg0.value))
672
               :: fields  in
673
             `Assoc fields)]
674
      | Op arg0 ->
675
          `List
676
            [`String "EXPRESSION";
677
            (let fields = []  in
678
             let fields =
679
               if arg0.args = []
680
               then fields
681
               else
682
                 ("args",
683
                   (((fun x  ->
684
                        `List
685
                          (List.map (fun x  -> vhdl_expr_t_to_yojson x) x)))
686
                      arg0.args))
687
                 :: fields
688
                in
689
             let fields =
690
               if arg0.id = ""
691
               then fields
692
               else
693
                 ("id",
694
                   (((fun (x : Ppx_deriving_runtime.string)  -> `String x))
695
                      arg0.id))
696
                 :: fields
697
                in
698
             `Assoc fields)]
699
      | IsNull  -> `List [`String "IsNull"]
700
      | Time arg0 ->
701
          `List
702
            [`String "Time";
703
            (let fields = []  in
704
             let fields =
705
               if arg0.phy_unit = ""
706
               then fields
707
               else
708
                 ("phy_unit",
709
                   (((fun (x : Ppx_deriving_runtime.string)  -> `String x))
710
                      arg0.phy_unit))
711
                 :: fields
712
                in
713
             let fields =
714
               ("value",
715
                 ((fun (x : Ppx_deriving_runtime.int)  -> `Int x) arg0.value))
716
               :: fields  in
717
             `Assoc fields)]
718
      | Sig arg0 ->
719
          `List
720
            [`String "Sig";
721
            (let fields = []  in
722
             let fields =
723
               if arg0.att = None
724
               then fields
725
               else
726
                 ("att",
727
                   (((function
728
                      | None  -> `Null
729
                      | Some x ->
730
                          ((fun x  -> vhdl_signal_attributes_t_to_yojson x))
731
                            x)) arg0.att))
732
                 :: fields
733
                in
734
             let fields =
735
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
736
               fields  in
737
             `Assoc fields)]
738
      | SuffixMod arg0 ->
739
          `List
740
            [`String "SuffixMod";
741
            (let fields = []  in
742
             let fields =
743
               ("selection",
744
                 ((fun x  -> vhdl_suffix_selection_t_to_yojson x)
745
                    arg0.selection))
746
               :: fields  in
747
             let fields =
748
               ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.expr)) ::
749
               fields  in
750
             `Assoc fields)]
751
      | Aggregate arg0 ->
752
          `List
753
            [`String "AGGREGATE";
754
            (let fields = []  in
755
             let fields =
756
               if arg0.elems = []
757
               then fields
758
               else
759
                 ("elems",
760
                   (((fun x  ->
761
                        `List
762
                          (List.map
763
                             (fun x  -> vhdl_element_assoc_t_to_yojson x) x)))
764
                      arg0.elems))
765
                 :: fields
766
                in
767
             `Assoc fields)]
768
      | QualifiedExpression arg0 ->
769
          `List
770
            [`String "QUALIFIED_EXPRESSION";
771
            (let fields = []  in
772
             let fields =
773
               if arg0.expression = None
774
               then fields
775
               else
776
                 ("expression",
777
                   (((function
778
                      | None  -> `Null
779
                      | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x))
780
                      arg0.expression))
781
                 :: fields
782
                in
783
             let fields =
784
               if arg0.aggregate = []
785
               then fields
786
               else
787
                 ("aggregate",
788
                   (((fun x  ->
789
                        `List
790
                          (List.map
791
                             (fun x  -> vhdl_element_assoc_t_to_yojson x) x)))
792
                      arg0.aggregate))
793
                 :: fields
794
                in
795
             let fields =
796
               ("type_mark",
797
                 ((fun x  -> vhdl_name_t_to_yojson x) arg0.type_mark))
798
               :: fields  in
799
             `Assoc fields)]
800
      | Others  -> `List [`String "OTHERS"])
801
  [@ocaml.warning "-A"])
802

    
803
and (vhdl_expr_t_of_yojson :
804
      Yojson.Safe.json -> vhdl_expr_t Ppx_deriving_yojson_runtime.error_or)
805
  =
806
  ((let open! Ppx_deriving_yojson_runtime in
807
      function
808
      | `List ((`String "CALL")::arg0::[]) ->
809
          ((fun x  -> vhdl_name_t_of_yojson x) arg0) >>=
810
            ((fun arg0  -> Result.Ok (Call arg0)))
811
      | `List ((`String "CONSTANT_VALUE")::arg0::[]) ->
812
          ((function
813
            | `Assoc xs ->
814
                let rec loop xs ((arg0,arg1) as _state) =
815
                  match xs with
816
                  | ("value",x)::xs ->
817
                      loop xs
818
                        (((fun x  -> vhdl_cst_val_t_of_yojson x) x), arg1)
819
                  | ("unit_name",x)::xs ->
820
                      loop xs
821
                        (arg0,
822
                          ((function
823
                            | `Null -> Result.Ok None
824
                            | x ->
825
                                ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
826
                                  ((fun x  -> Result.Ok (Some x)))) x))
827
                  | [] ->
828
                      arg1 >>=
829
                        ((fun arg1  ->
830
                            arg0 >>=
831
                              (fun arg0  ->
832
                                 Result.Ok
833
                                   (Cst { value = arg0; unit_name = arg1 }))))
834
                  | _::xs -> loop xs _state  in
835
                loop xs
836
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.value"),
837
                    (Result.Ok None))
838
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
839
      | `List ((`String "EXPRESSION")::arg0::[]) ->
840
          ((function
841
            | `Assoc xs ->
842
                let rec loop xs ((arg0,arg1) as _state) =
843
                  match xs with
844
                  | ("id",x)::xs ->
845
                      loop xs
846
                        (((function
847
                           | `String x -> Result.Ok x
848
                           | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.id") x),
849
                          arg1)
850
                  | ("args",x)::xs ->
851
                      loop xs
852
                        (arg0,
853
                          ((function
854
                            | `List xs ->
855
                                map_bind (fun x  -> vhdl_expr_t_of_yojson x)
856
                                  [] xs
857
                            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.args")
858
                             x))
859
                  | [] ->
860
                      arg1 >>=
861
                        ((fun arg1  ->
862
                            arg0 >>=
863
                              (fun arg0  ->
864
                                 Result.Ok (Op { id = arg0; args = arg1 }))))
865
                  | _::xs -> loop xs _state  in
866
                loop xs ((Result.Ok ""), (Result.Ok []))
867
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
868
      | `List ((`String "IsNull")::[]) -> Result.Ok IsNull
869
      | `List ((`String "Time")::arg0::[]) ->
870
          ((function
871
            | `Assoc xs ->
872
                let rec loop xs ((arg0,arg1) as _state) =
873
                  match xs with
874
                  | ("value",x)::xs ->
875
                      loop xs
876
                        (((function
877
                           | `Int x -> Result.Ok x
878
                           | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.value")
879
                            x), arg1)
880
                  | ("phy_unit",x)::xs ->
881
                      loop xs
882
                        (arg0,
883
                          ((function
884
                            | `String x -> Result.Ok x
885
                            | _ ->
886
                                Result.Error "Vhdl_ast.vhdl_expr_t.phy_unit")
887
                             x))
888
                  | [] ->
889
                      arg1 >>=
890
                        ((fun arg1  ->
891
                            arg0 >>=
892
                              (fun arg0  ->
893
                                 Result.Ok
894
                                   (Time { value = arg0; phy_unit = arg1 }))))
895
                  | _::xs -> loop xs _state  in
896
                loop xs
897
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.value"),
898
                    (Result.Ok ""))
899
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
900
      | `List ((`String "Sig")::arg0::[]) ->
901
          ((function
902
            | `Assoc xs ->
903
                let rec loop xs ((arg0,arg1) as _state) =
904
                  match xs with
905
                  | ("name",x)::xs ->
906
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
907
                  | ("att",x)::xs ->
908
                      loop xs
909
                        (arg0,
910
                          ((function
911
                            | `Null -> Result.Ok None
912
                            | x ->
913
                                ((fun x  ->
914
                                    vhdl_signal_attributes_t_of_yojson x) x)
915
                                  >>= ((fun x  -> Result.Ok (Some x)))) x))
916
                  | [] ->
917
                      arg1 >>=
918
                        ((fun arg1  ->
919
                            arg0 >>=
920
                              (fun arg0  ->
921
                                 Result.Ok (Sig { name = arg0; att = arg1 }))))
922
                  | _::xs -> loop xs _state  in
923
                loop xs
924
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.name"),
925
                    (Result.Ok None))
926
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
927
      | `List ((`String "SuffixMod")::arg0::[]) ->
928
          ((function
929
            | `Assoc xs ->
930
                let rec loop xs ((arg0,arg1) as _state) =
931
                  match xs with
932
                  | ("expr",x)::xs ->
933
                      loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
934
                  | ("selection",x)::xs ->
935
                      loop xs
936
                        (arg0,
937
                          ((fun x  -> vhdl_suffix_selection_t_of_yojson x) x))
938
                  | [] ->
939
                      arg1 >>=
940
                        ((fun arg1  ->
941
                            arg0 >>=
942
                              (fun arg0  ->
943
                                 Result.Ok
944
                                   (SuffixMod
945
                                      { expr = arg0; selection = arg1 }))))
946
                  | _::xs -> loop xs _state  in
947
                loop xs
948
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.expr"),
949
                    (Result.Error "Vhdl_ast.vhdl_expr_t.selection"))
950
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
951
      | `List ((`String "AGGREGATE")::arg0::[]) ->
952
          ((function
953
            | `Assoc xs ->
954
                let rec loop xs (arg0 as _state) =
955
                  match xs with
956
                  | ("elems",x)::xs ->
957
                      loop xs
958
                        ((function
959
                          | `List xs ->
960
                              map_bind
961
                                (fun x  -> vhdl_element_assoc_t_of_yojson x)
962
                                [] xs
963
                          | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.elems") x)
964
                  | [] ->
965
                      arg0 >>=
966
                        ((fun arg0  -> Result.Ok (Aggregate { elems = arg0 })))
967
                  | _::xs -> loop xs _state  in
968
                loop xs (Result.Ok [])
969
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
970
      | `List ((`String "QUALIFIED_EXPRESSION")::arg0::[]) ->
971
          ((function
972
            | `Assoc xs ->
973
                let rec loop xs ((arg0,arg1,arg2) as _state) =
974
                  match xs with
975
                  | ("type_mark",x)::xs ->
976
                      loop xs
977
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
978
                  | ("aggregate",x)::xs ->
979
                      loop xs
980
                        (arg0,
981
                          ((function
982
                            | `List xs ->
983
                                map_bind
984
                                  (fun x  -> vhdl_element_assoc_t_of_yojson x)
985
                                  [] xs
986
                            | _ ->
987
                                Result.Error "Vhdl_ast.vhdl_expr_t.aggregate")
988
                             x), arg2)
989
                  | ("expression",x)::xs ->
990
                      loop xs
991
                        (arg0, arg1,
992
                          ((function
993
                            | `Null -> Result.Ok None
994
                            | x ->
995
                                ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
996
                                  ((fun x  -> Result.Ok (Some x)))) x))
997
                  | [] ->
998
                      arg2 >>=
999
                        ((fun arg2  ->
1000
                            arg1 >>=
1001
                              (fun arg1  ->
1002
                                 arg0 >>=
1003
                                   (fun arg0  ->
1004
                                      Result.Ok
1005
                                        (QualifiedExpression
1006
                                           {
1007
                                             type_mark = arg0;
1008
                                             aggregate = arg1;
1009
                                             expression = arg2
1010
                                           })))))
1011
                  | _::xs -> loop xs _state  in
1012
                loop xs
1013
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.type_mark"),
1014
                    (Result.Ok []), (Result.Ok None))
1015
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1016
      | `List ((`String "OTHERS")::[]) -> Result.Ok Others
1017
      | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")
1018
  [@ocaml.warning "-A"])
1019

    
1020
and (vhdl_name_t_to_yojson : vhdl_name_t -> Yojson.Safe.json) =
1021
  ((let open! Ppx_deriving_yojson_runtime in
1022
      function
1023
      | Simple arg0 ->
1024
          `List
1025
            [`String "SIMPLE_NAME";
1026
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
1027
      | Identifier arg0 ->
1028
          `List
1029
            [`String "IDENTIFIER";
1030
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
1031
      | Selected arg0 ->
1032
          `List
1033
            [`String "SELECTED_NAME";
1034
            ((fun x  ->
1035
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0]
1036
      | Index arg0 ->
1037
          `List
1038
            [`String "INDEXED_NAME";
1039
            (let fields = []  in
1040
             let fields =
1041
               ("exprs",
1042
                 ((fun x  ->
1043
                     `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
1044
                    arg0.exprs))
1045
               :: fields  in
1046
             let fields =
1047
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1048
               fields  in
1049
             `Assoc fields)]
1050
      | Slice arg0 ->
1051
          `List
1052
            [`String "SLICE_NAME";
1053
            (let fields = []  in
1054
             let fields =
1055
               ("range",
1056
                 ((fun x  -> vhdl_discrete_range_t_to_yojson x) arg0.range))
1057
               :: fields  in
1058
             let fields =
1059
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1060
               fields  in
1061
             `Assoc fields)]
1062
      | Attribute arg0 ->
1063
          `List
1064
            [`String "ATTRIBUTE_NAME";
1065
            (let fields = []  in
1066
             let fields =
1067
               if arg0.expr = IsNull
1068
               then fields
1069
               else
1070
                 ("expr", (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.expr))
1071
                 :: fields
1072
                in
1073
             let fields =
1074
               ("designator",
1075
                 ((fun x  -> vhdl_name_t_to_yojson x) arg0.designator))
1076
               :: fields  in
1077
             let fields =
1078
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1079
               fields  in
1080
             `Assoc fields)]
1081
      | Function arg0 ->
1082
          `List
1083
            [`String "FUNCTION_CALL";
1084
            (let fields = []  in
1085
             let fields =
1086
               ("assoc_list",
1087
                 ((fun x  ->
1088
                     `List
1089
                       (List.map (fun x  -> vhdl_assoc_element_t_to_yojson x)
1090
                          x)) arg0.assoc_list))
1091
               :: fields  in
1092
             let fields =
1093
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1094
               fields  in
1095
             `Assoc fields)]
1096
      | Open  -> `List [`String "OPEN"]
1097
      | NoName  -> `List [`String "NoName"])
1098
  [@ocaml.warning "-A"])
1099

    
1100
and (vhdl_name_t_of_yojson :
1101
      Yojson.Safe.json -> vhdl_name_t Ppx_deriving_yojson_runtime.error_or)
1102
  =
1103
  ((let open! Ppx_deriving_yojson_runtime in
1104
      function
1105
      | `List ((`String "SIMPLE_NAME")::arg0::[]) ->
1106
          ((function
1107
            | `String x -> Result.Ok x
1108
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
1109
            ((fun arg0  -> Result.Ok (Simple arg0)))
1110
      | `List ((`String "IDENTIFIER")::arg0::[]) ->
1111
          ((function
1112
            | `String x -> Result.Ok x
1113
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
1114
            ((fun arg0  -> Result.Ok (Identifier arg0)))
1115
      | `List ((`String "SELECTED_NAME")::arg0::[]) ->
1116
          ((function
1117
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
1118
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
1119
            ((fun arg0  -> Result.Ok (Selected arg0)))
1120
      | `List ((`String "INDEXED_NAME")::arg0::[]) ->
1121
          ((function
1122
            | `Assoc xs ->
1123
                let rec loop xs ((arg0,arg1) as _state) =
1124
                  match xs with
1125
                  | ("id",x)::xs ->
1126
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1127
                  | ("exprs",x)::xs ->
1128
                      loop xs
1129
                        (arg0,
1130
                          ((function
1131
                            | `List xs ->
1132
                                map_bind (fun x  -> vhdl_expr_t_of_yojson x)
1133
                                  [] xs
1134
                            | _ -> Result.Error "Vhdl_ast.vhdl_name_t.exprs")
1135
                             x))
1136
                  | [] ->
1137
                      arg1 >>=
1138
                        ((fun arg1  ->
1139
                            arg0 >>=
1140
                              (fun arg0  ->
1141
                                 Result.Ok
1142
                                   (Index { id = arg0; exprs = arg1 }))))
1143
                  | _::xs -> loop xs _state  in
1144
                loop xs
1145
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1146
                    (Result.Error "Vhdl_ast.vhdl_name_t.exprs"))
1147
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1148
      | `List ((`String "SLICE_NAME")::arg0::[]) ->
1149
          ((function
1150
            | `Assoc xs ->
1151
                let rec loop xs ((arg0,arg1) as _state) =
1152
                  match xs with
1153
                  | ("id",x)::xs ->
1154
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1155
                  | ("range",x)::xs ->
1156
                      loop xs
1157
                        (arg0,
1158
                          ((fun x  -> vhdl_discrete_range_t_of_yojson x) x))
1159
                  | [] ->
1160
                      arg1 >>=
1161
                        ((fun arg1  ->
1162
                            arg0 >>=
1163
                              (fun arg0  ->
1164
                                 Result.Ok
1165
                                   (Slice { id = arg0; range = arg1 }))))
1166
                  | _::xs -> loop xs _state  in
1167
                loop xs
1168
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1169
                    (Result.Error "Vhdl_ast.vhdl_name_t.range"))
1170
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1171
      | `List ((`String "ATTRIBUTE_NAME")::arg0::[]) ->
1172
          ((function
1173
            | `Assoc xs ->
1174
                let rec loop xs ((arg0,arg1,arg2) as _state) =
1175
                  match xs with
1176
                  | ("id",x)::xs ->
1177
                      loop xs
1178
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
1179
                  | ("designator",x)::xs ->
1180
                      loop xs
1181
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
1182
                  | ("expr",x)::xs ->
1183
                      loop xs
1184
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
1185
                  | [] ->
1186
                      arg2 >>=
1187
                        ((fun arg2  ->
1188
                            arg1 >>=
1189
                              (fun arg1  ->
1190
                                 arg0 >>=
1191
                                   (fun arg0  ->
1192
                                      Result.Ok
1193
                                        (Attribute
1194
                                           {
1195
                                             id = arg0;
1196
                                             designator = arg1;
1197
                                             expr = arg2
1198
                                           })))))
1199
                  | _::xs -> loop xs _state  in
1200
                loop xs
1201
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1202
                    (Result.Error "Vhdl_ast.vhdl_name_t.designator"),
1203
                    (Result.Ok IsNull))
1204
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1205
      | `List ((`String "FUNCTION_CALL")::arg0::[]) ->
1206
          ((function
1207
            | `Assoc xs ->
1208
                let rec loop xs ((arg0,arg1) as _state) =
1209
                  match xs with
1210
                  | ("id",x)::xs ->
1211
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1212
                  | ("assoc_list",x)::xs ->
1213
                      loop xs
1214
                        (arg0,
1215
                          ((function
1216
                            | `List xs ->
1217
                                map_bind
1218
                                  (fun x  -> vhdl_assoc_element_t_of_yojson x)
1219
                                  [] xs
1220
                            | _ ->
1221
                                Result.Error
1222
                                  "Vhdl_ast.vhdl_name_t.assoc_list") x))
1223
                  | [] ->
1224
                      arg1 >>=
1225
                        ((fun arg1  ->
1226
                            arg0 >>=
1227
                              (fun arg0  ->
1228
                                 Result.Ok
1229
                                   (Function { id = arg0; assoc_list = arg1 }))))
1230
                  | _::xs -> loop xs _state  in
1231
                loop xs
1232
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1233
                    (Result.Error "Vhdl_ast.vhdl_name_t.assoc_list"))
1234
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1235
      | `List ((`String "OPEN")::[]) -> Result.Ok Open
1236
      | `List ((`String "NoName")::[]) -> Result.Ok NoName
1237
      | _ -> Result.Error "Vhdl_ast.vhdl_name_t")
1238
  [@ocaml.warning "-A"])
1239

    
1240
and (vhdl_assoc_element_t_to_yojson :
1241
      vhdl_assoc_element_t -> Yojson.Safe.json)
1242
  =
1243
  ((let open! Ppx_deriving_yojson_runtime in
1244
      fun x  ->
1245
        let fields = []  in
1246
        let fields =
1247
          if x.actual_expr = None
1248
          then fields
1249
          else
1250
            ("actual_expr",
1251
              (((function
1252
                 | None  -> `Null
1253
                 | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x))
1254
                 x.actual_expr))
1255
            :: fields
1256
           in
1257
        let fields =
1258
          if x.actual_designator = None
1259
          then fields
1260
          else
1261
            ("actual_designator",
1262
              (((function
1263
                 | None  -> `Null
1264
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1265
                 x.actual_designator))
1266
            :: fields
1267
           in
1268
        let fields =
1269
          if x.actual_name = None
1270
          then fields
1271
          else
1272
            ("actual_name",
1273
              (((function
1274
                 | None  -> `Null
1275
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1276
                 x.actual_name))
1277
            :: fields
1278
           in
1279
        let fields =
1280
          if x.formal_arg = None
1281
          then fields
1282
          else
1283
            ("formal_arg",
1284
              (((function
1285
                 | None  -> `Null
1286
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1287
                 x.formal_arg))
1288
            :: fields
1289
           in
1290
        let fields =
1291
          if x.formal_name = None
1292
          then fields
1293
          else
1294
            ("formal_name",
1295
              (((function
1296
                 | None  -> `Null
1297
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1298
                 x.formal_name))
1299
            :: fields
1300
           in
1301
        `Assoc fields)
1302
  [@ocaml.warning "-A"])
1303

    
1304
and (vhdl_assoc_element_t_of_yojson :
1305
      Yojson.Safe.json ->
1306
        vhdl_assoc_element_t Ppx_deriving_yojson_runtime.error_or)
1307
  =
1308
  ((let open! Ppx_deriving_yojson_runtime in
1309
      function
1310
      | `Assoc xs ->
1311
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
1312
            match xs with
1313
            | ("formal_name",x)::xs ->
1314
                loop xs
1315
                  (((function
1316
                     | `Null -> Result.Ok None
1317
                     | x ->
1318
                         ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1319
                           ((fun x  -> Result.Ok (Some x)))) x), arg1, arg2,
1320
                    arg3, arg4)
1321
            | ("formal_arg",x)::xs ->
1322
                loop xs
1323
                  (arg0,
1324
                    ((function
1325
                      | `Null -> Result.Ok None
1326
                      | x ->
1327
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1328
                            ((fun x  -> Result.Ok (Some x)))) x), arg2, arg3,
1329
                    arg4)
1330
            | ("actual_name",x)::xs ->
1331
                loop xs
1332
                  (arg0, arg1,
1333
                    ((function
1334
                      | `Null -> Result.Ok None
1335
                      | x ->
1336
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1337
                            ((fun x  -> Result.Ok (Some x)))) x), arg3, arg4)
1338
            | ("actual_designator",x)::xs ->
1339
                loop xs
1340
                  (arg0, arg1, arg2,
1341
                    ((function
1342
                      | `Null -> Result.Ok None
1343
                      | x ->
1344
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1345
                            ((fun x  -> Result.Ok (Some x)))) x), arg4)
1346
            | ("actual_expr",x)::xs ->
1347
                loop xs
1348
                  (arg0, arg1, arg2, arg3,
1349
                    ((function
1350
                      | `Null -> Result.Ok None
1351
                      | x ->
1352
                          ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
1353
                            ((fun x  -> Result.Ok (Some x)))) x))
1354
            | [] ->
1355
                arg4 >>=
1356
                  ((fun arg4  ->
1357
                      arg3 >>=
1358
                        (fun arg3  ->
1359
                           arg2 >>=
1360
                             (fun arg2  ->
1361
                                arg1 >>=
1362
                                  (fun arg1  ->
1363
                                     arg0 >>=
1364
                                       (fun arg0  ->
1365
                                          Result.Ok
1366
                                            {
1367
                                              formal_name = arg0;
1368
                                              formal_arg = arg1;
1369
                                              actual_name = arg2;
1370
                                              actual_designator = arg3;
1371
                                              actual_expr = arg4
1372
                                            }))))))
1373
            | _::xs -> loop xs _state  in
1374
          loop xs
1375
            ((Result.Ok (Some NoName)), (Result.Ok (Some NoName)),
1376
              (Result.Ok (Some NoName)), (Result.Ok (Some NoName)),
1377
              (Result.Ok (Some IsNull)))
1378
      | _ -> Result.Error "Vhdl_ast.vhdl_assoc_element_t")
1379
  [@ocaml.warning "-A"])
1380

    
1381
and (vhdl_element_assoc_t_to_yojson :
1382
      vhdl_element_assoc_t -> Yojson.Safe.json)
1383
  =
1384
  ((let open! Ppx_deriving_yojson_runtime in
1385
      fun x  ->
1386
        let fields = []  in
1387
        let fields = ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) x.expr))
1388
          :: fields  in
1389
        let fields =
1390
          if x.choices = []
1391
          then fields
1392
          else
1393
            ("choices",
1394
              (((fun x  ->
1395
                   `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x)))
1396
                 x.choices))
1397
            :: fields
1398
           in
1399
        `Assoc fields)
1400
  [@ocaml.warning "-A"])
1401

    
1402
and (vhdl_element_assoc_t_of_yojson :
1403
      Yojson.Safe.json ->
1404
        vhdl_element_assoc_t Ppx_deriving_yojson_runtime.error_or)
1405
  =
1406
  ((let open! Ppx_deriving_yojson_runtime in
1407
      function
1408
      | `Assoc xs ->
1409
          let rec loop xs ((arg0,arg1) as _state) =
1410
            match xs with
1411
            | ("choices",x)::xs ->
1412
                loop xs
1413
                  (((function
1414
                     | `List xs ->
1415
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
1416
                     | _ ->
1417
                         Result.Error "Vhdl_ast.vhdl_element_assoc_t.choices")
1418
                      x), arg1)
1419
            | ("expr",x)::xs ->
1420
                loop xs (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x))
1421
            | [] ->
1422
                arg1 >>=
1423
                  ((fun arg1  ->
1424
                      arg0 >>=
1425
                        (fun arg0  ->
1426
                           Result.Ok { choices = arg0; expr = arg1 })))
1427
            | _::xs -> loop xs _state  in
1428
          loop xs
1429
            ((Result.Ok []),
1430
              (Result.Error "Vhdl_ast.vhdl_element_assoc_t.expr"))
1431
      | _ -> Result.Error "Vhdl_ast.vhdl_element_assoc_t")
1432
  [@ocaml.warning "-A"])
1433

    
1434
and (vhdl_array_attributes_t_to_yojson :
1435
      vhdl_array_attributes_t -> Yojson.Safe.json)
1436
  =
1437
  ((let open! Ppx_deriving_yojson_runtime in
1438
      function
1439
      | AAttInt arg0 ->
1440
          `List
1441
            [`String "AAttInt";
1442
            (let fields = []  in
1443
             let fields =
1444
               ("arg",
1445
                 ((fun (x : Ppx_deriving_runtime.int)  -> `Int x) arg0.arg))
1446
               :: fields  in
1447
             let fields =
1448
               ("id",
1449
                 ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
1450
                    arg0.id))
1451
               :: fields  in
1452
             `Assoc fields)]
1453
      | AAttAscending  -> `List [`String "AAttAscending"])
1454
  [@ocaml.warning "-A"])
1455

    
1456
and (vhdl_array_attributes_t_of_yojson :
1457
      Yojson.Safe.json ->
1458
        vhdl_array_attributes_t Ppx_deriving_yojson_runtime.error_or)
1459
  =
1460
  ((let open! Ppx_deriving_yojson_runtime in
1461
      function
1462
      | `List ((`String "AAttInt")::arg0::[]) ->
1463
          ((function
1464
            | `Assoc xs ->
1465
                let rec loop xs ((arg0,arg1) as _state) =
1466
                  match xs with
1467
                  | ("id",x)::xs ->
1468
                      loop xs
1469
                        (((function
1470
                           | `String x -> Result.Ok x
1471
                           | _ ->
1472
                               Result.Error
1473
                                 "Vhdl_ast.vhdl_array_attributes_t.id") x),
1474
                          arg1)
1475
                  | ("arg",x)::xs ->
1476
                      loop xs
1477
                        (arg0,
1478
                          ((function
1479
                            | `Int x -> Result.Ok x
1480
                            | _ ->
1481
                                Result.Error
1482
                                  "Vhdl_ast.vhdl_array_attributes_t.arg") x))
1483
                  | [] ->
1484
                      arg1 >>=
1485
                        ((fun arg1  ->
1486
                            arg0 >>=
1487
                              (fun arg0  ->
1488
                                 Result.Ok
1489
                                   (AAttInt { id = arg0; arg = arg1 }))))
1490
                  | _::xs -> loop xs _state  in
1491
                loop xs
1492
                  ((Result.Error "Vhdl_ast.vhdl_array_attributes_t.id"),
1493
                    (Result.Error "Vhdl_ast.vhdl_array_attributes_t.arg"))
1494
            | _ -> Result.Error "Vhdl_ast.vhdl_array_attributes_t")) arg0
1495
      | `List ((`String "AAttAscending")::[]) -> Result.Ok AAttAscending
1496
      | _ -> Result.Error "Vhdl_ast.vhdl_array_attributes_t")
1497
  [@ocaml.warning "-A"])
1498

    
1499
and (vhdl_signal_attributes_t_to_yojson :
1500
      vhdl_signal_attributes_t -> Yojson.Safe.json)
1501
  =
1502
  ((let open! Ppx_deriving_yojson_runtime in
1503
      function
1504
      | SigAtt arg0 ->
1505
          `List
1506
            [`String "SigAtt";
1507
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0])
1508
  [@ocaml.warning "-A"])
1509

    
1510
and (vhdl_signal_attributes_t_of_yojson :
1511
      Yojson.Safe.json ->
1512
        vhdl_signal_attributes_t Ppx_deriving_yojson_runtime.error_or)
1513
  =
1514
  ((let open! Ppx_deriving_yojson_runtime in
1515
      function
1516
      | `List ((`String "SigAtt")::arg0::[]) ->
1517
          ((function
1518
            | `String x -> Result.Ok x
1519
            | _ -> Result.Error "Vhdl_ast.vhdl_signal_attributes_t") arg0)
1520
            >>= ((fun arg0  -> Result.Ok (SigAtt arg0)))
1521
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_attributes_t")
1522
  [@ocaml.warning "-A"])
1523

    
1524
and (vhdl_string_attributes_t_to_yojson :
1525
      vhdl_string_attributes_t -> Yojson.Safe.json)
1526
  =
1527
  ((let open! Ppx_deriving_yojson_runtime in
1528
      function
1529
      | StringAtt arg0 ->
1530
          `List
1531
            [`String "StringAtt";
1532
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0])
1533
  [@ocaml.warning "-A"])
1534

    
1535
and (vhdl_string_attributes_t_of_yojson :
1536
      Yojson.Safe.json ->
1537
        vhdl_string_attributes_t Ppx_deriving_yojson_runtime.error_or)
1538
  =
1539
  ((let open! Ppx_deriving_yojson_runtime in
1540
      function
1541
      | `List ((`String "StringAtt")::arg0::[]) ->
1542
          ((function
1543
            | `String x -> Result.Ok x
1544
            | _ -> Result.Error "Vhdl_ast.vhdl_string_attributes_t") arg0)
1545
            >>= ((fun arg0  -> Result.Ok (StringAtt arg0)))
1546
      | _ -> Result.Error "Vhdl_ast.vhdl_string_attributes_t")
1547
  [@ocaml.warning "-A"])
1548

    
1549
and (vhdl_suffix_selection_t_to_yojson :
1550
      vhdl_suffix_selection_t -> Yojson.Safe.json)
1551
  =
1552
  ((let open! Ppx_deriving_yojson_runtime in
1553
      function
1554
      | Idx arg0 ->
1555
          `List
1556
            [`String "Idx";
1557
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0]
1558
      | SuffixRange (arg0,arg1) ->
1559
          `List
1560
            [`String "SuffixRange";
1561
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0;
1562
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1])
1563
  [@ocaml.warning "-A"])
1564

    
1565
and (vhdl_suffix_selection_t_of_yojson :
1566
      Yojson.Safe.json ->
1567
        vhdl_suffix_selection_t Ppx_deriving_yojson_runtime.error_or)
1568
  =
1569
  ((let open! Ppx_deriving_yojson_runtime in
1570
      function
1571
      | `List ((`String "Idx")::arg0::[]) ->
1572
          ((function
1573
            | `Int x -> Result.Ok x
1574
            | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") arg0) >>=
1575
            ((fun arg0  -> Result.Ok (Idx arg0)))
1576
      | `List ((`String "SuffixRange")::arg0::arg1::[]) ->
1577
          ((function
1578
            | `Int x -> Result.Ok x
1579
            | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") arg1) >>=
1580
            ((fun arg1  ->
1581
                ((function
1582
                  | `Int x -> Result.Ok x
1583
                  | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t")
1584
                   arg0)
1585
                  >>= (fun arg0  -> Result.Ok (SuffixRange (arg0, arg1)))))
1586
      | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t")
1587
  [@ocaml.warning "-A"])
1588

    
1589
let rec vhdl_type_attributes_t_to_yojson :
1590
  'basetype .
1591
    ('basetype -> Yojson.Safe.json) ->
1592
      'basetype vhdl_type_attributes_t -> Yojson.Safe.json
1593
  =
1594
  fun poly_basetype  ->
1595
    ((let open! Ppx_deriving_yojson_runtime in
1596
        function
1597
        | TAttNoArg arg0 ->
1598
            `List
1599
              [`String "TAttNoArg";
1600
              (let fields = []  in
1601
               let fields =
1602
                 ("id",
1603
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
1604
                      arg0.id))
1605
                 :: fields  in
1606
               `Assoc fields)]
1607
        | TAttIntArg arg0 ->
1608
            `List
1609
              [`String "TAttIntArg";
1610
              (let fields = []  in
1611
               let fields =
1612
                 ("arg",
1613
                   ((fun (x : Ppx_deriving_runtime.int)  -> `Int x) arg0.arg))
1614
                 :: fields  in
1615
               let fields =
1616
                 ("id",
1617
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
1618
                      arg0.id))
1619
                 :: fields  in
1620
               `Assoc fields)]
1621
        | TAttValArg arg0 ->
1622
            `List
1623
              [`String "TAttValArg";
1624
              (let fields = []  in
1625
               let fields =
1626
                 ("arg", ((poly_basetype : _ -> Yojson.Safe.json) arg0.arg))
1627
                 :: fields  in
1628
               let fields =
1629
                 ("id",
1630
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
1631
                      arg0.id))
1632
                 :: fields  in
1633
               `Assoc fields)]
1634
        | TAttStringArg arg0 ->
1635
            `List
1636
              [`String "TAttStringArg";
1637
              (let fields = []  in
1638
               let fields =
1639
                 ("arg",
1640
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
1641
                      arg0.arg))
1642
                 :: fields  in
1643
               let fields =
1644
                 ("id",
1645
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
1646
                      arg0.id))
1647
                 :: fields  in
1648
               `Assoc fields)])
1649
    [@ocaml.warning "-A"])
1650

    
1651
and vhdl_type_attributes_t_of_yojson :
1652
  'basetype .
1653
    (Yojson.Safe.json -> 'basetype Ppx_deriving_yojson_runtime.error_or) ->
1654
      Yojson.Safe.json ->
1655
        'basetype vhdl_type_attributes_t Ppx_deriving_yojson_runtime.error_or
1656
  =
1657
  fun poly_basetype  ->
1658
    ((let open! Ppx_deriving_yojson_runtime in
1659
        function
1660
        | `List ((`String "TAttNoArg")::arg0::[]) ->
1661
            ((function
1662
              | `Assoc xs ->
1663
                  let rec loop xs (arg0 as _state) =
1664
                    match xs with
1665
                    | ("id",x)::xs ->
1666
                        loop xs
1667
                          ((function
1668
                            | `String x -> Result.Ok x
1669
                            | _ ->
1670
                                Result.Error
1671
                                  "Vhdl_ast.vhdl_type_attributes_t.id") x)
1672
                    | [] ->
1673
                        arg0 >>=
1674
                          ((fun arg0  -> Result.Ok (TAttNoArg { id = arg0 })))
1675
                    | _::xs -> loop xs _state  in
1676
                  loop xs (Result.Error "Vhdl_ast.vhdl_type_attributes_t.id")
1677
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
1678
        | `List ((`String "TAttIntArg")::arg0::[]) ->
1679
            ((function
1680
              | `Assoc xs ->
1681
                  let rec loop xs ((arg0,arg1) as _state) =
1682
                    match xs with
1683
                    | ("id",x)::xs ->
1684
                        loop xs
1685
                          (((function
1686
                             | `String x -> Result.Ok x
1687
                             | _ ->
1688
                                 Result.Error
1689
                                   "Vhdl_ast.vhdl_type_attributes_t.id") x),
1690
                            arg1)
1691
                    | ("arg",x)::xs ->
1692
                        loop xs
1693
                          (arg0,
1694
                            ((function
1695
                              | `Int x -> Result.Ok x
1696
                              | _ ->
1697
                                  Result.Error
1698
                                    "Vhdl_ast.vhdl_type_attributes_t.arg") x))
1699
                    | [] ->
1700
                        arg1 >>=
1701
                          ((fun arg1  ->
1702
                              arg0 >>=
1703
                                (fun arg0  ->
1704
                                   Result.Ok
1705
                                     (TAttIntArg { id = arg0; arg = arg1 }))))
1706
                    | _::xs -> loop xs _state  in
1707
                  loop xs
1708
                    ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
1709
                      (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
1710
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
1711
        | `List ((`String "TAttValArg")::arg0::[]) ->
1712
            ((function
1713
              | `Assoc xs ->
1714
                  let rec loop xs ((arg0,arg1) as _state) =
1715
                    match xs with
1716
                    | ("id",x)::xs ->
1717
                        loop xs
1718
                          (((function
1719
                             | `String x -> Result.Ok x
1720
                             | _ ->
1721
                                 Result.Error
1722
                                   "Vhdl_ast.vhdl_type_attributes_t.id") x),
1723
                            arg1)
1724
                    | ("arg",x)::xs ->
1725
                        loop xs
1726
                          (arg0,
1727
                            ((poly_basetype : Yojson.Safe.json -> _ error_or)
1728
                               x))
1729
                    | [] ->
1730
                        arg1 >>=
1731
                          ((fun arg1  ->
1732
                              arg0 >>=
1733
                                (fun arg0  ->
1734
                                   Result.Ok
1735
                                     (TAttValArg { id = arg0; arg = arg1 }))))
1736
                    | _::xs -> loop xs _state  in
1737
                  loop xs
1738
                    ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
1739
                      (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
1740
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
1741
        | `List ((`String "TAttStringArg")::arg0::[]) ->
1742
            ((function
1743
              | `Assoc xs ->
1744
                  let rec loop xs ((arg0,arg1) as _state) =
1745
                    match xs with
1746
                    | ("id",x)::xs ->
1747
                        loop xs
1748
                          (((function
1749
                             | `String x -> Result.Ok x
1750
                             | _ ->
1751
                                 Result.Error
1752
                                   "Vhdl_ast.vhdl_type_attributes_t.id") x),
1753
                            arg1)
1754
                    | ("arg",x)::xs ->
1755
                        loop xs
1756
                          (arg0,
1757
                            ((function
1758
                              | `String x -> Result.Ok x
1759
                              | _ ->
1760
                                  Result.Error
1761
                                    "Vhdl_ast.vhdl_type_attributes_t.arg") x))
1762
                    | [] ->
1763
                        arg1 >>=
1764
                          ((fun arg1  ->
1765
                              arg0 >>=
1766
                                (fun arg0  ->
1767
                                   Result.Ok
1768
                                     (TAttStringArg { id = arg0; arg = arg1 }))))
1769
                    | _::xs -> loop xs _state  in
1770
                  loop xs
1771
                    ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
1772
                      (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
1773
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
1774
        | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")
1775
    [@ocaml.warning "-A"])
1776

    
1777
let rec (vhdl_parameter_t_to_yojson : vhdl_parameter_t -> Yojson.Safe.json) =
1778
  ((let open! Ppx_deriving_yojson_runtime in
1779
      fun x  ->
1780
        let fields = []  in
1781
        let fields =
1782
          if x.init_val = None
1783
          then fields
1784
          else
1785
            ("init_val",
1786
              (((function
1787
                 | None  -> `Null
1788
                 | Some x -> ((fun x  -> vhdl_cst_val_t_to_yojson x)) x))
1789
                 x.init_val))
1790
            :: fields
1791
           in
1792
        let fields =
1793
          ("typ", ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.typ))
1794
          :: fields  in
1795
        let fields =
1796
          if x.mode = []
1797
          then fields
1798
          else
1799
            ("mode",
1800
              (((fun x  ->
1801
                   `List
1802
                     (List.map
1803
                        (fun (x : Ppx_deriving_runtime.string)  -> `String x)
1804
                        x))) x.mode))
1805
            :: fields
1806
           in
1807
        let fields =
1808
          ("names",
1809
            ((fun x  ->
1810
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
1811
               x.names))
1812
          :: fields  in
1813
        `Assoc fields)
1814
  [@ocaml.warning "-A"])
1815

    
1816
and (vhdl_parameter_t_of_yojson :
1817
      Yojson.Safe.json ->
1818
        vhdl_parameter_t Ppx_deriving_yojson_runtime.error_or)
1819
  =
1820
  ((let open! Ppx_deriving_yojson_runtime in
1821
      function
1822
      | `Assoc xs ->
1823
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
1824
            match xs with
1825
            | ("names",x)::xs ->
1826
                loop xs
1827
                  (((function
1828
                     | `List xs ->
1829
                         map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
1830
                     | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t.names") x),
1831
                    arg1, arg2, arg3)
1832
            | ("mode",x)::xs ->
1833
                loop xs
1834
                  (arg0,
1835
                    ((function
1836
                      | `List xs ->
1837
                          map_bind
1838
                            (function
1839
                             | `String x -> Result.Ok x
1840
                             | _ ->
1841
                                 Result.Error
1842
                                   "Vhdl_ast.vhdl_parameter_t.mode") [] xs
1843
                      | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t.mode") x),
1844
                    arg2, arg3)
1845
            | ("typ",x)::xs ->
1846
                loop xs
1847
                  (arg0, arg1,
1848
                    ((fun x  -> vhdl_subtype_indication_t_of_yojson x) x),
1849
                    arg3)
1850
            | ("init_val",x)::xs ->
1851
                loop xs
1852
                  (arg0, arg1, arg2,
1853
                    ((function
1854
                      | `Null -> Result.Ok None
1855
                      | x ->
1856
                          ((fun x  -> vhdl_cst_val_t_of_yojson x) x) >>=
1857
                            ((fun x  -> Result.Ok (Some x)))) x))
1858
            | [] ->
1859
                arg3 >>=
1860
                  ((fun arg3  ->
1861
                      arg2 >>=
1862
                        (fun arg2  ->
1863
                           arg1 >>=
1864
                             (fun arg1  ->
1865
                                arg0 >>=
1866
                                  (fun arg0  ->
1867
                                     Result.Ok
1868
                                       {
1869
                                         names = arg0;
1870
                                         mode = arg1;
1871
                                         typ = arg2;
1872
                                         init_val = arg3
1873
                                       })))))
1874
            | _::xs -> loop xs _state  in
1875
          loop xs
1876
            ((Result.Error "Vhdl_ast.vhdl_parameter_t.names"),
1877
              (Result.Ok []), (Result.Error "Vhdl_ast.vhdl_parameter_t.typ"),
1878
              (Result.Ok (Some (CstInt 0))))
1879
      | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t")
1880
  [@ocaml.warning "-A"])
1881

    
1882
let rec (vhdl_subprogram_spec_t_to_yojson :
1883
          vhdl_subprogram_spec_t -> Yojson.Safe.json)
1884
  =
1885
  ((let open! Ppx_deriving_yojson_runtime in
1886
      fun x  ->
1887
        let fields = []  in
1888
        let fields =
1889
          if x.isPure = false
1890
          then fields
1891
          else
1892
            ("isPure",
1893
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x)) x.isPure))
1894
            :: fields
1895
           in
1896
        let fields =
1897
          if x.parameters = []
1898
          then fields
1899
          else
1900
            ("parameters",
1901
              (((fun x  ->
1902
                   `List
1903
                     (List.map (fun x  -> vhdl_parameter_t_to_yojson x) x)))
1904
                 x.parameters))
1905
            :: fields
1906
           in
1907
        let fields =
1908
          if x.typeMark = NoName
1909
          then fields
1910
          else
1911
            ("typeMark", (((fun x  -> vhdl_name_t_to_yojson x)) x.typeMark))
1912
            :: fields
1913
           in
1914
        let fields =
1915
          if x.subprogram_type = ""
1916
          then fields
1917
          else
1918
            ("subprogram_type",
1919
              (((fun (x : Ppx_deriving_runtime.string)  -> `String x))
1920
                 x.subprogram_type))
1921
            :: fields
1922
           in
1923
        let fields =
1924
          if x.name = ""
1925
          then fields
1926
          else
1927
            ("name",
1928
              (((fun (x : Ppx_deriving_runtime.string)  -> `String x)) x.name))
1929
            :: fields
1930
           in
1931
        `Assoc fields)
1932
  [@ocaml.warning "-A"])
1933

    
1934
and (vhdl_subprogram_spec_t_of_yojson :
1935
      Yojson.Safe.json ->
1936
        vhdl_subprogram_spec_t Ppx_deriving_yojson_runtime.error_or)
1937
  =
1938
  ((let open! Ppx_deriving_yojson_runtime in
1939
      function
1940
      | `Assoc xs ->
1941
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
1942
            match xs with
1943
            | ("name",x)::xs ->
1944
                loop xs
1945
                  (((function
1946
                     | `String x -> Result.Ok x
1947
                     | _ ->
1948
                         Result.Error "Vhdl_ast.vhdl_subprogram_spec_t.name")
1949
                      x), arg1, arg2, arg3, arg4)
1950
            | ("subprogram_type",x)::xs ->
1951
                loop xs
1952
                  (arg0,
1953
                    ((function
1954
                      | `String x -> Result.Ok x
1955
                      | _ ->
1956
                          Result.Error
1957
                            "Vhdl_ast.vhdl_subprogram_spec_t.subprogram_type")
1958
                       x), arg2, arg3, arg4)
1959
            | ("typeMark",x)::xs ->
1960
                loop xs
1961
                  (arg0, arg1, ((fun x  -> vhdl_name_t_of_yojson x) x), arg3,
1962
                    arg4)
1963
            | ("parameters",x)::xs ->
1964
                loop xs
1965
                  (arg0, arg1, arg2,
1966
                    ((function
1967
                      | `List xs ->
1968
                          map_bind (fun x  -> vhdl_parameter_t_of_yojson x)
1969
                            [] xs
1970
                      | _ ->
1971
                          Result.Error
1972
                            "Vhdl_ast.vhdl_subprogram_spec_t.parameters") x),
1973
                    arg4)
1974
            | ("isPure",x)::xs ->
1975
                loop xs
1976
                  (arg0, arg1, arg2, arg3,
1977
                    ((function
1978
                      | `Bool x -> Result.Ok x
1979
                      | _ ->
1980
                          Result.Error
1981
                            "Vhdl_ast.vhdl_subprogram_spec_t.isPure") x))
1982
            | [] ->
1983
                arg4 >>=
1984
                  ((fun arg4  ->
1985
                      arg3 >>=
1986
                        (fun arg3  ->
1987
                           arg2 >>=
1988
                             (fun arg2  ->
1989
                                arg1 >>=
1990
                                  (fun arg1  ->
1991
                                     arg0 >>=
1992
                                       (fun arg0  ->
1993
                                          Result.Ok
1994
                                            {
1995
                                              name = arg0;
1996
                                              subprogram_type = arg1;
1997
                                              typeMark = arg2;
1998
                                              parameters = arg3;
1999
                                              isPure = arg4
2000
                                            }))))))
2001
            | _::xs -> loop xs _state  in
2002
          loop xs
2003
            ((Result.Ok ""), (Result.Ok ""), (Result.Ok NoName),
2004
              (Result.Ok []), (Result.Ok false))
2005
      | _ -> Result.Error "Vhdl_ast.vhdl_subprogram_spec_t")
2006
  [@ocaml.warning "-A"])
2007

    
2008
let rec (vhdl_waveform_element_t_to_yojson :
2009
          vhdl_waveform_element_t -> Yojson.Safe.json)
2010
  =
2011
  ((let open! Ppx_deriving_yojson_runtime in
2012
      fun x  ->
2013
        let fields = []  in
2014
        let fields =
2015
          if x.delay = None
2016
          then fields
2017
          else
2018
            ("delay",
2019
              (((function
2020
                 | None  -> `Null
2021
                 | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x))
2022
                 x.delay))
2023
            :: fields
2024
           in
2025
        let fields =
2026
          if x.value = None
2027
          then fields
2028
          else
2029
            ("value",
2030
              (((function
2031
                 | None  -> `Null
2032
                 | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x))
2033
                 x.value))
2034
            :: fields
2035
           in
2036
        `Assoc fields)
2037
  [@ocaml.warning "-A"])
2038

    
2039
and (vhdl_waveform_element_t_of_yojson :
2040
      Yojson.Safe.json ->
2041
        vhdl_waveform_element_t Ppx_deriving_yojson_runtime.error_or)
2042
  =
2043
  ((let open! Ppx_deriving_yojson_runtime in
2044
      function
2045
      | `Assoc xs ->
2046
          let rec loop xs ((arg0,arg1) as _state) =
2047
            match xs with
2048
            | ("value",x)::xs ->
2049
                loop xs
2050
                  (((function
2051
                     | `Null -> Result.Ok None
2052
                     | x ->
2053
                         ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
2054
                           ((fun x  -> Result.Ok (Some x)))) x), arg1)
2055
            | ("delay",x)::xs ->
2056
                loop xs
2057
                  (arg0,
2058
                    ((function
2059
                      | `Null -> Result.Ok None
2060
                      | x ->
2061
                          ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
2062
                            ((fun x  -> Result.Ok (Some x)))) x))
2063
            | [] ->
2064
                arg1 >>=
2065
                  ((fun arg1  ->
2066
                      arg0 >>=
2067
                        (fun arg0  ->
2068
                           Result.Ok { value = arg0; delay = arg1 })))
2069
            | _::xs -> loop xs _state  in
2070
          loop xs ((Result.Ok None), (Result.Ok None))
2071
      | _ -> Result.Error "Vhdl_ast.vhdl_waveform_element_t")
2072
  [@ocaml.warning "-A"])
2073

    
2074
let rec (vhdl_sequential_stmt_t_to_yojson :
2075
          vhdl_sequential_stmt_t -> Yojson.Safe.json)
2076
  =
2077
  ((let open! Ppx_deriving_yojson_runtime in
2078
      function
2079
      | VarAssign arg0 ->
2080
          `List
2081
            [`String "VARIABLE_ASSIGNMENT_STATEMENT";
2082
            (let fields = []  in
2083
             let fields =
2084
               ("rhs", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.rhs)) ::
2085
               fields  in
2086
             let fields =
2087
               ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) arg0.lhs)) ::
2088
               fields  in
2089
             let fields =
2090
               if arg0.label = NoName
2091
               then fields
2092
               else
2093
                 ("label",
2094
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
2095
                 :: fields
2096
                in
2097
             `Assoc fields)]
2098
      | SigSeqAssign arg0 ->
2099
          `List
2100
            [`String "SIGNAL_ASSIGNMENT_STATEMENT";
2101
            (let fields = []  in
2102
             let fields =
2103
               ("rhs",
2104
                 ((fun x  ->
2105
                     `List
2106
                       (List.map
2107
                          (fun x  -> vhdl_waveform_element_t_to_yojson x) x))
2108
                    arg0.rhs))
2109
               :: fields  in
2110
             let fields =
2111
               ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) arg0.lhs)) ::
2112
               fields  in
2113
             let fields =
2114
               if arg0.label = NoName
2115
               then fields
2116
               else
2117
                 ("label",
2118
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
2119
                 :: fields
2120
                in
2121
             `Assoc fields)]
2122
      | If arg0 ->
2123
          `List
2124
            [`String "IF_STATEMENT";
2125
            (let fields = []  in
2126
             let fields =
2127
               if arg0.default = []
2128
               then fields
2129
               else
2130
                 ("default",
2131
                   (((fun x  ->
2132
                        `List
2133
                          (List.map
2134
                             (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x)))
2135
                      arg0.default))
2136
                 :: fields
2137
                in
2138
             let fields =
2139
               ("if_cases",
2140
                 ((fun x  ->
2141
                     `List
2142
                       (List.map (fun x  -> vhdl_if_case_t_to_yojson x) x))
2143
                    arg0.if_cases))
2144
               :: fields  in
2145
             let fields =
2146
               if arg0.label = NoName
2147
               then fields
2148
               else
2149
                 ("label",
2150
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
2151
                 :: fields
2152
                in
2153
             `Assoc fields)]
2154
      | Case arg0 ->
2155
          `List
2156
            [`String "CASE_STATEMENT_TREE";
2157
            (let fields = []  in
2158
             let fields =
2159
               ("branches",
2160
                 ((fun x  ->
2161
                     `List
2162
                       (List.map (fun x  -> vhdl_case_item_t_to_yojson x) x))
2163
                    arg0.branches))
2164
               :: fields  in
2165
             let fields =
2166
               ("guard", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.guard)) ::
2167
               fields  in
2168
             let fields =
2169
               if arg0.label = NoName
2170
               then fields
2171
               else
2172
                 ("label",
2173
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
2174
                 :: fields
2175
                in
2176
             `Assoc fields)]
2177
      | Exit arg0 ->
2178
          `List
2179
            [`String "EXIT_STATEMENT";
2180
            (let fields = []  in
2181
             let fields =
2182
               if arg0.condition = (Some IsNull)
2183
               then fields
2184
               else
2185
                 ("condition",
2186
                   (((function
2187
                      | None  -> `Null
2188
                      | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x))
2189
                      arg0.condition))
2190
                 :: fields
2191
                in
2192
             let fields =
2193
               if arg0.loop_label = (Some "")
2194
               then fields
2195
               else
2196
                 ("loop_label",
2197
                   (((function
2198
                      | None  -> `Null
2199
                      | Some x ->
2200
                          ((fun (x : Ppx_deriving_runtime.string)  ->
2201
                              `String x)) x)) arg0.loop_label))
2202
                 :: fields
2203
                in
2204
             let fields =
2205
               if arg0.label = NoName
2206
               then fields
2207
               else
2208
                 ("label",
2209
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
2210
                 :: fields
2211
                in
2212
             `Assoc fields)]
2213
      | Assert arg0 ->
2214
          `List
2215
            [`String "ASSERTION_STATEMENT";
2216
            (let fields = []  in
2217
             let fields =
2218
               if arg0.severity = IsNull
2219
               then fields
2220
               else
2221
                 ("severity",
2222
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.severity))
2223
                 :: fields
2224
                in
2225
             let fields =
2226
               if arg0.report = IsNull
2227
               then fields
2228
               else
2229
                 ("report",
2230
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.report))
2231
                 :: fields
2232
                in
2233
             let fields =
2234
               ("cond", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.cond)) ::
2235
               fields  in
2236
             let fields =
2237
               if arg0.label = NoName
2238
               then fields
2239
               else
2240
                 ("label",
2241
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
2242
                 :: fields
2243
                in
2244
             `Assoc fields)]
2245
      | ProcedureCall arg0 ->
2246
          `List
2247
            [`String "PROCEDURE_CALL_STATEMENT";
2248
            (let fields = []  in
2249
             let fields =
2250
               if arg0.assocs = []
2251
               then fields
2252
               else
2253
                 ("assocs",
2254
                   (((fun x  ->
2255
                        `List
2256
                          (List.map
2257
                             (fun x  -> vhdl_assoc_element_t_to_yojson x) x)))
2258
                      arg0.assocs))
2259
                 :: fields
2260
                in
2261
             let fields =
2262
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
2263
               fields  in
2264
             let fields =
2265
               if arg0.label = NoName
2266
               then fields
2267
               else
2268
                 ("label",
2269
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
2270
                 :: fields
2271
                in
2272
             `Assoc fields)]
2273
      | Wait  -> `List [`String "WAIT_STATEMENT"]
2274
      | Null arg0 ->
2275
          `List
2276
            [`String "NULL_STATEMENT";
2277
            (let fields = []  in
2278
             let fields =
2279
               if arg0.label = NoName
2280
               then fields
2281
               else
2282
                 ("label",
2283
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
2284
                 :: fields
2285
                in
2286
             `Assoc fields)]
2287
      | Return arg0 ->
2288
          `List
2289
            [`String "RETURN_STATEMENT";
2290
            (let fields = []  in
2291
             let fields =
2292
               if arg0.expr = None
2293
               then fields
2294
               else
2295
                 ("expr",
2296
                   (((function
2297
                      | None  -> `Null
2298
                      | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x))
2299
                      arg0.expr))
2300
                 :: fields
2301
                in
2302
             let fields =
2303
               if arg0.label = None
2304
               then fields
2305
               else
2306
                 ("label",
2307
                   (((function
2308
                      | None  -> `Null
2309
                      | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
2310
                      arg0.label))
2311
                 :: fields
2312
                in
2313
             `Assoc fields)])
2314
  [@ocaml.warning "-A"])
2315

    
2316
and (vhdl_sequential_stmt_t_of_yojson :
2317
      Yojson.Safe.json ->
2318
        vhdl_sequential_stmt_t Ppx_deriving_yojson_runtime.error_or)
2319
  =
2320
  ((let open! Ppx_deriving_yojson_runtime in
2321
      function
2322
      | `List ((`String "VARIABLE_ASSIGNMENT_STATEMENT")::arg0::[]) ->
2323
          ((function
2324
            | `Assoc xs ->
2325
                let rec loop xs ((arg0,arg1,arg2) as _state) =
2326
                  match xs with
2327
                  | ("label",x)::xs ->
2328
                      loop xs
2329
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
2330
                  | ("lhs",x)::xs ->
2331
                      loop xs
2332
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
2333
                  | ("rhs",x)::xs ->
2334
                      loop xs
2335
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
2336
                  | [] ->
2337
                      arg2 >>=
2338
                        ((fun arg2  ->
2339
                            arg1 >>=
2340
                              (fun arg1  ->
2341
                                 arg0 >>=
2342
                                   (fun arg0  ->
2343
                                      Result.Ok
2344
                                        (VarAssign
2345
                                           {
2346
                                             label = arg0;
2347
                                             lhs = arg1;
2348
                                             rhs = arg2
2349
                                           })))))
2350
                  | _::xs -> loop xs _state  in
2351
                loop xs
2352
                  ((Result.Ok NoName),
2353
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.lhs"),
2354
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.rhs"))
2355
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
2356
      | `List ((`String "SIGNAL_ASSIGNMENT_STATEMENT")::arg0::[]) ->
2357
          ((function
2358
            | `Assoc xs ->
2359
                let rec loop xs ((arg0,arg1,arg2) as _state) =
2360
                  match xs with
2361
                  | ("label",x)::xs ->
2362
                      loop xs
2363
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
2364
                  | ("lhs",x)::xs ->
2365
                      loop xs
2366
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
2367
                  | ("rhs",x)::xs ->
2368
                      loop xs
2369
                        (arg0, arg1,
2370
                          ((function
2371
                            | `List xs ->
2372
                                map_bind
2373
                                  (fun x  ->
2374
                                     vhdl_waveform_element_t_of_yojson x) []
2375
                                  xs
2376
                            | _ ->
2377
                                Result.Error
2378
                                  "Vhdl_ast.vhdl_sequential_stmt_t.rhs") x))
2379
                  | [] ->
2380
                      arg2 >>=
2381
                        ((fun arg2  ->
2382
                            arg1 >>=
2383
                              (fun arg1  ->
2384
                                 arg0 >>=
2385
                                   (fun arg0  ->
2386
                                      Result.Ok
2387
                                        (SigSeqAssign
2388
                                           {
2389
                                             label = arg0;
2390
                                             lhs = arg1;
2391
                                             rhs = arg2
2392
                                           })))))
2393
                  | _::xs -> loop xs _state  in
2394
                loop xs
2395
                  ((Result.Ok NoName),
2396
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.lhs"),
2397
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.rhs"))
2398
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
2399
      | `List ((`String "IF_STATEMENT")::arg0::[]) ->
2400
          ((function
2401
            | `Assoc xs ->
2402
                let rec loop xs ((arg0,arg1,arg2) as _state) =
2403
                  match xs with
2404
                  | ("label",x)::xs ->
2405
                      loop xs
2406
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
2407
                  | ("if_cases",x)::xs ->
2408
                      loop xs
2409
                        (arg0,
2410
                          ((function
2411
                            | `List xs ->
2412
                                map_bind
2413
                                  (fun x  -> vhdl_if_case_t_of_yojson x) []
2414
                                  xs
2415
                            | _ ->
2416
                                Result.Error
2417
                                  "Vhdl_ast.vhdl_sequential_stmt_t.if_cases")
2418
                             x), arg2)
2419
                  | ("default",x)::xs ->
2420
                      loop xs
2421
                        (arg0, arg1,
2422
                          ((function
2423
                            | `List xs ->
2424
                                map_bind
2425
                                  (fun x  ->
2426
                                     vhdl_sequential_stmt_t_of_yojson x) []
2427
                                  xs
2428
                            | _ ->
2429
                                Result.Error
2430
                                  "Vhdl_ast.vhdl_sequential_stmt_t.default")
2431
                             x))
2432
                  | [] ->
2433
                      arg2 >>=
2434
                        ((fun arg2  ->
2435
                            arg1 >>=
2436
                              (fun arg1  ->
2437
                                 arg0 >>=
2438
                                   (fun arg0  ->
2439
                                      Result.Ok
2440
                                        (If
2441
                                           {
2442
                                             label = arg0;
2443
                                             if_cases = arg1;
2444
                                             default = arg2
2445
                                           })))))
2446
                  | _::xs -> loop xs _state  in
2447
                loop xs
2448
                  ((Result.Ok NoName),
2449
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.if_cases"),
2450
                    (Result.Ok []))
2451
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
2452
      | `List ((`String "CASE_STATEMENT_TREE")::arg0::[]) ->
2453
          ((function
2454
            | `Assoc xs ->
2455
                let rec loop xs ((arg0,arg1,arg2) as _state) =
2456
                  match xs with
2457
                  | ("label",x)::xs ->
2458
                      loop xs
2459
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
2460
                  | ("guard",x)::xs ->
2461
                      loop xs
2462
                        (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x), arg2)
2463
                  | ("branches",x)::xs ->
2464
                      loop xs
2465
                        (arg0, arg1,
2466
                          ((function
2467
                            | `List xs ->
2468
                                map_bind
2469
                                  (fun x  -> vhdl_case_item_t_of_yojson x) []
2470
                                  xs
2471
                            | _ ->
2472
                                Result.Error
2473
                                  "Vhdl_ast.vhdl_sequential_stmt_t.branches")
2474
                             x))
2475
                  | [] ->
2476
                      arg2 >>=
2477
                        ((fun arg2  ->
2478
                            arg1 >>=
2479
                              (fun arg1  ->
2480
                                 arg0 >>=
2481
                                   (fun arg0  ->
2482
                                      Result.Ok
2483
                                        (Case
2484
                                           {
2485
                                             label = arg0;
2486
                                             guard = arg1;
2487
                                             branches = arg2
2488
                                           })))))
2489
                  | _::xs -> loop xs _state  in
2490
                loop xs
2491
                  ((Result.Ok NoName),
2492
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.guard"),
2493
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.branches"))
2494
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
2495
      | `List ((`String "EXIT_STATEMENT")::arg0::[]) ->
2496
          ((function
2497
            | `Assoc xs ->
2498
                let rec loop xs ((arg0,arg1,arg2) as _state) =
2499
                  match xs with
2500
                  | ("label",x)::xs ->
2501
                      loop xs
2502
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
2503
                  | ("loop_label",x)::xs ->
2504
                      loop xs
2505
                        (arg0,
2506
                          ((function
2507
                            | `Null -> Result.Ok None
2508
                            | x ->
2509
                                ((function
2510
                                  | `String x -> Result.Ok x
2511
                                  | _ ->
2512
                                      Result.Error
2513
                                        "Vhdl_ast.vhdl_sequential_stmt_t.loop_label")
2514
                                   x)
2515
                                  >>= ((fun x  -> Result.Ok (Some x)))) x),
2516
                          arg2)
2517
                  | ("condition",x)::xs ->
2518
                      loop xs
2519
                        (arg0, arg1,
2520
                          ((function
2521
                            | `Null -> Result.Ok None
2522
                            | x ->
2523
                                ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
2524
                                  ((fun x  -> Result.Ok (Some x)))) x))
2525
                  | [] ->
2526
                      arg2 >>=
2527
                        ((fun arg2  ->
2528
                            arg1 >>=
2529
                              (fun arg1  ->
2530
                                 arg0 >>=
2531
                                   (fun arg0  ->
2532
                                      Result.Ok
2533
                                        (Exit
2534
                                           {
2535
                                             label = arg0;
2536
                                             loop_label = arg1;
2537
                                             condition = arg2
2538
                                           })))))
2539
                  | _::xs -> loop xs _state  in
2540
                loop xs
2541
                  ((Result.Ok NoName), (Result.Ok (Some "")),
2542
                    (Result.Ok (Some IsNull)))
2543
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
2544
      | `List ((`String "ASSERTION_STATEMENT")::arg0::[]) ->
2545
          ((function
2546
            | `Assoc xs ->
2547
                let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
2548
                  match xs with
2549
                  | ("label",x)::xs ->
2550
                      loop xs
2551
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2,
2552
                          arg3)
2553
                  | ("cond",x)::xs ->
2554
                      loop xs
2555
                        (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x), arg2,
2556
                          arg3)
2557
                  | ("report",x)::xs ->
2558
                      loop xs
2559
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x),
2560
                          arg3)
2561
                  | ("severity",x)::xs ->
2562
                      loop xs
2563
                        (arg0, arg1, arg2,
2564
                          ((fun x  -> vhdl_expr_t_of_yojson x) x))
2565
                  | [] ->
2566
                      arg3 >>=
2567
                        ((fun arg3  ->
2568
                            arg2 >>=
2569
                              (fun arg2  ->
2570
                                 arg1 >>=
2571
                                   (fun arg1  ->
2572
                                      arg0 >>=
2573
                                        (fun arg0  ->
2574
                                           Result.Ok
2575
                                             (Assert
2576
                                                {
2577
                                                  label = arg0;
2578
                                                  cond = arg1;
2579
                                                  report = arg2;
2580
                                                  severity = arg3
2581
                                                }))))))
2582
                  | _::xs -> loop xs _state  in
2583
                loop xs
2584
                  ((Result.Ok NoName),
2585
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.cond"),
2586
                    (Result.Ok IsNull), (Result.Ok IsNull))
2587
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
2588
      | `List ((`String "PROCEDURE_CALL_STATEMENT")::arg0::[]) ->
2589
          ((function
2590
            | `Assoc xs ->
2591
                let rec loop xs ((arg0,arg1,arg2) as _state) =
2592
                  match xs with
2593
                  | ("label",x)::xs ->
2594
                      loop xs
2595
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
2596
                  | ("name",x)::xs ->
2597
                      loop xs
2598
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
2599
                  | ("assocs",x)::xs ->
2600
                      loop xs
2601
                        (arg0, arg1,
2602
                          ((function
2603
                            | `List xs ->
2604
                                map_bind
2605
                                  (fun x  -> vhdl_assoc_element_t_of_yojson x)
2606
                                  [] xs
2607
                            | _ ->
2608
                                Result.Error
2609
                                  "Vhdl_ast.vhdl_sequential_stmt_t.assocs") x))
2610
                  | [] ->
2611
                      arg2 >>=
2612
                        ((fun arg2  ->
2613
                            arg1 >>=
2614
                              (fun arg1  ->
2615
                                 arg0 >>=
2616
                                   (fun arg0  ->
2617
                                      Result.Ok
2618
                                        (ProcedureCall
2619
                                           {
2620
                                             label = arg0;
2621
                                             name = arg1;
2622
                                             assocs = arg2
2623
                                           })))))
2624
                  | _::xs -> loop xs _state  in
2625
                loop xs
2626
                  ((Result.Ok NoName),
2627
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.name"),
2628
                    (Result.Ok []))
2629
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
2630
      | `List ((`String "WAIT_STATEMENT")::[]) -> Result.Ok Wait
2631
      | `List ((`String "NULL_STATEMENT")::arg0::[]) ->
2632
          ((function
2633
            | `Assoc xs ->
2634
                let rec loop xs (arg0 as _state) =
2635
                  match xs with
2636
                  | ("label",x)::xs ->
2637
                      loop xs ((fun x  -> vhdl_name_t_of_yojson x) x)
2638
                  | [] ->
2639
                      arg0 >>=
2640
                        ((fun arg0  -> Result.Ok (Null { label = arg0 })))
2641
                  | _::xs -> loop xs _state  in
2642
                loop xs (Result.Ok NoName)
2643
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
2644
      | `List ((`String "RETURN_STATEMENT")::arg0::[]) ->
2645
          ((function
2646
            | `Assoc xs ->
2647
                let rec loop xs ((arg0,arg1) as _state) =
2648
                  match xs with
2649
                  | ("label",x)::xs ->
2650
                      loop xs
2651
                        (((function
2652
                           | `Null -> Result.Ok None
2653
                           | x ->
2654
                               ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
2655
                                 ((fun x  -> Result.Ok (Some x)))) x), arg1)
2656
                  | ("expr",x)::xs ->
2657
                      loop xs
2658
                        (arg0,
2659
                          ((function
2660
                            | `Null -> Result.Ok None
2661
                            | x ->
2662
                                ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
2663
                                  ((fun x  -> Result.Ok (Some x)))) x))
2664
                  | [] ->
2665
                      arg1 >>=
2666
                        ((fun arg1  ->
2667
                            arg0 >>=
2668
                              (fun arg0  ->
2669
                                 Result.Ok
2670
                                   (Return { label = arg0; expr = arg1 }))))
2671
                  | _::xs -> loop xs _state  in
2672
                loop xs ((Result.Ok None), (Result.Ok None))
2673
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
2674
      | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")
2675
  [@ocaml.warning "-A"])
2676

    
2677
and (vhdl_if_case_t_to_yojson : vhdl_if_case_t -> Yojson.Safe.json) =
2678
  ((let open! Ppx_deriving_yojson_runtime in
2679
      fun x  ->
2680
        let fields = []  in
2681
        let fields =
2682
          ("if_block",
2683
            ((fun x  ->
2684
                `List
2685
                  (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x))
2686
               x.if_block))
2687
          :: fields  in
2688
        let fields =
2689
          ("if_cond", ((fun x  -> vhdl_expr_t_to_yojson x) x.if_cond)) ::
2690
          fields  in
2691
        `Assoc fields)
2692
  [@ocaml.warning "-A"])
2693

    
2694
and (vhdl_if_case_t_of_yojson :
2695
      Yojson.Safe.json -> vhdl_if_case_t Ppx_deriving_yojson_runtime.error_or)
2696
  =
2697
  ((let open! Ppx_deriving_yojson_runtime in
2698
      function
2699
      | `Assoc xs ->
2700
          let rec loop xs ((arg0,arg1) as _state) =
2701
            match xs with
2702
            | ("if_cond",x)::xs ->
2703
                loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
2704
            | ("if_block",x)::xs ->
2705
                loop xs
2706
                  (arg0,
2707
                    ((function
2708
                      | `List xs ->
2709
                          map_bind
2710
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
2711
                            xs
2712
                      | _ -> Result.Error "Vhdl_ast.vhdl_if_case_t.if_block")
2713
                       x))
2714
            | [] ->
2715
                arg1 >>=
2716
                  ((fun arg1  ->
2717
                      arg0 >>=
2718
                        (fun arg0  ->
2719
                           Result.Ok { if_cond = arg0; if_block = arg1 })))
2720
            | _::xs -> loop xs _state  in
2721
          loop xs
2722
            ((Result.Error "Vhdl_ast.vhdl_if_case_t.if_cond"),
2723
              (Result.Error "Vhdl_ast.vhdl_if_case_t.if_block"))
2724
      | _ -> Result.Error "Vhdl_ast.vhdl_if_case_t")
2725
  [@ocaml.warning "-A"])
2726

    
2727
and (vhdl_case_item_t_to_yojson : vhdl_case_item_t -> Yojson.Safe.json) =
2728
  ((let open! Ppx_deriving_yojson_runtime in
2729
      fun x  ->
2730
        let fields = []  in
2731
        let fields =
2732
          ("when_stmt",
2733
            ((fun x  ->
2734
                `List
2735
                  (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x))
2736
               x.when_stmt))
2737
          :: fields  in
2738
        let fields =
2739
          ("when_cond",
2740
            ((fun x  ->
2741
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
2742
               x.when_cond))
2743
          :: fields  in
2744
        `Assoc fields)
2745
  [@ocaml.warning "-A"])
2746

    
2747
and (vhdl_case_item_t_of_yojson :
2748
      Yojson.Safe.json ->
2749
        vhdl_case_item_t Ppx_deriving_yojson_runtime.error_or)
2750
  =
2751
  ((let open! Ppx_deriving_yojson_runtime in
2752
      function
2753
      | `Assoc xs ->
2754
          let rec loop xs ((arg0,arg1) as _state) =
2755
            match xs with
2756
            | ("when_cond",x)::xs ->
2757
                loop xs
2758
                  (((function
2759
                     | `List xs ->
2760
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
2761
                     | _ ->
2762
                         Result.Error "Vhdl_ast.vhdl_case_item_t.when_cond")
2763
                      x), arg1)
2764
            | ("when_stmt",x)::xs ->
2765
                loop xs
2766
                  (arg0,
2767
                    ((function
2768
                      | `List xs ->
2769
                          map_bind
2770
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
2771
                            xs
2772
                      | _ ->
2773
                          Result.Error "Vhdl_ast.vhdl_case_item_t.when_stmt")
2774
                       x))
2775
            | [] ->
2776
                arg1 >>=
2777
                  ((fun arg1  ->
2778
                      arg0 >>=
2779
                        (fun arg0  ->
2780
                           Result.Ok { when_cond = arg0; when_stmt = arg1 })))
2781
            | _::xs -> loop xs _state  in
2782
          loop xs
2783
            ((Result.Error "Vhdl_ast.vhdl_case_item_t.when_cond"),
2784
              (Result.Error "Vhdl_ast.vhdl_case_item_t.when_stmt"))
2785
      | _ -> Result.Error "Vhdl_ast.vhdl_case_item_t")
2786
  [@ocaml.warning "-A"])
2787

    
2788
let rec (vhdl_port_mode_t_to_yojson : vhdl_port_mode_t -> Yojson.Safe.json) =
2789
  ((let open! Ppx_deriving_yojson_runtime in
2790
      function
2791
      | InPort  -> `List [`String "in"]
2792
      | OutPort  -> `List [`String "out"]
2793
      | InoutPort  -> `List [`String "inout"]
2794
      | BufferPort  -> `List [`String "buffer"])
2795
  [@ocaml.warning "-A"])
2796

    
2797
and (vhdl_port_mode_t_of_yojson :
2798
      Yojson.Safe.json ->
2799
        vhdl_port_mode_t Ppx_deriving_yojson_runtime.error_or)
2800
  =
2801
  ((let open! Ppx_deriving_yojson_runtime in
2802
      function
2803
      | `List ((`String "in")::[]) -> Result.Ok InPort
2804
      | `List ((`String "out")::[]) -> Result.Ok OutPort
2805
      | `List ((`String "inout")::[]) -> Result.Ok InoutPort
2806
      | `List ((`String "buffer")::[]) -> Result.Ok BufferPort
2807
      | _ -> Result.Error "Vhdl_ast.vhdl_port_mode_t")
2808
  [@ocaml.warning "-A"])
2809

    
2810
let rec (vhdl_port_t_to_yojson : vhdl_port_t -> Yojson.Safe.json) =
2811
  ((let open! Ppx_deriving_yojson_runtime in
2812
      fun x  ->
2813
        let fields = []  in
2814
        let fields =
2815
          if x.expr = IsNull
2816
          then fields
2817
          else ("expr", (((fun x  -> vhdl_expr_t_to_yojson x)) x.expr)) ::
2818
            fields
2819
           in
2820
        let fields =
2821
          ("typ", ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.typ))
2822
          :: fields  in
2823
        let fields =
2824
          if x.mode = InPort
2825
          then fields
2826
          else ("mode", (((fun x  -> vhdl_port_mode_t_to_yojson x)) x.mode))
2827
            :: fields
2828
           in
2829
        let fields =
2830
          if x.names = []
2831
          then fields
2832
          else
2833
            ("names",
2834
              (((fun x  ->
2835
                   `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
2836
                 x.names))
2837
            :: fields
2838
           in
2839
        `Assoc fields)
2840
  [@ocaml.warning "-A"])
2841

    
2842
and (vhdl_port_t_of_yojson :
2843
      Yojson.Safe.json -> vhdl_port_t Ppx_deriving_yojson_runtime.error_or)
2844
  =
2845
  ((let open! Ppx_deriving_yojson_runtime in
2846
      function
2847
      | `Assoc xs ->
2848
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
2849
            match xs with
2850
            | ("names",x)::xs ->
2851
                loop xs
2852
                  (((function
2853
                     | `List xs ->
2854
                         map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
2855
                     | _ -> Result.Error "Vhdl_ast.vhdl_port_t.names") x),
2856
                    arg1, arg2, arg3)
2857
            | ("mode",x)::xs ->
2858
                loop xs
2859
                  (arg0, ((fun x  -> vhdl_port_mode_t_of_yojson x) x), arg2,
2860
                    arg3)
2861
            | ("typ",x)::xs ->
2862
                loop xs
2863
                  (arg0, arg1,
2864
                    ((fun x  -> vhdl_subtype_indication_t_of_yojson x) x),
2865
                    arg3)
2866
            | ("expr",x)::xs ->
2867
                loop xs
2868
                  (arg0, arg1, arg2, ((fun x  -> vhdl_expr_t_of_yojson x) x))
2869
            | [] ->
2870
                arg3 >>=
2871
                  ((fun arg3  ->
2872
                      arg2 >>=
2873
                        (fun arg2  ->
2874
                           arg1 >>=
2875
                             (fun arg1  ->
2876
                                arg0 >>=
2877
                                  (fun arg0  ->
2878
                                     Result.Ok
2879
                                       {
2880
                                         names = arg0;
2881
                                         mode = arg1;
2882
                                         typ = arg2;
2883
                                         expr = arg3
2884
                                       })))))
2885
            | _::xs -> loop xs _state  in
2886
          loop xs
2887
            ((Result.Ok []), (Result.Ok InPort),
2888
              (Result.Error "Vhdl_ast.vhdl_port_t.typ"), (Result.Ok IsNull))
2889
      | _ -> Result.Error "Vhdl_ast.vhdl_port_t")
2890
  [@ocaml.warning "-A"])
2891

    
2892
let rec (vhdl_declaration_t_to_yojson :
2893
          vhdl_declaration_t -> Yojson.Safe.json)
2894
  =
2895
  ((let open! Ppx_deriving_yojson_runtime in
2896
      function
2897
      | VarDecl arg0 ->
2898
          `List
2899
            [`String "VARIABLE_DECLARATION";
2900
            (let fields = []  in
2901
             let fields =
2902
               if arg0.init_val = IsNull
2903
               then fields
2904
               else
2905
                 ("init_val",
2906
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.init_val))
2907
                 :: fields
2908
                in
2909
             let fields =
2910
               ("typ",
2911
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
2912
               :: fields  in
2913
             let fields =
2914
               ("names",
2915
                 ((fun x  ->
2916
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
2917
                    arg0.names))
2918
               :: fields  in
2919
             `Assoc fields)]
2920
      | CstDecl arg0 ->
2921
          `List
2922
            [`String "CONSTANT_DECLARATION";
2923
            (let fields = []  in
2924
             let fields =
2925
               ("init_val",
2926
                 ((fun x  -> vhdl_expr_t_to_yojson x) arg0.init_val))
2927
               :: fields  in
2928
             let fields =
2929
               ("typ",
2930
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
2931
               :: fields  in
2932
             let fields =
2933
               ("names",
2934
                 ((fun x  ->
2935
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
2936
                    arg0.names))
2937
               :: fields  in
2938
             `Assoc fields)]
2939
      | SigDecl arg0 ->
2940
          `List
2941
            [`String "SIGNAL_DECLARATION";
2942
            (let fields = []  in
2943
             let fields =
2944
               if arg0.init_val = IsNull
2945
               then fields
2946
               else
2947
                 ("init_val",
2948
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.init_val))
2949
                 :: fields
2950
                in
2951
             let fields =
2952
               ("typ",
2953
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
2954
               :: fields  in
2955
             let fields =
2956
               ("names",
2957
                 ((fun x  ->
2958
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
2959
                    arg0.names))
2960
               :: fields  in
2961
             `Assoc fields)]
2962
      | ComponentDecl arg0 ->
2963
          `List
2964
            [`String "COMPONENT_DECLARATION";
2965
            (let fields = []  in
2966
             let fields =
2967
               if arg0.ports = []
2968
               then fields
2969
               else
2970
                 ("ports",
2971
                   (((fun x  ->
2972
                        `List
2973
                          (List.map (fun x  -> vhdl_port_t_to_yojson x) x)))
2974
                      arg0.ports))
2975
                 :: fields
2976
                in
2977
             let fields =
2978
               if arg0.generics = []
2979
               then fields
2980
               else
2981
                 ("generics",
2982
                   (((fun x  ->
2983
                        `List
2984
                          (List.map (fun x  -> vhdl_port_t_to_yojson x) x)))
2985
                      arg0.generics))
2986
                 :: fields
2987
                in
2988
             let fields =
2989
               if arg0.name = NoName
2990
               then fields
2991
               else
2992
                 ("name", (((fun x  -> vhdl_name_t_to_yojson x)) arg0.name))
2993
                 :: fields
2994
                in
2995
             `Assoc fields)]
2996
      | Subprogram arg0 ->
2997
          `List
2998
            [`String "SUBPROGRAM_BODY";
2999
            (let fields = []  in
3000
             let fields =
3001
               if arg0.stmts = []
3002
               then fields
3003
               else
3004
                 ("stmts",
3005
                   (((fun x  ->
3006
                        `List
3007
                          (List.map
3008
                             (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x)))
3009
                      arg0.stmts))
3010
                 :: fields
3011
                in
3012
             let fields =
3013
               if arg0.decl_part = []
3014
               then fields
3015
               else
3016
                 ("decl_part",
3017
                   (((fun x  ->
3018
                        `List
3019
                          (List.map
3020
                             (fun x  -> vhdl_declaration_t_to_yojson x) x)))
3021
                      arg0.decl_part))
3022
                 :: fields
3023
                in
3024
             let fields =
3025
               ("spec",
3026
                 ((fun x  -> vhdl_subprogram_spec_t_to_yojson x) arg0.spec))
3027
               :: fields  in
3028
             `Assoc fields)])
3029
  [@ocaml.warning "-A"])
3030

    
3031
and (vhdl_declaration_t_of_yojson :
3032
      Yojson.Safe.json ->
3033
        vhdl_declaration_t Ppx_deriving_yojson_runtime.error_or)
3034
  =
3035
  ((let open! Ppx_deriving_yojson_runtime in
3036
      function
3037
      | `List ((`String "VARIABLE_DECLARATION")::arg0::[]) ->
3038
          ((function
3039
            | `Assoc xs ->
3040
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3041
                  match xs with
3042
                  | ("names",x)::xs ->
3043
                      loop xs
3044
                        (((function
3045
                           | `List xs ->
3046
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
3047
                                 [] xs
3048
                           | _ ->
3049
                               Result.Error
3050
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
3051
                          arg1, arg2)
3052
                  | ("typ",x)::xs ->
3053
                      loop xs
3054
                        (arg0,
3055
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
3056
                             x), arg2)
3057
                  | ("init_val",x)::xs ->
3058
                      loop xs
3059
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
3060
                  | [] ->
3061
                      arg2 >>=
3062
                        ((fun arg2  ->
3063
                            arg1 >>=
3064
                              (fun arg1  ->
3065
                                 arg0 >>=
3066
                                   (fun arg0  ->
3067
                                      Result.Ok
3068
                                        (VarDecl
3069
                                           {
3070
                                             names = arg0;
3071
                                             typ = arg1;
3072
                                             init_val = arg2
3073
                                           })))))
3074
                  | _::xs -> loop xs _state  in
3075
                loop xs
3076
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
3077
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
3078
                    (Result.Ok IsNull))
3079
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
3080
      | `List ((`String "CONSTANT_DECLARATION")::arg0::[]) ->
3081
          ((function
3082
            | `Assoc xs ->
3083
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3084
                  match xs with
3085
                  | ("names",x)::xs ->
3086
                      loop xs
3087
                        (((function
3088
                           | `List xs ->
3089
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
3090
                                 [] xs
3091
                           | _ ->
3092
                               Result.Error
3093
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
3094
                          arg1, arg2)
3095
                  | ("typ",x)::xs ->
3096
                      loop xs
3097
                        (arg0,
3098
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
3099
                             x), arg2)
3100
                  | ("init_val",x)::xs ->
3101
                      loop xs
3102
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
3103
                  | [] ->
3104
                      arg2 >>=
3105
                        ((fun arg2  ->
3106
                            arg1 >>=
3107
                              (fun arg1  ->
3108
                                 arg0 >>=
3109
                                   (fun arg0  ->
3110
                                      Result.Ok
3111
                                        (CstDecl
3112
                                           {
3113
                                             names = arg0;
3114
                                             typ = arg1;
3115
                                             init_val = arg2
3116
                                           })))))
3117
                  | _::xs -> loop xs _state  in
3118
                loop xs
3119
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
3120
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
3121
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.init_val"))
3122
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
3123
      | `List ((`String "SIGNAL_DECLARATION")::arg0::[]) ->
3124
          ((function
3125
            | `Assoc xs ->
3126
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3127
                  match xs with
3128
                  | ("names",x)::xs ->
3129
                      loop xs
3130
                        (((function
3131
                           | `List xs ->
3132
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
3133
                                 [] xs
3134
                           | _ ->
3135
                               Result.Error
3136
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
3137
                          arg1, arg2)
3138
                  | ("typ",x)::xs ->
3139
                      loop xs
3140
                        (arg0,
3141
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
3142
                             x), arg2)
3143
                  | ("init_val",x)::xs ->
3144
                      loop xs
3145
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
3146
                  | [] ->
3147
                      arg2 >>=
3148
                        ((fun arg2  ->
3149
                            arg1 >>=
3150
                              (fun arg1  ->
3151
                                 arg0 >>=
3152
                                   (fun arg0  ->
3153
                                      Result.Ok
3154
                                        (SigDecl
3155
                                           {
3156
                                             names = arg0;
3157
                                             typ = arg1;
3158
                                             init_val = arg2
3159
                                           })))))
3160
                  | _::xs -> loop xs _state  in
3161
                loop xs
3162
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
3163
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
3164
                    (Result.Ok IsNull))
3165
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
3166
      | `List ((`String "COMPONENT_DECLARATION")::arg0::[]) ->
3167
          ((function
3168
            | `Assoc xs ->
3169
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3170
                  match xs with
3171
                  | ("name",x)::xs ->
3172
                      loop xs
3173
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3174
                  | ("generics",x)::xs ->
3175
                      loop xs
3176
                        (arg0,
3177
                          ((function
3178
                            | `List xs ->
3179
                                map_bind (fun x  -> vhdl_port_t_of_yojson x)
3180
                                  [] xs
3181
                            | _ ->
3182
                                Result.Error
3183
                                  "Vhdl_ast.vhdl_declaration_t.generics") x),
3184
                          arg2)
3185
                  | ("ports",x)::xs ->
3186
                      loop xs
3187
                        (arg0, arg1,
3188
                          ((function
3189
                            | `List xs ->
3190
                                map_bind (fun x  -> vhdl_port_t_of_yojson x)
3191
                                  [] xs
3192
                            | _ ->
3193
                                Result.Error
3194
                                  "Vhdl_ast.vhdl_declaration_t.ports") x))
3195
                  | [] ->
3196
                      arg2 >>=
3197
                        ((fun arg2  ->
3198
                            arg1 >>=
3199
                              (fun arg1  ->
3200
                                 arg0 >>=
3201
                                   (fun arg0  ->
3202
                                      Result.Ok
3203
                                        (ComponentDecl
3204
                                           {
3205
                                             name = arg0;
3206
                                             generics = arg1;
3207
                                             ports = arg2
3208
                                           })))))
3209
                  | _::xs -> loop xs _state  in
3210
                loop xs ((Result.Ok NoName), (Result.Ok []), (Result.Ok []))
3211
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
3212
      | `List ((`String "SUBPROGRAM_BODY")::arg0::[]) ->
3213
          ((function
3214
            | `Assoc xs ->
3215
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3216
                  match xs with
3217
                  | ("spec",x)::xs ->
3218
                      loop xs
3219
                        (((fun x  -> vhdl_subprogram_spec_t_of_yojson x) x),
3220
                          arg1, arg2)
3221
                  | ("decl_part",x)::xs ->
3222
                      loop xs
3223
                        (arg0,
3224
                          ((function
3225
                            | `List xs ->
3226
                                map_bind
3227
                                  (fun x  -> vhdl_declaration_t_of_yojson x)
3228
                                  [] xs
3229
                            | _ ->
3230
                                Result.Error
3231
                                  "Vhdl_ast.vhdl_declaration_t.decl_part") x),
3232
                          arg2)
3233
                  | ("stmts",x)::xs ->
3234
                      loop xs
3235
                        (arg0, arg1,
3236
                          ((function
3237
                            | `List xs ->
3238
                                map_bind
3239
                                  (fun x  ->
3240
                                     vhdl_sequential_stmt_t_of_yojson x) []
3241
                                  xs
3242
                            | _ ->
3243
                                Result.Error
3244
                                  "Vhdl_ast.vhdl_declaration_t.stmts") x))
3245
                  | [] ->
3246
                      arg2 >>=
3247
                        ((fun arg2  ->
3248
                            arg1 >>=
3249
                              (fun arg1  ->
3250
                                 arg0 >>=
3251
                                   (fun arg0  ->
3252
                                      Result.Ok
3253
                                        (Subprogram
3254
                                           {
3255
                                             spec = arg0;
3256
                                             decl_part = arg1;
3257
                                             stmts = arg2
3258
                                           })))))
3259
                  | _::xs -> loop xs _state  in
3260
                loop xs
3261
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.spec"),
3262
                    (Result.Ok []), (Result.Ok []))
3263
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
3264
      | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")
3265
  [@ocaml.warning "-A"])
3266

    
3267
let rec (vhdl_load_t_to_yojson : vhdl_load_t -> Yojson.Safe.json) =
3268
  ((let open! Ppx_deriving_yojson_runtime in
3269
      function
3270
      | Library arg0 ->
3271
          `List
3272
            [`String "LIBRARY_CLAUSE";
3273
            ((fun x  ->
3274
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0]
3275
      | Use arg0 ->
3276
          `List
3277
            [`String "USE_CLAUSE";
3278
            ((fun x  ->
3279
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0])
3280
  [@ocaml.warning "-A"])
3281

    
3282
and (vhdl_load_t_of_yojson :
3283
      Yojson.Safe.json -> vhdl_load_t Ppx_deriving_yojson_runtime.error_or)
3284
  =
3285
  ((let open! Ppx_deriving_yojson_runtime in
3286
      function
3287
      | `List ((`String "LIBRARY_CLAUSE")::arg0::[]) ->
3288
          ((function
3289
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
3290
            | _ -> Result.Error "Vhdl_ast.vhdl_load_t") arg0) >>=
3291
            ((fun arg0  -> Result.Ok (Library arg0)))
3292
      | `List ((`String "USE_CLAUSE")::arg0::[]) ->
3293
          ((function
3294
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
3295
            | _ -> Result.Error "Vhdl_ast.vhdl_load_t") arg0) >>=
3296
            ((fun arg0  -> Result.Ok (Use arg0)))
3297
      | _ -> Result.Error "Vhdl_ast.vhdl_load_t")
3298
  [@ocaml.warning "-A"])
3299

    
3300
let rec (vhdl_declarative_item_t_to_yojson :
3301
          vhdl_declarative_item_t -> Yojson.Safe.json)
3302
  =
3303
  ((let open! Ppx_deriving_yojson_runtime in
3304
      fun x  ->
3305
        let fields = []  in
3306
        let fields =
3307
          if x.definition = None
3308
          then fields
3309
          else
3310
            ("definition",
3311
              (((function
3312
                 | None  -> `Null
3313
                 | Some x -> ((fun x  -> vhdl_definition_t_to_yojson x)) x))
3314
                 x.definition))
3315
            :: fields
3316
           in
3317
        let fields =
3318
          if x.declaration = None
3319
          then fields
3320
          else
3321
            ("declaration",
3322
              (((function
3323
                 | None  -> `Null
3324
                 | Some x -> ((fun x  -> vhdl_declaration_t_to_yojson x)) x))
3325
                 x.declaration))
3326
            :: fields
3327
           in
3328
        let fields =
3329
          if x.use_clause = None
3330
          then fields
3331
          else
3332
            ("use_clause",
3333
              (((function
3334
                 | None  -> `Null
3335
                 | Some x -> ((fun x  -> vhdl_load_t_to_yojson x)) x))
3336
                 x.use_clause))
3337
            :: fields
3338
           in
3339
        `Assoc fields)
3340
  [@ocaml.warning "-A"])
3341

    
3342
and (vhdl_declarative_item_t_of_yojson :
3343
      Yojson.Safe.json ->
3344
        vhdl_declarative_item_t Ppx_deriving_yojson_runtime.error_or)
3345
  =
3346
  ((let open! Ppx_deriving_yojson_runtime in
3347
      function
3348
      | `Assoc xs ->
3349
          let rec loop xs ((arg0,arg1,arg2) as _state) =
3350
            match xs with
3351
            | ("use_clause",x)::xs ->
3352
                loop xs
3353
                  (((function
3354
                     | `Null -> Result.Ok None
3355
                     | x ->
3356
                         ((fun x  -> vhdl_load_t_of_yojson x) x) >>=
3357
                           ((fun x  -> Result.Ok (Some x)))) x), arg1, arg2)
3358
            | ("declaration",x)::xs ->
3359
                loop xs
3360
                  (arg0,
3361
                    ((function
3362
                      | `Null -> Result.Ok None
3363
                      | x ->
3364
                          ((fun x  -> vhdl_declaration_t_of_yojson x) x) >>=
3365
                            ((fun x  -> Result.Ok (Some x)))) x), arg2)
3366
            | ("definition",x)::xs ->
3367
                loop xs
3368
                  (arg0, arg1,
3369
                    ((function
3370
                      | `Null -> Result.Ok None
3371
                      | x ->
3372
                          ((fun x  -> vhdl_definition_t_of_yojson x) x) >>=
3373
                            ((fun x  -> Result.Ok (Some x)))) x))
3374
            | [] ->
3375
                arg2 >>=
3376
                  ((fun arg2  ->
3377
                      arg1 >>=
3378
                        (fun arg1  ->
3379
                           arg0 >>=
3380
                             (fun arg0  ->
3381
                                Result.Ok
3382
                                  {
3383
                                    use_clause = arg0;
3384
                                    declaration = arg1;
3385
                                    definition = arg2
3386
                                  }))))
3387
            | _::xs -> loop xs _state  in
3388
          loop xs ((Result.Ok None), (Result.Ok None), (Result.Ok None))
3389
      | _