-
Notifications
You must be signed in to change notification settings - Fork 5
/
yaml_interp.c
135 lines (132 loc) · 6.23 KB
/
yaml_interp.c
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
void process_event(yaml_event_t *event) {
switch (event->type) {
case YAML_NO_EVENT:
printf("YAML_NO_EVENT\n");
break;
case YAML_STREAM_START_EVENT:
printf("YAML_STREAM_START_EVENT\n");
switch (event->data.stream_start.encoding) {
case YAML_ANY_ENCODING:
printf("\tYAML_ANY_ENCODING\n");
break;
case YAML_UTF8_ENCODING:
printf("\tYAML_UTF8_ENCODING\n");
break;
case YAML_UTF16LE_ENCODING:
printf("\tYAML_UTF16LE_ENCODING\n");
break;
case YAML_UTF16BE_ENCODING:
printf("\tYAML_UTF16BE_ENCODING\n");
break;
}
break;
case YAML_STREAM_END_EVENT:
printf("YAML_STREAM_END_EVENT\n");
break;
case YAML_DOCUMENT_START_EVENT:
printf("YAML_DOCUMENT_START_EVENT\n");
if (event->data.document_start.version_directive != NULL) {
printf("\tVersion directive: %d.%d\n",
event->data.document_start.version_directive->major,
event->data.document_start.version_directive->minor);
}
printf("\t\"document indicator\" is %simplicit, whatever that means\n", event->data.document_start.implicit ? "" : "not ");
if (event->data.document_start.tag_directives.start != NULL) {
printf("\tTag directives start: tag handle: %s\t\ttag prefix: %s\n",
event->data.document_start.tag_directives.start->handle,
event->data.document_start.tag_directives.start->prefix);
}
if (event->data.document_start.tag_directives.end != NULL) {
printf("\tTag directives end: tag handle: %s\t\ttag prefix: %s\n",
event->data.document_start.tag_directives.end->handle,
event->data.document_start.tag_directives.end->prefix);
}
break;
case YAML_DOCUMENT_END_EVENT:
printf("YAML_DOCUMENT_END_EVENT\n");
printf("\t\"document indicator\" is %simplicit, whatever that means\n", event->data.document_end.implicit ? "" : "not ");
break;
case YAML_ALIAS_EVENT:
printf("YAML_ALIAS_EVENT\n");
if (event->data.alias.anchor != NULL) {
printf("\tAnchor: %s\n", event->data.alias.anchor);
}
break;
case YAML_SCALAR_EVENT:
printf("YAML_SCALAR_EVENT\n");
if (event->data.scalar.anchor != NULL)
printf("\tAnchor: %s\n", event->data.scalar.anchor);
if (event->data.scalar.tag != NULL)
printf("\tTag: %s\n", event->data.scalar.tag);
if (event->data.scalar.value != NULL)
printf("\tValue: %s\n", event->data.scalar.value);
printf("\tLength: %d\n", event->data.scalar.length);
printf("\t\"plain_implicit\" is %simplicit, whatever that means\n", event->data.scalar.plain_implicit ? "" : "not ");
printf("\t\"quoted_implicit\" is %simplicit, whatever that means\n", event->data.scalar.quoted_implicit ? "" : "not ");
switch (event->data.scalar.style) {
case YAML_ANY_SCALAR_STYLE:
printf("\tYAML_ANY_SCALAR_STYLE\n");
break;
case YAML_PLAIN_SCALAR_STYLE:
printf("\tYAML_PLAIN_SCALAR_STYLE\n");
break;
case YAML_SINGLE_QUOTED_SCALAR_STYLE:
printf("\tYAML_SINGLE_QUOTED_SCALAR_STYLE\n");
break;
case YAML_DOUBLE_QUOTED_SCALAR_STYLE:
printf("\tYAML_DOUBLE_QUOTED_SCALAR_STYLE\n");
break;
case YAML_LITERAL_SCALAR_STYLE:
printf("\tYAML_LITERAL_SCALAR_STYLE\n");
break;
case YAML_FOLDED_SCALAR_STYLE:
printf("\tYAML_FOLDED_SCALAR_STYLE\n");
break;
}
break;
case YAML_SEQUENCE_START_EVENT:
printf("YAML_SEQUENCE_START_EVENT\n");
if (event->data.sequence_start.anchor != NULL)
printf("\tAnchor: %s\n", event->data.sequence_start.anchor);
if (event->data.sequence_start.tag != NULL)
printf("\tTag: %s\n", event->data.sequence_start.tag);
printf("\ttag is %simplicit, whatever that means\n", event->data.sequence_start.implicit ? "" : "not ");
switch (event->data.sequence_start.style) {
case YAML_ANY_SEQUENCE_STYLE:
printf("\tYAML_ANY_SEQUENCE_STYLE\n");
break;
case YAML_BLOCK_SEQUENCE_STYLE:
printf("\tYAML_BLOCK_SEQUENCE_STYLE\n");
break;
case YAML_FLOW_SEQUENCE_STYLE:
printf("\tYAML_FLOW_SEQUENCE_STYLE\n");
break;
}
break;
case YAML_SEQUENCE_END_EVENT:
printf("YAML_SEQUENCE_END_EVENT\n");
break;
case YAML_MAPPING_START_EVENT:
printf("YAML_MAPPING_START_EVENT\n");
if (event->data.mapping_start.anchor != NULL)
printf("\tAnchor: %s\n", event->data.mapping_start.anchor);
if (event->data.mapping_start.tag != NULL)
printf("\tTag: %s\n", event->data.mapping_start.tag);
printf("\tmapping is %simplicit, whatever that means\n", event->data.mapping_start.implicit ? "" : "not ");
switch (event->data.sequence_start.style) {
case YAML_ANY_MAPPING_STYLE:
printf("\tYAML_ANY_MAPPING_STYLE\n");
break;
case YAML_BLOCK_MAPPING_STYLE:
printf("\tYAML_BLOCK_MAPPING_STYLE\n");
break;
case YAML_FLOW_MAPPING_STYLE:
printf("\tYAML_FLOW_MAPPING_STYLE\n");
break;
}
break;
case YAML_MAPPING_END_EVENT:
printf("YAML_MAPPING_END_EVENT\n");
break;
};
}