summaryrefslogtreecommitdiff
path: root/ext/syck/token.c
diff options
context:
space:
mode:
authorwhy <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-07-24 16:30:43 +0000
committerwhy <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-07-24 16:30:43 +0000
commit4d859f926a2bacd21f06630ff185da3d09a1a314 (patch)
tree02194bf8491c84894172a7156ffcfb088bff5181 /ext/syck/token.c
parentc37d8b287e63815e09c82f4fb9bc63dca6193489 (diff)
* ext/syck/emitter.c (syck_emitter_flush): accepts count
of bytes to flush. anchor offsets now functional. * ext/syck/syck.h (syck_emitter_flush): ditto. * ext/syck/rubyext.c: ditto. * ext/syck/token.c: URI escaping now supported. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/syck/token.c')
-rw-r--r--ext/syck/token.c267
1 files changed, 174 insertions, 93 deletions
diff --git a/ext/syck/token.c b/ext/syck/token.c
index 03ab1965103..bec1e7bb5b9 100644
--- a/ext/syck/token.c
+++ b/ext/syck/token.c
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.5 on Sun Jun 15 16:14:26 2003 */
+/* Generated by re2c 0.5 on Thu Jul 24 10:01:15 2003 */
#line 1 "token.re"
/*
* token.re
@@ -1685,7 +1685,7 @@ yy153:
}
else if ( indt_len < lvl->spaces )
{
- /* Error! */
+ /* FIXME */
}
if ( keep_nl == 1 )
@@ -1880,6 +1880,11 @@ yy175: ++YYCURSOR;
TransferMethod:
{
+ int qidx = 0;
+ int qcapa = 100;
+ char *qstr = S_ALLOC_N( char, qcapa );
+
+TransferMethod2:
YYTOKTMP = YYCURSOR;
{
@@ -1888,22 +1893,28 @@ TransferMethod:
goto yy176;
yy177: ++YYCURSOR;
yy176:
- if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
+ if((YYLIMIT - YYCURSOR) < 4) YYFILL(4);
yych = *YYCURSOR;
switch(yych){
case '\000': goto yy178;
case '\n': goto yy179;
case '\r': goto yy182;
case ' ': goto yy181;
- default: goto yy184;
+ case '\\': goto yy184;
+ default: goto yy185;
+ }
+yy178: YYCURSOR = YYMARKER;
+ switch(yyaccept){
+ case 0: goto yy183;
}
-yy178:yy179: yych = *++YYCURSOR;
+yy179: yych = *++YYCURSOR;
yy180:
-#line 694
+#line 699
{ SyckLevel *lvl;
YYCURSOR = YYTOKTMP;
if ( YYCURSOR == YYTOKEN + 1 )
{
+ free( qstr );
return ITRANSFER;
}
@@ -1912,62 +1923,132 @@ yy180:
/*
* URL Prefixing
*/
- if ( *(YYTOKEN + 1) == '^' )
+ if ( *qstr == '^' )
{
- yylval->name = S_ALLOC_N( char, ( YYCURSOR - YYTOKEN ) + strlen( lvl->domain ) );
+ yylval->name = S_ALLOC_N( char, qidx + strlen( lvl->domain ) );
yylval->name[0] = '\0';
strcat( yylval->name, lvl->domain );
- strncat( yylval->name, YYTOKEN + 2, ( YYCURSOR - YYTOKEN ) - 2 );
+ strncat( yylval->name, qstr + 1, qidx - 1 );
+ free( qstr );
}
else
{
- char *carat = YYTOKEN;
- while ( (++carat) < YYCURSOR )
+ char *carat = qstr;
+ char *qend = qstr + qidx;
+ while ( (++carat) < qend )
{
if ( *carat == '^' )
break;
}
- if ( carat < YYCURSOR )
+ if ( carat < qend )
{
free( lvl->domain );
- lvl->domain = syck_strndup( YYTOKEN + 1, ( carat - YYTOKEN ) - 1 );
- yylval->name = S_ALLOC_N( char, ( YYCURSOR - carat ) + strlen( lvl->domain ) );
+ lvl->domain = syck_strndup( qstr, carat - qstr );
+ yylval->name = S_ALLOC_N( char, ( qend - carat ) + strlen( lvl->domain ) );
yylval->name[0] = '\0';
strcat( yylval->name, lvl->domain );
- strncat( yylval->name, carat + 1, ( YYCURSOR - carat ) - 1 );
+ strncat( yylval->name, carat + 1, ( qend - carat ) - 1 );
+ free( qstr );
}
else
{
- yylval->name = syck_strndup( YYTOKEN + 1, ( YYCURSOR - YYTOKEN ) - 1 );
+ yylval->name = qstr;
}
}
return TRANSFER;
}
yy181: yych = *++YYCURSOR;
- goto yy187;
+ goto yy192;
yy182: yych = *++YYCURSOR;
switch(yych){
- case '\n': goto yy185;
+ case '\n': goto yy190;
default: goto yy183;
}
yy183:
-#line 740
- { goto TransferMethod; }
-yy184: yych = *++YYCURSOR;
- goto yy183;
+#line 761
+ { QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1));
+ goto TransferMethod2;
+ }
+yy184: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case 'x': goto yy186;
+ default: goto yy183;
+ }
yy185: yych = *++YYCURSOR;
+ goto yy183;
+yy186: 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 yy187;
+ default: goto yy178;
+ }
+yy187: 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 yy188;
+ default: goto yy178;
+ }
+yy188: yych = *++YYCURSOR;
+yy189:
+#line 752
+ { 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;
+ }
+yy190: yych = *++YYCURSOR;
goto yy180;
-yy186: ++YYCURSOR;
+yy191: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
-yy187: switch(yych){
- case ' ': goto yy186;
+yy192: switch(yych){
+ case ' ': goto yy191;
default: goto yy180;
}
}
-#line 742
+#line 766
}
@@ -2017,23 +2098,23 @@ ScalarBlock2:
{
YYCTYPE yych;
unsigned int yyaccept;
- goto yy188;
-yy189: ++YYCURSOR;
-yy188:
+ goto yy193;
+yy194: ++YYCURSOR;
+yy193:
if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
yych = *YYCURSOR;
switch(yych){
- case '\000': goto yy196;
- case '\n': goto yy190;
- case '\r': goto yy192;
- case '#': goto yy194;
- default: goto yy198;
+ case '\000': goto yy201;
+ case '\n': goto yy195;
+ case '\r': goto yy197;
+ case '#': goto yy199;
+ default: goto yy203;
}
-yy190: yyaccept = 0;
+yy195: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
- goto yy200;
-yy191:
-#line 790
+ goto yy205;
+yy196:
+#line 814
{ char *pacer;
char *tok = YYTOKTMP;
int indt_len = 0, nl_count = 0, fold_nl = 0, nl_begin = 0;
@@ -2099,19 +2180,19 @@ yy191:
}
goto ScalarBlock2;
}
-yy192: yych = *++YYCURSOR;
+yy197: yych = *++YYCURSOR;
switch(yych){
- case '\n': goto yy199;
- default: goto yy193;
+ case '\n': goto yy204;
+ default: goto yy198;
}
-yy193:
-#line 876
+yy198:
+#line 900
{ QUOTECAT(qstr, qcapa, qidx, *YYTOKTMP);
goto ScalarBlock2;
}
-yy194: yych = *++YYCURSOR;
-yy195:
-#line 857
+yy199: yych = *++YYCURSOR;
+yy200:
+#line 881
{ lvl = CURRENT_LEVEL();
if ( lvl->status != syck_lvl_block )
{
@@ -2124,37 +2205,37 @@ yy195:
}
goto ScalarBlock2;
}
-yy196: yych = *++YYCURSOR;
-yy197:
-#line 871
+yy201: yych = *++YYCURSOR;
+yy202:
+#line 895
{ YYCURSOR--;
POP_LEVEL();
RETURN_BLOCK();
}
-yy198: yych = *++YYCURSOR;
- goto yy193;
-yy199: yyaccept = 0;
+yy203: yych = *++YYCURSOR;
+ goto yy198;
+yy204: yyaccept = 0;
YYMARKER = ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
-yy200: switch(yych){
- case '\n': case ' ': goto yy199;
- case '\r': goto yy201;
- default: goto yy191;
+yy205: switch(yych){
+ case '\n': case ' ': goto yy204;
+ case '\r': goto yy206;
+ default: goto yy196;
}
-yy201: ++YYCURSOR;
+yy206: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
switch(yych){
- case '\n': goto yy199;
- default: goto yy202;
+ case '\n': goto yy204;
+ default: goto yy207;
}
-yy202: YYCURSOR = YYMARKER;
+yy207: YYCURSOR = YYMARKER;
switch(yyaccept){
- case 0: goto yy191;
+ case 0: goto yy196;
}
}
-#line 881
+#line 905
}
@@ -2172,60 +2253,60 @@ Comment:
{
YYCTYPE yych;
unsigned int yyaccept;
- goto yy203;
-yy204: ++YYCURSOR;
-yy203:
+ goto yy208;
+yy209: ++YYCURSOR;
+yy208:
if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
yych = *YYCURSOR;
switch(yych){
- case '\000': goto yy205;
- case '\n': goto yy207;
- case '\r': goto yy208;
- default: goto yy210;
- }
-yy205: yych = *++YYCURSOR;
-yy206:
-#line 897
+ case '\000': goto yy210;
+ case '\n': goto yy212;
+ case '\r': goto yy213;
+ default: goto yy215;
+ }
+yy210: yych = *++YYCURSOR;
+yy211:
+#line 921
{ SyckLevel *lvl = CURRENT_LEVEL();
YYCURSOR = tok;
return;
}
-yy207: yyaccept = 0;
+yy212: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
- goto yy212;
-yy208: yych = *++YYCURSOR;
+ goto yy217;
+yy213: yych = *++YYCURSOR;
switch(yych){
- case '\n': goto yy211;
- default: goto yy209;
+ case '\n': goto yy216;
+ default: goto yy214;
}
-yy209:
-#line 902
+yy214:
+#line 926
{ goto Comment;
}
-yy210: yych = *++YYCURSOR;
- goto yy209;
-yy211: yyaccept = 0;
+yy215: yych = *++YYCURSOR;
+ goto yy214;
+yy216: yyaccept = 0;
YYMARKER = ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
-yy212: switch(yych){
- case '\n': goto yy211;
- case '\r': goto yy213;
- default: goto yy206;
+yy217: switch(yych){
+ case '\n': goto yy216;
+ case '\r': goto yy218;
+ default: goto yy211;
}
-yy213: ++YYCURSOR;
+yy218: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
switch(yych){
- case '\n': goto yy211;
- default: goto yy214;
+ case '\n': goto yy216;
+ default: goto yy219;
}
-yy214: YYCURSOR = YYMARKER;
+yy219: YYCURSOR = YYMARKER;
switch(yyaccept){
- case 0: goto yy206;
+ case 0: goto yy211;
}
}
-#line 905
+#line 929
}