## lustrec / src / backends / VHDL / vhdl_ast_deriving.ml @ 32614c2d

History | View | Annotate | Download (243 KB)

1 | 40364f53 | Arnaud Dieumegard | let base_types = |
---|---|---|---|

2 | ["integer"; |
||

3 | "character"; |
||

4 | "bit"; |
||

5 | "real"; |
||

6 | "natural"; |
||

7 | "positive"; |
||

8 | "std_logic"; |
||

9 | "std_logic_vector"] |
||

10 | let std_logic_cst = ["U"; "X"; "0"; "1"; "Z"; "W"; "L"; "H"; "-"] |
||

11 | let literal_base = ["B"; "O"; "X"; "UB"; "UO"; "UX"; "SB"; "SO"; "SX"; "D"] |
||

12 | type vhdl_cst_val_t = |
||

13 | | CstInt of int |
||

14 | | CstStdLogic of string |
||

15 | | CstLiteral of string [@name "CST_LITERAL"] |
||

16 | |||

17 | let rec (pp_vhdl_cst_val_t : |
||

18 | Format.formatter -> vhdl_cst_val_t -> Ppx_deriving_runtime.unit) |
||

19 | = |
||

20 | ((let open! Ppx_deriving_runtime in |
||

21 | fun fmt -> |
||

22 | function |
||

23 | | CstInt a0 -> |
||

24 | (Format.fprintf fmt "%d") a0; |
||

25 | | CstStdLogic a0 -> |
||

26 | (Format.fprintf fmt "%S") a0; |
||

27 | | CstLiteral a0 -> |
||

28 | f779d524 | Arnaud Dieumegard | (Format.fprintf fmt "%s") a0;) |

29 | 40364f53 | Arnaud Dieumegard | [@ocaml.warning "-A"]) |

30 | |||

31 | and show_vhdl_cst_val_t : vhdl_cst_val_t -> Ppx_deriving_runtime.string = |
||

32 | fun x -> Format.asprintf "%a" pp_vhdl_cst_val_t x |
||

33 | |||

34 | let rec (vhdl_cst_val_t_to_yojson : vhdl_cst_val_t -> Yojson.Safe.json) = |
||

35 | ((let open! Ppx_deriving_yojson_runtime in |
||

36 | function |
||

37 | | CstInt arg0 -> |
||

38 | `List |
||

39 | [`String "CstInt"; |
||

40 | ((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg0] |
||

41 | | CstStdLogic arg0 -> |
||

42 | `List |
||

43 | [`String "CstStdLogic"; |
||

44 | ((fun (x : Ppx_deriving_runtime.string) -> `String x)) arg0] |
||

45 | | CstLiteral arg0 -> |
||

46 | `List |
||

47 | [`String "CST_LITERAL"; |
||

48 | ((fun (x : Ppx_deriving_runtime.string) -> `String x)) arg0]) |
||

49 | [@ocaml.warning "-A"]) |
||

50 | |||

51 | and (vhdl_cst_val_t_of_yojson : |
||

52 | Yojson.Safe.json -> vhdl_cst_val_t Ppx_deriving_yojson_runtime.error_or) |
||

53 | = |
||

54 | ((let open! Ppx_deriving_yojson_runtime in |
||

55 | function |
||

56 | | `List ((`String "CstInt")::arg0::[]) -> |
||

57 | ((function |
||

58 | | `Int x -> Result.Ok x |
||

59 | | _ -> Result.Error "Vhdl_ast.vhdl_cst_val_t") arg0) >>= |
||

60 | ((fun arg0 -> Result.Ok (CstInt arg0))) |
||

61 | | `List ((`String "CstStdLogic")::arg0::[]) -> |
||

62 | ((function |
||

63 | | `String x -> Result.Ok x |
||

64 | | _ -> Result.Error "Vhdl_ast.vhdl_cst_val_t") arg0) >>= |
||

65 | ((fun arg0 -> Result.Ok (CstStdLogic arg0))) |
||

66 | | `List ((`String "CST_LITERAL")::arg0::[]) -> |
||

67 | ((function |
||

68 | | `String x -> Result.Ok x |
||

69 | | _ -> Result.Error "Vhdl_ast.vhdl_cst_val_t") arg0) >>= |
||

70 | ((fun arg0 -> Result.Ok (CstLiteral arg0))) |
||

71 | | _ -> Result.Error "Vhdl_ast.vhdl_cst_val_t") |
||

72 | [@ocaml.warning "-A"]) |
||

73 | |||

74 | type vhdl_type_t = |
||

75 | | Base of string |
||

76 | | Range of string option * int * int |
||

77 | | Bit_vector of int * int |
||

78 | 248eb65e | Arnaud Dieumegard | | Array of |

79 | { |
||

80 | ec031ed0 | Arnaud Dieumegard | indexes: vhdl_name_t list [@default []]; |

81 | 248eb65e | Arnaud Dieumegard | const: vhdl_constraint_t option [@default None]; |

82 | definition: vhdl_subtype_indication_t } [@name "ARRAY_TYPE_DEFINITION"] |
||

83 | | Record of vhdl_element_declaration_t list |
||

84 | [@name "RECORD_TYPE_DEFINITION"] |
||

85 | | Enumerated of vhdl_name_t list [@name "ENUMERATION_TYPE_DEFINITION"] |
||

86 | 40364f53 | Arnaud Dieumegard | | Void |

87 | 248eb65e | Arnaud Dieumegard | and vhdl_element_declaration_t = |

88 | { |
||

89 | names: vhdl_name_t list ; |
||

90 | definition: vhdl_subtype_indication_t } |
||

91 | 40364f53 | Arnaud Dieumegard | and vhdl_subtype_indication_t = |

92 | { |
||

93 | name: vhdl_name_t [@default NoName]; |
||

94 | functionName: vhdl_name_t [@default NoName]; |
||

95 | const: vhdl_constraint_t [@default NoConstraint]} |
||

96 | and vhdl_discrete_range_t = |
||

97 | | SubDiscreteRange of vhdl_subtype_indication_t |
||

98 | [@name "SUB_DISCRETE_RANGE"] |
||

99 | | NamedRange of vhdl_name_t [@name "NAMED_RANGE"] |
||

100 | | DirectedRange of |
||

101 | { |
||

102 | direction: string ; |
||

103 | from: vhdl_expr_t ; |
||

104 | _to: vhdl_expr_t } [@name "RANGE_WITH_DIRECTION"] |
||

105 | and vhdl_constraint_t = |
||

106 | | RefConstraint of { |
||

107 | ref_name: vhdl_name_t } |
||

108 | | RangeConstraint of { |
||

109 | range: vhdl_discrete_range_t } [@name "RANGE_CONSTRAINT"] |
||

110 | | IndexConstraint of { |
||

111 | ranges: vhdl_discrete_range_t list } [@name "INDEX_CONSTRAINT"] |
||

112 | | ArrayConstraint of |
||

113 | { |
||

114 | ranges: vhdl_discrete_range_t list ; |
||

115 | sub: vhdl_constraint_t } [@name "ARRAY_CONSTRAINT"] |
||

116 | | RecordConstraint |
||

117 | | NoConstraint |
||

118 | and vhdl_definition_t = |
||

119 | | Type of { |
||

120 | name: vhdl_name_t ; |
||

121 | definition: vhdl_type_t } [@name "TYPE_DECLARATION"] |
||

122 | | Subtype of { |
||

123 | name: vhdl_name_t ; |
||

124 | typ: vhdl_subtype_indication_t } [@name "SUBTYPE_DECLARATION"] |
||

125 | and vhdl_expr_t = |
||

126 | | Call of vhdl_name_t [@name "CALL"] |
||

127 | ab6312e7 | Arnaud Dieumegard | | Cst of |

128 | { |
||

129 | value: vhdl_cst_val_t ; |
||

130 | unit_name: vhdl_name_t option [@default None]} [@name "CONSTANT_VALUE"] |
||

131 | 40364f53 | Arnaud Dieumegard | | Op of { |

132 | id: string [@default ""]; |
||

133 | args: vhdl_expr_t list [@default []]} [@name "EXPRESSION"] |
||

134 | | IsNull [@name "IsNull"] |
||

135 | | Time of { |
||

136 | value: int ; |
||

137 | phy_unit: string [@default ""]} |
||

138 | | Sig of { |
||

139 | name: vhdl_name_t ; |
||

140 | att: vhdl_signal_attributes_t option } |
||

141 | | SuffixMod of { |
||

142 | expr: vhdl_expr_t ; |
||

143 | selection: vhdl_suffix_selection_t } |
||

144 | | Aggregate of { |
||

145 | elems: vhdl_element_assoc_t list } [@name "AGGREGATE"] |
||

146 | | Others [@name "OTHERS"] |
||

147 | and vhdl_name_t = |
||

148 | | Simple of string [@name "SIMPLE_NAME"] |
||

149 | | Identifier of string [@name "IDENTIFIER"] |
||

150 | | Selected of vhdl_name_t list [@name "SELECTED_NAME"] |
||

151 | | Index of { |
||

152 | id: vhdl_name_t ; |
||

153 | exprs: vhdl_expr_t list } [@name "INDEXED_NAME"] |
||

154 | | Slice of { |
||

155 | id: vhdl_name_t ; |
||

156 | range: vhdl_discrete_range_t } [@name "SLICE_NAME"] |
||

157 | | Attribute of |
||

158 | { |
||

159 | id: vhdl_name_t ; |
||

160 | designator: vhdl_name_t ; |
||

161 | expr: vhdl_expr_t [@default IsNull]} [@name "ATTRIBUTE_NAME"] |
||

162 | | Function of { |
||

163 | id: vhdl_name_t ; |
||

164 | assoc_list: vhdl_assoc_element_t list } [@name "FUNCTION_CALL"] |
||

165 | | NoName |
||

166 | and vhdl_assoc_element_t = |
||

167 | { |
||

168 | 00970bbf | Arnaud Dieumegard | formal_name: vhdl_name_t option [@default None]; |

169 | formal_arg: vhdl_name_t option [@default None]; |
||

170 | actual_name: vhdl_name_t option [@default None]; |
||

171 | actual_designator: vhdl_name_t option [@default None]; |
||

172 | actual_expr: vhdl_expr_t option [@default None]} |
||

173 | 40364f53 | Arnaud Dieumegard | and vhdl_element_assoc_t = { |

174 | 7f55f63f | Arnaud Dieumegard | choices: vhdl_expr_t list [@default []]; |

175 | 40364f53 | Arnaud Dieumegard | expr: vhdl_expr_t } |

176 | and vhdl_array_attributes_t = |
||

177 | | AAttInt of { |
||

178 | id: string ; |
||

179 | arg: int } |
||

180 | | AAttAscending |
||

181 | and vhdl_signal_attributes_t = |
||

182 | | SigAtt of string |
||

183 | and vhdl_string_attributes_t = |
||

184 | | StringAtt of string |
||

185 | and vhdl_suffix_selection_t = |
||

186 | | Idx of int |
||

187 | | SuffixRange of int * int |
||

188 | |||

189 | let rec pp_vhdl_type_t : |
||

190 | Format.formatter -> vhdl_type_t -> Ppx_deriving_runtime.unit = |
||

191 | 248eb65e | Arnaud Dieumegard | let __4 () = pp_vhdl_name_t |

192 | |||

193 | and __3 () = pp_vhdl_element_declaration_t |
||

194 | |||

195 | and __2 () = pp_vhdl_subtype_indication_t |
||

196 | |||

197 | and __1 () = pp_vhdl_constraint_t |
||

198 | |||

199 | and __0 () = pp_vhdl_name_t |
||

200 | in |
||

201 | 40364f53 | Arnaud Dieumegard | ((let open! Ppx_deriving_runtime in |

202 | fun fmt -> |
||

203 | function |
||

204 | | Base a0 -> |
||

205 | f779d524 | Arnaud Dieumegard | (Format.fprintf fmt "%s") a0; |

206 | 40364f53 | Arnaud Dieumegard | | Range (a0,a1,a2) -> |

207 | f779d524 | Arnaud Dieumegard | (( |

208 | (Format.fprintf fmt "%d") a1); |
||

209 | ((function |
||

210 | 389493d3 | Arnaud Dieumegard | | None -> Format.pp_print_string fmt "" |

211 | 40364f53 | Arnaud Dieumegard | | Some x -> |

212 | 389493d3 | Arnaud Dieumegard | (Format.fprintf fmt "%s") x; |

213 | f779d524 | Arnaud Dieumegard | )) a0; |

214 | 40364f53 | Arnaud Dieumegard | (Format.fprintf fmt "%d") a2); |

215 | | Bit_vector (a0,a1) -> |
||

216 | 389493d3 | Arnaud Dieumegard | (Format.fprintf fmt "array (%d,%d) of bit") a0 a1; |

217 | 248eb65e | Arnaud Dieumegard | | Array |

218 | { indexes = aindexes; const = aconst; definition = adefinition } |
||

219 | -> |
||

220 | Format.fprintf fmt "array"; |
||

221 | (match aindexes with |
||

222 | | [] -> Format.fprintf fmt ""; |
||

223 | | _ -> |
||

224 | ((fun x -> |
||

225 | ignore |
||

226 | (List.fold_left |
||

227 | (fun sep -> |
||

228 | fun x -> |
||

229 | if sep then Format.fprintf fmt ",@ "; |
||

230 | ((__0 ()) fmt) x; |
||

231 | true) false x)) aindexes)); |
||

232 | (function |
||

233 | | None -> Format.pp_print_string fmt "" |
||

234 | | Some x -> |
||

235 | ((__1 ()) fmt) x) aconst; |
||

236 | Format.fprintf fmt " of "; |
||

237 | ((__2 ()) fmt) adefinition; |
||

238 | | Record a0 -> |
||

239 | Format.fprintf fmt "@[<v 2>record@;"; |
||

240 | (fun x -> |
||

241 | ignore |
||

242 | (List.fold_left |
||

243 | (fun sep -> |
||

244 | fun x -> |
||

245 | if sep then Format.fprintf fmt ";@;"; |
||

246 | ((__3 ()) fmt) x; |
||

247 | true) false x); |
||

248 | Format.fprintf fmt "@]@;end record") a0; |
||

249 | 40364f53 | Arnaud Dieumegard | | Enumerated a0 -> |

250 | 248eb65e | Arnaud Dieumegard | (Format.fprintf fmt "("; |

251 | ((fun x -> |
||

252 | ignore |
||

253 | (List.fold_left |
||

254 | (fun sep -> |
||

255 | fun x -> |
||

256 | if sep then Format.fprintf fmt ",@ "; |
||

257 | ((__4 ()) fmt) x; |
||

258 | true) false x))) a0; |
||

259 | Format.fprintf fmt ")"); |
||

260 | 389493d3 | Arnaud Dieumegard | | Void -> Format.pp_print_string fmt "") |

261 | 40364f53 | Arnaud Dieumegard | [@ocaml.warning "-A"]) |

262 | |||

263 | and show_vhdl_type_t : vhdl_type_t -> Ppx_deriving_runtime.string = |
||

264 | fun x -> Format.asprintf "%a" pp_vhdl_type_t x |
||

265 | |||

266 | 248eb65e | Arnaud Dieumegard | and pp_vhdl_element_declaration_t : |

267 | Format.formatter -> vhdl_element_declaration_t -> Ppx_deriving_runtime.unit |
||

268 | = |
||

269 | let __1 () = pp_vhdl_subtype_indication_t |
||

270 | |||

271 | and __0 () = pp_vhdl_name_t |
||

272 | in |
||

273 | ((let open! Ppx_deriving_runtime in |
||

274 | fun fmt -> |
||

275 | fun x -> |
||

276 | (fun x -> |
||

277 | ignore |
||

278 | (List.fold_left |
||

279 | (fun sep -> |
||

280 | fun x -> |
||

281 | if sep then Format.fprintf fmt ",@ "; |
||

282 | ((__0 ()) fmt) x; |
||

283 | true) false x)) x.names; |
||

284 | Format.fprintf fmt ":@ "; |
||

285 | ((__1 ()) fmt) x.definition) |
||

286 | [@ocaml.warning "-A"]) |
||

287 | |||

288 | and show_vhdl_element_declaration_t : |
||

289 | vhdl_element_declaration_t -> Ppx_deriving_runtime.string = |
||

290 | fun x -> Format.asprintf "%a" pp_vhdl_element_declaration_t x |
||

291 | |||

292 | 40364f53 | Arnaud Dieumegard | and pp_vhdl_subtype_indication_t : |

293 | Format.formatter -> vhdl_subtype_indication_t -> Ppx_deriving_runtime.unit |
||

294 | = |
||

295 | let __2 () = pp_vhdl_constraint_t |
||

296 | |||

297 | and __1 () = pp_vhdl_name_t |
||

298 | |||

299 | and __0 () = pp_vhdl_name_t |
||

300 | in |
||

301 | ((let open! Ppx_deriving_runtime in |
||

302 | fun fmt -> |
||

303 | fun x -> |
||

304 | f779d524 | Arnaud Dieumegard | ((__0 ()) fmt) x.name; |

305 | ((__1 ()) fmt) x.functionName; |
||

306 | d4175560 | Arnaud Dieumegard | (match x.const with |

307 | | NoConstraint -> Format.fprintf fmt ""; |
||

308 | | _ -> Format.fprintf fmt " "; |
||

309 | ((__2 ()) fmt) x.const)) |
||

310 | 40364f53 | Arnaud Dieumegard | [@ocaml.warning "-A"]) |

311 | |||

312 | and show_vhdl_subtype_indication_t : |
||

313 | vhdl_subtype_indication_t -> Ppx_deriving_runtime.string = |
||

314 | fun x -> Format.asprintf "%a" pp_vhdl_subtype_indication_t x |
||

315 | |||

316 | and pp_vhdl_discrete_range_t : |
||

317 | Format.formatter -> vhdl_discrete_range_t -> Ppx_deriving_runtime.unit = |
||

318 | let __3 () = pp_vhdl_expr_t |
||

319 | |||

320 | and __2 () = pp_vhdl_expr_t |
||

321 | |||

322 | and __1 () = pp_vhdl_name_t |
||

323 | |||

324 | and __0 () = pp_vhdl_subtype_indication_t |
||

325 | in |
||

326 | ((let open! Ppx_deriving_runtime in |
||

327 | fun fmt -> |
||

328 | function |
||

329 | | SubDiscreteRange a0 -> |
||

330 | ((__0 ()) fmt) a0; |
||

331 | | NamedRange a0 -> |
||

332 | ((__1 ()) fmt) a0; |
||

333 | | DirectedRange { direction = adirection; from = afrom; _to = a_to } |
||

334 | -> |
||

335 | ((__2 ()) fmt) afrom; |
||

336 | f779d524 | Arnaud Dieumegard | (Format.fprintf fmt " %s ") adirection; |

337 | ((__3 ()) fmt) a_to; |
||

338 | ) |
||

339 | 40364f53 | Arnaud Dieumegard | [@ocaml.warning "-A"]) |

340 | |||

341 | and show_vhdl_discrete_range_t : |
||

342 | vhdl_discrete_range_t -> Ppx_deriving_runtime.string = |
||

343 | fun x -> Format.asprintf "%a" pp_vhdl_discrete_range_t x |
||

344 | |||

345 | 3bc26d43 | Arnaud Dieumegard | (* TODO Adapt for: ArrayConstraint, RecordConstraint *) |

346 | 40364f53 | Arnaud Dieumegard | and pp_vhdl_constraint_t : |

347 | Format.formatter -> vhdl_constraint_t -> Ppx_deriving_runtime.unit = |
||

348 | let __4 () = pp_vhdl_constraint_t |
||

349 | |||

350 | and __3 () = pp_vhdl_discrete_range_t |
||

351 | |||

352 | and __2 () = pp_vhdl_discrete_range_t |
||

353 | |||

354 | and __1 () = pp_vhdl_discrete_range_t |
||

355 | |||

356 | and __0 () = pp_vhdl_name_t |
||

357 | in |
||

358 | ((let open! Ppx_deriving_runtime in |
||

359 | fun fmt -> |
||

360 | function |
||

361 | | RefConstraint { ref_name = aref_name } -> |
||

362 | f779d524 | Arnaud Dieumegard | (Format.fprintf fmt "("; |

363 | 40364f53 | Arnaud Dieumegard | ((__0 ()) fmt) aref_name; |

364 | f779d524 | Arnaud Dieumegard | Format.fprintf fmt ")"); |

365 | 40364f53 | Arnaud Dieumegard | | RangeConstraint { range = arange } -> |

366 | f779d524 | Arnaud Dieumegard | (Format.fprintf fmt "("; |

367 | 40364f53 | Arnaud Dieumegard | ((__1 ()) fmt) arange; |

368 | f779d524 | Arnaud Dieumegard | Format.fprintf fmt ")"); |

369 | 40364f53 | Arnaud Dieumegard | | IndexConstraint { ranges = aranges } -> |

370 | f779d524 | Arnaud Dieumegard | Format.fprintf fmt "("; |

371 | ((fun x -> |
||

372 | ignore |
||

373 | (List.fold_left |
||

374 | (fun sep -> |
||

375 | fun x -> |
||

376 | if sep then Format.fprintf fmt ", "; |
||

377 | ((__2 ()) fmt) x; |
||

378 | true) false x))) aranges; |
||

379 | Format.fprintf fmt ")"; |
||

380 | 40364f53 | Arnaud Dieumegard | | ArrayConstraint { ranges = aranges; sub = asub } -> |

381 | (Format.fprintf fmt "@[<2>ArrayConstraint {@,"; |
||

382 | ((Format.fprintf fmt "@[%s =@ " "ranges"; |
||

383 | ((fun x -> |
||

384 | Format.fprintf fmt "@[<2>["; |
||

385 | ignore |
||

386 | (List.fold_left |
||

387 | (fun sep -> |
||

388 | fun x -> |
||

389 | if sep then Format.fprintf fmt ";@ "; |
||

390 | ((__3 ()) fmt) x; |
||

391 | true) false x); |
||

392 | Format.fprintf fmt "@,]@]")) aranges; |
||

393 | Format.fprintf fmt "@]"); |
||

394 | Format.fprintf fmt ";@ "; |
||

395 | Format.fprintf fmt "@[%s =@ " "sub"; |
||

396 | ((__4 ()) fmt) asub; |
||

397 | Format.fprintf fmt "@]"); |
||

398 | Format.fprintf fmt "@]}") |
||

399 | f779d524 | Arnaud Dieumegard | | RecordConstraint -> Format.pp_print_string fmt "" |

400 | | NoConstraint -> Format.pp_print_string fmt "") |
||

401 | 40364f53 | Arnaud Dieumegard | [@ocaml.warning "-A"]) |

402 | |||

403 | and show_vhdl_constraint_t : vhdl_constraint_t -> Ppx_deriving_runtime.string |
||

404 | = fun x -> Format.asprintf "%a" pp_vhdl_constraint_t x |
||

405 | |||

406 | and pp_vhdl_definition_t : |
||

407 | Format.formatter -> vhdl_definition_t -> Ppx_deriving_runtime.unit = |
||

408 | let __3 () = pp_vhdl_subtype_indication_t |
||

409 | |||

410 | and __2 () = pp_vhdl_name_t |
||

411 | |||

412 | and __1 () = pp_vhdl_type_t |
||

413 | |||

414 | and __0 () = pp_vhdl_name_t |
||

415 | in |
||

416 | ((let open! Ppx_deriving_runtime in |
||

417 | fun fmt -> |
||

418 | function |
||

419 | | Type { name = aname; definition = adefinition } -> |
||

420 | 3bc26d43 | Arnaud Dieumegard | Format.fprintf fmt "type "; |

421 | f779d524 | Arnaud Dieumegard | ((__0 ()) fmt) aname; |

422 | Format.fprintf fmt " is "; |
||

423 | ((__1 ()) fmt) adefinition; |
||

424 | 40364f53 | Arnaud Dieumegard | | Subtype { name = aname; typ = atyp } -> |

425 | 3bc26d43 | Arnaud Dieumegard | Format.fprintf fmt "subtype "; |

426 | f779d524 | Arnaud Dieumegard | ((__2 ()) fmt) aname; |

427 | Format.fprintf fmt " is "; |
||

428 | ((__3 ()) fmt) atyp; |
||

429 | ) |
||

430 | 40364f53 | Arnaud Dieumegard | [@ocaml.warning "-A"]) |

431 | |||

432 | and show_vhdl_definition_t : vhdl_definition_t -> Ppx_deriving_runtime.string |
||

433 | = fun x -> Format.asprintf "%a" pp_vhdl_definition_t x |
||

434 | |||

435 | 389493d3 | Arnaud Dieumegard | (* TODO adapt for Op, Time, Sig, suffixMod, Aggregate *) |

436 | 40364f53 | Arnaud Dieumegard | and pp_vhdl_expr_t : |

437 | Format.formatter -> vhdl_expr_t -> Ppx_deriving_runtime.unit = |
||

438 | ab6312e7 | Arnaud Dieumegard | let __8 () = pp_vhdl_element_assoc_t |

439 | 40364f53 | Arnaud Dieumegard | |

440 | ab6312e7 | Arnaud Dieumegard | and __7 () = pp_vhdl_suffix_selection_t |

441 | 40364f53 | Arnaud Dieumegard | |

442 | ab6312e7 | Arnaud Dieumegard | and __6 () = pp_vhdl_expr_t |

443 | 40364f53 | Arnaud Dieumegard | |

444 | ab6312e7 | Arnaud Dieumegard | and __5 () = pp_vhdl_signal_attributes_t |

445 | 40364f53 | Arnaud Dieumegard | |

446 | ab6312e7 | Arnaud Dieumegard | and __4 () = pp_vhdl_name_t |

447 | 40364f53 | Arnaud Dieumegard | |

448 | ab6312e7 | Arnaud Dieumegard | and __3 () = pp_vhdl_expr_t |

449 | |||

450 | and __2 () = pp_vhdl_name_t |
||

451 | 40364f53 | Arnaud Dieumegard | |

452 | and __1 () = pp_vhdl_cst_val_t |
||

453 | |||

454 | and __0 () = pp_vhdl_name_t |
||

455 | in |
||

456 | ((let open! Ppx_deriving_runtime in |
||

457 | fun fmt -> |
||

458 | function |
||

459 | | Call a0 -> |
||

460 | ((__0 ()) fmt) a0; |
||

461 | ab6312e7 | Arnaud Dieumegard | | Cst { value = avalue; unit_name = aunit_name } -> |

462 | ((__1 ()) fmt) avalue; |
||

463 | 1f15a1b9 | Arnaud Dieumegard | (function |

464 | ab6312e7 | Arnaud Dieumegard | | None -> Format.pp_print_string fmt "" |

465 | | Some x -> |
||

466 | 1f15a1b9 | Arnaud Dieumegard | Format.fprintf fmt " "; |

467 | ((__2 ()) fmt) x) aunit_name; |
||

468 | 40364f53 | Arnaud Dieumegard | | Op { id = aid; args = aargs } -> |

469 | f779d524 | Arnaud Dieumegard | (match aargs with |

470 | | [] -> (Format.fprintf fmt "%s") aid; |
||

471 | | hd::[] -> |
||

472 | (Format.fprintf fmt "%s") aid; |
||

473 | ab6312e7 | Arnaud Dieumegard | ((__3 ()) fmt) hd |

474 | f779d524 | Arnaud Dieumegard | | hd::(hd2::[]) -> |

475 | ab6312e7 | Arnaud Dieumegard | ((__3 ()) fmt) hd; |

476 | f779d524 | Arnaud Dieumegard | (Format.fprintf fmt " %s ") aid; |

477 | ab6312e7 | Arnaud Dieumegard | ((__3 ()) fmt) hd2 |

478 | f779d524 | Arnaud Dieumegard | | _ -> |

479 | 40364f53 | Arnaud Dieumegard | (Format.fprintf fmt "@[<2>Op {@,"; |

480 | ((Format.fprintf fmt "@[%s =@ " "id"; |
||

481 | (Format.fprintf fmt "%S") aid; |
||

482 | Format.fprintf fmt "@]"); |
||

483 | Format.fprintf fmt ";@ "; |
||

484 | Format.fprintf fmt "@[%s =@ " "args"; |
||

485 | ((fun x -> |
||

486 | Format.fprintf fmt "@[<2>["; |
||

487 | ignore |
||

488 | (List.fold_left |
||

489 | (fun sep -> |
||

490 | fun x -> |
||

491 | if sep then Format.fprintf fmt ";@ "; |
||

492 | ab6312e7 | Arnaud Dieumegard | ((__3 ()) fmt) x; |

493 | 40364f53 | Arnaud Dieumegard | true) false x); |

494 | Format.fprintf fmt "@,]@]")) aargs; |
||

495 | Format.fprintf fmt "@]"); |
||

496 | f779d524 | Arnaud Dieumegard | Format.fprintf fmt "@]}")) |

497 | | IsNull -> Format.pp_print_string fmt "" |
||

498 | 40364f53 | Arnaud Dieumegard | | Time { value = avalue; phy_unit = aphy_unit } -> |

499 | (Format.fprintf fmt "@[<2>Time {@,"; |
||

500 | ((Format.fprintf fmt "@[%s =@ " "value"; |
||

501 | (Format.fprintf fmt "%d") avalue; |
||

502 | Format.fprintf fmt "@]"); |
||

503 | Format.fprintf fmt ";@ "; |
||

504 | Format.fprintf fmt "@[%s =@ " "phy_unit"; |
||

505 | (Format.fprintf fmt "%S") aphy_unit; |
||

506 | Format.fprintf fmt "@]"); |
||

507 | Format.fprintf fmt "@]}") |
||

508 | | Sig { name = aname; att = aatt } -> |
||

509 | 389493d3 | Arnaud Dieumegard | (Format.fprintf fmt "--@[<2>Sig {@,"; |

510 | 40364f53 | Arnaud Dieumegard | ((Format.fprintf fmt "@[%s =@ " "name"; |

511 | ab6312e7 | Arnaud Dieumegard | ((__4 ()) fmt) aname; |

512 | 40364f53 | Arnaud Dieumegard | Format.fprintf fmt "@]"); |

513 | Format.fprintf fmt ";@ "; |
||

514 | Format.fprintf fmt "@[%s =@ " "att"; |
||

515 | ((function |
||

516 | | None -> Format.pp_print_string fmt "None" |
||

517 | | Some x -> |
||

518 | (Format.pp_print_string fmt "(Some "; |
||

519 | ab6312e7 | Arnaud Dieumegard | ((__5 ()) fmt) x; |

520 | 40364f53 | Arnaud Dieumegard | Format.pp_print_string fmt ")"))) aatt; |

521 | Format.fprintf fmt "@]"); |
||

522 | Format.fprintf fmt "@]}") |
||

523 | | SuffixMod { expr = aexpr; selection = aselection } -> |
||

524 | 389493d3 | Arnaud Dieumegard | (Format.fprintf fmt "--@[<2>SuffixMod {@,"; |

525 | 40364f53 | Arnaud Dieumegard | ((Format.fprintf fmt "@[%s =@ " "expr"; |

526 | ab6312e7 | Arnaud Dieumegard | ((__6 ()) fmt) aexpr; |

527 | 40364f53 | Arnaud Dieumegard | Format.fprintf fmt "@]"); |

528 | Format.fprintf fmt ";@ "; |
||

529 | Format.fprintf fmt "@[%s =@ " "selection"; |
||

530 | ab6312e7 | Arnaud Dieumegard | ((__7 ()) fmt) aselection; |

531 | 40364f53 | Arnaud Dieumegard | Format.fprintf fmt "@]"); |

532 | Format.fprintf fmt "@]}") |
||

533 | | Aggregate { elems = aelems } -> |
||

534 | eab3066b | Arnaud Dieumegard | (match aelems with |

535 | | [] -> Format.fprintf fmt ""; |
||

536 | | _ -> |
||

537 | (Format.fprintf fmt "(@["; |
||

538 | 40364f53 | Arnaud Dieumegard | ((fun x -> |

539 | ignore |
||

540 | (List.fold_left |
||

541 | (fun sep -> |
||

542 | fun x -> |
||

543 | eab3066b | Arnaud Dieumegard | if sep then Format.fprintf fmt ", "; |

544 | ab6312e7 | Arnaud Dieumegard | ((__8 ()) fmt) x; |

545 | eab3066b | Arnaud Dieumegard | true) false x))) aelems; |

546 | Format.fprintf fmt ")@]");) |
||

547 | f779d524 | Arnaud Dieumegard | | Others -> Format.pp_print_string fmt "others") |

548 | 40364f53 | Arnaud Dieumegard | [@ocaml.warning "-A"]) |

549 | |||

550 | and show_vhdl_expr_t : vhdl_expr_t -> Ppx_deriving_runtime.string = |
||

551 | fun x -> Format.asprintf "%a" pp_vhdl_expr_t x |
||

552 | |||

553 | and pp_vhdl_name_t : |
||

554 | Format.formatter -> vhdl_name_t -> Ppx_deriving_runtime.unit = |
||

555 | let __9 () = pp_vhdl_assoc_element_t |
||

556 | |||

557 | and __8 () = pp_vhdl_name_t |
||

558 | |||

559 | and __7 () = pp_vhdl_expr_t |
||

560 | |||

561 | and __6 () = pp_vhdl_name_t |
||

562 | |||

563 | and __5 () = pp_vhdl_name_t |
||

564 | |||

565 | and __4 () = pp_vhdl_discrete_range_t |
||

566 | |||

567 | and __3 () = pp_vhdl_name_t |
||

568 | |||

569 | and __2 () = pp_vhdl_expr_t |
||

570 | |||

571 | and __1 () = pp_vhdl_name_t |
||

572 | |||

573 | and __0 () = pp_vhdl_name_t |
||

574 | in |
||

575 | ((let open! Ppx_deriving_runtime in |
||

576 | fun fmt -> |
||

577 | function |
||

578 | | Simple a0 -> |
||

579 | f779d524 | Arnaud Dieumegard | (Format.fprintf fmt "%s") a0; |

580 | 40364f53 | Arnaud Dieumegard | | Identifier a0 -> |

581 | f779d524 | Arnaud Dieumegard | (Format.fprintf fmt "%s") a0; |

582 | 40364f53 | Arnaud Dieumegard | | Selected a0 -> |

583 | ((fun x -> |
||

584 | ignore |
||

585 | (List.fold_left |
||

586 | (fun sep -> |
||

587 | fun x -> |
||

588 | f779d524 | Arnaud Dieumegard | if sep then Format.fprintf fmt "."; |

589 | 40364f53 | Arnaud Dieumegard | ((__0 ()) fmt) x; |

590 | f779d524 | Arnaud Dieumegard | true) false x);) a0;) |

591 | 40364f53 | Arnaud Dieumegard | | Index { id = aid; exprs = aexprs } -> |

592 | f779d524 | Arnaud Dieumegard | ((__1 ()) fmt) aid; |

593 | Format.fprintf fmt "("; |
||

594 | (fun x -> |
||

595 | ignore |
||

596 | (List.fold_left |
||

597 | (fun sep -> |
||

598 | fun x -> |
||

599 | if sep then Format.fprintf fmt ",@ "; |
||

600 | ((__2 ()) fmt) x; |
||

601 | true |
||

602 | ) false x); |
||

603 | ) aexprs; |
||

604 | Format.fprintf fmt ")"; |
||

605 | 40364f53 | Arnaud Dieumegard | | Slice { id = aid; range = arange } -> |

606 | f779d524 | Arnaud Dieumegard | ((__3 ()) fmt) aid; |

607 | Format.fprintf fmt "("; |
||

608 | 40364f53 | Arnaud Dieumegard | ((__4 ()) fmt) arange; |

609 | f779d524 | Arnaud Dieumegard | Format.fprintf fmt ")"; |

610 | 40364f53 | Arnaud Dieumegard | | Attribute { id = aid; designator = adesignator; expr = aexpr } -> |

611 | f779d524 | Arnaud Dieumegard | ((__5 ()) fmt) aid; |

612 | Format.fprintf fmt "\'"; |
||

613 | ((__6 ()) fmt) adesignator; |
||

614 | (match aexpr with |
||

615 | | IsNull -> Format.fprintf fmt ""; |
||

616 | | _ -> |
||

617 | Format.fprintf fmt "("; |
||

618 | ((__7 ()) fmt) aexpr; |
||

619 | Format.fprintf fmt ")") |
||

620 | 40364f53 | Arnaud Dieumegard | | Function { id = aid; assoc_list = aassoc_list } -> |

621 | 00970bbf | Arnaud Dieumegard | (((__8 ()) fmt) aid; |

622 | Format.fprintf fmt "("; |
||

623 | ((fun x -> |
||

624 | Format.fprintf fmt "@["; |
||

625 | ignore |
||

626 | (List.fold_left |
||

627 | (fun sep -> |
||

628 | fun x -> |
||

629 | if sep then Format.fprintf fmt ";@ "; |
||

630 | ((__9 ()) fmt) x; |
||

631 | true) false x); |
||

632 | Format.fprintf fmt "@]")) aassoc_list; |
||

633 | Format.fprintf fmt ")";) |
||

634 | f779d524 | Arnaud Dieumegard | | NoName -> Format.pp_print_string fmt "") |

635 | 40364f53 | Arnaud Dieumegard | [@ocaml.warning "-A"]) |

636 | |||

637 | and show_vhdl_name_t : vhdl_name_t -> Ppx_deriving_runtime.string = |
||

638 | fun x -> Format.asprintf "%a" pp_vhdl_name_t x |
||

639 | |||

640 | and pp_vhdl_assoc_element_t : |
||

641 | Format.formatter -> vhdl_assoc_element_t -> Ppx_deriving_runtime.unit = |
||

642 | let __4 () = pp_vhdl_expr_t |
||

643 | |||

644 | and __3 () = pp_vhdl_name_t |
||

645 | |||

646 | and __2 () = pp_vhdl_name_t |
||

647 | |||

648 | and __1 () = pp_vhdl_name_t |
||

649 | |||

650 | and __0 () = pp_vhdl_name_t |
||

651 | in |
||

652 | ((let open! Ppx_deriving_runtime in |
||

653 | fun fmt -> |
||

654 | fun x -> |
||

655 | 00970bbf | Arnaud Dieumegard | (match x.formal_name with |

656 | | None -> Format.pp_print_string fmt "" |
||

657 | | Some NoName -> Format.pp_print_string fmt "" |
||

658 | | Some a -> |
||

659 | (((__0 ()) fmt) a; |
||

660 | (match x.formal_arg with |
||

661 | | None -> () |
||

662 | | Some b -> Format.fprintf fmt "("; |
||

663 | ((__1 ()) fmt) b; |
||

664 | Format.fprintf fmt ")"); |
||

665 | Format.fprintf fmt " => ")); |
||

666 | (match x.actual_name with |
||

667 | | None -> Format.pp_print_string fmt "" |
||

668 | | Some a -> |
||

669 | (((__2 ()) fmt) a; |
||

670 | (match x.actual_designator with |
||

671 | | None -> () |
||

672 | | Some NoName -> Format.pp_print_string fmt "" |
||

673 | | Some b -> (Format.fprintf fmt "("; |
||

674 | ((__3 ()) fmt) b; |
||

675 | Format.fprintf fmt ")")); |
||

676 | (match x.actual_expr with |
||

677 | | None -> () |
||

678 | | Some IsNull -> Format.pp_print_string fmt "" |
||

679 | | Some c -> (Format.fprintf fmt "("; |
||

680 | ((__4 ()) fmt) c; |
||

681 | Format.fprintf fmt ")"))));) |
||

682 | 40364f53 | Arnaud Dieumegard | [@ocaml.warning "-A"]) |

683 | |||

684 | and show_vhdl_assoc_element_t : |
||

685 | vhdl_assoc_element_t -> Ppx_deriving_runtime.string = |
||

686 | fun x -> Format.asprintf "%a" pp_vhdl_assoc_element_t x |
||

687 | |||

688 | and pp_vhdl_element_assoc_t : |
||

689 | Format.formatter -> vhdl_element_assoc_t -> Ppx_deriving_runtime.unit = |
||

690 | let __1 () = pp_vhdl_expr_t |
||

691 | |||

692 | and __0 () = pp_vhdl_expr_t |
||

693 | in |
||

694 | ((let open! Ppx_deriving_runtime in |
||

695 | fun fmt -> |
||

696 | fun x -> |
||

697 | 389493d3 | Arnaud Dieumegard | (match x.choices with |

698 | | [] -> Format.fprintf fmt ""; |
||

699 | | _ -> |
||

700 | (((fun x -> |
||

701 | 40364f53 | Arnaud Dieumegard | ignore |

702 | (List.fold_left |
||

703 | (fun sep -> |
||

704 | fun x -> |
||

705 | 389493d3 | Arnaud Dieumegard | if sep then Format.fprintf fmt "|@ "; |

706 | 40364f53 | Arnaud Dieumegard | ((__0 ()) fmt) x; |

707 | 389493d3 | Arnaud Dieumegard | true) false x))) x.choices; |

708 | Format.fprintf fmt " => ";)); |
||

709 | ((__1 ()) fmt) x.expr) |
||

710 | 40364f53 | Arnaud Dieumegard | [@ocaml.warning "-A"]) |

711 | |||

712 | and show_vhdl_element_assoc_t : |
||

713 | vhdl_element_assoc_t -> Ppx_deriving_runtime.string = |
||

714 | fun x -> Format.asprintf "%a" pp_vhdl_element_assoc_t x |
||

715 | |||

716 | 389493d3 | Arnaud Dieumegard | (* TODO *) |

717 | 40364f53 | Arnaud Dieumegard | and (pp_vhdl_array_attributes_t : |

718 | Format.formatter -> |
||

719 | vhdl_array_attributes_t -> Ppx_deriving_runtime.unit) |
||

720 | = |
||

721 | ((let open! Ppx_deriving_runtime in |
||

722 | fun fmt -> |
||

723 | function |
||

724 | | AAttInt { id = aid; arg = aarg } -> |
||

725 | (Format.fprintf fmt "@[<2>AAttInt {@,"; |
||

726 | ((Format.fprintf fmt "@[%s =@ " "id"; |
||

727 | (Format.fprintf fmt "%S") aid; |
||

728 | Format.fprintf fmt "@]"); |
||

729 | Format.fprintf fmt ";@ "; |
||

730 | Format.fprintf fmt "@[%s =@ " "arg"; |
||

731 | (Format.fprintf fmt "%d") aarg; |
||

732 | Format.fprintf fmt "@]"); |
||

733 | Format.fprintf fmt "@]}") |
||

734 | | AAttAscending -> Format.pp_print_string fmt "AAttAscending") |
||

735 | [@ocaml.warning "-A"]) |
||

736 | |||

737 | and show_vhdl_array_attributes_t : |
||

738 | vhdl_array_attributes_t -> Ppx_deriving_runtime.string = |
||

739 | fun x -> Format.asprintf "%a" pp_vhdl_array_attributes_t x |
||

740 | |||

741 | 389493d3 | Arnaud Dieumegard | (* TODO *) |

742 | 40364f53 | Arnaud Dieumegard | and (pp_vhdl_signal_attributes_t : |

743 | Format.formatter -> |
||

744 | vhdl_signal_attributes_t -> Ppx_deriving_runtime.unit) |
||

745 | = |
||

746 | ((let open! Ppx_deriving_runtime in |
||

747 | fun fmt -> |
||

748 | function |
||

749 | | SigAtt a0 -> |
||

750 | (Format.fprintf fmt "(@[<2>SigAtt@ "; |
||

751 | (Format.fprintf fmt "%S") a0; |
||

752 | Format.fprintf fmt "@])")) |
||

753 | [@ocaml.warning "-A"]) |
||

754 | |||

755 | and show_vhdl_signal_attributes_t : |
||

756 | vhdl_signal_attributes_t -> Ppx_deriving_runtime.string = |
||

757 | fun x -> Format.asprintf "%a" pp_vhdl_signal_attributes_t x |
||

758 | |||

759 | 389493d3 | Arnaud Dieumegard | (* TODO *) |

760 | 40364f53 | Arnaud Dieumegard | and (pp_vhdl_string_attributes_t : |

761 | Format.formatter -> |
||

762 | vhdl_string_attributes_t -> Ppx_deriving_runtime.unit) |
||

763 | = |
||

764 | ((let open! Ppx_deriving_runtime in |
||

765 | fun fmt -> |
||

766 | function |
||

767 | | StringAtt a0 -> |
||

768 | (Format.fprintf fmt "(@[<2>StringAtt@ "; |
||

769 | (Format.fprintf fmt "%S") a0; |
||

770 | Format.fprintf fmt "@])")) |
||

771 | [@ocaml.warning "-A"]) |
||

772 | |||

773 | and show_vhdl_string_attributes_t : |
||

774 | vhdl_string_attributes_t -> Ppx_deriving_runtime.string = |
||

775 | fun x -> Format.asprintf "%a" pp_vhdl_string_attributes_t x |
||

776 | |||

777 | 389493d3 | Arnaud Dieumegard | (* TODO *) |

778 | 40364f53 | Arnaud Dieumegard | and (pp_vhdl_suffix_selection_t : |

779 | Format.formatter -> |
||

780 | vhdl_suffix_selection_t -> Ppx_deriving_runtime.unit) |
||

781 | = |
||

782 | ((let open! Ppx_deriving_runtime in |
||

783 | fun fmt -> |
||

784 | function |
||

785 | | Idx a0 -> |
||

786 | (Format.fprintf fmt "(@[<2>Idx@ "; |
||

787 | (Format.fprintf fmt "%d") a0; |
||

788 | Format.fprintf fmt "@])") |
||

789 | | SuffixRange (a0,a1) -> |
||

790 | (Format.fprintf fmt "(@[<2>SuffixRange (@,"; |
||

791 | ((Format.fprintf fmt "%d") a0; |
||

792 | Format.fprintf fmt ",@ "; |
||

793 | (Format.fprintf fmt "%d") a1); |
||

794 | Format.fprintf fmt "@,))@]")) |
||

795 | [@ocaml.warning "-A"]) |
||

796 | |||

797 | and show_vhdl_suffix_selection_t : |
||

798 | vhdl_suffix_selection_t -> Ppx_deriving_runtime.string = |
||

799 | fun x -> Format.asprintf "%a" pp_vhdl_suffix_selection_t x |
||

800 | |||

801 | let rec (vhdl_type_t_to_yojson : vhdl_type_t -> Yojson.Safe.json) = |
||

802 | ((let open! Ppx_deriving_yojson_runtime in |
||

803 | function |
||

804 | | Base arg0 -> |
||

805 | `List |
||

806 | [`String "Base"; |
||

807 | ((fun (x : Ppx_deriving_runtime.string) -> `String x)) arg0] |
||

808 | | Range (arg0,arg1,arg2) -> |
||

809 | `List |
||

810 | [`String "Range"; |
||

811 | ((function |
||

812 | | None -> `Null |
||

813 | | Some x -> |
||

814 | ((fun (x : Ppx_deriving_runtime.string) -> `String x)) x)) |
||

815 | arg0; |
||

816 | ((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg1; |
||

817 | ((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg2] |
||

818 | | Bit_vector (arg0,arg1) -> |
||

819 | `List |
||

820 | [`String "Bit_vector"; |
||

821 | ((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg0; |
||

822 | ((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg1] |
||

823 | 248eb65e | Arnaud Dieumegard | | Array arg0 -> |

824 | 40364f53 | Arnaud Dieumegard | `List |

825 | 248eb65e | Arnaud Dieumegard | [`String "ARRAY_TYPE_DEFINITION"; |

826 | (let fields = [] in |
||

827 | let fields = |
||

828 | ("definition", |
||

829 | ((fun x -> vhdl_subtype_indication_t_to_yojson x) |
||

830 | arg0.definition)) |
||

831 | :: fields in |
||

832 | let fields = |
||

833 | if arg0.const = None |
||

834 | then fields |
||

835 | else |
||

836 | ("const", |
||

837 | (((function |
||

838 | | None -> `Null |
||

839 | | Some x -> |
||

840 | ((fun x -> vhdl_constraint_t_to_yojson x)) x)) |
||

841 | arg0.const)) |
||

842 | :: fields |
||

843 | in |
||

844 | let fields = |
||

845 | ec031ed0 | Arnaud Dieumegard | if arg0.indexes = [] |

846 | then fields |
||

847 | else |
||

848 | ("indexes", |
||

849 | (((fun x -> |
||

850 | `List |
||

851 | (List.map (fun x -> vhdl_name_t_to_yojson x) x))) |
||

852 | arg0.indexes)) |
||

853 | :: fields |
||

854 | in |
||

855 | 248eb65e | Arnaud Dieumegard | `Assoc fields)] |

856 | | Record arg0 -> |
||

857 | 40364f53 | Arnaud Dieumegard | `List |

858 | 248eb65e | Arnaud Dieumegard | [`String "RECORD_TYPE_DEFINITION"; |

859 | 40364f53 | Arnaud Dieumegard | ((fun x -> |

860 | `List |
||

861 | (List.map |
||

862 | 248eb65e | Arnaud Dieumegard | (fun x -> vhdl_element_declaration_t_to_yojson x) x))) |

863 | 40364f53 | Arnaud Dieumegard | arg0] |

864 | 248eb65e | Arnaud Dieumegard | | Enumerated arg0 -> |

865 | `List |
||

866 | [`String "ENUMERATION_TYPE_DEFINITION"; |
||

867 | ((fun x -> |
||

868 | `List (List.map (fun x -> vhdl_name_t_to_yojson x) x))) arg0] |
||

869 | 40364f53 | Arnaud Dieumegard | | Void -> `List [`String "Void"]) |

870 | [@ocaml.warning "-A"]) |
||

871 | |||

872 | and (vhdl_type_t_of_yojson : |
||

873 | Yojson.Safe.json -> vhdl_type_t Ppx_deriving_yojson_runtime.error_or) |
||

874 | = |
||

875 | ((let open! Ppx_deriving_yojson_runtime in |
||

876 | function |
||

877 | | `List ((`String "Base")::arg0::[]) -> |
||

878 | ((function |
||

879 | | `String x -> Result.Ok x |
||

880 | | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>= |
||

881 | ((fun arg0 -> Result.Ok (Base arg0))) |
||

882 | | `List ((`String "Range")::arg0::arg1::arg2::[]) -> |
||

883 | ((function |
||

884 | | `Int x -> Result.Ok x |
||

885 | | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg2) >>= |
||

886 | ((fun arg2 -> |
||

887 | ((function |
||

888 | | `Int x -> Result.Ok x |
||

889 | | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg1) >>= |
||

890 | (fun arg1 -> |
||

891 | ((function |
||

892 | | `Null -> Result.Ok None |
||

893 | | x -> |
||

894 | ((function |
||

895 | | `String x -> Result.Ok x |
||

896 | | _ -> Result.Error "Vhdl_ast.vhdl_type_t") x) |
||

897 | >>= ((fun x -> Result.Ok (Some x)))) arg0) |
||

898 | >>= |
||

899 | (fun arg0 -> Result.Ok (Range (arg0, arg1, arg2)))))) |
||

900 | | `List ((`String "Bit_vector")::arg0::arg1::[]) -> |
||

901 | ((function |
||

902 | | `Int x -> Result.Ok x |
||

903 | | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg1) >>= |
||

904 | ((fun arg1 -> |
||

905 | ((function |
||

906 | | `Int x -> Result.Ok x |
||

907 | | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>= |
||

908 | (fun arg0 -> Result.Ok (Bit_vector (arg0, arg1))))) |
||

909 | 248eb65e | Arnaud Dieumegard | | `List ((`String "ARRAY_TYPE_DEFINITION")::arg0::[]) -> |

910 | ((function |
||

911 | | `Assoc xs -> |
||

912 | let rec loop xs ((arg0,arg1,arg2) as _state) = |
||

913 | match xs with |
||

914 | | ("indexes",x)::xs -> |
||

915 | loop xs |
||

916 | (((function |
||

917 | | `List xs -> |
||

918 | map_bind (fun x -> vhdl_name_t_of_yojson x) |
||

919 | [] xs |
||

920 | | _ -> Result.Error "Vhdl_ast.vhdl_type_t.indexes") |
||

921 | x), arg1, arg2) |
||

922 | | ("const",x)::xs -> |
||

923 | loop xs |
||

924 | (arg0, |
||

925 | ((function |
||

926 | | `Null -> Result.Ok None |
||

927 | | x -> |
||

928 | ((fun x -> vhdl_constraint_t_of_yojson x) x) |
||

929 | >>= ((fun x -> Result.Ok (Some x)))) x), |
||

930 | arg2) |
||

931 | | ("definition",x)::xs -> |
||

932 | loop xs |
||

933 | (arg0, arg1, |
||

934 | ((fun x -> vhdl_subtype_indication_t_of_yojson x) |
||

935 | x)) |
||

936 | | [] -> |
||

937 | arg2 >>= |
||

938 | ((fun arg2 -> |
||

939 | arg1 >>= |
||

940 | (fun arg1 -> |
||

941 | arg0 >>= |
||

942 | (fun arg0 -> |
||

943 | Result.Ok |
||

944 | (Array |
||

945 | { |
||

946 | indexes = arg0; |
||

947 | const = arg1; |
||

948 | definition = arg2 |
||

949 | }))))) |
||

950 | | _::xs -> loop xs _state in |
||

951 | loop xs |
||

952 | ec031ed0 | Arnaud Dieumegard | ((Result.Ok []), (Result.Ok None), |

953 | 248eb65e | Arnaud Dieumegard | (Result.Error "Vhdl_ast.vhdl_type_t.definition")) |

954 | | _ -> Result.Error "Vhdl_ast.vhdl_type_t")) arg0 |
||

955 | | `List ((`String "RECORD_TYPE_DEFINITION")::arg0::[]) -> |
||

956 | 40364f53 | Arnaud Dieumegard | ((function |

957 | | `List xs -> |
||

958 | 248eb65e | Arnaud Dieumegard | map_bind (fun x -> vhdl_element_declaration_t_of_yojson x) |

959 | [] xs |
||

960 | | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>= |
||

961 | ((fun arg0 -> Result.Ok (Record arg0))) |
||

962 | | `List ((`String "ENUMERATION_TYPE_DEFINITION")::arg0::[]) -> |
||

963 | ((function |
||

964 | | `List xs -> map_bind (fun x -> vhdl_name_t_of_yojson x) [] xs |
||

965 | 40364f53 | Arnaud Dieumegard | | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>= |

966 | ((fun arg0 -> Result.Ok (Enumerated arg0))) |
||

967 | | `List ((`String "Void")::[]) -> Result.Ok Void |
||

968 | | _ -> Result.Error "Vhdl_ast.vhdl_type_t") |
||

969 | [@ocaml.warning "-A"]) |
||

970 | |||

971 | 248eb65e | Arnaud Dieumegard | and (vhdl_element_declaration_t_to_yojson : |

972 | vhdl_element_declaration_t -> Yojson.Safe.json) |
||

973 | = |
||

974 | ((let open! Ppx_deriving_yojson_runtime in |
||

975 | fun x -> |
||

976 | let fields = [] in |
||

977 | let fields = |
||

978 | ("definition", |
||

979 | ((fun x -> vhdl_subtype_indication_t_to_yojson x) x.definition)) |
||

980 | :: fields in |
||

981 | let fields = |
||

982 | ("names", |
||

983 | ((fun x -> |
||

984 | `List (List.map (fun x -> vhdl_name_t_to_yojson x) x)) |
||

985 | x.names)) |
||

986 | :: fields in |
||

987 | `Assoc fields) |
||

988 | [@ocaml.warning "-A"]) |
||

989 | |||

990 | and (vhdl_element_declaration_t_of_yojson : |
||

991 | Yojson.Safe.json -> |
||

992 | vhdl_element_declaration_t Ppx_deriving_yojson_runtime.error_or) |
||

993 | = |
||

994 | ((let open! Ppx_deriving_yojson_runtime in |
||

995 | function |
||

996 | | `Assoc xs -> |
||

997 | let rec loop xs ((arg0,arg1) as _state) = |
||

998 | match xs with |
||

999 | | ("names",x)::xs -> |
||

1000 | loop xs |
||

1001 | (((function |
||

1002 | | `List xs -> |
||

1003 | map_bind (fun x -> vhdl_name_t_of_yojson x) [] xs |
||

1004 | | _ -> |
||

1005 | Result.Error |
||

1006 | "Vhdl_ast.vhdl_element_declaration_t.names") x), |
||

1007 | arg1) |
||

1008 | | ("definition",x)::xs -> |
||

1009 | loop xs |
||

1010 | (arg0, |
||

1011 | ((fun x -> vhdl_subtype_indication_t_of_yojson x) x)) |
||

1012 | | [] -> |
||

1013 | arg1 >>= |
||

1014 | ((fun arg1 -> |
||

1015 | arg0 >>= |
||

1016 | (fun arg0 -> |
||

1017 | Result.Ok { names = arg0; definition = arg1 }))) |
||

1018 | | _::xs -> loop xs _state in |
||

1019 | loop xs |
||

1020 | ((Result.Error "Vhdl_ast.vhdl_element_declaration_t.names"), |
||

1021 | (Result.Error "Vhdl_ast.vhdl_element_declaration_t.definition")) |
||

1022 | | _ -> Result.Error "Vhdl_ast.vhdl_element_declaration_t") |
||

1023 | [@ocaml.warning "-A"]) |
||

1024 | |||

1025 | 40364f53 | Arnaud Dieumegard | and (vhdl_subtype_indication_t_to_yojson : |

1026 | vhdl_subtype_indication_t -> Yojson.Safe.json) |
||

1027 | = |
||

1028 | ((let open! Ppx_deriving_yojson_runtime in |
||

1029 | fun x -> |
||

1030 | let fields = [] in |
||

1031 | let fields = |
||

1032 | if x.const = NoConstraint |
||

1033 | then fields |
||

1034 | else |
||

1035 | ("const", (((fun x -> vhdl_constraint_t_to_yojson x)) x.const)) |
||

1036 | :: fields |
||

1037 | in |
||

1038 | let fields = |
||

1039 | if x.functionName = NoName |
||

1040 | then fields |
||

1041 | else |
||

1042 | ("functionName", |
||

1043 | (((fun x -> vhdl_name_t_to_yojson x)) x.functionName)) |
||

1044 | :: fields |
||

1045 | in |
||

1046 | let fields = |
||

1047 | if x.name = NoName |
||

1048 | then fields |
||

1049 | else ("name", (((fun x -> vhdl_name_t_to_yojson x)) x.name)) :: |
||

1050 | fields |
||

1051 | in |
||

1052 | `Assoc fields) |
||

1053 | [@ocaml.warning "-A"]) |
||

1054 | |||

1055 | and (vhdl_subtype_indication_t_of_yojson : |
||

1056 | Yojson.Safe.json -> |
||

1057 | vhdl_subtype_indication_t Ppx_deriving_yojson_runtime.error_or) |
||

1058 | = |
||

1059 | ((let open! Ppx_deriving_yojson_runtime in |
||

1060 | function |
||

1061 | | `Assoc xs -> |
||

1062 | let rec loop xs ((arg0,arg1,arg2) as _state) = |
||

1063 | match xs with |
||

1064 | | ("name",x)::xs -> |
||

1065 | loop xs (((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2) |
||

1066 | | ("functionName",x)::xs -> |
||

1067 | loop xs (arg0, ((fun x -> vhdl_name_t_of_yojson x) x), arg2) |
||

1068 | | ("const",x)::xs -> |
||

1069 | loop xs |
||

1070 | (arg0, arg1, ((fun x -> vhdl_constraint_t_of_yojson x) x)) |
||

1071 | | [] -> |
||

1072 | arg2 >>= |
||

1073 | ((fun arg2 -> |
||

1074 | arg1 >>= |
||

1075 | (fun arg1 -> |
||

1076 | arg0 >>= |
||

1077 | (fun arg0 -> |
||

1078 | Result.Ok |
||

1079 | { |
||

1080 | name = arg0; |
||

1081 | functionName = arg1; |
||

1082 | const = arg2 |
||

1083 | })))) |
||

1084 | | _::xs -> loop xs _state in |
||

1085 | loop xs |
||

1086 | ((Result.Ok NoName), (Result.Ok NoName), |
||

1087 | (Result.Ok NoConstraint)) |
||

1088 | | _ -> Result.Error "Vhdl_ast.vhdl_subtype_indication_t") |
||

1089 | [@ocaml.warning "-A"]) |
||

1090 | |||

1091 | and (vhdl_discrete_range_t_to_yojson : |
||

1092 | vhdl_discrete_range_t -> Yojson.Safe.json) |
||

1093 | = |
||

1094 | ((let open! Ppx_deriving_yojson_runtime in |
||

1095 | function |
||

1096 | | SubDiscreteRange arg0 -> |
||

1097 | `List |
||

1098 | [`String "SUB_DISCRETE_RANGE"; |
||

1099 | ((fun x -> vhdl_subtype_indication_t_to_yojson x)) arg0] |
||

1100 | | NamedRange arg0 -> |
||

1101 | `List |
||

1102 | [`String "NAMED_RANGE"; |
||

1103 | ((fun x -> vhdl_name_t_to_yojson x)) arg0] |
||

1104 | | DirectedRange arg0 -> |
||

1105 | `List |
||

1106 | [`String "RANGE_WITH_DIRECTION"; |
||

1107 | (let fields = [] in |
||

1108 | let fields = |
||

1109 | ("_to", ((fun x -> vhdl_expr_t_to_yojson x) arg0._to)) :: |
||

1110 | fields in |
||

1111 | let fields = |
||

1112 | ("from", ((fun x -> vhdl_expr_t_to_yojson x) arg0.from)) :: |
||

1113 | fields in |
||

1114 | let fields = |
||

1115 | ("direction", |
||

1116 | ((fun (x : Ppx_deriving_runtime.string) -> `String x) |
||

1117 | arg0.direction)) |
||

1118 | :: fields in |
||

1119 | `Assoc fields)]) |
||

1120 | [@ocaml.warning "-A"]) |
||

1121 | |||

1122 | and (vhdl_discrete_range_t_of_yojson : |
||

1123 | Yojson.Safe.json -> |
||

1124 | vhdl_discrete_range_t Ppx_deriving_yojson_runtime.error_or) |
||

1125 | = |
||

1126 | ((let open! Ppx_deriving_yojson_runtime in |
||

1127 | function |
||

1128 | | `List ((`String "SUB_DISCRETE_RANGE")::arg0::[]) -> |
||

1129 | ((fun x -> vhdl_subtype_indication_t_of_yojson x) arg0) >>= |
||

1130 | ((fun arg0 -> Result.Ok (SubDiscreteRange arg0))) |
||

1131 | | `List ((`String "NAMED_RANGE")::arg0::[]) -> |
||

1132 | ((fun x -> vhdl_name_t_of_yojson x) arg0) >>= |
||

1133 | ((fun arg0 -> Result.Ok (NamedRange arg0))) |
||

1134 | | `List ((`String "RANGE_WITH_DIRECTION")::arg0::[]) -> |
||

1135 | ((function |
||

1136 | | `Assoc xs -> |
||

1137 | let rec loop xs ((arg0,arg1,arg2) as _state) = |
||

1138 | match xs with |
||

1139 | | ("direction",x)::xs -> |
||

1140 | loop xs |
||

1141 | (((function |
||

1142 | | `String x -> Result.Ok x |
||

1143 | | _ -> |
||

1144 | Result.Error |
||

1145 | "Vhdl_ast.vhdl_discrete_range_t.direction") |
||

1146 | x), arg1, arg2) |
||

1147 | | ("from",x)::xs -> |
||

1148 | loop xs |
||

1149 | (arg0, ((fun x -> vhdl_expr_t_of_yojson x) x), arg2) |
||

1150 | | ("_to",x)::xs -> |
||

1151 | loop xs |
||

1152 | (arg0, arg1, ((fun x -> vhdl_expr_t_of_yojson x) x)) |
||

1153 | | [] -> |
||

1154 | arg2 >>= |
||

1155 | ((fun arg2 -> |
||

1156 | arg1 >>= |
||

1157 | (fun arg1 -> |
||

1158 | arg0 >>= |
||

1159 | (fun arg0 -> |
||

1160 | Result.Ok |
||

1161 | (DirectedRange |
||

1162 | { |
||

1163 | direction = arg0; |
||

1164 | from = arg1; |
||

1165 | _to = arg2 |
||

1166 | }))))) |
||

1167 | | _::xs -> loop xs _state in |
||

1168 | loop xs |
||

1169 | ((Result.Error "Vhdl_ast.vhdl_discrete_range_t.direction"), |
||

1170 | (Result.Error "Vhdl_ast.vhdl_discrete_range_t.from"), |
||

1171 | (Result.Error "Vhdl_ast.vhdl_discrete_range_t._to")) |
||

1172 | | _ -> Result.Error "Vhdl_ast.vhdl_discrete_range_t")) arg0 |
||

1173 | | _ -> Result.Error "Vhdl_ast.vhdl_discrete_range_t") |
||

1174 | [@ocaml.warning "-A"]) |
||

1175 | |||

1176 | and (vhdl_constraint_t_to_yojson : vhdl_constraint_t -> Yojson.Safe.json) = |
||

1177 | ((let open! Ppx_deriving_yojson_runtime in |
||

1178 | function |
||

1179 | | RefConstraint arg0 -> |
||

1180 | `List |
||

1181 | [`String "RefConstraint"; |
||

1182 | (let fields = [] in |
||

1183 | let fields = |
||

1184 | ("ref_name", |
||

1185 | ((fun x -> vhdl_name_t_to_yojson x) arg0.ref_name)) |
||

1186 | :: fields in |
||

1187 | `Assoc fields)] |
||

1188 | | RangeConstraint arg0 -> |
||

1189 | `List |
||

1190 | [`String "RANGE_CONSTRAINT"; |
||

1191 | (let fields = [] in |
||

1192 | let fields = |
||

1193 | ("range", |
||

1194 | ((fun x -> vhdl_discrete_range_t_to_yojson x) arg0.range)) |
||

1195 | :: fields in |
||

1196 | `Assoc fields)] |
||

1197 | | IndexConstraint arg0 -> |
||

1198 | `List |
||

1199 | [`String "INDEX_CONSTRAINT"; |
||

1200 | (let fields = [] in |
||

1201 | let fields = |
||

1202 | ("ranges", |
||

1203 | ((fun x -> |
||

1204 | `List |
||

1205 | (List.map |
||

1206 | (fun x -> vhdl_discrete_range_t_to_yojson x) x)) |
||

1207 | arg0.ranges)) |
||

1208 | :: fields in |
||

1209 | `Assoc fields)] |
||

1210 | | ArrayConstraint arg0 -> |
||

1211 | `List |
||

1212 | [`String "ARRAY_CONSTRAINT"; |
||

1213 | (let fields = [] in |
||

1214 | let fields = |
||

1215 | ("sub", ((fun x -> vhdl_constraint_t_to_yojson x) arg0.sub)) |
||

1216 | :: fields in |
||

1217 | let fields = |
||

1218 | ("ranges", |
||

1219 | ((fun x -> |
||

1220 | `List |
||

1221 | (List.map |
||

1222 | (fun x -> vhdl_discrete_range_t_to_yojson x) x)) |
||

1223 | arg0.ranges)) |
||

1224 | :: fields in |
||

1225 | `Assoc fields)] |
||

1226 | | RecordConstraint -> `List [`String "RecordConstraint"] |
||

1227 | | NoConstraint -> `List [`String "NoConstraint"]) |
||

1228 | [@ocaml.warning "-A"]) |
||

1229 | |||

1230 | and (vhdl_constraint_t_of_yojson : |
||

1231 | Yojson.Safe.json -> |
||

1232 | vhdl_constraint_t Ppx_deriving_yojson_runtime.error_or) |
||

1233 | = |
||

1234 | ((let open! Ppx_deriving_yojson_runtime in |
||

1235 | function |
||

1236 | | `List ((`String "RefConstraint")::arg0::[]) -> |
||

1237 | ((function |
||

1238 | | `Assoc xs -> |
||

1239 | let rec loop xs (arg0 as _state) = |
||

1240 | match xs with |
||

1241 | | ("ref_name",x)::xs -> |
||

1242 | loop xs ((fun x -> vhdl_name_t_of_yojson x) x) |
||

1243 | | [] -> |
||

1244 | arg0 >>= |
||

1245 | ((fun arg0 -> |
||

1246 | Result.Ok (RefConstraint { ref_name = arg0 }))) |
||

1247 | | _::xs -> loop xs _state in |
||

1248 | loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.ref_name") |
||

1249 | | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0 |
||

1250 | | `List ((`String "RANGE_CONSTRAINT")::arg0::[]) -> |
||

1251 | ((function |
||

1252 | | `Assoc xs -> |
||

1253 | let rec loop xs (arg0 as _state) = |
||

1254 | match xs with |
||

1255 | | ("range",x)::xs -> |
||

1256 | loop xs |
||

1257 | ((fun x -> vhdl_discrete_range_t_of_yojson x) x) |
||

1258 | | [] -> |
||

1259 | arg0 >>= |
||

1260 | ((fun arg0 -> |
||

1261 | Result.Ok (RangeConstraint { range = arg0 }))) |
||

1262 | | _::xs -> loop xs _state in |
||

1263 | loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.range") |
||

1264 | | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0 |
||

1265 | | `List ((`String "INDEX_CONSTRAINT")::arg0::[]) -> |
||

1266 | ((function |
||

1267 | | `Assoc xs -> |
||

1268 | let rec loop xs (arg0 as _state) = |
||

1269 | match xs with |
||

1270 | | ("ranges",x)::xs -> |
||

1271 | loop xs |
||

1272 | ((function |
||

1273 | | `List xs -> |
||

1274 | map_bind |
||

1275 | (fun x -> vhdl_discrete_range_t_of_yojson x) |
||

1276 | [] xs |
||

1277 | | _ -> |
||

1278 | Result.Error |
||

1279 | "Vhdl_ast.vhdl_constraint_t.ranges") x) |
||

1280 | | [] -> |
||

1281 | arg0 >>= |
||

1282 | ((fun arg0 -> |
||

1283 | Result.Ok (IndexConstraint { ranges = arg0 }))) |
||

1284 | | _::xs -> loop xs _state in |
||

1285 | loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.ranges") |
||

1286 | | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0 |
||

1287 | | `List ((`String "ARRAY_CONSTRAINT")::arg0::[]) -> |
||

1288 | ((function |
||

1289 | | `Assoc xs -> |
||

1290 | let rec loop xs ((arg0,arg1) as _state) = |
||

1291 | match xs with |
||

1292 | | ("ranges",x)::xs -> |
||

1293 | loop xs |
||

1294 | (((function |
||

1295 | | `List xs -> |
||

1296 | map_bind |
||

1297 | (fun x -> vhdl_discrete_range_t_of_yojson x) |
||

1298 | [] xs |
||

1299 | | _ -> |
||

1300 | Result.Error |
||

1301 | "Vhdl_ast.vhdl_constraint_t.ranges") x), |
||

1302 | arg1) |
||

1303 | | ("sub",x)::xs -> |
||

1304 | loop xs |
||

1305 | (arg0, ((fun x -> vhdl_constraint_t_of_yojson x) x)) |
||

1306 | | [] -> |
||

1307 | arg1 >>= |
||

1308 | ((fun arg1 -> |
||

1309 | arg0 >>= |
||

1310 | (fun arg0 -> |
||

1311 | Result.Ok |
||

1312 | (ArrayConstraint |
||

1313 | { ranges = arg0; sub = arg1 })))) |
||

1314 | | _::xs -> loop xs _state in |
||

1315 | loop xs |
||

1316 | ((Result.Error "Vhdl_ast.vhdl_constraint_t.ranges"), |
||

1317 | (Result.Error "Vhdl_ast.vhdl_constraint_t.sub")) |
||

1318 | | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0 |
||

1319 | | `List ((`String "RecordConstraint")::[]) -> |
||

1320 | Result.Ok RecordConstraint |
||

1321 | | `List ((`String "NoConstraint")::[]) -> Result.Ok NoConstraint |
||

1322 | | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t") |
||

1323 | [@ocaml.warning "-A"]) |
||

1324 | |||

1325 | and (vhdl_definition_t_to_yojson : vhdl_definition_t -> Yojson.Safe.json) = |
||

1326 | ((let open! Ppx_deriving_yojson_runtime in |
||

1327 | function |
||

1328 | | Type arg0 -> |
||

1329 | `List |
||

1330 | [`String "TYPE_DECLARATION"; |
||

1331 | (let fields = [] in |
||

1332 | let fields = |
||

1333 | ("definition", |
||

1334 | ((fun x -> vhdl_type_t_to_yojson x) arg0.definition)) |
||

1335 | :: fields in |
||

1336 | let fields = |
||

1337 | ("name", ((fun x -> vhdl_name_t_to_yojson x) arg0.name)) :: |
||

1338 | fields in |
||

1339 | `Assoc fields)] |
||

1340 | | Subtype arg0 -> |
||

1341 | `List |
||

1342 | [`String "SUBTYPE_DECLARATION"; |
||

1343 | (let fields = [] in |
||

1344 | let fields = |
||

1345 | ("typ", |
||

1346 | ((fun x -> vhdl_subtype_indication_t_to_yojson x) arg0.typ)) |
||

1347 | :: fields in |
||

1348 | let fields = |
||

1349 | ("name", ((fun x -> vhdl_name_t_to_yojson x) arg0.name)) :: |
||

1350 | fields in |
||

1351 | `Assoc fields)]) |
||

1352 | [@ocaml.warning "-A"]) |
||

1353 | |||

1354 | and (vhdl_definition_t_of_yojson : |
||

1355 | Yojson.Safe.json -> |
||

1356 | vhdl_definition_t Ppx_deriving_yojson_runtime.error_or) |
||

1357 | = |
||

1358 | ((let open! Ppx_deriving_yojson_runtime in |
||

1359 | function |
||

1360 | | `List ((`String "TYPE_DECLARATION")::arg0::[]) -> |
||

1361 | ((function |
||

1362 | | `Assoc xs -> |
||

1363 | let rec loop xs ((arg0,arg1) as _state) = |
||

1364 | match xs with |
||

1365 | | ("name",x)::xs -> |
||

1366 | loop xs (((fun x -> vhdl_name_t_of_yojson x) x), arg1) |
||

1367 | | ("definition",x)::xs -> |
||

1368 | loop xs (arg0, ((fun x -> vhdl_type_t_of_yojson x) x)) |
||

1369 | | [] -> |
||

1370 | arg1 >>= |
||

1371 | ((fun arg1 -> |
||

1372 | arg0 >>= |
||

1373 | (fun arg0 -> |
||

1374 | Result.Ok |
||

1375 | (Type { name = arg0; definition = arg1 })))) |
||

1376 | | _::xs -> loop xs _state in |
||

1377 | loop xs |
||

1378 | ((Result.Error "Vhdl_ast.vhdl_definition_t.name"), |
||

1379 | (Result.Error "Vhdl_ast.vhdl_definition_t.definition")) |
||

1380 | | _ -> Result.Error "Vhdl_ast.vhdl_definition_t")) arg0 |
||

1381 | | `List ((`String "SUBTYPE_DECLARATION")::arg0::[]) -> |
||

1382 | ((function |
||

1383 | | `Assoc xs -> |
||

1384 | let rec loop xs ((arg0,arg1) as _state) = |
||

1385 | match xs with |
||

1386 | | ("name",x)::xs -> |
||

1387 | loop xs (((fun x -> vhdl_name_t_of_yojson x) x), arg1) |
||

1388 | | ("typ",x)::xs -> |
||

1389 | loop xs |
||

1390 | (arg0, |
||

1391 | ((fun x -> vhdl_subtype_indication_t_of_yojson x) |
||

1392 | x)) |
||

1393 | | [] -> |
||

1394 | arg1 >>= |
||

1395 | ((fun arg1 -> |
||

1396 | arg0 >>= |
||

1397 | (fun arg0 -> |
||

1398 | Result.Ok |
||

1399 | (Subtype { name = arg0; typ = arg1 })))) |
||

1400 | | _::xs -> loop xs _state in |
||

1401 | loop xs |
||

1402 | ((Result.Error "Vhdl_ast.vhdl_definition_t.name"), |
||

1403 | (Result.Error "Vhdl_ast.vhdl_definition_t.typ")) |
||

1404 | | _ -> Result.Error "Vhdl_ast.vhdl_definition_t")) arg0 |
||

1405 | | _ -> Result.Error "Vhdl_ast.vhdl_definition_t") |
||

1406 | [@ocaml.warning "-A"]) |
||

1407 | |||

1408 | and (vhdl_expr_t_to_yojson : vhdl_expr_t -> Yojson.Safe.json) = |
||

1409 | ((let open! Ppx_deriving_yojson_runtime in |
||

1410 | function |
||

1411 | | Call arg0 -> |
||

1412 | `List [`String "CALL"; ((fun x -> vhdl_name_t_to_yojson x)) arg0] |
||

1413 | | Cst arg0 -> |
||

1414 | `List |
||

1415 | [`String "CONSTANT_VALUE"; |
||

1416 | ab6312e7 | Arnaud Dieumegard | (let fields = [] in |

1417 | let fields = |
||

1418 | if arg0.unit_name = None |
||

1419 | then fields |
||

1420 | else |
||

1421 | ("unit_name", |
||

1422 | (((function |
||

1423 | | None -> `Null |
||

1424 | | Some x -> ((fun x -> vhdl_name_t_to_yojson x)) x)) |
||

1425 | arg0.unit_name)) |
||

1426 | :: fields |
||

1427 | in |
||

1428 | let fields = |
||

1429 | ("value", ((fun x -> vhdl_cst_val_t_to_yojson x) arg0.value)) |
||

1430 | :: fields in |
||

1431 | `Assoc fields)] |
||

1432 | 40364f53 | Arnaud Dieumegard | | Op arg0 -> |

1433 | `List |
||

1434 | [`String "EXPRESSION"; |
||

1435 | (let fields = [] in |
||

1436 | let fields = |
||

1437 | if arg0.args = [] |
||

1438 | then fields |
||

1439 | else |
||

1440 | ("args", |
||

1441 | (((fun x -> |
||

1442 | `List |
||

1443 | (List.map (fun x -> vhdl_expr_t_to_yojson x) x))) |
||

1444 | arg0.args)) |
||

1445 | :: fields |
||

1446 | in |
||

1447 | let fields = |
||

1448 | if arg0.id = "" |
||

1449 | then fields |
||

1450 | else |
||

1451 | ("id", |
||

1452 | (((fun (x : Ppx_deriving_runtime.string) -> `String x)) |
||

1453 | arg0.id)) |
||

1454 | :: fields |
||

1455 | in |
||

1456 | `Assoc fields)] |
||

1457 | | IsNull -> `List [`String "IsNull"] |
||

1458 | | Time arg0 -> |
||

1459 | `List |
||

1460 | [`String "Time"; |
||

1461 | (let fields = [] in |
||

1462 | let fields = |
||

1463 | if arg0.phy_unit = "" |
||

1464 | then fields |
||

1465 | else |
||

1466 | ("phy_unit", |
||

1467 | (((fun (x : Ppx_deriving_runtime.string) -> `String x)) |
||

1468 | arg0.phy_unit)) |
||

1469 | :: fields |
||

1470 | in |
||

1471 | let fields = |
||

1472 | ("value", |
||

1473 | ((fun (x : Ppx_deriving_runtime.int) -> `Int x) arg0.value)) |
||

1474 | :: fields in |
||

1475 | `Assoc fields)] |
||

1476 | | Sig arg0 -> |
||

1477 | `List |
||

1478 | [`String "Sig"; |
||

1479 | (let fields = [] in |
||

1480 | let fields = |
||

1481 | ("att", |
||

1482 | ((function |
||

1483 | | None -> `Null |
||

1484 | | Some x -> |
||

1485 | ((fun x -> vhdl_signal_attributes_t_to_yojson x)) x) |
||

1486 | arg0.att)) |
||

1487 | :: fields in |
||

1488 | let fields = |
||

1489 | ("name", ((fun x -> vhdl_name_t_to_yojson x) arg0.name)) :: |
||

1490 | fields in |
||

1491 | `Assoc fields)] |
||

1492 | | SuffixMod arg0 -> |
||

1493 | `List |
||

1494 | [`String "SuffixMod"; |
||

1495 | (let fields = [] in |
||

1496 | let fields = |
||

1497 | ("selection", |
||

1498 | ((fun x -> vhdl_suffix_selection_t_to_yojson x) |
||

1499 | arg0.selection)) |
||

1500 | :: fields in |
||

1501 | let fields = |
||

1502 | ("expr", ((fun x -> vhdl_expr_t_to_yojson x) arg0.expr)) :: |
||

1503 | fields in |
||

1504 | `Assoc fields)] |
||

1505 | | Aggregate arg0 -> |
||

1506 | `List |
||

1507 | [`String "AGGREGATE"; |
||

1508 | (let fields = [] in |
||

1509 | let fields = |
||

1510 | ("elems", |
||

1511 | ((fun x -> |
||

1512 | `List |
||

1513 | (List.map (fun x -> vhdl_element_assoc_t_to_yojson x) |
||

1514 | x)) arg0.elems)) |
||

1515 | :: fields in |
||

1516 | `Assoc fields)] |
||

1517 | | Others -> `List [`String "OTHERS"]) |
||

1518 | [@ocaml.warning "-A"]) |
||

1519 | |||

1520 | and (vhdl_expr_t_of_yojson : |
||

1521 | Yojson.Safe.json -> vhdl_expr_t Ppx_deriving_yojson_runtime.error_or) |
||

1522 | = |
||

1523 | ((let open! Ppx_deriving_yojson_runtime in |
||

1524 | function |
||

1525 | | `List ((`String "CALL")::arg0::[]) -> |
||

1526 | ((fun x -> vhdl_name_t_of_yojson x) arg0) >>= |
||

1527 | ((fun arg0 -> Result.Ok (Call arg0))) |
||

1528 | | `List ((`String "CONSTANT_VALUE")::arg0::[]) -> |
||

1529 | ab6312e7 | Arnaud Dieumegard | ((function |

1530 | | `Assoc xs -> |
||

1531 | let rec loop xs ((arg0,arg1) as _state) = |
||

1532 | match xs with |
||

1533 | | ("value",x)::xs -> |
||

1534 | loop xs |
||

1535 | (((fun x -> vhdl_cst_val_t_of_yojson x) x), arg1) |
||

1536 | | ("unit_name",x)::xs -> |
||

1537 | loop xs |
||

1538 | (arg0, |
||

1539 | ((function |
||

1540 | | `Null -> Result.Ok None |
||

1541 | | x -> |
||

1542 | ((fun x -> vhdl_name_t_of_yojson x) x) >>= |
||

1543 | ((fun x -> Result.Ok (Some x)))) x)) |
||

1544 | | [] -> |
||

1545 | arg1 >>= |
||

1546 | ((fun arg1 -> |
||

1547 | arg0 >>= |
||

1548 | (fun arg0 -> |
||

1549 | Result.Ok |
||

1550 | (Cst { value = arg0; unit_name = arg1 })))) |
||

1551 | | _::xs -> loop xs _state in |
||

1552 | loop xs |
||

1553 | ((Result.Error "Vhdl_ast.vhdl_expr_t.value"), |
||

1554 | (Result.Ok None)) |
||

1555 | | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0 |
||

1556 | 40364f53 | Arnaud Dieumegard | | `List ((`String "EXPRESSION")::arg0::[]) -> |

1557 | ((function |
||

1558 | | `Assoc xs -> |
||

1559 | let rec loop xs ((arg0,arg1) as _state) = |
||

1560 | match xs with |
||

1561 | | ("id",x)::xs -> |
||

1562 | loop xs |
||

1563 | (((function |
||

1564 | | `String x -> Result.Ok x |
||

1565 | | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.id") x), |
||

1566 | arg1) |
||

1567 | | ("args",x)::xs -> |
||

1568 | loop xs |
||

1569 | (arg0, |
||

1570 | ((function |
||

1571 | | `List xs -> |
||

1572 | map_bind (fun x -> vhdl_expr_t_of_yojson x) |
||

1573 | [] xs |
||

1574 | | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.args") |
||

1575 | x)) |
||

1576 | | [] -> |
||

1577 | arg1 >>= |
||

1578 | ((fun arg1 -> |
||

1579 | arg0 >>= |
||

1580 | (fun arg0 -> |
||

1581 | Result.Ok (Op { id = arg0; args = arg1 })))) |
||

1582 | | _::xs -> loop xs _state in |
||

1583 | loop xs ((Result.Ok ""), (Result.Ok [])) |
||

1584 | | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0 |
||

1585 | | `List ((`String "IsNull")::[]) -> Result.Ok IsNull |
||

1586 | | `List ((`String "Time")::arg0::[]) -> |
||

1587 | ((function |
||

1588 | | `Assoc xs -> |
||

1589 | let rec loop xs ((arg0,arg1) as _state) = |
||

1590 | match xs with |
||

1591 | | ("value",x)::xs -> |
||

1592 | loop xs |
||

1593 | (((function |
||

1594 | | `Int x -> Result.Ok x |
||

1595 | | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.value") |
||

1596 | x), arg1) |
||

1597 | | ("phy_unit",x)::xs -> |
||

1598 | loop xs |
||

1599 | (arg0, |
||

1600 | ((function |
||

1601 | | `String x -> Result.Ok x |
||

1602 | | _ -> |
||

1603 | Result.Error "Vhdl_ast.vhdl_expr_t.phy_unit") |
||

1604 | x)) |
||

1605 | | [] -> |
||

1606 | arg1 >>= |
||

1607 | ((fun arg1 -> |
||

1608 | arg0 >>= |
||

1609 | (fun arg0 -> |
||

1610 | Result.Ok |
||

1611 | (Time { value = arg0; phy_unit = arg1 })))) |
||

1612 | | _::xs -> loop xs _state in |
||

1613 | loop xs |
||

1614 | ((Result.Error "Vhdl_ast.vhdl_expr_t.value"), |
||

1615 | (Result.Ok "")) |
||

1616 | | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0 |
||

1617 | | `List ((`String "Sig")::arg0::[]) -> |
||

1618 | ((function |
||

1619 | | `Assoc xs -> |
||

1620 | let rec loop xs ((arg0,arg1) as _state) = |
||

1621 | match xs with |
||

1622 | | ("name",x)::xs -> |
||

1623 | loop xs (((fun x -> vhdl_name_t_of_yojson x) x), arg1) |
||

1624 | | ("att",x)::xs -> |
||

1625 | loop xs |
||

1626 | (arg0, |
||

1627 | ((function |
||

1628 | | `Null -> Result.Ok None |
||

1629 | | x -> |
||

1630 | ((fun x -> |
||

1631 | vhdl_signal_attributes_t_of_yojson x) x) |
||

1632 | >>= ((fun x -> Result.Ok (Some x)))) x)) |
||

1633 | | [] -> |
||

1634 | arg1 >>= |
||

1635 | ((fun arg1 -> |
||

1636 | arg0 >>= |
||

1637 | (fun arg0 -> |
||

1638 | Result.Ok (Sig { name = arg0; att = arg1 })))) |
||

1639 | | _::xs -> loop xs _state in |
||

1640 | loop xs |
||

1641 | ((Result.Error "Vhdl_ast.vhdl_expr_t.name"), |
||

1642 | (Result.Error "Vhdl_ast.vhdl_expr_t.att")) |
||

1643 | | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0 |
||

1644 | | `List ((`String "SuffixMod")::arg0::[]) -> |
||

1645 | ((function |
||

1646 | | `Assoc xs -> |
||

1647 | let rec loop xs ((arg0,arg1) as _state) = |
||

1648 | match xs with |
||

1649 | | ("expr",x)::xs -> |
||

1650 | loop xs (((fun x -> vhdl_expr_t_of_yojson x) x), arg1) |
||

1651 | | ("selection",x)::xs -> |
||

1652 | loop xs |
||

1653 | (arg0, |
||

1654 | ((fun x -> vhdl_suffix_selection_t_of_yojson x) x)) |
||

1655 | | [] -> |
||

1656 | arg1 >>= |
||

1657 | ((fun arg1 -> |
||

1658 | arg0 >>= |
||

1659 | (fun arg0 -> |
||

1660 | Result.Ok |
||

1661 | (SuffixMod |
||

1662 | { expr = arg0; selection = arg1 })))) |
||

1663 | | _::xs -> loop xs _state in |
||

1664 | loop xs |
||

1665 | ((Result.Error "Vhdl_ast.vhdl_expr_t.expr"), |
||

1666 | (Result.Error "Vhdl_ast.vhdl_expr_t.selection")) |
||

1667 | | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0 |
||

1668 | | `List ((`String "AGGREGATE")::arg0::[]) -> |
||

1669 | ((function |
||

1670 | | `Assoc xs -> |
||

1671 | let rec loop xs (arg0 as _state) = |
||

1672 | match xs with |
||

1673 | | ("elems",x)::xs -> |
||

1674 | loop xs |
||

1675 | ((function |
||

1676 | | `List xs -> |
||

1677 | map_bind |
||

1678 | (fun x -> vhdl_element_assoc_t_of_yojson x) |
||

1679 | [] xs |
||

1680 | | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.elems") x) |
||

1681 | | [] -> |
||

1682 | arg0 >>= |
||

1683 | ((fun arg0 -> Result.Ok (Aggregate { elems = arg0 }))) |
||

1684 | | _::xs -> loop xs _state in |
||

1685 | loop xs (Result.Error "Vhdl_ast.vhdl_expr_t.elems") |
||

1686 | | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0 |
||

1687 | | `List ((`String "OTHERS")::[]) -> Result.Ok Others |
||

1688 | | _ -> Result.Error "Vhdl_ast.vhdl_expr_t") |
||

1689 | [@ocaml.warning "-A"]) |
||

1690 | |||

1691 | and (vhdl_name_t_to_yojson : vhdl_name_t -> Yojson.Safe.json) = |
||

1692 | ((let open! Ppx_deriving_yojson_runtime in |
||

1693 | function |
||

1694 | | Simple arg0 -> |
||

1695 | `List |
||

1696 | [`String "SIMPLE_NAME"; |
||

1697 | ((fun (x : Ppx_deriving_runtime.string) -> `String x)) arg0] |
||

1698 | | Identifier arg0 -> |
||

1699 | `List |
||

1700 | [`String "IDENTIFIER"; |
||

1701 | ((fun (x : Ppx_deriving_runtime.string) -> `String x)) arg0] |
||

1702 | | Selected arg0 -> |
||

1703 | `List |
||

1704 | [`String "SELECTED_NAME"; |
||

1705 | ((fun x -> |
||

1706 | `List (List.map (fun x -> vhdl_name_t_to_yojson x) x))) arg0] |
||

1707 | | Index arg0 -> |
||

1708 | `List |
||

1709 | [`String "INDEXED_NAME"; |
||

1710 | (let fields = [] in |
||

1711 | let fields = |
||

1712 | ("exprs", |
||

1713 | ((fun x -> |
||

1714 | `List (List.map (fun x -> vhdl_expr_t_to_yojson x) x)) |
||

1715 | arg0.exprs)) |
||

1716 | :: fields in |
||

1717 | let fields = |
||

1718 | ("id", ((fun x -> vhdl_name_t_to_yojson x) arg0.id)) :: |
||

1719 | fields in |
||

1720 | `Assoc fields)] |
||

1721 | | Slice arg0 -> |
||

1722 | `List |
||

1723 | [`String "SLICE_NAME"; |
||

1724 | (let fields = [] in |
||

1725 | let fields = |
||

1726 | ("range", |
||

1727 | ((fun x -> vhdl_discrete_range_t_to_yojson x) arg0.range)) |
||

1728 | :: fields in |
||

1729 | let fields = |
||

1730 | ("id", ((fun x -> vhdl_name_t_to_yojson x) arg0.id)) :: |
||

1731 | fields in |
||

1732 | `Assoc fields)] |
||

1733 | | Attribute arg0 -> |
||

1734 | `List |
||

1735 | [`String "ATTRIBUTE_NAME"; |
||

1736 | (let fields = [] in |
||

1737 | let fields = |
||

1738 | if arg0.expr = IsNull |
||

1739 | then fields |
||

1740 | else |
||

1741 | ("expr", (((fun x -> vhdl_expr_t_to_yojson x)) arg0.expr)) |
||

1742 | :: fields |
||

1743 | in |
||

1744 | let fields = |
||

1745 | ("designator", |
||

1746 | ((fun x -> vhdl_name_t_to_yojson x) arg0.designator)) |
||

1747 | :: fields in |
||

1748 | let fields = |
||

1749 | ("id", ((fun x -> vhdl_name_t_to_yojson x) arg0.id)) :: |
||

1750 | fields in |
||

1751 | `Assoc fields)] |
||

1752 | | Function arg0 -> |
||

1753 | `List |
||

1754 | [`String "FUNCTION_CALL"; |
||

1755 | (let fields = [] in |
||

1756 | let fields = |
||

1757 | ("assoc_list", |
||

1758 | ((fun x -> |
||

1759 | `List |
||

1760 | (List.map (fun x -> vhdl_assoc_element_t_to_yojson x) |
||

1761 | x)) arg0.assoc_list)) |
||

1762 | :: fields in |
||

1763 | let fields = |
||

1764 | ("id", ((fun x -> vhdl_name_t_to_yojson x) arg0.id)) :: |
||

1765 | fields in |
||

1766 | `Assoc fields)] |
||

1767 | | NoName -> `List [`String "NoName"]) |
||

1768 | [@ocaml.warning "-A"]) |
||

1769 | |||

1770 | and (vhdl_name_t_of_yojson : |
||

1771 | Yojson.Safe.json -> vhdl_name_t Ppx_deriving_yojson_runtime.error_or) |
||

1772 | = |
||

1773 | ((let open! Ppx_deriving_yojson_runtime in |
||

1774 | function |
||

1775 | | `List ((`String "SIMPLE_NAME")::arg0::[]) -> |
||

1776 | ((function |
||

1777 | | `String x -> Result.Ok x |
||

1778 | | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>= |
||

1779 | ((fun arg0 -> Result.Ok (Simple arg0))) |
||

1780 | | `List ((`String "IDENTIFIER")::arg0::[]) -> |
||

1781 | ((function |
||

1782 | | `String x -> Result.Ok x |
||

1783 | | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>= |
||

1784 | ((fun arg0 -> Result.Ok (Identifier arg0))) |
||

1785 | | `List ((`String "SELECTED_NAME")::arg0::[]) -> |
||

1786 | ((function |
||

1787 | | `List xs -> map_bind (fun x -> vhdl_name_t_of_yojson x) [] xs |
||

1788 | | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>= |
||

1789 | ((fun arg0 -> Result.Ok (Selected arg0))) |
||

1790 | | `List ((`String "INDEXED_NAME")::arg0::[]) -> |
||

1791 | ((function |
||

1792 | | `Assoc xs -> |
||

1793 | let rec loop xs ((arg0,arg1) as _state) = |
||

1794 | match xs with |
||

1795 | | ("id",x)::xs -> |
||

1796 | loop xs (((fun x -> vhdl_name_t_of_yojson x) x), arg1) |
||

1797 | | ("exprs",x)::xs -> |
||

1798 | loop xs |
||

1799 | (arg0, |
||

1800 | ((function |
||

1801 | | `List xs -> |
||

1802 | map_bind (fun x -> vhdl_expr_t_of_yojson x) |
||

1803 | [] xs |
||

1804 | | _ -> Result.Error "Vhdl_ast.vhdl_name_t.exprs") |
||

1805 | x)) |
||

1806 | | [] -> |
||

1807 | arg1 >>= |
||

1808 | ((fun arg1 -> |
||

1809 | arg0 >>= |
||

1810 | (fun arg0 -> |
||

1811 | Result.Ok |
||

1812 | (Index { id = arg0; exprs = arg1 })))) |
||

1813 | | _::xs -> loop xs _state in |
||

1814 | loop xs |
||

1815 | ((Result.Error "Vhdl_ast.vhdl_name_t.id"), |
||

1816 | (Result.Error "Vhdl_ast.vhdl_name_t.exprs")) |
||

1817 | | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0 |
||

1818 | | `List ((`String "SLICE_NAME")::arg0::[]) -> |
||

1819 | ((function |
||

1820 | | `Assoc xs -> |
||

1821 | let rec loop xs ((arg0,arg1) as _state) = |
||

1822 | match xs with |
||

1823 | | ("id",x)::xs -> |
||

1824 | loop xs (((fun x -> vhdl_name_t_of_yojson x) x), arg1) |
||

1825 | | ("range",x)::xs -> |
||

1826 | loop xs |
||

1827 | (arg0, |
||

1828 | ((fun x -> vhdl_discrete_range_t_of_yojson x) x)) |
||

1829 | | [] -> |
||

1830 | arg1 >>= |
||

1831 | ((fun arg1 -> |
||

1832 | arg0 >>= |
||

1833 | (fun arg0 -> |
||

1834 | Result.Ok |
||

1835 | (Slice { id = arg0; range = arg1 })))) |
||

1836 | | _::xs -> loop xs _state in |
||

1837 | loop xs |
||

1838 | ((Result.Error "Vhdl_ast.vhdl_name_t.id"), |
||

1839 | (Result.Error "Vhdl_ast.vhdl_name_t.range")) |
||

1840 | | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0 |
||

1841 | | `List ((`String "ATTRIBUTE_NAME")::arg0::[]) -> |
||

1842 | ((function |
||

1843 | | `Assoc xs -> |
||

1844 | let rec loop xs ((arg0,arg1,arg2) as _state) = |
||

1845 | match xs with |
||

1846 | | ("id",x)::xs -> |
||

1847 | loop xs |
||

1848 | (((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2) |
||

1849 | | ("designator",x)::xs -> |
||

1850 | loop xs |
||

1851 | (arg0, ((fun x -> vhdl_name_t_of_yojson x) x), arg2) |
||

1852 | | ("expr",x)::xs -> |
||

1853 | loop xs |
||

1854 | (arg0, arg1, ((fun x -> vhdl_expr_t_of_yojson x) x)) |
||

1855 | | [] -> |
||

1856 | arg2 >>= |
||

1857 | ((fun arg2 -> |
||

1858 | arg1 >>= |
||

1859 | (fun arg1 -> |
||

1860 | arg0 >>= |
||

1861 | (fun arg0 -> |
||

1862 | Result.Ok |
||

1863 | (Attribute |
||

1864 | { |
||

1865 | id = arg0; |
||

1866 | designator = arg1; |
||

1867 | expr = arg2 |
||

1868 | }))))) |
||

1869 | | _::xs -> loop xs _state in |
||

1870 | loop xs |
||

1871 | ((Result.Error "Vhdl_ast.vhdl_name_t.id"), |
||

1872 | (Result.Error "Vhdl_ast.vhdl_name_t.designator"), |
||

1873 | (Result.Ok IsNull)) |
||

1874 | | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0 |
||

1875 | | `List ((`String "FUNCTION_CALL")::arg0::[]) -> |
||

1876 | ((function |
||

1877 | | `Assoc xs -> |
||

1878 | let rec loop xs ((arg0,arg1) as _state) = |
||

1879 | match xs with |
||

1880 | | ("id",x)::xs -> |
||

1881 | loop xs (((fun x -> vhdl_name_t_of_yojson x) x), arg1) |
||

1882 | | ("assoc_list",x)::xs -> |
||

1883 | loop xs |
||

1884 | (arg0, |
||

1885 | ((function |
||

1886 | | `List xs -> |
||

1887 | map_bind |
||

1888 | (fun x -> vhdl_assoc_element_t_of_yojson x) |
||

1889 | [] xs |
||

1890 | | _ -> |
||

1891 | Result.Error |
||

1892 | "Vhdl_ast.vhdl_name_t.assoc_list") x)) |
||

1893 | | [] -> |
||

1894 | arg1 >>= |
||

1895 | ((fun arg1 -> |
||

1896 | arg0 >>= |
||

1897 | (fun arg0 -> |
||

1898 | Result.Ok |
||

1899 | (Function { id = arg0; assoc_list = arg1 })))) |
||

1900 | | _::xs -> loop xs _state in |
||

1901 | loop xs |
||

1902 | ((Result.Error "Vhdl_ast.vhdl_name_t.id"), |
||

1903 | (Result.Error "Vhdl_ast.vhdl_name_t.assoc_list")) |
||

1904 | | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0 |
||

1905 | | `List ((`String "NoName")::[]) -> Result.Ok NoName |
||

1906 | | _ -> Result.Error "Vhdl_ast.vhdl_name_t") |
||

1907 | [@ocaml.warning "-A"]) |
||

1908 | |||

1909 | and (vhdl_assoc_element_t_to_yojson : |
||

1910 | vhdl_assoc_element_t -> Yojson.Safe.json) |
||

1911 | = |
||

1912 | ((let open! Ppx_deriving_yojson_runtime in |
||

1913 | fun x -> |
||

1914 | let fields = [] in |
||

1915 | let fields = |
||

1916 | 00970bbf | Arnaud Dieumegard | if x.actual_expr = None |

1917 | 40364f53 | Arnaud Dieumegard | then fields |

1918 | else |
||

1919 | ("actual_expr", |
||

1920 | (((function |
||

1921 | | None -> `Null |
||

1922 | | Some x -> ((fun x -> vhdl_expr_t_to_yojson x)) x)) |
||

1923 | x.actual_expr)) |
||

1924 | :: fields |
||

1925 | in |
||

1926 | let fields = |
||

1927 | 00970bbf | Arnaud Dieumegard | if x.actual_designator = None |

1928 | 40364f53 | Arnaud Dieumegard | then fields |

1929 | else |
||

1930 | ("actual_designator", |
||

1931 | (((function |
||

1932 | | None -> `Null |
||

1933 | | Some x -> ((fun x -> vhdl_name_t_to_yojson x)) x)) |
||

1934 | x.actual_designator)) |
||

1935 | :: fields |
||

1936 | in |
||

1937 | let fields = |
||

1938 | 00970bbf | Arnaud Dieumegard | if x.actual_name = None |

1939 | 40364f53 | Arnaud Dieumegard | then fields |

1940 | else |
||

1941 | ("actual_name", |
||

1942 | (((function |
||

1943 | | None -> `Null |
||

1944 | | Some x -> ((fun x -> vhdl_name_t_to_yojson x)) x)) |
||

1945 | x.actual_name)) |
||

1946 | :: fields |
||

1947 | in |
||

1948 | let fields = |
||

1949 | 00970bbf | Arnaud Dieumegard | if x.formal_arg = None |

1950 | 40364f53 | Arnaud Dieumegard | then fields |

1951 | else |
||

1952 | ("formal_arg", |
||

1953 | (((function |
||

1954 | | None -> `Null |
||

1955 | | Some x -> ((fun x -> vhdl_name_t_to_yojson x)) x)) |
||

1956 | x.formal_arg)) |
||

1957 | :: fields |
||

1958 | in |
||

1959 | let fields = |
||

1960 | 00970bbf | Arnaud Dieumegard | if x.formal_name = None |

1961 | 40364f53 | Arnaud Dieumegard | then fields |

1962 | else |
||

1963 | ("formal_name", |
||

1964 | (((function |
||

1965 | | None -> `Null |
||

1966 | | Some x -> ((fun x -> vhdl_name_t_to_yojson x)) x)) |
||

1967 | x.formal_name)) |
||

1968 | :: fields |
||

1969 | in |
||

1970 | `Assoc fields) |
||

1971 | [@ocaml.warning "-A"]) |
||

1972 | |||

1973 | and (vhdl_assoc_element_t_of_yojson : |
||

1974 | Yojson.Safe.json -> |
||

1975 | vhdl_assoc_element_t Ppx_deriving_yojson_runtime.error_or) |
||

1976 | = |
||

1977 | ((let open! Ppx_deriving_yojson_runtime in |
||

1978 | function |
||

1979 | | `Assoc xs -> |
||

1980 | let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) = |
||

1981 | match xs with |
||

1982 | | ("formal_name",x)::xs -> |
||

1983 | loop xs |
||

1984 | (((function |
||

1985 | | `Null -> Result.Ok None |
||

1986 | | x -> |
||

1987 | ((fun x -> vhdl_name_t_of_yojson x) x) >>= |
||

1988 | ((fun x -> Result.Ok (Some x)))) x), arg1, arg2, |
||

1989 | arg3, arg4) |
||

1990 | | ("formal_arg",x)::xs -> |
||

1991 | loop xs |
||

1992 | (arg0, |
||

1993 | ((function |
||

1994 | | `Null -> Result.Ok None |
||

1995 | | x -> |
||

1996 | ((fun x -> vhdl_name_t_of_yojson x) x) >>= |
||

1997 | ((fun x -> Result.Ok (Some x)))) x), arg2, arg3, |
||

1998 | arg4) |
||

1999 | | ("actual_name",x)::xs -> |
||

2000 | loop xs |
||

2001 | (arg0, arg1, |
||

2002 | ((function |
||

2003 | | `Null -> Result.Ok None |
||

2004 | | x -> |
||

2005 | ((fun x -> vhdl_name_t_of_yojson x) x) >>= |
||

2006 | ((fun x -> Result.Ok (Some x)))) x), arg3, arg4) |
||

2007 | | ("actual_designator",x)::xs -> |
||

2008 | loop xs |
||

2009 | (arg0, arg1, arg2, |
||

2010 | ((function |
||

2011 | | `Null -> Result.Ok None |
||

2012 | | x -> |
||

2013 | ((fun x -> vhdl_name_t_of_yojson x) x) >>= |
||

2014 | ((fun x -> Result.Ok (Some x)))) x), arg4) |
||

2015 | | ("actual_expr",x)::xs -> |
||

2016 | loop xs |
||

2017 | (arg0, arg1, arg2, arg3, |
||

2018 | ((function |
||

2019 | | `Null -> Result.Ok None |
||

2020 | | x -> |
||

2021 | ((fun x -> vhdl_expr_t_of_yojson x) x) >>= |
||

2022 | ((fun x -> Result.Ok (Some x)))) x)) |
||

2023 | | [] -> |
||

2024 | arg4 >>= |
||

2025 | ((fun arg4 -> |
||

2026 | arg3 >>= |
||

2027 | (fun arg3 -> |
||

2028 | arg2 >>= |
||

2029 | (fun arg2 -> |
||

2030 | arg1 >>= |
||

2031 | (fun arg1 -> |
||

2032 | arg0 >>= |
||

2033 | (fun arg0 -> |
||

2034 | Result.Ok |
||

2035 | { |
||

2036 | formal_name = arg0; |
||

2037 | formal_arg = arg1; |
||

2038 | actual_name = arg2; |
||

2039 | actual_designator = arg3; |
||

2040 | actual_expr = arg4 |
||

2041 | })))))) |
||

2042 | | _::xs -> loop xs _state in |
||

2043 | loop xs |
||

2044 | ((Result.Ok (Some NoName)), (Result.Ok (Some NoName)), |
||

2045 | (Result.Ok (Some NoName)), (Result.Ok (Some NoName)), |
||

2046 | (Result.Ok (Some IsNull))) |
||

2047 | | _ -> Result.Error "Vhdl_ast.vhdl_assoc_element_t") |
||

2048 | [@ocaml.warning "-A"]) |
||

2049 | |||

2050 | and (vhdl_element_assoc_t_to_yojson : |
||

2051 | vhdl_element_assoc_t -> Yojson.Safe.json) |
||

2052 | = |
||

2053 | ((let open! Ppx_deriving_yojson_runtime in |
||

2054 | fun x -> |
||

2055 | let fields = [] in |
||

2056 | let fields = ("expr", ((fun x -> vhdl_expr_t_to_yojson x) x.expr)) |
||

2057 | :: fields in |
||

2058 | let fields = |
||

2059 | 7f55f63f | Arnaud Dieumegard | if x.choices = [] |

2060 | then fields |
||

2061 | else |
||

2062 | ("choices", |
||

2063 | (((fun x -> |
||

2064 | `List (List.map (fun x -> vhdl_expr_t_to_yojson x) x))) |
||

2065 | x.choices)) |
||

2066 | :: fields |
||

2067 | in |
||

2068 | 40364f53 | Arnaud Dieumegard | `Assoc fields) |

2069 | [@ocaml.warning "-A"]) |
||

2070 | |||

2071 | and (vhdl_element_assoc_t_of_yojson : |
||

2072 | Yojson.Safe.json -> |
||

2073 | vhdl_element_assoc_t Ppx_deriving_yojson_runtime.error_or) |
||

2074 | = |
||

2075 | ((let open! Ppx_deriving_yojson_runtime in |
||

2076 | function |
||

2077 | | `Assoc xs -> |
||

2078 | let rec loop xs ((arg0,arg1) as _state) = |
||

2079 | match xs with |
||

2080 | | ("choices",x)::xs -> |
||

2081 | loop xs |
||

2082 | (((function |
||

2083 | | `List xs -> |
||

2084 | map_bind (fun x -> vhdl_expr_t_of_yojson x) [] xs |
||

2085 | | _ -> |
||

2086 | Result.Error "Vhdl_ast.vhdl_element_assoc_t.choices") |
||

2087 | x), arg1) |
||

2088 | | ("expr",x)::xs -> |
||

2089 | loop xs (arg0, ((fun x -> vhdl_expr_t_of_yojson x) x)) |
||

2090 | | [] -> |
||

2091 | arg1 >>= |
||

2092 | ((fun arg1 -> |
||

2093 | arg0 >>= |
||

2094 | (fun arg0 -> |
||

2095 | Result.Ok { choices = arg0; expr = arg1 }))) |
||

2096 | | _::xs -> loop xs _state in |
||

2097 | loop xs |
||

2098 | 7f55f63f | Arnaud Dieumegard | ((Result.Ok []), |

2099 | 40364f53 | Arnaud Dieumegard | (Result.Error "Vhdl_ast.vhdl_element_assoc_t.expr")) |

2100 | | _ -> Result.Error "Vhdl_ast.vhdl_element_assoc_t") |
||

2101 | [@ocaml.warning "-A"]) |
||

2102 | |||

2103 | and (vhdl_array_attributes_t_to_yojson : |
||

2104 | vhdl_array_attributes_t -> Yojson.Safe.json) |
||

2105 | = |
||

2106 | ((let open! Ppx_deriving_yojson_runtime in |
||

2107 | function |
||

2108 | | AAttInt arg0 -> |
||

2109 | `List |
||

2110 | [`String "AAttInt"; |
||

2111 | (let fields = [] in |
||

2112 | let fields = |
||

2113 | ("arg", |
||

2114 | ((fun (x : Ppx_deriving_runtime.int) -> `Int x) arg0.arg)) |
||

2115 | :: fields in |
||

2116 | let fields = |
||

2117 | ("id", |
||

2118 | ((fun (x : Ppx_deriving_runtime.string) -> `String x) |
||

2119 | arg0.id)) |
||

2120 | :: fields in |
||

2121 | `Assoc fields)] |
||

2122 | | AAttAscending -> `List [`String "AAttAscending"]) |
||

2123 | [@ocaml.warning "-A"]) |
||

2124 | |||

2125 | and (vhdl_array_attributes_t_of_yojson : |
||

2126 | Yojson.Safe.json -> |
||

2127 | vhdl_array_attributes_t Ppx_deriving_yojson_runtime.error_or) |
||

2128 | = |
||

2129 | ((let open! Ppx_deriving_yojson_runtime in |
||

2130 | function |
||

2131 | | `List ((`String "AAttInt")::arg0::[]) -> |
||

2132 | ((function |
||

2133 | | `Assoc xs -> |
||

2134 | let rec loop xs ((arg0,arg1) as _state) = |
||

2135 | match xs with |
||

2136 | | ("id",x)::xs -> |
||

2137 | loop xs |
||

2138 | (((function |
||

2139 | | `String x -> Result.Ok x |
||

2140 | | _ -> |
||

2141 | Result.Error |
||

2142 | "Vhdl_ast.vhdl_array_attributes_t.id") x), |
||

2143 | arg1) |
||

2144 | | ("arg",x)::xs -> |
||

2145 | loop xs |
||

2146 | (arg0, |
||

2147 | ((function |
||

2148 | | `Int x -> Result.Ok x |
||

2149 | | _ -> |
||

2150 | Result.Error |
||

2151 | "Vhdl_ast.vhdl_array_attributes_t.arg") x)) |
||

2152 | | [] -> |
||

2153 | arg1 >>= |
||

2154 | ((fun arg1 -> |
||

2155 | arg0 >>= |
||

2156 | (fun arg0 -> |
||

2157 | Result.Ok |
||

2158 | (AAttInt { id = arg0; arg = arg1 })))) |
||

2159 | | _::xs -> loop xs _state in |
||

2160 | loop xs |
||

2161 | ((Result.Error "Vhdl_ast.vhdl_array_attributes_t.id"), |
||

2162 | (Result.Error "Vhdl_ast.vhdl_array_attributes_t.arg")) |
||

2163 | | _ -> Result.Error "Vhdl_ast.vhdl_array_attributes_t")) arg0 |
||

2164 | | `List ((`String "AAttAscending")::[]) -> Result.Ok AAttAscending |
||

2165 | | _ -> Result.Error "Vhdl_ast.vhdl_array_attributes_t") |
||

2166 | [@ocaml.warning "-A"]) |
||

2167 | |||

2168 | and (vhdl_signal_attributes_t_to_yojson : |
||

2169 | vhdl_signal_attributes_t -> Yojson.Safe.json) |
||

2170 | = |
||

2171 | ((let open! Ppx_deriving_yojson_runtime in |
||

2172 | function |
||

2173 | | SigAtt arg0 -> |
||

2174 | `List |
||

2175 | [`String "SigAtt"; |
||

2176 | ((fun (x : Ppx_deriving_runtime.string) -> `String x)) arg0]) |
||

2177 | [@ocaml.warning "-A"]) |
||

2178 | |||

2179 | and (vhdl_signal_attributes_t_of_yojson : |
||

2180 | Yojson.Safe.json -> |
||

2181 | vhdl_signal_attributes_t Ppx_deriving_yojson_runtime.error_or) |
||

2182 | = |
||

2183 | ((let open! Ppx_deriving_yojson_runtime in |
||

2184 | function |
||

2185 | | `List ((`String "SigAtt")::arg0::[]) -> |
||

2186 | ((function |
||

2187 | | `String x -> Result.Ok x |
||

2188 | | _ -> Result.Error "Vhdl_ast.vhdl_signal_attributes_t") arg0) |
||

2189 | >>= ((fun arg0 -> Result.Ok (SigAtt arg0))) |
||

2190 | | _ -> Result.Error "Vhdl_ast.vhdl_signal_attributes_t") |
||

2191 | [@ocaml.warning "-A"]) |
||

2192 | |||

2193 | and (vhdl_string_attributes_t_to_yojson : |
||

2194 | vhdl_string_attributes_t -> Yojson.Safe.json) |
||

2195 | = |
||

2196 | ((let open! Ppx_deriving_yojson_runtime in |
||

2197 | function |
||

2198 | | StringAtt arg0 -> |
||

2199 | `List |
||

2200 | [`String "StringAtt"; |
||

2201 | ((fun (x : Ppx_deriving_runtime.string) -> `String x)) arg0]) |
||

2202 | [@ocaml.warning "-A"]) |
||

2203 | |||

2204 | and (vhdl_string_attributes_t_of_yojson : |
||

2205 | Yojson.Safe.json -> |
||

2206 | vhdl_string_attributes_t Ppx_deriving_yojson_runtime.error_or) |
||

2207 | = |
||

2208 | ((let open! Ppx_deriving_yojson_runtime in |
||

2209 | function |
||

2210 | | `List ((`String "StringAtt")::arg0::[]) -> |
||

2211 | ((function |
||

2212 | | `String x -> Result.Ok x |
||

2213 | | _ -> Result.Error "Vhdl_ast.vhdl_string_attributes_t") arg0) |
||

2214 | >>= ((fun arg0 -> Result.Ok (StringAtt arg0))) |
||

2215 | | _ -> Result.Error "Vhdl_ast.vhdl_string_attributes_t") |
||

2216 | [@ocaml.warning "-A"]) |
||

2217 | |||

2218 | and (vhdl_suffix_selection_t_to_yojson : |
||

2219 | vhdl_suffix_selection_t -> Yojson.Safe.json) |
||

2220 | = |
||

2221 | ((let open! Ppx_deriving_yojson_runtime in |
||

2222 | function |
||

2223 | | Idx arg0 -> |
||

2224 | `List |
||

2225 | [`String "Idx"; |
||

2226 | ((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg0] |
||

2227 | | SuffixRange (arg0,arg1) -> |
||

2228 | `List |
||

2229 | [`String "SuffixRange"; |
||

2230 | ((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg0; |
||

2231 | ((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg1]) |
||

2232 | [@ocaml.warning "-A"]) |
||

2233 | |||

2234 | and (vhdl_suffix_selection_t_of_yojson : |
||

2235 | Yojson.Safe.json -> |
||

2236 | vhdl_suffix_selection_t Ppx_deriving_yojson_runtime.error_or) |
||

2237 | = |
||

2238 | ((let open! Ppx_deriving_yojson_runtime in |
||

2239 | function |
||

2240 | | `List ((`String "Idx")::arg0::[]) -> |
||

2241 | ((function |
||

2242 | | `Int x -> Result.Ok x |
||

2243 | | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") arg0) >>= |
||

2244 | ((fun arg0 -> Result.Ok (Idx arg0))) |
||

2245 | | `List ((`String "SuffixRange")::arg0::arg1::[]) -> |
||

2246 | ((function |
||

2247 | | `Int x -> Result.Ok x |
||

2248 | | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") arg1) >>= |
||

2249 | ((fun arg1 -> |
||

2250 | ((function |
||

2251 | | `Int x -> Result.Ok x |
||

2252 | | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") |
||

2253 | arg0) |
||

2254 | >>= (fun arg0 -> Result.Ok (SuffixRange (arg0, arg1))))) |
||

2255 | | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") |
||

2256 | [@ocaml.warning "-A"]) |
||

2257 | |||

2258 | type 'basetype vhdl_type_attributes_t = |
||

2259 | | TAttNoArg of { |
||

2260 | id: string } |
||

2261 | | TAttIntArg of { |
||

2262 | id: string ; |
||

2263 | arg: int } |
||

2264 | | TAttValArg of { |
||

2265 | id: string ; |
||

2266 | arg: 'basetype } |
||

2267 | | TAttStringArg of { |
||

2268 | id: string ; |
||

2269 | arg: string } |
||

2270 | |||

2271 | 389493d3 | Arnaud Dieumegard | (* TODO *) |

2272 | 40364f53 | Arnaud Dieumegard | let rec pp_vhdl_type_attributes_t |

2273 | = |
||

2274 | ((let open! Ppx_deriving_runtime in |
||

2275 | fun poly_basetype -> |
||

2276 | fun fmt -> |
||

2277 | function |
||

2278 | | TAttNoArg { id = aid } -> |
||

2279 | (Format.fprintf fmt "@[<2>TAttNoArg {@,"; |
||

2280 | (Format.fprintf fmt "@[%s =@ " "id"; |
||

2281 | (Format.fprintf fmt "%S") aid; |
||

2282 | Format.fprintf fmt "@]"); |
||

2283 | Format.fprintf fmt "@]}") |
||

2284 | | TAttIntArg { id = aid; arg = aarg } -> |
||

2285 | (Format.fprintf fmt "@[<2>TAttIntArg {@,"; |
||

2286 | ((Format.fprintf fmt "@[%s =@ " "id"; |
||

2287 | (Format.fprintf fmt "%S") aid; |
||

2288 | Format.fprintf fmt "@]"); |
||

2289 | Format.fprintf fmt ";@ "; |
||

2290 | Format.fprintf fmt "@[%s =@ " "arg"; |
||

2291 | (Format.fprintf fmt "%d") aarg; |
||

2292 | Format.fprintf fmt "@]"); |
||

2293 | Format.fprintf fmt "@]}") |
||

2294 | | TAttValArg { id = aid; arg = aarg } -> |
||

2295 | (Format.fprintf fmt "@[<2>TAttValArg {@,"; |
||

2296 | ((Format.fprintf fmt "@[%s =@ " "id"; |
||

2297 | (Format.fprintf fmt "%S") aid; |
||

2298 | Format.fprintf fmt "@]"); |
||

2299 | Format.fprintf fmt ";@ "; |
||

2300 | Format.fprintf fmt "@[%s =@ " "arg"; |
||

2301 | (poly_basetype fmt) aarg; |
||

2302 | Format.fprintf fmt "@]"); |
||

2303 | Format.fprintf fmt "@]}") |
||

2304 | | TAttStringArg { id = aid; arg = aarg } -> |
||

2305 | (Format.fprintf fmt "@[<2>TAttStringArg {@,"; |
||

2306 | ((Format.fprintf fmt "@[%s =@ " "id"; |
||

2307 | (Format.fprintf fmt "%S") aid; |
||

2308 | Format.fprintf fmt "@]"); |
||

2309 | Format.fprintf fmt ";@ "; |
||

2310 | Format.fprintf fmt "@[%s =@ " "arg"; |
||

2311 | (Format.fprintf fmt "%S") aarg; |
||

2312 | Format.fprintf fmt "@]"); |
||

2313 | Format.fprintf fmt "@]}")) |
||

2314 | [@ocaml.warning "-A"]) |
||

2315 | |||

2316 | and show_vhdl_type_attributes_t = |
||

2317 | fun poly_basetype -> |
||

2318 | fun x -> |
||

2319 | Format.asprintf "%a" (pp_vhdl_type_attributes_t poly_basetype) x |
||

2320 | |||

2321 | let rec vhdl_type_attributes_t_to_yojson : |
||

2322 | 'basetype . |
||

2323 | ('basetype -> Yojson.Safe.json) -> |
||

2324 | 'basetype vhdl_type_attributes_t -> Yojson.Safe.json |
||

2325 | = |
||

2326 | fun poly_basetype -> |
||

2327 | ((let open! Ppx_deriving_yojson_runtime in |
||

2328 | function |
||

2329 | | TAttNoArg arg0 -> |
||

2330 | `List |
||

2331 | [`String "TAttNoArg"; |
||

2332 | (let fields = [] in |
||

2333 | let fields = |
||

2334 | ("id", |
||

2335 | ((fun (x : Ppx_deriving_runtime.string) -> `String x) |
||

2336 | arg0.id)) |
||

2337 | :: fields in |
||

2338 | `Assoc fields)] |
||

2339 | | TAttIntArg arg0 -> |
||

2340 | `List |
||

2341 | [`String "TAttIntArg"; |
||

2342 | (let fields = [] in |
||

2343 | let fields = |
||

2344 | ("arg", |
||

2345 | ((fun (x : Ppx_deriving_runtime.int) -> `Int x) arg0.arg)) |
||

2346 | :: fields in |
||

2347 | let fields = |
||

2348 | ("id", |
||

2349 | ((fun (x : Ppx_deriving_runtime.string) -> `String x) |
||

2350 | arg0.id)) |
||

2351 | :: fields in |
||

2352 | `Assoc fields)] |
||

2353 | | TAttValArg arg0 -> |
||

2354 | `List |
||

2355 | [`String "TAttValArg"; |
||

2356 | (let fields = [] in |
||

2357 | let fields = |
||

2358 | ("arg", ((poly_basetype : _ -> Yojson.Safe.json) arg0.arg)) |
||

2359 | :: fields in |
||

2360 | let fields = |
||

2361 | ("id", |
||

2362 | ((fun (x : Ppx_deriving_runtime.string) -> `String x) |
||

2363 | arg0.id)) |
||

2364 | :: fields in |
||

2365 | `Assoc fields)] |
||

2366 | | TAttStringArg arg0 -> |
||

2367 | `List |
||

2368 | [`String "TAttStringArg"; |
||

2369 | (let fields = [] in |
||

2370 | let fields = |
||

2371 | ("arg", |
||

2372 | ((fun (x : Ppx_deriving_runtime.string) -> `String x) |
||

2373 | arg0.arg)) |
||

2374 | :: fields in |
||

2375 | let fields = |
||

2376 | ("id", |
||

2377 | ((fun (x : Ppx_deriving_runtime.string) -> `String x) |
||

2378 | arg0.id)) |
||

2379 | :: fields in |
||

2380 | `Assoc fields)]) |
||

2381 | [@ocaml.warning "-A"]) |
||

2382 | |||

2383 | and vhdl_type_attributes_t_of_yojson : |
||

2384 | 'basetype . |
||

2385 | (Yojson.Safe.json -> 'basetype Ppx_deriving_yojson_runtime.error_or) -> |
||

2386 | Yojson.Safe.json -> |
||

2387 | 'basetype vhdl_type_attributes_t Ppx_deriving_yojson_runtime.error_or |
||

2388 | = |
||

2389 | fun poly_basetype -> |
||

2390 | ((let open! Ppx_deriving_yojson_runtime in |
||

2391 | function |
||

2392 | | `List ((`String "TAttNoArg")::arg0::[]) -> |
||

2393 | ((function |
||

2394 | | `Assoc xs -> |
||

2395 | let rec loop xs (arg0 as _state) = |
||

2396 | match xs with |
||

2397 | | ("id",x)::xs -> |
||

2398 | loop xs |
||

2399 | ((function |
||

2400 | | `String x -> Result.Ok x |
||

2401 | | _ -> |
||

2402 | Result.Error |
||

2403 | "Vhdl_ast.vhdl_type_attributes_t.id") x) |
||

2404 | | [] -> |
||

2405 | arg0 >>= |
||

2406 | ((fun arg0 -> Result.Ok (TAttNoArg { id = arg0 }))) |
||

2407 | | _::xs -> loop xs _state in |
||

2408 | loop xs (Result.Error "Vhdl_ast.vhdl_type_attributes_t.id") |
||

2409 | | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0 |
||

2410 | | `List ((`String "TAttIntArg")::arg0::[]) -> |
||

2411 | ((function |
||

2412 | | `Assoc xs -> |
||

2413 | let rec loop xs ((arg0,arg1) as _state) = |
||

2414 | match xs with |
||

2415 | | ("id",x)::xs -> |
||

2416 | loop xs |
||

2417 | (((function |
||

2418 | | `String x -> Result.Ok x |
||

2419 | | _ -> |
||

2420 | Result.Error |
||

2421 | "Vhdl_ast.vhdl_type_attributes_t.id") x), |
||

2422 | arg1) |
||

2423 | | ("arg",x)::xs -> |
||

2424 | loop xs |
||

2425 | (arg0, |
||

2426 | ((function |
||

2427 | | `Int x -> Result.Ok x |
||

2428 | | _ -> |
||

2429 | Result.Error |
||

2430 | "Vhdl_ast.vhdl_type_attributes_t.arg") x)) |
||

2431 | | [] -> |
||

2432 | arg1 >>= |
||

2433 | ((fun arg1 -> |
||

2434 | arg0 >>= |
||

2435 | (fun arg0 -> |
||

2436 | Result.Ok |
||

2437 | (TAttIntArg { id = arg0; arg = arg1 })))) |
||

2438 | | _::xs -> loop xs _state in |
||

2439 | loop xs |
||

2440 | ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"), |
||

2441 | (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg")) |
||

2442 | | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0 |
||

2443 | | `List ((`String "TAttValArg")::arg0::[]) -> |
||

2444 | ((function |
||

2445 | | `Assoc xs -> |
||

2446 | let rec loop xs ((arg0,arg1) as _state) = |
||

2447 | match xs with |
||

2448 | | ("id",x)::xs -> |
||

2449 | loop xs |
||

2450 | (((function |
||

2451 | | `String x -> Result.Ok x |
||

2452 | | _ -> |
||

2453 | Result.Error |
||

2454 | "Vhdl_ast.vhdl_type_attributes_t.id") x), |
||

2455 | arg1) |
||

2456 | | ("arg",x)::xs -> |
||

2457 | loop xs |
||

2458 | (arg0, |
||

2459 | ((poly_basetype : Yojson.Safe.json -> _ error_or) |
||

2460 | x)) |
||

2461 | | [] -> |
||

2462 | arg1 >>= |
||

2463 | ((fun arg1 -> |
||

2464 | arg0 >>= |
||

2465 | (fun arg0 -> |
||

2466 | Result.Ok |
||

2467 | (TAttValArg { id = arg0; arg = arg1 })))) |
||

2468 | | _::xs -> loop xs _state in |
||

2469 | loop xs |
||

2470 | ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"), |
||

2471 | (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg")) |
||

2472 | | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0 |
||

2473 | | `List ((`String "TAttStringArg")::arg0::[]) -> |
||

2474 | ((function |
||

2475 | | `Assoc xs -> |
||

2476 | let rec loop xs ((arg0,arg1) as _state) = |
||

2477 | match xs with |
||

2478 | | ("id",x)::xs -> |
||

2479 | loop xs |
||

2480 | (((function |
||

2481 | | `String x -> Result.Ok x |
||

2482 | | _ -> |
||

2483 | Result.Error |
||

2484 | "Vhdl_ast.vhdl_type_attributes_t.id") x), |
||

2485 | arg1) |
||

2486 | | ("arg",x)::xs -> |
||

2487 | loop xs |
||

2488 | (arg0, |
||

2489 | ((function |
||

2490 | | `String x -> Result.Ok x |
||

2491 | | _ -> |
||

2492 | Result.Error |
||

2493 | "Vhdl_ast.vhdl_type_attributes_t.arg") x)) |
||

2494 | | [] -> |
||

2495 | arg1 >>= |
||

2496 | ((fun arg1 -> |
||

2497 | arg0 >>= |
||

2498 | (fun arg0 -> |
||

2499 | Result.Ok |
||

2500 | (TAttStringArg { id = arg0; arg = arg1 })))) |
||

2501 | | _::xs -> loop xs _state in |
||

2502 | loop xs |
||

2503 | ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"), |
||

2504 | (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg")) |
||

2505 | | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0 |
||

2506 | | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t") |
||

2507 | [@ocaml.warning "-A"]) |
||

2508 | |||

2509 | let typ_att_noarg = ["base"; "left"; "right"; "high"; "low"] |
||

2510 | let typ_att_intarg = ["pos"; "val"; "succ"; "pred"; "leftof"; "rightof"] |
||

2511 | let typ_att_valarg = ["image"] |
||

2512 | let typ_att_stringarg = ["value"] |
||

2513 | let array_att_intarg = |
||

2514 | ["left"; "right"; "high"; "low"; "range"; "reverse_range"; "length"] |
||

2515 | type vhdl_parameter_t = |
||

2516 | { |
||

2517 | names: vhdl_name_t list ; |
||

2518 | mode: string list [@default []]; |
||

2519 | typ: vhdl_subtype_indication_t ; |
||

2520 | 00970bbf | Arnaud Dieumegard | init_val: vhdl_cst_val_t option [@default None]} |

2521 | 40364f53 | Arnaud Dieumegard | |

2522 | 389493d3 | Arnaud Dieumegard | (* TODO *) |

2523 | 40364f53 | Arnaud Dieumegard | let rec pp_vhdl_parameter_t : |

2524 | Format.formatter -> vhdl_parameter_t -> Ppx_deriving_runtime.unit = |
||

2525 | let __2 () = pp_vhdl_cst_val_t |
||

2526 | |||

2527 | and __1 () = pp_vhdl_subtype_indication_t |
||

2528 | |||

2529 | and __0 () = pp_vhdl_name_t |
||

2530 | in |
||

2531 | ((let open! Ppx_deriving_runtime in |
||

2532 | fun fmt -> |
||

2533 | fun x -> |
||

2534 | Format.fprintf fmt "@[<2>{ "; |
||

2535 | ((((Format.fprintf fmt "@[%s =@ " "names"; |
||

2536 | ((fun x -> |
||

2537 | Format.fprintf fmt "@[<2>["; |
||

2538 | ignore |
||

2539 | (List.fold_left |
||

2540 | (fun sep -> |
||

2541 | fun x -> |
||

2542 | if sep then Format.fprintf fmt ";@ "; |
||

2543 | ((__0 ()) fmt) x; |
||

2544 | true) false x); |
||

2545 | Format.fprintf fmt "@,]@]")) x.names; |
||

2546 | Format.fprintf fmt "@]"); |
||

2547 | Format.fprintf fmt ";@ "; |
||

2548 | Format.fprintf fmt "@[%s =@ " "mode"; |
||

2549 | ((fun x -> |
||

2550 | Format.fprintf fmt "@[<2>["; |
||

2551 | ignore |
||

2552 | (List.fold_left |
||

2553 | (fun sep -> |
||

2554 | fun x -> |
||

2555 | if sep then Format.fprintf fmt ";@ "; |
||

2556 | (Format.fprintf fmt "%S") x; |
||

2557 | true) false x); |
||

2558 | Format.fprintf fmt "@,]@]")) x.mode; |
||

2559 | Format.fprintf fmt "@]"); |
||

2560 | Format.fprintf fmt ";@ "; |
||

2561 | Format.fprintf fmt "@[%s =@ " "typ"; |
||

2562 | ((__1 ()) fmt) x.typ; |
||

2563 | Format.fprintf fmt "@]"); |
||

2564 | Format.fprintf fmt ";@ "; |
||

2565 | Format.fprintf fmt "@[%s =@ " "init_val"; |
||

2566 | ((function |
||

2567 | | None -> Format.pp_print_string fmt "None" |
||

2568 | | Some x -> |
||

2569 | (Format.pp_print_string fmt "(Some "; |
||

2570 | ((__2 ()) fmt) x; |
||

2571 | Format.pp_print_string fmt ")"))) x.init_val; |
||

2572 | Format.fprintf fmt "@]"); |
||

2573 | Format.fprintf fmt "@ }@]") |
||

2574 | [@ocaml.warning "-A"]) |
||

2575 | |||

2576 | and show_vhdl_parameter_t : vhdl_parameter_t -> Ppx_deriving_runtime.string = |
||

2577 | fun x -> Format.asprintf "%a" pp_vhdl_parameter_t x |
||

2578 | |||

2579 | let rec (vhdl_parameter_t_to_yojson : vhdl_parameter_t -> Yojson.Safe.json) = |
||

2580 | ((let open! Ppx_deriving_yojson_runtime in |
||

2581 | fun x -> |
||

2582 | let fields = [] in |
||

2583 | let fields = |
||

2584 | 00970bbf | Arnaud Dieumegard | if x.init_val = None |

2585 | 40364f53 | Arnaud Dieumegard | then fields |

2586 | else |
||

2587 | ("init_val", |
||

2588 | (((function |
||

2589 | | None -> `Null |
||

2590 | | Some x -> ((fun x -> vhdl_cst_val_t_to_yojson x)) x)) |
||

2591 | x.init_val)) |
||

2592 | :: fields |
||

2593 | in |
||

2594 | let fields = |
||

2595 | ("typ", ((fun x -> vhdl_subtype_indication_t_to_yojson x) x.typ)) |
||

2596 | :: fields in |
||

2597 | let fields = |
||

2598 | if x.mode = [] |
||

2599 | then fields |
||

2600 | else |
||

2601 | ("mode", |
||

2602 | (((fun x -> |
||

2603 | `List |
||

2604 | (List.map |
||

2605 | (fun (x : Ppx_deriving_runtime.string) -> `String x) |
||

2606 | x))) x.mode)) |
||

2607 | :: fields |
||

2608 | in |
||

2609 | let fields = |
||

2610 | ("names", |
||

2611 | ((fun x -> |
||

2612 | `List (List.map (fun x -> vhdl_name_t_to_yojson x) x)) |
||

2613 | x.names)) |
||

2614 | :: fields in |
||

2615 | `Assoc fields) |
||

2616 | [@ocaml.warning "-A"]) |
||

2617 | |||

2618 | and (vhdl_parameter_t_of_yojson : |
||

2619 | Yojson.Safe.json -> |
||

2620 | vhdl_parameter_t Ppx_deriving_yojson_runtime.error_or) |
||

2621 | = |
||

2622 | ((let open! Ppx_deriving_yojson_runtime in |
||

2623 | function |
||

2624 | | `Assoc xs -> |
||

2625 | let rec loop xs ((arg0,arg1,arg2,arg3) as _state) = |
||

2626 | match xs with |
||

2627 | | ("names",x)::xs -> |
||

2628 | loop xs |
||

2629 | (((function |
||

2630 | | `List xs -> |
||

2631 | map_bind (fun x -> vhdl_name_t_of_yojson x) [] xs |
||

2632 | | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t.names") x), |
||

2633 | arg1, arg2, arg3) |
||

2634 | | ("mode",x)::xs -> |
||

2635 | loop xs |
||

2636 | (arg0, |
||

2637 | ((function |
||

2638 | | `List xs -> |
||

2639 | map_bind |
||

2640 | (function |
||

2641 | | `String x -> Result.Ok x |
||

2642 | | _ -> |
||

2643 | Result.Error |
||

2644 | "Vhdl_ast.vhdl_parameter_t.mode") [] xs |
||

2645 | | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t.mode") x), |
||

2646 | arg2, arg3) |
||

2647 | | ("typ",x)::xs -> |
||

2648 | loop xs |
||

2649 | (arg0, arg1, |
||

2650 | ((fun x -> vhdl_subtype_indication_t_of_yojson x) x), |
||

2651 | arg3) |
||

2652 | | ("init_val",x)::xs -> |
||

2653 | loop xs |
||

2654 | (arg0, arg1, arg2, |
||

2655 | ((function |
||

2656 | | `Null -> Result.Ok None |
||

2657 | | x -> |
||

2658 | ((fun x -> vhdl_cst_val_t_of_yojson x) x) >>= |
||

2659 | ((fun x -> Result.Ok (Some x)))) x)) |
||

2660 | | [] -> |
||

2661 | arg3 >>= |
||

2662 | ((fun arg3 -> |
||

2663 | arg2 >>= |
||

2664 | (fun arg2 -> |
||

2665 | arg1 >>= |
||

2666 | (fun arg1 -> |
||

2667 | arg0 >>= |
||

2668 | (fun arg0 -> |
||

2669 | Result.Ok |
||

2670 | { |
||

2671 | names = arg0; |
||

2672 | mode = arg1; |
||

2673 | typ = arg2; |
||

2674 | init_val = arg3 |
||

2675 | }))))) |
||

2676 | | _::xs -> loop xs _state in |
||

2677 | loop xs |
||

2678 | ((Result.Error "Vhdl_ast.vhdl_parameter_t.names"), |
||

2679 | (Result.Ok []), (Result.Error "Vhdl_ast.vhdl_parameter_t.typ"), |
||

2680 | (Result.Ok (Some (CstInt 0)))) |
||

2681 | | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t") |
||

2682 | [@ocaml.warning "-A"]) |
||

2683 | |||

2684 | type vhdl_subprogram_spec_t = |
||

2685 | { |
||

2686 | name: string [@default ""]; |
||

2687 | typeMark: vhdl_name_t [@default NoName]; |
||

2688 | parameters: vhdl_parameter_t list ; |
||

2689 | isPure: bool [@default false]} |
||

2690 | |||

2691 | 389493d3 | Arnaud Dieumegard | (* TODO *) |

2692 | 40364f53 | Arnaud Dieumegard | let rec pp_vhdl_subprogram_spec_t : |

2693 | Format.formatter -> vhdl_subprogram_spec_t -> Ppx_deriving_runtime.unit = |
||

2694 | let __1 () = pp_vhdl_parameter_t |
||

2695 | |||

2696 | and __0 () = pp_vhdl_name_t |
||

2697 | in |
||

2698 | ((let open! Ppx_deriving_runtime in |
||

2699 | fun fmt -> |
||

2700 | fun x -> |
||

2701 | Format.fprintf fmt "@[<2>{ "; |
||

2702 | ((((Format.fprintf fmt "@[%s =@ " "name"; |
||

2703 | (Format.fprintf fmt "%S") x.name; |
||

2704 | Format.fprintf fmt "@]"); |
||

2705 | Format.fprintf fmt ";@ "; |
||

2706 | Format.fprintf fmt "@[%s =@ " "typeMark"; |
||

2707 | ((__0 ()) fmt) x.typeMark; |
||

2708 | Format.fprintf fmt "@]"); |
||

2709 | Format.fprintf fmt ";@ "; |
||

2710 | Format.fprintf fmt "@[%s =@ " "parameters"; |
||

2711 | ((fun x -> |
||

2712 | Format.fprintf fmt "@[<2>["; |
||

2713 | ignore |
||

2714 | (List.fold_left |
||

2715 | (fun sep -> |
||

2716 | fun x -> |
||

2717 | if sep then Format.fprintf fmt ";@ "; |
||

2718 | ((__1 ()) fmt) x; |
||

2719 | true) false x); |
||

2720 | Format.fprintf fmt "@,]@]")) x.parameters; |
||

2721 | Format.fprintf fmt "@]"); |
||

2722 | Format.fprintf fmt ";@ "; |
||

2723 | Format.fprintf fmt "@[%s =@ " "isPure"; |
||

2724 | (Format.fprintf fmt "%B") x.isPure; |
||

2725 | Format.fprintf fmt "@]"); |
||

2726 | Format.fprintf fmt "@ }@]") |
||

2727 | [@ocaml.warning "-A"]) |
||

2728 | |||

2729 | and show_vhdl_subprogram_spec_t : |
||

2730 | vhdl_subprogram_spec_t -> Ppx_deriving_runtime.string = |
||

2731 | fun x -> Format.asprintf "%a" pp_vhdl_subprogram_spec_t x |
||

2732 | |||

2733 | let rec (vhdl_subprogram_spec_t_to_yojson : |
||

2734 | vhdl_subprogram_spec_t -> Yojson.Safe.json) |
||

2735 | = |
||

2736 | ((let open! Ppx_deriving_yojson_runtime in |
||

2737 | fun x -> |
||

2738 | let fields = [] in |
||

2739 | let fields = |
||

2740 | if x.isPure = false |
||

2741 | then fields |
||

2742 | else |
||

2743 | ("isPure", |
||

2744 | (((fun (x : Ppx_deriving_runtime.bool) -> `Bool x)) x.isPure)) |
||

2745 | :: fields |
||

2746 | in |
||

2747 | let fields = |
||

2748 | 32614c2d | Arnaud Dieumegard | if x.parameters = [] |

2749 | then fields |
||

2750 | else |
||

2751 | ("parameters", |
||

2752 | (((fun x -> |
||

2753 | `List |
||

2754 | (List.map (fun x -> vhdl_parameter_t_to_yojson x) x))) |
||

2755 | x.parameters)) |
||

2756 | :: fields |
||

2757 | in |
||

2758 | 40364f53 | Arnaud Dieumegard | let fields = |

2759 | if x.typeMark = NoName |
||

2760 | then fields |
||

2761 | else |
||

2762 | ("typeMark", (((fun x -> vhdl_name_t_to_yojson x)) x.typeMark)) |
||

2763 | :: fields |
||

2764 | in |
||

2765 | let fields = |
||

2766 | if x.name = "" |
||

2767 | then fields |
||

2768 | else |
||

2769 | ("name", |
||

2770 | (((fun (x : Ppx_deriving_runtime.string) -> `String x)) x.name)) |
||

2771 | :: fields |
||

2772 | in |
||

2773 | `Assoc fields) |
||

2774 | [@ocaml.warning "-A"]) |
||

2775 | |||

2776 | and (vhdl_subprogram_spec_t_of_yojson : |
||

2777 | Yojson.Safe.json -> |
||

2778 | vhdl_subprogram_spec_t Ppx_deriving_yojson_runtime.error_or) |
||

2779 | = |
||

2780 | ((let open! Ppx_deriving_yojson_runtime in |
||

2781 | function |
||

2782 | | `Assoc xs -> |
||

2783 | let rec loop xs ((arg0,arg1,arg2,arg3) as _state) = |
||

2784 | match xs with |
||

2785 | | ("name",x)::xs -> |
||

2786 | loop xs |
||

2787 | (((function |
||

2788 | | `String x -> Result.Ok x |
||

2789 | | _ -> |
||

2790 | Result.Error "Vhdl_ast.vhdl_subprogram_spec_t.name") |
||

2791 | x), arg1, arg2, arg3) |
||

2792 | | ("typeMark",x)::xs -> |
||

2793 | loop xs |
||

2794 | (arg0, ((fun x -> vhdl_name_t_of_yojson x) x), arg2, arg3) |
||

2795 | | ("parameters",x)::xs -> |
||

2796 | loop xs |
||

2797 | (arg0, arg1, |
||

2798 | ((function |
||

2799 | | `List xs -> |
||

2800 | map_bind (fun x -> vhdl_parameter_t_of_yojson x) |
||

2801 | [] xs |
||

2802 | | _ -> |
||

2803 | Result.Error |
||

2804 | "Vhdl_ast.vhdl_subprogram_spec_t.parameters") x), |
||

2805 | arg3) |
||

2806 | | ("isPure",x)::xs -> |
||

2807 | loop xs |
||

2808 | (arg0, arg1, arg2, |
||

2809 | ((function |
||

2810 | | `Bool x -> Result.Ok x |
||

2811 | | _ -> |
||

2812 | Result.Error |
||

2813 | "Vhdl_ast.vhdl_subprogram_spec_t.isPure") x)) |
||

2814 | | [] -> |
||

2815 | arg3 >>= |
||

2816 | ((fun arg3 -> |
||

2817 | arg2 >>= |
||

2818 | (fun arg2 -> |
||

2819 | arg1 >>= |
||

2820 | (fun arg1 -> |
||

2821 | arg0 >>= |
||

2822 | (fun arg0 -> |
||

2823 | Result.Ok |
||

2824 | { |
||

2825 | name = arg0; |
||

2826 | typeMark = arg1; |
||

2827 | parameters = arg2; |
||

2828 | isPure = arg3 |
||

2829 | }))))) |
||

2830 | | _::xs -> loop xs _state in |
||

2831 | loop xs |
||

2832 | 32614c2d | Arnaud Dieumegard | ((Result.Ok ""), (Result.Ok NoName), (Result.Ok []), |

2833 | 40364f53 | Arnaud Dieumegard | (Result.Ok false)) |

2834 | | _ -> Result.Error "Vhdl_ast.vhdl_subprogram_spec_t") |
||

2835 | [@ocaml.warning "-A"]) |
||

2836 | |||

2837 | let arith_funs = ["+"; "-"; "*"; "/"; "mod"; "rem"; "abs"; "**"; "&"] |
||

2838 | let bool_funs = ["and"; "or"; "nand"; "nor"; "xor"; "not"] |
||

2839 | let rel_funs = |
||

2840 | ["<"; |
||

2841 | ">"; |
||

2842 | "<="; |
||

2843 | ">="; |
||

2844 | "/="; |
||

2845 | "="; |
||

2846 | "?="; |
||

2847 | "?/="; |
||

2848 | "?<"; |
||

2849 | "?<="; |
||

2850 | "?>"; |
||

2851 | "?>="; |
||

2852 | "??"] |
||

2853 | let shift_funs = ["sll"; "srl"; "sla"; "sra"; "rol"; "ror"] |
||

2854 | type vhdl_sequential_stmt_t = |
||

2855 | | VarAssign of |
||

2856 | { |
||

2857 | label: vhdl_name_t [@default NoName]; |
||

2858 | lhs: vhdl_name_t ; |
||

2859 | rhs: vhdl_expr_t } [@name "VARIABLE_ASSIGNMENT_STATEMENT"] |
||

2860 | | SigSeqAssign of |
||

2861 | { |
||

2862 | label: vhdl_name_t [@default NoName]; |
||

2863 | lhs: vhdl_name_t ; |
||

2864 | rhs: vhdl_expr_t list } [@name "SIGNAL_ASSIGNMENT_STATEMENT"] |
||

2865 | | If of |
||

2866 | { |
||

2867 | label: vhdl_name_t [@default NoName]; |
||

2868 | if_cases: vhdl_if_case_t list ; |
||

2869 | default: vhdl_sequential_stmt_t list [@default []]} [@name "IF_STATEMENT"] |
||

2870 | | Case of |
||

2871 | { |
||

2872 | label: vhdl_name_t [@default NoName]; |
||

2873 | guard: vhdl_expr_t ; |
||

2874 | branches: vhdl_case_item_t list } [@name "CASE_STATEMENT_TREE"] |
||

2875 | | Exit of |
||

2876 | { |
||

2877 | label: vhdl_name_t [@default NoName]; |
||

2878 | loop_label: string option [@default Some ""]; |
||

2879 | condition: vhdl_expr_t option [@default Some IsNull]} |
||

2880 | [@name "EXIT_STATEMENT"] |
||

2881 | | Assert of |
||

2882 | { |
||

2883 | label: vhdl_name_t [@default NoName]; |
||

2884 | cond: vhdl_expr_t ; |
||

2885 | report: vhdl_expr_t [@default IsNull]; |
||

2886 | severity: vhdl_expr_t [@default IsNull]} [@name "ASSERTION_STATEMENT"] |
||

2887 | 6d3b5007 | Arnaud Dieumegard | | ProcedureCall of |

2888 | { |
||

2889 | label: vhdl_name_t [@default NoName]; |
||

2890 | name: vhdl_name_t ; |
||

2891 | assocs: vhdl_assoc_element_t list } [@name "PROCEDURE_CALL_STATEMENT"] |
||

2892 | 40364f53 | Arnaud Dieumegard | | Wait [@name "WAIT_STATEMENT"] |

2893 | | Null of { |
||

2894 | label: vhdl_name_t [@default NoName]} [@name "NULL_STATEMENT"] |
||

2895 | | Return of { |
||

2896 | label: vhdl_name_t [@default NoName]} [@name "RETURN_STATEMENT"] |
||

2897 | and vhdl_if_case_t = |
||

2898 | { |
||

2899 | if_cond: vhdl_expr_t ; |
||

2900 | if_block: vhdl_sequential_stmt_t list } |
||

2901 | and vhdl_case_item_t = |
||

2902 | { |
||

2903 | when_cond: vhdl_expr_t list ; |
||

2904 | when_stmt: vhdl_sequential_stmt_t list } |
||

2905 | |||

2906 | let rec pp_vhdl_sequential_stmt_t : |
||

2907 | Format.formatter -> vhdl_sequential_stmt_t -> Ppx_deriving_runtime.unit = |
||

2908 | 6d3b5007 | Arnaud Dieumegard | let __22 () = pp_vhdl_name_t |

2909 | |||

2910 | and __21 () = pp_vhdl_name_t |
||

2911 | |||

2912 | and __20 () = pp_vhdl_assoc_element_t |
||

2913 | |||

2914 | and __19 () = pp_vhdl_name_t |
||

2915 | 40364f53 | Arnaud Dieumegard | |

2916 | and __18 () = pp_vhdl_name_t |
||

2917 | |||

2918 | and __17 () = pp_vhdl_expr_t |
||

2919 | |||

2920 | and __16 () = pp_vhdl_expr_t |
||

2921 | |||

2922 | and __15 () = pp_vhdl_expr_t |
||

2923 | |||

2924 | and __14 () = pp_vhdl_name_t |
||

2925 | |||

2926 | and __13 () = pp_vhdl_expr_t |
||

2927 | |||

2928 | and __12 () = pp_vhdl_name_t |
||

2929 | |||

2930 | and __11 () = pp_vhdl_case_item_t |
||

2931 | |||

2932 | and __10 () = pp_vhdl_expr_t |
||

2933 | |||

2934 | and __9 () = pp_vhdl_name_t |
||

2935 | |||

2936 | and __8 () = pp_vhdl_sequential_stmt_t |
||

2937 | |||

2938 | and __7 () = pp_vhdl_if_case_t |
||

2939 | |||

2940 | and __6 () = pp_vhdl_name_t |
||

2941 | |||

2942 | and __5 () = pp_vhdl_expr_t |
||

2943 | |||

2944 | and __4 () = pp_vhdl_name_t |
||

2945 | |||

2946 | and __3 () = pp_vhdl_name_t |
||

2947 | |||

2948 | and __2 () = pp_vhdl_expr_t |
||

2949 | |||

2950 | and __1 () = pp_vhdl_name_t |
||

2951 | |||

2952 | and __0 () = pp_vhdl_name_t |
||

2953 | in |
||

2954 | ((let open! Ppx_deriving_runtime in |
||

2955 | fun fmt -> |
||

2956 | function |
||

2957 | | VarAssign { label = alabel; lhs = alhs; rhs = arhs } -> |
||

2958 | f779d524 | Arnaud Dieumegard | (match alabel with |

2959 | | NoName -> Format.fprintf fmt ""; |
||

2960 | | _ -> (((__0 ()) fmt) alabel; |
||

2961 | 1f15a1b9 | Arnaud Dieumegard | Format.fprintf fmt ": ") |

2962 | f779d524 | Arnaud Dieumegard | ); |

2963 | ((__1 ()) fmt) alhs; |
||

2964 | 1f15a1b9 | Arnaud Dieumegard | Format.fprintf fmt " := "; |

2965 | f779d524 | Arnaud Dieumegard | ((__2 ()) fmt) arhs; |

2966 | (* TODO: Check |
||

2967 | 40364f53 | Arnaud Dieumegard | (Format.fprintf fmt "@[<2>VarAssign {@,"; |

2968 | (((Format.fprintf fmt "@[%s =@ " "label"; |
||

2969 | ((__0 ()) fmt) alabel; |
||

2970 | Format.fprintf fmt "@]"); |
||

2971 | Format.fprintf fmt ";@ "; |
||

2972 | Format.fprintf fmt "@[%s =@ " "lhs"; |
||

2973 | ((__1 ()) fmt) alhs; |
||

2974 | Format.fprintf fmt "@]"); |
||

2975 | Format.fprintf fmt ";@ "; |
||

2976 | Format.fprintf fmt "@[%s =@ " "rhs"; |
||

2977 | ((__2 ()) fmt) arhs; |
||

2978 | Format.fprintf fmt "@]"); |
||

2979 | f779d524 | Arnaud Dieumegard | Format.fprintf fmt "@]}") *) |

2980 | 40364f53 | Arnaud Dieumegard | | SigSeqAssign { label = alabel; lhs = alhs; rhs = arhs } -> |

2981 | f779d524 | Arnaud Dieumegard | (match alabel with |

2982 | | NoName -> Format.fprintf fmt ""; |
||

2983 | | _ -> (((__3 ()) fmt) alabel; |
||

2984 | Format.fprintf fmt ":@ ") |
||

2985 | ); |
||

2986 | Format.fprintf fmt "@[<2>"; |
||

2987 | ((__4 ()) fmt) alhs; |
||

2988 | Format.fprintf fmt "@ <=@ "; |
||

2989 | ((fun x -> |
||

2990 | Format.fprintf fmt "@["; |
||

2991 | ignore |
||

2992 | (List.fold_left |
||

2993 | (fun sep -> |
||

2994 | fun x -> |
||

2995 | if sep then Format.fprintf fmt ""; |
||

2996 | ((__5 ()) fmt) x; |
||

2997 | true) false x); |
||

2998 | 00970bbf | Arnaud Dieumegard | Format.fprintf fmt "@]@]")) arhs; |

2999 | 40364f53 | Arnaud Dieumegard | | If { label = alabel; if_cases = aif_cases; default = adefault } -> |

3000 | f779d524 | Arnaud Dieumegard | (match alabel with |

3001 | | NoName -> Format.fprintf fmt ""; |
||

3002 | | _ -> (((__6 ()) fmt) alabel; |
||

3003 | Format.fprintf fmt ":@ ") |
||

3004 | ); |
||

3005 | Format.fprintf fmt "@[<v>if"; |
||

3006 | ((fun x -> |
||

3007 | ignore |
||

3008 | (List.fold_left |
||

3009 | (fun sep -> |
||

3010 | fun x -> |
||

3011 | if sep then Format.fprintf fmt "@;elseif"; |
||

3012 | ((__7 ()) fmt) x; |
||

3013 | true |
||

3014 | ) false x); |
||

3015 | )) aif_cases; |
||

3016 | 00970bbf | Arnaud Dieumegard | (match adefault with |

3017 | f779d524 | Arnaud Dieumegard | | [] -> Format.fprintf fmt ""; |

3018 | | _ -> (Format.fprintf fmt "@;else"; |
||

3019 | ((fun x -> |
||

3020 | Format.fprintf fmt "@;<0 2>"; |
||

3021 | ignore |
||

3022 | (List.fold_left |
||

3023 | (fun sep -> |
||

3024 | fun x -> |
||

3025 | if sep then Format.fprintf fmt ""; |
||

3026 | ((__8 ()) fmt) x; |
||

3027 | 00970bbf | Arnaud Dieumegard | true) false x))) adefault)); |

3028 | Format.fprintf fmt "@;end if;@]" |
||

3029 | 40364f53 | Arnaud Dieumegard | | Case { label = alabel; guard = aguard; branches = abranches } -> |

3030 | f779d524 | Arnaud Dieumegard | (match alabel with |

3031 | | NoName -> Format.fprintf fmt ""; |
||

3032 | | _ -> (((__9 ()) fmt) alabel; |
||

3033 | Format.fprintf fmt ":@ ") |
||

3034 | ); |
||

3035 | Format.fprintf fmt "@[<v>case "; |
||

3036 | ((__10 ()) fmt) aguard; |
||

3037 | Format.fprintf fmt " is"; |
||

3038 | ((fun x -> |
||

3039 | ignore |
||

3040 | (List.fold_left |
||

3041 | (fun sep -> |
||

3042 | fun x -> |
||

3043 | if sep then Format.fprintf fmt ""; |
||

3044 | ((__11 ()) fmt) x; |
||

3045 | true) false x);)) abranches; |
||

3046 | 00970bbf | Arnaud Dieumegard | Format.fprintf fmt "@;end case;@]"; |

3047 | 40364f53 | Arnaud Dieumegard | | Exit |

3048 | { label = alabel; loop_label = aloop_label; |
||

3049 | condition = acondition } |
||

3050 | -> |
||

3051 | 52323a31 | Arnaud Dieumegard | (match alabel with |

3052 | | NoName -> Format.fprintf fmt ""; |
||

3053 | | _ -> (((__12 ()) fmt) alabel; |
||

3054 | Format.fprintf fmt ":@ ") |
||

3055 | ); |
||

3056 | Format.fprintf fmt "exit"; |
||

3057 | (match aloop_label with |
||

3058 | | None -> Format.pp_print_string fmt "" |
||

3059 | | Some x -> (Format.fprintf fmt "@ %s@ย ") x); |
||

3060 | ((function |
||

3061 | | None -> Format.pp_print_string fmt "" |
||

3062 | | Some x -> |
||

3063 | (Format.pp_print_string fmt "when@ "; |
||

3064 | ((__13 ()) fmt) x;))) acondition; |
||

3065 | 40364f53 | Arnaud Dieumegard | | Assert |

3066 | { label = alabel; cond = acond; report = areport; |
||

3067 | severity = aseverity } |
||

3068 | -> |
||

3069 | 21b75edb | Arnaud Dieumegard | Format.fprintf fmt "@[<v 2>"; |

3070 | (match alabel with |
||

3071 | | NoName -> Format.fprintf fmt ""; |
||

3072 | | _ -> (((__14 ()) fmt) alabel; |
||

3073 | Format.fprintf fmt ":@ ") |
||

3074 | ); |
||

3075 | Format.fprintf fmt "assert "; |
||

3076 | ((__15 ()) fmt) acond; |
||

3077 | (match areport with |
||

3078 | | IsNull -> Format.fprintf fmt ""; |
||

3079 | | _ -> |
||

3080 | Format.fprintf fmt "@;report "; |
||

3081 | ((__16 ()) fmt) areport); |
||

3082 | (match aseverity with |
||

3083 | | IsNull -> Format.fprintf fmt ""; |
||

3084 | | _ -> |
||

3085 | Format.fprintf fmt "@;severity "; |
||

3086 | ((__17 ()) fmt) aseverity); |
||

3087 | Format.fprintf fmt "@]"; |
||

3088 | 6d3b5007 | Arnaud Dieumegard | | ProcedureCall { label = alabel; name = aname; assocs = aassocs } -> |

3089 | (match alabel with |
||

3090 | | NoName -> Format.fprintf fmt ""; |
||

3091 | | _ -> (((__18 ()) fmt) alabel; |
||

3092 | Format.fprintf fmt ":@ ") |
||

3093 | ); |
||

3094 | ((__19 ()) fmt) aname; |
||

3095 | 32614c2d | Arnaud Dieumegard | (match aassocs with |

3096 | | [] -> Format.fprintf fmt ""; |
||

3097 | | _ -> |
||

3098 | ((fun x -> |
||

3099 | 6d3b5007 | Arnaud Dieumegard | Format.fprintf fmt "("; |

3100 | ignore |
||

3101 | (List.fold_left |
||

3102 | (fun sep -> |
||

3103 | fun x -> |
||

3104 | if sep then Format.fprintf fmt ",@ "; |
||

3105 | ((__20 ()) fmt) x; |
||

3106 | true) false x); |
||

3107 | 32614c2d | Arnaud Dieumegard | Format.fprintf fmt ")")) aassocs); |

3108 | 52323a31 | Arnaud Dieumegard | | Wait -> Format.pp_print_string fmt "wait" |

3109 | 40364f53 | Arnaud Dieumegard | | Null { label = alabel } -> |

3110 | 52323a31 | Arnaud Dieumegard | (match alabel with |

3111 | | NoName -> Format.fprintf fmt ""; |
||

3112 | | _ -> (((__18 ()) fmt) alabel; |
||

3113 | Format.fprintf fmt ":@ ") |
||

3114 | ); |
||

3115 | Format.fprintf fmt "null"; |
||

3116 | 40364f53 | Arnaud Dieumegard | | Return { label = alabel } -> |

3117 | 52323a31 | Arnaud Dieumegard | (match alabel with |

3118 | | NoName -> Format.fprintf fmt ""; |
||

3119 | | _ -> (((__19 ()) fmt) alabel; |
||

3120 | Format.fprintf fmt ":@ ") |
||

3121 | ); |
||

3122 | Format.fprintf fmt "return";) |
||

3123 | 40364f53 | Arnaud Dieumegard | [@ocaml.warning "-A"]) |

3124 | |||

3125 | and show_vhdl_sequential_stmt_t : |
||

3126 | vhdl_sequential_stmt_t -> Ppx_deriving_runtime.string = |
||

3127 | fun x -> Format.asprintf "%a" pp_vhdl_sequential_stmt_t x |
||

3128 | |||

3129 | and pp_vhdl_if_case_t : |
||

3130 | Format.formatter -> vhdl_if_case_t -> Ppx_deriving_runtime.unit = |
||

3131 | let __1 () = pp_vhdl_sequential_stmt_t |
||

3132 | |||

3133 | and __0 () = pp_vhdl_expr_t |
||

3134 | in |
||

3135 | ((let open! Ppx_deriving_runtime in |
||

3136 | fun fmt -> |
||

3137 | fun x -> |
||

3138 | f779d524 | Arnaud Dieumegard | Format.fprintf fmt " ("; |

3139 | ((__0 ()) fmt) x.if_cond; |
||

3140 | Format.fprintf fmt ") then@;<0 2>"; |
||

3141 | ((fun x -> |
||

3142 | ignore |
||

3143 | (List.fold_left |
||

3144 | (fun sep -> |
||

3145 | fun x -> |
||

3146 | if sep then Format.fprintf fmt "@;<0 2>"; |
||

3147 | ((__1 ()) fmt) x; |
||

3148 | true) false x); |
||

3149 | )) x.if_block;) |
||

3150 | 40364f53 | Arnaud Dieumegard | [@ocaml.warning "-A"]) |

3151 | |||

3152 | and show_vhdl_if_case_t : vhdl_if_case_t -> Ppx_deriving_runtime.string = |
||

3153 | fun x -> Format.asprintf "%a" pp_vhdl_if_case_t x |
||

3154 | |||

3155 | and pp_vhdl_case_item_t : |
||

3156 | Format.formatter -> vhdl_case_item_t -> Ppx_deriving_runtime.unit = |
||

3157 | let __1 () = pp_vhdl_sequential_stmt_t |
||

3158 | |||

3159 | and __0 () = pp_vhdl_expr_t |
||

3160 | in |
||

3161 | ((let open! Ppx_deriving_runtime in |
||

3162 | fun fmt -> |
||

3163 | fun x -> |
||

3164 | 1f15a1b9 | Arnaud Dieumegard | Format.fprintf fmt "@;@[<v 2>when "; |

3165 | 40364f53 | Arnaud Dieumegard | ((fun x -> |

3166 | ignore |
||

3167 | (List.fold_left |
||

3168 | (fun sep -> |
||

3169 | fun x -> |
||

3170 | f779d524 | Arnaud Dieumegard | if sep then Format.fprintf fmt "@ |@ "; |

3171 | 40364f53 | Arnaud Dieumegard | ((__0 ()) fmt) x; |

3172 | f779d524 | Arnaud Dieumegard | true) false x);)) x.when_cond; |

3173 | Format.fprintf fmt "ย =>ย "; |
||

3174 | 1f15a1b9 | Arnaud Dieumegard | (fun x -> |

3175 | 40364f53 | Arnaud Dieumegard | ignore |

3176 | (List.fold_left |
||

3177 | (fun sep -> |
||

3178 | fun x -> |
||

3179 | 1f15a1b9 | Arnaud Dieumegard | if sep then Format.fprintf fmt "@;"; |

3180 | 40364f53 | Arnaud Dieumegard | ((__1 ()) fmt) x; |

3181 | 1f15a1b9 | Arnaud Dieumegard | Format.fprintf fmt ";"; |

3182 | true) ((List.length x) > 1) x);) x.when_stmt; |
||

3183 | Format.fprintf fmt "@]") |
||

3184 | 40364f53 | Arnaud Dieumegard | [@ocaml.warning "-A"]) |

3185 | |||

3186 | and show_vhdl_case_item_t : vhdl_case_item_t -> Ppx_deriving_runtime.string = |
||

3187 | fun x -> Format.asprintf "%a" pp_vhdl_case_item_t x |
||

3188 | |||

3189 | let rec (vhdl_sequential_stmt_t_to_yojson : |
||

3190 | vhdl_sequential_stmt_t -> Yojson.Safe.json) |
||

3191 | = |
||

3192 | ((let open! Ppx_deriving_yojson_runtime in |
||

3193 | function |
||

3194 | | VarAssign arg0 -> |
||

3195 | `List |
||

3196 | [`String "VARIABLE_ASSIGNMENT_STATEMENT"; |
||

3197 | (let fields = [] in |
||

3198 | let fields = |
||

3199 | ("rhs", ((fun x -> vhdl_expr_t_to_yojson x) arg0.rhs)) :: |
||

3200 | fields in |
||

3201 | let fields = |
||

3202 | ("lhs", ((fun x -> vhdl_name_t_to_yojson x) arg0.lhs)) :: |
||

3203 | fields in |
||

3204 | let fields = |
||

3205 | if arg0.label = NoName |
||

3206 | then fields |
||

3207 | else |
||

3208 | ("label", |
||

3209 | (((fun x -> vhdl_name_t_to_yojson x)) arg0.label)) |
||

3210 | :: fields |
||

3211 | in |
||

3212 | `Assoc fields)] |
||

3213 | | SigSeqAssign arg0 -> |
||

3214 | `List |
||

3215 | [`String "SIGNAL_ASSIGNMENT_STATEMENT"; |
||

3216 | (let fields = [] in |
||

3217 | let fields = |
||

3218 | ("rhs", |
||

3219 | ((fun x -> |
||

3220 | `List (List.map (fun x -> vhdl_expr_t_to_yojson x) x)) |
||

3221 | arg0.rhs)) |
||

3222 | :: fields in |
||

3223 | let fields = |
||

3224 | ("lhs", ((fun x -> vhdl_name_t_to_yojson x) arg0.lhs)) :: |
||

3225 | fields in |
||

3226 | let fields = |
||

3227 | if arg0.label = NoName |
||

3228 | then fields |
||

3229 | else |
||

3230 | ("label", |
||

3231 | (((fun x -> vhdl_name_t_to_yojson x)) arg0.label)) |
||

3232 | :: fields |
||

3233 | in |
||

3234 | `Assoc fields)] |
||

3235 | | If arg0 -> |
||

3236 | `List |
||

3237 | [`String "IF_STATEMENT"; |
||

3238 | (let fields = [] in |
||

3239 | let fields = |
||

3240 | if arg0.default = [] |
||

3241 | then fields |
||

3242 | else |
||

3243 | ("default", |
||

3244 | (((fun x -> |
||

3245 | `List |
||

3246 | (List.map |
||

3247 | (fun x -> vhdl_sequential_stmt_t_to_yojson x) x))) |
||

3248 | arg0.default)) |
||

3249 | :: fields |
||

3250 | in |
||

3251 | let fields = |
||

3252 | ("if_cases", |
||

3253 | ((fun x -> |
||

3254 | `List |
||

3255 | (List.map (fun x -> vhdl_if_case_t_to_yojson x) x)) |
||

3256 | arg0.if_cases)) |
||

3257 | :: fields in |
||

3258 | let fields = |
||

3259 | if arg0.label = NoName |
||

3260 | then fields |
||

3261 | else |
||

3262 | ("label", |
||

3263 | (((fun x -> vhdl_name_t_to_yojson x)) arg0.label)) |
||

3264 | :: fields |
||

3265 | in |
||

3266 | `Assoc fields)] |
||

3267 | | Case arg0 -> |
||

3268 | `List |
||

3269 | [`String "CASE_STATEMENT_TREE"; |
||

3270 | (let fields = [] in |
||

3271 | let fields = |
||

3272 | ("branches", |
||

3273 | ((fun x -> |
||

3274 | `List |
||

3275 | (List.map (fun x -> vhdl_case_item_t_to_yojson x) x)) |
||

3276 | arg0.branches)) |
||

3277 | :: fields in |
||

3278 | let fields = |
||

3279 | ("guard", ((fun x -> vhdl_expr_t_to_yojson x) arg0.guard)) :: |
||

3280 | fields in |
||

3281 | let fields = |
||

3282 | if arg0.label = NoName |
||

3283 | then fields |
||

3284 | else |
||

3285 | ("label", |
||

3286 | (((fun x -> vhdl_name_t_to_yojson x)) arg0.label)) |
||

3287 | :: fields |
||

3288 | in |
||

3289 | `Assoc fields)] |
||

3290 | | Exit arg0 -> |
||

3291 | `List |
||

3292 | [`String "EXIT_STATEMENT"; |
||

3293 | (let fields = [] in |
||

3294 | let fields = |
||

3295 | if arg0.condition = (Some IsNull) |
||

3296 | then fields |
||

3297 | else |
||

3298 | ("condition", |
||

3299 | (((function |
||

3300 | | None -> `Null |
||

3301 | | Some x -> ((fun x -> vhdl_expr_t_to_yojson x)) x)) |
||

3302 | arg0.condition)) |
||

3303 | :: fields |
||

3304 | in |
||

3305 | let fields = |
||

3306 | if arg0.loop_label = (Some "") |
||

3307 | then fields |
||

3308 | else |
||

3309 | ("loop_label", |
||

3310 | (((function |
||

3311 | | None -> `Null |
||

3312 | | Some x -> |
||

3313 | ((fun (x : Ppx_deriving_runtime.string) -> |
||

3314 | `String x)) x)) arg0.loop_label)) |
||

3315 | :: fields |
||

3316 | in |
||

3317 | let fields = |
||

3318 | if arg0.label = NoName |
||

3319 | then fields |
||

3320 | else |
||

3321 | ("label", |
||

3322 | (((fun x -> vhdl_name_t_to_yojson x)) arg0.label)) |
||

3323 | :: fields |
||

3324 | in |
||

3325 | `Assoc fields)] |
||

3326 | | Assert arg0 -> |
||

3327 | `List |
||

3328 | [`String "ASSERTION_STATEMENT"; |
||

3329 | (let fields = [] in |
||

3330 | let fields = |
||

3331 | if arg0.severity = IsNull |
||

3332 | then fields |
||

3333 | else |
||

3334 | ("severity", |
||

3335 | (((fun x -> vhdl_expr_t_to_yojson x)) arg0.severity)) |
||

3336 | :: fields |
||

3337 | in |
||

3338 | let fields = |
||

3339 | if arg0.report = IsNull |
||

3340 | then fields |
||

3341 | else |
||

3342 | ("report", |
||

3343 | (((fun x -> vhdl_expr_t_to_yojson x)) arg0.report)) |
||

3344 | :: fields |
||

3345 | in |
||

3346 | let fields = |
||

3347 | ("cond", ((fun x -> vhdl_expr_t_to_yojson x) arg0.cond)) :: |
||

3348 | fields in |
||

3349 | let fields = |
||

3350 | if arg0.label = NoName |
||

3351 | then fields |
||

3352 | else |
||

3353 | ("label", |
||

3354 | (((fun x -> vhdl_name_t_to_yojson x)) arg0.label)) |
||

3355 | :: fields |
||

3356 | in |
||

3357 | `Assoc fields)] |
||

3358 | 6d3b5007 | Arnaud Dieumegard | | ProcedureCall arg0 -> |

3359 | `List |
||

3360 | [`String "PROCEDURE_CALL_STATEMENT"; |
||

3361 | (let fields = [] in |
||

3362 | let fields = |
||

3363 | 32614c2d | Arnaud Dieumegard | if arg0.assocs = [] |

3364 | then fields |
||

3365 | else |
||

3366 | ("assocs", |
||

3367 | (((fun x -> |
||

3368 | `List |
||

3369 | (List.map |
||

3370 | (fun x -> vhdl_assoc_element_t_to_yojson x) x))) |
||

3371 | arg0.assocs)) |
||

3372 | :: fields |
||

3373 | in |
||

3374 | 6d3b5007 | Arnaud Dieumegard | let fields = |

3375 | ("name", ((fun x -> vhdl_name_t_to_yojson x) arg0.name)) :: |
||

3376 | fields in |
||

3377 | let fields = |
||

3378 | if arg0.label = NoName |
||

3379 | then fields |
||

3380 | else |
||

3381 | ("label", |
||

3382 | (((fun x -> vhdl_name_t_to_yojson x)) arg0.label)) |
||

3383 | :: fields |
||

3384 | in |
||

3385 | `Assoc fields)] |
||

3386 | 40364f53 | Arnaud Dieumegard | | Wait -> `List [`String "WAIT_STATEMENT"] |

3387 | | Null arg0 -> |
||

3388 | `List |
||

3389 | [`String "NULL_STATEMENT"; |
||

3390 | (let fields = [] in |
||

3391 | let fields = |
||

3392 | if arg0.label = NoName |
||

3393 | then fields |
||

3394 | else |
||

3395 | ("label", |
||

3396 | (((fun x -> vhdl_name_t_to_yojson x)) arg0.label)) |
||

3397 | :: fields |
||

3398 | in |
||

3399 | `Assoc fields)] |
||

3400 | | Return arg0 -> |
||

3401 | `List |
||

3402 | [`String "RETURN_STATEMENT"; |
||

3403 | (let fields = [] in |
||

3404 | let fields = |
||

3405 | if arg0.label = NoName |
||

3406 | then fields |
||

3407 | else |
||

3408 | ("label", |
||

3409 | (((fun x -> vhdl_name_t_to_yojson x)) arg0.label)) |
||

3410 | :: fields |
||

3411 | in |
||

3412 | `Assoc fields)]) |
||

3413 | [@ocaml.warning "-A"]) |
||

3414 | |||

3415 | and (vhdl_sequential_stmt_t_of_yojson : |
||

3416 | Yojson.Safe.json -> |
||

3417 | vhdl_sequential_stmt_t Ppx_deriving_yojson_runtime.error_or) |
||

3418 | = |
||

3419 | ((let open! Ppx_deriving_yojson_runtime in |
||

3420 | function |
||

3421 | | `List ((`String "VARIABLE_ASSIGNMENT_STATEMENT")::arg0::[]) -> |
||

3422 | ((function |
||

3423 | | `Assoc xs -> |
||

3424 | let rec loop xs ((arg0,arg1,arg2) as _state) = |
||

3425 | match xs with |
||

3426 | | ("label",x)::xs -> |
||

3427 | loop xs |
||

3428 | (((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2) |
||

3429 | | ("lhs",x)::xs -> |
||

3430 | loop xs |
||

3431 | (arg0, ((fun x -> vhdl_name_t_of_yojson x) x), arg2) |
||

3432 | | ("rhs",x)::xs -> |
||

3433 | loop xs |
||

3434 | (arg0, arg1, ((fun x -> vhdl_expr_t_of_yojson x) x)) |
||

3435 | | [] -> |
||

3436 | arg2 >>= |
||

3437 | ((fun arg2 -> |
||

3438 | arg1 >>= |
||

3439 | (fun arg1 -> |
||

3440 | arg0 >>= |
||

3441 | (fun arg0 -> |
||

3442 | Result.Ok |
||

3443 | (VarAssign |
||

3444 | { |
||

3445 | label = arg0; |
||

3446 | lhs = arg1; |
||

3447 | rhs = arg2 |
||

3448 | }))))) |
||

3449 | | _::xs -> loop xs _state in |
||

3450 | loop xs |
||

3451 | ((Result.Ok NoName), |
||

3452 | (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.lhs"), |
||

3453 | (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.rhs")) |
||

3454 | | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0 |
||

3455 | | `List ((`String "SIGNAL_ASSIGNMENT_STATEMENT")::arg0::[]) -> |
||

3456 | ((function |
||

3457 | | `Assoc xs -> |
||

3458 | let rec loop xs ((arg0,arg1,arg2) as _state) = |
||

3459 | match xs with |
||

3460 | | ("label",x)::xs -> |
||

3461 | loop xs |
||

3462 | (((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2) |
||

3463 | | ("lhs",x)::xs -> |
||

3464 | loop xs |
||

3465 | (arg0, ((fun x -> vhdl_name_t_of_yojson x) x), arg2) |
||

3466 | | ("rhs",x)::xs -> |
||

3467 | loop xs |
||

3468 | (arg0, arg1, |
||

3469 | ((function |
||

3470 | | `List xs -> |
||

3471 | map_bind (fun x -> vhdl_expr_t_of_yojson x) |
||

3472 | [] xs |
||

3473 | | _ -> |
||

3474 | Result.Error |
||

3475 | "Vhdl_ast.vhdl_sequential_stmt_t.rhs") x)) |
||

3476 | | [] -> |
||

3477 | arg2 >>= |
||

3478 | ((fun arg2 -> |
||

3479 | arg1 >>= |
||

3480 | (fun arg1 -> |
||

3481 | arg0 >>= |
||

3482 | (fun arg0 -> |
||

3483 | Result.Ok |
||

3484 | (SigSeqAssign |
||

3485 | { |
||

3486 | label = arg0; |
||

3487 | lhs = arg1; |
||

3488 | rhs = arg2 |
||

3489 | }))))) |
||

3490 | | _::xs -> loop xs _state in |
||

3491 | loop xs |
||

3492 | ((Result.Ok NoName), |
||

3493 | (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.lhs"), |
||

3494 | (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.rhs")) |
||

3495 | | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0 |
||

3496 | | `List ((`String "IF_STATEMENT")::arg0::[]) -> |
||

3497 | ((function |
||

3498 | | `Assoc xs -> |
||

3499 | let rec loop xs ((arg0,arg1,arg2) as _state) = |
||

3500 | match xs with |
||

3501 | | ("label",x)::xs -> |
||

3502 | loop xs |
||

3503 | (((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2) |
||

3504 | | ("if_cases",x)::xs -> |
||

3505 | loop xs |
||

3506 | (arg0, |
||

3507 | ((function |
||

3508 | | `List xs -> |
||

3509 | map_bind |
||

3510 | (fun x -> vhdl_if_case_t_of_yojson x) [] |
||

3511 | xs |
||

3512 | | _ -> |
||

3513 | Result.Error |
||

3514 | "Vhdl_ast.vhdl_sequential_stmt_t.if_cases") |
||

3515 | x), arg2) |
||

3516 | | ("default",x)::xs -> |
||

3517 | loop xs |
||

3518 | (arg0, arg1, |
||

3519 | ((function |
||

3520 | | `List xs -> |
||

3521 | map_bind |
||

3522 | (fun x -> |
||

3523 | vhdl_sequential_stmt_t_of_yojson x) [] |
||

3524 | xs |
||

3525 | | _ -> |
||

3526 | Result.Error |
||

3527 | "Vhdl_ast.vhdl_sequential_stmt_t.default") |
||

3528 | x)) |
||