Changeset 243
- Timestamp:
- 01/08/07 13:33:55 (6 years ago)
- Location:
- libyaml/trunk
- Files:
-
- 6 edited
-
include/yaml.h (modified) (17 diffs)
-
src/api.c (modified) (5 diffs)
-
src/loader.c (modified) (4 diffs)
-
src/parser.c (modified) (6 diffs)
-
src/scanner.c (modified) (1 diff)
-
src/yaml_private.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libyaml/trunk/include/yaml.h
r238 r243 96 96 /** The stream encoding. */ 97 97 typedef enum yaml_encoding_e { 98 /** Let the parser choose the encoding. */ 98 99 YAML_ANY_ENCODING, 100 /** The default UTF-8 encoding. */ 99 101 YAML_UTF8_ENCODING, 102 /** The UTF-16-LE encoding with BOM. */ 100 103 YAML_UTF16LE_ENCODING, 104 /** The UTF-16-BE encoding with BOM. */ 101 105 YAML_UTF16BE_ENCODING 102 106 } yaml_encoding_t; … … 105 109 106 110 typedef enum yaml_break_e { 111 /** Let the parser choose the break type. */ 107 112 YAML_ANY_BREAK, 113 /** Use CR for line breaks (Mac style). */ 108 114 YAML_CR_BREAK, 115 /** Use LN for line breaks (Unix style). */ 109 116 YAML_LN_BREAK, 117 /** Use CR LN for line breaks (DOS style). */ 110 118 YAML_CRLN_BREAK 111 119 } yaml_break_t; … … 113 121 /** Many bad things could happen with the parser and emitter. */ 114 122 typedef enum yaml_error_type_e { 123 /** No error is produced. */ 115 124 YAML_NO_ERROR, 116 125 126 /** Cannot allocate or reallocate a block of memory. */ 117 127 YAML_MEMORY_ERROR, 118 128 129 /** Cannot read or decode the input stream. */ 119 130 YAML_READER_ERROR, 131 /** Cannot scan the input stream. */ 120 132 YAML_SCANNER_ERROR, 133 /** Cannot parse the input stream. */ 121 134 YAML_PARSER_ERROR, 135 /** Cannot compose a YAML document. */ 122 136 YAML_COMPOSER_ERROR, 123 137 138 /** Cannot write to the output stream. */ 124 139 YAML_WRITER_ERROR, 140 /** Cannot emit a YAML stream. */ 125 141 YAML_EMITTER_ERROR 126 142 } yaml_error_type_t; … … 147 163 /** Scalar styles. */ 148 164 typedef enum yaml_scalar_style_e { 165 /** Let the emitter choose the style. */ 149 166 YAML_ANY_SCALAR_STYLE, 150 167 168 /** The plain scalar style. */ 151 169 YAML_PLAIN_SCALAR_STYLE, 152 170 171 /** The single-quoted scalar style. */ 153 172 YAML_SINGLE_QUOTED_SCALAR_STYLE, 173 /** The double-quoted scalar style. */ 154 174 YAML_DOUBLE_QUOTED_SCALAR_STYLE, 155 175 176 /** The literal scalar style. */ 156 177 YAML_LITERAL_SCALAR_STYLE, 178 /** The folded scalar style. */ 157 179 YAML_FOLDED_SCALAR_STYLE 158 180 } yaml_scalar_style_t; … … 160 182 /** Sequence styles. */ 161 183 typedef enum yaml_sequence_style_e { 184 /** Let the emitter choose the style. */ 162 185 YAML_ANY_SEQUENCE_STYLE, 163 186 187 /** The block sequence style. */ 164 188 YAML_BLOCK_SEQUENCE_STYLE, 189 /** The flow sequence style. */ 165 190 YAML_FLOW_SEQUENCE_STYLE 166 191 } yaml_sequence_style_t; … … 168 193 /** Mapping styles. */ 169 194 typedef enum yaml_mapping_style_e { 195 /** Let the emitter choose the style. */ 170 196 YAML_ANY_MAPPING_STYLE, 171 197 198 /** The block mapping style. */ 172 199 YAML_BLOCK_MAPPING_STYLE, 200 /** The flow mapping style. */ 173 201 YAML_FLOW_MAPPING_STYLE 174 202 /* YAML_FLOW_SET_MAPPING_STYLE */ … … 184 212 /** Token types. */ 185 213 typedef enum yaml_token_type_e { 214 /** An empty token. */ 186 215 YAML_NO_TOKEN, 187 216 217 /** A STREAM-START token. */ 188 218 YAML_STREAM_START_TOKEN, 219 /** A STREAM-END token. */ 189 220 YAML_STREAM_END_TOKEN, 190 221 222 /** A VERSION-DIRECTIVE token. */ 191 223 YAML_VERSION_DIRECTIVE_TOKEN, 224 /** A TAG-DIRECTIVE token. */ 192 225 YAML_TAG_DIRECTIVE_TOKEN, 226 /** A DOCUMENT-START token. */ 193 227 YAML_DOCUMENT_START_TOKEN, 228 /** A DOCUMENT-END token. */ 194 229 YAML_DOCUMENT_END_TOKEN, 195 230 231 /** A BLOCK-SEQUENCE-START token. */ 196 232 YAML_BLOCK_SEQUENCE_START_TOKEN, 233 /** A BLOCK-SEQUENCE-END token. */ 197 234 YAML_BLOCK_MAPPING_START_TOKEN, 235 /** A BLOCK-END token. */ 198 236 YAML_BLOCK_END_TOKEN, 199 237 238 /** A FLOW-SEQUENCE-START token. */ 200 239 YAML_FLOW_SEQUENCE_START_TOKEN, 240 /** A FLOW-SEQUENCE-END token. */ 201 241 YAML_FLOW_SEQUENCE_END_TOKEN, 242 /** A FLOW-MAPPING-START token. */ 202 243 YAML_FLOW_MAPPING_START_TOKEN, 244 /** A FLOW-MAPPING-END token. */ 203 245 YAML_FLOW_MAPPING_END_TOKEN, 204 246 247 /** A BLOCK-ENTRY token. */ 205 248 YAML_BLOCK_ENTRY_TOKEN, 249 /** A FLOW-ENTRY token. */ 206 250 YAML_FLOW_ENTRY_TOKEN, 251 /** A KEY token. */ 207 252 YAML_KEY_TOKEN, 253 /** A VALUE token. */ 208 254 YAML_VALUE_TOKEN, 209 255 256 /** An ALIAS token. */ 210 257 YAML_ALIAS_TOKEN, 258 /** An ANCHOR token. */ 211 259 YAML_ANCHOR_TOKEN, 260 /** A TAG token. */ 212 261 YAML_TAG_TOKEN, 262 /** A SCALAR token. */ 213 263 YAML_SCALAR_TOKEN 214 264 } yaml_token_type_t; … … 302 352 /** Event types. */ 303 353 typedef enum yaml_event_type_e { 354 /** An empty event. */ 304 355 YAML_NO_EVENT, 305 356 357 /** A STREAM-START event. */ 306 358 YAML_STREAM_START_EVENT, 359 /** A STREAM-END event. */ 307 360 YAML_STREAM_END_EVENT, 308 361 362 /** A DOCUMENT-START event. */ 309 363 YAML_DOCUMENT_START_EVENT, 364 /** A DOCUMENT-END event. */ 310 365 YAML_DOCUMENT_END_EVENT, 311 366 367 /** An ALIAS event. */ 312 368 YAML_ALIAS_EVENT, 369 /** A SCALAR event. */ 313 370 YAML_SCALAR_EVENT, 314 371 372 /** A SEQUENCE-START event. */ 315 373 YAML_SEQUENCE_START_EVENT, 374 /** A SEQUENCE-END event. */ 316 375 YAML_SEQUENCE_END_EVENT, 317 376 377 /** A MAPPING-START event. */ 318 378 YAML_MAPPING_START_EVENT, 379 /** A MAPPING-END event. */ 319 380 YAML_MAPPING_END_EVENT 320 381 } yaml_event_type_t; … … 594 655 yaml_event_delete(yaml_event_t *event); 595 656 657 /** @} */ 658 596 659 /** 597 660 * @defgroup nodes Nodes … … 599 662 */ 600 663 664 /** The tag @c !!null with the only possible value: @c null. */ 601 665 #define YAML_NULL_TAG "tag:yaml.org,2002:null" 666 /** The tag @c !!bool with the values: @c true and @c falce. */ 602 667 #define YAML_BOOL_TAG "tag:yaml.org,2002:bool" 668 /** The tag @c !!str for string values. */ 603 669 #define YAML_STR_TAG "tag:yaml.org,2002:str" 670 /** The tag @c !!int for integer values. */ 604 671 #define YAML_INT_TAG "tag:yaml.org,2002:int" 672 /** The tag @c !!float for float values. */ 605 673 #define YAML_FLOAT_TAG "tag:yaml.org,2002:float" 674 /** The tag @c !!timestamp for date and time values. */ 606 675 #define YAML_TIMESTAMP_TAG "tag:yaml.org,2002:timestamp" 607 676 677 /** The tag @c !!seq is used to denote sequences. */ 608 678 #define YAML_SEQ_TAG "tag:yaml.org,2002:seq" 679 /** The tag @c !!map is used to denote mapping. */ 609 680 #define YAML_MAP_TAG "tag:yaml.org,2002:map" 610 681 682 /** The default scalar tag is @c !!str. */ 611 683 #define YAML_DEFAULT_SCALAR_TAG YAML_STR_TAG 684 /** The default sequence tag is @c !!seq. */ 612 685 #define YAML_DEFAULT_SEQUENCE_TAG YAML_SEQ_TAG 686 /** The default mapping tag is @c !!map. */ 613 687 #define YAML_DEFAULT_MAPPING_TAG YAML_MAP_TAG 614 688 615 689 /** Node types. */ 616 690 typedef enum yaml_node_type_e { 691 /** An empty node. */ 617 692 YAML_NO_NODE, 618 693 694 /** A scalar node. */ 619 695 YAML_SCALAR_NODE, 696 /** A sequence node. */ 620 697 YAML_SEQUENCE_NODE, 698 /** A mapping node. */ 621 699 YAML_MAPPING_NODE 622 700 } yaml_node_type_t; … … 774 852 * 775 853 * @param[in] document A document object. 776 * @param[in] nodeThe node id.854 * @param[in] index The node id. 777 855 * 778 856 * @returns the node objct or @c NULL if @c node_id is out of range. … … 780 858 781 859 YAML_DECLARE(yaml_node_t *) 782 yaml_document_get_node(yaml_document_t *document, int node_id);860 yaml_document_get_node(yaml_document_t *document, int index); 783 861 784 862 /** … … 931 1009 */ 932 1010 typedef enum yaml_parser_state_e { 1011 /** Expect STREAM-START. */ 933 1012 YAML_PARSE_STREAM_START_STATE, 1013 /** Expect the beginning of an implicit document. */ 934 1014 YAML_PARSE_IMPLICIT_DOCUMENT_START_STATE, 1015 /** Expect DOCUMENT-START. */ 935 1016 YAML_PARSE_DOCUMENT_START_STATE, 1017 /** Expect the content of a document. */ 936 1018 YAML_PARSE_DOCUMENT_CONTENT_STATE, 1019 /** Expect DOCUMENT-END. */ 937 1020 YAML_PARSE_DOCUMENT_END_STATE, 1021 /** Expect a block node. */ 938 1022 YAML_PARSE_BLOCK_NODE_STATE, 1023 /** Expect a block node or indentless sequence. */ 939 1024 YAML_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE, 1025 /** Expect a flow node. */ 940 1026 YAML_PARSE_FLOW_NODE_STATE, 1027 /** Expect the first entry of a block sequence. */ 941 1028 YAML_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE, 1029 /** Expect an entry of a block sequence. */ 942 1030 YAML_PARSE_BLOCK_SEQUENCE_ENTRY_STATE, 1031 /** Expect an entry of an indentless sequence. */ 943 1032 YAML_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE, 1033 /** Expect the first key of a block mapping. */ 944 1034 YAML_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE, 1035 /** Expect a block mapping key. */ 945 1036 YAML_PARSE_BLOCK_MAPPING_KEY_STATE, 1037 /** Expect a block mapping value. */ 946 1038 YAML_PARSE_BLOCK_MAPPING_VALUE_STATE, 1039 /** Expect the first entry of a flow sequence. */ 947 1040 YAML_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE, 1041 /** Expect an entry of a flow sequence. */ 948 1042 YAML_PARSE_FLOW_SEQUENCE_ENTRY_STATE, 1043 /** Expect a key of an ordered mapping. */ 949 1044 YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE, 1045 /** Expect a value of an ordered mapping. */ 950 1046 YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE, 1047 /** Expect the and of an ordered mapping entry. */ 951 1048 YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE, 1049 /** Expect the first key of a flow mapping. */ 952 1050 YAML_PARSE_FLOW_MAPPING_FIRST_KEY_STATE, 1051 /** Expect a key of a flow mapping. */ 953 1052 YAML_PARSE_FLOW_MAPPING_KEY_STATE, 1053 /** Expect a value of a flow mapping. */ 954 1054 YAML_PARSE_FLOW_MAPPING_VALUE_STATE, 1055 /** Expect an empty value of a flow mapping. */ 955 1056 YAML_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE, 1057 /** Expect nothing. */ 956 1058 YAML_PARSE_END_STATE 957 1059 } yaml_parser_state_t; … … 1376 1478 /** The emitter states. */ 1377 1479 typedef enum yaml_emitter_state_e { 1480 /** Expect STREAM-START. */ 1378 1481 YAML_EMIT_STREAM_START_STATE, 1482 /** Expect the first DOCUMENT-START or STREAM-END. */ 1379 1483 YAML_EMIT_FIRST_DOCUMENT_START_STATE, 1484 /** Expect DOCUMENT-START or STREAM-END. */ 1380 1485 YAML_EMIT_DOCUMENT_START_STATE, 1486 /** Expect the content of a document. */ 1381 1487 YAML_EMIT_DOCUMENT_CONTENT_STATE, 1488 /** Expect DOCUMENT-END. */ 1382 1489 YAML_EMIT_DOCUMENT_END_STATE, 1490 /** Expect the first item of a flow sequence. */ 1383 1491 YAML_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE, 1492 /** Expect an item of a flow sequence. */ 1384 1493 YAML_EMIT_FLOW_SEQUENCE_ITEM_STATE, 1494 /** Expect the first key of a flow mapping. */ 1385 1495 YAML_EMIT_FLOW_MAPPING_FIRST_KEY_STATE, 1496 /** Expect a key of a flow mapping. */ 1386 1497 YAML_EMIT_FLOW_MAPPING_KEY_STATE, 1498 /** Expect a value for a simple key of a flow mapping. */ 1387 1499 YAML_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE, 1500 /** Expect a value of a flow mapping. */ 1388 1501 YAML_EMIT_FLOW_MAPPING_VALUE_STATE, 1502 /** Expect the first item of a block sequence. */ 1389 1503 YAML_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE, 1504 /** Expect an item of a block sequence. */ 1390 1505 YAML_EMIT_BLOCK_SEQUENCE_ITEM_STATE, 1506 /** Expect the first key of a block mapping. */ 1391 1507 YAML_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE, 1508 /** Expect the key of a block mapping. */ 1392 1509 YAML_EMIT_BLOCK_MAPPING_KEY_STATE, 1510 /** Expect a value for a simple key of a block mapping. */ 1393 1511 YAML_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE, 1512 /** Expect a value of a block mapping. */ 1394 1513 YAML_EMIT_BLOCK_MAPPING_VALUE_STATE, 1514 /** Expect nothing. */ 1395 1515 YAML_EMIT_END_STATE 1396 1516 } yaml_emitter_state_t; … … 1786 1906 yaml_emitter_emit(yaml_emitter_t *emitter, yaml_event_t *event); 1787 1907 1788 /* 1908 /** 1789 1909 * Start a YAML stream. 1790 1910 * … … 1799 1919 yaml_emitter_open(yaml_emitter_t *emitter); 1800 1920 1801 /* 1921 /** 1802 1922 * Finish a YAML stream. 1803 1923 * … … 1812 1932 yaml_emitter_close(yaml_emitter_t *emitter); 1813 1933 1814 /* 1934 /** 1815 1935 * Emit a YAML document. 1816 1936 * -
libyaml/trunk/src/api.c
r239 r243 1119 1119 struct { 1120 1120 yaml_error_type_t error; 1121 } context = { YAML_NO_ERROR };1121 } context; 1122 1122 yaml_tag_directive_t *tag_directive; 1123 1124 context.error = YAML_NO_ERROR; /* Eliminate a compliler warning. */ 1123 1125 1124 1126 assert(document); /* Non-NULL document object is expected. */ … … 1160 1162 1161 1163 YAML_DECLARE(yaml_node_t *) 1162 yaml_document_get_node(yaml_document_t *document, int node)1164 yaml_document_get_node(yaml_document_t *document, int index) 1163 1165 { 1164 1166 assert(document); /* Non-NULL document object is expected. */ 1165 1167 1166 if ( node > 0 && document->nodes.start + node<= document->nodes.top) {1167 return document->nodes.start + node- 1;1168 if (index > 0 && document->nodes.start + index <= document->nodes.top) { 1169 return document->nodes.start + index - 1; 1168 1170 } 1169 1171 return NULL; … … 1206 1208 1207 1209 if (!tag) { 1208 tag = YAML_DEFAULT_SCALAR_TAG;1210 tag = (yaml_char_t *)YAML_DEFAULT_SCALAR_TAG; 1209 1211 } 1210 1212 … … 1258 1260 1259 1261 if (!tag) { 1260 tag = YAML_DEFAULT_SEQUENCE_TAG;1262 tag = (yaml_char_t *)YAML_DEFAULT_SEQUENCE_TAG; 1261 1263 } 1262 1264 … … 1303 1305 1304 1306 if (!tag) { 1305 tag = YAML_DEFAULT_MAPPING_TAG;1307 tag = (yaml_char_t *)YAML_DEFAULT_MAPPING_TAG; 1306 1308 } 1307 1309 -
libyaml/trunk/src/loader.c
r239 r243 14 14 15 15 static int 16 yaml_parser_set_ parser_error(yaml_parser_t *parser,16 yaml_parser_set_composer_error(yaml_parser_t *parser, 17 17 const char *problem, yaml_mark_t problem_mark); 18 18 19 19 static int 20 yaml_parser_set_ parser_error_context(yaml_parser_t *parser,20 yaml_parser_set_composer_error_context(yaml_parser_t *parser, 21 21 const char *context, yaml_mark_t context_mark, 22 22 const char *problem, yaml_mark_t problem_mark); … … 287 287 if (!tag || strcmp((char *)tag, "!") == 0) { 288 288 yaml_free(tag); 289 tag = yaml_strdup( YAML_DEFAULT_SCALAR_TAG);289 tag = yaml_strdup((yaml_char_t *)YAML_DEFAULT_SCALAR_TAG); 290 290 if (!tag) goto error; 291 291 } … … 330 330 if (!tag || strcmp((char *)tag, "!") == 0) { 331 331 yaml_free(tag); 332 tag = yaml_strdup( YAML_DEFAULT_SEQUENCE_TAG);332 tag = yaml_strdup((yaml_char_t *)YAML_DEFAULT_SEQUENCE_TAG); 333 333 if (!tag) goto error; 334 334 } … … 388 388 if (!tag || strcmp((char *)tag, "!") == 0) { 389 389 yaml_free(tag); 390 tag = yaml_strdup( YAML_DEFAULT_MAPPING_TAG);390 tag = yaml_strdup((yaml_char_t *)YAML_DEFAULT_MAPPING_TAG); 391 391 if (!tag) goto error; 392 392 } -
libyaml/trunk/src/parser.c
r216 r243 751 751 else if (token->type == YAML_BLOCK_END_TOKEN) 752 752 { 753 yaml_mark_t dummy_mark; /* Used to eliminate a compiler warning. */ 753 754 parser->state = POP(parser, parser->states); 754 POP(parser, parser->marks);755 dummy_mark = POP(parser, parser->marks); 755 756 SEQUENCE_END_EVENT_INIT(*event, token->start_mark, token->end_mark); 756 757 SKIP_TOKEN(parser); … … 860 861 else if (token->type == YAML_BLOCK_END_TOKEN) 861 862 { 863 yaml_mark_t dummy_mark; /* Used to eliminate a compiler warning. */ 862 864 parser->state = POP(parser, parser->states); 863 POP(parser, parser->marks);865 dummy_mark = POP(parser, parser->marks); 864 866 MAPPING_END_EVENT_INIT(*event, token->start_mark, token->end_mark); 865 867 SKIP_TOKEN(parser); … … 942 944 { 943 945 yaml_token_t *token; 946 yaml_mark_t dummy_mark; /* Used to eliminate a compiler warning. */ 944 947 945 948 if (first) { … … 986 989 987 990 parser->state = POP(parser, parser->states); 988 POP(parser, parser->marks);991 dummy_mark = POP(parser, parser->marks); 989 992 SEQUENCE_END_EVENT_INIT(*event, token->start_mark, token->end_mark); 990 993 SKIP_TOKEN(parser); … … 1093 1096 { 1094 1097 yaml_token_t *token; 1098 yaml_mark_t dummy_mark; /* Used to eliminate a compiler warning. */ 1095 1099 1096 1100 if (first) { … … 1146 1150 1147 1151 parser->state = POP(parser, parser->states); 1148 POP(parser, parser->marks);1152 dummy_mark = POP(parser, parser->marks); 1149 1153 MAPPING_END_EVENT_INIT(*event, token->start_mark, token->end_mark); 1150 1154 SKIP_TOKEN(parser); -
libyaml/trunk/src/scanner.c
r239 r243 1187 1187 yaml_parser_decrease_flow_level(yaml_parser_t *parser) 1188 1188 { 1189 yaml_simple_key_t dummy_key; /* Used to eliminate a compiler warning. */ 1190 1189 1191 if (parser->flow_level) { 1190 1192 parser->flow_level --; 1191 POP(parser, parser->simple_keys);1193 dummy_key = POP(parser, parser->simple_keys); 1192 1194 } 1193 1195 -
libyaml/trunk/src/yaml_private.h
r238 r243 587 587 document_version_directive,document_tag_directives_start, \ 588 588 document_tag_directives_end,document_start_implicit, \ 589 document_end_implicit, start_mark,end_mark)\589 document_end_implicit,document_start_mark,document_end_mark) \ 590 590 (memset(&(document), 0, sizeof(yaml_document_t)), \ 591 591 (document).nodes.start = (document_nodes_start), \ … … 596 596 (document).tag_directives.end = (document_tag_directives_end), \ 597 597 (document).start_implicit = (document_start_implicit), \ 598 (document).end_implicit = (document_end_implicit)) 598 (document).end_implicit = (document_end_implicit), \ 599 (document).start_mark = (document_start_mark), \ 600 (document).end_mark = (document_end_mark)) 599 601 600 602 /*
Note: See TracChangeset
for help on using the changeset viewer.
