diff options
Diffstat (limited to 'ext/syck')
| -rw-r--r-- | ext/syck/.cvsignore | 3 | ||||
| -rw-r--r-- | ext/syck/MANIFEST | 15 | ||||
| -rw-r--r-- | ext/syck/bytecode.c | 1109 | ||||
| -rw-r--r-- | ext/syck/emitter.c | 434 | ||||
| -rw-r--r-- | ext/syck/extconf.rb | 5 | ||||
| -rw-r--r-- | ext/syck/gram.c | 1776 | ||||
| -rw-r--r-- | ext/syck/gram.h | 81 | ||||
| -rw-r--r-- | ext/syck/handler.c | 156 | ||||
| -rw-r--r-- | ext/syck/implicit.c | 2808 | ||||
| -rw-r--r-- | ext/syck/node.c | 324 | ||||
| -rw-r--r-- | ext/syck/rubyext.c | 1481 | ||||
| -rw-r--r-- | ext/syck/syck.c | 503 | ||||
| -rw-r--r-- | ext/syck/syck.h | 400 | ||||
| -rw-r--r-- | ext/syck/token.c | 2394 | ||||
| -rw-r--r-- | ext/syck/yaml2byte.c | 251 | ||||
| -rw-r--r-- | ext/syck/yamlbyte.h | 170 |
16 files changed, 0 insertions, 11910 deletions
diff --git a/ext/syck/.cvsignore b/ext/syck/.cvsignore deleted file mode 100644 index 4088712231..0000000000 --- a/ext/syck/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -Makefile -mkmf.log -*.def diff --git a/ext/syck/MANIFEST b/ext/syck/MANIFEST deleted file mode 100644 index bb126fa530..0000000000 --- a/ext/syck/MANIFEST +++ /dev/null @@ -1,15 +0,0 @@ -MANIFEST -extconf.rb -bytecode.c -emitter.c -gram.c -gram.h -handler.c -implicit.c -node.c -rubyext.c -syck.c -syck.h -token.c -yaml2byte.c -yamlbyte.h diff --git a/ext/syck/bytecode.c b/ext/syck/bytecode.c deleted file mode 100644 index df15658a73..0000000000 --- a/ext/syck/bytecode.c +++ /dev/null @@ -1,1109 +0,0 @@ -/* Generated by re2c 0.5 on Sun Nov 23 14:51:02 2003 */ -#line 1 "bytecode.re" -/* - * bytecode.re - * - * $Author$ - * $Date$ - * - * Copyright (C) 2003 why the lucky stiff - */ -#include "syck.h" -#include "ruby.h" -#include "gram.h" - -#define QUOTELEN 128 - -/* - * They do my bidding... - */ -#define YYCTYPE char -#define YYCURSOR parser->cursor -#define YYMARKER parser->marker -#define YYLIMIT parser->limit -#define YYTOKEN parser->token -#define YYTOKTMP parser->toktmp -#define YYLINEPTR parser->lineptr -#define YYLINECTPTR parser->linectptr -#define YYLINE parser->linect -#define YYFILL(n) syck_parser_read(parser) - -extern SyckParser *syck_parser_ptr; - -char *get_inline( SyckParser *parser ); - -/* - * Repositions the cursor at `n' offset from the token start. - * Only works in `Header' and `Document' sections. - */ -#define YYPOS(n) YYCURSOR = YYTOKEN + n - -/* - * Track line numbers - */ -#define CHK_NL(ptr) if ( *( ptr - 1 ) == '\n' && ptr > YYLINECTPTR ) { YYLINEPTR = ptr; YYLINE++; YYLINECTPTR = YYLINEPTR; } - -/* - * I like seeing the level operations as macros... - */ -#define ADD_LEVEL(len, status) syck_parser_add_level( parser, len, status ) -#define POP_LEVEL() syck_parser_pop_level( parser ) -#define CURRENT_LEVEL() syck_parser_current_level( parser ) - -/* - * Force a token next time around sycklex() - */ -#define FORCE_NEXT_TOKEN(tok) parser->force_token = tok; - -/* - * Adding levels in bytecode requires us to make sure - * we've got all our tokens worked out. - */ -#define ADD_BYTE_LEVEL(lvl, len, s ) \ - switch ( lvl->status ) \ - { \ - case syck_lvl_seq: \ - lvl->ncount++; \ - ADD_LEVEL(len, syck_lvl_open); \ - YYPOS(0); \ - return '-'; \ - \ - case syck_lvl_map: \ - lvl->ncount++; \ - ADD_LEVEL(len, s); \ - break; \ - \ - case syck_lvl_open: \ - lvl->status = s; \ - break; \ - \ - default: \ - ADD_LEVEL(len, s); \ - break; \ - } - -/* - * Nice little macro to ensure we're YAML_IOPENed to the current level. - * * Only use this macro in the "Document" section * - */ -#define ENSURE_YAML_IOPEN(last_lvl, lvl_type, to_len, reset) \ - if ( last_lvl->spaces < to_len ) \ - { \ - if ( last_lvl->status == syck_lvl_inline ) \ - { \ - goto Document; \ - } \ - else \ - { \ - ADD_LEVEL( to_len, lvl_type ); \ - if ( reset == 1 ) YYPOS(0); \ - return YAML_IOPEN; \ - } \ - } - -/* - * Nice little macro to ensure closure of levels. - * * Only use this macro in the "Document" section * - */ -#define ENSURE_YAML_IEND(last_lvl, to_len) \ - if ( last_lvl->spaces > to_len ) \ - { \ - syck_parser_pop_level( parser ); \ - YYPOS(0); \ - return YAML_IEND; \ - } - -/* - * Concatenates string items and manages allocation - * to the string - */ -#define CAT(s, c, i, l) \ - { \ - if ( i + 1 >= c ) \ - { \ - c += QUOTELEN; \ - S_REALLOC_N( s, char, c ); \ - } \ - s[i++] = l; \ - s[i] = '\0'; \ - } - -/* - * Parser for standard YAML Bytecode [UTF-8] - */ -int -sycklex_bytecode_utf8( YYSTYPE *sycklval, SyckParser *parser ) -{ - SyckLevel *lvl; - int doc_level = 0; - syck_parser_ptr = parser; - if ( YYCURSOR == NULL ) - { - syck_parser_read( parser ); - } - - if ( parser->force_token != 0 ) - { - int t = parser->force_token; - parser->force_token = 0; - return t; - } - -#line 173 - - - lvl = CURRENT_LEVEL(); - if ( lvl->status == syck_lvl_doc ) - { - goto Document; - } - -Header: - - YYTOKEN = YYCURSOR; - -{ - YYCTYPE yych; - unsigned int yyaccept; - goto yy0; -yy1: ++YYCURSOR; -yy0: - if((YYLIMIT - YYCURSOR) < 3) YYFILL(3); - yych = *YYCURSOR; - switch(yych){ - case '\000': goto yy2; - case 'D': goto yy3; - default: goto yy5; - } -yy2: YYCURSOR = YYMARKER; - switch(yyaccept){ - case 0: goto yy4; - } -yy3: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case '\n': goto yy6; - case '\r': goto yy8; - default: goto yy4; - } -yy4: -#line 200 - { YYPOS(0); - goto Document; - } -yy5: yych = *++YYCURSOR; - goto yy4; -yy6: yych = *++YYCURSOR; -yy7: -#line 187 - { if ( lvl->status == syck_lvl_header ) - { - CHK_NL(YYCURSOR); - goto Directive; - } - else - { - ENSURE_YAML_IEND(lvl, -1); - YYPOS(0); - return 0; - } - } -yy8: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy6; - default: goto yy2; - } -} -#line 204 - - -Document: - { - lvl = CURRENT_LEVEL(); - if ( lvl->status == syck_lvl_header ) - { - lvl->status = syck_lvl_doc; - } - - YYTOKEN = YYCURSOR; - -{ - YYCTYPE yych; - unsigned int yyaccept; - goto yy9; -yy10: ++YYCURSOR; -yy9: - if((YYLIMIT - YYCURSOR) < 3) YYFILL(3); - yych = *YYCURSOR; - switch(yych){ - case '\000': goto yy30; - case '\n': goto yy27; - case '\r': goto yy29; - case 'A': goto yy19; - case 'D': goto yy12; - case 'E': goto yy16; - case 'M': goto yy14; - case 'P': goto yy13; - case 'Q': goto yy15; - case 'R': goto yy21; - case 'S': goto yy17; - case 'T': goto yy23; - case 'c': goto yy25; - default: goto yy11; - } -yy11:yy12: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy41; - case '\r': goto yy44; - default: goto yy11; - } -yy13: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy41; - case '\r': goto yy43; - default: goto yy11; - } -yy14: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy38; - case '\r': goto yy40; - default: goto yy11; - } -yy15: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy35; - case '\r': goto yy37; - default: goto yy11; - } -yy16: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy32; - case '\r': goto yy34; - default: goto yy11; - } -yy17: yych = *++YYCURSOR; -yy18: -#line 289 - { ADD_BYTE_LEVEL(lvl, lvl->spaces + 1, syck_lvl_str); - goto Scalar; - } -yy19: yych = *++YYCURSOR; -yy20: -#line 293 - { ADD_BYTE_LEVEL(lvl, lvl->spaces + 1, syck_lvl_open); - sycklval->name = get_inline( parser ); - syck_hdlr_remove_anchor( parser, sycklval->name ); - CHK_NL(YYCURSOR); - return YAML_ANCHOR; - } -yy21: yych = *++YYCURSOR; -yy22: -#line 300 - { ADD_BYTE_LEVEL(lvl, lvl->spaces + 1, syck_lvl_str); - sycklval->name = get_inline( parser ); - POP_LEVEL(); - if ( *( YYCURSOR - 1 ) == '\n' ) YYCURSOR--; - return YAML_ALIAS; - } -yy23: yych = *++YYCURSOR; -yy24: -#line 307 - { char *qstr; - ADD_BYTE_LEVEL(lvl, lvl->spaces + 1, syck_lvl_open); - qstr = get_inline( parser ); - CHK_NL(YYCURSOR); - if ( qstr[0] == '!' ) - { - int qidx = strlen( qstr ); - if ( qstr[1] == '\0' ) - { - free( qstr ); - return YAML_ITRANSFER; - } - - lvl = CURRENT_LEVEL(); - - /* - * URL Prefixing - */ - if ( qstr[1] == '^' ) - { - sycklval->name = S_ALLOC_N( char, qidx + strlen( lvl->domain ) ); - sycklval->name[0] = '\0'; - strcat( sycklval->name, lvl->domain ); - strncat( sycklval->name, qstr + 2, qidx - 2 ); - free( qstr ); - } - else - { - char *carat = qstr + 1; - char *qend = qstr + qidx; - while ( (++carat) < qend ) - { - if ( *carat == '^' ) - break; - } - - if ( carat < qend ) - { - free( lvl->domain ); - lvl->domain = syck_strndup( qstr + 1, carat - ( qstr + 1 ) ); - sycklval->name = S_ALLOC_N( char, ( qend - carat ) + strlen( lvl->domain ) ); - sycklval->name[0] = '\0'; - strcat( sycklval->name, lvl->domain ); - strncat( sycklval->name, carat + 1, ( qend - carat ) - 1 ); - free( qstr ); - } - else - { - sycklval->name = S_ALLOC_N( char, strlen( qstr ) ); - sycklval->name[0] = '\0'; - S_MEMCPY( sycklval->name, qstr + 1, char, strlen( qstr ) ); - free( qstr ); - } - } - return YAML_TRANSFER; - } - sycklval->name = qstr; - return YAML_TAGURI; - } -yy25: yych = *++YYCURSOR; -yy26: -#line 367 - { goto Comment; } -yy27: yych = *++YYCURSOR; -yy28: -#line 369 - { CHK_NL(YYCURSOR); - if ( lvl->status == syck_lvl_seq ) - { - return YAML_INDENT; - } - else if ( lvl->status == syck_lvl_map ) - { - if ( lvl->ncount % 2 == 1 ) return ':'; - else return YAML_INDENT; - } - goto Document; - } -yy29: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy27; - default: goto yy11; - } -yy30: yych = *++YYCURSOR; -yy31: -#line 382 - { ENSURE_YAML_IEND(lvl, -1); - YYPOS(0); - return 0; - } -yy32: yych = *++YYCURSOR; -yy33: -#line 253 - { if ( lvl->status == syck_lvl_seq && lvl->ncount == 0 ) - { - lvl->ncount++; - YYPOS(0); - FORCE_NEXT_TOKEN( ']' ); - return '['; - } - else if ( lvl->status == syck_lvl_map && lvl->ncount == 0 ) - { - lvl->ncount++; - YYPOS(0); - FORCE_NEXT_TOKEN( '}' ); - return '{'; - } - - POP_LEVEL(); - lvl = CURRENT_LEVEL(); - if ( lvl->status == syck_lvl_seq ) - { - FORCE_NEXT_TOKEN(YAML_INDENT); - } - else if ( lvl->status == syck_lvl_map ) - { - if ( lvl->ncount % 2 == 1 ) - { - FORCE_NEXT_TOKEN(':'); - } - else - { - FORCE_NEXT_TOKEN(YAML_INDENT); - } - } - CHK_NL(YYCURSOR); - return YAML_IEND; - } -yy34: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy32; - default: goto yy11; - } -yy35: yych = *++YYCURSOR; -yy36: -#line 238 - { int complex = 0; - if ( lvl->ncount % 2 == 0 && ( lvl->status == syck_lvl_map || lvl->status == syck_lvl_seq ) ) - { - complex = 1; - } - ADD_BYTE_LEVEL(lvl, lvl->spaces + 1, syck_lvl_seq); - CHK_NL(YYCURSOR); - if ( complex ) - { - FORCE_NEXT_TOKEN( YAML_IOPEN ); - return '?'; - } - return YAML_IOPEN; - } -yy37: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy35; - default: goto yy11; - } -yy38: yych = *++YYCURSOR; -yy39: -#line 223 - { int complex = 0; - if ( lvl->ncount % 2 == 0 && ( lvl->status == syck_lvl_map || lvl->status == syck_lvl_seq ) ) - { - complex = 1; - } - ADD_BYTE_LEVEL(lvl, lvl->spaces + 1, syck_lvl_map); - CHK_NL(YYCURSOR); - if ( complex ) - { - FORCE_NEXT_TOKEN( YAML_IOPEN ); - return '?'; - } - return YAML_IOPEN; - } -yy40: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy38; - default: goto yy11; - } -yy41: yych = *++YYCURSOR; -yy42: -#line 218 - { ENSURE_YAML_IEND(lvl, -1); - YYPOS(0); - return 0; - } -yy43: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy41; - default: goto yy11; - } -yy44: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy41; - default: goto yy11; - } -} -#line 387 - - - } - -Directive: - { - YYTOKTMP = YYCURSOR; - -{ - YYCTYPE yych; - unsigned int yyaccept; - goto yy45; -yy46: ++YYCURSOR; -yy45: - if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); - yych = *YYCURSOR; - switch(yych){ - case '\000': goto yy47; - case 'V': goto yy48; - default: goto yy50; - } -yy47: YYCURSOR = YYMARKER; - switch(yyaccept){ - case 0: goto yy49; - } -yy48: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case '.': - case '/': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case ';': - case '<': - case '=': - case '>': - case '?': - case '@': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '[': - case '\\': - case ']': - case '^': - case '_': case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto yy51; - default: goto yy49; - } -yy49: -#line 400 - { YYCURSOR = YYTOKTMP; - return YAML_DOCSEP; - } -yy50: yych = *++YYCURSOR; - goto yy49; -yy51: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy52: switch(yych){ - case '.': - case '/': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': case ';': - case '<': - case '=': - case '>': - case '?': - case '@': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '[': - case '\\': - case ']': - case '^': - case '_': case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto yy51; - case ':': goto yy53; - default: goto yy47; - } -yy53: yych = *++YYCURSOR; - switch(yych){ - case '.': - case '/': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case ';': - case '<': - case '=': - case '>': - case '?': - case '@': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '[': - case '\\': - case ']': - case '^': - case '_': case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto yy54; - default: goto yy47; - } -yy54: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy55: switch(yych){ - case '\n': goto yy56; - case '\r': goto yy58; - case '.': - case '/': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case ';': - case '<': - case '=': - case '>': - case '?': - case '@': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '[': - case '\\': - case ']': - case '^': - case '_': case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto yy54; - default: goto yy47; - } -yy56: yych = *++YYCURSOR; -yy57: -#line 397 - { CHK_NL(YYCURSOR); - goto Directive; } -yy58: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy56; - default: goto yy47; - } -} -#line 403 - - - } - -Comment: - { - YYTOKTMP = YYCURSOR; - -{ - YYCTYPE yych; - unsigned int yyaccept; - goto yy59; -yy60: ++YYCURSOR; -yy59: - if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); - yych = *YYCURSOR; - switch(yych){ - case '\000': goto yy61; - case '\n': goto yy62; - case '\r': goto yy64; - default: goto yy66; - } -yy61:yy62: yych = *++YYCURSOR; -yy63: -#line 413 - { CHK_NL(YYCURSOR); - goto Document; } -yy64: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy67; - default: goto yy65; - } -yy65: -#line 416 - { goto Comment; } -yy66: yych = *++YYCURSOR; - goto yy65; -yy67: yych = *++YYCURSOR; - goto yy63; -} -#line 418 - - - } - -Scalar: - { - int idx = 0; - int cap = 100; - char *str = S_ALLOC_N( char, cap ); - char *tok; - - str[0] = '\0'; - -Scalar2: - tok = YYCURSOR; - -{ - YYCTYPE yych; - unsigned int yyaccept; - goto yy68; -yy69: ++YYCURSOR; -yy68: - if((YYLIMIT - YYCURSOR) < 3) YYFILL(3); - yych = *YYCURSOR; - switch(yych){ - case '\000': goto yy74; - case '\n': goto yy70; - case '\r': goto yy72; - default: goto yy76; - } -yy70: yych = *++YYCURSOR; - switch(yych){ - case 'C': goto yy78; - case 'N': goto yy80; - case 'Z': goto yy83; - default: goto yy71; - } -yy71: -#line 462 - { YYCURSOR = tok; - goto ScalarEnd; - } -yy72: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy77; - default: goto yy73; - } -yy73: -#line 470 - { CAT(str, cap, idx, tok[0]); - goto Scalar2; - } -yy74: yych = *++YYCURSOR; -yy75: -#line 466 - { YYCURSOR = tok; - goto ScalarEnd; - } -yy76: yych = *++YYCURSOR; - goto yy73; -yy77: yych = *++YYCURSOR; - switch(yych){ - case 'C': goto yy78; - case 'N': goto yy80; - case 'Z': goto yy83; - default: goto yy71; - } -yy78: yych = *++YYCURSOR; -yy79: -#line 436 - { CHK_NL(tok+1); - goto Scalar2; } -yy80: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy81: switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy80; - default: goto yy82; - } -yy82: -#line 439 - { CHK_NL(tok+1); - if ( tok + 2 < YYCURSOR ) - { - char *count = tok + 2; - int total = strtod( count, NULL ); - int i; - for ( i = 0; i < total; i++ ) - { - CAT(str, cap, idx, '\n'); - } - } - else - { - CAT(str, cap, idx, '\n'); - } - goto Scalar2; - } -yy83: yych = *++YYCURSOR; -yy84: -#line 457 - { CHK_NL(tok+1); - CAT(str, cap, idx, '\0'); - goto Scalar2; - } -} -#line 474 - - -ScalarEnd: - { - SyckNode *n = syck_alloc_str(); - n->data.str->ptr = str; - n->data.str->len = idx; - sycklval->nodeData = n; - POP_LEVEL(); - if ( parser->implicit_typing == 1 ) - { - try_tag_implicit( sycklval->nodeData, parser->taguri_expansion ); - } - return YAML_PLAIN; - } - } - -} - -char * -get_inline( SyckParser *parser ) -{ - int idx = 0; - int cap = 100; - char *str = S_ALLOC_N( char, cap ); - char *tok; - - str[0] = '\0'; - -Inline: - { - tok = YYCURSOR; - -{ - YYCTYPE yych; - unsigned int yyaccept; - goto yy85; -yy86: ++YYCURSOR; -yy85: - if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); - yych = *YYCURSOR; - switch(yych){ - case '\000': goto yy91; - case '\n': goto yy87; - case '\r': goto yy89; - default: goto yy93; - } -yy87: yych = *++YYCURSOR; -yy88: -#line 509 - { CHK_NL(YYCURSOR); - return str; } -yy89: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy94; - default: goto yy90; - } -yy90: -#line 516 - { CAT(str, cap, idx, tok[0]); - goto Inline; - } -yy91: yych = *++YYCURSOR; -yy92: -#line 512 - { YYCURSOR = tok; - return str; - } -yy93: yych = *++YYCURSOR; - goto yy90; -yy94: yych = *++YYCURSOR; - goto yy88; -} -#line 520 - - - } - -} - diff --git a/ext/syck/emitter.c b/ext/syck/emitter.c deleted file mode 100644 index 1cc0ea5075..0000000000 --- a/ext/syck/emitter.c +++ /dev/null @@ -1,434 +0,0 @@ -/* - * emitter.c - * - * $Author$ - * $Date$ - * - * Copyright (C) 2003 why the lucky stiff - * - * All Base64 code from Ruby's pack.c. - * Ruby is Copyright (C) 1993-2003 Yukihiro Matsumoto - */ -#include <stdio.h> -#include <string.h> - -#include "syck.h" -#include "ruby.h" - -#define DEFAULT_ANCHOR_FORMAT "id%03d" - -static char b64_table[] = -"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - -struct adjust_arg { - /* Position to start adjusting */ - long startpos; - /* Adjusting by an offset */ - int offset; -}; - -/* - * Built-in base64 (from Ruby's pack.c) - */ -char * -syck_base64enc( char *s, long len ) -{ - long i = 0; - int padding = '='; - char *buff = S_ALLOCA_N(char, len * 4 / 3 + 6); - - while (len >= 3) { - buff[i++] = b64_table[077 & (*s >> 2)]; - buff[i++] = b64_table[077 & (((*s << 4) & 060) | ((s[1] >> 4) & 017))]; - buff[i++] = b64_table[077 & (((s[1] << 2) & 074) | ((s[2] >> 6) & 03))]; - buff[i++] = b64_table[077 & s[2]]; - s += 3; - len -= 3; - } - if (len == 2) { - buff[i++] = b64_table[077 & (*s >> 2)]; - buff[i++] = b64_table[077 & (((*s << 4) & 060) | ((s[1] >> 4) & 017))]; - buff[i++] = b64_table[077 & (((s[1] << 2) & 074) | (('\0' >> 6) & 03))]; - buff[i++] = padding; - } - else if (len == 1) { - buff[i++] = b64_table[077 & (*s >> 2)]; - buff[i++] = b64_table[077 & (((*s << 4) & 060) | (('\0' >> 4) & 017))]; - buff[i++] = padding; - buff[i++] = padding; - } - buff[i++] = '\n'; - return buff; -} - -char * -syck_base64dec( char *s, long len ) -{ - int a = -1,b = -1,c = 0,d; - static int first = 1; - static int b64_xtable[256]; - char *ptr = syck_strndup( s, len ); - char *end = ptr; - char *send = s + len; - - if (first) { - int i; - first = 0; - - for (i = 0; i < 256; i++) { - b64_xtable[i] = -1; - } - for (i = 0; i < 64; i++) { - b64_xtable[(int)b64_table[i]] = i; - } - } - while (s < send) { - while (s[0] == '\r' || s[0] == '\n') { s++; } - if ((a = b64_xtable[(int)s[0]]) == -1) break; - if ((b = b64_xtable[(int)s[1]]) == -1) break; - if ((c = b64_xtable[(int)s[2]]) == -1) break; - if ((d = b64_xtable[(int)s[3]]) == -1) break; - *end++ = a << 2 | b >> 4; - *end++ = b << 4 | c >> 2; - *end++ = c << 6 | d; - s += 4; - } - if (a != -1 && b != -1) { - if (s + 2 < send && s[2] == '=') - *end++ = a << 2 | b >> 4; - if (c != -1 && s + 3 < send && s[3] == '=') { - *end++ = a << 2 | b >> 4; - *end++ = b << 4 | c >> 2; - } - } - *end = '\0'; - /*RSTRING(buf)->len = ptr - RSTRING(buf)->ptr;*/ - return ptr; -} - -/* - * Allocate an emitter - */ -SyckEmitter * -syck_new_emitter() -{ - SyckEmitter *e; - e = S_ALLOC( SyckEmitter ); - e->headless = 0; - e->seq_map = 0; - e->use_header = 0; - e->use_version = 0; - e->sort_keys = 0; - e->anchor_format = NULL; - e->explicit_typing = 0; - e->best_width = 80; - e->block_style = block_arbitrary; - e->stage = doc_open; - e->indent = 2; - e->level = -1; - e->ignore_id = 0; - e->anchors = NULL; - e->markers = NULL; - e->bufsize = SYCK_BUFFERSIZE; - e->buffer = NULL; - e->marker = NULL; - e->bufpos = 0; - e->handler = NULL; - e->bonus = NULL; - return e; -} - -int -syck_st_free_anchors( char *key, char *name, char *arg ) -{ - S_FREE( name ); - return ST_CONTINUE; -} - -int -syck_st_free_markers( char *key, SyckEmitterNode *n, char *arg ) -{ - S_FREE( n ); - return ST_CONTINUE; -} - -void -syck_emitter_st_free( SyckEmitter *e ) -{ - /* - * Free the anchor tables - */ - if ( e->anchors != NULL ) - { - st_foreach( e->anchors, syck_st_free_anchors, 0 ); - st_free_table( e->anchors ); - e->anchors = NULL; - } - - /* - * Free the markers tables - */ - if ( e->markers != NULL ) - { - st_foreach( e->markers, syck_st_free_markers, 0 ); - st_free_table( e->markers ); - e->markers = NULL; - } -} - -void -syck_emitter_ignore_id( SyckEmitter *e, SYMID id ) -{ - e->ignore_id = id; -} - -void -syck_emitter_handler( SyckEmitter *e, SyckOutputHandler hdlr ) -{ - e->handler = hdlr; -} - -void -syck_free_emitter( SyckEmitter *e ) -{ - /* - * Free tables - */ - syck_emitter_st_free( e ); - if ( e->buffer != NULL ) - { - S_FREE( e->buffer ); - } - S_FREE( e ); -} - -void -syck_emitter_clear( SyckEmitter *e ) -{ - if ( e->buffer == NULL ) - { - e->buffer = S_ALLOC_N( char, e->bufsize ); - S_MEMZERO( e->buffer, char, e->bufsize ); - } - e->buffer[0] = '\0'; - e->marker = e->buffer; - e->bufpos = 0; -} - -/* - * Raw write to the emitter buffer. - */ -void -syck_emitter_write( SyckEmitter *e, char *str, long len ) -{ - long at; - ASSERT( str != NULL ) - if ( e->buffer == NULL ) - { - syck_emitter_clear( e ); - } - - /* - * Flush if at end of buffer - */ - at = e->marker - e->buffer; - if ( len + at > e->bufsize ) - { - syck_emitter_flush( e, 0 ); - } - - /* - * Write to buffer - */ - S_MEMCPY( e->marker, str, char, len ); - e->marker += len; -} - -/* - * Write a chunk of data out. - */ -void -syck_emitter_flush( SyckEmitter *e, long check_room ) -{ - /* - * Check for enough space in the buffer for check_room length. - */ - if ( check_room > 0 ) - { - if ( e->bufsize > ( e->marker - e->buffer ) + check_room ) - { - return; - } - } - else - { - check_room = e->bufsize; - } - - /* - * Determine headers. - */ - if ( ( e->stage == doc_open && ( e->headless == 0 || e->use_header == 1 ) ) || - e->stage == doc_need_header ) - { - if ( e->use_version == 1 ) - { - char *header = S_ALLOC_N( char, 64 ); - S_MEMZERO( header, char, 64 ); - sprintf( header, "--- %%YAML:%d.%d ", SYCK_YAML_MAJOR, SYCK_YAML_MINOR ); - (e->handler)( e, header, strlen( header ) ); - S_FREE( header ); - } - else - { - (e->handler)( e, "--- ", 4 ); - } - e->stage = doc_processing; - } - - /* - * Commit buffer. - */ - if ( check_room > e->marker - e->buffer ) - { - check_room = e->marker - e->buffer; - } - (e->handler)( e, e->buffer, check_room ); - e->bufpos += check_room; - e->marker -= check_room; -} - -/* - * Emit a simple, unquoted string. - */ -void -syck_emitter_simple( SyckEmitter *e, char *str, long len ) -{ - e->seq_map = 0; - syck_emitter_write( e, str, len ); -} - -/* - * Shift the offsets of all applicable anchors - */ -int -syck_adjust_anchors( char *key, SyckEmitterNode *n, struct adjust_arg *arg ) -{ - if ( arg->startpos < n->pos ) - { - n->pos += arg->offset; - } - return ST_CONTINUE; -} - -/* - * call on start of an object's marshalling - * (handles anchors, returns an alias) - */ -char * -syck_emitter_start_obj( SyckEmitter *e, SYMID oid ) -{ - SyckEmitterNode *n = NULL; - char *anchor_name = NULL; - - e->level++; - if ( oid != e->ignore_id ) - { - /* - * Look for anchors - */ - if ( e->markers == NULL ) - { - e->markers = st_init_numtable(); - } - - /* - * Markers table initially marks the string position of the - * object. Doesn't yet create an anchor, simply notes the - * position. - */ - if ( ! st_lookup( e->markers, (st_data_t)oid, (st_data_t *)&n ) ) - { - /* - * Store all markers - */ - n = S_ALLOC( SyckEmitterNode ); - n->is_shortcut = 0; - n->indent = e->level * e->indent; - n->pos = e->bufpos + ( e->marker - e->buffer ); - st_insert( e->markers, (st_data_t)oid, (st_data_t)n ); - } - else - { - if ( e->anchors == NULL ) - { - e->anchors = st_init_numtable(); - } - - if ( ! st_lookup( e->anchors, (st_data_t)oid, (st_data_t *)&anchor_name ) ) - { - int idx = 0; - /* - * Second time hitting this object, let's give it an anchor - */ - idx = e->anchors->num_entries + 1; - - /* - * Create the anchor tag - */ - if ( n->pos >= e->bufpos ) - { - int alen; - struct adjust_arg *args = S_ALLOC( struct adjust_arg ); - char *start = e->buffer + ( n->pos - e->bufpos ); - - char *anc = ( e->anchor_format == NULL ? DEFAULT_ANCHOR_FORMAT : e->anchor_format ); - anchor_name = S_ALLOC_N( char, strlen( anc ) + 10 ); - S_MEMZERO( anchor_name, char, strlen( anc ) + 10 ); - sprintf( anchor_name, anc, idx ); - - /* - * Need to flush the buffer some, if there is not room for the anchor. - */ - alen = strlen( anchor_name ) + 2; - syck_emitter_flush( e, alen ); - - /* - * Write the anchor into the buffer - */ - S_MEMMOVE( start + alen, start, char, e->marker - start ); - S_MEMCPY( start + 1, anchor_name, char, strlen( anchor_name ) ); - start[0] = '&'; - start[alen - 1] = ' '; - e->marker += alen; - - /* - * Cycle through anchors, modify for the size of the anchor. - */ - args->startpos = n->pos; - args->offset = alen; - st_foreach( e->markers, syck_adjust_anchors, (st_data_t)args ); - S_FREE( args ); - - /* - * Insert into anchors table - */ - st_insert( e->anchors, (st_data_t)oid, (st_data_t)anchor_name ); - } - } - - } - } - - return anchor_name; -} - -/* - * call on completion of an object's marshalling - */ -void -syck_emitter_end_obj( SyckEmitter *e ) -{ - e->level--; -} - diff --git a/ext/syck/extconf.rb b/ext/syck/extconf.rb deleted file mode 100644 index 6c10448c70..0000000000 --- a/ext/syck/extconf.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'mkmf' - -have_header( "st.h" ) -create_makefile( "syck" ) - diff --git a/ext/syck/gram.c b/ext/syck/gram.c deleted file mode 100644 index 5bdd025629..0000000000 --- a/ext/syck/gram.c +++ /dev/null @@ -1,1776 +0,0 @@ -/* A Bison parser, made from gram.y, by GNU bison 1.75. */ - -/* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -/* Written by Richard Stallman by simplifying the original so called - ``semantic'' parser. */ - -/* All symbols defined below should begin with yy or YY, to avoid - infringing on user name space. This should be done even for local - variables, as they might otherwise be expanded by user macros. - There are some unavoidable exceptions within include files to - define necessary library symbols; they are noted "INFRINGES ON - USER NAME SPACE" below. */ - -/* Identify Bison output. */ -#define YYBISON 1 - -/* Pure parsers. */ -#define YYPURE 1 - -/* Using locations. */ -#define YYLSP_NEEDED 0 - -/* If NAME_PREFIX is specified substitute the variables and functions - names. */ -#define yyparse syckparse -#define yylex sycklex -#define yyerror syckerror -#define yylval sycklval -#define yychar syckchar -#define yydebug syckdebug -#define yynerrs sycknerrs - - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - YAML_ANCHOR = 258, - YAML_ALIAS = 259, - YAML_TRANSFER = 260, - YAML_TAGURI = 261, - YAML_ITRANSFER = 262, - YAML_WORD = 263, - YAML_PLAIN = 264, - YAML_BLOCK = 265, - YAML_DOCSEP = 266, - YAML_IOPEN = 267, - YAML_INDENT = 268, - YAML_IEND = 269 - }; -#endif -#define YAML_ANCHOR 258 -#define YAML_ALIAS 259 -#define YAML_TRANSFER 260 -#define YAML_TAGURI 261 -#define YAML_ITRANSFER 262 -#define YAML_WORD 263 -#define YAML_PLAIN 264 -#define YAML_BLOCK 265 -#define YAML_DOCSEP 266 -#define YAML_IOPEN 267 -#define YAML_INDENT 268 -#define YAML_IEND 269 - - - - -/* Copy the first part of user declarations. */ -#line 14 "gram.y" - - -#include "syck.h" - -#define YYPARSE_PARAM parser -#define YYLEX_PARAM parser - - - -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 1 -#endif - -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 0 -#endif - -#ifndef YYSTYPE -#line 23 "gram.y" -typedef union { - SYMID nodeId; - SyckNode *nodeData; - char *name; -} yystype; -/* Line 193 of /usr/local/share/bison/yacc.c. */ -#line 125 "y.tab.c" -# define YYSTYPE yystype -# define YYSTYPE_IS_TRIVIAL 1 -#endif - -#ifndef YYLTYPE -typedef struct yyltype -{ - int first_line; - int first_column; - int last_line; - int last_column; -} yyltype; -# define YYLTYPE yyltype -# define YYLTYPE_IS_TRIVIAL 1 -#endif - -/* Copy the second part of user declarations. */ -int sycklex( YYSTYPE *, SyckParser * ); - - -/* Line 213 of /usr/local/share/bison/yacc.c. */ -#line 146 "y.tab.c" - -#if ! defined (yyoverflow) || YYERROR_VERBOSE - -/* The parser invokes alloca or malloc; define the necessary symbols. */ - -# if YYSTACK_USE_ALLOCA -# define YYSTACK_ALLOC alloca -# else -# ifndef YYSTACK_USE_ALLOCA -# if defined (alloca) || defined (_ALLOCA_H) -# define YYSTACK_ALLOC alloca -# else -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# endif -# endif -# endif -# endif - -# ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) -# else -# if defined (__STDC__) || defined (__cplusplus) -# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# endif -# define YYSTACK_ALLOC malloc -# define YYSTACK_FREE free -# endif -#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ - - -#if (! defined (yyoverflow) \ - && (! defined (__cplusplus) \ - || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) - -/* A type that is properly aligned for any stack member. */ -union yyalloc -{ - short yyss; - YYSTYPE yyvs; - }; - -/* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1) - -/* The size of an array large to enough to hold all stacks, each with - N elements. */ -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ - + YYSTACK_GAP_MAX) - -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - register YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (0) -# endif -# endif - -/* Relocate STACK from its old location to the new one. The - local variables YYSIZE and YYSTACKSIZE give the old and new number of - elements in the stack, and YYPTR gives the new location of the - stack. Advance YYPTR to a properly aligned location for the next - stack. */ -# define YYSTACK_RELOCATE(Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (0) - -#endif - -#if defined (__STDC__) || defined (__cplusplus) - typedef signed char yysigned_char; -#else - typedef short yysigned_char; -#endif - -/* YYFINAL -- State number of the termination state. */ -#define YYFINAL 38 -#define YYLAST 414 - -/* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 23 -/* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 25 -/* YYNRULES -- Number of rules. */ -#define YYNRULES 69 -/* YYNRULES -- Number of states. */ -#define YYNSTATES 121 - -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ -#define YYUNDEFTOK 2 -#define YYMAXUTOK 269 - -#define YYTRANSLATE(X) \ - ((unsigned)(X) <= YYMAXUTOK ? yytranslate[X] : YYUNDEFTOK) - -/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ -static const unsigned char yytranslate[] = -{ - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 21, 15, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 16, 2, - 2, 2, 2, 22, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 17, 2, 18, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 19, 2, 20, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 -}; - -#if YYDEBUG -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ -static const unsigned char yyprhs[] = -{ - 0, 0, 3, 5, 8, 9, 11, 13, 15, 18, - 22, 26, 28, 31, 32, 34, 37, 39, 41, 43, - 46, 49, 52, 55, 58, 60, 62, 64, 67, 70, - 72, 74, 76, 78, 80, 84, 87, 89, 93, 96, - 100, 103, 107, 110, 112, 116, 119, 123, 126, 128, - 132, 136, 140, 144, 147, 151, 154, 158, 161, 165, - 167, 173, 175, 179, 183, 186, 190, 194, 197, 199 -}; - -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const yysigned_char yyrhs[] = -{ - 24, 0, -1, 33, -1, 11, 27, -1, -1, 32, - -1, 26, -1, 33, -1, 3, 26, -1, 28, 32, - 31, -1, 28, 26, 31, -1, 25, -1, 28, 29, - -1, -1, 12, -1, 28, 13, -1, 14, -1, 13, - -1, 14, -1, 30, 31, -1, 5, 32, -1, 6, - 32, -1, 7, 32, -1, 3, 32, -1, 4, -1, - 8, -1, 9, -1, 5, 33, -1, 6, 33, -1, - 10, -1, 34, -1, 38, -1, 40, -1, 46, -1, - 28, 36, 29, -1, 15, 27, -1, 37, -1, 5, - 30, 36, -1, 5, 36, -1, 6, 30, 36, -1, - 6, 36, -1, 3, 30, 36, -1, 3, 36, -1, - 35, -1, 37, 30, 35, -1, 37, 30, -1, 17, - 39, 18, -1, 17, 18, -1, 25, -1, 39, 21, - 25, -1, 28, 41, 29, -1, 28, 44, 29, -1, - 5, 30, 44, -1, 5, 41, -1, 6, 30, 44, - -1, 6, 41, -1, 3, 30, 44, -1, 3, 41, - -1, 32, 16, 27, -1, 42, -1, 22, 25, 30, - 16, 27, -1, 43, -1, 44, 30, 35, -1, 44, - 30, 43, -1, 44, 30, -1, 25, 16, 27, -1, - 19, 47, 20, -1, 19, 20, -1, 45, -1, 47, - 21, 45, -1 -}; - -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const unsigned short yyrline[] = -{ - 0, 44, 44, 48, 52, 58, 59, 62, 63, 72, - 76, 82, 83, 96, 114, 115, 118, 121, 124, 125, - 133, 138, 143, 151, 155, 163, 176, 183, 188, 193, - 194, 195, 196, 197, 203, 209, 215, 216, 221, 226, - 231, 236, 240, 246, 250, 255, 264, 268, 274, 278, - 288, 293, 300, 305, 310, 315, 320, 324, 330, 345, - 346, 354, 355, 367, 374, 383, 391, 395, 401, 402 -}; -#endif - -#if YYDEBUG || YYERROR_VERBOSE -/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ -static const char *const yytname[] = -{ - "$end", "error", "$undefined", "YAML_ANCHOR", "YAML_ALIAS", - "YAML_TRANSFER", "YAML_TAGURI", "YAML_ITRANSFER", "YAML_WORD", - "YAML_PLAIN", "YAML_BLOCK", "YAML_DOCSEP", "YAML_IOPEN", "YAML_INDENT", - "YAML_IEND", "'-'", "':'", "'['", "']'", "'{'", "'}'", "','", "'?'", - "$accept", "doc", "atom", "ind_rep", "atom_or_empty", "indent_open", - "indent_end", "indent_sep", "indent_flex_end", "word_rep", "struct_rep", - "implicit_seq", "basic_seq", "top_imp_seq", "in_implicit_seq", - "inline_seq", "in_inline_seq", "implicit_map", "top_imp_map", - "basic_mapping", "complex_mapping", "in_implicit_map", "basic_mapping2", - "inline_map", "in_inline_map", 0 -}; -#endif - -# ifdef YYPRINT -/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to - token YYLEX-NUM. */ -static const unsigned short yytoknum[] = -{ - 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 45, 58, 91, 93, 123, - 125, 44, 63 -}; -# endif - -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const unsigned char yyr1[] = -{ - 0, 23, 24, 24, 24, 25, 25, 26, 26, 26, - 26, 27, 27, 27, 28, 28, 29, 30, 31, 31, - 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, - 33, 33, 33, 33, 34, 35, 36, 36, 36, 36, - 36, 36, 36, 37, 37, 37, 38, 38, 39, 39, - 40, 40, 41, 41, 41, 41, 41, 41, 42, 43, - 43, 44, 44, 44, 44, 45, 46, 46, 47, 47 -}; - -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const unsigned char yyr2[] = -{ - 0, 2, 1, 2, 0, 1, 1, 1, 2, 3, - 3, 1, 2, 0, 1, 2, 1, 1, 1, 2, - 2, 2, 2, 2, 1, 1, 1, 2, 2, 1, - 1, 1, 1, 1, 3, 2, 1, 3, 2, 3, - 2, 3, 2, 1, 3, 2, 3, 2, 1, 3, - 3, 3, 3, 2, 3, 2, 3, 2, 3, 1, - 5, 1, 3, 3, 2, 3, 3, 2, 1, 3 -}; - -/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state - STATE-NUM when YYTABLE doesn't specify something else to do. Zero - means the default is an error. */ -static const unsigned char yydefact[] = -{ - 4, 0, 0, 29, 13, 14, 0, 0, 0, 0, - 2, 30, 31, 32, 33, 27, 28, 0, 24, 0, - 0, 0, 25, 26, 11, 6, 3, 0, 5, 7, - 47, 48, 0, 0, 67, 0, 68, 0, 1, 0, - 0, 0, 15, 13, 0, 0, 43, 0, 36, 0, - 59, 61, 0, 8, 23, 0, 20, 21, 0, 0, - 22, 0, 0, 0, 16, 0, 12, 0, 46, 0, - 13, 66, 0, 17, 0, 42, 57, 0, 38, 53, - 0, 40, 55, 35, 0, 13, 34, 45, 50, 51, - 64, 18, 0, 10, 9, 49, 65, 69, 0, 0, - 0, 41, 56, 37, 52, 39, 54, 0, 58, 44, - 62, 63, 19, 0, 0, 0, 13, 0, 0, 0, - 60 -}; - -/* YYDEFGOTO[NTERM-NUM]. */ -static const yysigned_char yydefgoto[] = -{ - -1, 8, 24, 25, 26, 32, 66, 90, 93, 28, - 29, 11, 46, 75, 48, 12, 33, 13, 49, 50, - 51, 52, 36, 14, 37 -}; - -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -#define YYPACT_NINF -68 -static const short yypact[] = -{ - 133, 177, 177, -68, 352, -68, 335, 283, 27, 223, - -68, -68, -68, -68, -68, -68, -68, 352, -68, 369, - 369, 97, -68, -68, -68, -68, -68, 154, -68, -68, - -68, -68, 203, -12, -68, 17, -68, 46, -68, 386, - 386, 386, -68, 352, 352, 25, -68, 30, 33, 30, - -68, -68, 67, -68, -68, 97, -68, -68, 97, 97, - -68, 301, 318, 318, -68, 107, -68, 37, -68, 352, - 352, -68, 352, -68, 243, -68, -68, 243, -68, -68, - 243, -68, -68, -68, 33, 352, -68, 40, -68, -68, - 263, -68, 107, -68, -68, -68, -68, -68, 399, 399, - 399, -68, 33, -68, 33, -68, 33, 42, -68, -68, - -68, -68, -68, 84, 84, 84, 352, 9, 9, 9, - -68 -}; - -/* YYPGOTO[NTERM-NUM]. */ -static const yysigned_char yypgoto[] = -{ - -68, -68, 10, -9, -38, 0, -7, 86, -56, 56, - 29, -68, -62, -6, -68, -68, -68, -68, -2, -68, - -26, -67, -3, -68, -68 -}; - -/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, parse error. */ -#define YYTABLE_NINF -1 -static const unsigned char yytable[] = -{ - 9, 9, 9, 47, 27, 83, 68, 102, 53, 69, - 104, 94, 117, 106, 118, 119, 31, 35, 65, 9, - 9, 47, 73, 65, 43, 109, 47, 38, 110, 10, - 15, 16, 96, 70, 78, 81, 112, 76, 79, 82, - 86, 85, 88, 27, 64, 89, 73, 108, 15, 16, - 73, 91, 53, 85, 84, 43, 78, 81, 116, 76, - 79, 82, 9, 9, 111, 45, 71, 72, 101, 97, - 27, 103, 0, 54, 105, 56, 57, 60, 120, 95, - 73, 64, 35, 67, 0, 27, 0, 117, 67, 118, - 119, 15, 16, 78, 81, 54, 56, 57, 0, 43, - 55, 18, 58, 59, 21, 22, 23, 101, 103, 105, - 0, 54, 78, 81, 56, 57, 27, 54, 56, 57, - 73, 91, 0, 0, 0, 74, 77, 80, 0, 0, - 45, 0, 0, 45, 87, 0, 45, 0, 1, 2, - 0, 0, 0, 3, 4, 5, 45, 74, 77, 80, - 6, 92, 7, 92, 54, 56, 57, 61, 18, 62, - 63, 21, 22, 23, 3, 0, 5, 42, 64, 43, - 107, 6, 0, 7, 0, 0, 44, 0, 92, 0, - 0, 0, 1, 2, 113, 114, 115, 3, 0, 5, - 0, 0, 0, 0, 6, 0, 7, 0, 0, 0, - 0, 0, 0, 113, 114, 115, 61, 18, 62, 63, - 21, 22, 23, 3, 0, 5, 42, 0, 43, 0, - 6, 0, 7, 0, 0, 44, 39, 18, 40, 41, - 21, 22, 23, 0, 0, 0, 42, 0, 43, 0, - 0, 0, 0, 0, 0, 44, 98, 18, 99, 100, - 21, 22, 23, 0, 0, 0, 0, 0, 43, 0, - 0, 0, 0, 0, 0, 44, 55, 18, 58, 59, - 21, 22, 23, 0, 0, 0, 0, 0, 43, 0, - 0, 0, 0, 0, 0, 44, 17, 18, 19, 20, - 21, 22, 23, 3, 0, 5, 0, 0, 0, 0, - 6, 0, 7, 34, 61, 18, 62, 63, 21, 22, - 23, 3, 0, 5, 73, 0, 43, 0, 6, 0, - 7, 39, 18, 62, 63, 21, 22, 23, 3, 0, - 5, 73, 0, 43, 0, 6, 0, 7, 17, 18, - 19, 20, 21, 22, 23, 3, 0, 5, 0, 0, - 0, 0, 6, 30, 7, 17, 18, 19, 20, 21, - 22, 23, 3, 0, 5, 0, 0, 0, 0, 6, - 0, 7, 55, 18, 19, 20, 21, 22, 23, 3, - 0, 5, 0, 0, 0, 0, 6, 0, 7, 39, - 18, 40, 41, 21, 22, 23, 0, 0, 0, 73, - 0, 43, 98, 18, 99, 100, 21, 22, 23, 0, - 0, 0, 73, 0, 43 -}; - -static const yysigned_char yycheck[] = -{ - 0, 1, 2, 9, 4, 43, 18, 74, 17, 21, - 77, 67, 3, 80, 5, 6, 6, 7, 27, 19, - 20, 27, 13, 32, 15, 87, 32, 0, 90, 0, - 1, 2, 70, 16, 40, 41, 92, 39, 40, 41, - 47, 16, 49, 43, 14, 52, 13, 85, 19, 20, - 13, 14, 61, 16, 44, 15, 62, 63, 16, 61, - 62, 63, 62, 63, 90, 9, 20, 21, 74, 72, - 70, 77, -1, 17, 80, 19, 20, 21, 116, 69, - 13, 14, 72, 27, -1, 85, -1, 3, 32, 5, - 6, 62, 63, 99, 100, 39, 40, 41, -1, 15, - 3, 4, 5, 6, 7, 8, 9, 113, 114, 115, - -1, 55, 118, 119, 58, 59, 116, 61, 62, 63, - 13, 14, -1, -1, -1, 39, 40, 41, -1, -1, - 74, -1, -1, 77, 48, -1, 80, -1, 5, 6, - -1, -1, -1, 10, 11, 12, 90, 61, 62, 63, - 17, 65, 19, 67, 98, 99, 100, 3, 4, 5, - 6, 7, 8, 9, 10, -1, 12, 13, 14, 15, - 84, 17, -1, 19, -1, -1, 22, -1, 92, -1, - -1, -1, 5, 6, 98, 99, 100, 10, -1, 12, - -1, -1, -1, -1, 17, -1, 19, -1, -1, -1, - -1, -1, -1, 117, 118, 119, 3, 4, 5, 6, - 7, 8, 9, 10, -1, 12, 13, -1, 15, -1, - 17, -1, 19, -1, -1, 22, 3, 4, 5, 6, - 7, 8, 9, -1, -1, -1, 13, -1, 15, -1, - -1, -1, -1, -1, -1, 22, 3, 4, 5, 6, - 7, 8, 9, -1, -1, -1, -1, -1, 15, -1, - -1, -1, -1, -1, -1, 22, 3, 4, 5, 6, - 7, 8, 9, -1, -1, -1, -1, -1, 15, -1, - -1, -1, -1, -1, -1, 22, 3, 4, 5, 6, - 7, 8, 9, 10, -1, 12, -1, -1, -1, -1, - 17, -1, 19, 20, 3, 4, 5, 6, 7, 8, - 9, 10, -1, 12, 13, -1, 15, -1, 17, -1, - 19, 3, 4, 5, 6, 7, 8, 9, 10, -1, - 12, 13, -1, 15, -1, 17, -1, 19, 3, 4, - 5, 6, 7, 8, 9, 10, -1, 12, -1, -1, - -1, -1, 17, 18, 19, 3, 4, 5, 6, 7, - 8, 9, 10, -1, 12, -1, -1, -1, -1, 17, - -1, 19, 3, 4, 5, 6, 7, 8, 9, 10, - -1, 12, -1, -1, -1, -1, 17, -1, 19, 3, - 4, 5, 6, 7, 8, 9, -1, -1, -1, 13, - -1, 15, 3, 4, 5, 6, 7, 8, 9, -1, - -1, -1, 13, -1, 15 -}; - -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -static const unsigned char yystos[] = -{ - 0, 5, 6, 10, 11, 12, 17, 19, 24, 28, - 33, 34, 38, 40, 46, 33, 33, 3, 4, 5, - 6, 7, 8, 9, 25, 26, 27, 28, 32, 33, - 18, 25, 28, 39, 20, 25, 45, 47, 0, 3, - 5, 6, 13, 15, 22, 32, 35, 36, 37, 41, - 42, 43, 44, 26, 32, 3, 32, 32, 5, 6, - 32, 3, 5, 6, 14, 26, 29, 32, 18, 21, - 16, 20, 21, 13, 30, 36, 41, 30, 36, 41, - 30, 36, 41, 27, 25, 16, 29, 30, 29, 29, - 30, 14, 30, 31, 31, 25, 27, 45, 3, 5, - 6, 36, 44, 36, 44, 36, 44, 30, 27, 35, - 35, 43, 31, 30, 30, 30, 16, 3, 5, 6, - 27 -}; - -#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) -# define YYSIZE_T __SIZE_TYPE__ -#endif -#if ! defined (YYSIZE_T) && defined (size_t) -# define YYSIZE_T size_t -#endif -#if ! defined (YYSIZE_T) -# if defined (__STDC__) || defined (__cplusplus) -# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# endif -#endif -#if ! defined (YYSIZE_T) -# define YYSIZE_T unsigned int -#endif - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY -2 -#define YYEOF 0 - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrlab1 - -/* Like YYERROR except do call yyerror. This remains here temporarily - to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ - -#define YYFAIL goto yyerrlab - -#define YYRECOVERING() (!!yyerrstatus) - -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - yychar1 = YYTRANSLATE (yychar); \ - YYPOPSTACK; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror ("syntax error: cannot back up"); \ - YYERROR; \ - } \ -while (0) - -#define YYTERROR 1 -#define YYERRCODE 256 - -/* YYLLOC_DEFAULT -- Compute the default location (before the actions - are run). */ - -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - Current.first_line = Rhs[1].first_line; \ - Current.first_column = Rhs[1].first_column; \ - Current.last_line = Rhs[N].last_line; \ - Current.last_column = Rhs[N].last_column; -#endif - -/* YYLEX -- calling `yylex' with the right arguments. */ - -#ifdef YYLEX_PARAM -# define YYLEX yylex (&yylval, YYLEX_PARAM) -#else -# define YYLEX yylex (&yylval) -#endif - -/* Enable debugging if requested. */ -#if YYDEBUG - -# ifndef YYFPRINTF -# include <stdio.h> /* INFRINGES ON USER NAME SPACE */ -# define YYFPRINTF fprintf -# endif - -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (0) -# define YYDSYMPRINT(Args) \ -do { \ - if (yydebug) \ - yysymprint Args; \ -} while (0) -/* Nonzero means print parse trace. It is left uninitialized so that - multiple parsers can coexist. */ -int yydebug; -#else /* !YYDEBUG */ -# define YYDPRINTF(Args) -# define YYDSYMPRINT(Args) -#endif /* !YYDEBUG */ - -/* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH -# define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only - if the built-in stack extension method is used). - - Do not make this value too large; the results are undefined if - SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) - evaluated with infinite-precision integer arithmetic. */ - -#if YYMAXDEPTH == 0 -# undef YYMAXDEPTH -#endif - -#ifndef YYMAXDEPTH -# define YYMAXDEPTH 10000 -#endif - - - -#if YYERROR_VERBOSE - -# ifndef yystrlen -# if defined (__GLIBC__) && defined (_STRING_H) -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -static YYSIZE_T -# if defined (__STDC__) || defined (__cplusplus) -yystrlen (const char *yystr) -# else -yystrlen (yystr) - const char *yystr; -# endif -{ - register const char *yys = yystr; - - while (*yys++ != '\0') - continue; - - return yys - yystr - 1; -} -# endif -# endif - -# ifndef yystpcpy -# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -static char * -# if defined (__STDC__) || defined (__cplusplus) -yystpcpy (char *yydest, const char *yysrc) -# else -yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -# endif -{ - register char *yyd = yydest; - register const char *yys = yysrc; - - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -# endif -# endif - -#endif /* !YYERROR_VERBOSE */ - - - -#if YYDEBUG -/*-----------------------------. -| Print this symbol on YYOUT. | -`-----------------------------*/ - -static void -#if defined (__STDC__) || defined (__cplusplus) -yysymprint (FILE* yyout, int yytype, YYSTYPE yyvalue) -#else -yysymprint (yyout, yytype, yyvalue) - FILE* yyout; - int yytype; - YYSTYPE yyvalue; -#endif -{ - /* Pacify ``unused variable'' warnings. */ - (void) yyvalue; - - if (yytype < YYNTOKENS) - { - YYFPRINTF (yyout, "token %s (", yytname[yytype]); -# ifdef YYPRINT - YYPRINT (yyout, yytoknum[yytype], yyvalue); -# endif - } - else - YYFPRINTF (yyout, "nterm %s (", yytname[yytype]); - - switch (yytype) - { - default: - break; - } - YYFPRINTF (yyout, ")"); -} -#endif /* YYDEBUG. */ - - -/*-----------------------------------------------. -| Release the memory associated to this symbol. | -`-----------------------------------------------*/ - -static void -#if defined (__STDC__) || defined (__cplusplus) -yydestruct (int yytype, YYSTYPE yyvalue) -#else -yydestruct (yytype, yyvalue) - int yytype; - YYSTYPE yyvalue; -#endif -{ - /* Pacify ``unused variable'' warnings. */ - (void) yyvalue; - - switch (yytype) - { - default: - break; - } -} - - - -/* The user can define YYPARSE_PARAM as the name of an argument to be passed - into yyparse. The argument should have type void *. - It should actually point to an object. - Grammar actions can access the variable by casting it - to the proper pointer type. */ - -#ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) -# define YYPARSE_PARAM_ARG void *YYPARSE_PARAM -# define YYPARSE_PARAM_DECL -# else -# define YYPARSE_PARAM_ARG YYPARSE_PARAM -# define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; -# endif -#else /* !YYPARSE_PARAM */ -# define YYPARSE_PARAM_ARG -# define YYPARSE_PARAM_DECL -#endif /* !YYPARSE_PARAM */ - -/* Prevent warning if -Wstrict-prototypes. */ -#ifdef __GNUC__ -# ifdef YYPARSE_PARAM -int yyparse (void *); -# else -int yyparse (void); -# endif -#endif - - - - -int -yyparse (YYPARSE_PARAM_ARG) - YYPARSE_PARAM_DECL -{ - /* The lookahead symbol. */ -int yychar; - -/* The semantic value of the lookahead symbol. */ -YYSTYPE yylval; - -/* Number of parse errors so far. */ -int yynerrs; - - register int yystate; - register int yyn; - int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Lookahead token as an internal (translated) token number. */ - int yychar1 = 0; - - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - short yyssa[YYINITDEPTH]; - short *yyss = yyssa; - register short *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - register YYSTYPE *yyvsp; - - - -#define YYPOPSTACK (yyvsp--, yyssp--) - - YYSIZE_T yystacksize = YYINITDEPTH; - - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - - - /* When reducing, the number of symbols on the RHS of the reduced - rule. */ - int yylen; - - YYDPRINTF ((stderr, "Starting parse\n")); - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - - yyssp = yyss; - yyvsp = yyvs; - - goto yysetstate; - -/*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | -`------------------------------------------------------------*/ - yynewstate: - /* In all cases, when you get here, the value and location stacks - have just been pushed. so pushing a state here evens the stacks. - */ - yyssp++; - - yysetstate: - *yyssp = yystate; - - if (yyssp >= yyss + yystacksize - 1) - { - /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; - -#ifdef yyoverflow - { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - short *yyss1 = yyss; - - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow ("parser stack overflow", - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - - &yystacksize); - - yyss = yyss1; - yyvs = yyvs1; - } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyoverflowlab; -# else - /* Extend the stack our own way. */ - if (yystacksize >= YYMAXDEPTH) - goto yyoverflowlab; - yystacksize *= 2; - if (yystacksize > YYMAXDEPTH) - yystacksize = YYMAXDEPTH; - - { - short *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyoverflowlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - -# undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); - } -# endif -#endif /* no yyoverflow */ - - yyssp = yyss + yysize - 1; - yyvsp = yyvs + yysize - 1; - - - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); - - if (yyssp >= yyss + yystacksize - 1) - YYABORT; - } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - - goto yybackup; - -/*-----------. -| yybackup. | -`-----------*/ -yybackup: - -/* Do appropriate processing given the current state. */ -/* Read a lookahead token if we need one and don't already have one. */ -/* yyresume: */ - - /* First try to decide what to do without reference to lookahead token. */ - - yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) - goto yydefault; - - /* Not known => get a lookahead token if don't already have one. */ - - /* yychar is either YYEMPTY or YYEOF - or a valid token in external form. */ - - if (yychar == YYEMPTY) - { - YYDPRINTF ((stderr, "Reading a token: ")); - yychar = YYLEX; - } - - /* Convert token to internal form (in yychar1) for indexing tables with. */ - - if (yychar <= 0) /* This means end of input. */ - { - yychar1 = 0; - yychar = YYEOF; /* Don't call YYLEX any more. */ - - YYDPRINTF ((stderr, "Now at end of input.\n")); - } - else - { - yychar1 = YYTRANSLATE (yychar); - - /* We have to keep this `#if YYDEBUG', since we use variables - which are defined only if `YYDEBUG' is set. */ - YYDPRINTF ((stderr, "Next token is ")); - YYDSYMPRINT ((stderr, yychar1, yylval)); - YYDPRINTF ((stderr, "\n")); - } - - /* If the proper action on seeing token YYCHAR1 is to reduce or to - detect an error, take that action. */ - yyn += yychar1; - if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yychar1) - goto yydefault; - yyn = yytable[yyn]; - if (yyn <= 0) - { - if (yyn == 0 || yyn == YYTABLE_NINF) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - - if (yyn == YYFINAL) - YYACCEPT; - - /* Shift the lookahead token. */ - YYDPRINTF ((stderr, "Shifting token %d (%s), ", - yychar, yytname[yychar1])); - - /* Discard the token being shifted unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; - - *++yyvsp = yylval; - - - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus) - yyerrstatus--; - - yystate = yyn; - goto yynewstate; - - -/*-----------------------------------------------------------. -| yydefault -- do the default action for the current state. | -`-----------------------------------------------------------*/ -yydefault: - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - goto yyreduce; - - -/*-----------------------------. -| yyreduce -- Do a reduction. | -`-----------------------------*/ -yyreduce: - /* yyn is the number of a rule to reduce with. */ - yylen = yyr2[yyn]; - - /* If YYLEN is nonzero, implement the default value of the action: - `$$ = $1'. - - Otherwise, the following line sets YYVAL to garbage. - This behavior is undocumented and Bison - users should not rely upon it. Assigning to YYVAL - unconditionally makes the parser a bit smaller, and it avoids a - GCC warning that YYVAL may be used uninitialized. */ - yyval = yyvsp[1-yylen]; - - - -#if YYDEBUG - /* We have to keep this `#if YYDEBUG', since we use variables which - are defined only if `YYDEBUG' is set. */ - if (yydebug) - { - int yyi; - - YYFPRINTF (stderr, "Reducing via rule %d (line %d), ", - yyn - 1, yyrline[yyn]); - - /* Print the symbols being reduced, and their result. */ - for (yyi = yyprhs[yyn]; yyrhs[yyi] >= 0; yyi++) - YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); - YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]); - } -#endif - switch (yyn) - { - case 2: -#line 45 "gram.y" - { - ((SyckParser *)parser)->root = syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ); - } - break; - - case 3: -#line 49 "gram.y" - { - ((SyckParser *)parser)->root = syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ); - } - break; - - case 4: -#line 53 "gram.y" - { - ((SyckParser *)parser)->eof = 1; - } - break; - - case 8: -#line 64 "gram.y" - { - /* - * _Anchors_: The language binding must keep a separate symbol table - * for anchors. The actual ID in the symbol table is returned to the - * higher nodes, though. - */ - yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-1].name, yyvsp[0].nodeData ); - } - break; - - case 9: -#line 73 "gram.y" - { - yyval.nodeData = yyvsp[-1].nodeData; - } - break; - - case 10: -#line 77 "gram.y" - { - yyval.nodeData = yyvsp[-1].nodeData; - } - break; - - case 12: -#line 84 "gram.y" - { - SyckNode *n = syck_new_str( "" ); - if ( ((SyckParser *)parser)->taguri_expansion == 1 ) - { - n->type_id = syck_taguri( YAML_DOMAIN, "null", 4 ); - } - else - { - n->type_id = syck_strndup( "null", 4 ); - } - yyval.nodeData = n; - } - break; - - case 13: -#line 97 "gram.y" - { - SyckNode *n = syck_new_str( "" ); - if ( ((SyckParser *)parser)->taguri_expansion == 1 ) - { - n->type_id = syck_taguri( YAML_DOMAIN, "null", 4 ); - } - else - { - n->type_id = syck_strndup( "null", 4 ); - } - yyval.nodeData = n; - } - break; - - case 20: -#line 134 "gram.y" - { - syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion ); - yyval.nodeData = yyvsp[0].nodeData; - } - break; - - case 21: -#line 139 "gram.y" - { - syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, 0 ); - yyval.nodeData = yyvsp[0].nodeData; - } - break; - - case 22: -#line 144 "gram.y" - { - if ( ((SyckParser *)parser)->implicit_typing == 1 ) - { - try_tag_implicit( yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion ); - } - yyval.nodeData = yyvsp[0].nodeData; - } - break; - - case 23: -#line 152 "gram.y" - { - yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-1].name, yyvsp[0].nodeData ); - } - break; - - case 24: -#line 156 "gram.y" - { - /* - * _Aliases_: The anchor symbol table is scanned for the anchor name. - * The anchor's ID in the language's symbol table is returned. - */ - yyval.nodeData = syck_hdlr_get_anchor( (SyckParser *)parser, yyvsp[0].name ); - } - break; - - case 25: -#line 164 "gram.y" - { - SyckNode *n = yyvsp[0].nodeData; - if ( ((SyckParser *)parser)->taguri_expansion == 1 ) - { - n->type_id = syck_taguri( YAML_DOMAIN, "str", 3 ); - } - else - { - n->type_id = syck_strndup( "str", 3 ); - } - yyval.nodeData = n; - } - break; - - case 27: -#line 184 "gram.y" - { - syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion ); - yyval.nodeData = yyvsp[0].nodeData; - } - break; - - case 28: -#line 189 "gram.y" - { - syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, 0 ); - yyval.nodeData = yyvsp[0].nodeData; - } - break; - - case 34: -#line 204 "gram.y" - { - yyval.nodeData = yyvsp[-1].nodeData; - } - break; - - case 35: -#line 210 "gram.y" - { - yyval.nodeId = syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ); - } - break; - - case 37: -#line 217 "gram.y" - { - syck_add_transfer( yyvsp[-2].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion ); - yyval.nodeData = yyvsp[0].nodeData; - } - break; - - case 38: -#line 222 "gram.y" - { - syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion ); - yyval.nodeData = yyvsp[0].nodeData; - } - break; - - case 39: -#line 227 "gram.y" - { - syck_add_transfer( yyvsp[-2].name, yyvsp[0].nodeData, 0 ); - yyval.nodeData = yyvsp[0].nodeData; - } - break; - - case 40: -#line 232 "gram.y" - { - syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, 0 ); - yyval.nodeData = yyvsp[0].nodeData; - } - break; - - case 41: -#line 237 "gram.y" - { - yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-2].name, yyvsp[0].nodeData ); - } - break; - - case 42: -#line 241 "gram.y" - { - yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-1].name, yyvsp[0].nodeData ); - } - break; - - case 43: -#line 247 "gram.y" - { - yyval.nodeData = syck_new_seq( yyvsp[0].nodeId ); - } - break; - - case 44: -#line 251 "gram.y" - { - syck_seq_add( yyvsp[-2].nodeData, yyvsp[0].nodeId ); - yyval.nodeData = yyvsp[-2].nodeData; - } - break; - - case 45: -#line 256 "gram.y" - { - yyval.nodeData = yyvsp[-1].nodeData; - } - break; - - case 46: -#line 265 "gram.y" - { - yyval.nodeData = yyvsp[-1].nodeData; - } - break; - - case 47: -#line 269 "gram.y" - { - yyval.nodeData = syck_alloc_seq(); - } - break; - - case 48: -#line 275 "gram.y" - { - yyval.nodeData = syck_new_seq( syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ) ); - } - break; - - case 49: -#line 279 "gram.y" - { - syck_seq_add( yyvsp[-2].nodeData, syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ) ); - yyval.nodeData = yyvsp[-2].nodeData; - } - break; - - case 50: -#line 289 "gram.y" - { - apply_seq_in_map( (SyckParser *)parser, yyvsp[-1].nodeData ); - yyval.nodeData = yyvsp[-1].nodeData; - } - break; - - case 51: -#line 294 "gram.y" - { - apply_seq_in_map( (SyckParser *)parser, yyvsp[-1].nodeData ); - yyval.nodeData = yyvsp[-1].nodeData; - } - break; - - case 52: -#line 301 "gram.y" - { - syck_add_transfer( yyvsp[-2].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion ); - yyval.nodeData = yyvsp[0].nodeData; - } - break; - - case 53: -#line 306 "gram.y" - { - syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion ); - yyval.nodeData = yyvsp[0].nodeData; - } - break; - - case 54: -#line 311 "gram.y" - { - syck_add_transfer( yyvsp[-2].name, yyvsp[0].nodeData, 0 ); - yyval.nodeData = yyvsp[0].nodeData; - } - break; - - case 55: -#line 316 "gram.y" - { - syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, 0 ); - yyval.nodeData = yyvsp[0].nodeData; - } - break; - - case 56: -#line 321 "gram.y" - { - yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-2].name, yyvsp[0].nodeData ); - } - break; - - case 57: -#line 325 "gram.y" - { - yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-1].name, yyvsp[0].nodeData ); - } - break; - - case 58: -#line 331 "gram.y" - { - yyval.nodeData = syck_new_map( - syck_hdlr_add_node( (SyckParser *)parser, yyvsp[-2].nodeData ), - syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ) ); - } - break; - - case 60: -#line 347 "gram.y" - { - yyval.nodeData = syck_new_map( - syck_hdlr_add_node( (SyckParser *)parser, yyvsp[-3].nodeData ), - syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ) ); - } - break; - - case 62: -#line 356 "gram.y" - { - if ( yyvsp[-2].nodeData->shortcut == NULL ) - { - yyvsp[-2].nodeData->shortcut = syck_new_seq( yyvsp[0].nodeId ); - } - else - { - syck_seq_add( yyvsp[-2].nodeData->shortcut, yyvsp[0].nodeId ); - } - yyval.nodeData = yyvsp[-2].nodeData; - } - break; - - case 63: -#line 368 "gram.y" - { - apply_seq_in_map( (SyckParser *)parser, yyvsp[-2].nodeData ); - syck_map_update( yyvsp[-2].nodeData, yyvsp[0].nodeData ); - syck_free_node( yyvsp[0].nodeData ); - yyval.nodeData = yyvsp[-2].nodeData; - } - break; - - case 64: -#line 375 "gram.y" - { - yyval.nodeData = yyvsp[-1].nodeData; - } - break; - - case 65: -#line 384 "gram.y" - { - yyval.nodeData = syck_new_map( - syck_hdlr_add_node( (SyckParser *)parser, yyvsp[-2].nodeData ), - syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ) ); - } - break; - - case 66: -#line 392 "gram.y" - { - yyval.nodeData = yyvsp[-1].nodeData; - } - break; - - case 67: -#line 396 "gram.y" - { - yyval.nodeData = syck_alloc_map(); - } - break; - - case 69: -#line 403 "gram.y" - { - syck_map_update( yyvsp[-2].nodeData, yyvsp[0].nodeData ); - syck_free_node( yyvsp[0].nodeData ); - yyval.nodeData = yyvsp[-2].nodeData; - } - break; - - - } - -/* Line 1016 of /usr/local/share/bison/yacc.c. */ -#line 1538 "y.tab.c" - - yyvsp -= yylen; - yyssp -= yylen; - - -#if YYDEBUG - if (yydebug) - { - short *yyssp1 = yyss - 1; - YYFPRINTF (stderr, "state stack now"); - while (yyssp1 != yyssp) - YYFPRINTF (stderr, " %d", *++yyssp1); - YYFPRINTF (stderr, "\n"); - } -#endif - - *++yyvsp = yyval; - - - /* Now `shift' the result of the reduction. Determine what state - that goes to, based on the state we popped back to and the rule - number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; - - goto yynewstate; - - -/*------------------------------------. -| yyerrlab -- here on detecting error | -`------------------------------------*/ -yyerrlab: - /* If not already recovering from an error, report this error. */ - if (!yyerrstatus) - { - ++yynerrs; -#if YYERROR_VERBOSE - yyn = yypact[yystate]; - - if (YYPACT_NINF < yyn && yyn < YYLAST) - { - YYSIZE_T yysize = 0; - int yytype = YYTRANSLATE (yychar); - char *yymsg; - int yyx, yycount; - - yycount = 0; - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - for (yyx = yyn < 0 ? -yyn : 0; - yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - yysize += yystrlen (yytname[yyx]) + 15, yycount++; - yysize += yystrlen ("parse error, unexpected ") + 1; - yysize += yystrlen (yytname[yytype]); - yymsg = (char *) YYSTACK_ALLOC (yysize); - if (yymsg != 0) - { - char *yyp = yystpcpy (yymsg, "parse error, unexpected "); - yyp = yystpcpy (yyp, yytname[yytype]); - - if (yycount < 5) - { - yycount = 0; - for (yyx = yyn < 0 ? -yyn : 0; - yyx < (int) (sizeof (yytname) / sizeof (char *)); - yyx++) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - const char *yyq = ! yycount ? ", expecting " : " or "; - yyp = yystpcpy (yyp, yyq); - yyp = yystpcpy (yyp, yytname[yyx]); - yycount++; - } - } - yyerror (yymsg); - YYSTACK_FREE (yymsg); - } - else - yyerror ("parse error; also virtual memory exhausted"); - } - else -#endif /* YYERROR_VERBOSE */ - yyerror ("parse error"); - } - goto yyerrlab1; - - -/*----------------------------------------------------. -| yyerrlab1 -- error raised explicitly by an action. | -`----------------------------------------------------*/ -yyerrlab1: - if (yyerrstatus == 3) - { - /* If just tried and failed to reuse lookahead token after an - error, discard it. */ - - /* Return failure if at end of input. */ - if (yychar == YYEOF) - { - /* Pop the error token. */ - YYPOPSTACK; - /* Pop the rest of the stack. */ - while (yyssp > yyss) - { - YYDPRINTF ((stderr, "Error: popping ")); - YYDSYMPRINT ((stderr, - yystos[*yyssp], - *yyvsp)); - YYDPRINTF ((stderr, "\n")); - yydestruct (yystos[*yyssp], *yyvsp); - YYPOPSTACK; - } - YYABORT; - } - - YYDPRINTF ((stderr, "Discarding token %d (%s).\n", - yychar, yytname[yychar1])); - yydestruct (yychar1, yylval); - yychar = YYEMPTY; - } - - /* Else will try to reuse lookahead token after shifting the error - token. */ - - yyerrstatus = 3; /* Each real token shifted decrements this. */ - - for (;;) - { - yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } - - /* Pop the current state because it cannot handle the error token. */ - if (yyssp == yyss) - YYABORT; - - YYDPRINTF ((stderr, "Error: popping ")); - YYDSYMPRINT ((stderr, - yystos[*yyssp], *yyvsp)); - YYDPRINTF ((stderr, "\n")); - - yydestruct (yystos[yystate], *yyvsp); - yyvsp--; - yystate = *--yyssp; - - -#if YYDEBUG - if (yydebug) - { - short *yyssp1 = yyss - 1; - YYFPRINTF (stderr, "Error: state stack now"); - while (yyssp1 != yyssp) - YYFPRINTF (stderr, " %d", *++yyssp1); - YYFPRINTF (stderr, "\n"); - } -#endif - } - - if (yyn == YYFINAL) - YYACCEPT; - - YYDPRINTF ((stderr, "Shifting error token, ")); - - *++yyvsp = yylval; - - - yystate = yyn; - goto yynewstate; - - -/*-------------------------------------. -| yyacceptlab -- YYACCEPT comes here. | -`-------------------------------------*/ -yyacceptlab: - yyresult = 0; - goto yyreturn; - -/*-----------------------------------. -| yyabortlab -- YYABORT comes here. | -`-----------------------------------*/ -yyabortlab: - yyresult = 1; - goto yyreturn; - -#ifndef yyoverflow -/*----------------------------------------------. -| yyoverflowlab -- parser overflow comes here. | -`----------------------------------------------*/ -yyoverflowlab: - yyerror ("parser stack overflow"); - yyresult = 2; - /* Fall through. */ -#endif - -yyreturn: -#ifndef yyoverflow - if (yyss != yyssa) - YYSTACK_FREE (yyss); -#endif - return yyresult; -} - - -#line 410 "gram.y" - - -void -apply_seq_in_map( SyckParser *parser, SyckNode *n ) -{ - long map_len; - if ( n->shortcut == NULL ) - { - return; - } - - map_len = syck_map_count( n ); - syck_map_assign( n, map_value, map_len - 1, - syck_hdlr_add_node( parser, n->shortcut ) ); - - n->shortcut = NULL; -} - - diff --git a/ext/syck/gram.h b/ext/syck/gram.h deleted file mode 100644 index d1e577b0ee..0000000000 --- a/ext/syck/gram.h +++ /dev/null @@ -1,81 +0,0 @@ -/* A Bison parser, made from gram.y, by GNU bison 1.75. */ - -/* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -#ifndef BISON_Y_TAB_H -# define BISON_Y_TAB_H - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - YAML_ANCHOR = 258, - YAML_ALIAS = 259, - YAML_TRANSFER = 260, - YAML_TAGURI = 261, - YAML_ITRANSFER = 262, - YAML_WORD = 263, - YAML_PLAIN = 264, - YAML_BLOCK = 265, - YAML_DOCSEP = 266, - YAML_IOPEN = 267, - YAML_INDENT = 268, - YAML_IEND = 269 - }; -#endif -#define YAML_ANCHOR 258 -#define YAML_ALIAS 259 -#define YAML_TRANSFER 260 -#define YAML_TAGURI 261 -#define YAML_ITRANSFER 262 -#define YAML_WORD 263 -#define YAML_PLAIN 264 -#define YAML_BLOCK 265 -#define YAML_DOCSEP 266 -#define YAML_IOPEN 267 -#define YAML_INDENT 268 -#define YAML_IEND 269 - - - - -#ifndef YYSTYPE -#line 23 "gram.y" -typedef union { - SYMID nodeId; - SyckNode *nodeData; - char *name; -} yystype; -/* Line 1281 of /usr/local/share/bison/yacc.c. */ -#line 74 "y.tab.h" -# define YYSTYPE yystype -#endif - - - - -#endif /* not BISON_Y_TAB_H */ - diff --git a/ext/syck/handler.c b/ext/syck/handler.c deleted file mode 100644 index eddc6465af..0000000000 --- a/ext/syck/handler.c +++ /dev/null @@ -1,156 +0,0 @@ -/* - * handler.c - * - * $Author$ - * $Date$ - * - * Copyright (C) 2003 why the lucky stiff - */ - -#include "syck.h" -#include "ruby.h" - -SYMID -syck_hdlr_add_node( SyckParser *p, SyckNode *n ) -{ - SYMID id; - - if ( ! n->id ) - { - n->id = (p->handler)( p, n ); - } - id = n->id; - - if ( n->anchor == NULL ) - { - syck_free_node( n ); - } - return id; -} - -SyckNode * -syck_hdlr_add_anchor( SyckParser *p, char *a, SyckNode *n ) -{ - n->anchor = a; - if ( p->bad_anchors != NULL ) - { - SyckNode *bad; - if ( st_lookup( p->bad_anchors, (st_data_t)a, (st_data_t *)&bad ) ) - { - if ( n->kind != syck_str_kind ) - { - n->id = bad->id; - (p->handler)( p, n ); - } - } - } - if ( p->anchors == NULL ) - { - p->anchors = st_init_strtable(); - } - st_insert( p->anchors, (st_data_t)a, (st_data_t)n ); - return n; -} - -void -syck_hdlr_remove_anchor( SyckParser *p, char *a ) -{ - if ( p->anchors == NULL ) - { - p->anchors = st_init_strtable(); - } - st_insert( p->anchors, (st_data_t)a, (st_data_t)1 ); -} - -SyckNode * -syck_hdlr_get_anchor( SyckParser *p, char *a ) -{ - SyckNode *n = NULL; - - if ( p->anchors != NULL ) - { - if ( st_lookup( p->anchors, (st_data_t)a, (st_data_t *)&n ) ) - { - if ( n != (void *)1 ) - { - S_FREE( a ); - return n; - } - else - { - if ( p->bad_anchors == NULL ) - { - p->bad_anchors = st_init_strtable(); - } - if ( ! st_lookup( p->bad_anchors, (st_data_t)a, (st_data_t *)&n ) ) - { - n = (p->bad_anchor_handler)( p, a ); - st_insert( p->bad_anchors, (st_data_t)a, (st_data_t)n ); - } - } - } - } - - if ( n == NULL ) - { - n = (p->bad_anchor_handler)( p, a ); - } - - if ( n->anchor ) - { - S_FREE( a ); - } - else - { - n->anchor = a; - } - - return n; -} - -void -syck_add_transfer( char *uri, SyckNode *n, int taguri ) -{ - if ( n->type_id != NULL ) - { - S_FREE( n->type_id ); - } - - if ( taguri == 0 ) - { - n->type_id = uri; - return; - } - - n->type_id = syck_type_id_to_uri( uri ); - S_FREE( uri ); -} - -char * -syck_xprivate( char *type_id, int type_len ) -{ - char *uri = S_ALLOC_N( char, type_len + 14 ); - uri[0] = '\0'; - strcat( uri, "x-private:" ); - strncat( uri, type_id, type_len ); - return uri; -} - -char * -syck_taguri( char *domain, char *type_id, int type_len ) -{ - char *uri = S_ALLOC_N( char, strlen( domain ) + type_len + 14 ); - uri[0] = '\0'; - strcat( uri, "tag:" ); - strcat( uri, domain ); - strcat( uri, ":" ); - strncat( uri, type_id, type_len ); - return uri; -} - -int -syck_try_implicit( SyckNode *n ) -{ - return 1; -} - diff --git a/ext/syck/implicit.c b/ext/syck/implicit.c deleted file mode 100644 index 1dfeac3953..0000000000 --- a/ext/syck/implicit.c +++ /dev/null @@ -1,2808 +0,0 @@ -/* Generated by re2c 0.5 on Thu Oct 16 14:12:57 2003 */ -#line 1 "implicit.re" -/* - * implicit.re - * - * $Author$ - * $Date$ - * - * Copyright (C) 2003 why the lucky stiff - */ - -#include "syck.h" -#include "ruby.h" - -#define YYCTYPE char -#define YYCURSOR cursor -#define YYMARKER marker -#define YYLIMIT limit -#define YYFILL(n) - -void -try_tag_implicit( SyckNode *n, int taguri ) -{ - char *tid = ""; - switch ( n->kind ) - { - case syck_str_kind: - tid = syck_match_implicit( n->data.str->ptr, n->data.str->len ); - break; - - case syck_seq_kind: - tid = "seq"; - break; - - case syck_map_kind: - tid = "map"; - break; - } - if ( taguri == 1 ) - { - n->type_id = syck_taguri( YAML_DOMAIN, tid, strlen( tid ) ); - } else { - n->type_id = syck_strndup( tid, strlen( tid ) ); - } -} - -char *syck_match_implicit( char *str, size_t len ) -{ - char *cursor, *limit, *marker; - cursor = str; - limit = str + len; - -{ - YYCTYPE yych; - unsigned int yyaccept; - goto yy0; -yy1: ++YYCURSOR; -yy0: - if((YYLIMIT - YYCURSOR) < 26) YYFILL(26); - yych = *YYCURSOR; - switch(yych){ - case '\000': goto yy6; - case '+': goto yy16; - case '-': goto yy17; - case '.': goto yy20; - case '0': goto yy18; - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy19; - case '<': goto yy22; - case '=': goto yy21; - case 'F': goto yy15; - case 'N': goto yy5; - case 'O': goto yy13; - case 'T': goto yy9; - case 'Y': goto yy11; - case 'f': goto yy14; - case 'n': goto yy4; - case 'o': goto yy12; - case 't': goto yy8; - case 'y': goto yy10; - case '~': goto yy2; - default: goto yy23; - } -yy2: yych = *++YYCURSOR; - if(yych <= '\000') goto yy6; -yy3: -#line 116 - { return "str"; } -yy4: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case 'o': goto yy163; - case 'u': goto yy191; - default: goto yy3; - } -yy5: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case 'O': case 'o': goto yy163; - case 'U': goto yy186; - case 'u': goto yy187; - default: goto yy3; - } -yy6: yych = *++YYCURSOR; -yy7: -#line 82 - { return "null"; } -yy8: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case 'r': goto yy184; - default: goto yy3; - } -yy9: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case 'R': goto yy180; - case 'r': goto yy181; - default: goto yy3; - } -yy10: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case 'e': goto yy179; - default: goto yy3; - } -yy11: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case 'E': goto yy177; - case 'e': goto yy178; - default: goto yy3; - } -yy12: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case 'f': goto yy176; - case 'n': goto yy173; - default: goto yy3; - } -yy13: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case 'F': goto yy171; - case 'N': case 'n': goto yy173; - case 'f': goto yy172; - default: goto yy3; - } -yy14: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case 'a': goto yy168; - default: goto yy3; - } -yy15: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case 'A': goto yy159; - case 'a': goto yy160; - default: goto yy3; - } -yy16: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case '.': goto yy158; - case '0': goto yy149; - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy47; - default: goto yy3; - } -yy17: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case '.': goto yy148; - case '0': goto yy149; - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy47; - default: goto yy3; - } -yy18: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case '\000': goto yy51; - case ',': goto yy133; - case '.': goto yy49; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': goto yy131; - case '8': - case '9': goto yy132; - case 'x': goto yy135; - default: goto yy3; - } -yy19: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case '\000': goto yy51; - case ',': goto yy47; - case '.': goto yy49; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy46; - default: goto yy3; - } -yy20: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case 'I': goto yy33; - case 'N': goto yy31; - case 'i': goto yy32; - case 'n': goto yy30; - default: goto yy3; - } -yy21: yych = *++YYCURSOR; - if(yych <= '\000') goto yy28; - goto yy3; -yy22: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case '<': goto yy24; - default: goto yy3; - } -yy23: yych = *++YYCURSOR; - goto yy3; -yy24: yych = *++YYCURSOR; - if(yych <= '\000') goto yy26; -yy25: YYCURSOR = YYMARKER; - switch(yyaccept){ - case 0: goto yy3; - } -yy26: yych = *++YYCURSOR; -yy27: -#line 114 - { return "merge"; } -yy28: yych = *++YYCURSOR; -yy29: -#line 112 - { return "default"; } -yy30: yych = *++YYCURSOR; - switch(yych){ - case 'a': goto yy45; - default: goto yy25; - } -yy31: yych = *++YYCURSOR; - switch(yych){ - case 'A': goto yy40; - case 'a': goto yy41; - default: goto yy25; - } -yy32: yych = *++YYCURSOR; - switch(yych){ - case 'n': goto yy39; - default: goto yy25; - } -yy33: yych = *++YYCURSOR; - switch(yych){ - case 'N': goto yy34; - case 'n': goto yy35; - default: goto yy25; - } -yy34: yych = *++YYCURSOR; - switch(yych){ - case 'F': goto yy36; - default: goto yy25; - } -yy35: yych = *++YYCURSOR; - switch(yych){ - case 'f': goto yy36; - default: goto yy25; - } -yy36: yych = *++YYCURSOR; - if(yych >= '\001') goto yy25; -yy37: yych = *++YYCURSOR; -yy38: -#line 98 - { return "float#inf"; } -yy39: yych = *++YYCURSOR; - switch(yych){ - case 'f': goto yy36; - default: goto yy25; - } -yy40: yych = *++YYCURSOR; - switch(yych){ - case 'N': goto yy42; - default: goto yy25; - } -yy41: yych = *++YYCURSOR; - switch(yych){ - case 'N': goto yy42; - default: goto yy25; - } -yy42: yych = *++YYCURSOR; - if(yych >= '\001') goto yy25; -yy43: yych = *++YYCURSOR; -yy44: -#line 102 - { return "float#nan"; } -yy45: yych = *++YYCURSOR; - switch(yych){ - case 'n': goto yy42; - default: goto yy25; - } -yy46: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy65; - default: goto yy48; - } -yy47: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy48: switch(yych){ - case '\000': goto yy51; - case ',': case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy47; - case '.': goto yy49; - default: goto yy25; - } -yy49: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy50: switch(yych){ - case '\000': goto yy55; - case ',': goto yy53; - case '.': goto yy57; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy49; - case 'E': case 'e': goto yy59; - default: goto yy25; - } -yy51: yych = *++YYCURSOR; -yy52: -#line 92 - { return "int"; } -yy53: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy54: switch(yych){ - case '\000': goto yy55; - case ',': case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy53; - default: goto yy25; - } -yy55: yych = *++YYCURSOR; -yy56: -#line 94 - { return "float#fix"; } -yy57: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy58: switch(yych){ - case '.': case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy57; - case 'E': case 'e': goto yy59; - default: goto yy25; - } -yy59: yych = *++YYCURSOR; - switch(yych){ - case '+': case '-': goto yy60; - default: goto yy25; - } -yy60: yych = *++YYCURSOR; - if(yych <= '\000') goto yy25; - goto yy62; -yy61: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy62: switch(yych){ - case '\000': goto yy63; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy61; - default: goto yy25; - } -yy63: yych = *++YYCURSOR; -yy64: -#line 96 - { return "float#exp"; } -yy65: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy66; - default: goto yy48; - } -yy66: yych = *++YYCURSOR; - switch(yych){ - case '-': goto yy67; - default: goto yy48; - } -yy67: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy68; - default: goto yy25; - } -yy68: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy69; - default: goto yy25; - } -yy69: yych = *++YYCURSOR; - switch(yych){ - case '-': goto yy70; - default: goto yy25; - } -yy70: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy71; - default: goto yy25; - } -yy71: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy72; - default: goto yy25; - } -yy72: yych = *++YYCURSOR; - switch(yych){ - case '\000': goto yy73; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy25; - case 'T': goto yy75; - case 't': goto yy76; - default: goto yy78; - } -yy73: yych = *++YYCURSOR; -yy74: -#line 104 - { return "timestamp#ymd"; } -yy75: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy117; - default: goto yy25; - } -yy76: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy99; - default: goto yy25; - } -yy77: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy78: switch(yych){ - case '\t': case ' ': goto yy77; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy79; - default: goto yy25; - } -yy79: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy80; - default: goto yy25; - } -yy80: yych = *++YYCURSOR; - switch(yych){ - case ':': goto yy81; - default: goto yy25; - } -yy81: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy82; - default: goto yy25; - } -yy82: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy83; - default: goto yy25; - } -yy83: yych = *++YYCURSOR; - switch(yych){ - case ':': goto yy84; - default: goto yy25; - } -yy84: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy85; - default: goto yy25; - } -yy85: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy86; - default: goto yy25; - } -yy86: yych = *++YYCURSOR; - switch(yych){ - case '\t': case ' ': goto yy89; - case '.': goto yy87; - default: goto yy25; - } -yy87: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy88: switch(yych){ - case '\t': case ' ': goto yy89; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy87; - default: goto yy25; - } -yy89: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy90: switch(yych){ - case '\t': case ' ': goto yy89; - case '+': case '-': goto yy92; - case 'Z': goto yy91; - default: goto yy25; - } -yy91: yych = *++YYCURSOR; - if(yych <= '\000') goto yy96; - goto yy25; -yy92: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy93; - default: goto yy25; - } -yy93: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy94; - default: goto yy25; - } -yy94: yych = *++YYCURSOR; - switch(yych){ - case '\000': goto yy96; - case ':': goto yy95; - default: goto yy25; - } -yy95: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy98; - default: goto yy25; - } -yy96: yych = *++YYCURSOR; -yy97: -#line 108 - { return "timestamp#spaced"; } -yy98: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy91; - default: goto yy25; - } -yy99: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy100; - default: goto yy25; - } -yy100: yych = *++YYCURSOR; - switch(yych){ - case ':': goto yy101; - default: goto yy25; - } -yy101: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy102; - default: goto yy25; - } -yy102: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy103; - default: goto yy25; - } -yy103: yych = *++YYCURSOR; - switch(yych){ - case ':': goto yy104; - default: goto yy25; - } -yy104: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy105; - default: goto yy25; - } -yy105: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy106; - default: goto yy25; - } -yy106: yych = *++YYCURSOR; - switch(yych){ - case '.': goto yy107; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy25; - default: goto yy108; - } -yy107: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy108: switch(yych){ - case '+': case '-': goto yy110; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy107; - case 'Z': goto yy109; - default: goto yy25; - } -yy109: yych = *++YYCURSOR; - if(yych <= '\000') goto yy114; - goto yy25; -yy110: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy111; - default: goto yy25; - } -yy111: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy112; - default: goto yy25; - } -yy112: yych = *++YYCURSOR; - switch(yych){ - case '\000': goto yy114; - case ':': goto yy113; - default: goto yy25; - } -yy113: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy116; - default: goto yy25; - } -yy114: yych = *++YYCURSOR; -yy115: -#line 106 - { return "timestamp#iso8601"; } -yy116: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy109; - default: goto yy25; - } -yy117: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy118; - default: goto yy25; - } -yy118: yych = *++YYCURSOR; - switch(yych){ - case ':': goto yy119; - default: goto yy25; - } -yy119: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy120; - default: goto yy25; - } -yy120: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy121; - default: goto yy25; - } -yy121: yych = *++YYCURSOR; - switch(yych){ - case ':': goto yy122; - default: goto yy25; - } -yy122: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy123; - default: goto yy25; - } -yy123: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy124; - default: goto yy25; - } -yy124: yych = *++YYCURSOR; - switch(yych){ - case '.': goto yy125; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy25; - case 'Z': goto yy127; - default: goto yy126; - } -yy125: ++YYCURSOR; - if((YYLIMIT - YYCURSOR) < 7) YYFILL(7); - yych = *YYCURSOR; -yy126: switch(yych){ - case '+': case '-': goto yy110; - case '0': goto yy125; - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy129; - case 'Z': goto yy109; - default: goto yy25; - } -yy127: yych = *++YYCURSOR; - if(yych >= '\001') goto yy25; -yy128: yych = *++YYCURSOR; - goto yy115; -yy129: ++YYCURSOR; - if((YYLIMIT - YYCURSOR) < 7) YYFILL(7); - yych = *YYCURSOR; -yy130: switch(yych){ - case '+': case '-': goto yy110; - case '0': goto yy125; - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy129; - case 'Z': goto yy127; - default: goto yy25; - } -yy131: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': goto yy146; - case '8': - case '9': goto yy144; - default: goto yy134; - } -yy132: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy144; - default: goto yy143; - } -yy133: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy134: switch(yych){ - case '\000': goto yy140; - case ',': case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': goto yy133; - case '.': goto yy49; - case '8': - case '9': goto yy142; - default: goto yy25; - } -yy135: yych = *++YYCURSOR; - if(yych <= '\000') goto yy25; - goto yy137; -yy136: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy137: switch(yych){ - case '\000': goto yy138; - case ',': case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': goto yy136; - default: goto yy25; - } -yy138: yych = *++YYCURSOR; -yy139: -#line 88 - { return "int#hex"; } -yy140: yych = *++YYCURSOR; -yy141: -#line 90 - { return "int#oct"; } -yy142: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy143: switch(yych){ - case ',': case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy142; - case '.': goto yy49; - default: goto yy25; - } -yy144: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy145; - default: goto yy143; - } -yy145: yych = *++YYCURSOR; - switch(yych){ - case '-': goto yy67; - default: goto yy143; - } -yy146: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': goto yy147; - case '8': - case '9': goto yy145; - default: goto yy134; - } -yy147: yych = *++YYCURSOR; - switch(yych){ - case '-': goto yy67; - default: goto yy134; - } -yy148: yych = *++YYCURSOR; - switch(yych){ - case 'I': goto yy151; - case 'i': goto yy150; - default: goto yy25; - } -yy149: yych = *++YYCURSOR; - switch(yych){ - case '\000': goto yy51; - case 'x': goto yy135; - default: goto yy134; - } -yy150: yych = *++YYCURSOR; - switch(yych){ - case 'n': goto yy157; - default: goto yy25; - } -yy151: yych = *++YYCURSOR; - switch(yych){ - case 'N': goto yy152; - case 'n': goto yy153; - default: goto yy25; - } -yy152: yych = *++YYCURSOR; - switch(yych){ - case 'F': goto yy154; - default: goto yy25; - } -yy153: yych = *++YYCURSOR; - switch(yych){ - case 'f': goto yy154; - default: goto yy25; - } -yy154: yych = *++YYCURSOR; - if(yych >= '\001') goto yy25; -yy155: yych = *++YYCURSOR; -yy156: -#line 100 - { return "float#neginf"; } -yy157: yych = *++YYCURSOR; - switch(yych){ - case 'f': goto yy154; - default: goto yy25; - } -yy158: yych = *++YYCURSOR; - switch(yych){ - case 'I': goto yy33; - case 'i': goto yy32; - default: goto yy25; - } -yy159: yych = *++YYCURSOR; - switch(yych){ - case 'L': goto yy166; - default: goto yy25; - } -yy160: yych = *++YYCURSOR; - switch(yych){ - case 'l': goto yy161; - default: goto yy25; - } -yy161: yych = *++YYCURSOR; - switch(yych){ - case 's': goto yy162; - default: goto yy25; - } -yy162: yych = *++YYCURSOR; - switch(yych){ - case 'e': goto yy163; - default: goto yy25; - } -yy163: yych = *++YYCURSOR; - if(yych >= '\001') goto yy25; -yy164: yych = *++YYCURSOR; -yy165: -#line 86 - { return "bool#no"; } -yy166: yych = *++YYCURSOR; - switch(yych){ - case 'S': goto yy167; - default: goto yy25; - } -yy167: yych = *++YYCURSOR; - switch(yych){ - case 'E': goto yy163; - default: goto yy25; - } -yy168: yych = *++YYCURSOR; - switch(yych){ - case 'l': goto yy169; - default: goto yy25; - } -yy169: yych = *++YYCURSOR; - switch(yych){ - case 's': goto yy170; - default: goto yy25; - } -yy170: yych = *++YYCURSOR; - switch(yych){ - case 'e': goto yy163; - default: goto yy25; - } -yy171: yych = *++YYCURSOR; - switch(yych){ - case 'F': goto yy163; - default: goto yy25; - } -yy172: yych = *++YYCURSOR; - switch(yych){ - case 'f': goto yy163; - default: goto yy25; - } -yy173: yych = *++YYCURSOR; - if(yych >= '\001') goto yy25; -yy174: yych = *++YYCURSOR; -yy175: -#line 84 - { return "bool#yes"; } -yy176: yych = *++YYCURSOR; - switch(yych){ - case 'f': goto yy163; - default: goto yy25; - } -yy177: yych = *++YYCURSOR; - switch(yych){ - case 'S': goto yy173; - default: goto yy25; - } -yy178: yych = *++YYCURSOR; - switch(yych){ - case 's': goto yy173; - default: goto yy25; - } -yy179: yych = *++YYCURSOR; - switch(yych){ - case 's': goto yy173; - default: goto yy25; - } -yy180: yych = *++YYCURSOR; - switch(yych){ - case 'U': goto yy183; - default: goto yy25; - } -yy181: yych = *++YYCURSOR; - switch(yych){ - case 'u': goto yy182; - default: goto yy25; - } -yy182: yych = *++YYCURSOR; - switch(yych){ - case 'e': goto yy173; - default: goto yy25; - } -yy183: yych = *++YYCURSOR; - switch(yych){ - case 'E': goto yy173; - default: goto yy25; - } -yy184: yych = *++YYCURSOR; - switch(yych){ - case 'u': goto yy185; - default: goto yy25; - } -yy185: yych = *++YYCURSOR; - switch(yych){ - case 'e': goto yy173; - default: goto yy25; - } -yy186: yych = *++YYCURSOR; - switch(yych){ - case 'L': goto yy190; - default: goto yy25; - } -yy187: yych = *++YYCURSOR; - switch(yych){ - case 'l': goto yy188; - default: goto yy25; - } -yy188: yych = *++YYCURSOR; - switch(yych){ - case 'l': goto yy189; - default: goto yy25; - } -yy189: yych = *++YYCURSOR; - if(yych <= '\000') goto yy6; - goto yy25; -yy190: yych = *++YYCURSOR; - switch(yych){ - case 'L': goto yy189; - default: goto yy25; - } -yy191: yych = *++YYCURSOR; - switch(yych){ - case 'l': goto yy192; - default: goto yy25; - } -yy192: yych = *++YYCURSOR; - switch(yych){ - case 'l': goto yy189; - default: goto yy25; - } -} -#line 118 - - -} - -char * -syck_type_id_to_uri( char *type_id ) -{ - char *cursor, *limit, *marker; - - cursor = type_id; - limit = type_id + strlen( type_id ); - -{ - YYCTYPE yych; - unsigned int yyaccept; - goto yy193; -yy194: ++YYCURSOR; -yy193: - if((YYLIMIT - YYCURSOR) < 21) YYFILL(21); - yych = *YYCURSOR; - switch(yych){ - case '\000': goto yy195; - case '!': goto yy199; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': case '_': case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': case 'u': - case 'v': - case 'w': case 'y': - case 'z': goto yy201; - case 't': goto yy196; - case 'x': goto yy198; - default: goto yy202; - } -yy195: YYCURSOR = YYMARKER; - switch(yyaccept){ - case 0: goto yy197; - } -yy196: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case ',': goto yy207; - case '-': goto yy203; - case '.': goto yy208; - case '/': goto yy209; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': case '_': case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto yy205; - case 'a': goto yy237; - default: goto yy197; - } -yy197: -#line 170 - { return syck_taguri( YAML_DOMAIN, type_id, strlen( type_id ) ); } -yy198: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case ',': case '.': - case '/': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': case '_': case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto yy206; - case '-': goto yy227; - default: goto yy197; - } -yy199: yych = *++YYCURSOR; -yy200: -#line 144 - { return syck_xprivate( type_id + 1, strlen( type_id ) - 1 ); } -yy201: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case ',': goto yy207; - case '-': goto yy203; - case '.': goto yy208; - case '/': goto yy209; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': case '_': case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto yy205; - default: goto yy197; - } -yy202: yych = *++YYCURSOR; - goto yy197; -yy203: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy204: switch(yych){ - case '-': goto yy203; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': case '_': case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto yy205; - default: goto yy195; - } -yy205: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy206: switch(yych){ - case ',': goto yy207; - case '-': goto yy203; - case '.': goto yy208; - case '/': goto yy209; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': case '_': case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto yy205; - default: goto yy195; - } -yy207: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy215; - default: goto yy195; - } -yy208: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': case '_': case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto yy211; - default: goto yy195; - } -yy209: yych = *++YYCURSOR; -yy210: -#line 146 - { char *domain = S_ALLOC_N( char, ( YYCURSOR - type_id ) + 15 ); - char *uri; - - domain[0] = '\0'; - strncat( domain, type_id, ( YYCURSOR - type_id ) - 1 ); - strcat( domain, "." ); - strcat( domain, YAML_DOMAIN ); - uri = syck_taguri( domain, YYCURSOR, YYLIMIT - YYCURSOR ); - - S_FREE( domain ); - return uri; - } -yy211: ++YYCURSOR; - if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); - yych = *YYCURSOR; -yy212: switch(yych){ - case ',': goto yy207; - case '-': goto yy213; - case '.': goto yy208; - case '/': goto yy209; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': case '_': case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto yy211; - default: goto yy195; - } -yy213: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy214: switch(yych){ - case '-': goto yy213; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': case '_': case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto yy211; - default: goto yy195; - } -yy215: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy216; - default: goto yy195; - } -yy216: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy217; - default: goto yy195; - } -yy217: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy218; - default: goto yy195; - } -yy218: yych = *++YYCURSOR; - switch(yych){ - case '-': goto yy219; - case '/': goto yy220; - default: goto yy195; - } -yy219: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy222; - default: goto yy195; - } -yy220: yych = *++YYCURSOR; -yy221: -#line 159 - { char *domain = S_ALLOC_N( char, YYCURSOR - type_id ); - char *uri; - - domain[0] = '\0'; - strncat( domain, type_id, ( YYCURSOR - type_id ) - 1 ); - uri = syck_taguri( domain, YYCURSOR, YYLIMIT - YYCURSOR ); - - S_FREE( domain ); - return uri; - } -yy222: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy223; - default: goto yy195; - } -yy223: yych = *++YYCURSOR; - switch(yych){ - case '-': goto yy224; - case '/': goto yy220; - default: goto yy195; - } -yy224: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy225; - default: goto yy195; - } -yy225: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy226; - default: goto yy195; - } -yy226: yych = *++YYCURSOR; - switch(yych){ - case '/': goto yy220; - default: goto yy195; - } -yy227: yych = *++YYCURSOR; - switch(yych){ - case 'p': goto yy228; - default: goto yy204; - } -yy228: yych = *++YYCURSOR; - switch(yych){ - case ',': goto yy207; - case '.': goto yy208; - case '/': goto yy209; - case 'r': goto yy229; - default: goto yy204; - } -yy229: yych = *++YYCURSOR; - switch(yych){ - case ',': goto yy207; - case '.': goto yy208; - case '/': goto yy209; - case 'i': goto yy230; - default: goto yy204; - } -yy230: yych = *++YYCURSOR; - switch(yych){ - case ',': goto yy207; - case '.': goto yy208; - case '/': goto yy209; - case 'v': goto yy231; - default: goto yy204; - } -yy231: yych = *++YYCURSOR; - switch(yych){ - case ',': goto yy207; - case '.': goto yy208; - case '/': goto yy209; - case 'a': goto yy232; - default: goto yy204; - } -yy232: yych = *++YYCURSOR; - switch(yych){ - case ',': goto yy207; - case '.': goto yy208; - case '/': goto yy209; - case 't': goto yy233; - default: goto yy204; - } -yy233: yych = *++YYCURSOR; - switch(yych){ - case ',': goto yy207; - case '.': goto yy208; - case '/': goto yy209; - case 'e': goto yy234; - default: goto yy204; - } -yy234: yych = *++YYCURSOR; - switch(yych){ - case ',': goto yy207; - case '.': goto yy208; - case '/': goto yy209; - case ':': goto yy235; - default: goto yy204; - } -yy235: yych = *++YYCURSOR; -yy236: -#line 142 - { return type_id; } -yy237: yych = *++YYCURSOR; - switch(yych){ - case ',': goto yy207; - case '.': goto yy208; - case '/': goto yy209; - case 'g': goto yy238; - default: goto yy204; - } -yy238: yych = *++YYCURSOR; - switch(yych){ - case ',': goto yy207; - case '.': goto yy208; - case '/': goto yy209; - case ':': goto yy239; - default: goto yy204; - } -yy239: yych = *++YYCURSOR; - switch(yych){ - case ',': - case '-': - case '.': goto yy195; - default: goto yy241; - } -yy240: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy241: switch(yych){ - case ',': goto yy244; - case '-': goto yy242; - case '.': goto yy245; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': case '_': case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto yy240; - default: goto yy195; - } -yy242: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy243: switch(yych){ - case '-': goto yy242; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': case '_': case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto yy240; - default: goto yy195; - } -yy244: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy250; - default: goto yy195; - } -yy245: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': case '_': case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto yy246; - default: goto yy195; - } -yy246: ++YYCURSOR; - if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); - yych = *YYCURSOR; -yy247: switch(yych){ - case ',': goto yy244; - case '-': goto yy248; - case '.': goto yy245; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': case '_': case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto yy246; - default: goto yy195; - } -yy248: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy249: switch(yych){ - case '-': goto yy248; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': case '_': case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto yy246; - default: goto yy195; - } -yy250: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy251; - default: goto yy195; - } -yy251: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy252; - default: goto yy195; - } -yy252: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy253; - default: goto yy195; - } -yy253: yych = *++YYCURSOR; - switch(yych){ - case '-': goto yy254; - case ':': goto yy255; - default: goto yy195; - } -yy254: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy257; - default: goto yy195; - } -yy255: yych = *++YYCURSOR; -yy256: -#line 140 - { return type_id; } -yy257: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy258; - default: goto yy195; - } -yy258: yych = *++YYCURSOR; - switch(yych){ - case '-': goto yy259; - case ':': goto yy255; - default: goto yy195; - } -yy259: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy260; - default: goto yy195; - } -yy260: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy261; - default: goto yy195; - } -yy261: yych = *++YYCURSOR; - switch(yych){ - case ':': goto yy255; - default: goto yy195; - } -} -#line 172 - - -} - diff --git a/ext/syck/node.c b/ext/syck/node.c deleted file mode 100644 index f999700554..0000000000 --- a/ext/syck/node.c +++ /dev/null @@ -1,324 +0,0 @@ -/* - * node.c - * - * $Author$ - * $Date$ - * - * Copyright (C) 2003 why the lucky stiff - */ - -#include "syck.h" -#include "ruby.h" - -/* - * Node allocation functions - */ -SyckNode * -syck_alloc_node( enum syck_kind_tag type ) -{ - SyckNode *s; - - s = S_ALLOC( SyckNode ); - s->kind = type; - s->id = 0; - s->type_id = NULL; - s->anchor = NULL; - s->shortcut = NULL; - - return s; -} - -void -syck_free_node( SyckNode *n ) -{ - syck_free_members( n ); - if ( n->type_id != NULL ) - S_FREE( n->type_id ); - if ( n->anchor != NULL ) - S_FREE( n->anchor ); - S_FREE( n ); -} - -SyckNode * -syck_alloc_map() -{ - SyckNode *n; - struct SyckMap *m; - - m = S_ALLOC( struct SyckMap ); - m->idx = 0; - m->capa = ALLOC_CT; - m->keys = S_ALLOC_N( SYMID, m->capa ); - m->values = S_ALLOC_N( SYMID, m->capa ); - - n = syck_alloc_node( syck_map_kind ); - n->data.pairs = m; - - return n; -} - -SyckNode * -syck_alloc_seq() -{ - SyckNode *n; - struct SyckSeq *s; - - s = S_ALLOC( struct SyckSeq ); - s->idx = 0; - s->capa = ALLOC_CT; - s->items = S_ALLOC_N( SYMID, s->capa ); - - n = syck_alloc_node( syck_seq_kind ); - n->data.list = s; - - return n; -} - -SyckNode * -syck_alloc_str() -{ - SyckNode *n; - struct SyckStr *s; - - s = S_ALLOC( struct SyckStr ); - s->len = 0; - s->ptr = NULL; - - n = syck_alloc_node( syck_str_kind ); - n->data.str = s; - - return n; -} - -SyckNode * -syck_new_str( char *str ) -{ - return syck_new_str2( str, strlen( str ) ); -} - -SyckNode * -syck_new_str2( char *str, long len ) -{ - SyckNode *n; - - n = syck_alloc_str(); - n->data.str->ptr = S_ALLOC_N( char, len + 1 ); - n->data.str->len = len; - memcpy( n->data.str->ptr, str, len ); - n->data.str->ptr[len] = '\0'; - - return n; -} - -void -syck_str_blow_away_commas( SyckNode *n ) -{ - char *go, *end; - - go = n->data.str->ptr; - end = go + n->data.str->len; - while ( *(++go) != '\0' ) - { - if ( *go == ',' ) - { - n->data.str->len -= 1; - memmove( go, go + 1, end - go ); - end -= 1; - } - } -} - -char * -syck_str_read( SyckNode *n ) -{ - ASSERT( n != NULL ); - return n->data.str->ptr; -} - -SyckNode * -syck_new_map( SYMID key, SYMID value ) -{ - SyckNode *n; - - n = syck_alloc_map(); - syck_map_add( n, key, value ); - - return n; -} - -void -syck_map_add( SyckNode *map, SYMID key, SYMID value ) -{ - struct SyckMap *m; - long idx; - - ASSERT( map != NULL ); - ASSERT( map->data.pairs != NULL ); - - m = map->data.pairs; - idx = m->idx; - m->idx += 1; - if ( m->idx > m->capa ) - { - m->capa += ALLOC_CT; - S_REALLOC_N( m->keys, SYMID, m->capa ); - S_REALLOC_N( m->values, SYMID, m->capa ); - } - m->keys[idx] = key; - m->values[idx] = value; -} - -void -syck_map_update( SyckNode *map1, SyckNode *map2 ) -{ - struct SyckMap *m1, *m2; - long new_idx, new_capa; - ASSERT( map1 != NULL ); - ASSERT( map2 != NULL ); - - m1 = map1->data.pairs; - m2 = map2->data.pairs; - if ( m2->idx < 1 ) return; - - new_idx = m1->idx; - new_idx += m2->idx; - new_capa = m1->capa; - while ( new_idx > new_capa ) - { - new_capa += ALLOC_CT; - } - if ( new_capa > m1->capa ) - { - m1->capa = new_capa; - S_REALLOC_N( m1->keys, SYMID, m1->capa ); - S_REALLOC_N( m1->values, SYMID, m1->capa ); - } - for ( new_idx = 0; new_idx < m2->idx; m1->idx++, new_idx++ ) - { - m1->keys[m1->idx] = m2->keys[new_idx]; - m1->values[m1->idx] = m2->values[new_idx]; - } -} - -long -syck_map_count( SyckNode *map ) -{ - ASSERT( map != NULL ); - ASSERT( map->data.pairs != NULL ); - return map->data.pairs->idx; -} - -void -syck_map_assign( SyckNode *map, enum map_part p, long idx, SYMID id ) -{ - struct SyckMap *m; - - ASSERT( map != NULL ); - m = map->data.pairs; - ASSERT( m != NULL ); - if ( p == map_key ) - { - m->keys[idx] = id; - } - else - { - m->values[idx] = id; - } -} - -SYMID -syck_map_read( SyckNode *map, enum map_part p, long idx ) -{ - struct SyckMap *m; - - ASSERT( map != NULL ); - m = map->data.pairs; - ASSERT( m != NULL ); - if ( p == map_key ) - { - return m->keys[idx]; - } - else - { - return m->values[idx]; - } -} - -SyckNode * -syck_new_seq( SYMID value ) -{ - SyckNode *n; - - n = syck_alloc_seq(); - syck_seq_add( n, value ); - - return n; -} - -void -syck_seq_add( SyckNode *arr, SYMID value ) -{ - struct SyckSeq *s; - long idx; - - ASSERT( arr != NULL ); - ASSERT( arr->data.list != NULL ); - - s = arr->data.list; - idx = s->idx; - s->idx += 1; - if ( s->idx > s->capa ) - { - s->capa += ALLOC_CT; - S_REALLOC_N( s->items, SYMID, s->capa ); - } - s->items[idx] = value; -} - -long -syck_seq_count( SyckNode *seq ) -{ - ASSERT( seq != NULL ); - ASSERT( seq->data.list != NULL ); - return seq->data.list->idx; -} - -SYMID -syck_seq_read( SyckNode *seq, long idx ) -{ - struct SyckSeq *s; - - ASSERT( seq != NULL ); - s = seq->data.list; - ASSERT( s != NULL ); - return s->items[idx]; -} - -void -syck_free_members( SyckNode *n ) -{ - switch ( n->kind ) - { - case syck_str_kind: - if ( n->data.str->ptr != NULL ) - { - S_FREE( n->data.str->ptr ); - n->data.str->ptr = NULL; - n->data.str->len = 0; - S_FREE( n->data.str ); - } - break; - - case syck_seq_kind: - S_FREE( n->data.list->items ); - S_FREE( n->data.list ); - break; - - case syck_map_kind: - S_FREE( n->data.pairs->keys ); - S_FREE( n->data.pairs->values ); - S_FREE( n->data.pairs ); - break; - } -} - diff --git a/ext/syck/rubyext.c b/ext/syck/rubyext.c deleted file mode 100644 index 3722babc39..0000000000 --- a/ext/syck/rubyext.c +++ /dev/null @@ -1,1481 +0,0 @@ -/* - * rubyext.c - * - * $Author$ - * $Date$ - * - * Copyright (C) 2003 why the lucky stiff - */ - -#include "ruby.h" -#include "syck.h" -#include <sys/types.h> -#include <time.h> - -typedef struct RVALUE { - union { -#if 0 - struct { - unsigned long flags; /* always 0 for freed obj */ - struct RVALUE *next; - } free; -#endif - struct RBasic basic; - struct RObject object; - struct RClass klass; - /*struct RFloat flonum;*/ - /*struct RString string;*/ - struct RArray array; - /*struct RRegexp regexp;*/ - struct RHash hash; - /*struct RData data;*/ - struct RStruct rstruct; - /*struct RBignum bignum;*/ - /*struct RFile file;*/ - } as; -} RVALUE; - -typedef struct { - long hash; - char *buffer; - long length; - long remaining; - int printed; -} bytestring_t; - -#define RUBY_DOMAIN "ruby.yaml.org,2002" - -/* - * symbols and constants - */ -static ID s_new, s_utc, s_at, s_to_f, s_to_i, s_read, s_binmode, s_call, s_transfer, s_update, s_dup, s_match, s_keys, s_to_str, s_unpack, s_tr_bang, s_anchors, s_default_set; -static VALUE sym_model, sym_generic, sym_input, sym_bytecode; -static VALUE sym_scalar, sym_seq, sym_map; -VALUE cDate, cParser, cLoader, cNode, cPrivateType, cDomainType, cBadAlias, cDefaultKey, cMergeKey, cEmitter; -VALUE oDefaultLoader; - -/* - * my private collection of numerical oddities. - */ -static double S_zero() { return 0.0; } -static double S_one() { return 1.0; } -static double S_inf() { return S_one() / S_zero(); } -static double S_nan() { return S_zero() / S_zero(); } - -static VALUE syck_node_transform( VALUE ); - -/* - * handler prototypes - */ -SYMID rb_syck_parse_handler _((SyckParser *, SyckNode *)); -SYMID rb_syck_load_handler _((SyckParser *, SyckNode *)); -void rb_syck_err_handler _((SyckParser *, char *)); -SyckNode * rb_syck_bad_anchor_handler _((SyckParser *, char *)); -void rb_syck_output_handler _((SyckEmitter *, char *, long)); -int syck_parser_assign_io _((SyckParser *, VALUE)); - -struct parser_xtra { - VALUE data; /* Borrowed this idea from marshal.c to fix [ruby-core:8067] problem */ - VALUE proc; - int taint; -}; - -/* - * Convert YAML to bytecode - */ -VALUE -rb_syck_compile(self, port) - VALUE self, port; -{ - SYMID oid; - int taint; - char *ret; - VALUE bc; - bytestring_t *sav; - - SyckParser *parser = syck_new_parser(); - taint = syck_parser_assign_io(parser, port); - syck_parser_handler( parser, syck_yaml2byte_handler ); - syck_parser_error_handler( parser, NULL ); - syck_parser_implicit_typing( parser, 0 ); - syck_parser_taguri_expansion( parser, 0 ); - oid = syck_parse( parser ); - syck_lookup_sym( parser, oid, (char **)&sav ); - - ret = S_ALLOC_N( char, strlen( sav->buffer ) + 3 ); - ret[0] = '\0'; - strcat( ret, "D\n" ); - strcat( ret, sav->buffer ); - - syck_free_parser( parser ); - - bc = rb_str_new2( ret ); - if ( taint ) OBJ_TAINT( bc ); - return bc; -} - -/* - * read from io. - */ -long -rb_syck_io_str_read( char *buf, SyckIoStr *str, long max_size, long skip ) -{ - long len = 0; - - ASSERT( str != NULL ); - max_size -= skip; - - if ( max_size <= 0 ) max_size = 0; - else - { - /* - * call io#read. - */ - VALUE src = (VALUE)str->ptr; - VALUE n = LONG2NUM(max_size); - VALUE str2 = rb_funcall2(src, s_read, 1, &n); - if (!NIL_P(str2)) - { - len = RSTRING(str2)->len; - memcpy( buf + skip, RSTRING(str2)->ptr, len ); - } - } - len += skip; - buf[len] = '\0'; - return len; -} - -/* - * determine: are we reading from a string or io? - * (returns tainted? boolean) - */ -int -syck_parser_assign_io(parser, port) - SyckParser *parser; - VALUE port; -{ - int taint = Qtrue; - if (rb_respond_to(port, s_to_str)) { - taint = OBJ_TAINTED(port); /* original taintedness */ - StringValue(port); /* possible conversion */ - syck_parser_str( parser, RSTRING(port)->ptr, RSTRING(port)->len, NULL ); - } - else if (rb_respond_to(port, s_read)) { - if (rb_respond_to(port, s_binmode)) { - rb_funcall2(port, s_binmode, 0, 0); - } - syck_parser_str( parser, (char *)port, 0, rb_syck_io_str_read ); - } - else { - rb_raise(rb_eTypeError, "instance of IO needed"); - } - return taint; -} - -/* - * Get value in hash by key, forcing an empty hash if nil. - */ -VALUE -syck_get_hash_aref(hsh, key) - VALUE hsh, key; -{ - VALUE val = rb_hash_aref( hsh, key ); - if ( NIL_P( val ) ) - { - val = rb_hash_new(); - rb_hash_aset(hsh, key, val); - } - return val; -} - -/* - * creating timestamps - */ -SYMID -rb_syck_mktime(str) - char *str; -{ - VALUE time; - char *ptr = str; - VALUE year, mon, day, hour, min, sec, usec; - - /* Year*/ - ptr[4] = '\0'; - year = INT2FIX(strtol(ptr, NULL, 10)); - - /* Month*/ - ptr += 4; - while ( !ISDIGIT( *ptr ) ) ptr++; - mon = INT2FIX(strtol(ptr, NULL, 10)); - - /* Day*/ - ptr += 2; - while ( !ISDIGIT( *ptr ) ) ptr++; - day = INT2FIX(strtol(ptr, NULL, 10)); - - /* Hour*/ - ptr += 2; - while ( !ISDIGIT( *ptr ) ) ptr++; - hour = INT2FIX(strtol(ptr, NULL, 10)); - - /* Minute */ - ptr += 2; - while ( !ISDIGIT( *ptr ) ) ptr++; - min = INT2FIX(strtol(ptr, NULL, 10)); - - /* Second */ - ptr += 2; - while ( !ISDIGIT( *ptr ) ) ptr++; - sec = INT2FIX(strtol(ptr, NULL, 10)); - - /* Millisecond */ - ptr += 2; - if ( *ptr == '.' ) - { - usec = INT2FIX( strtod( ptr, NULL ) * 1000000 ); - } - else - { - usec = INT2FIX( 0 ); - } - - /* Make UTC time*/ - time = rb_funcall(rb_cTime, s_utc, 7, year, mon, day, hour, min, sec, usec); - - /* Time Zone*/ - while ( *ptr != 'Z' && *ptr != '+' && *ptr != '-' && *ptr != '\0' ) ptr++; - if ( *ptr == '-' || *ptr == '+' ) - { - double tz_offset = 0; - double utc_time = 0; - tz_offset += strtod(ptr, NULL) * 3600; - - while ( *ptr != ':' && *ptr != '\0' ) ptr++; - if ( *ptr == ':' ) - { - ptr += 1; - if ( tz_offset < 0 ) - { - tz_offset -= strtod(ptr, NULL) * 60; - } - else - { - tz_offset += strtod(ptr, NULL) * 60; - } - } - - /* Make TZ time*/ - utc_time = NUM2DBL(rb_funcall(time, s_to_f, 0)); - utc_time -= tz_offset; - time = rb_funcall(rb_cTime, s_at, 1, rb_float_new(utc_time)); - } - - return time; -} - -/* - * {generic mode} node handler - * - Loads data into Node classes - */ -SYMID -rb_syck_parse_handler(p, n) - SyckParser *p; - SyckNode *n; -{ - VALUE t, obj, v = Qnil; - int i; - struct parser_xtra *bonus; - - obj = rb_obj_alloc(cNode); - if ( n->type_id != NULL ) - { - t = rb_str_new2(n->type_id); - rb_iv_set(obj, "@type_id", t); - } - - switch (n->kind) - { - case syck_str_kind: - rb_iv_set(obj, "@kind", sym_scalar); - v = rb_str_new( n->data.str->ptr, n->data.str->len ); - break; - - case syck_seq_kind: - rb_iv_set(obj, "@kind", sym_seq); - v = rb_ary_new2( n->data.list->idx ); - for ( i = 0; i < n->data.list->idx; i++ ) - { - rb_ary_store( v, i, syck_seq_read( n, i ) ); - } - break; - - case syck_map_kind: - rb_iv_set(obj, "@kind", sym_map); - v = rb_hash_new(); - for ( i = 0; i < n->data.pairs->idx; i++ ) - { - VALUE key = syck_node_transform( syck_map_read( n, map_key, i ) ); - VALUE val = rb_ary_new(); - rb_ary_push(val, syck_map_read( n, map_key, i )); - rb_ary_push(val, syck_map_read( n, map_value, i )); - - rb_hash_aset( v, key, val ); - } - break; - } - - bonus = (struct parser_xtra *)p->bonus; - if ( bonus->taint) OBJ_TAINT( obj ); - if ( bonus->proc != 0 ) rb_funcall(bonus->proc, s_call, 1, v); - - rb_iv_set(obj, "@value", v); - rb_hash_aset(bonus->data, INT2FIX(RHASH(bonus->data)->tbl->num_entries), obj); - return obj; -} - -/* - * handles merging of an array of hashes - * (see http://www.yaml.org/type/merge/) - */ -VALUE -syck_merge_i( entry, hsh ) - VALUE entry, hsh; -{ - if ( rb_obj_is_kind_of( entry, rb_cHash ) ) - { - rb_funcall( hsh, s_update, 1, entry ); - } - return Qnil; -} - -/* - * build a syck node from a Ruby VALUE - */ -SyckNode * -rb_new_syck_node( obj, type_id ) - VALUE obj, type_id; -{ - long i = 0; - SyckNode *n = NULL; - - if (rb_respond_to(obj, s_to_str)) - { - StringValue(obj); /* possible conversion */ - n = syck_alloc_str(); - n->data.str->ptr = RSTRING(obj)->ptr; - n->data.str->len = RSTRING(obj)->len; - } - else if ( rb_obj_is_kind_of( obj, rb_cArray ) ) - { - n = syck_alloc_seq(); - for ( i = 0; i < RARRAY(obj)->len; i++ ) - { - syck_seq_add(n, rb_ary_entry(obj, i)); - } - } - else if ( rb_obj_is_kind_of( obj, rb_cHash ) ) - { - VALUE keys; - n = syck_alloc_map(); - keys = rb_funcall( obj, s_keys, 0 ); - for ( i = 0; i < RARRAY(keys)->len; i++ ) - { - VALUE key = rb_ary_entry(keys, i); - syck_map_add(n, key, rb_hash_aref(obj, key)); - } - } - - if ( n!= NULL && rb_respond_to( type_id, s_to_str ) ) - { - StringValue(type_id); - n->type_id = syck_strndup( RSTRING(type_id)->ptr, RSTRING(type_id)->len ); - } - - return n; -} - -/* - * default handler for ruby.yaml.org types - */ -int -yaml_org_handler( n, ref ) - SyckNode *n; - VALUE *ref; -{ - char *type_id = n->type_id; - int transferred = 0; - long i = 0; - VALUE obj = Qnil; - - switch (n->kind) - { - case syck_str_kind: - transferred = 1; - if ( type_id == NULL || strcmp( type_id, "str" ) == 0 ) - { - obj = rb_str_new( n->data.str->ptr, n->data.str->len ); - } - else if ( strcmp( type_id, "null" ) == 0 ) - { - obj = Qnil; - } - else if ( strcmp( type_id, "binary" ) == 0 ) - { - VALUE arr; - obj = rb_str_new( n->data.str->ptr, n->data.str->len ); - rb_funcall( obj, s_tr_bang, 2, rb_str_new2( "\n\t " ), rb_str_new2( "" ) ); - arr = rb_funcall( obj, s_unpack, 1, rb_str_new2( "m" ) ); - obj = rb_ary_shift( arr ); - } - else if ( strcmp( type_id, "bool#yes" ) == 0 ) - { - obj = Qtrue; - } - else if ( strcmp( type_id, "bool#no" ) == 0 ) - { - obj = Qfalse; - } - else if ( strcmp( type_id, "int#hex" ) == 0 ) - { - obj = rb_cstr2inum( n->data.str->ptr, 16 ); - } - else if ( strcmp( type_id, "int#oct" ) == 0 ) - { - obj = rb_cstr2inum( n->data.str->ptr, 8 ); - } - else if ( strncmp( type_id, "int", 3 ) == 0 ) - { - syck_str_blow_away_commas( n ); - obj = rb_cstr2inum( n->data.str->ptr, 10 ); - } - else if ( strcmp( type_id, "float#nan" ) == 0 ) - { - obj = rb_float_new( S_nan() ); - } - else if ( strcmp( type_id, "float#inf" ) == 0 ) - { - obj = rb_float_new( S_inf() ); - } - else if ( strcmp( type_id, "float#neginf" ) == 0 ) - { - obj = rb_float_new( -S_inf() ); - } - else if ( strncmp( type_id, "float", 5 ) == 0 ) - { - double f; - syck_str_blow_away_commas( n ); - f = strtod( n->data.str->ptr, NULL ); - obj = rb_float_new( f ); - } - else if ( strcmp( type_id, "timestamp#iso8601" ) == 0 ) - { - obj = rb_syck_mktime( n->data.str->ptr ); - } - else if ( strcmp( type_id, "timestamp#spaced" ) == 0 ) - { - obj = rb_syck_mktime( n->data.str->ptr ); - } - else if ( strcmp( type_id, "timestamp#ymd" ) == 0 ) - { - char *ptr = n->data.str->ptr; - VALUE year, mon, day; - - /* Year*/ - ptr[4] = '\0'; - year = INT2FIX(strtol(ptr, NULL, 10)); - - /* Month*/ - ptr += 4; - while ( !ISDIGIT( *ptr ) ) ptr++; - mon = INT2FIX(strtol(ptr, NULL, 10)); - - /* Day*/ - ptr += 2; - while ( !ISDIGIT( *ptr ) ) ptr++; - day = INT2FIX(strtol(ptr, NULL, 10)); - - obj = rb_funcall( cDate, s_new, 3, year, mon, day ); - } - else if ( strncmp( type_id, "timestamp", 9 ) == 0 ) - { - obj = rb_syck_mktime( n->data.str->ptr ); - } - else if ( strncmp( type_id, "merge", 5 ) == 0 ) - { - obj = rb_funcall( cMergeKey, s_new, 0 ); - } - else if ( strncmp( type_id, "default", 7 ) == 0 ) - { - obj = rb_funcall( cDefaultKey, s_new, 0 ); - } - else - { - transferred = 0; - obj = rb_str_new( n->data.str->ptr, n->data.str->len ); - } - break; - - case syck_seq_kind: - if ( type_id == NULL || strcmp( type_id, "seq" ) == 0 ) - { - transferred = 1; - } - obj = rb_ary_new2( n->data.list->idx ); - for ( i = 0; i < n->data.list->idx; i++ ) - { - rb_ary_store( obj, i, syck_seq_read( n, i ) ); - } - break; - - case syck_map_kind: - if ( type_id == NULL || strcmp( type_id, "map" ) == 0 ) - { - transferred = 1; - } - obj = rb_hash_new(); - for ( i = 0; i < n->data.pairs->idx; i++ ) - { - VALUE k = syck_map_read( n, map_key, i ); - VALUE v = syck_map_read( n, map_value, i ); - int skip_aset = 0; - - /* - * Handle merge keys - */ - if ( rb_obj_is_kind_of( k, cMergeKey ) ) - { - if ( rb_obj_is_kind_of( v, rb_cHash ) ) - { - VALUE dup = rb_funcall( v, s_dup, 0 ); - rb_funcall( dup, s_update, 1, obj ); - obj = dup; - skip_aset = 1; - } - else if ( rb_obj_is_kind_of( v, rb_cArray ) ) - { - VALUE end = rb_ary_pop( v ); - if ( rb_obj_is_kind_of( end, rb_cHash ) ) - { - VALUE dup = rb_funcall( end, s_dup, 0 ); - v = rb_ary_reverse( v ); - rb_ary_push( v, obj ); - rb_iterate( rb_each, v, syck_merge_i, dup ); - obj = dup; - skip_aset = 1; - } - } - } - else if ( rb_obj_is_kind_of( k, cDefaultKey ) ) - { - rb_funcall( obj, s_default_set, 1, v ); - skip_aset = 1; - } - - if ( ! skip_aset ) - { - rb_hash_aset( obj, k, v ); - } - } - break; - } - - *ref = obj; - return transferred; -} - -/* - * {native mode} node handler - * - Converts data into native Ruby types - */ -SYMID -rb_syck_load_handler(p, n) - SyckParser *p; - SyckNode *n; -{ - VALUE obj = Qnil; - struct parser_xtra *bonus; - - /* - * Attempt common transfers - */ - int transferred = yaml_org_handler(n, &obj); - if ( transferred == 0 && n->type_id != NULL ) - { - obj = rb_funcall( oDefaultLoader, s_transfer, 2, rb_str_new2( n->type_id ), obj ); - } - - /* - * ID already set, let's alter the symbol table to accept the new object - */ - if (n->id > 0) - { - MEMCPY((void *)n->id, (void *)obj, RVALUE, 1); - MEMZERO((void *)obj, RVALUE, 1); - obj = n->id; - } - - bonus = (struct parser_xtra *)p->bonus; - if ( bonus->taint) OBJ_TAINT( obj ); - if ( bonus->proc != 0 ) rb_funcall(bonus->proc, s_call, 1, obj); - - rb_hash_aset(bonus->data, INT2FIX(RHASH(bonus->data)->tbl->num_entries), obj); - return obj; -} - -/* - * friendly errors. - */ -void -rb_syck_err_handler(p, msg) - SyckParser *p; - char *msg; -{ - char *endl = p->cursor; - - while ( *endl != '\0' && *endl != '\n' ) - endl++; - - endl[0] = '\0'; - rb_raise(rb_eArgError, "%s on line %d, col %d: `%s'", - msg, - p->linect, - p->cursor - p->lineptr, - p->lineptr); -} - -/* - * provide bad anchor object to the parser. - */ -SyckNode * -rb_syck_bad_anchor_handler(p, a) - SyckParser *p; - char *a; -{ - VALUE anchor_name = rb_str_new2( a ); - SyckNode *badanc = syck_new_map( rb_str_new2( "name" ), anchor_name ); - badanc->type_id = syck_strndup( "tag:ruby.yaml.org,2002:object:YAML::Syck::BadAlias", 53 ); - return badanc; -} - -/* - * data loaded based on the model requested. - */ -void -syck_set_model( parser, input, model ) - SyckParser *parser; - VALUE input, model; -{ - if ( model == sym_generic ) - { - syck_parser_handler( parser, rb_syck_parse_handler ); - syck_parser_implicit_typing( parser, 1 ); - syck_parser_taguri_expansion( parser, 1 ); - } - else - { - syck_parser_handler( parser, rb_syck_load_handler ); - syck_parser_implicit_typing( parser, 1 ); - syck_parser_taguri_expansion( parser, 0 ); - } - if ( input == sym_bytecode ) - { - syck_parser_set_input_type( parser, syck_bytecode_utf8 ); - } - syck_parser_error_handler( parser, rb_syck_err_handler ); - syck_parser_bad_anchor_handler( parser, rb_syck_bad_anchor_handler ); -} - -/* - * mark parser nodes - */ -static void -syck_mark_parser(parser) - SyckParser *parser; -{ - rb_gc_mark(parser->root); - rb_gc_mark(parser->root_on_error); -} - -/* - * YAML::Syck::Parser.new - */ -VALUE -syck_parser_new(argc, argv, class) - int argc; - VALUE *argv; - VALUE class; -{ - VALUE pobj, options, init_argv[1]; - SyckParser *parser = syck_new_parser(); - - rb_scan_args(argc, argv, "01", &options); - pobj = Data_Wrap_Struct( class, syck_mark_parser, syck_free_parser, parser ); - - syck_parser_set_root_on_error( parser, Qnil ); - - if ( ! rb_obj_is_instance_of( options, rb_cHash ) ) - { - options = rb_hash_new(); - } - init_argv[0] = options; - rb_obj_call_init(pobj, 1, init_argv); - return pobj; -} - -/* - * YAML::Syck::Parser.initialize( options ) - */ -static VALUE -syck_parser_initialize( self, options ) - VALUE self, options; -{ - rb_iv_set(self, "@options", options); - return self; -} - -/* - * YAML::Syck::Parser.bufsize = Integer - */ -static VALUE -syck_parser_bufsize_set( self, size ) - VALUE self, size; -{ - SyckParser *parser; - - Data_Get_Struct(self, SyckParser, parser); - if ( rb_respond_to( size, s_to_i ) ) { - parser->bufsize = NUM2INT(rb_funcall(size, s_to_i, 0)); - } - return self; -} - -/* - * YAML::Syck::Parser.bufsize => Integer - */ -static VALUE -syck_parser_bufsize_get( self ) - VALUE self; -{ - SyckParser *parser; - - Data_Get_Struct(self, SyckParser, parser); - return INT2FIX( parser->bufsize ); -} - -/* - * YAML::Syck::Parser.load( IO or String ) - */ -VALUE -syck_parser_load(argc, argv, self) - int argc; - VALUE *argv; - VALUE self; -{ - VALUE port, proc, model, input; - SyckParser *parser; - struct parser_xtra bonus; - volatile VALUE hash; /* protect from GC */ - - rb_scan_args(argc, argv, "11", &port, &proc); - Data_Get_Struct(self, SyckParser, parser); - - input = rb_hash_aref( rb_iv_get( self, "@options" ), sym_input ); - model = rb_hash_aref( rb_iv_get( self, "@options" ), sym_model ); - syck_set_model( parser, input, model ); - - bonus.taint = syck_parser_assign_io(parser, port); - bonus.data = hash = rb_hash_new(); - if ( NIL_P( proc ) ) bonus.proc = 0; - else bonus.proc = proc; - - parser->bonus = (void *)&bonus; - - return syck_parse( parser ); -} - -/* - * YAML::Syck::Parser.load_documents( IO or String ) { |doc| } - */ -VALUE -syck_parser_load_documents(argc, argv, self) - int argc; - VALUE *argv; - VALUE self; -{ - VALUE port, proc, v, input, model; - SyckParser *parser; - struct parser_xtra bonus; - volatile VALUE hash; - - rb_scan_args(argc, argv, "1&", &port, &proc); - Data_Get_Struct(self, SyckParser, parser); - - input = rb_hash_aref( rb_iv_get( self, "@options" ), sym_input ); - model = rb_hash_aref( rb_iv_get( self, "@options" ), sym_model ); - syck_set_model( parser, input, model ); - - bonus.taint = syck_parser_assign_io(parser, port); - while ( 1 ) - { - /* Reset hash for tracking nodes */ - bonus.data = hash = rb_hash_new(); - bonus.proc = 0; - parser->bonus = (void *)&bonus; - - /* Parse a document */ - v = syck_parse( parser ); - if ( parser->eof == 1 ) - { - break; - } - - /* Pass document to block */ - rb_funcall( proc, s_call, 1, v ); - } - - return Qnil; -} - -/* - * YAML::Syck::Loader.initialize - */ -static VALUE -syck_loader_initialize( self ) - VALUE self; -{ - VALUE families; - - rb_iv_set(self, "@families", rb_hash_new() ); - rb_iv_set(self, "@private_types", rb_hash_new() ); - rb_iv_set(self, "@anchors", rb_hash_new() ); - families = rb_iv_get(self, "@families"); - - rb_hash_aset(families, rb_str_new2( YAML_DOMAIN ), rb_hash_new()); - rb_hash_aset(families, rb_str_new2( RUBY_DOMAIN ), rb_hash_new()); - - return self; -} - -/* - * Add type family, used by add_*_type methods. - */ -VALUE -syck_loader_add_type_family( self, domain, type_re, proc ) - VALUE self, domain, type_re, proc; -{ - VALUE families, domain_types; - - families = rb_iv_get(self, "@families"); - domain_types = syck_get_hash_aref(families, domain); - rb_hash_aset( domain_types, type_re, proc ); - return Qnil; -} - -/* - * YAML::Syck::Loader.add_domain_type - */ -VALUE -syck_loader_add_domain_type( argc, argv, self ) - int argc; - VALUE *argv; - VALUE self; -{ - VALUE domain, type_re, proc; - - rb_scan_args(argc, argv, "2&", &domain, &type_re, &proc); - syck_loader_add_type_family( self, domain, type_re, proc ); - return Qnil; -} - - -/* - * YAML::Syck::Loader.add_builtin_type - */ -VALUE -syck_loader_add_builtin_type( argc, argv, self ) - int argc; - VALUE *argv; - VALUE self; -{ - VALUE type_re, proc; - - rb_scan_args(argc, argv, "1&", &type_re, &proc); - syck_loader_add_type_family( self, rb_str_new2( YAML_DOMAIN ), type_re, proc ); - return Qnil; -} - -/* - * YAML::Syck::Loader.add_ruby_type - */ -VALUE -syck_loader_add_ruby_type( argc, argv, self ) - int argc; - VALUE *argv; - VALUE self; -{ - VALUE type_re, proc; - - rb_scan_args(argc, argv, "1&", &type_re, &proc); - syck_loader_add_type_family( self, rb_str_new2( RUBY_DOMAIN ), type_re, proc ); - return Qnil; -} - -/* - * YAML::Syck::Loader.add_private_type - */ -VALUE -syck_loader_add_private_type( argc, argv, self ) - int argc; - VALUE *argv; - VALUE self; -{ - VALUE type_re, proc, priv_types; - - rb_scan_args(argc, argv, "1&", &type_re, &proc); - - priv_types = rb_iv_get(self, "@private_types"); - rb_hash_aset( priv_types, type_re, proc ); - return Qnil; -} - -/* - * YAML::Syck::Loader#detect - */ -VALUE -syck_loader_detect_implicit( self, val ) - VALUE self, val; -{ - char *type_id; - - if ( TYPE(val) == T_STRING ) - { - type_id = syck_match_implicit( RSTRING(val)->ptr, RSTRING(val)->len ); - return rb_str_new2( type_id ); - } - - return rb_str_new2( "" ); -} - -/* - * iterator to search a type hash for a match. - */ -static VALUE -transfer_find_i(entry, col) - VALUE entry, col; -{ - VALUE key = rb_ary_entry( entry, 0 ); - VALUE tid = rb_ary_entry( col, 0 ); - if ( rb_respond_to( key, s_match ) ) - { - VALUE match = rb_funcall( key, rb_intern("match"), 1, tid ); - if ( ! NIL_P( match ) ) - { - rb_ary_push( col, rb_ary_entry( entry, 1 ) ); - rb_iter_break(); - } - } - return Qnil; -} - -/* - * YAML::Syck::Loader#transfer - */ -VALUE -syck_loader_transfer( self, type, val ) - VALUE self, type, val; -{ - char *taguri = NULL; - - if (NIL_P(type) || !RSTRING(type)->ptr || RSTRING(type)->len == 0) - { - /* - * Empty transfer, detect type - */ - if ( TYPE(val) == T_STRING ) - { - StringValue(val); - taguri = syck_match_implicit( RSTRING(val)->ptr, RSTRING(val)->len ); - taguri = syck_taguri( YAML_DOMAIN, taguri, strlen( taguri ) ); - } - } - else - { - taguri = syck_type_id_to_uri( RSTRING(type)->ptr ); - } - - if ( taguri != NULL ) - { - int transferred = 0; - VALUE scheme, name, type_hash, domain = Qnil, type_proc = Qnil; - VALUE type_uri = rb_str_new2( taguri ); - VALUE str_taguri = rb_str_new2("tag"); - VALUE str_xprivate = rb_str_new2("x-private"); - VALUE str_yaml_domain = rb_str_new2(YAML_DOMAIN); - VALUE parts = rb_str_split( type_uri, ":" ); - - scheme = rb_ary_shift( parts ); - - if ( rb_str_cmp( scheme, str_xprivate ) == 0 ) - { - name = rb_ary_join( parts, rb_str_new2( ":" ) ); - type_hash = rb_iv_get(self, "@private_types"); - } - else if ( rb_str_cmp( scheme, str_taguri ) == 0 ) - { - domain = rb_ary_shift( parts ); - name = rb_ary_join( parts, rb_str_new2( ":" ) ); - type_hash = rb_iv_get(self, "@families"); - type_hash = rb_hash_aref(type_hash, domain); - - /* - * Route yaml.org types through the transfer - * method here in this extension - */ - if ( rb_str_cmp( domain, str_yaml_domain ) == 0 ) - { - SyckNode *n = rb_new_syck_node(val, name); - if ( n != NULL ) - { - transferred = yaml_org_handler(n, &val); - S_FREE( n ); - } - } - - } - else - { - rb_raise(rb_eTypeError, "invalid typing scheme: %s given", - scheme); - } - - if ( ! transferred ) - { - if ( rb_obj_is_instance_of( type_hash, rb_cHash ) ) - { - type_proc = rb_hash_aref( type_hash, name ); - if ( NIL_P( type_proc ) ) - { - VALUE col = rb_ary_new(); - rb_ary_push( col, name ); - rb_iterate(rb_each, type_hash, transfer_find_i, col ); - name = rb_ary_shift( col ); - type_proc = rb_ary_shift( col ); - } - } - - if ( rb_respond_to( type_proc, s_call ) ) - { - val = rb_funcall(type_proc, s_call, 2, type_uri, val); - } - else if ( rb_str_cmp( scheme, str_xprivate ) == 0 ) - { - val = rb_funcall(cPrivateType, s_new, 2, name, val); - } - else - { - val = rb_funcall(cDomainType, s_new, 3, domain, name, val); - } - transferred = 1; - } - } - - return val; -} - -/* - * YAML::Syck::BadAlias.initialize - */ -VALUE -syck_badalias_initialize( self, val ) - VALUE self, val; -{ - rb_iv_set( self, "@name", val ); - return self; -} - -/* - * YAML::Syck::DomainType.initialize - */ -VALUE -syck_domaintype_initialize( self, domain, type_id, val ) - VALUE self, type_id, val; -{ - rb_iv_set( self, "@domain", domain ); - rb_iv_set( self, "@type_id", type_id ); - rb_iv_set( self, "@value", val ); - return self; -} - -/* - * YAML::Syck::PrivateType.initialize - */ -VALUE -syck_privatetype_initialize( self, type_id, val ) - VALUE self, type_id, val; -{ - rb_iv_set( self, "@type_id", type_id ); - rb_iv_set( self, "@value", val ); - return self; -} - -/* - * YAML::Syck::Node.initialize - */ -VALUE -syck_node_initialize( self, type_id, val ) - VALUE self, type_id, val; -{ - rb_iv_set( self, "@type_id", type_id ); - rb_iv_set( self, "@value", val ); - return self; -} - -VALUE -syck_node_thash( entry, t ) - VALUE entry, t; -{ - VALUE key, val; - key = rb_ary_entry( entry, 0 ); - val = syck_node_transform( rb_ary_entry( rb_ary_entry( entry, 1 ), 1 ) ); - rb_hash_aset( t, key, val ); - return Qnil; -} - -VALUE -syck_node_ahash( entry, t ) - VALUE entry, t; -{ - VALUE val = syck_node_transform( entry ); - rb_ary_push( t, val ); - return Qnil; -} - -/* - * YAML::Syck::Node.transform - */ -VALUE -syck_node_transform( self ) - VALUE self; -{ - VALUE t = Qnil; - VALUE type_id = rb_iv_get( self, "@type_id" ); - VALUE val = rb_iv_get( self, "@value" ); - if ( rb_obj_is_instance_of( val, rb_cHash ) ) - { - t = rb_hash_new(); - rb_iterate( rb_each, val, syck_node_thash, t ); - } - else if ( rb_obj_is_instance_of( val, rb_cArray ) ) - { - t = rb_ary_new(); - rb_iterate( rb_each, val, syck_node_ahash, t ); - } - else - { - t = val; - } - return rb_funcall( oDefaultLoader, s_transfer, 2, type_id, t ); -} - -/* - * Handle output from the emitter - */ -void -rb_syck_output_handler( emitter, str, len ) - SyckEmitter *emitter; - char *str; - long len; -{ - VALUE dest = (VALUE)emitter->bonus; - if ( rb_respond_to( dest, s_to_str ) ) { - rb_str_cat( dest, str, len ); - } else { - rb_io_write( dest, rb_str_new( str, len ) ); - } -} - -/* - * Mark emitter values. - */ -static void -syck_mark_emitter(emitter) - SyckEmitter *emitter; -{ - rb_gc_mark(emitter->ignore_id); - if ( emitter->bonus != NULL ) - { - rb_gc_mark( (VALUE)emitter->bonus ); - } -} - -/* - * YAML::Syck::Emitter.new - */ -VALUE -syck_emitter_new(argc, argv, class) - int argc; - VALUE *argv; - VALUE class; -{ - VALUE pobj, options, init_argv[1]; - SyckEmitter *emitter = syck_new_emitter(); - syck_emitter_ignore_id( emitter, Qnil ); - syck_emitter_handler( emitter, rb_syck_output_handler ); - - emitter->bonus = (void *)rb_str_new2( "" ); - - rb_scan_args(argc, argv, "01", &options); - pobj = Data_Wrap_Struct( class, syck_mark_emitter, syck_free_emitter, emitter ); - - if ( ! rb_obj_is_instance_of( options, rb_cHash ) ) - { - options = rb_hash_new(); - } - init_argv[0] = options; - rb_obj_call_init(pobj, 1, init_argv); - return pobj; -} - -/* - * YAML::Syck::Emitter.initialize( options ) - */ -static VALUE -syck_emitter_initialize( self, options ) - VALUE self, options; -{ - rb_iv_set(self, "@options", options); - return self; -} - -/* - * YAML::Syck::Emitter.level - */ -VALUE -syck_emitter_level_m( self ) - VALUE self; -{ - SyckEmitter *emitter; - - Data_Get_Struct(self, SyckEmitter, emitter); - return LONG2NUM( emitter->level ); -} - -/* - * YAML::Syck::Emitter.flush - */ -VALUE -syck_emitter_flush_m( self ) - VALUE self; -{ - SyckEmitter *emitter; - - Data_Get_Struct(self, SyckEmitter, emitter); - syck_emitter_flush( emitter, 0 ); - return self; -} - -/* - * YAML::Syck::Emitter.write( str ) - */ -VALUE -syck_emitter_write_m( self, str ) - VALUE self, str; -{ - SyckEmitter *emitter; - - Data_Get_Struct(self, SyckEmitter, emitter); - syck_emitter_write( emitter, RSTRING(str)->ptr, RSTRING(str)->len ); - return self; -} - -/* - * YAML::Syck::Emitter.simple( str ) - */ -VALUE -syck_emitter_simple_write( self, str ) - VALUE self, str; -{ - SyckEmitter *emitter; - - Data_Get_Struct(self, SyckEmitter, emitter); - syck_emitter_simple( emitter, RSTRING(str)->ptr, RSTRING(str)->len ); - return self; -} - -/* - * YAML::Syck::Emitter.start_object( object_id ) - */ -VALUE -syck_emitter_start_object( self, oid ) - VALUE self, oid; -{ - char *anchor_name; - SyckEmitter *emitter; - - Data_Get_Struct(self, SyckEmitter, emitter); - anchor_name = syck_emitter_start_obj( emitter, oid ); - - if ( anchor_name == NULL ) - { - return Qnil; - } - - return rb_str_new2( anchor_name ); -} - -/* - * YAML::Syck::Emitter.end_object( object_id ) - */ -VALUE -syck_emitter_end_object( self, oid ) - VALUE self, oid; -{ - SyckEmitter *emitter; - - Data_Get_Struct(self, SyckEmitter, emitter); - syck_emitter_end_obj( emitter ); - - if ( emitter->level < 0 ) - { - syck_emitter_flush( emitter, 0 ); - } - return (VALUE)emitter->bonus; -} - -/* - * Initialize Syck extension - */ -void -Init_syck() -{ - VALUE rb_yaml = rb_define_module( "YAML" ); - VALUE rb_syck = rb_define_module_under( rb_yaml, "Syck" ); - rb_define_const( rb_syck, "VERSION", rb_str_new2( SYCK_VERSION ) ); - rb_define_module_function( rb_syck, "compile", rb_syck_compile, 1 ); - - /* - * Global symbols - */ - s_new = rb_intern("new"); - s_utc = rb_intern("utc"); - s_at = rb_intern("at"); - s_to_f = rb_intern("to_f"); - s_to_i = rb_intern("to_i"); - s_read = rb_intern("read"); - s_anchors = rb_intern("anchors"); - s_binmode = rb_intern("binmode"); - s_transfer = rb_intern("transfer"); - s_call = rb_intern("call"); - s_update = rb_intern("update"); - s_dup = rb_intern("dup"); - s_default_set = rb_intern("default="); - s_match = rb_intern("match"); - s_keys = rb_intern("keys"); - s_to_str = rb_intern("to_str"); - s_tr_bang = rb_intern("tr!"); - s_unpack = rb_intern("unpack"); - - sym_model = ID2SYM(rb_intern("Model")); - sym_generic = ID2SYM(rb_intern("Generic")); - sym_input = ID2SYM(rb_intern("Input")); - sym_bytecode = ID2SYM(rb_intern("Bytecode")); - sym_map = ID2SYM(rb_intern("map")); - sym_scalar = ID2SYM(rb_intern("scalar")); - sym_seq = ID2SYM(rb_intern("seq")); - - /* - * Load Date module - */ - rb_require( "date" ); - cDate = rb_funcall( rb_cObject, rb_intern("const_get"), 1, rb_str_new2("Date") ); - - /* - * Define YAML::Syck::Loader class - */ - cLoader = rb_define_class_under( rb_syck, "Loader", rb_cObject ); - rb_define_attr( cLoader, "families", 1, 1 ); - rb_define_attr( cLoader, "private_types", 1, 1 ); - rb_define_attr( cLoader, "anchors", 1, 1 ); - rb_define_method( cLoader, "initialize", syck_loader_initialize, 0 ); - rb_define_method( cLoader, "add_domain_type", syck_loader_add_domain_type, -1 ); - rb_define_method( cLoader, "add_builtin_type", syck_loader_add_builtin_type, -1 ); - rb_define_method( cLoader, "add_ruby_type", syck_loader_add_ruby_type, -1 ); - rb_define_method( cLoader, "add_private_type", syck_loader_add_private_type, -1 ); - rb_define_method( cLoader, "bufsize=", syck_parser_bufsize_set, 1 ); - rb_define_method( cLoader, "bufsize", syck_parser_bufsize_get, 0 ); - rb_define_method( cLoader, "detect_implicit", syck_loader_detect_implicit, 1 ); - rb_define_method( cLoader, "transfer", syck_loader_transfer, 2 ); - - oDefaultLoader = rb_funcall( cLoader, rb_intern( "new" ), 0 ); - rb_define_const( rb_syck, "DefaultLoader", oDefaultLoader ); - - /* - * Define YAML::Syck::Parser class - */ - cParser = rb_define_class_under( rb_syck, "Parser", rb_cObject ); - rb_define_attr( cParser, "options", 1, 1 ); - rb_define_singleton_method( cParser, "new", syck_parser_new, -1 ); - rb_define_method(cParser, "initialize", syck_parser_initialize, 1); - rb_define_method(cParser, "load", syck_parser_load, -1); - rb_define_method(cParser, "load_documents", syck_parser_load_documents, -1); - - /* - * Define YAML::Syck::Node class - */ - cNode = rb_define_class_under( rb_syck, "Node", rb_cObject ); - rb_define_attr( cNode, "kind", 1, 1 ); - rb_define_attr( cNode, "type_id", 1, 1 ); - rb_define_attr( cNode, "value", 1, 1 ); - rb_define_attr( cNode, "anchor", 1, 1 ); - rb_define_method( cNode, "initialize", syck_node_initialize, 2); - rb_define_method( cNode, "transform", syck_node_transform, 0); - - /* - * Define YAML::Syck::PrivateType class - */ - cPrivateType = rb_define_class_under( rb_syck, "PrivateType", rb_cObject ); - rb_define_attr( cPrivateType, "type_id", 1, 1 ); - rb_define_attr( cPrivateType, "value", 1, 1 ); - rb_define_method( cPrivateType, "initialize", syck_privatetype_initialize, 2); - - /* - * Define YAML::Syck::DomainType class - */ - cDomainType = rb_define_class_under( rb_syck, "DomainType", rb_cObject ); - rb_define_attr( cDomainType, "domain", 1, 1 ); - rb_define_attr( cDomainType, "type_id", 1, 1 ); - rb_define_attr( cDomainType, "value", 1, 1 ); - rb_define_method( cDomainType, "initialize", syck_domaintype_initialize, 3); - - /* - * Define YAML::Syck::BadAlias class - */ - cBadAlias = rb_define_class_under( rb_syck, "BadAlias", rb_cObject ); - rb_define_attr( cBadAlias, "name", 1, 1 ); - rb_define_method( cBadAlias, "initialize", syck_badalias_initialize, 1); - - /* - * Define YAML::Syck::MergeKey class - */ - cMergeKey = rb_define_class_under( rb_syck, "MergeKey", rb_cObject ); - - /* - * Define YAML::Syck::DefaultKey class - */ - cDefaultKey = rb_define_class_under( rb_syck, "DefaultKey", rb_cObject ); - - /* - * Define YAML::Syck::Emitter class - */ - cEmitter = rb_define_class_under( rb_syck, "Emitter", rb_cObject ); - rb_define_singleton_method( cEmitter, "new", syck_emitter_new, -1 ); - rb_define_method( cEmitter, "initialize", syck_emitter_initialize, 1 ); - rb_define_method( cEmitter, "level", syck_emitter_level_m, 0 ); - rb_define_method( cEmitter, "write", syck_emitter_write_m, 1 ); - rb_define_method( cEmitter, "<<", syck_emitter_write_m, 1 ); - rb_define_method( cEmitter, "simple", syck_emitter_simple_write, 1 ); - rb_define_method( cEmitter, "flush", syck_emitter_flush_m, 0 ); - rb_define_method( cEmitter, "start_object", syck_emitter_start_object, 1 ); - rb_define_method( cEmitter, "end_object", syck_emitter_end_object, 0 ); -} - diff --git a/ext/syck/syck.c b/ext/syck/syck.c deleted file mode 100644 index ec4e7a1efd..0000000000 --- a/ext/syck/syck.c +++ /dev/null @@ -1,503 +0,0 @@ -/* - * syck.c - * - * $Author$ - * $Date$ - * - * Copyright (C) 2003 why the lucky stiff - */ -#include <stdio.h> -#include <string.h> - -#include "syck.h" -#include "ruby.h" - -void syck_parser_pop_level( SyckParser * ); - -/* - * Custom assert - */ -void -syck_assert( char *file_name, unsigned line_num ) -{ - fflush( NULL ); - fprintf( stderr, "\nAssertion failed: %s, line %u\n", - file_name, line_num ); - fflush( stderr ); - abort(); -} - -/* - * Allocates and copies a string - */ -char * -syck_strndup( char *buf, long len ) -{ - char *new = S_ALLOC_N( char, len + 1 ); - S_MEMZERO( new, char, len + 1 ); - S_MEMCPY( new, buf, char, len ); - return new; -} - -/* - * Default FILE IO function - */ -long -syck_io_file_read( char *buf, SyckIoFile *file, long max_size, long skip ) -{ - long len = 0; - - ASSERT( file != NULL ); - - max_size -= skip; - len = fread( buf + skip, sizeof( char ), max_size, file->ptr ); - len += skip; - buf[len] = '\0'; - - return len; -} - -/* - * Default string IO function - */ -long -syck_io_str_read( char *buf, SyckIoStr *str, long max_size, long skip ) -{ - char *beg; - long len = 0; - - ASSERT( str != NULL ); - beg = str->ptr; - if ( max_size >= 0 ) - { - max_size -= skip; - if ( max_size <= 0 ) max_size = 0; - else str->ptr += max_size; - - if ( str->ptr > str->end ) - { - str->ptr = str->end; - } - } - else - { - /* Use exact string length */ - while ( str->ptr < str->end ) { - if (*(str->ptr++) == '\n') break; - } - } - if ( beg < str->ptr ) - { - len = ( str->ptr - beg ); - S_MEMCPY( buf + skip, beg, char, len ); - } - len += skip; - buf[len] = '\0'; - - return len; -} - -void -syck_parser_reset_levels( SyckParser *p ) -{ - while ( p->lvl_idx > 1 ) - { - syck_parser_pop_level( p ); - } - - if ( p->lvl_idx < 1 ) - { - p->lvl_idx = 1; - p->levels[0].spaces = -1; - p->levels[0].ncount = 0; - p->levels[0].domain = syck_strndup( "", 0 ); - } - p->levels[0].status = syck_lvl_header; -} - -void -syck_parser_reset_cursor( SyckParser *p ) -{ - if ( p->buffer == NULL ) - { - p->buffer = S_ALLOC_N( char, p->bufsize ); - S_MEMZERO( p->buffer, char, p->bufsize ); - } - p->buffer[0] = '\0'; - - p->cursor = NULL; - p->lineptr = NULL; - p->linectptr = NULL; - p->token = NULL; - p->toktmp = NULL; - p->marker = NULL; - p->limit = NULL; - - p->root = 0; - p->root_on_error = 0; - p->linect = 0; - p->eof = 0; - p->last_token = 0; - p->force_token = 0; -} - -/* - * Value to return on a parse error - */ -void -syck_parser_set_root_on_error( SyckParser *p, SYMID roer ) -{ - p->root_on_error = roer; -} - -/* - * Allocate the parser - */ -SyckParser * -syck_new_parser() -{ - SyckParser *p; - p = S_ALLOC( SyckParser ); - p->lvl_capa = ALLOC_CT; - p->levels = S_ALLOC_N( SyckLevel, p->lvl_capa ); - p->input_type = syck_yaml_utf8; - p->io_type = syck_io_str; - p->io.str = NULL; - p->syms = NULL; - p->anchors = NULL; - p->bad_anchors = NULL; - p->implicit_typing = 1; - p->taguri_expansion = 0; - p->bufsize = SYCK_BUFFERSIZE; - p->buffer = NULL; - p->lvl_idx = 0; - syck_parser_reset_levels( p ); - return p; -} - -int -syck_add_sym( SyckParser *p, char *data ) -{ - SYMID id = 0; - if ( p->syms == NULL ) - { - p->syms = st_init_numtable(); - } - id = p->syms->num_entries + 1; - st_insert( p->syms, id, (st_data_t)data ); - return id; -} - -int -syck_lookup_sym( SyckParser *p, SYMID id, char **data ) -{ - if ( p->syms == NULL ) return 0; - return st_lookup( p->syms, id, (st_data_t *)data ); -} - -int -syck_st_free_nodes( char *key, SyckNode *n, char *arg ) -{ - syck_free_node( n ); - return ST_CONTINUE; -} - -void -syck_st_free( SyckParser *p ) -{ - /* - * Free the adhoc symbol table - */ - if ( p->syms != NULL ) - { - st_free_table( p->syms ); - p->syms = NULL; - } - - /* - * Free the anchor tables - */ - if ( p->anchors != NULL ) - { - st_foreach( p->anchors, syck_st_free_nodes, 0 ); - st_free_table( p->anchors ); - p->anchors = NULL; - } - - if ( p->bad_anchors != NULL ) - { - st_foreach( p->bad_anchors, syck_st_free_nodes, 0 ); - st_free_table( p->bad_anchors ); - p->bad_anchors = NULL; - } -} - -void -syck_free_parser( SyckParser *p ) -{ - /* - * Free tables, levels - */ - syck_st_free( p ); - syck_parser_reset_levels( p ); - S_FREE( p->levels[0].domain ); - S_FREE( p->levels ); - - if ( p->buffer != NULL ) - { - S_FREE( p->buffer ); - } - free_any_io( p ); - S_FREE( p ); -} - -void -syck_parser_handler( SyckParser *p, SyckNodeHandler hdlr ) -{ - ASSERT( p != NULL ); - p->handler = hdlr; -} - -void -syck_parser_implicit_typing( SyckParser *p, int flag ) -{ - p->implicit_typing = ( flag == 0 ? 0 : 1 ); -} - -void -syck_parser_taguri_expansion( SyckParser *p, int flag ) -{ - p->taguri_expansion = ( flag == 0 ? 0 : 1 ); -} - -void -syck_parser_error_handler( SyckParser *p, SyckErrorHandler hdlr ) -{ - ASSERT( p != NULL ); - p->error_handler = hdlr; -} - -void -syck_parser_bad_anchor_handler( SyckParser *p, SyckBadAnchorHandler hdlr ) -{ - ASSERT( p != NULL ); - p->bad_anchor_handler = hdlr; -} - -void -syck_parser_set_input_type( SyckParser *p, enum syck_parser_input input_type ) -{ - ASSERT( p != NULL ); - p->input_type = input_type; -} - -void -syck_parser_file( SyckParser *p, FILE *fp, SyckIoFileRead read ) -{ - ASSERT( p != NULL ); - free_any_io( p ); - syck_parser_reset_cursor( p ); - p->io_type = syck_io_file; - p->io.file = S_ALLOC( SyckIoFile ); - p->io.file->ptr = fp; - if ( read != NULL ) - { - p->io.file->read = read; - } - else - { - p->io.file->read = syck_io_file_read; - } -} - -void -syck_parser_str( SyckParser *p, char *ptr, long len, SyckIoStrRead read ) -{ - ASSERT( p != NULL ); - free_any_io( p ); - syck_parser_reset_cursor( p ); - p->io_type = syck_io_str; - p->io.str = S_ALLOC( SyckIoStr ); - p->io.str->beg = ptr; - p->io.str->ptr = ptr; - p->io.str->end = ptr + len; - if ( read != NULL ) - { - p->io.str->read = read; - } - else - { - p->io.str->read = syck_io_str_read; - } -} - -void -syck_parser_str_auto( SyckParser *p, char *ptr, SyckIoStrRead read ) -{ - syck_parser_str( p, ptr, strlen( ptr ), read ); -} - -SyckLevel * -syck_parser_current_level( SyckParser *p ) -{ - return &p->levels[p->lvl_idx-1]; -} - -void -syck_parser_pop_level( SyckParser *p ) -{ - ASSERT( p != NULL ); - - /* The root level should never be popped */ - if ( p->lvl_idx <= 1 ) return; - - p->lvl_idx -= 1; - free( p->levels[p->lvl_idx].domain ); -} - -void -syck_parser_add_level( SyckParser *p, int len, enum syck_level_status status ) -{ - ASSERT( p != NULL ); - if ( p->lvl_idx + 1 > p->lvl_capa ) - { - p->lvl_capa += ALLOC_CT; - S_REALLOC_N( p->levels, SyckLevel, p->lvl_capa ); - } - - ASSERT( len > p->levels[p->lvl_idx-1].spaces ); - p->levels[p->lvl_idx].spaces = len; - p->levels[p->lvl_idx].ncount = 0; - p->levels[p->lvl_idx].domain = syck_strndup( p->levels[p->lvl_idx-1].domain, strlen( p->levels[p->lvl_idx-1].domain ) ); - p->levels[p->lvl_idx].status = status; - p->lvl_idx += 1; -} - -void -free_any_io( SyckParser *p ) -{ - ASSERT( p != NULL ); - switch ( p->io_type ) - { - case syck_io_str: - if ( p->io.str != NULL ) - { - S_FREE( p->io.str ); - p->io.str = NULL; - } - break; - - case syck_io_file: - if ( p->io.file != NULL ) - { - S_FREE( p->io.file ); - p->io.file = NULL; - } - break; - } -} - -long -syck_move_tokens( SyckParser *p ) -{ - long count, skip; - ASSERT( p->buffer != NULL ); - - if ( p->token == NULL ) - return 0; - - skip = p->limit - p->token; - if ( skip < 1 ) - return 0; - - if ( ( count = p->token - p->buffer ) ) - { - S_MEMMOVE( p->buffer, p->token, char, skip ); - p->token = p->buffer; - p->marker -= count; - p->cursor -= count; - p->toktmp -= count; - p->limit -= count; - p->lineptr -= count; - p->linectptr -= count; - } - return skip; -} - -void -syck_check_limit( SyckParser *p, long len ) -{ - if ( p->cursor == NULL ) - { - p->cursor = p->buffer; - p->lineptr = p->buffer; - p->linectptr = p->buffer; - p->marker = p->buffer; - } - p->limit = p->buffer + len; -} - -long -syck_parser_read( SyckParser *p ) -{ - long len = 0; - long skip = 0; - ASSERT( p != NULL ); - switch ( p->io_type ) - { - case syck_io_str: - skip = syck_move_tokens( p ); - len = (p->io.str->read)( p->buffer, p->io.str, SYCK_BUFFERSIZE - 1, skip ); - break; - - case syck_io_file: - skip = syck_move_tokens( p ); - len = (p->io.file->read)( p->buffer, p->io.file, SYCK_BUFFERSIZE - 1, skip ); - break; - } - syck_check_limit( p, len ); - return len; -} - -long -syck_parser_readlen( SyckParser *p, long max_size ) -{ - long len = 0; - long skip = 0; - ASSERT( p != NULL ); - switch ( p->io_type ) - { - case syck_io_str: - skip = syck_move_tokens( p ); - len = (p->io.str->read)( p->buffer, p->io.str, max_size, skip ); - break; - - case syck_io_file: - skip = syck_move_tokens( p ); - len = (p->io.file->read)( p->buffer, p->io.file, max_size, skip ); - break; - } - syck_check_limit( p, len ); - return len; -} - -SYMID -syck_parse( SyckParser *p ) -{ - ASSERT( p != NULL ); - - syck_st_free( p ); - syck_parser_reset_levels( p ); - syckparse( p ); - return p->root; -} - -void -syck_default_error_handler( SyckParser *p, char *msg ) -{ - printf( "Error at [Line %d, Col %d]: %s\n", - p->linect, - p->cursor - p->lineptr, - msg ); -} - diff --git a/ext/syck/syck.h b/ext/syck/syck.h deleted file mode 100644 index 0383c5ad47..0000000000 --- a/ext/syck/syck.h +++ /dev/null @@ -1,400 +0,0 @@ -/* - * syck.h - * - * $Author$ - * $Date$ - * - * Copyright (C) 2003 why the lucky stiff - */ - -#ifndef SYCK_H -#define SYCK_H - -#define SYCK_YAML_MAJOR 1 -#define SYCK_YAML_MINOR 0 - -#define SYCK_VERSION "0.42" -#define YAML_DOMAIN "yaml.org,2002" - -#include <stdio.h> -#include <ctype.h> -#include "st.h" - -#if defined(__cplusplus) -extern "C" { -#endif - -/* - * Memory Allocation - */ -#if defined(HAVE_ALLOCA_H) && !defined(__GNUC__) -#include <alloca.h> -#endif - -#if DEBUG - void syck_assert( char *, unsigned ); -# define ASSERT(f) \ - if ( f ) \ - {} \ - else \ - syck_assert( __FILE__, __LINE__ ) -#else -# define ASSERT(f) -#endif - -#ifndef NULL -# define NULL (void *)0 -#endif - -#define ALLOC_CT 8 -#define SYCK_BUFFERSIZE 4096 -#define S_ALLOC_N(type,n) (type*)malloc(sizeof(type)*(n)) -#define S_ALLOC(type) (type*)malloc(sizeof(type)) -#define S_REALLOC_N(var,type,n) (var)=(type*)realloc((char*)(var),sizeof(type)*(n)) -#define S_FREE(n) free(n); n = NULL; - -#define S_ALLOCA_N(type,n) (type*)alloca(sizeof(type)*(n)) - -#define S_MEMZERO(p,type,n) memset((p), 0, sizeof(type)*(n)) -#define S_MEMCPY(p1,p2,type,n) memcpy((p1), (p2), sizeof(type)*(n)) -#define S_MEMMOVE(p1,p2,type,n) memmove((p1), (p2), sizeof(type)*(n)) -#define S_MEMCMP(p1,p2,type,n) memcmp((p1), (p2), sizeof(type)*(n)) - -#define BLOCK_FOLD 10 -#define BLOCK_LIT 20 -#define BLOCK_PLAIN 30 -#define NL_CHOMP 130 -#define NL_KEEP 140 - -/* - * Node definitions - */ -#define SYMID unsigned long - -typedef struct _syck_node SyckNode; - -enum syck_kind_tag { - syck_map_kind, - syck_seq_kind, - syck_str_kind -}; - -enum map_part { - map_key, - map_value -}; - -/* - * Node metadata struct - */ -struct _syck_node { - /* Symbol table ID */ - SYMID id; - /* Underlying kind */ - enum syck_kind_tag kind; - /* Fully qualified tag-uri for type */ - char *type_id; - /* Anchor name */ - char *anchor; - union { - /* Storage for map data */ - struct SyckMap { - SYMID *keys; - SYMID *values; - long capa; - long idx; - } *pairs; - /* Storage for sequence data */ - struct SyckSeq { - SYMID *items; - long capa; - long idx; - } *list; - /* Storage for string data */ - struct SyckStr { - char *ptr; - long len; - } *str; - } data; - /* Shortcut node */ - void *shortcut; -}; - -/* - * Parser definitions - */ -typedef struct _syck_parser SyckParser; -typedef struct _syck_file SyckIoFile; -typedef struct _syck_str SyckIoStr; -typedef struct _syck_level SyckLevel; - -typedef SYMID (*SyckNodeHandler)(SyckParser *, SyckNode *); -typedef void (*SyckErrorHandler)(SyckParser *, char *); -typedef SyckNode * (*SyckBadAnchorHandler)(SyckParser *, char *); -typedef long (*SyckIoFileRead)(char *, SyckIoFile *, long, long); -typedef long (*SyckIoStrRead)(char *, SyckIoStr *, long, long); - -enum syck_io_type { - syck_io_str, - syck_io_file -}; - -enum syck_parser_input { - syck_yaml_utf8, - syck_yaml_utf16, - syck_yaml_utf32, - syck_bytecode_utf8 -}; - -enum syck_level_status { - syck_lvl_header, - syck_lvl_doc, - syck_lvl_open, - syck_lvl_seq, - syck_lvl_map, - syck_lvl_block, - syck_lvl_str, - syck_lvl_inline, - syck_lvl_end, - syck_lvl_pause -}; - -/* - * Parser structs - */ -struct _syck_file { - /* File pointer */ - FILE *ptr; - /* Function which FILE -> buffer */ - SyckIoFileRead read; -}; - -struct _syck_str { - /* String buffer pointers */ - char *beg, *ptr, *end; - /* Function which string -> buffer */ - SyckIoStrRead read; -}; - -struct _syck_level { - int spaces; - int ncount; - char *domain; - enum syck_level_status status; -}; - -struct _syck_parser { - /* Root node */ - SYMID root, root_on_error; - /* Implicit typing flag */ - int implicit_typing, taguri_expansion; - /* Scripting language function to handle nodes */ - SyckNodeHandler handler; - /* Error handler */ - SyckErrorHandler error_handler; - /* InvalidAnchor handler */ - SyckBadAnchorHandler bad_anchor_handler; - /* Parser input type */ - enum syck_parser_input input_type; - /* IO type */ - enum syck_io_type io_type; - /* Custom buffer size */ - size_t bufsize; - /* Buffer pointers */ - char *buffer, *linectptr, *lineptr, *toktmp, *token, *cursor, *marker, *limit; - /* Line counter */ - int linect; - /* Last token from yylex() */ - int last_token; - /* Force a token upon next call to yylex() */ - int force_token; - /* EOF flag */ - int eof; - union { - SyckIoFile *file; - SyckIoStr *str; - } io; - /* Symbol table for anchors */ - st_table *anchors, *bad_anchors; - /* Optional symbol table for SYMIDs */ - st_table *syms; - /* Levels of indentation */ - SyckLevel *levels; - int lvl_idx; - int lvl_capa; - void *bonus; -}; - -/* - * Emitter definitions - */ -typedef struct _syck_emitter SyckEmitter; -typedef struct _syck_emitter_node SyckEmitterNode; - -typedef void (*SyckOutputHandler)(SyckEmitter *, char *, long); - -enum doc_stage { - doc_open, - doc_need_header, - doc_processing -}; - -enum block_styles { - block_arbitrary, - block_fold, - block_literal -}; - -/* - * Emitter struct - */ -struct _syck_emitter { - /* Headerless doc flag */ - int headless; - /* Sequence map shortcut flag */ - int seq_map; - /* Force header? */ - int use_header; - /* Force version? */ - int use_version; - /* Sort hash keys */ - int sort_keys; - /* Anchor format */ - char *anchor_format; - /* Explicit typing on all collections? */ - int explicit_typing; - /* Best width on folded scalars */ - int best_width; - /* Use literal[1] or folded[2] blocks on all text? */ - enum block_styles block_style; - /* Stage of written document */ - enum doc_stage stage; - /* Level counter */ - int level; - /* Default indentation */ - int indent; - /* Object ignore ID */ - SYMID ignore_id; - /* Symbol table for anchors */ - st_table *markers, *anchors; - /* Custom buffer size */ - size_t bufsize; - /* Buffer */ - char *buffer, *marker; - /* Absolute position of the buffer */ - long bufpos; - /* Handler for output */ - SyckOutputHandler handler; - /* Pointer for extension's use */ - void *bonus; -}; - -/* - * Emitter node metadata struct - */ -struct _syck_emitter_node { - /* Node buffer position */ - long pos; - /* Current indent */ - long indent; - /* Collection? */ - int is_shortcut; -}; - -/* - * Handler prototypes - */ -SYMID syck_hdlr_add_node( SyckParser *, SyckNode * ); -SyckNode *syck_hdlr_add_anchor( SyckParser *, char *, SyckNode * ); -void syck_hdlr_remove_anchor( SyckParser *, char * ); -SyckNode *syck_hdlr_get_anchor( SyckParser *, char * ); -void syck_add_transfer( char *, SyckNode *, int ); -char *syck_xprivate( char *, int ); -char *syck_taguri( char *, char *, int ); -int syck_add_sym( SyckParser *, char * ); -int syck_lookup_sym( SyckParser *, SYMID, char ** ); -int syck_try_implicit( SyckNode * ); -char *syck_type_id_to_uri( char * ); -void try_tag_implicit( SyckNode *, int ); -char *syck_match_implicit( char *, size_t ); - -/* - * API prototypes - */ -char *syck_strndup( char *, long ); -long syck_io_file_read( char *, SyckIoFile *, long, long ); -long syck_io_str_read( char *, SyckIoStr *, long, long ); -char *syck_base64enc( char *, long ); -char *syck_base64dec( char *, long ); -SyckEmitter *syck_new_emitter(); -void syck_emitter_ignore_id( SyckEmitter *, SYMID ); -void syck_emitter_handler( SyckEmitter *, SyckOutputHandler ); -void syck_free_emitter( SyckEmitter * ); -void syck_emitter_clear( SyckEmitter * ); -void syck_emitter_simple( SyckEmitter *, char *, long ); -void syck_emitter_write( SyckEmitter *, char *, long ); -void syck_emitter_flush( SyckEmitter *, long ); -char *syck_emitter_start_obj( SyckEmitter *, SYMID ); -void syck_emitter_end_obj( SyckEmitter * ); -SyckParser *syck_new_parser(); -void syck_free_parser( SyckParser * ); -void syck_parser_set_root_on_error( SyckParser *, SYMID ); -void syck_parser_implicit_typing( SyckParser *, int ); -void syck_parser_taguri_expansion( SyckParser *, int ); -void syck_parser_handler( SyckParser *, SyckNodeHandler ); -void syck_parser_error_handler( SyckParser *, SyckErrorHandler ); -void syck_parser_bad_anchor_handler( SyckParser *, SyckBadAnchorHandler ); -void syck_parser_file( SyckParser *, FILE *, SyckIoFileRead ); -void syck_parser_str( SyckParser *, char *, long, SyckIoStrRead ); -void syck_parser_str_auto( SyckParser *, char *, SyckIoStrRead ); -SyckLevel *syck_parser_current_level( SyckParser * ); -void syck_parser_add_level( SyckParser *, int, enum syck_level_status ); -void syck_parser_pop_level( SyckParser * ); -void free_any_io( SyckParser * ); -long syck_parser_read( SyckParser * ); -long syck_parser_readlen( SyckParser *, long ); -void syck_parser_init( SyckParser *, int ); -SYMID syck_parse( SyckParser * ); -void syck_default_error_handler( SyckParser *, char * ); -SYMID syck_yaml2byte_handler( SyckParser *, SyckNode * ); -char *syck_yaml2byte( char * ); - -/* - * Allocation prototypes - */ -SyckNode *syck_alloc_map(); -SyckNode *syck_alloc_seq(); -SyckNode *syck_alloc_str(); -void syck_free_node( SyckNode * ); -void syck_free_members( SyckNode * ); -SyckNode *syck_new_str( char * ); -SyckNode *syck_new_str2( char *, long ); -void syck_str_blow_away_commas( SyckNode * ); -char *syck_str_read( SyckNode * ); -SyckNode *syck_new_map( SYMID, SYMID ); -void syck_map_add( SyckNode *, SYMID, SYMID ); -SYMID syck_map_read( SyckNode *, enum map_part, long ); -void syck_map_assign( SyckNode *, enum map_part, long, SYMID ); -long syck_map_count( SyckNode * ); -void syck_map_update( SyckNode *, SyckNode * ); -SyckNode *syck_new_seq( SYMID ); -void syck_seq_add( SyckNode *, SYMID ); -SYMID syck_seq_read( SyckNode *, long ); -long syck_seq_count( SyckNode * ); - -void apply_seq_in_map( SyckParser *, SyckNode * ); - -/* - * Lexer prototypes - */ -void syckerror( char * ); - -#ifndef ST_DATA_T_DEFINED -typedef long st_data_t; -#endif - -#if defined(__cplusplus) -} /* extern "C" { */ -#endif - -#endif /* ifndef SYCK_H */ diff --git a/ext/syck/token.c b/ext/syck/token.c deleted file mode 100644 index f9e0601e52..0000000000 --- a/ext/syck/token.c +++ /dev/null @@ -1,2394 +0,0 @@ -/* Generated by re2c 0.5 on Tue Nov 25 12:10:28 2003 */ -#line 1 "token.re" -/* - * token.re - * - * $Author$ - * $Date$ - * - * Copyright (C) 2003 why the lucky stiff - */ -#include "syck.h" -#include "ruby.h" -#include "gram.h" - -/* - * Allocate quoted strings in chunks - */ -#define QUOTELEN 1024 - -/* - * They do my bidding... - */ -#define YYCTYPE char -#define YYCURSOR parser->cursor -#define YYMARKER parser->marker -#define YYLIMIT parser->limit -#define YYTOKEN parser->token -#define YYTOKTMP parser->toktmp -#define YYLINEPTR parser->lineptr -#define YYLINECTPTR parser->linectptr -#define YYLINE parser->linect -#define YYFILL(n) syck_parser_read(parser) - -/* - * Repositions the cursor at `n' offset from the token start. - * Only works in `Header' and `Document' sections. - */ -#define YYPOS(n) YYCURSOR = YYTOKEN + n - -/* - * Track line numbers - */ -#define NEWLINE(ptr) YYLINEPTR = ptr + 1; if ( YYLINEPTR > YYLINECTPTR ) { YYLINE++; YYLINECTPTR = YYLINEPTR; } - -/* - * I like seeing the level operations as macros... - */ -#define ADD_LEVEL(len, status) syck_parser_add_level( parser, len, status ) -#define POP_LEVEL() syck_parser_pop_level( parser ) -#define CURRENT_LEVEL() syck_parser_current_level( parser ) - -/* - * Force a token next time around sycklex() - */ -#define FORCE_NEXT_TOKEN(tok) parser->force_token = tok; - -/* - * Nice little macro to ensure we're YAML_IOPENed to the current level. - * * Only use this macro in the "Document" section * - */ -#define ENSURE_YAML_IOPEN(last_lvl, to_len, reset) \ - if ( last_lvl->spaces < to_len ) \ - { \ - if ( last_lvl->status == syck_lvl_inline ) \ - { \ - goto Document; \ - } \ - else \ - { \ - ADD_LEVEL( to_len, syck_lvl_doc ); \ - if ( reset == 1 ) YYPOS(0); \ - return YAML_IOPEN; \ - } \ - } - -/* - * Nice little macro to ensure closure of levels. - * * Only use this macro in the "Document" section * - */ -#define ENSURE_YAML_IEND(last_lvl, to_len) \ - if ( last_lvl->spaces > to_len ) \ - { \ - syck_parser_pop_level( parser ); \ - YYPOS(0); \ - return YAML_IEND; \ - } - -/* - * Concatenates quoted string items and manages allocation - * to the quoted string - */ -#define QUOTECAT(s, c, i, l) \ - { \ - if ( i + 1 >= c ) \ - { \ - c += QUOTELEN; \ - S_REALLOC_N( s, char, c ); \ - } \ - s[i++] = l; \ - s[i] = '\0'; \ - } - -#define QUOTECATS(s, c, i, cs, cl) \ - { \ - while ( i + cl >= c ) \ - { \ - c += QUOTELEN; \ - S_REALLOC_N( s, char, c ); \ - } \ - S_MEMCPY( s + i, cs, char, cl ); \ - i += cl; \ - s[i] = '\0'; \ - } - -/* - * Tags a plain scalar with a transfer method - * * Use only in "Plain" section * - */ -#define RETURN_IMPLICIT() \ - { \ - SyckNode *n = syck_alloc_str(); \ - YYCURSOR = YYTOKEN; \ - n->data.str->ptr = qstr; \ - n->data.str->len = qidx; \ - sycklval->nodeData = n; \ - if ( parser->implicit_typing == 1 ) \ - { \ - try_tag_implicit( sycklval->nodeData, parser->taguri_expansion ); \ - } \ - return YAML_PLAIN; \ - } - -/* - * Keep or chomp block? - * * Use only in "ScalarBlock" section * - */ -#define RETURN_YAML_BLOCK() \ - { \ - SyckNode *n = syck_alloc_str(); \ - n->type_id = syck_strndup( "str", 3 ); \ - n->data.str->ptr = qstr; \ - n->data.str->len = qidx; \ - if ( qidx > 0 ) \ - { \ - if ( nlDoWhat != NL_KEEP ) \ - { \ - char *fc = n->data.str->ptr + n->data.str->len - 1; \ - while ( is_newline( fc ) ) fc--; \ - if ( nlDoWhat != NL_CHOMP ) \ - fc += 1; \ - n->data.str->len = fc - n->data.str->ptr + 1; \ - } \ - } \ - sycklval->nodeData = n; \ - return YAML_BLOCK; \ - } - -/* - * Handles newlines, calculates indent - */ -#define GOBBLE_UP_YAML_INDENT( ict, start ) \ - char *indent = start; \ - NEWLINE(indent); \ - while ( indent < YYCURSOR ) \ - { \ - if ( is_newline( ++indent ) ) \ - { \ - NEWLINE(indent); \ - } \ - } \ - ict = 0; \ - if ( *YYCURSOR == '\0' ) \ - { \ - ict = -1; \ - start = YYCURSOR - 1; \ - } \ - else if ( *YYLINEPTR == ' ' ) \ - { \ - ict = YYCURSOR - YYLINEPTR; \ - } - -/* - * If an indent exists at the current level, back up. - */ -#define GET_TRUE_YAML_INDENT(indt_len) \ - { \ - SyckLevel *lvl_deep = CURRENT_LEVEL(); \ - indt_len = lvl_deep->spaces; \ - if ( indt_len == YYTOKEN - YYLINEPTR ) \ - { \ - SyckLevel *lvl_over; \ - parser->lvl_idx--; \ - lvl_over = CURRENT_LEVEL(); \ - indt_len = lvl_over->spaces; \ - parser->lvl_idx++; \ - } \ - } - -/* - * Argjh! I hate globals! Here for syckerror() only! - */ -SyckParser *syck_parser_ptr = NULL; - -/* - * Accessory funcs later in this file. - */ -void eat_comments( SyckParser * ); -int is_newline( char *ptr ); -int sycklex_yaml_utf8( YYSTYPE *, SyckParser * ); -int sycklex_bytecode_utf8( YYSTYPE *, SyckParser * ); -int syckwrap(); - -/* - * My own re-entrant sycklex() using re2c. - * You really get used to the limited regexp. - * It's really nice to not rely on backtracking and such. - */ -int -sycklex( YYSTYPE *sycklval, SyckParser *parser ) -{ - switch ( parser->input_type ) - { - case syck_yaml_utf8: - return sycklex_yaml_utf8( sycklval, parser ); - - case syck_yaml_utf16: - syckerror( "UTF-16 is not currently supported in Syck.\nPlease contribute code to help this happen!" ); - break; - - case syck_yaml_utf32: - syckerror( "UTF-32 is not currently supported in Syck.\nPlease contribute code to help this happen!" ); - break; - - case syck_bytecode_utf8: - return sycklex_bytecode_utf8( sycklval, parser ); - } -} - -/* - * Parser for standard YAML [UTF-8] - */ -int -sycklex_yaml_utf8( YYSTYPE *sycklval, SyckParser *parser ) -{ - int doc_level = 0; - syck_parser_ptr = parser; - if ( YYCURSOR == NULL ) - { - syck_parser_read( parser ); - } - - if ( parser->force_token != 0 ) - { - int t = parser->force_token; - parser->force_token = 0; - return t; - } - -#line 274 - - - if ( YYLINEPTR != YYCURSOR ) - { - goto Document; - } - -Header: - - YYTOKEN = YYCURSOR; - -{ - YYCTYPE yych; - unsigned int yyaccept; - goto yy0; -yy1: ++YYCURSOR; -yy0: - if((YYLIMIT - YYCURSOR) < 5) YYFILL(5); - yych = *YYCURSOR; - switch(yych){ - case '\000': goto yy7; - case '\n': goto yy9; - case '\r': goto yy11; - case ' ': goto yy12; - case '#': goto yy5; - case '-': goto yy2; - case '.': goto yy4; - default: goto yy14; - } -yy2: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case '-': goto yy28; - default: goto yy3; - } -yy3: -#line 333 - { YYPOS(0); - goto Document; - } -yy4: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case '.': goto yy21; - default: goto yy3; - } -yy5: yych = *++YYCURSOR; -yy6: -#line 315 - { eat_comments( parser ); - goto Header; - } -yy7: yych = *++YYCURSOR; -yy8: -#line 319 - { SyckLevel *lvl = CURRENT_LEVEL(); - ENSURE_YAML_IEND(lvl, -1); - YYPOS(0); - return 0; - } -yy9: yyaccept = 1; - yych = *(YYMARKER = ++YYCURSOR); - goto yy18; -yy10: -#line 325 - { GOBBLE_UP_YAML_INDENT( doc_level, YYTOKEN ); - goto Header; - } -yy11: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy17; - default: goto yy3; - } -yy12: yych = *++YYCURSOR; - goto yy16; -yy13: -#line 329 - { doc_level = YYCURSOR - YYLINEPTR; - goto Header; - } -yy14: yych = *++YYCURSOR; - goto yy3; -yy15: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy16: switch(yych){ - case ' ': goto yy15; - default: goto yy13; - } -yy17: yyaccept = 1; - YYMARKER = ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy18: switch(yych){ - case '\n': case ' ': goto yy17; - case '\r': goto yy19; - default: goto yy10; - } -yy19: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - switch(yych){ - case '\n': goto yy17; - default: goto yy20; - } -yy20: YYCURSOR = YYMARKER; - switch(yyaccept){ - case 1: goto yy10; - case 0: goto yy3; - } -yy21: yych = *++YYCURSOR; - switch(yych){ - case '.': goto yy22; - default: goto yy20; - } -yy22: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy23; - case '\r': goto yy27; - case ' ': goto yy25; - default: goto yy20; - } -yy23: yych = *++YYCURSOR; -yy24: -#line 301 - { SyckLevel *lvl = CURRENT_LEVEL(); - if ( lvl->status == syck_lvl_header ) - { - goto Header; - } - else - { - ENSURE_YAML_IEND(lvl, -1); - YYPOS(0); - return 0; - } - return 0; - } -yy25: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy26: switch(yych){ - case ' ': goto yy25; - default: goto yy24; - } -yy27: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy23; - default: goto yy20; - } -yy28: yych = *++YYCURSOR; - switch(yych){ - case '-': goto yy29; - default: goto yy20; - } -yy29: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy30; - case '\r': goto yy34; - case ' ': goto yy32; - default: goto yy20; - } -yy30: yych = *++YYCURSOR; -yy31: -#line 287 - { SyckLevel *lvl = CURRENT_LEVEL(); - if ( lvl->status == syck_lvl_header ) - { - YYPOS(3); - goto Directive; - } - else - { - ENSURE_YAML_IEND(lvl, -1); - YYPOS(0); - return 0; - } - } -yy32: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy33: switch(yych){ - case ' ': goto yy32; - default: goto yy31; - } -yy34: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy30; - default: goto yy20; - } -} -#line 337 - - -Document: - { - SyckLevel *lvl = CURRENT_LEVEL(); - if ( lvl->status == syck_lvl_header ) - { - lvl->status = syck_lvl_doc; - } - - YYTOKEN = YYCURSOR; - -{ - YYCTYPE yych; - unsigned int yyaccept; - goto yy35; -yy36: ++YYCURSOR; -yy35: - if((YYLIMIT - YYCURSOR) < 3) YYFILL(3); - yych = *YYCURSOR; - switch(yych){ - case '\000': goto yy60; - case '\n': goto yy37; - case '\r': goto yy39; - case ' ': goto yy58; - case '!': goto yy49; - case '"': goto yy53; - case '#': goto yy56; - case '&': goto yy47; - case '\'': goto yy51; - case '*': goto yy48; - case ',': case ':': goto yy45; - case '-': case '?': goto yy46; - case '>': case '|': goto yy55; - case '[': case '{': goto yy41; - case ']': case '}': goto yy43; - default: goto yy62; - } -yy37: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - goto yy90; -yy38: -#line 351 - { /* Isolate spaces */ - int indt_len; - GOBBLE_UP_YAML_INDENT( indt_len, YYTOKEN ); - lvl = CURRENT_LEVEL(); - doc_level = 0; - - /* XXX: Comment lookahead */ - if ( *YYCURSOR == '#' ) - { - goto Document; - } - - /* Check for open indent */ - ENSURE_YAML_IEND(lvl, indt_len); - ENSURE_YAML_IOPEN(lvl, indt_len, 0); - if ( indt_len == -1 ) - { - return 0; - } - return YAML_INDENT; - } -yy39: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy89; - default: goto yy40; - } -yy40: -#line 445 - { ENSURE_YAML_IOPEN(lvl, doc_level, 1); - goto Plain; - } -yy41: yych = *++YYCURSOR; -yy42: -#line 373 - { ENSURE_YAML_IOPEN(lvl, doc_level, 1); - lvl = CURRENT_LEVEL(); - ADD_LEVEL(lvl->spaces + 1, syck_lvl_inline); - return YYTOKEN[0]; - } -yy43: yych = *++YYCURSOR; -yy44: -#line 379 - { POP_LEVEL(); - return YYTOKEN[0]; - } -yy45: yyaccept = 1; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case '\n': goto yy84; - case '\r': goto yy88; - case ' ': goto yy86; - default: goto yy40; - } -yy46: yyaccept = 1; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case '\n': goto yy79; - case '\r': goto yy83; - case ' ': goto yy81; - default: goto yy40; - } -yy47: yych = *++YYCURSOR; - switch(yych){ - case '-': case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': case '_': case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto yy76; - default: goto yy40; - } -yy48: yych = *++YYCURSOR; - switch(yych){ - case '-': case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': case '_': case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto yy73; - default: goto yy40; - } -yy49: yych = *++YYCURSOR; -yy50: -#line 418 - { ENSURE_YAML_IOPEN(lvl, doc_level, 1); - goto TransferMethod; } -yy51: yych = *++YYCURSOR; -yy52: -#line 421 - { ENSURE_YAML_IOPEN(lvl, doc_level, 1); - goto SingleQuote; } -yy53: yych = *++YYCURSOR; -yy54: -#line 424 - { ENSURE_YAML_IOPEN(lvl, doc_level, 1); - goto DoubleQuote; } -yy55: yyaccept = 1; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case '\n': goto yy68; - case '\r': goto yy72; - case ' ': goto yy70; - case '+': case '-': case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy65; - default: goto yy40; - } -yy56: yych = *++YYCURSOR; -yy57: -#line 434 - { eat_comments( parser ); - goto Document; - } -yy58: yych = *++YYCURSOR; - goto yy64; -yy59: -#line 438 - { goto Document; } -yy60: yych = *++YYCURSOR; -yy61: -#line 440 - { ENSURE_YAML_IEND(lvl, -1); - YYPOS(0); - return 0; - } -yy62: yych = *++YYCURSOR; - goto yy40; -yy63: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy64: switch(yych){ - case ' ': goto yy63; - default: goto yy59; - } -yy65: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy66: switch(yych){ - case '\n': goto yy68; - case '\r': goto yy72; - case ' ': goto yy70; - case '+': case '-': case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy65; - default: goto yy67; - } -yy67: YYCURSOR = YYMARKER; - switch(yyaccept){ - case 0: goto yy38; - case 1: goto yy40; - } -yy68: yych = *++YYCURSOR; -yy69: -#line 427 - { if ( is_newline( YYCURSOR - 1 ) ) - { - YYCURSOR--; - } - goto ScalarBlock; - } -yy70: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy71: switch(yych){ - case ' ': goto yy70; - default: goto yy69; - } -yy72: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy68; - default: goto yy67; - } -yy73: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy74: switch(yych){ - case '-': case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': case '_': case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto yy73; - default: goto yy75; - } -yy75: -#line 413 - { ENSURE_YAML_IOPEN(lvl, doc_level, 1); - sycklval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 ); - return YAML_ALIAS; - } -yy76: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy77: switch(yych){ - case '-': case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': case '_': case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto yy76; - default: goto yy78; - } -yy78: -#line 401 - { ENSURE_YAML_IOPEN(lvl, doc_level, 1); - sycklval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 ); - - /* - * Remove previous anchors of the same name. Since the parser will likely - * construct deeper nodes first, we want those nodes to be placed in the - * queue for matching at a higher level of indentation. - */ - syck_hdlr_remove_anchor(parser, sycklval->name); - return YAML_ANCHOR; - } -yy79: yych = *++YYCURSOR; -yy80: -#line 387 - { ENSURE_YAML_IOPEN(lvl, YYTOKEN - YYLINEPTR, 1); - FORCE_NEXT_TOKEN(YAML_IOPEN); - if ( is_newline( YYCURSOR ) || is_newline( YYCURSOR - 1 ) ) - { - YYCURSOR--; - ADD_LEVEL((YYTOKEN + 1) - YYLINEPTR, syck_lvl_doc); - } - else - { - ADD_LEVEL(YYCURSOR - YYLINEPTR, syck_lvl_doc); - } - return YYTOKEN[0]; - } -yy81: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy82: switch(yych){ - case ' ': goto yy81; - default: goto yy80; - } -yy83: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy79; - default: goto yy67; - } -yy84: yych = *++YYCURSOR; -yy85: -#line 383 - { YYPOS(1); - return YYTOKEN[0]; - } -yy86: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy87: switch(yych){ - case ' ': goto yy86; - default: goto yy85; - } -yy88: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy84; - default: goto yy67; - } -yy89: yyaccept = 0; - YYMARKER = ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy90: switch(yych){ - case '\n': case ' ': goto yy89; - case '\r': goto yy91; - default: goto yy38; - } -yy91: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - switch(yych){ - case '\n': goto yy89; - default: goto yy67; - } -} -#line 449 - - } - -Directive: - { - YYTOKTMP = YYCURSOR; - -{ - YYCTYPE yych; - unsigned int yyaccept; - goto yy92; -yy93: ++YYCURSOR; -yy92: - if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); - yych = *YYCURSOR; - switch(yych){ - case '\000': goto yy94; - case ' ': goto yy97; - case '%': goto yy95; - default: goto yy99; - } -yy94: YYCURSOR = YYMARKER; - switch(yyaccept){ - case 0: goto yy96; - } -yy95: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case '.': - case '/': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case ';': - case '<': - case '=': - case '>': - case '?': - case '@': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '[': - case '\\': - case ']': - case '^': - case '_': case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto yy102; - default: goto yy96; - } -yy96: -#line 462 - { YYCURSOR = YYTOKTMP; - return YAML_DOCSEP; - } -yy97: yych = *++YYCURSOR; - goto yy101; -yy98: -#line 460 - { goto Directive; } -yy99: yych = *++YYCURSOR; - goto yy96; -yy100: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy101: switch(yych){ - case ' ': goto yy100; - default: goto yy98; - } -yy102: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy103: switch(yych){ - case '.': - case '/': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': case ';': - case '<': - case '=': - case '>': - case '?': - case '@': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '[': - case '\\': - case ']': - case '^': - case '_': case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto yy102; - case ':': goto yy104; - default: goto yy94; - } -yy104: yych = *++YYCURSOR; - switch(yych){ - case '.': - case '/': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case ';': - case '<': - case '=': - case '>': - case '?': - case '@': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '[': - case '\\': - case ']': - case '^': - case '_': case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto yy105; - default: goto yy94; - } -yy105: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy106: switch(yych){ - case '.': - case '/': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case ';': - case '<': - case '=': - case '>': - case '?': - case '@': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '[': - case '\\': - case ']': - case '^': - case '_': case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto yy105; - default: goto yy107; - } -yy107: -#line 458 - { goto Directive; } -} -#line 465 - - - } - -Plain: - { - int qidx = 0; - int qcapa = 100; - char *qstr = S_ALLOC_N( char, qcapa ); - SyckLevel *plvl; - int parentIndent; - - YYCURSOR = YYTOKEN; - plvl = CURRENT_LEVEL(); - GET_TRUE_YAML_INDENT(parentIndent); - -Plain2: - YYTOKEN = YYCURSOR; - -Plain3: - -{ - YYCTYPE yych; - unsigned int yyaccept; - goto yy108; -yy109: ++YYCURSOR; -yy108: - if((YYLIMIT - YYCURSOR) < 3) YYFILL(3); - yych = *YYCURSOR; - switch(yych){ - case '\000': goto yy120; - case '\n': goto yy110; - case '\r': goto yy112; - case ' ': goto yy118; - case ',': goto yy117; - case ':': goto yy114; - case ']': case '}': goto yy115; - default: goto yy122; - } -yy110: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - goto yy136; -yy111: -#line 488 - { int indt_len, nl_count = 0; - SyckLevel *lvl; - char *tok = YYTOKEN; - GOBBLE_UP_YAML_INDENT( indt_len, tok ); - lvl = CURRENT_LEVEL(); - - if ( indt_len <= parentIndent ) - { - RETURN_IMPLICIT(); - } - - while ( YYTOKEN < YYCURSOR ) - { - if ( is_newline( YYTOKEN++ ) ) - nl_count++; - } - if ( nl_count <= 1 ) - { - QUOTECAT(qstr, qcapa, qidx, ' '); - } - else - { - int i; - for ( i = 0; i < nl_count - 1; i++ ) - { - QUOTECAT(qstr, qcapa, qidx, '\n'); - } - } - - goto Plain2; - } -yy112: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy135; - default: goto yy113; - } -yy113: -#line 542 - { QUOTECATS(qstr, qcapa, qidx, YYTOKEN, YYCURSOR - YYTOKEN); - goto Plain2; - } -yy114: yyaccept = 1; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case '\n': goto yy130; - case '\r': goto yy134; - case ' ': goto yy132; - default: goto yy113; - } -yy115: yych = *++YYCURSOR; -yy116: -#line 522 - { if ( plvl->status != syck_lvl_inline ) - { - if ( *(YYCURSOR - 1) == ' ' || is_newline( YYCURSOR - 1 ) ) - { - YYCURSOR--; - } - QUOTECATS(qstr, qcapa, qidx, YYTOKEN, YYCURSOR - YYTOKEN); - goto Plain2; - } - RETURN_IMPLICIT(); - } -yy117: yyaccept = 1; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case '\n': goto yy125; - case '\r': goto yy128; - case ' ': goto yy126; - default: goto yy113; - } -yy118: yych = *++YYCURSOR; - switch(yych){ - case '#': goto yy123; - default: goto yy119; - } -yy119: -#line 540 - { goto Plain3; } -yy120: yych = *++YYCURSOR; -yy121: -#line 538 - { RETURN_IMPLICIT(); } -yy122: yych = *++YYCURSOR; - goto yy113; -yy123: yych = *++YYCURSOR; -yy124: -#line 534 - { eat_comments( parser ); - RETURN_IMPLICIT(); - } -yy125: yych = *++YYCURSOR; - goto yy116; -yy126: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy127: switch(yych){ - case ' ': goto yy126; - default: goto yy116; - } -yy128: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy125; - default: goto yy129; - } -yy129: YYCURSOR = YYMARKER; - switch(yyaccept){ - case 0: goto yy111; - case 1: goto yy113; - } -yy130: yych = *++YYCURSOR; -yy131: -#line 520 - { RETURN_IMPLICIT(); } -yy132: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy133: switch(yych){ - case ' ': goto yy132; - default: goto yy131; - } -yy134: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy130; - default: goto yy129; - } -yy135: yyaccept = 0; - YYMARKER = ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy136: switch(yych){ - case '\n': case ' ': goto yy135; - case '\r': goto yy137; - default: goto yy111; - } -yy137: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - switch(yych){ - case '\n': goto yy135; - default: goto yy129; - } -} -#line 546 - - } - -SingleQuote: - { - int qidx = 0; - int qcapa = 100; - char *qstr = S_ALLOC_N( char, qcapa ); - -SingleQuote2: - YYTOKEN = YYCURSOR; - -{ - YYCTYPE yych; - unsigned int yyaccept; - goto yy138; -yy139: ++YYCURSOR; -yy138: - if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); - yych = *YYCURSOR; - switch(yych){ - case '\000': goto yy146; - case '\n': goto yy140; - case '\r': goto yy142; - case '\'': goto yy144; - default: goto yy147; - } -yy140: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - goto yy151; -yy141: -#line 560 - { int indt_len; - int nl_count = 0; - SyckLevel *lvl; - GOBBLE_UP_YAML_INDENT( indt_len, YYTOKEN ); - lvl = CURRENT_LEVEL(); - - if ( lvl->status != syck_lvl_str ) - { - ADD_LEVEL( indt_len, syck_lvl_str ); - } - else if ( indt_len < lvl->spaces ) - { - /* Error! */ - } - - while ( YYTOKEN < YYCURSOR ) - { - if ( is_newline( YYTOKEN++ ) ) - nl_count++; - } - if ( nl_count <= 1 ) - { - QUOTECAT(qstr, qcapa, qidx, ' '); - } - else - { - int i; - for ( i = 0; i < nl_count - 1; i++ ) - { - QUOTECAT(qstr, qcapa, qidx, '\n'); - } - } - - goto SingleQuote2; - } -yy142: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy150; - default: goto yy143; - } -yy143: -#line 615 - { QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1)); - goto SingleQuote2; - } -yy144: yych = *++YYCURSOR; - switch(yych){ - case '\'': goto yy148; - default: goto yy145; - } -yy145: -#line 600 - { SyckLevel *lvl; - SyckNode *n = syck_alloc_str(); - lvl = CURRENT_LEVEL(); - - if ( lvl->status == syck_lvl_str ) - { - POP_LEVEL(); - } - n->type_id = syck_strndup( "str", 3 ); - n->data.str->ptr = qstr; - n->data.str->len = qidx; - sycklval->nodeData = n; - return YAML_PLAIN; - } -yy146: yych = *++YYCURSOR; - goto yy145; -yy147: yych = *++YYCURSOR; - goto yy143; -yy148: yych = *++YYCURSOR; -yy149: -#line 596 - { QUOTECAT(qstr, qcapa, qidx, '\''); - goto SingleQuote2; - } -yy150: yyaccept = 0; - YYMARKER = ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy151: switch(yych){ - case '\n': case ' ': goto yy150; - case '\r': goto yy152; - default: goto yy141; - } -yy152: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - switch(yych){ - case '\n': goto yy150; - default: goto yy153; - } -yy153: YYCURSOR = YYMARKER; - switch(yyaccept){ - case 0: goto yy141; - } -} -#line 619 - - - } - - -DoubleQuote: - { - int keep_nl = 1; - int qidx = 0; - int qcapa = 100; - char *qstr = S_ALLOC_N( char, qcapa ); - -DoubleQuote2: - YYTOKEN = YYCURSOR; - - -{ - YYCTYPE yych; - unsigned int yyaccept; - goto yy154; -yy155: ++YYCURSOR; -yy154: - if((YYLIMIT - YYCURSOR) < 4) YYFILL(4); - yych = *YYCURSOR; - switch(yych){ - case '\000': goto yy161; - case '\n': goto yy156; - case '\r': goto yy158; - case '"': goto yy163; - case '\\': goto yy160; - default: goto yy164; - } -yy156: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - goto yy178; -yy157: -#line 637 - { int indt_len; - int nl_count = 0; - SyckLevel *lvl; - GOBBLE_UP_YAML_INDENT( indt_len, YYTOKEN ); - lvl = CURRENT_LEVEL(); - - if ( lvl->status != syck_lvl_str ) - { - ADD_LEVEL( indt_len, syck_lvl_str ); - } - else if ( indt_len < lvl->spaces ) - { - /* FIXME */ - } - - if ( keep_nl == 1 ) - { - while ( YYTOKEN < YYCURSOR ) - { - if ( is_newline( YYTOKEN++ ) ) - nl_count++; - } - if ( nl_count <= 1 ) - { - QUOTECAT(qstr, qcapa, qidx, ' '); - } - else - { - int i; - for ( i = 0; i < nl_count - 1; i++ ) - { - QUOTECAT(qstr, qcapa, qidx, '\n'); - } - } - } - - keep_nl = 1; - goto DoubleQuote2; - } -yy158: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy177; - default: goto yy159; - } -yy159: -#line 722 - { QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1)); - goto DoubleQuote2; - } -yy160: yyaccept = 1; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case '\n': goto yy168; - case '\r': goto yy170; - case ' ': goto yy165; - case '"': case '\\': case 'a': - case 'b': case 'e': - case 'f': case 'n': case 'r': case 't': case 'v': goto yy172; - case 'x': goto yy171; - default: goto yy159; - } -yy161: yych = *++YYCURSOR; -yy162: -#line 707 - { SyckLevel *lvl; - SyckNode *n = syck_alloc_str(); - lvl = CURRENT_LEVEL(); - - if ( lvl->status == syck_lvl_str ) - { - POP_LEVEL(); - } - n->type_id = syck_strndup( "str", 3 ); - n->data.str->ptr = qstr; - n->data.str->len = qidx; - sycklval->nodeData = n; - return YAML_PLAIN; - } -yy163: yych = *++YYCURSOR; - goto yy162; -yy164: yych = *++YYCURSOR; - goto yy159; -yy165: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy166: switch(yych){ - case '\n': goto yy168; - case '\r': goto yy170; - case ' ': goto yy165; - default: goto yy167; - } -yy167: YYCURSOR = YYMARKER; - switch(yyaccept){ - case 0: goto yy157; - case 1: goto yy159; - } -yy168: yych = *++YYCURSOR; -yy169: -#line 702 - { keep_nl = 0; - YYCURSOR--; - goto DoubleQuote2; - } -yy170: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy168; - default: goto yy167; - } -yy171: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': goto yy174; - default: goto yy167; - } -yy172: yych = *++YYCURSOR; -yy173: -#line 677 - { char ch = *( YYCURSOR - 1 ); - switch ( ch ) - { - case 'a': ch = 7; break; - case 'b': ch = '\010'; break; - case 'e': ch = '\033'; break; - case 'f': ch = '\014'; break; - case 'n': ch = '\n'; break; - case 'r': ch = '\015'; break; - case 't': ch = '\t'; break; - case 'v': ch = '\013'; break; - } - QUOTECAT(qstr, qcapa, qidx, ch); - goto DoubleQuote2; - } -yy174: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': goto yy175; - default: goto yy167; - } -yy175: yych = *++YYCURSOR; -yy176: -#line 693 - { long ch; - char *chr_text = syck_strndup( YYTOKEN, 4 ); - chr_text[0] = '0'; - ch = strtol( chr_text, NULL, 16 ); - free( chr_text ); - QUOTECAT(qstr, qcapa, qidx, ch); - goto DoubleQuote2; - } -yy177: yyaccept = 0; - YYMARKER = ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy178: switch(yych){ - case '\n': case ' ': goto yy177; - case '\r': goto yy179; - default: goto yy157; - } -yy179: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - switch(yych){ - case '\n': goto yy177; - default: goto yy167; - } -} -#line 726 - - } - -TransferMethod: - { - int qidx = 0; - int qcapa = 100; - char *qstr = S_ALLOC_N( char, qcapa ); - -TransferMethod2: - YYTOKTMP = YYCURSOR; - -{ - YYCTYPE yych; - unsigned int yyaccept; - goto yy180; -yy181: ++YYCURSOR; -yy180: - if((YYLIMIT - YYCURSOR) < 4) YYFILL(4); - yych = *YYCURSOR; - switch(yych){ - case '\000': goto yy182; - case '\n': goto yy183; - case '\r': goto yy186; - case ' ': goto yy185; - case '\\': goto yy188; - default: goto yy189; - } -yy182: YYCURSOR = YYMARKER; - switch(yyaccept){ - case 0: goto yy187; - } -yy183: yych = *++YYCURSOR; -yy184: -#line 740 - { SyckLevel *lvl; - YYCURSOR = YYTOKTMP; - if ( YYCURSOR == YYTOKEN + 1 ) - { - free( qstr ); - return YAML_ITRANSFER; - } - - lvl = CURRENT_LEVEL(); - - /* - * URL Prefixing - */ - if ( *qstr == '^' ) - { - sycklval->name = S_ALLOC_N( char, qidx + strlen( lvl->domain ) ); - sycklval->name[0] = '\0'; - strcat( sycklval->name, lvl->domain ); - strncat( sycklval->name, qstr + 1, qidx - 1 ); - free( qstr ); - } - else - { - char *carat = qstr; - char *qend = qstr + qidx; - while ( (++carat) < qend ) - { - if ( *carat == '^' ) - break; - } - - if ( carat < qend ) - { - free( lvl->domain ); - lvl->domain = syck_strndup( qstr, carat - qstr ); - sycklval->name = S_ALLOC_N( char, ( qend - carat ) + strlen( lvl->domain ) ); - sycklval->name[0] = '\0'; - strcat( sycklval->name, lvl->domain ); - strncat( sycklval->name, carat + 1, ( qend - carat ) - 1 ); - free( qstr ); - } - else - { - sycklval->name = qstr; - } - } - - return YAML_TRANSFER; - } -yy185: yych = *++YYCURSOR; - goto yy196; -yy186: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy194; - default: goto yy187; - } -yy187: -#line 802 - { QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1)); - goto TransferMethod2; - } -yy188: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case 'x': goto yy190; - default: goto yy187; - } -yy189: yych = *++YYCURSOR; - goto yy187; -yy190: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': goto yy191; - default: goto yy182; - } -yy191: yych = *++YYCURSOR; - switch(yych){ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': goto yy192; - default: goto yy182; - } -yy192: yych = *++YYCURSOR; -yy193: -#line 793 - { long ch; - char *chr_text = syck_strndup( YYTOKTMP, 4 ); - chr_text[0] = '0'; - ch = strtol( chr_text, NULL, 16 ); - free( chr_text ); - QUOTECAT(qstr, qcapa, qidx, ch); - goto TransferMethod2; - } -yy194: yych = *++YYCURSOR; - goto yy184; -yy195: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy196: switch(yych){ - case ' ': goto yy195; - default: goto yy184; - } -} -#line 807 - - } - -ScalarBlock: - { - int qidx = 0; - int qcapa = 100; - char *qstr = S_ALLOC_N( char, qcapa ); - int blockType = 0; - int nlDoWhat = 0; - int lastIndent = 0; - int forceIndent = -1; - char *yyt = YYTOKEN; - SyckLevel *lvl = CURRENT_LEVEL(); - int parentIndent; - GET_TRUE_YAML_INDENT(parentIndent); - - switch ( *yyt ) - { - case '|': blockType = BLOCK_LIT; break; - case '>': blockType = BLOCK_FOLD; break; - } - - while ( ++yyt <= YYCURSOR ) - { - if ( *yyt == '-' ) - { - nlDoWhat = NL_CHOMP; - } - else if ( *yyt == '+' ) - { - nlDoWhat = NL_KEEP; - } - else if ( isdigit( *yyt ) ) - { - forceIndent = strtol( yyt, NULL, 10 ) + parentIndent; - } - } - - qstr[0] = '\0'; - YYTOKEN = YYCURSOR; - -ScalarBlock2: - YYTOKEN = YYCURSOR; - -{ - YYCTYPE yych; - unsigned int yyaccept; - goto yy197; -yy198: ++YYCURSOR; -yy197: - if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); - yych = *YYCURSOR; - switch(yych){ - case '\000': goto yy205; - case '\n': goto yy199; - case '\r': goto yy201; - case '#': goto yy203; - default: goto yy207; - } -yy199: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - goto yy209; -yy200: -#line 854 - { char *pacer; - char *tok = YYTOKEN; - int indt_len = 0, nl_count = 0, fold_nl = 0, nl_begin = 0; - GOBBLE_UP_YAML_INDENT( indt_len, tok ); - lvl = CURRENT_LEVEL(); - - if ( indt_len > parentIndent && lvl->status != syck_lvl_block ) - { - int new_spaces = forceIndent > 0 ? forceIndent : indt_len; - ADD_LEVEL( new_spaces, syck_lvl_block ); - lastIndent = indt_len - new_spaces; - nl_begin = 1; - lvl = CURRENT_LEVEL(); - } - else if ( lvl->status != syck_lvl_block ) - { - YYCURSOR = YYTOKEN; - RETURN_YAML_BLOCK(); - } - - /* - * Fold only in the event of two lines being on the leftmost - * indentation. - */ - if ( blockType == BLOCK_FOLD && lastIndent == 0 && ( indt_len - lvl->spaces ) == 0 ) - { - fold_nl = 1; - } - - pacer = YYTOKEN; - while ( pacer < YYCURSOR ) - { - if ( is_newline( pacer++ ) ) - nl_count++; - } - - if ( fold_nl == 1 || nl_begin == 1 ) - { - nl_count--; - } - - if ( nl_count < 1 && nl_begin == 0 ) - { - QUOTECAT(qstr, qcapa, qidx, ' '); - } - else - { - int i; - for ( i = 0; i < nl_count; i++ ) - { - QUOTECAT(qstr, qcapa, qidx, '\n'); - } - } - - lastIndent = indt_len - lvl->spaces; - YYCURSOR -= lastIndent; - - if ( indt_len < lvl->spaces ) - { - POP_LEVEL(); - YYCURSOR = YYTOKEN; - RETURN_YAML_BLOCK(); - } - goto ScalarBlock2; - } -yy201: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy208; - default: goto yy202; - } -yy202: -#line 940 - { QUOTECAT(qstr, qcapa, qidx, *YYTOKEN); - goto ScalarBlock2; - } -yy203: yych = *++YYCURSOR; -yy204: -#line 921 - { lvl = CURRENT_LEVEL(); - if ( lvl->status != syck_lvl_block ) - { - eat_comments( parser ); - YYTOKEN = YYCURSOR; - } - else - { - QUOTECAT(qstr, qcapa, qidx, *YYTOKEN); - } - goto ScalarBlock2; - } -yy205: yych = *++YYCURSOR; -yy206: -#line 935 - { YYCURSOR--; - POP_LEVEL(); - RETURN_YAML_BLOCK(); - } -yy207: yych = *++YYCURSOR; - goto yy202; -yy208: yyaccept = 0; - YYMARKER = ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy209: switch(yych){ - case '\n': case ' ': goto yy208; - case '\r': goto yy210; - default: goto yy200; - } -yy210: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - switch(yych){ - case '\n': goto yy208; - default: goto yy211; - } -yy211: YYCURSOR = YYMARKER; - switch(yyaccept){ - case 0: goto yy200; - } -} -#line 945 - - } - - return 0; - -} - -void -eat_comments( SyckParser *parser ) -{ -Comment: - { - YYTOKEN = YYCURSOR; - -{ - YYCTYPE yych; - unsigned int yyaccept; - goto yy212; -yy213: ++YYCURSOR; -yy212: - if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); - yych = *YYCURSOR; - switch(yych){ - case '\000': goto yy214; - case '\n': goto yy216; - case '\r': goto yy217; - default: goto yy219; - } -yy214: yych = *++YYCURSOR; -yy215: -#line 961 - { YYCURSOR = YYTOKEN; - return; - } -yy216: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - goto yy221; -yy217: yych = *++YYCURSOR; - switch(yych){ - case '\n': goto yy220; - default: goto yy218; - } -yy218: -#line 965 - { goto Comment; - } -yy219: yych = *++YYCURSOR; - goto yy218; -yy220: yyaccept = 0; - YYMARKER = ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy221: switch(yych){ - case '\n': goto yy220; - case '\r': goto yy222; - default: goto yy215; - } -yy222: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - switch(yych){ - case '\n': goto yy220; - default: goto yy223; - } -yy223: YYCURSOR = YYMARKER; - switch(yyaccept){ - case 0: goto yy215; - } -} -#line 968 - - - } - -} - -int -is_newline( char *ptr ) -{ - if ( *ptr == '\n' ) - return 1; - - if ( *ptr == '\r' && *( ptr + 1 ) == '\n' ) - return 1; - - return 0; -} - -int -syckwrap() -{ - return 1; -} - -void -syckerror( char *msg ) -{ - if ( syck_parser_ptr->error_handler == NULL ) - syck_parser_ptr->error_handler = syck_default_error_handler; - - syck_parser_ptr->root = syck_parser_ptr->root_on_error; - (syck_parser_ptr->error_handler)(syck_parser_ptr, msg); -} - diff --git a/ext/syck/yaml2byte.c b/ext/syck/yaml2byte.c deleted file mode 100644 index d55d1083b4..0000000000 --- a/ext/syck/yaml2byte.c +++ /dev/null @@ -1,251 +0,0 @@ -/* - * ybext.c - * - * $Author$ - * $Date$ - * - * Copyright (C) 2003 why the lucky stiff, clark evans - * - * WARNING WARNING WARNING --- THIS IS *NOT JUST* PLAYING - * ANYMORE! -- WHY HAS EMBRACED THIS AS THE REAL THING! - */ -#include <syck.h> -#include <assert.h> -#define YAMLBYTE_UTF8 -#include "yamlbyte.h" -#include "ruby.h" - -#include <stdio.h> -#define TRACE0(a) \ - do { printf(a); printf("\n"); fflush(stdout); } while(0) -#define TRACE1(a,b) \ - do { printf(a,b); printf("\n"); fflush(stdout); } while(0) -#define TRACE2(a,b,c) \ - do { printf(a,b,c); printf("\n"); fflush(stdout); } while(0) -#define TRACE3(a,b,c,d) \ - do { printf(a,b,c,d); printf("\n"); fflush(stdout); } while(0) - -/* Reinvent the wheel... */ -#define CHUNKSIZE 64 -#define HASH ((long)0xCAFECAFE) -typedef struct { - long hash; - char *buffer; - long length; - long remaining; - int printed; -} bytestring_t; -bytestring_t *bytestring_alloc() { - bytestring_t *ret; - /*TRACE0("bytestring_alloc()");*/ - ret = S_ALLOC(bytestring_t); - ret->hash = HASH; - ret->length = CHUNKSIZE; - ret->remaining = ret->length; - ret->buffer = S_ALLOC_N(char, ret->length + 1 ); - ret->buffer[0] = 0; - ret->printed = 0; - return ret; -} -void bytestring_append(bytestring_t *str, char code, - char *start, char *finish) -{ - long grow; - long length = 2; /* CODE + LF */ - char *curr; - assert(str && HASH == str->hash); - /*TRACE0("bytestring_append()");*/ - if(start) { - if(!finish) - finish = start + strlen(start); - length += (finish-start); - } - if(length > str->remaining) { - grow = (length - str->remaining) + CHUNKSIZE; - str->remaining += grow; - str->length += grow; - str->buffer = S_REALLOC_N( str->buffer, char, str->length + 1 ); - assert(str->buffer); - } - curr = str->buffer + (str->length - str->remaining); - *curr = code; - curr += 1; - if(start) - while(start < finish) - *curr ++ = *start ++; - *curr = '\n'; - curr += 1; - *curr = 0; - str->remaining = str->remaining - length; - assert( (str->buffer + str->length) - str->remaining ); -} -void bytestring_extend(bytestring_t *str, bytestring_t *ext) -{ - char *from; - char *curr; - char *stop; - long grow; - long length; - assert(str && HASH == str->hash); - assert(ext && HASH == ext->hash); - if(ext->printed) { - assert(ext->buffer[0] ==YAMLBYTE_ANCHOR); - curr = ext->buffer; - while( '\n' != *curr) - curr++; - bytestring_append(str, YAMLBYTE_ALIAS, ext->buffer + 1, curr); - } else { - ext->printed = 1; - length = (ext->length - ext->remaining); - if(length > str->remaining) { - grow = (length - str->remaining) + CHUNKSIZE; - str->remaining += grow; - str->length += grow; - str->buffer = S_REALLOC_N( str->buffer, char, str->length + 1 ); - } - curr = str->buffer + (str->length - str->remaining); - from = ext->buffer; - stop = ext->buffer + length; - while( from < stop ) - *curr ++ = *from ++; - *curr = 0; - str->remaining = str->remaining - length; - assert( (str->buffer + str->length) - str->remaining ); - } -} - -/* convert SyckNode into yamlbyte_buffer_t objects */ -SYMID -syck_yaml2byte_handler(p, n) - SyckParser *p; - SyckNode *n; -{ - SYMID oid; - long i; - char ch; - char nextcode; - char *start; - char *current; - char *finish; - bytestring_t *val = NULL; - bytestring_t *sav = NULL; - /*TRACE0("syck_yaml2byte_handler()");*/ - val = bytestring_alloc(); - if(n->anchor) bytestring_append(val,YAMLBYTE_ANCHOR, n->anchor, NULL); - if ( n->type_id ) - { - if ( p->taguri_expansion ) - { - bytestring_append(val,YAMLBYTE_TRANSFER, n->type_id, NULL); - } - else - { - char *type_tag = S_ALLOC_N( char, strlen( n->type_id ) + 1 ); - type_tag[0] = '\0'; - strcat( type_tag, "!" ); - strcat( type_tag, n->type_id ); - bytestring_append( val, YAMLBYTE_TRANSFER, type_tag, NULL); - } - } - switch (n->kind) - { - case syck_str_kind: - nextcode = YAMLBYTE_SCALAR; - start = n->data.str->ptr; - finish = start + n->data.str->len - 1; - current = start; - /*TRACE2("SCALAR: %s %d", start, n->data.str->len); */ - while(1) { - ch = *current; - if('\n' == ch || 0 == ch || current > finish) { - if(current >= start) { - bytestring_append(val, nextcode, start, current); - nextcode = YAMLBYTE_CONTINUE; - } - start = current + 1; - if(current > finish) - { - break; - } - else if('\n' == ch ) - { - bytestring_append(val,YAMLBYTE_NEWLINE,NULL,NULL); - } - else if(0 == ch) - { - bytestring_append(val,YAMLBYTE_NULLCHAR,NULL,NULL); - } - else - { - assert("oops"); - } - } - current += 1; - } - break; - case syck_seq_kind: - bytestring_append(val,YAMLBYTE_SEQUENCE,NULL,NULL); - for ( i = 0; i < n->data.list->idx; i++ ) - { - oid = syck_seq_read( n, i ); - syck_lookup_sym( p, oid, (char **)&sav ); - bytestring_extend(val, sav); - } - bytestring_append(val,YAMLBYTE_END_BRANCH,NULL,NULL); - break; - case syck_map_kind: - bytestring_append(val,YAMLBYTE_MAPPING,NULL,NULL); - for ( i = 0; i < n->data.pairs->idx; i++ ) - { - oid = syck_map_read( n, map_key, i ); - syck_lookup_sym( p, oid, (char **)&sav ); - bytestring_extend(val, sav); - oid = syck_map_read( n, map_value, i ); - syck_lookup_sym( p, oid, (char **)&sav ); - bytestring_extend(val, sav); - } - bytestring_append(val,YAMLBYTE_END_BRANCH,NULL,NULL); - break; - } - oid = syck_add_sym( p, (char *) val ); - /*TRACE1("Saving: %s", val->buffer );*/ - return oid; -} - -char * -syck_yaml2byte(char *yamlstr) -{ - SYMID oid; - char *ret; - bytestring_t *sav; - - SyckParser *parser = syck_new_parser(); - syck_parser_str_auto( parser, yamlstr, NULL ); - syck_parser_handler( parser, syck_yaml2byte_handler ); - syck_parser_error_handler( parser, NULL ); - syck_parser_implicit_typing( parser, 1 ); - syck_parser_taguri_expansion( parser, 1 ); - oid = syck_parse( parser ); - syck_lookup_sym( parser, oid, (char **)&sav ); - - ret = S_ALLOC_N( char, strlen( sav->buffer ) + 3 ); - ret[0] = '\0'; - strcat( ret, "D\n" ); - strcat( ret, sav->buffer ); - - syck_free_parser( parser ); - return ret; -} - -#ifdef TEST_YBEXT -#include <stdio.h> -int main() { - char *yaml = "test: 1\nand: \"with new\\nline\\n\"\nalso: &3 three\nmore: *3"; - printf("--- # YAML \n"); - printf(yaml); - printf("\n...\n"); - printf(syck_yaml2byte(yaml)); - return 0; -} -#endif - diff --git a/ext/syck/yamlbyte.h b/ext/syck/yamlbyte.h deleted file mode 100644 index 0fe4e7b576..0000000000 --- a/ext/syck/yamlbyte.h +++ /dev/null @@ -1,170 +0,0 @@ -/* yamlbyte.h - * - * The YAML bytecode "C" interface header file. See the YAML bytecode - * reference for bytecode sequence rules and for the meaning of each - * bytecode. - */ - -#ifndef YAMLBYTE_H -#define YAMLBYTE_H -#include <stddef.h> - -/* define what a character is */ -typedef unsigned char yamlbyte_utf8_t; -typedef unsigned short yamlbyte_utf16_t; -#ifdef YAMLBYTE_UTF8 - #ifdef YAMLBYTE_UTF16 - #error Must only define YAMLBYTE_UTF8 or YAMLBYTE_UTF16 - #endif - typedef yamlbyte_utf8_t yamlbyte_char_t; -#else - #ifdef YAMLBYTE_UTF16 - typedef yamlbyte_utf16_t yamlbyte_char_t; - #else - #error Must define YAMLBYTE_UTF8 or YAMLBYTE_UTF16 - #endif -#endif - -/* specify list of bytecodes */ -#define YAMLBYTE_FINISH ((yamlbyte_char_t) 0) -#define YAMLBYTE_DOCUMENT ((yamlbyte_char_t)'D') -#define YAMLBYTE_DIRECTIVE ((yamlbyte_char_t)'V') -#define YAMLBYTE_PAUSE ((yamlbyte_char_t)'P') -#define YAMLBYTE_MAPPING ((yamlbyte_char_t)'M') -#define YAMLBYTE_SEQUENCE ((yamlbyte_char_t)'Q') -#define YAMLBYTE_END_BRANCH ((yamlbyte_char_t)'E') -#define YAMLBYTE_SCALAR ((yamlbyte_char_t)'S') -#define YAMLBYTE_CONTINUE ((yamlbyte_char_t)'C') -#define YAMLBYTE_NEWLINE ((yamlbyte_char_t)'N') -#define YAMLBYTE_NULLCHAR ((yamlbyte_char_t)'Z') -#define YAMLBYTE_ANCHOR ((yamlbyte_char_t)'A') -#define YAMLBYTE_ALIAS ((yamlbyte_char_t)'R') -#define YAMLBYTE_TRANSFER ((yamlbyte_char_t)'T') -/* formatting bytecodes */ -#define YAMLBYTE_COMMENT ((yamlbyte_char_t)'c') -#define YAMLBYTE_INDENT ((yamlbyte_char_t)'i') -#define YAMLBYTE_STYLE ((yamlbyte_char_t)'s') -/* other bytecodes */ -#define YAMLBYTE_LINE_NUMBER ((yamlbyte_char_t)'#') -#define YAMLBYTE_WHOLE_SCALAR ((yamlbyte_char_t)'<') -#define YAMLBYTE_NOTICE ((yamlbyte_char_t)'!') -#define YAMLBYTE_SPAN ((yamlbyte_char_t)')') -#define YAMLBYTE_ALLOC ((yamlbyte_char_t)'@') - -/* second level style bytecodes, ie "s>" */ -#define YAMLBYTE_FLOW ((yamlbyte_char_t)'>') -#define YAMLBYTE_LITERAL ((yamlbyte_char_t)'|') -#define YAMLBYTE_BLOCK ((yamlbyte_char_t)'b') -#define YAMLBYTE_PLAIN ((yamlbyte_char_t)'p') -#define YAMLBYTE_INLINE_MAPPING ((yamlbyte_char_t)'{') -#define YAMLBYTE_INLINE_SEQUENCE ((yamlbyte_char_t)'[') -#define YAMLBYTE_SINGLE_QUOTED ((yamlbyte_char_t)39) -#define YAMLBYTE_DOUBLE_QUOTED ((yamlbyte_char_t)'"') - -/* - * The "C" API has two variants, one based on instructions, - * with events delivered via pointers; and the other one - * is character based where one or more instructions are - * serialized into a buffer. - * - * Note: In the instruction based API, WHOLE_SCALAR does - * not have the '<here' marshalling stuff. - */ - -typedef void * yamlbyte_consumer_t; -typedef void * yamlbyte_producer_t; - -/* push and pull APIs need a way to communicate results */ -typedef enum { - YAMLBYTE_OK = 0, /* proceed */ - YAMLBYTE_E_MEMORY = 'M', /* could not allocate memory */ - YAMLBYTE_E_READ = 'R', /* input stream read error */ - YAMLBYTE_E_WRITE = 'W', /* output stream write error */ - YAMLBYTE_E_OTHER = '?', /* some other error condition */ - YAMLBYTE_E_PARSE = 'P', /* parse error, check bytecodes */ -} yamlbyte_result_t; - -typedef const yamlbyte_char_t *yamlbyte_buff_t; - -/* - * The "Instruction" API - */ - -typedef struct yaml_instruction { - yamlbyte_char_t bytecode; - yamlbyte_buff_t start; - yamlbyte_buff_t finish; /* open range, *finish is _not_ part */ -} *yamlbyte_inst_t; - -/* producer pushes the instruction with one bytecode event to the - * consumer; if the consumer's result is not YAMLBYTE_OK, then - * the producer should stop */ -typedef - yamlbyte_result_t - (*yamlbyte_push_t)( - yamlbyte_consumer_t self, - yamlbyte_inst_t inst - ); - -/* consumer pulls a bytecode instruction from the producer; in this - * case the instruction (and is buffer) are owned by the producer and - * will remain valid till the pull function is called once again; - * if the instruction is NULL, then there are no more results; and - * it is important to call the pull function till it returns NULL so - * that the producer can clean up its memory allocations */ -typedef - yamlbyte_result_t - (*yamlbyte_pull_t)( - yamlbyte_producer_t self, - yamlbyte_inst_t *inst /* to be filled in by the producer */ - ); - -/* - * Buffer based API - */ - -/* producer pushes a null terminated buffer filled with one or more - * bytecode events to the consumer; if the consumer's result is not - * YAMLBYTE_OK, then the producer should stop */ -typedef - yamlbyte_result_t - (*yamlbyte_pushbuff_t)( - yamlbyte_consumer_t self, - yamlbyte_buff_t buff - ); - -/* consumer pulls bytecode events from the producer; in this case - * the buffer is owned by the producer, and will remain valid till - * the pull function is called once again; if the buffer pointer - * is set to NULL, then there are no more results; it is important - * to call the pull function till it returns NULL so that the - * producer can clean up its memory allocations */ -typedef - yamlbyte_result_t - (*yamlbyte_pullbuff_t)( - yamlbyte_producer_t self, - yamlbyte_buff_t *buff /* to be filled in by the producer */ - ); - -/* convert a pull interface to a push interface; the reverse process - * requires threads and thus is language dependent */ -#define YAMLBYTE_PULL2PUSH(pull,producer,push,consumer,result) \ - do { \ - yamlbyte_pullbuff_t _pull = (pull); \ - yamlbyte_pushbuff_t _push = (push); \ - yamlbyte_result_t _result = YAMLBYTE_OK; \ - yamlbyte_producer_t _producer = (producer); \ - yamlbyte_consumer_t _consumer = (consumer); \ - while(1) { \ - yamlbyte_buff_t buff = NULL; \ - _result = _pull(_producer,&buff); \ - if(YAMLBYTE_OK != result || NULL == buff) \ - break; \ - _result = _push(_consumer,buff); \ - if(YAMLBYTE_OK != result) \ - break; \ - } \ - (result) = _result; \ - } while(0) - -#endif |
