-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjson_pkg.sv
80 lines (70 loc) · 2.03 KB
/
json_pkg.sv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package json_pkg;
// Forward declarations
typedef json_value;
typedef json_object;
typedef json_array;
typedef json_string;
typedef json_int;
typedef json_real;
typedef json_bool;
// Alias to raise syntax errors in a more compact way
`define JSON_SYNTAX_ERR(KIND, STR, IDX, DESCR="")\
parser_result::err( \
json_error::create( \
.kind(KIND), \
.description(DESCR), \
.json_str(STR), \
.json_pos(IDX), \
.source_file(`__FILE__), \
.source_line(`__LINE__) \
) \
)
// Alias to raise internal error in a more compact way
`define JSON_INTERNAL_ERR(DESCR="", RES_T=parser_result)\
RES_T::err( \
json_error::create( \
.kind(json_error::INTERNAL), \
.description(DESCR), \
.source_file(`__FILE__), \
.source_line(`__LINE__) \
) \
)
// Alias to raise common error
`define JSON_ERR(KIND, DESCR="", VAL_T=json_value)\
json_result#(VAL_T)::err( \
json_error::create( \
.kind(KIND), \
.description(DESCR), \
.source_file(`__FILE__), \
.source_line(`__LINE__) \
) \
)
// Utility classes
`include "json_error.sv"
`include "json_result.sv"
// Interface classes for encoding standard JSON value types
`include "json_value_encodable.sv"
`include "json_object_encodable.sv"
`include "json_array_encodable.sv"
`include "json_string_encodable.sv"
`include "json_int_encodable.sv"
`include "json_real_encodable.sv"
`include "json_bool_encodable.sv"
// Wrapper classes to represent standard JSON value types
`include "json_value.sv"
`include "json_object.sv"
`include "json_array.sv"
`include "json_string.sv"
`include "json_int.sv"
`include "json_real.sv"
`include "json_bool.sv"
// Extension classes to handle SV specific types
`include "json_enum.sv"
`include "json_bits.sv"
// JSON processors
`include "json_decoder.sv"
`include "json_encoder.sv"
`undef JSON_SYNTAX_ERR
`undef JSON_INTERNAL_ERR
`undef JSON_ERR
endpackage : json_pkg