From 7f64b0efa26b36a9ed3bef29f5f6d15950a0c460 Mon Sep 17 00:00:00 2001 From: why Date: Tue, 20 Sep 2005 23:58:18 +0000 Subject: * ext/syck/token.c: correctly compute identation of a block scalar's parent node. [ruby-talk:150620] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 ++ ext/syck/token.c | 225 ++++++++++++++++++++++++++++--------------------------- 2 files changed, 120 insertions(+), 110 deletions(-) diff --git a/ChangeLog b/ChangeLog index 056fd99ea7..6568149ec2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Sep 21 08:52:25 2005 why the lucky stiff + + * ext/syck/token.c: correctly compute identation of a block + scalar's parent node. [ruby-talk:150620] + Wed Sep 21 08:53:45 2005 Yukihiro Matsumoto * stable version 1.8.3 released. diff --git a/ext/syck/token.c b/ext/syck/token.c index 57a7910168..3c6cd1a9cf 100644 --- a/ext/syck/token.c +++ b/ext/syck/token.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.9.10 on Mon Sep 19 23:23:24 2005 */ +/* Generated by re2c 0.9.10 on Tue Sep 20 17:46:17 2005 */ #line 1 "token.re" /* * token.re @@ -218,7 +218,7 @@ { \ SyckLevel *lvl_deep = CURRENT_LEVEL(); \ indt_len = lvl_deep->spaces; \ - if ( indt_len == YYTOKEN - YYLINEPTR ) \ + if ( lvl_deep->status == syck_lvl_seq || ( indt_len == YYCURSOR - YYLINEPTR && lvl_deep->status != syck_lvl_map ) ) \ { \ SyckLevel *lvl_over; \ parser->lvl_idx--; \ @@ -582,7 +582,7 @@ yy39: ++YYCURSOR; default: goto yy40; } yy40: -#line 496 "token.re" +#line 497 "token.re" { ENSURE_YAML_IOPEN(lvl, doc_level, 1); goto Plain; } @@ -762,20 +762,20 @@ yy50: yych = *++YYCURSOR; yy51: ++YYCURSOR; goto yy52; yy52: -#line 470 "token.re" +#line 471 "token.re" { goto TransferMethod; } #line 767 "" yy53: ++YYCURSOR; goto yy54; yy54: -#line 472 "token.re" +#line 473 "token.re" { ENSURE_YAML_IOPEN(lvl, doc_level, 1); goto SingleQuote; } #line 774 "" yy55: ++YYCURSOR; goto yy56; yy56: -#line 475 "token.re" +#line 476 "token.re" { ENSURE_YAML_IOPEN(lvl, doc_level, 1); goto DoubleQuote; } #line 781 "" @@ -800,7 +800,7 @@ yy57: yyaccept = 1; yy58: ++YYCURSOR; goto yy59; yy59: -#line 485 "token.re" +#line 486 "token.re" { eat_comments( parser ); goto Document; } @@ -809,13 +809,13 @@ yy60: ++YYCURSOR; yych = *YYCURSOR; goto yy66; yy61: -#line 489 "token.re" +#line 490 "token.re" { goto Document; } #line 814 "" yy62: ++YYCURSOR; goto yy63; yy63: -#line 491 "token.re" +#line 492 "token.re" { ENSURE_YAML_IEND(lvl, -1); YYPOS(0); return 0; @@ -859,7 +859,7 @@ yy69: YYCURSOR = YYMARKER; yy70: ++YYCURSOR; goto yy71; yy71: -#line 478 "token.re" +#line 479 "token.re" { if ( is_newline( YYCURSOR - 1 ) ) { YYCURSOR--; @@ -948,7 +948,7 @@ yy76: switch(yych){ default: goto yy77; } yy77: -#line 465 "token.re" +#line 466 "token.re" { ENSURE_YAML_IOPEN(lvl, doc_level, 1); sycklval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 ); return YAML_ALIAS; @@ -1022,7 +1022,7 @@ yy79: switch(yych){ default: goto yy80; } yy80: -#line 454 "token.re" +#line 455 "token.re" { sycklval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 ); /* @@ -1037,17 +1037,17 @@ yy80: yy81: ++YYCURSOR; goto yy82; yy82: -#line 440 "token.re" +#line 441 "token.re" { ENSURE_YAML_IOPEN(lvl, YYTOKEN - YYLINEPTR, 1); FORCE_NEXT_TOKEN(YAML_IOPEN); if ( *YYCURSOR == '#' || is_newline( YYCURSOR ) || is_newline( YYCURSOR - 1 ) ) { YYCURSOR--; - ADD_LEVEL((YYTOKEN + 1) - YYLINEPTR, syck_lvl_doc); + ADD_LEVEL((YYTOKEN + 1) - YYLINEPTR, syck_lvl_seq); } else /* spaces followed by content uses the space as indentation */ { - ADD_LEVEL(YYCURSOR - YYLINEPTR, syck_lvl_doc); + ADD_LEVEL(YYCURSOR - YYLINEPTR, syck_lvl_seq); } return YYTOKEN[0]; } @@ -1069,10 +1069,11 @@ yy86: ++YYCURSOR; goto yy87; yy87: #line 436 "token.re" -{ YYPOS(1); +{ if ( *YYTOKEN == ':' && lvl->status != syck_lvl_imap ) lvl->status = syck_lvl_map; + YYPOS(1); return YYTOKEN[0]; } -#line 1075 "" +#line 1076 "" yy88: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; @@ -1104,7 +1105,7 @@ yy93: ++YYCURSOR; default: goto yy69; } } -#line 500 "token.re" +#line 501 "token.re" } @@ -1113,7 +1114,7 @@ Directive: YYTOKTMP = YYCURSOR; -#line 1116 "" +#line 1117 "" { YYCTYPE yych; unsigned int yyaccept; @@ -1213,18 +1214,18 @@ yy97: yyaccept = 0; default: goto yy98; } yy98: -#line 513 "token.re" +#line 514 "token.re" { YYCURSOR = YYTOKTMP; return YAML_DOCSEP; } -#line 1220 "" +#line 1221 "" yy99: ++YYCURSOR; yych = *YYCURSOR; goto yy103; yy100: -#line 511 "token.re" +#line 512 "token.re" { goto Directive; } -#line 1227 "" +#line 1228 "" yy101: yych = *++YYCURSOR; goto yy98; yy102: ++YYCURSOR; @@ -1478,11 +1479,11 @@ yy108: switch(yych){ default: goto yy109; } yy109: -#line 509 "token.re" +#line 510 "token.re" { goto Directive; } -#line 1483 "" +#line 1484 "" } -#line 516 "token.re" +#line 517 "token.re" } @@ -1505,7 +1506,7 @@ Plain2: Plain3: -#line 1508 "" +#line 1509 "" { YYCTYPE yych; unsigned int yyaccept; @@ -1530,7 +1531,7 @@ yy112: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); goto yy142; yy113: -#line 539 "token.re" +#line 540 "token.re" { int indt_len, nl_count = 0; SyckLevel *lvl; char *tok = YYTOKEN; @@ -1566,18 +1567,18 @@ yy113: goto Plain2; } -#line 1569 "" +#line 1570 "" yy114: ++YYCURSOR; switch((yych = *YYCURSOR)) { case 0x0A: goto yy141; default: goto yy115; } yy115: -#line 626 "token.re" +#line 627 "token.re" { QUOTECATS(qstr, qcapa, qidx, YYTOKEN, YYCURSOR - YYTOKEN); goto Plain2; } -#line 1580 "" +#line 1581 "" yy116: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ @@ -1597,7 +1598,7 @@ yy117: yyaccept = 1; yy118: ++YYCURSOR; goto yy119; yy119: -#line 588 "token.re" +#line 589 "token.re" { if ( plvl->status != syck_lvl_imap ) { PLAIN_NOT_INL(); @@ -1608,11 +1609,11 @@ yy119: } RETURN_IMPLICIT(); } -#line 1611 "" +#line 1612 "" yy120: ++YYCURSOR; goto yy121; yy121: -#line 599 "token.re" +#line 600 "token.re" { if ( plvl->status != syck_lvl_iseq ) { PLAIN_NOT_INL(); @@ -1623,14 +1624,14 @@ yy121: } RETURN_IMPLICIT(); } -#line 1626 "" +#line 1627 "" yy122: ++YYCURSOR; switch((yych = *YYCURSOR)) { case '#': goto yy128; default: goto yy123; } yy123: -#line 616 "token.re" +#line 617 "token.re" { if ( qidx == 0 ) { goto Plain2; @@ -1640,13 +1641,13 @@ yy123: goto Plain3; } } -#line 1643 "" +#line 1644 "" yy124: ++YYCURSOR; goto yy125; yy125: -#line 614 "token.re" +#line 615 "token.re" { RETURN_IMPLICIT(); } -#line 1649 "" +#line 1650 "" yy126: yych = *++YYCURSOR; goto yy123; yy127: yych = *++YYCURSOR; @@ -1654,15 +1655,15 @@ yy127: yych = *++YYCURSOR; yy128: ++YYCURSOR; goto yy129; yy129: -#line 610 "token.re" +#line 611 "token.re" { eat_comments( parser ); RETURN_IMPLICIT(); } -#line 1661 "" +#line 1662 "" yy130: ++YYCURSOR; goto yy131; yy131: -#line 577 "token.re" +#line 578 "token.re" { if ( plvl->status != syck_lvl_iseq && plvl->status != syck_lvl_imap ) { PLAIN_NOT_INL(); @@ -1673,7 +1674,7 @@ yy131: } RETURN_IMPLICIT(); } -#line 1676 "" +#line 1677 "" yy132: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; @@ -1695,9 +1696,9 @@ yy135: YYCURSOR = YYMARKER; yy136: ++YYCURSOR; goto yy137; yy137: -#line 575 "token.re" +#line 576 "token.re" { RETURN_IMPLICIT(); } -#line 1700 "" +#line 1701 "" yy138: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; @@ -1729,7 +1730,7 @@ yy143: ++YYCURSOR; default: goto yy135; } } -#line 630 "token.re" +#line 631 "token.re" } @@ -1743,7 +1744,7 @@ SingleQuote2: YYTOKEN = YYCURSOR; -#line 1746 "" +#line 1747 "" { YYCTYPE yych; unsigned int yyaccept; @@ -1763,7 +1764,7 @@ yy146: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); goto yy157; yy147: -#line 644 "token.re" +#line 645 "token.re" { int indt_len; int nl_count = 0; SyckLevel *lvl; @@ -1803,25 +1804,25 @@ yy147: goto SingleQuote2; } -#line 1806 "" +#line 1807 "" yy148: ++YYCURSOR; switch((yych = *YYCURSOR)) { case 0x0A: goto yy156; default: goto yy149; } yy149: -#line 711 "token.re" +#line 712 "token.re" { QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1)); goto SingleQuote2; } -#line 1817 "" +#line 1818 "" yy150: ++YYCURSOR; switch((yych = *YYCURSOR)) { case '\'': goto yy154; default: goto yy151; } yy151: -#line 688 "token.re" +#line 689 "token.re" { SyckLevel *lvl; SyckNode *n = syck_alloc_str(); lvl = CURRENT_LEVEL(); @@ -1844,7 +1845,7 @@ yy151: sycklval->nodeData = n; return YAML_PLAIN; } -#line 1847 "" +#line 1848 "" yy152: yych = *++YYCURSOR; goto yy151; yy153: yych = *++YYCURSOR; @@ -1852,11 +1853,11 @@ yy153: yych = *++YYCURSOR; yy154: ++YYCURSOR; goto yy155; yy155: -#line 684 "token.re" +#line 685 "token.re" { QUOTECAT(qstr, qcapa, qidx, '\''); goto SingleQuote2; } -#line 1859 "" +#line 1860 "" yy156: yyaccept = 0; YYMARKER = ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -1879,7 +1880,7 @@ yy159: YYCURSOR = YYMARKER; case 0: goto yy147; } } -#line 715 "token.re" +#line 716 "token.re" } @@ -1897,7 +1898,7 @@ DoubleQuote2: -#line 1900 "" +#line 1901 "" { YYCTYPE yych; unsigned int yyaccept; @@ -1918,7 +1919,7 @@ yy162: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); goto yy184; yy163: -#line 733 "token.re" +#line 734 "token.re" { int indt_len; int nl_count = 0; SyckLevel *lvl; @@ -1962,18 +1963,18 @@ yy163: keep_nl = 1; goto DoubleQuote2; } -#line 1965 "" +#line 1966 "" yy164: ++YYCURSOR; switch((yych = *YYCURSOR)) { case 0x0A: goto yy183; default: goto yy165; } yy165: -#line 819 "token.re" +#line 820 "token.re" { QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1)); goto DoubleQuote2; } -#line 1976 "" +#line 1977 "" yy166: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ @@ -1989,7 +1990,7 @@ yy166: yyaccept = 1; yy167: ++YYCURSOR; goto yy168; yy168: -#line 796 "token.re" +#line 797 "token.re" { SyckLevel *lvl; SyckNode *n = syck_alloc_str(); lvl = CURRENT_LEVEL(); @@ -2012,7 +2013,7 @@ yy168: sycklval->nodeData = n; return YAML_PLAIN; } -#line 2015 "" +#line 2016 "" yy169: yych = *++YYCURSOR; goto yy168; yy170: yych = *++YYCURSOR; @@ -2035,12 +2036,12 @@ yy173: YYCURSOR = YYMARKER; yy174: ++YYCURSOR; goto yy175; yy175: -#line 791 "token.re" +#line 792 "token.re" { keep_nl = 0; YYCURSOR--; goto DoubleQuote2; } -#line 2043 "" +#line 2044 "" yy176: yych = *++YYCURSOR; switch(yych){ case 0x0A: goto yy174; @@ -2073,12 +2074,12 @@ yy177: yych = *++YYCURSOR; yy178: ++YYCURSOR; goto yy179; yy179: -#line 777 "token.re" +#line 778 "token.re" { char ch = *( YYCURSOR - 1 ); QUOTECAT(qstr, qcapa, qidx, escape_seq( ch )); goto DoubleQuote2; } -#line 2081 "" +#line 2082 "" yy180: yych = *++YYCURSOR; switch(yych){ case '0': @@ -2106,7 +2107,7 @@ yy180: yych = *++YYCURSOR; yy181: ++YYCURSOR; goto yy182; yy182: -#line 782 "token.re" +#line 783 "token.re" { long ch; char *chr_text = syck_strndup( YYTOKEN, 4 ); chr_text[0] = '0'; @@ -2115,7 +2116,7 @@ yy182: QUOTECAT(qstr, qcapa, qidx, ch); goto DoubleQuote2; } -#line 2118 "" +#line 2119 "" yy183: yyaccept = 0; YYMARKER = ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -2134,7 +2135,7 @@ yy185: ++YYCURSOR; default: goto yy173; } } -#line 823 "token.re" +#line 824 "token.re" } @@ -2148,7 +2149,7 @@ TransferMethod2: YYTOKTMP = YYCURSOR; -#line 2151 "" +#line 2152 "" { YYCTYPE yych; unsigned int yyaccept; @@ -2168,7 +2169,7 @@ yy186: yy188: ++YYCURSOR; goto yy189; yy189: -#line 837 "token.re" +#line 838 "token.re" { SyckLevel *lvl; YYCURSOR = YYTOKTMP; if ( YYCURSOR == YYTOKEN + 1 ) @@ -2218,7 +2219,7 @@ yy189: return YAML_TRANSFER; } -#line 2221 "" +#line 2222 "" yy190: yych = *++YYCURSOR; goto yy189; yy191: yych = *++YYCURSOR; @@ -2229,11 +2230,11 @@ yy192: ++YYCURSOR; default: goto yy193; } yy193: -#line 904 "token.re" +#line 905 "token.re" { QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1)); goto TransferMethod2; } -#line 2236 "" +#line 2237 "" yy194: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ @@ -2276,12 +2277,12 @@ yy197: YYCURSOR = YYMARKER; yy198: ++YYCURSOR; goto yy199; yy199: -#line 890 "token.re" +#line 891 "token.re" { char ch = *( YYCURSOR - 1 ); QUOTECAT(qstr, qcapa, qidx, escape_seq( ch )); goto TransferMethod2; } -#line 2284 "" +#line 2285 "" yy200: yych = *++YYCURSOR; switch(yych){ case '0': @@ -2309,7 +2310,7 @@ yy200: yych = *++YYCURSOR; yy201: ++YYCURSOR; goto yy202; yy202: -#line 895 "token.re" +#line 896 "token.re" { long ch; char *chr_text = syck_strndup( YYTOKTMP, 4 ); chr_text[0] = '0'; @@ -2318,7 +2319,7 @@ yy202: QUOTECAT(qstr, qcapa, qidx, ch); goto TransferMethod2; } -#line 2321 "" +#line 2322 "" yy203: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; @@ -2328,7 +2329,7 @@ yy204: switch(yych){ default: goto yy189; } } -#line 909 "token.re" +#line 910 "token.re" } @@ -2343,8 +2344,7 @@ ScalarBlock: int forceIndent = -1; char *yyt = YYTOKEN; SyckLevel *lvl = CURRENT_LEVEL(); - int parentIndent; - GET_TRUE_YAML_INDENT(parentIndent); + int parentIndent = -1; switch ( *yyt ) { @@ -2364,7 +2364,7 @@ ScalarBlock: } else if ( isdigit( *yyt ) ) { - forceIndent = strtol( yyt, NULL, 10 ) + parentIndent; + forceIndent = strtol( yyt, NULL, 10 ); } } @@ -2403,18 +2403,23 @@ yy208: 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 ) + if ( lvl->status != syck_lvl_block ) { - YYCURSOR = YYTOKEN; - RETURN_YAML_BLOCK(); + GET_TRUE_YAML_INDENT(parentIndent); + if ( forceIndent > 0 ) forceIndent += parentIndent; + if ( indt_len > parentIndent ) + { + 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 + { + YYCURSOR = YYTOKEN; + RETURN_YAML_BLOCK(); + } } /* @@ -2466,22 +2471,22 @@ yy208: } goto ScalarBlock2; } -#line 2469 "" +#line 2474 "" yy209: ++YYCURSOR; switch((yych = *YYCURSOR)) { case 0x0A: goto yy225; default: goto yy210; } yy210: -#line 1065 "token.re" +#line 1070 "token.re" { QUOTECAT(qstr, qcapa, qidx, *YYTOKEN); goto ScalarBlock2; } -#line 2480 "" +#line 2485 "" yy211: ++YYCURSOR; goto yy212; yy212: -#line 1027 "token.re" +#line 1032 "token.re" { lvl = CURRENT_LEVEL(); if ( lvl->status != syck_lvl_block ) { @@ -2494,16 +2499,16 @@ yy212: } goto ScalarBlock2; } -#line 2497 "" +#line 2502 "" yy213: ++YYCURSOR; goto yy214; yy214: -#line 1041 "token.re" +#line 1046 "token.re" { YYCURSOR--; POP_LEVEL(); RETURN_YAML_BLOCK(); } -#line 2506 "" +#line 2511 "" yy215: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ @@ -2532,7 +2537,7 @@ yy219: yych = *++YYCURSOR; yy220: ++YYCURSOR; goto yy221; yy221: -#line 1046 "token.re" +#line 1051 "token.re" { if ( YYTOKEN == YYLINEPTR ) { if ( blockType == BLOCK_FOLD && qidx > 0 ) @@ -2551,7 +2556,7 @@ yy221: goto ScalarBlock2; } } -#line 2554 "" +#line 2559 "" yy222: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; @@ -2583,7 +2588,7 @@ yy227: ++YYCURSOR; default: goto yy218; } } -#line 1070 "token.re" +#line 1075 "token.re" } @@ -2599,7 +2604,7 @@ Comment: YYTOKEN = YYCURSOR; -#line 2602 "" +#line 2607 "" { YYCTYPE yych; unsigned int yyaccept; @@ -2617,11 +2622,11 @@ yy228: yy230: ++YYCURSOR; goto yy231; yy231: -#line 1086 "token.re" +#line 1091 "token.re" { YYCURSOR = YYTOKEN; return; } -#line 2624 "" +#line 2629 "" yy232: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); goto yy237; @@ -2631,10 +2636,10 @@ yy233: ++YYCURSOR; default: goto yy234; } yy234: -#line 1090 "token.re" +#line 1095 "token.re" { goto Comment; } -#line 2637 "" +#line 2642 "" yy235: yych = *++YYCURSOR; goto yy234; yy236: yyaccept = 0; @@ -2659,7 +2664,7 @@ yy239: YYCURSOR = YYMARKER; case 0: goto yy231; } } -#line 1093 "token.re" +#line 1098 "token.re" } -- cgit v1.2.3