Changeset 194
- Timestamp:
- 06/19/06 16:27:22 (7 years ago)
- File:
-
- 1 edited
-
libyaml/trunk/src/scanner.c (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libyaml/trunk/src/scanner.c
r190 r194 1012 1012 1013 1013 parser->tokens[parser->tokens_head++] = NULL; 1014 if (parser->tokens_head == parser->tokens_size)1015 parser->tokens_head = 0;1016 1014 1017 1015 parser->tokens_parsed++; 1016 1017 if (token->type == YAML_STREAM_END_TOKEN) { 1018 parser->stream_end_produced = 1; 1019 } 1018 1020 1019 1021 return token; … … 1081 1083 memset(new_buffer+string->size, 0, string->size); 1082 1084 1083 string->pointer = new_buffer + (string-> buffer-string->pointer);1085 string->pointer = new_buffer + (string->pointer-string->buffer); 1084 1086 string->buffer = new_buffer; 1085 1087 string->size *= 2; … … 1104 1106 1105 1107 memcpy(string1->pointer, string2->buffer, string2->pointer-string2->buffer); 1108 string1->pointer += string2->pointer-string2->buffer; 1106 1109 1107 1110 return 1; … … 1139 1142 } 1140 1143 1141 memset(new_buffer+ (*size), 0, item_size*(*size));1144 memset(new_buffer+item_size*(*size), 0, item_size*(*size)); 1142 1145 1143 1146 *buffer = new_buffer; … … 1160 1163 parser->problem = problem; 1161 1164 parser->problem_mark = yaml_parser_get_mark(parser); 1165 1166 return 0; 1162 1167 } 1163 1168 … … 1205 1210 { 1206 1211 /* Check if any potential simple key may occupy the head position. */ 1212 1213 if (!yaml_parser_stale_simple_keys(parser)) 1214 return 0; 1207 1215 1208 1216 for (k = 0; k <= parser->flow_level; k++) { … … 1252 1260 return 0; 1253 1261 1262 /* Remove obsolete potential simple keys. */ 1263 1264 if (!yaml_parser_stale_simple_keys(parser)) 1265 return 0; 1266 1254 1267 /* Check the indentation level against the current column. */ 1255 1268 … … 1331 1344 /* Is it the key indicator? */ 1332 1345 1333 if (CHECK(parser, '?') && ( !parser->flow_level || IS_BLANKZ_AT(parser, 1)))1346 if (CHECK(parser, '?') && (parser->flow_level || IS_BLANKZ_AT(parser, 1))) 1334 1347 return yaml_parser_fetch_key(parser); 1335 1348 1336 1349 /* Is it the value indicator? */ 1337 1350 1338 if (CHECK(parser, ':') && ( !parser->flow_level || IS_BLANKZ_AT(parser, 1)))1351 if (CHECK(parser, ':') && (parser->flow_level || IS_BLANKZ_AT(parser, 1))) 1339 1352 return yaml_parser_fetch_value(parser); 1340 1353 … … 1383 1396 * '%', '@', '`'. 1384 1397 * 1385 * In the block context, it may also start with the characters 1398 * In the block context (and, for the '-' indicator, in the flow context 1399 * too), it may also start with the characters 1386 1400 * 1387 1401 * '-', '?', ':' … … 1399 1413 || CHECK(parser, '\'') || CHECK(parser, '"') || CHECK(parser, '%') 1400 1414 || CHECK(parser, '@') || CHECK(parser, '`')) || 1415 (CHECK(parser, '-') && !IS_BLANK_AT(parser, 1)) || 1401 1416 (!parser->flow_level && 1402 (CHECK(parser, '-') || CHECK(parser, '?') || CHECK(parser, ':')) && 1403 IS_BLANKZ_AT(parser, 1))) 1417 (CHECK(parser, '?') || CHECK(parser, ':')) && !IS_BLANKZ_AT(parser, 1))) 1404 1418 return yaml_parser_fetch_plain_scalar(parser); 1405 1419 … … 1436 1450 1437 1451 if (simple_key && (simple_key->line < parser->line || 1438 simple_key->index < parser->index+1024)) {1452 simple_key->index+1024 < parser->index)) { 1439 1453 1440 1454 /* Check if the potential simple key to be removed is required. */ … … 1790 1804 return 0; 1791 1805 1792 /* We have finished. */ 1793 1794 parser->stream_end_produced = 1; 1806 /* Reset simple keys. */ 1807 1808 if (!yaml_parser_remove_simple_key(parser)) 1809 return 0; 1810 1811 parser->simple_key_allowed = 0; 1795 1812 1796 1813 /* Create the STREAM-END token. */ … … 2205 2222 /* In the block context, we may need to add the BLOCK-MAPPING-START token. */ 2206 2223 2207 if (!yaml_parser_roll_indent(parser, parser->column,2224 if (!yaml_parser_roll_indent(parser, simple_key->column, 2208 2225 simple_key->token_number, 2209 2226 YAML_BLOCK_MAPPING_START_TOKEN, simple_key->mark)) … … 2990 3007 handle[0] = '!'; 2991 3008 handle[1] = '\0'; 3009 3010 /* 3011 * A special case: the '!' tag. 3012 */ 3013 3014 if (suffix[0] == '\0') { 3015 yaml_char_t *tmp = handle; 3016 handle = suffix; 3017 suffix = tmp; 3018 } 2992 3019 } 2993 3020 } … … 3069 3096 { 3070 3097 /* 3071 * It's not really a tag handle. If it's a %TAG directive, it's an 3072 * error. If it's a tag token, it must be a part of URI. 3098 * It's either the '!' tag or not really a tag handle. If it's a %TAG 3099 * directive, it's an error. If it's a tag token, it must be a part of 3100 * URI. 3073 3101 */ 3074 3102 3075 if (directive ) {3076 yaml_parser_set_scanner_error(parser, "while parsing a directive",3103 if (directive && !(string.buffer[0] == '!' && string.buffer[1] == '\0')) { 3104 yaml_parser_set_scanner_error(parser, "while parsing a tag directive", 3077 3105 start_mark, "did not find expected '!'"); 3078 3106 goto error; … … 3108 3136 } 3109 3137 3110 /* Copy the head if needed. */ 3111 3112 if (length) { 3113 memcpy(string.buffer, head, length); 3114 string.pointer += length; 3138 /* 3139 * Copy the head if needed. 3140 * 3141 * Note that we don't copy the leading '!' character. 3142 */ 3143 3144 if (length > 1) { 3145 memcpy(string.buffer, head+1, length-1); 3146 string.pointer += length-1; 3115 3147 } 3116 3148 … … 3673 3705 break; 3674 3706 3707 case '\\': 3708 *(string.pointer++) = '\\'; 3709 break; 3710 3675 3711 case 'N': /* NEL (#x85) */ 3676 3712 *(string.pointer++) = '\xC2'; … … 3692 3728 *(string.pointer++) = '\xE2'; 3693 3729 *(string.pointer++) = '\x80'; 3694 *(string.pointer++) = '\xA 8';3730 *(string.pointer++) = '\xA9'; 3695 3731 break; 3696 3732 … … 3801 3837 COPY(parser, whitespaces); 3802 3838 } 3839 else { 3840 FORWARD(parser); 3841 } 3803 3842 } 3804 3843 else … … 3932 3971 while (!IS_BLANKZ(parser)) 3933 3972 { 3934 /* Check for 'x:x' in the flow context. */3973 /* Check for 'x:x' in the flow context. TODO: Fix the test "spec-08-13". */ 3935 3974 3936 3975 if (parser->flow_level && CHECK(parser, ':') && !IS_BLANKZ_AT(parser, 1)) { … … 4011 4050 yaml_parser_set_scanner_error(parser, "while scanning a plain scalar", 4012 4051 start_mark, "found a tab character that violate intendation"); 4013 break;4052 goto error; 4014 4053 } 4015 4054 … … 4019 4058 if (!RESIZE(parser, whitespaces)) goto error; 4020 4059 COPY(parser, whitespaces); 4060 } 4061 else { 4062 FORWARD(parser); 4021 4063 } 4022 4064 } … … 4044 4086 /* Check intendation level. */ 4045 4087 4046 if ( parser->column < indent)4088 if (!parser->flow_level && parser->column < indent) 4047 4089 break; 4048 4090 }
Note: See TracChangeset
for help on using the changeset viewer.
