Project

General

Profile

« Previous | Next » 

Revision e050e30c

Added by Arnaud Dieumegard over 3 years ago

Removed generated yojson parser, now relies on pre-processed version

View differences:

src/backends/VHDL/vhdl_ast_yojson.ml
1
open Vhdl_ast
2

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  
1456
and (vhdl_array_attributes_t_of_yojson :
1457
      Yojson.Safe.json ->
1458
        vhdl_array_attributes_t Ppx_deriving_yojson_runtime.error_or)
1459
  =
1460
  ((let open! Ppx_deriving_yojson_runtime in
1461
      function
1462
      | `List ((`String "AAttInt")::arg0::[]) ->
1463
          ((function
1464
            | `Assoc xs ->
1465
                let rec loop xs ((arg0,arg1) as _state) =
1466
                  match xs with
1467
                  | ("id",x)::xs ->
1468
                      loop xs
1469
                        (((function
1470
                           | `String x -> Result.Ok x
1471
                           | _ ->
1472
                               Result.Error
1473
                                 "Vhdl_ast.vhdl_array_attributes_t.id") x),
1474
                          arg1)
1475
                  | ("arg",x)::xs ->
1476
                      loop xs
1477
                        (arg0,
1478
                          ((function
1479
                            | `Int x -> Result.Ok x
1480
                            | _ ->
1481
                                Result.Error
1482
                                  "Vhdl_ast.vhdl_array_attributes_t.arg") x))
1483
                  | [] ->
1484
                      arg1 >>=
1485
                        ((fun arg1  ->
1486
                            arg0 >>=
1487
                              (fun arg0  ->
1488
                                 Result.Ok
1489
                                   (AAttInt { id = arg0; arg = arg1 }))))
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff