summaryrefslogtreecommitdiff
path: root/ext/syck/token.c
diff options
context:
space:
mode:
authorwhy <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-05-29 23:33:10 +0000
committerwhy <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-05-29 23:33:10 +0000
commit5d47fda3f8b7148087a866cfd3033ab185e492fd (patch)
tree26a0794e612989e8f2f8a02e69a1d651702c8d12 /ext/syck/token.c
parent4ca5e66ee793f0c8b7f96d4f82d813c8f98a26be (diff)
* ext/syck/handler.c, ext/syck/syck.h: removed syck_fold_format().
* ext/syck/gram.c: flexibility for aliases and anchors. * ext/syck/token.c: folding now handled in the tokenizer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3880 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/syck/token.c')
-rw-r--r--ext/syck/token.c537
1 files changed, 260 insertions, 277 deletions
diff --git a/ext/syck/token.c b/ext/syck/token.c
index 0a3f08fda70..e6bb1015f59 100644
--- a/ext/syck/token.c
+++ b/ext/syck/token.c
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.5 on Thu May 22 07:19:06 2003 */
+/* Generated by re2c 0.5 on Thu May 29 17:33:02 2003 */
#line 1 "token.re"
/*
* token.re
@@ -99,18 +99,30 @@
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(fold) \
+#define RETURN_IMPLICIT() \
{ \
SyckLevel *i_lvl = CURRENT_LEVEL(); \
+ SyckNode *n = syck_alloc_str(); \
YYCURSOR = YYTOKTMP; \
- yylval->nodeData = syck_new_str2( YYTOKEN, YYCURSOR - YYTOKEN ); \
- if ( fold ) { \
- syck_fold_format( yylval->nodeData->data.str, BLOCK_PLAIN, i_lvl->spaces, NL_CHOMP ); \
- } \
+ n->data.str->ptr = qstr; \
+ n->data.str->len = qidx; \
+ yylval->nodeData = n; \
if ( parser->implicit_typing == 1 ) \
{ \
try_tag_implicit( yylval->nodeData, parser->taguri_expansion ); \
@@ -119,6 +131,35 @@
}
/*
+ * Keep or chomp block?
+ * * Use only in "ScalarBlock" section *
+ */
+#define RETURN_BLOCK() \
+ { \
+ SyckNode *n = syck_alloc_str(); \
+ 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 ( *fc == '\n' ) fc--; \
+ if ( nlDoWhat != NL_CHOMP ) \
+ fc += 1; \
+ n->data.str->len = fc - n->data.str->ptr + 1; \
+ } \
+ else \
+ { \
+ n->data.str->ptr[n->data.str->len] = '\n'; \
+ n->data.str->len++; \
+ } \
+ } \
+ yylval->nodeData = n; \
+ return BLOCK; \
+ }
+
+/*
* Handles newlines, calculates indent
*/
#define GOBBLE_UP_INDENT( ict, start ) \
@@ -190,7 +231,7 @@ yylex( YYSTYPE *yylval, SyckParser *parser )
return t;
}
-#line 206
+#line 247
if ( YYLINEPTR != YYCURSOR )
@@ -224,19 +265,19 @@ yy2: yyaccept = 0;
default: goto yy3;
}
yy3:
-#line 247
+#line 288
{ YYPOS(0);
goto Document;
}
yy4: yych = *++YYCURSOR;
yy5:
-#line 233
+#line 274
{ eat_comments( parser );
goto Header;
}
yy6: yych = *++YYCURSOR;
yy7:
-#line 237
+#line 278
{ SyckLevel *lvl = CURRENT_LEVEL();
ENSURE_IEND(lvl, -1);
return 0;
@@ -244,7 +285,7 @@ yy7:
yy8: yych = *++YYCURSOR;
goto yy12;
yy9:
-#line 242
+#line 283
{ int indt_len;
GOBBLE_UP_INDENT( indt_len, YYTOKEN );
goto Header;
@@ -289,7 +330,7 @@ yy19: switch(yych){
default: goto yy20;
}
yy20:
-#line 219
+#line 260
{ SyckLevel *lvl = CURRENT_LEVEL();
if ( lvl->status == syck_lvl_header )
{
@@ -311,7 +352,7 @@ yy22: switch(yych){
default: goto yy20;
}
}
-#line 251
+#line 292
Document:
@@ -352,7 +393,7 @@ yy23:
yy25: yych = *++YYCURSOR;
goto yy77;
yy26:
-#line 265
+#line 306
{ // Isolate spaces
int indt_len;
GOBBLE_UP_INDENT( indt_len, YYTOKEN );
@@ -369,7 +410,7 @@ yy26:
}
yy27: yych = *++YYCURSOR;
yy28:
-#line 280
+#line 321
{ ENSURE_IOPEN(lvl, 0, 1);
lvl = CURRENT_LEVEL();
ADD_LEVEL(lvl->spaces + 1, syck_lvl_inline);
@@ -377,7 +418,7 @@ yy28:
}
yy29: yych = *++YYCURSOR;
yy30:
-#line 286
+#line 327
{ POP_LEVEL();
return YYTOKEN[0];
}
@@ -388,7 +429,7 @@ yy31: yych = *++YYCURSOR;
default: goto yy32;
}
yy32:
-#line 338
+#line 385
{ ENSURE_IOPEN(lvl, 0, 1);
goto Plain;
}
@@ -400,9 +441,7 @@ yy33: yych = *++YYCURSOR;
}
yy34: yych = *++YYCURSOR;
switch(yych){
- case '.':
- case '/':
- case '0':
+ case '-': case '0':
case '1':
case '2':
case '3':
@@ -411,15 +450,7 @@ yy34: yych = *++YYCURSOR;
case '6':
case '7':
case '8':
- case '9':
- case ':':
- case ';':
- case '<':
- case '=':
- case '>':
- case '?':
- case '@':
- case 'A':
+ case '9': case 'A':
case 'B':
case 'C':
case 'D':
@@ -444,12 +475,7 @@ yy34: yych = *++YYCURSOR;
case 'W':
case 'X':
case 'Y':
- case 'Z':
- case '[':
- case '\\':
- case ']':
- case '^':
- case '_': case 'a':
+ case 'Z': case '_': case 'a':
case 'b':
case 'c':
case 'd':
@@ -479,9 +505,7 @@ yy34: yych = *++YYCURSOR;
}
yy35: yych = *++YYCURSOR;
switch(yych){
- case '.':
- case '/':
- case '0':
+ case '-': case '0':
case '1':
case '2':
case '3':
@@ -490,15 +514,7 @@ yy35: yych = *++YYCURSOR;
case '6':
case '7':
case '8':
- case '9':
- case ':':
- case ';':
- case '<':
- case '=':
- case '>':
- case '?':
- case '@':
- case 'A':
+ case '9': case 'A':
case 'B':
case 'C':
case 'D':
@@ -523,12 +539,7 @@ yy35: yych = *++YYCURSOR;
case 'W':
case 'X':
case 'Y':
- case 'Z':
- case '[':
- case '\\':
- case ']':
- case '^':
- case '_': case 'a':
+ case 'Z': case '_': case 'a':
case 'b':
case 'c':
case 'd':
@@ -558,17 +569,17 @@ yy35: yych = *++YYCURSOR;
}
yy36: yych = *++YYCURSOR;
yy37:
-#line 312
+#line 359
{ ENSURE_IOPEN(lvl, 0, 1);
goto TransferMethod; }
yy38: yych = *++YYCURSOR;
yy39:
-#line 315
+#line 362
{ ENSURE_IOPEN(lvl, 0, 1);
goto SingleQuote; }
yy40: yych = *++YYCURSOR;
yy41:
-#line 318
+#line 365
{ ENSURE_IOPEN(lvl, 0, 1);
goto DoubleQuote; }
yy42: yyaccept = 0;
@@ -590,18 +601,18 @@ yy42: yyaccept = 0;
}
yy43: yych = *++YYCURSOR;
yy44:
-#line 328
+#line 375
{ eat_comments( parser );
goto Document;
}
yy45: yych = *++YYCURSOR;
goto yy51;
yy46:
-#line 332
+#line 379
{ goto Document; }
yy47: yych = *++YYCURSOR;
yy48:
-#line 334
+#line 381
{ ENSURE_IEND(lvl, -1);
return 0;
}
@@ -644,7 +655,7 @@ yy56: switch(yych){
default: goto yy57;
}
yy57:
-#line 321
+#line 368
{ if ( *( YYCURSOR - 1 ) == '\n' )
{
YYCURSOR--;
@@ -662,9 +673,7 @@ yy60: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy61: switch(yych){
- case '.':
- case '/':
- case '0':
+ case '-': case '0':
case '1':
case '2':
case '3':
@@ -673,15 +682,7 @@ yy61: switch(yych){
case '6':
case '7':
case '8':
- case '9':
- case ':':
- case ';':
- case '<':
- case '=':
- case '>':
- case '?':
- case '@':
- case 'A':
+ case '9': case 'A':
case 'B':
case 'C':
case 'D':
@@ -706,12 +707,7 @@ yy61: switch(yych){
case 'W':
case 'X':
case 'Y':
- case 'Z':
- case '[':
- case '\\':
- case ']':
- case '^':
- case '_': case 'a':
+ case 'Z': case '_': case 'a':
case 'b':
case 'c':
case 'd':
@@ -740,17 +736,16 @@ yy61: switch(yych){
default: goto yy62;
}
yy62:
-#line 308
- { yylval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 );
+#line 354
+ { ENSURE_IOPEN(lvl, 0, 1);
+ yylval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 );
return ALIAS;
}
yy63: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy64: switch(yych){
- case '.':
- case '/':
- case '0':
+ case '-': case '0':
case '1':
case '2':
case '3':
@@ -759,15 +754,7 @@ yy64: switch(yych){
case '6':
case '7':
case '8':
- case '9':
- case ':':
- case ';':
- case '<':
- case '=':
- case '>':
- case '?':
- case '@':
- case 'A':
+ case '9': case 'A':
case 'B':
case 'C':
case 'D':
@@ -792,12 +779,7 @@ yy64: switch(yych){
case 'W':
case 'X':
case 'Y':
- case 'Z':
- case '[':
- case '\\':
- case ']':
- case '^':
- case '_': case 'a':
+ case 'Z': case '_': case 'a':
case 'b':
case 'c':
case 'd':
@@ -826,8 +808,9 @@ yy64: switch(yych){
default: goto yy65;
}
yy65:
-#line 304
- { yylval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 );
+#line 349
+ { ENSURE_IOPEN(lvl, 0, 1);
+ yylval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 );
return ANCHOR;
}
yy66: ++YYCURSOR;
@@ -838,14 +821,18 @@ yy67: switch(yych){
default: goto yy68;
}
yy68:
-#line 294
+#line 335
{ ENSURE_IOPEN(lvl, YYTOKEN - YYLINEPTR, 1);
FORCE_NEXT_TOKEN(IOPEN);
- if ( *( YYCURSOR - 1 ) == '\n' )
+ if ( *YYCURSOR == '\n' || *( YYCURSOR - 1 ) == '\n' )
{
YYCURSOR--;
+ ADD_LEVEL((YYTOKEN + 1) - YYLINEPTR, syck_lvl_doc);
+ }
+ else
+ {
+ ADD_LEVEL(YYCURSOR - YYLINEPTR, syck_lvl_doc);
}
- ADD_LEVEL(YYCURSOR - YYLINEPTR, syck_lvl_doc);
return YYTOKEN[0];
}
yy69: ++YYCURSOR;
@@ -863,7 +850,7 @@ yy72: switch(yych){
default: goto yy73;
}
yy73:
-#line 290
+#line 331
{ YYPOS(1);
return YYTOKEN[0];
}
@@ -890,7 +877,7 @@ yy79: switch(yych){
default: goto yy26;
}
}
-#line 342
+#line 389
}
@@ -919,9 +906,7 @@ yy82: YYCURSOR = YYMARKER;
yy83: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
switch(yych){
- case '.':
- case '/':
- case '0':
+ case '-': case '0':
case '1':
case '2':
case '3':
@@ -930,15 +915,7 @@ yy83: yyaccept = 0;
case '6':
case '7':
case '8':
- case '9':
- case ':':
- case ';':
- case '<':
- case '=':
- case '>':
- case '?':
- case '@':
- case 'A':
+ case '9': case 'A':
case 'B':
case 'C':
case 'D':
@@ -963,12 +940,7 @@ yy83: yyaccept = 0;
case 'W':
case 'X':
case 'Y':
- case 'Z':
- case '[':
- case '\\':
- case ']':
- case '^':
- case '_': case 'a':
+ case 'Z': case '_': case 'a':
case 'b':
case 'c':
case 'd':
@@ -997,14 +969,14 @@ yy83: yyaccept = 0;
default: goto yy84;
}
yy84:
-#line 355
+#line 402
{ YYCURSOR = YYTOKTMP;
return DOCSEP;
}
yy85: yych = *++YYCURSOR;
goto yy89;
yy86:
-#line 353
+#line 400
{ goto Directive; }
yy87: yych = *++YYCURSOR;
goto yy84;
@@ -1019,9 +991,7 @@ yy90: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy91: switch(yych){
- case '.':
- case '/':
- case '0':
+ case '-': case '0':
case '1':
case '2':
case '3':
@@ -1030,13 +1000,7 @@ yy91: switch(yych){
case '6':
case '7':
case '8':
- case '9': case ';':
- case '<':
- case '=':
- case '>':
- case '?':
- case '@':
- case 'A':
+ case '9': case 'A':
case 'B':
case 'C':
case 'D':
@@ -1061,12 +1025,7 @@ yy91: switch(yych){
case 'W':
case 'X':
case 'Y':
- case 'Z':
- case '[':
- case '\\':
- case ']':
- case '^':
- case '_': case 'a':
+ case 'Z': case '_': case 'a':
case 'b':
case 'c':
case 'd':
@@ -1097,9 +1056,7 @@ yy91: switch(yych){
}
yy92: yych = *++YYCURSOR;
switch(yych){
- case '.':
- case '/':
- case '0':
+ case '-': case '0':
case '1':
case '2':
case '3':
@@ -1108,15 +1065,7 @@ yy92: yych = *++YYCURSOR;
case '6':
case '7':
case '8':
- case '9':
- case ':':
- case ';':
- case '<':
- case '=':
- case '>':
- case '?':
- case '@':
- case 'A':
+ case '9': case 'A':
case 'B':
case 'C':
case 'D':
@@ -1141,12 +1090,7 @@ yy92: yych = *++YYCURSOR;
case 'W':
case 'X':
case 'Y':
- case 'Z':
- case '[':
- case '\\':
- case ']':
- case '^':
- case '_': case 'a':
+ case 'Z': case '_': case 'a':
case 'b':
case 'c':
case 'd':
@@ -1178,9 +1122,7 @@ yy93: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy94: switch(yych){
- case '.':
- case '/':
- case '0':
+ case '-': case '0':
case '1':
case '2':
case '3':
@@ -1189,15 +1131,7 @@ yy94: switch(yych){
case '6':
case '7':
case '8':
- case '9':
- case ':':
- case ';':
- case '<':
- case '=':
- case '>':
- case '?':
- case '@':
- case 'A':
+ case '9': case 'A':
case 'B':
case 'C':
case 'D':
@@ -1222,12 +1156,7 @@ yy94: switch(yych){
case 'W':
case 'X':
case 'Y':
- case 'Z':
- case '[':
- case '\\':
- case ']':
- case '^':
- case '_': case 'a':
+ case 'Z': case '_': case 'a':
case 'b':
case 'c':
case 'd':
@@ -1256,19 +1185,22 @@ yy94: switch(yych){
default: goto yy95;
}
yy95:
-#line 351
+#line 398
{ goto Directive; }
}
-#line 358
+#line 405
}
Plain:
{
+ int qidx = 0;
+ int qcapa = 100;
+ char *qstr = S_ALLOC_N( char, qcapa );
SyckLevel *plvl;
int parentIndent;
- int multiLine = 0;
+
YYCURSOR = YYTOKEN;
plvl = CURRENT_LEVEL();
GET_TRUE_INDENT(parentIndent);
@@ -1287,9 +1219,9 @@ yy96:
if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
yych = *YYCURSOR;
switch(yych){
- case '\000': goto yy105;
+ case '\000': goto yy107;
case '\n': goto yy98;
- case ' ': goto yy107;
+ case ' ': goto yy105;
case ',': goto yy104;
case ':': goto yy100;
case ']': case '}': goto yy102;
@@ -1298,8 +1230,8 @@ yy96:
yy98: yych = *++YYCURSOR;
goto yy122;
yy99:
-#line 378
- { int indt_len;
+#line 428
+ { int indt_len, nl_count = 0;
SyckLevel *lvl;
char *tok = YYTOKTMP;
GOBBLE_UP_INDENT( indt_len, tok );
@@ -1307,10 +1239,27 @@ yy99:
if ( indt_len <= parentIndent )
{
- RETURN_IMPLICIT(multiLine);
+ RETURN_IMPLICIT();
+ }
+
+ while ( YYTOKTMP < YYCURSOR )
+ {
+ if ( *YYTOKTMP++ == '\n' )
+ 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');
+ }
}
- multiLine = 1;
goto Plain2;
}
yy100: yych = *++YYCURSOR;
@@ -1320,13 +1269,20 @@ yy100: yych = *++YYCURSOR;
default: goto yy101;
}
yy101:
-#line 407
- { goto Plain2; }
+#line 479
+ { QUOTECATS(qstr, qcapa, qidx, YYTOKTMP, YYCURSOR - YYTOKTMP);
+ goto Plain2;
+ }
yy102: yych = *++YYCURSOR;
yy103:
-#line 395
- { if ( plvl->status != syck_lvl_inline ) goto Plain2;
- RETURN_IMPLICIT(multiLine);
+#line 462
+ { if ( plvl->status != syck_lvl_inline )
+ {
+ YYCURSOR--;
+ QUOTECATS(qstr, qcapa, qidx, YYTOKTMP, YYCURSOR - YYTOKTMP);
+ goto Plain2;
+ }
+ RETURN_IMPLICIT();
}
yy104: yych = *++YYCURSOR;
switch(yych){
@@ -1335,24 +1291,24 @@ yy104: yych = *++YYCURSOR;
default: goto yy101;
}
yy105: yych = *++YYCURSOR;
-yy106:
-#line 399
- { RETURN_IMPLICIT(multiLine); }
-yy107: yych = *++YYCURSOR;
switch(yych){
case '#': goto yy110;
- default: goto yy108;
+ default: goto yy106;
}
-yy108:
-#line 405
+yy106:
+#line 477
{ goto Plain3; }
+yy107: yych = *++YYCURSOR;
+yy108:
+#line 475
+ { RETURN_IMPLICIT(); }
yy109: yych = *++YYCURSOR;
goto yy101;
yy110: yych = *++YYCURSOR;
yy111:
-#line 401
+#line 471
{ eat_comments( parser );
- RETURN_IMPLICIT(multiLine);
+ RETURN_IMPLICIT();
}
yy112: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
@@ -1376,8 +1332,8 @@ yy117: switch(yych){
default: goto yy118;
}
yy118:
-#line 393
- { RETURN_IMPLICIT(multiLine); }
+#line 460
+ { RETURN_IMPLICIT(); }
yy119: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
@@ -1401,7 +1357,7 @@ yy124: switch(yych){
default: goto yy99;
}
}
-#line 409
+#line 483
}
@@ -1431,7 +1387,7 @@ yy125:
yy127: yych = *++YYCURSOR;
goto yy137;
yy128:
-#line 423
+#line 497
{ int indt_len;
int nl_count = 0;
SyckLevel *lvl;
@@ -1473,7 +1429,7 @@ yy129: yych = *++YYCURSOR;
default: goto yy130;
}
yy130:
-#line 463
+#line 537
{ SyckLevel *lvl;
SyckNode *n = syck_alloc_str();
lvl = CURRENT_LEVEL();
@@ -1491,13 +1447,13 @@ yy131: yych = *++YYCURSOR;
goto yy130;
yy132: yych = *++YYCURSOR;
yy133:
-#line 477
+#line 551
{ QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1));
goto SingleQuote2;
}
yy134: yych = *++YYCURSOR;
yy135:
-#line 459
+#line 533
{ QUOTECAT(qstr, qcapa, qidx, '\'');
goto SingleQuote2;
}
@@ -1517,7 +1473,7 @@ yy139: switch(yych){
default: goto yy128;
}
}
-#line 481
+#line 555
}
@@ -1552,7 +1508,7 @@ yy140:
yy142: yych = *++YYCURSOR;
goto yy158;
yy143:
-#line 499
+#line 573
{ int indt_len;
int nl_count = 0;
SyckLevel *lvl;
@@ -1603,13 +1559,13 @@ yy144: yyaccept = 0;
default: goto yy145;
}
yy145:
-#line 574
+#line 648
{ QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1));
goto DoubleQuote2;
}
yy146: yych = *++YYCURSOR;
yy147:
-#line 560
+#line 634
{ SyckLevel *lvl;
SyckNode *n = syck_alloc_str();
lvl = CURRENT_LEVEL();
@@ -1641,15 +1597,15 @@ yy152: YYCURSOR = YYMARKER;
}
yy153: yych = *++YYCURSOR;
yy154:
-#line 555
+#line 629
{ keep_nl = 0;
YYCURSOR--;
goto DoubleQuote2;
}
yy155: yych = *++YYCURSOR;
yy156:
-#line 539
- { char ch = *( YYCURSOR - 1 );
+#line 613
+ { char ch = *( YYCURSOR - 1 );
switch ( ch )
{
case 'a': ch = 7; break;
@@ -1680,7 +1636,7 @@ yy160: switch(yych){
default: goto yy143;
}
}
-#line 578
+#line 652
}
@@ -1705,7 +1661,7 @@ yy161:
yy163:yy164: yych = *++YYCURSOR;
goto yy172;
yy165:
-#line 587
+#line 661
{ SyckLevel *lvl;
YYCURSOR = YYTOKTMP;
if ( YYCURSOR == YYTOKEN + 1 )
@@ -1755,7 +1711,7 @@ yy166: yych = *++YYCURSOR;
goto yy170;
yy167: yych = *++YYCURSOR;
yy168:
-#line 633
+#line 707
{ goto TransferMethod; }
yy169: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
@@ -1772,14 +1728,19 @@ yy172: switch(yych){
default: goto yy165;
}
}
-#line 635
+#line 709
}
ScalarBlock:
{
+ int keep_nl = 1;
+ 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();
@@ -1808,6 +1769,7 @@ ScalarBlock:
}
}
+ qstr[0] = '\0';
YYTOKEN = YYCURSOR;
ScalarBlock2:
@@ -1824,85 +1786,106 @@ yy173:
switch(yych){
case '\000': goto yy177;
case '\n': goto yy175;
- case '#': goto yy179;
- default: goto yy181;
+ default: goto yy179;
}
yy175: yych = *++YYCURSOR;
- goto yy184;
+ goto yy182;
yy176:
-#line 677
- { int indt_len;
- GOBBLE_UP_INDENT( indt_len, YYTOKTMP );
+#line 757
+ { char *pacer;
+ char *tok = YYTOKTMP;
+ int indt_len = 0, nl_count = 0, fold_nl = 0;
+ GOBBLE_UP_INDENT( indt_len, tok );
lvl = CURRENT_LEVEL();
if ( indt_len > parentIndent && lvl->status != syck_lvl_block )
{
ADD_LEVEL( forceIndent > 0 ? forceIndent : indt_len, syck_lvl_block );
+ goto ScalarBlock2;
}
lvl = CURRENT_LEVEL();
if ( lvl->status != syck_lvl_block )
{
- yylval->nodeData = syck_new_str2( YYTOKEN, 0 );
YYCURSOR = YYTOKTMP;
- return BLOCK;
+ RETURN_BLOCK();
}
- else if ( indt_len < lvl->spaces )
+
+ //
+ // Fold only in the event of two lines being on the leftmost
+ // indentation.
+ //
+ if ( blockType == BLOCK_FOLD && lastIndent == 0 && ( indt_len - lvl->spaces ) == 0 )
{
- YYCURSOR--;
- yylval->nodeData = syck_new_str2( YYTOKEN, YYCURSOR - YYTOKEN );
- syck_fold_format( yylval->nodeData->data.str, blockType, lvl->spaces, nlDoWhat );
- if ( lvl->status == syck_lvl_block )
+ fold_nl = 1;
+ }
+
+ pacer = YYTOKTMP;
+ while ( pacer < YYCURSOR )
+ {
+ if ( *pacer++ == '\n' )
+ nl_count++;
+ }
+
+ if ( fold_nl == 1 )
+ {
+ nl_count--;
+ }
+
+ if ( nl_count < 1 )
+ {
+ QUOTECAT(qstr, qcapa, qidx, ' ');
+ }
+ else
+ {
+ int i;
+ for ( i = 0; i < nl_count; i++ )
{
- POP_LEVEL();
+ QUOTECAT(qstr, qcapa, qidx, '\n');
}
+ }
+
+ lastIndent = indt_len - lvl->spaces;
+ YYCURSOR -= lastIndent;
+
+ if ( indt_len < lvl->spaces )
+ {
+ POP_LEVEL();
YYCURSOR = YYTOKTMP;
- return BLOCK;
+ RETURN_BLOCK();
}
goto ScalarBlock2;
}
yy177: yych = *++YYCURSOR;
yy178:
-#line 709
- { lvl = CURRENT_LEVEL();
- YYCURSOR--;
- yylval->nodeData = syck_new_str2( YYTOKEN, YYCURSOR - YYTOKEN );
- syck_fold_format( yylval->nodeData->data.str, blockType, lvl->spaces, nlDoWhat );
+#line 823
+ { YYCURSOR--;
POP_LEVEL();
- return BLOCK;
+ RETURN_BLOCK();
}
yy179: yych = *++YYCURSOR;
yy180:
-#line 717
- { lvl = CURRENT_LEVEL();
- if ( lvl->status != syck_lvl_block )
- {
- eat_comments( parser );
- YYTOKEN = YYCURSOR;
- }
+#line 828
+ { QUOTECAT(qstr, qcapa, qidx, *YYTOKTMP);
goto ScalarBlock2;
}
-yy181: yych = *++YYCURSOR;
-yy182:
-#line 726
- { goto ScalarBlock2; }
-yy183: ++YYCURSOR;
+yy181: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
-yy184: switch(yych){
- case '\n': goto yy183;
- case ' ': goto yy185;
+yy182: switch(yych){
+ case '\n': goto yy181;
+ case ' ': goto yy183;
default: goto yy176;
}
-yy185: ++YYCURSOR;
+yy183: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
-yy186: switch(yych){
- case '\n': case ' ': goto yy185;
+yy184: switch(yych){
+ case '\n': case ' ': goto yy183;
default: goto yy176;
}
}
-#line 728
+#line 833
}
@@ -1920,39 +1903,39 @@ Comment:
{
YYCTYPE yych;
unsigned int yyaccept;
- goto yy187;
-yy188: ++YYCURSOR;
-yy187:
+ goto yy185;
+yy186: ++YYCURSOR;
+yy185:
if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
yych = *YYCURSOR;
switch(yych){
- case '\000': goto yy189;
- case '\n': goto yy191;
- default: goto yy192;
+ case '\000': goto yy187;
+ case '\n': goto yy189;
+ default: goto yy190;
}
-yy189: yych = *++YYCURSOR;
-yy190:
-#line 744
+yy187: yych = *++YYCURSOR;
+yy188:
+#line 849
{ SyckLevel *lvl = CURRENT_LEVEL();
YYCURSOR = tok;
return;
}
-yy191: yych = *++YYCURSOR;
- goto yy195;
-yy192: yych = *++YYCURSOR;
-yy193:
-#line 749
+yy189: yych = *++YYCURSOR;
+ goto yy193;
+yy190: yych = *++YYCURSOR;
+yy191:
+#line 854
{ goto Comment;
}
-yy194: ++YYCURSOR;
+yy192: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
-yy195: switch(yych){
- case '\n': goto yy194;
- default: goto yy190;
+yy193: switch(yych){
+ case '\n': goto yy192;
+ default: goto yy188;
}
}
-#line 752
+#line 857
}