diff options
author | why <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-08-21 21:16:58 +0000 |
---|---|---|
committer | why <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-08-21 21:16:58 +0000 |
commit | b2da7a3f81a5aacb3a2c725aad2b7397ea721cd5 (patch) | |
tree | af728c81dbd8c7d197b9965109d6f0802a893e15 /ext | |
parent | 563f5d369266b5a13d3fa7ea8fd0c17de052ddd2 (diff) | |
download | ruby-b2da7a3f81a5aacb3a2c725aad2b7397ea721cd5.tar.gz ruby-b2da7a3f81a5aacb3a2c725aad2b7397ea721cd5.tar.xz ruby-b2da7a3f81a5aacb3a2c725aad2b7397ea721cd5.zip |
* ext/syck/rubyext.c: refactoring of the transfer method
dispatch. added yaml_org_handler for faster dispatch of
transfers to base types.
* lib/yaml/rubytypes.rb: removed handling of builtins from
Ruby library.
* ext/syck/token.c: quoted and block scalars are now implicit !str
* ext/syck/implicit.c: empty string detected as !null.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@4423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/syck/implicit.c | 1051 | ||||
-rw-r--r-- | ext/syck/rubyext.c | 219 | ||||
-rw-r--r-- | ext/syck/token.c | 125 |
3 files changed, 754 insertions, 641 deletions
diff --git a/ext/syck/implicit.c b/ext/syck/implicit.c index 4ab61c553..d872c83fd 100644 --- a/ext/syck/implicit.c +++ b/ext/syck/implicit.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.5 on Mon Jul 28 11:21:48 2003 */ +/* Generated by re2c 0.5 on Thu Aug 21 14:06:39 2003 */ #line 1 "implicit.re" /* * implicit.re @@ -59,11 +59,11 @@ yy0: if((YYLIMIT - YYCURSOR) < 26) YYFILL(26); yych = *YYCURSOR; switch(yych){ - case '\000': goto yy2; - case '+': goto yy15; - case '-': goto yy16; - case '.': goto yy19; - case '0': goto yy17; + case '\000': goto yy6; + case '+': goto yy16; + case '-': goto yy17; + case '.': goto yy20; + case '0': goto yy18; case '1': case '2': case '3': @@ -72,105 +72,105 @@ yy0: case '6': case '7': case '8': - case '9': goto yy18; - case '<': goto yy21; - case '=': goto yy20; - case 'F': goto yy14; - case 'N': goto yy6; - case 'O': goto yy12; - case 'T': goto yy8; - case 'Y': goto yy10; - case 'f': goto yy13; - case 'n': goto yy5; - case 'o': goto yy11; - case 't': goto yy7; - case 'y': goto yy9; - case '~': goto yy3; - default: goto yy22; + 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: YYCURSOR = YYMARKER; - switch(yyaccept){ - case 0: goto yy4; - } -yy3: yych = *++YYCURSOR; - if(yych <= '\000') goto yy188; -yy4: +yy2: yych = *++YYCURSOR; + if(yych <= '\000') goto yy6; +yy3: #line 116 { return "str"; } -yy5: yyaccept = 0; +yy4: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ - case 'o': goto yy161; + case 'o': goto yy163; case 'u': goto yy191; - default: goto yy4; - } -yy6: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - switch(yych){ - case 'O': case 'o': goto yy161; - case 'U': goto yy184; - case 'u': goto yy185; - default: goto yy4; + default: goto yy3; } -yy7: yyaccept = 0; +yy5: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ - case 'r': goto yy182; - default: goto yy4; + 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 yy178; - case 'r': goto yy179; - default: goto yy4; + case 'r': goto yy184; + default: goto yy3; } yy9: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ - case 'e': goto yy177; - default: goto yy4; + case 'R': goto yy180; + case 'r': goto yy181; + default: goto yy3; } yy10: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ - case 'E': goto yy175; - case 'e': goto yy176; - default: goto yy4; + case 'e': goto yy179; + default: goto yy3; } yy11: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ - case 'f': goto yy174; - case 'n': goto yy171; - default: goto yy4; + case 'E': goto yy177; + case 'e': goto yy178; + default: goto yy3; } yy12: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ - case 'F': goto yy169; - case 'N': case 'n': goto yy171; - case 'f': goto yy170; - default: goto yy4; + case 'f': goto yy176; + case 'n': goto yy173; + default: goto yy3; } yy13: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ - case 'a': goto yy166; - default: goto yy4; + 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 yy157; - case 'a': goto yy158; - default: goto yy4; + case 'a': goto yy168; + default: goto yy3; } yy15: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ - case '.': goto yy156; - case '0': goto yy147; + 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': @@ -179,14 +179,14 @@ yy15: yyaccept = 0; case '6': case '7': case '8': - case '9': goto yy45; - default: goto yy4; + case '9': goto yy47; + default: goto yy3; } -yy16: yyaccept = 0; +yy17: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ - case '.': goto yy146; - case '0': goto yy147; + case '.': goto yy148; + case '0': goto yy149; case '1': case '2': case '3': @@ -195,15 +195,15 @@ yy16: yyaccept = 0; case '6': case '7': case '8': - case '9': goto yy45; - default: goto yy4; + case '9': goto yy47; + default: goto yy3; } -yy17: yyaccept = 0; +yy18: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ - case '\000': goto yy49; - case ',': goto yy131; - case '.': goto yy47; + case '\000': goto yy51; + case ',': goto yy133; + case '.': goto yy49; case '0': case '1': case '2': @@ -211,18 +211,18 @@ yy17: yyaccept = 0; case '4': case '5': case '6': - case '7': goto yy129; + case '7': goto yy131; case '8': - case '9': goto yy130; - case 'x': goto yy133; - default: goto yy4; + case '9': goto yy132; + case 'x': goto yy135; + default: goto yy3; } -yy18: yyaccept = 0; +yy19: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ - case '\000': goto yy49; - case ',': goto yy45; - case '.': goto yy47; + case '\000': goto yy51; + case ',': goto yy47; + case '.': goto yy49; case '0': case '1': case '2': @@ -232,104 +232,108 @@ yy18: yyaccept = 0; case '6': case '7': case '8': - case '9': goto yy44; - default: goto yy4; + case '9': goto yy46; + default: goto yy3; } -yy19: yyaccept = 0; +yy20: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ - case 'I': goto yy31; - case 'N': goto yy29; - case 'i': goto yy30; - case 'n': goto yy28; - default: goto yy4; + case 'I': goto yy33; + case 'N': goto yy31; + case 'i': goto yy32; + case 'n': goto yy30; + default: goto yy3; } -yy20: yych = *++YYCURSOR; - if(yych <= '\000') goto yy26; - goto yy4; -yy21: yyaccept = 0; +yy21: yych = *++YYCURSOR; + if(yych <= '\000') goto yy28; + goto yy3; +yy22: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ - case '<': goto yy23; - default: goto yy4; + case '<': goto yy24; + default: goto yy3; } -yy22: yych = *++YYCURSOR; - goto yy4; yy23: yych = *++YYCURSOR; - if(yych >= '\001') goto yy2; + goto yy3; yy24: yych = *++YYCURSOR; -yy25: -#line 114 - { return "merge"; } + 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"; } -yy28: yych = *++YYCURSOR; - switch(yych){ - case 'a': goto yy43; - default: goto yy2; - } -yy29: yych = *++YYCURSOR; - switch(yych){ - case 'A': goto yy38; - case 'a': goto yy39; - default: goto yy2; - } yy30: yych = *++YYCURSOR; switch(yych){ - case 'n': goto yy37; - default: goto yy2; + case 'a': goto yy45; + default: goto yy25; } yy31: yych = *++YYCURSOR; switch(yych){ - case 'N': goto yy32; - case 'n': goto yy33; - default: goto yy2; + case 'A': goto yy40; + case 'a': goto yy41; + default: goto yy25; } yy32: yych = *++YYCURSOR; switch(yych){ - case 'F': goto yy34; - default: goto yy2; + case 'n': goto yy39; + default: goto yy25; } yy33: yych = *++YYCURSOR; switch(yych){ - case 'f': goto yy34; - default: goto yy2; + case 'N': goto yy34; + case 'n': goto yy35; + default: goto yy25; } yy34: yych = *++YYCURSOR; - if(yych >= '\001') goto yy2; -yy35: yych = *++YYCURSOR; -yy36: -#line 98 - { return "float#inf"; } -yy37: yych = *++YYCURSOR; switch(yych){ - case 'f': goto yy34; - default: goto yy2; + case 'F': goto yy36; + default: goto yy25; } -yy38: yych = *++YYCURSOR; +yy35: yych = *++YYCURSOR; switch(yych){ - case 'N': goto yy40; - default: goto yy2; + 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 'N': goto yy40; - default: goto yy2; + case 'f': goto yy36; + default: goto yy25; } yy40: yych = *++YYCURSOR; - if(yych >= '\001') goto yy2; + switch(yych){ + case 'N': goto yy42; + default: goto yy25; + } yy41: yych = *++YYCURSOR; -yy42: + 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"; } -yy43: yych = *++YYCURSOR; +yy45: yych = *++YYCURSOR; switch(yych){ - case 'n': goto yy40; - default: goto yy2; + case 'n': goto yy42; + default: goto yy25; } -yy44: yych = *++YYCURSOR; +yy46: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -340,14 +344,14 @@ yy44: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy63; - default: goto yy46; + case '9': goto yy65; + default: goto yy48; } -yy45: ++YYCURSOR; +yy47: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy46: switch(yych){ - case '\000': goto yy49; +yy48: switch(yych){ + case '\000': goto yy51; case ',': case '0': case '1': case '2': @@ -357,17 +361,17 @@ yy46: switch(yych){ case '6': case '7': case '8': - case '9': goto yy45; - case '.': goto yy47; - default: goto yy2; + case '9': goto yy47; + case '.': goto yy49; + default: goto yy25; } -yy47: ++YYCURSOR; +yy49: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy48: switch(yych){ - case '\000': goto yy53; - case ',': goto yy51; - case '.': goto yy55; +yy50: switch(yych){ + case '\000': goto yy55; + case ',': goto yy53; + case '.': goto yy57; case '0': case '1': case '2': @@ -377,19 +381,19 @@ yy48: switch(yych){ case '6': case '7': case '8': - case '9': goto yy47; - case 'E': case 'e': goto yy57; - default: goto yy2; + case '9': goto yy49; + case 'E': case 'e': goto yy59; + default: goto yy25; } -yy49: yych = *++YYCURSOR; -yy50: +yy51: yych = *++YYCURSOR; +yy52: #line 92 { return "int"; } -yy51: ++YYCURSOR; +yy53: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy52: switch(yych){ - case '\000': goto yy53; +yy54: switch(yych){ + case '\000': goto yy55; case ',': case '0': case '1': case '2': @@ -399,17 +403,17 @@ yy52: switch(yych){ case '6': case '7': case '8': - case '9': goto yy51; - default: goto yy2; + case '9': goto yy53; + default: goto yy25; } -yy53: yych = *++YYCURSOR; -yy54: +yy55: yych = *++YYCURSOR; +yy56: #line 94 { return "float#fix"; } -yy55: ++YYCURSOR; +yy57: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy56: switch(yych){ +yy58: switch(yych){ case '.': case '0': case '1': case '2': @@ -419,23 +423,23 @@ yy56: switch(yych){ case '6': case '7': case '8': - case '9': goto yy55; - case 'E': case 'e': goto yy57; - default: goto yy2; + case '9': goto yy57; + case 'E': case 'e': goto yy59; + default: goto yy25; } -yy57: yych = *++YYCURSOR; +yy59: yych = *++YYCURSOR; switch(yych){ - case '+': case '-': goto yy58; - default: goto yy2; + case '+': case '-': goto yy60; + default: goto yy25; } -yy58: yych = *++YYCURSOR; - if(yych <= '\000') goto yy2; - goto yy60; -yy59: ++YYCURSOR; +yy60: yych = *++YYCURSOR; + if(yych <= '\000') goto yy25; + goto yy62; +yy61: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy60: switch(yych){ - case '\000': goto yy61; +yy62: switch(yych){ + case '\000': goto yy63; case '0': case '1': case '2': @@ -445,14 +449,14 @@ yy60: switch(yych){ case '6': case '7': case '8': - case '9': goto yy59; - default: goto yy2; + case '9': goto yy61; + default: goto yy25; } -yy61: yych = *++YYCURSOR; -yy62: +yy63: yych = *++YYCURSOR; +yy64: #line 96 { return "float#exp"; } -yy63: yych = *++YYCURSOR; +yy65: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -463,15 +467,15 @@ yy63: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy64; - default: goto yy46; + case '9': goto yy66; + default: goto yy48; } -yy64: yych = *++YYCURSOR; +yy66: yych = *++YYCURSOR; switch(yych){ - case '-': goto yy65; - default: goto yy46; + case '-': goto yy67; + default: goto yy48; } -yy65: yych = *++YYCURSOR; +yy67: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -482,10 +486,10 @@ yy65: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy66; - default: goto yy2; + case '9': goto yy68; + default: goto yy25; } -yy66: yych = *++YYCURSOR; +yy68: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -496,15 +500,15 @@ yy66: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy67; - default: goto yy2; + case '9': goto yy69; + default: goto yy25; } -yy67: yych = *++YYCURSOR; +yy69: yych = *++YYCURSOR; switch(yych){ - case '-': goto yy68; - default: goto yy2; + case '-': goto yy70; + default: goto yy25; } -yy68: yych = *++YYCURSOR; +yy70: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -515,10 +519,10 @@ yy68: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy69; - default: goto yy2; + case '9': goto yy71; + default: goto yy25; } -yy69: yych = *++YYCURSOR; +yy71: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -529,12 +533,12 @@ yy69: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy70; - default: goto yy2; + case '9': goto yy72; + default: goto yy25; } -yy70: yych = *++YYCURSOR; +yy72: yych = *++YYCURSOR; switch(yych){ - case '\000': goto yy71; + case '\000': goto yy73; case '0': case '1': case '2': @@ -544,16 +548,16 @@ yy70: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy2; - case 'T': goto yy73; - case 't': goto yy74; - default: goto yy76; + case '9': goto yy25; + case 'T': goto yy75; + case 't': goto yy76; + default: goto yy78; } -yy71: yych = *++YYCURSOR; -yy72: +yy73: yych = *++YYCURSOR; +yy74: #line 104 { return "timestamp#ymd"; } -yy73: yych = *++YYCURSOR; +yy75: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -564,10 +568,10 @@ yy73: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy115; - default: goto yy2; + case '9': goto yy117; + default: goto yy25; } -yy74: yych = *++YYCURSOR; +yy76: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -578,14 +582,14 @@ yy74: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy97; - default: goto yy2; + case '9': goto yy99; + default: goto yy25; } -yy75: ++YYCURSOR; +yy77: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy76: switch(yych){ - case '\t': case ' ': goto yy75; +yy78: switch(yych){ + case '\t': case ' ': goto yy77; case '0': case '1': case '2': @@ -595,10 +599,10 @@ yy76: switch(yych){ case '6': case '7': case '8': - case '9': goto yy77; - default: goto yy2; + case '9': goto yy79; + default: goto yy25; } -yy77: yych = *++YYCURSOR; +yy79: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -609,15 +613,15 @@ yy77: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy78; - default: goto yy2; + case '9': goto yy80; + default: goto yy25; } -yy78: yych = *++YYCURSOR; +yy80: yych = *++YYCURSOR; switch(yych){ - case ':': goto yy79; - default: goto yy2; + case ':': goto yy81; + default: goto yy25; } -yy79: yych = *++YYCURSOR; +yy81: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -628,10 +632,10 @@ yy79: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy80; - default: goto yy2; + case '9': goto yy82; + default: goto yy25; } -yy80: yych = *++YYCURSOR; +yy82: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -642,15 +646,15 @@ yy80: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy81; - default: goto yy2; + case '9': goto yy83; + default: goto yy25; } -yy81: yych = *++YYCURSOR; +yy83: yych = *++YYCURSOR; switch(yych){ - case ':': goto yy82; - default: goto yy2; + case ':': goto yy84; + default: goto yy25; } -yy82: yych = *++YYCURSOR; +yy84: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -661,10 +665,10 @@ yy82: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy83; - default: goto yy2; + case '9': goto yy85; + default: goto yy25; } -yy83: yych = *++YYCURSOR; +yy85: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -675,20 +679,20 @@ yy83: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy84; - default: goto yy2; + case '9': goto yy86; + default: goto yy25; } -yy84: yych = *++YYCURSOR; +yy86: yych = *++YYCURSOR; switch(yych){ - case '\t': case ' ': goto yy87; - case '.': goto yy85; - default: goto yy2; + case '\t': case ' ': goto yy89; + case '.': goto yy87; + default: goto yy25; } -yy85: ++YYCURSOR; +yy87: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy86: switch(yych){ - case '\t': case ' ': goto yy87; +yy88: switch(yych){ + case '\t': case ' ': goto yy89; case '0': case '1': case '2': @@ -698,22 +702,22 @@ yy86: switch(yych){ case '6': case '7': case '8': - case '9': goto yy85; - default: goto yy2; + case '9': goto yy87; + default: goto yy25; } -yy87: ++YYCURSOR; +yy89: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy88: switch(yych){ - case '\t': case ' ': goto yy87; - case '+': case '-': goto yy90; - case 'Z': goto yy89; - default: goto yy2; +yy90: switch(yych){ + case '\t': case ' ': goto yy89; + case '+': case '-': goto yy92; + case 'Z': goto yy91; + default: goto yy25; } -yy89: yych = *++YYCURSOR; - if(yych <= '\000') goto yy94; - goto yy2; -yy90: yych = *++YYCURSOR; +yy91: yych = *++YYCURSOR; + if(yych <= '\000') goto yy96; + goto yy25; +yy92: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -724,10 +728,10 @@ yy90: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy91; - default: goto yy2; + case '9': goto yy93; + default: goto yy25; } -yy91: yych = *++YYCURSOR; +yy93: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -738,16 +742,16 @@ yy91: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy92; - default: goto yy2; + case '9': goto yy94; + default: goto yy25; } -yy92: yych = *++YYCURSOR; +yy94: yych = *++YYCURSOR; switch(yych){ - case '\000': goto yy94; - case ':': goto yy93; - default: goto yy2; + case '\000': goto yy96; + case ':': goto yy95; + default: goto yy25; } -yy93: yych = *++YYCURSOR; +yy95: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -758,14 +762,14 @@ yy93: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy96; - default: goto yy2; + case '9': goto yy98; + default: goto yy25; } -yy94: yych = *++YYCURSOR; -yy95: +yy96: yych = *++YYCURSOR; +yy97: #line 108 { return "timestamp#spaced"; } -yy96: yych = *++YYCURSOR; +yy98: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -776,10 +780,10 @@ yy96: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy89; - default: goto yy2; + case '9': goto yy91; + default: goto yy25; } -yy97: yych = *++YYCURSOR; +yy99: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -790,15 +794,15 @@ yy97: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy98; - default: goto yy2; + case '9': goto yy100; + default: goto yy25; } -yy98: yych = *++YYCURSOR; +yy100: yych = *++YYCURSOR; switch(yych){ - case ':': goto yy99; - default: goto yy2; + case ':': goto yy101; + default: goto yy25; } -yy99: yych = *++YYCURSOR; +yy101: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -809,10 +813,10 @@ yy99: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy100; - default: goto yy2; + case '9': goto yy102; + default: goto yy25; } -yy100: yych = *++YYCURSOR; +yy102: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -823,15 +827,15 @@ yy100: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy101; - default: goto yy2; + case '9': goto yy103; + default: goto yy25; } -yy101: yych = *++YYCURSOR; +yy103: yych = *++YYCURSOR; switch(yych){ - case ':': goto yy102; - default: goto yy2; + case ':': goto yy104; + default: goto yy25; } -yy102: yych = *++YYCURSOR; +yy104: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -842,10 +846,10 @@ yy102: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy103; - default: goto yy2; + case '9': goto yy105; + default: goto yy25; } -yy103: yych = *++YYCURSOR; +yy105: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -856,12 +860,12 @@ yy103: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy104; - default: goto yy2; + case '9': goto yy106; + default: goto yy25; } -yy104: yych = *++YYCURSOR; +yy106: yych = *++YYCURSOR; switch(yych){ - case '.': goto yy105; + case '.': goto yy107; case '0': case '1': case '2': @@ -871,14 +875,14 @@ yy104: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy2; - default: goto yy106; + case '9': goto yy25; + default: goto yy108; } -yy105: ++YYCURSOR; +yy107: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy106: switch(yych){ - case '+': case '-': goto yy108; +yy108: switch(yych){ + case '+': case '-': goto yy110; case '0': case '1': case '2': @@ -888,14 +892,14 @@ yy106: switch(yych){ case '6': case '7': case '8': - case '9': goto yy105; - case 'Z': goto yy107; - default: goto yy2; + case '9': goto yy107; + case 'Z': goto yy109; + default: goto yy25; } -yy107: yych = *++YYCURSOR; - if(yych <= '\000') goto yy112; - goto yy2; -yy108: yych = *++YYCURSOR; +yy109: yych = *++YYCURSOR; + if(yych <= '\000') goto yy114; + goto yy25; +yy110: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -906,10 +910,10 @@ yy108: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy109; - default: goto yy2; + case '9': goto yy111; + default: goto yy25; } -yy109: yych = *++YYCURSOR; +yy111: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -920,16 +924,16 @@ yy109: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy110; - default: goto yy2; + case '9': goto yy112; + default: goto yy25; } -yy110: yych = *++YYCURSOR; +yy112: yych = *++YYCURSOR; switch(yych){ - case '\000': goto yy112; - case ':': goto yy111; - default: goto yy2; + case '\000': goto yy114; + case ':': goto yy113; + default: goto yy25; } -yy111: yych = *++YYCURSOR; +yy113: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -940,14 +944,14 @@ yy111: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy114; - default: goto yy2; + case '9': goto yy116; + default: goto yy25; } -yy112: yych = *++YYCURSOR; -yy113: +yy114: yych = *++YYCURSOR; +yy115: #line 106 { return "timestamp#iso8601"; } -yy114: yych = *++YYCURSOR; +yy116: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -958,10 +962,10 @@ yy114: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy107; - default: goto yy2; + case '9': goto yy109; + default: goto yy25; } -yy115: yych = *++YYCURSOR; +yy117: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -972,15 +976,15 @@ yy115: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy116; - default: goto yy2; + case '9': goto yy118; + default: goto yy25; } -yy116: yych = *++YYCURSOR; +yy118: yych = *++YYCURSOR; switch(yych){ - case ':': goto yy117; - default: goto yy2; + case ':': goto yy119; + default: goto yy25; } -yy117: yych = *++YYCURSOR; +yy119: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -991,10 +995,10 @@ yy117: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy118; - default: goto yy2; + case '9': goto yy120; + default: goto yy25; } -yy118: yych = *++YYCURSOR; +yy120: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -1005,15 +1009,15 @@ yy118: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy119; - default: goto yy2; + case '9': goto yy121; + default: goto yy25; } -yy119: yych = *++YYCURSOR; +yy121: yych = *++YYCURSOR; switch(yych){ - case ':': goto yy120; - default: goto yy2; + case ':': goto yy122; + default: goto yy25; } -yy120: yych = *++YYCURSOR; +yy122: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -1024,10 +1028,10 @@ yy120: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy121; - default: goto yy2; + case '9': goto yy123; + default: goto yy25; } -yy121: yych = *++YYCURSOR; +yy123: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -1038,12 +1042,12 @@ yy121: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy122; - default: goto yy2; + case '9': goto yy124; + default: goto yy25; } -yy122: yych = *++YYCURSOR; +yy124: yych = *++YYCURSOR; switch(yych){ - case '.': goto yy123; + case '.': goto yy125; case '0': case '1': case '2': @@ -1053,16 +1057,16 @@ yy122: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy2; - case 'Z': goto yy125; - default: goto yy124; + case '9': goto yy25; + case 'Z': goto yy127; + default: goto yy126; } -yy123: ++YYCURSOR; +yy125: ++YYCURSOR; if((YYLIMIT - YYCURSOR) < 7) YYFILL(7); yych = *YYCURSOR; -yy124: switch(yych){ - case '+': case '-': goto yy108; - case '0': goto yy123; +yy126: switch(yych){ + case '+': case '-': goto yy110; + case '0': goto yy125; case '1': case '2': case '3': @@ -1071,20 +1075,20 @@ yy124: switch(yych){ case '6': case '7': case '8': - case '9': goto yy127; - case 'Z': goto yy107; - default: goto yy2; + case '9': goto yy129; + case 'Z': goto yy109; + default: goto yy25; } -yy125: yych = *++YYCURSOR; - if(yych >= '\001') goto yy2; -yy126: yych = *++YYCURSOR; - goto yy113; -yy127: ++YYCURSOR; +yy127: yych = *++YYCURSOR; + if(yych >= '\001') goto yy25; +yy128: yych = *++YYCURSOR; + goto yy115; +yy129: ++YYCURSOR; if((YYLIMIT - YYCURSOR) < 7) YYFILL(7); yych = *YYCURSOR; -yy128: switch(yych){ - case '+': case '-': goto yy108; - case '0': goto yy123; +yy130: switch(yych){ + case '+': case '-': goto yy110; + case '0': goto yy125; case '1': case '2': case '3': @@ -1093,11 +1097,11 @@ yy128: switch(yych){ case '6': case '7': case '8': - case '9': goto yy127; - case 'Z': goto yy125; - default: goto yy2; + case '9': goto yy129; + case 'Z': goto yy127; + default: goto yy25; } -yy129: yych = *++YYCURSOR; +yy131: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -1106,12 +1110,12 @@ yy129: yych = *++YYCURSOR; case '4': case '5': case '6': - case '7': goto yy144; + case '7': goto yy146; case '8': - case '9': goto yy142; - default: goto yy132; + case '9': goto yy144; + default: goto yy134; } -yy130: yych = *++YYCURSOR; +yy132: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -1122,14 +1126,14 @@ yy130: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy142; - default: goto yy141; + case '9': goto yy144; + default: goto yy143; } -yy131: ++YYCURSOR; +yy133: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy132: switch(yych){ - case '\000': goto yy138; +yy134: switch(yych){ + case '\000': goto yy140; case ',': case '0': case '1': case '2': @@ -1137,20 +1141,20 @@ yy132: switch(yych){ case '4': case '5': case '6': - case '7': goto yy131; - case '.': goto yy47; + case '7': goto yy133; + case '.': goto yy49; case '8': - case '9': goto yy140; - default: goto yy2; + case '9': goto yy142; + default: goto yy25; } -yy133: yych = *++YYCURSOR; - if(yych <= '\000') goto yy2; - goto yy135; -yy134: ++YYCURSOR; +yy135: yych = *++YYCURSOR; + if(yych <= '\000') goto yy25; + goto yy137; +yy136: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy135: switch(yych){ - case '\000': goto yy136; +yy137: switch(yych){ + case '\000': goto yy138; case ',': case '0': case '1': case '2': @@ -1170,21 +1174,21 @@ yy135: switch(yych){ case 'c': case 'd': case 'e': - case 'f': goto yy134; - default: goto yy2; + case 'f': goto yy136; + default: goto yy25; } -yy136: yych = *++YYCURSOR; -yy137: -#line 88 - { return "int#hex"; } yy138: yych = *++YYCURSOR; yy139: +#line 88 + { return "int#hex"; } +yy140: yych = *++YYCURSOR; +yy141: #line 90 { return "int#oct"; } -yy140: ++YYCURSOR; +yy142: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy141: switch(yych){ +yy143: switch(yych){ case ',': case '0': case '1': case '2': @@ -1194,11 +1198,11 @@ yy141: switch(yych){ case '6': case '7': case '8': - case '9': goto yy140; - case '.': goto yy47; - default: goto yy2; + case '9': goto yy142; + case '.': goto yy49; + default: goto yy25; } -yy142: yych = *++YYCURSOR; +yy144: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -1209,15 +1213,15 @@ yy142: yych = *++YYCURSOR; case '6': case '7': case '8': - case '9': goto yy143; - default: goto yy141; + case '9': goto yy145; + default: goto yy143; } -yy143: yych = *++YYCURSOR; +yy145: yych = *++YYCURSOR; switch(yych){ - case '-': goto yy65; - default: goto yy141; + case '-': goto yy67; + default: goto yy143; } -yy144: yych = *++YYCURSOR; +yy146: yych = *++YYCURSOR; switch(yych){ case '0': case '1': @@ -1226,218 +1230,215 @@ yy144: yych = *++YYCURSOR; case '4': case '5': case '6': - case '7': goto yy145; + case '7': goto yy147; case '8': - case '9': goto yy143; - default: goto yy132; - } -yy145: yych = *++YYCURSOR; - switch(yych){ - case '-': goto yy65; - default: goto yy132; - } -yy146: yych = *++YYCURSOR; - switch(yych){ - case 'I': goto yy149; - case 'i': goto yy148; - default: goto yy2; + case '9': goto yy145; + default: goto yy134; } yy147: yych = *++YYCURSOR; switch(yych){ - case '\000': goto yy49; - case 'x': goto yy133; - default: goto yy132; + case '-': goto yy67; + default: goto yy134; } yy148: yych = *++YYCURSOR; switch(yych){ - case 'n': goto yy155; - default: goto yy2; + case 'I': goto yy151; + case 'i': goto yy150; + default: goto yy25; } yy149: yych = *++YYCURSOR; switch(yych){ - case 'N': goto yy150; - case 'n': goto yy151; - default: goto yy2; + case '\000': goto yy51; + case 'x': goto yy135; + default: goto yy134; } yy150: yych = *++YYCURSOR; switch(yych){ - case 'F': goto yy152; - default: goto yy2; + case 'n': goto yy157; + default: goto yy25; } yy151: yych = *++YYCURSOR; switch(yych){ - case 'f': goto yy152; - default: goto yy2; + case 'N': goto yy152; + case 'n': goto yy153; + default: goto yy25; } yy152: yych = *++YYCURSOR; - if(yych >= '\001') goto yy2; -yy153: yych = *++YYCURSOR; -yy154: -#line 100 - { return "float#neginf"; } -yy155: yych = *++YYCURSOR; switch(yych){ - case 'f': goto yy152; - default: goto yy2; + case 'F': goto yy154; + default: goto yy25; } -yy156: yych = *++YYCURSOR; +yy153: yych = *++YYCURSOR; switch(yych){ - case 'I': goto yy31; - case 'i': goto yy30; - default: goto yy2; + 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 'L': goto yy164; - default: goto yy2; + case 'f': goto yy154; + default: goto yy25; } yy158: yych = *++YYCURSOR; switch(yych){ - case 'l': goto yy159; - default: goto yy2; + case 'I': goto yy33; + case 'i': goto yy32; + default: goto yy25; } yy159: yych = *++YYCURSOR; switch(yych){ - case 's': goto yy160; - default: goto yy2; + case 'L': goto yy166; + default: goto yy25; } yy160: yych = *++YYCURSOR; switch(yych){ - case 'e': goto yy161; - default: goto yy2; + case 'l': goto yy161; + default: goto yy25; } yy161: yych = *++YYCURSOR; - if(yych >= '\001') goto yy2; -yy162: yych = *++YYCURSOR; -yy163: -#line 86 - { return "bool#no"; } -yy164: yych = *++YYCURSOR; switch(yych){ - case 'S': goto yy165; - default: goto yy2; + case 's': goto yy162; + default: goto yy25; } -yy165: yych = *++YYCURSOR; +yy162: yych = *++YYCURSOR; switch(yych){ - case 'E': goto yy161; - default: goto yy2; + 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 'l': goto yy167; - default: goto yy2; + case 'S': goto yy167; + default: goto yy25; } yy167: yych = *++YYCURSOR; switch(yych){ - case 's': goto yy168; - default: goto yy2; + case 'E': goto yy163; + default: goto yy25; } yy168: yych = *++YYCURSOR; switch(yych){ - case 'e': goto yy161; - default: goto yy2; + case 'l': goto yy169; + default: goto yy25; } yy169: yych = *++YYCURSOR; switch(yych){ - case 'F': goto yy161; - default: goto yy2; + case 's': goto yy170; + default: goto yy25; } yy170: yych = *++YYCURSOR; switch(yych){ - case 'f': goto yy161; - default: goto yy2; + case 'e': goto yy163; + default: goto yy25; } yy171: yych = *++YYCURSOR; - if(yych >= '\001') goto yy2; -yy172: yych = *++YYCURSOR; -yy173: -#line 84 - { return "bool#yes"; } -yy174: yych = *++YYCURSOR; switch(yych){ - case 'f': goto yy161; - default: goto yy2; + case 'F': goto yy163; + default: goto yy25; } -yy175: yych = *++YYCURSOR; +yy172: yych = *++YYCURSOR; switch(yych){ - case 'S': goto yy171; - default: goto yy2; + 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 's': goto yy171; - default: goto yy2; + case 'f': goto yy163; + default: goto yy25; } yy177: yych = *++YYCURSOR; switch(yych){ - case 's': goto yy171; - default: goto yy2; + case 'S': goto yy173; + default: goto yy25; } yy178: yych = *++YYCURSOR; switch(yych){ - case 'U': goto yy181; - default: goto yy2; + case 's': goto yy173; + default: goto yy25; } yy179: yych = *++YYCURSOR; switch(yych){ - case 'u': goto yy180; - default: goto yy2; + case 's': goto yy173; + default: goto yy25; } yy180: yych = *++YYCURSOR; switch(yych){ - case 'e': goto yy171; - default: goto yy2; + case 'U': goto yy183; + default: goto yy25; } yy181: yych = *++YYCURSOR; switch(yych){ - case 'E': goto yy171; - default: goto yy2; + case 'u': goto yy182; + default: goto yy25; } yy182: yych = *++YYCURSOR; switch(yych){ - case 'u': goto yy183; - default: goto yy2; + case 'e': goto yy173; + default: goto yy25; } yy183: yych = *++YYCURSOR; switch(yych){ - case 'e': goto yy171; - default: goto yy2; + case 'E': goto yy173; + default: goto yy25; } yy184: yych = *++YYCURSOR; switch(yych){ - case 'L': goto yy190; - default: goto yy2; + case 'u': goto yy185; + default: goto yy25; } yy185: yych = *++YYCURSOR; switch(yych){ - case 'l': goto yy186; - default: goto yy2; + case 'e': goto yy173; + default: goto yy25; } yy186: yych = *++YYCURSOR; switch(yych){ - case 'l': goto yy187; - default: goto yy2; + case 'L': goto yy190; + default: goto yy25; } yy187: yych = *++YYCURSOR; - if(yych >= '\001') goto yy2; + switch(yych){ + case 'l': goto yy188; + default: goto yy25; + } yy188: yych = *++YYCURSOR; -yy189: -#line 82 - { return "null"; } + 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 yy187; - default: goto yy2; + case 'L': goto yy189; + default: goto yy25; } yy191: yych = *++YYCURSOR; switch(yych){ case 'l': goto yy192; - default: goto yy2; + default: goto yy25; } yy192: yych = *++YYCURSOR; switch(yych){ - case 'l': goto yy187; - default: goto yy2; + case 'l': goto yy189; + default: goto yy25; } } #line 118 diff --git a/ext/syck/rubyext.c b/ext/syck/rubyext.c index ec54ef831..5b350474f 100644 --- a/ext/syck/rubyext.c +++ b/ext/syck/rubyext.c @@ -40,7 +40,7 @@ typedef struct RVALUE { /* * symbols and constants */ -static ID s_new, s_utc, s_at, s_to_f, s_read, s_binmode, s_call, s_transfer, s_update, s_dup, s_match; +static ID s_new, s_utc, s_at, s_to_f, s_read, s_binmode, s_call, s_transfer, s_update, s_dup, s_match, s_keys, s_to_str, s_unpack, s_tr_bang; static VALUE sym_model, sym_generic; static VALUE sym_scalar, sym_seq, sym_map; VALUE cDate, cParser, cLoader, cNode, cPrivateType, cDomainType, cBadAlias, cMergeKey, cEmitter; @@ -112,7 +112,7 @@ syck_parser_assign_io(parser, port) VALUE port; { int taint = Qtrue; - if (rb_respond_to(port, rb_intern("to_str"))) { + 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 ); @@ -306,79 +306,136 @@ syck_merge_i( entry, hsh ) } /* - * {native mode} node handler - * - Converts data into native Ruby types + * build a syck node from a Ruby VALUE */ -SYMID -rb_syck_load_handler(p, n) - SyckParser *p; +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; - long i; - int check_transfers = 0; - struct parser_xtra *bonus; + /* + * If prefixed with YAML_DOMAIN, skip to type name + */ switch (n->kind) { case syck_str_kind: - if ( n->type_id == NULL || strcmp( n->type_id, "str" ) == 0 ) + 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( n->type_id, "null" ) == 0 ) + else if ( strcmp( type_id, "null" ) == 0 ) { obj = Qnil; } - else if ( strcmp( n->type_id, "bool#yes" ) == 0 ) + 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( n->type_id, "bool#no" ) == 0 ) + else if ( strcmp( type_id, "bool#no" ) == 0 ) { obj = Qfalse; } - else if ( strcmp( n->type_id, "int#hex" ) == 0 ) + else if ( strcmp( type_id, "int#hex" ) == 0 ) { obj = rb_cstr2inum( n->data.str->ptr, 16 ); } - else if ( strcmp( n->type_id, "int#oct" ) == 0 ) + else if ( strcmp( type_id, "int#oct" ) == 0 ) { obj = rb_cstr2inum( n->data.str->ptr, 8 ); } - else if ( strncmp( n->type_id, "int", 3 ) == 0 ) + 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( n->type_id, "float#nan" ) == 0 ) + else if ( strcmp( type_id, "float#nan" ) == 0 ) { obj = rb_float_new( S_nan() ); } - else if ( strcmp( n->type_id, "float#inf" ) == 0 ) + else if ( strcmp( type_id, "float#inf" ) == 0 ) { obj = rb_float_new( S_inf() ); } - else if ( strcmp( n->type_id, "float#neginf" ) == 0 ) + else if ( strcmp( type_id, "float#neginf" ) == 0 ) { obj = rb_float_new( -S_inf() ); } - else if ( strncmp( n->type_id, "float", 5 ) == 0 ) + 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( n->type_id, "timestamp#iso8601" ) == 0 ) + else if ( strcmp( type_id, "timestamp#iso8601" ) == 0 ) { obj = rb_syck_mktime( n->data.str->ptr ); } - else if ( strcmp( n->type_id, "timestamp#spaced" ) == 0 ) + else if ( strcmp( type_id, "timestamp#spaced" ) == 0 ) { obj = rb_syck_mktime( n->data.str->ptr ); } - else if ( strcmp( n->type_id, "timestamp#ymd" ) == 0 ) + else if ( strcmp( type_id, "timestamp#ymd" ) == 0 ) { char *ptr = n->data.str->ptr; VALUE year, mon, day; @@ -399,17 +456,17 @@ rb_syck_load_handler(p, n) obj = rb_funcall( cDate, s_new, 3, year, mon, day ); } - else if ( strncmp( n->type_id, "timestamp", 9 ) == 0 ) + else if ( strncmp( type_id, "timestamp", 9 ) == 0 ) { obj = rb_syck_mktime( n->data.str->ptr ); } - else if ( strncmp( n->type_id, "merge", 5 ) == 0 ) + else if ( strncmp( type_id, "merge", 5 ) == 0 ) { obj = rb_funcall( cMergeKey, s_new, 0 ); } else { - check_transfers = 1; + transferred = 0; obj = rb_str_new( n->data.str->ptr, n->data.str->len ); } break; @@ -420,7 +477,10 @@ rb_syck_load_handler(p, n) { rb_ary_store( obj, i, syck_seq_read( n, i ) ); } - check_transfers = 1; + if ( type_id == NULL || strcmp( type_id, "seq" ) == 0 ) + { + transferred = 1; + } break; case syck_map_kind: @@ -463,10 +523,38 @@ rb_syck_load_handler(p, n) rb_hash_aset( obj, k, v ); } } - check_transfers = 1; + if ( type_id == NULL || strcmp( type_id, "map" ) == 0 ) + { + transferred = 1; + } 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 */ @@ -481,11 +569,6 @@ rb_syck_load_handler(p, n) if ( bonus->taint) OBJ_TAINT( obj ); if ( bonus->proc != 0 ) rb_funcall(bonus->proc, s_call, 1, obj); - if ( check_transfers == 1 && n->type_id != NULL ) - { - obj = rb_funcall( oDefaultLoader, s_transfer, 2, rb_str_new2( n->type_id ), obj ); - } - rb_hash_aset(bonus->data, INT2FIX(RHASH(bonus->data)->tbl->num_entries), obj); return obj; } @@ -824,6 +907,7 @@ syck_loader_transfer( self, type, val ) */ 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 ) ); } @@ -835,10 +919,12 @@ syck_loader_transfer( self, type, val ) 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("taguri"); 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 ); @@ -854,6 +940,21 @@ syck_loader_transfer( self, type, val ) 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 { @@ -861,30 +962,34 @@ syck_loader_transfer( self, type, val ) scheme); } - if ( rb_obj_is_instance_of( type_hash, rb_cHash ) ) + if ( ! transferred ) { - type_proc = rb_hash_aref( type_hash, name ); - if ( NIL_P( type_proc ) ) + if ( rb_obj_is_instance_of( type_hash, rb_cHash ) ) { - 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 ); + 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); + 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; } } @@ -996,7 +1101,7 @@ rb_syck_output_handler( emitter, str, len ) long len; { VALUE dest = (VALUE)emitter->bonus; - if ( rb_respond_to( dest, rb_intern("to_str") ) ) { + if ( rb_respond_to( dest, s_to_str ) ) { rb_str_cat( dest, str, len ); } else { rb_io_write( dest, rb_str_new( str, len ) ); @@ -1175,6 +1280,10 @@ Init_syck() s_update = rb_intern("update"); s_dup = rb_intern("dup"); 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")); diff --git a/ext/syck/token.c b/ext/syck/token.c index 1fc274c59..d84d54505 100644 --- a/ext/syck/token.c +++ b/ext/syck/token.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.5 on Mon Jul 28 21:10:39 2003 */ +/* Generated by re2c 0.5 on Thu Aug 21 14:28:35 2003 */ #line 1 "token.re" /* * token.re @@ -137,6 +137,7 @@ #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 ) \ @@ -228,7 +229,7 @@ sycklex( YYSTYPE *sycklval, SyckParser *parser ) return t; } -#line 246 +#line 247 if ( YYLINEPTR != YYCURSOR ) @@ -264,7 +265,7 @@ yy2: yyaccept = 0; default: goto yy3; } yy3: -#line 302 +#line 303 { YYPOS(0); goto Document; } @@ -276,13 +277,13 @@ yy4: yyaccept = 0; } yy5: yych = *++YYCURSOR; yy6: -#line 287 +#line 288 { eat_comments( parser ); goto Header; } yy7: yych = *++YYCURSOR; yy8: -#line 291 +#line 292 { SyckLevel *lvl = CURRENT_LEVEL(); ENSURE_YAML_IEND(lvl, -1); YYPOS(0); @@ -292,7 +293,7 @@ yy9: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); goto yy14; yy10: -#line 297 +#line 298 { int indt_len; GOBBLE_UP_YAML_INDENT( indt_len, YYTOKEN ); goto Header; @@ -339,7 +340,7 @@ yy18: yych = *++YYCURSOR; } yy19: yych = *++YYCURSOR; yy20: -#line 273 +#line 274 { SyckLevel *lvl = CURRENT_LEVEL(); if ( lvl->status == syck_lvl_header ) { @@ -379,7 +380,7 @@ yy25: yych = *++YYCURSOR; } yy26: yych = *++YYCURSOR; yy27: -#line 259 +#line 260 { SyckLevel *lvl = CURRENT_LEVEL(); if ( lvl->status == syck_lvl_header ) { @@ -406,7 +407,7 @@ yy30: yych = *++YYCURSOR; default: goto yy16; } } -#line 306 +#line 307 Document: @@ -449,7 +450,7 @@ yy33: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); goto yy86; yy34: -#line 320 +#line 321 { /* Isolate spaces */ int indt_len; GOBBLE_UP_YAML_INDENT( indt_len, YYTOKEN ); @@ -470,13 +471,13 @@ yy35: yych = *++YYCURSOR; default: goto yy36; } yy36: -#line 407 +#line 408 { ENSURE_YAML_IOPEN(lvl, 0, 1); goto Plain; } yy37: yych = *++YYCURSOR; yy38: -#line 335 +#line 336 { ENSURE_YAML_IOPEN(lvl, 0, 1); lvl = CURRENT_LEVEL(); ADD_LEVEL(lvl->spaces + 1, syck_lvl_inline); @@ -484,7 +485,7 @@ yy38: } yy39: yych = *++YYCURSOR; yy40: -#line 341 +#line 342 { POP_LEVEL(); return YYTOKEN[0]; } @@ -634,17 +635,17 @@ yy44: yych = *++YYCURSOR; } yy45: yych = *++YYCURSOR; yy46: -#line 380 +#line 381 { ENSURE_YAML_IOPEN(lvl, 0, 1); goto TransferMethod; } yy47: yych = *++YYCURSOR; yy48: -#line 383 +#line 384 { ENSURE_YAML_IOPEN(lvl, 0, 1); goto SingleQuote; } yy49: yych = *++YYCURSOR; yy50: -#line 386 +#line 387 { ENSURE_YAML_IOPEN(lvl, 0, 1); goto DoubleQuote; } yy51: yyaccept = 1; @@ -667,18 +668,18 @@ yy51: yyaccept = 1; } yy52: yych = *++YYCURSOR; yy53: -#line 396 +#line 397 { eat_comments( parser ); goto Document; } yy54: yych = *++YYCURSOR; goto yy60; yy55: -#line 400 +#line 401 { goto Document; } yy56: yych = *++YYCURSOR; yy57: -#line 402 +#line 403 { ENSURE_YAML_IEND(lvl, -1); YYPOS(0); return 0; @@ -718,7 +719,7 @@ yy63: YYCURSOR = YYMARKER; } yy64: yych = *++YYCURSOR; yy65: -#line 389 +#line 390 { if ( is_newline( YYCURSOR - 1 ) ) { YYCURSOR--; @@ -804,7 +805,7 @@ yy70: switch(yych){ default: goto yy71; } yy71: -#line 375 +#line 376 { ENSURE_YAML_IOPEN(lvl, 0, 1); sycklval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 ); return YAML_ALIAS; @@ -876,7 +877,7 @@ yy73: switch(yych){ default: goto yy74; } yy74: -#line 363 +#line 364 { ENSURE_YAML_IOPEN(lvl, 0, 1); sycklval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 ); @@ -890,7 +891,7 @@ yy74: } yy75: yych = *++YYCURSOR; yy76: -#line 349 +#line 350 { ENSURE_YAML_IOPEN(lvl, YYTOKEN - YYLINEPTR, 1); FORCE_NEXT_TOKEN(YAML_IOPEN); if ( is_newline( YYCURSOR ) || is_newline( YYCURSOR - 1 ) ) @@ -918,7 +919,7 @@ yy79: yych = *++YYCURSOR; } yy80: yych = *++YYCURSOR; yy81: -#line 345 +#line 346 { YYPOS(1); return YYTOKEN[0]; } @@ -951,7 +952,7 @@ yy87: ++YYCURSOR; default: goto yy63; } } -#line 411 +#line 412 } @@ -1058,14 +1059,14 @@ yy91: yyaccept = 0; default: goto yy92; } yy92: -#line 424 +#line 425 { YYCURSOR = YYTOKTMP; return YAML_DOCSEP; } yy93: yych = *++YYCURSOR; goto yy97; yy94: -#line 422 +#line 423 { goto Directive; } yy95: yych = *++YYCURSOR; goto yy92; @@ -1317,10 +1318,10 @@ yy102: switch(yych){ default: goto yy103; } yy103: -#line 420 +#line 421 { goto Directive; } } -#line 427 +#line 428 } @@ -1364,7 +1365,7 @@ yy106: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); goto yy132; yy107: -#line 450 +#line 451 { int indt_len, nl_count = 0; SyckLevel *lvl; char *tok = YYTOKTMP; @@ -1402,7 +1403,7 @@ yy108: yych = *++YYCURSOR; default: goto yy109; } yy109: -#line 504 +#line 505 { QUOTECATS(qstr, qcapa, qidx, YYTOKTMP, YYCURSOR - YYTOKTMP); goto Plain2; } @@ -1416,7 +1417,7 @@ yy110: yyaccept = 1; } yy111: yych = *++YYCURSOR; yy112: -#line 484 +#line 485 { if ( plvl->status != syck_lvl_inline ) { if ( *(YYCURSOR - 1) == ' ' || is_newline( YYCURSOR - 1 ) ) @@ -1442,17 +1443,17 @@ yy114: yych = *++YYCURSOR; default: goto yy115; } yy115: -#line 502 +#line 503 { goto Plain3; } yy116: yych = *++YYCURSOR; yy117: -#line 500 +#line 501 { RETURN_IMPLICIT(); } yy118: yych = *++YYCURSOR; goto yy109; yy119: yych = *++YYCURSOR; yy120: -#line 496 +#line 497 { eat_comments( parser ); RETURN_IMPLICIT(); } @@ -1477,7 +1478,7 @@ yy125: YYCURSOR = YYMARKER; } yy126: yych = *++YYCURSOR; yy127: -#line 482 +#line 483 { RETURN_IMPLICIT(); } yy128: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -1508,7 +1509,7 @@ yy133: ++YYCURSOR; default: goto yy125; } } -#line 508 +#line 509 } @@ -1540,7 +1541,7 @@ yy136: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); goto yy147; yy137: -#line 522 +#line 523 { int indt_len; int nl_count = 0; SyckLevel *lvl; @@ -1582,7 +1583,7 @@ yy138: yych = *++YYCURSOR; default: goto yy139; } yy139: -#line 576 +#line 578 { QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1)); goto SingleQuote2; } @@ -1592,7 +1593,7 @@ yy140: yych = *++YYCURSOR; default: goto yy141; } yy141: -#line 562 +#line 563 { SyckLevel *lvl; SyckNode *n = syck_alloc_str(); lvl = CURRENT_LEVEL(); @@ -1601,6 +1602,7 @@ yy141: { POP_LEVEL(); } + n->type_id = syck_strndup( "str", 3 ); n->data.str->ptr = qstr; n->data.str->len = qidx; sycklval->nodeData = n; @@ -1612,7 +1614,7 @@ yy143: yych = *++YYCURSOR; goto yy139; yy144: yych = *++YYCURSOR; yy145: -#line 558 +#line 559 { QUOTECAT(qstr, qcapa, qidx, '\''); goto SingleQuote2; } @@ -1637,7 +1639,7 @@ yy149: YYCURSOR = YYMARKER; case 0: goto yy137; } } -#line 580 +#line 582 } @@ -1674,7 +1676,7 @@ yy152: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); goto yy174; yy153: -#line 598 +#line 600 { int indt_len; int nl_count = 0; SyckLevel *lvl; @@ -1720,7 +1722,7 @@ yy154: yych = *++YYCURSOR; default: goto yy155; } yy155: -#line 682 +#line 685 { QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1)); goto DoubleQuote2; } @@ -1738,7 +1740,7 @@ yy156: yyaccept = 1; } yy157: yych = *++YYCURSOR; yy158: -#line 668 +#line 670 { SyckLevel *lvl; SyckNode *n = syck_alloc_str(); lvl = CURRENT_LEVEL(); @@ -1747,6 +1749,7 @@ yy158: { POP_LEVEL(); } + n->type_id = syck_strndup( "str", 3 ); n->data.str->ptr = qstr; n->data.str->len = qidx; sycklval->nodeData = n; @@ -1772,7 +1775,7 @@ yy163: YYCURSOR = YYMARKER; } yy164: yych = *++YYCURSOR; yy165: -#line 663 +#line 665 { keep_nl = 0; YYCURSOR--; goto DoubleQuote2; @@ -1808,7 +1811,7 @@ yy167: yych = *++YYCURSOR; } yy168: yych = *++YYCURSOR; yy169: -#line 638 +#line 640 { char ch = *( YYCURSOR - 1 ); switch ( ch ) { @@ -1850,7 +1853,7 @@ yy170: yych = *++YYCURSOR; } yy171: yych = *++YYCURSOR; yy172: -#line 654 +#line 656 { long ch; char *chr_text = syck_strndup( YYTOKTMP, 4 ); chr_text[0] = '0'; @@ -1876,7 +1879,7 @@ yy175: ++YYCURSOR; default: goto yy163; } } -#line 686 +#line 689 } @@ -1911,7 +1914,7 @@ yy178: YYCURSOR = YYMARKER; } yy179: yych = *++YYCURSOR; yy180: -#line 700 +#line 703 { SyckLevel *lvl; YYCURSOR = YYTOKTMP; if ( YYCURSOR == YYTOKEN + 1 ) @@ -1969,7 +1972,7 @@ yy182: yych = *++YYCURSOR; default: goto yy183; } yy183: -#line 762 +#line 765 { QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1)); goto TransferMethod2; } @@ -2031,7 +2034,7 @@ yy187: yych = *++YYCURSOR; } yy188: yych = *++YYCURSOR; yy189: -#line 753 +#line 756 { long ch; char *chr_text = syck_strndup( YYTOKTMP, 4 ); chr_text[0] = '0'; @@ -2050,7 +2053,7 @@ yy192: switch(yych){ default: goto yy180; } } -#line 767 +#line 770 } @@ -2115,7 +2118,7 @@ yy195: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); goto yy205; yy196: -#line 814 +#line 817 { char *pacer; char *tok = YYTOKTMP; int indt_len = 0, nl_count = 0, fold_nl = 0, nl_begin = 0; @@ -2187,13 +2190,13 @@ yy197: yych = *++YYCURSOR; default: goto yy198; } yy198: -#line 900 +#line 903 { QUOTECAT(qstr, qcapa, qidx, *YYTOKTMP); goto ScalarBlock2; } yy199: yych = *++YYCURSOR; yy200: -#line 881 +#line 884 { lvl = CURRENT_LEVEL(); if ( lvl->status != syck_lvl_block ) { @@ -2208,7 +2211,7 @@ yy200: } yy201: yych = *++YYCURSOR; yy202: -#line 895 +#line 898 { YYCURSOR--; POP_LEVEL(); RETURN_YAML_BLOCK(); @@ -2236,7 +2239,7 @@ yy207: YYCURSOR = YYMARKER; case 0: goto yy196; } } -#line 905 +#line 908 } @@ -2269,7 +2272,7 @@ yy208: } yy210: yych = *++YYCURSOR; yy211: -#line 923 +#line 926 { YYCURSOR = tok; return; } @@ -2282,7 +2285,7 @@ yy213: yych = *++YYCURSOR; default: goto yy214; } yy214: -#line 927 +#line 930 { goto Comment; } yy215: yych = *++YYCURSOR; @@ -2308,7 +2311,7 @@ yy219: YYCURSOR = YYMARKER; case 0: goto yy211; } } -#line 930 +#line 933 } |