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
      | NoName  -> `List [`String "NoName"])
1097
  [@ocaml.warning "-A"])
1098

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3390
let rec (vh