summaryrefslogtreecommitdiff
path: root/ext/syck/token.c
diff options
context:
space:
mode:
authorwhy <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-05-13 06:34:18 +0000
committerwhy <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-05-13 06:34:18 +0000
commitbd810795c589a81e8939b53ad921f823e7133ee9 (patch)
tree5c96a98d2d411fd2f8324791db1977423fc1e14c /ext/syck/token.c
parentcea30a129ac3e25d1f45947b346788aeff8ee4d6 (diff)
* lib/yaml/rubytypes.rb: object and struct loading
* lib/yaml.rb: YAML::detect_implicit will discover typing for a Ruby string * ext/syck/: Fixed portable comments, misuse of NULL and methods without return VALUEs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/syck/token.c')
-rw-r--r--ext/syck/token.c259
1 files changed, 127 insertions, 132 deletions
diff --git a/ext/syck/token.c b/ext/syck/token.c
index 04c5bab860b..5098cf53f38 100644
--- a/ext/syck/token.c
+++ b/ext/syck/token.c
@@ -1,25 +1,24 @@
-/* Generated by re2c 0.5 on Sat May 10 19:31:12 2003 */
+/* Generated by re2c 0.5 on Tue May 13 00:35:24 2003 */
#line 1 "token.re"
-//
-// token.re
-//
-// $Author$
-// $Date$
-//
-// Copyright (C) 2003 why the lucky stiff
-//
-
+/*
+ * token.re
+ *
+ * $Author$
+ * $Date$
+ *
+ * Copyright (C) 2003 why the lucky stiff
+ */
#include "syck.h"
#include "gram.h"
-//
-// Allocate quoted strings in chunks
-//
+/*
+ * Allocate quoted strings in chunks
+ */
#define QUOTELEN 1024
-//
-// They do my bidding...
-//
+/*
+ * They do my bidding...
+ */
#define YYCTYPE char
#define YYCURSOR parser->cursor
#define YYMARKER parser->marker
@@ -30,33 +29,33 @@
#define YYLINE parser->linect
#define YYFILL(n) syck_parser_read(parser)
-//
-// Repositions the cursor at `n' offset from the token start.
-// Only works in `Header' and `Document' sections.
-//
+/*
+ * Repositions the cursor at `n' offset from the token start.
+ * Only works in `Header' and `Document' sections.
+ */
#define YYPOS(n) YYCURSOR = YYTOKEN + n
-//
-// Track line numbers
-//
+/*
+ * Track line numbers
+ */
#define NEWLINE(ptr) YYLINE++; YYLINEPTR = ptr + 1
-//
-// I like seeing the level operations as macros...
-//
+/*
+ * I like seeing the level operations as macros...
+ */
#define ADD_LEVEL(len, status) syck_parser_add_level( parser, len, status )
#define POP_LEVEL() syck_parser_pop_level( parser )
#define CURRENT_LEVEL() syck_parser_current_level( parser )
-//
-// Force a token next time around yylex()
-//
+/*
+ * Force a token next time around yylex()
+ */
#define FORCE_NEXT_TOKEN(tok) parser->force_token = tok;
-//
-// Nice little macro to ensure we're IOPENed to the current level.
-// * Only use this macro in the "Document" section *
-//
+/*
+ * Nice little macro to ensure we're IOPENed to the current level.
+ * * Only use this macro in the "Document" section *
+ */
#define ENSURE_IOPEN(last_lvl, to_len, reset) \
if ( last_lvl->spaces < to_len ) \
{ \
@@ -72,10 +71,10 @@
} \
}
-//
-// Nice little macro to ensure closure of levels.
-// * Only use this macro in the "Document" section *
-//
+/*
+ * Nice little macro to ensure closure of levels.
+ * * Only use this macro in the "Document" section *
+ */
#define ENSURE_IEND(last_lvl, to_len) \
if ( last_lvl->spaces > to_len ) \
{ \
@@ -84,10 +83,10 @@
return IEND; \
}
-//
-// Concatenates quoted string items and manages allocation
-// to the quoted string
-//
+/*
+ * Concatenates quoted string items and manages allocation
+ * to the quoted string
+ */
#define QUOTECAT(s, c, i, l) \
{ \
if ( i + 1 >= c ) \
@@ -99,10 +98,10 @@
s[i] = '\0'; \
}
-//
-// Tags a plain scalar with a transfer method
-// * Use only in "Plain" section *
-//
+/*
+ * Tags a plain scalar with a transfer method
+ * * Use only in "Plain" section *
+ */
#define RETURN_IMPLICIT(fold) \
{ \
SyckLevel *i_lvl = CURRENT_LEVEL(); \
@@ -118,9 +117,9 @@
return PLAIN; \
}
-//
-// Handles newlines, calculates indent
-//
+/*
+ * Handles newlines, calculates indent
+ */
#define GOBBLE_UP_INDENT( ict, start ) \
char *indent = start; \
NEWLINE(indent); \
@@ -142,9 +141,9 @@
ict = YYCURSOR - YYLINEPTR; \
}
-//
-// If an indent exists at the current level, back up.
-//
+/*
+ * If an indent exists at the current level, back up.
+ */
#define GET_TRUE_INDENT(indt_len) \
{ \
SyckLevel *lvl_deep = CURRENT_LEVEL(); \
@@ -159,21 +158,21 @@
} \
}
-//
-// Argjh! I hate globals! Here for yyerror() only!
-//
+/*
+ * Argjh! I hate globals! Here for yyerror() only!
+ */
SyckParser *syck_parser_ptr = NULL;
-//
-// Accessory funcs later in this file.
-//
+/*
+ * Accessory funcs later in this file.
+ */
void eat_comments( SyckParser * );
-//
-// My own re-entrant yylex() using re2c.
-// You really get used to the limited regexp.
-// It's really nice to not rely on backtracking and such.
-//
+/*
+ * My own re-entrant yylex() using re2c.
+ * You really get used to the limited regexp.
+ * It's really nice to not rely on backtracking and such.
+ */
int
yylex( YYSTYPE *yylval, SyckParser *parser )
{
@@ -190,7 +189,7 @@ yylex( YYSTYPE *yylval, SyckParser *parser )
return t;
}
-#line 206
+#line 205
if ( YYLINEPTR != YYCURSOR )
@@ -256,19 +255,19 @@ yy2: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
if(yych == '-') goto yy15;
yy3:
-#line 247
+#line 246
{ YYPOS(0);
goto Document;
}
yy4: yych = *++YYCURSOR;
yy5:
-#line 233
+#line 232
{ eat_comments( parser );
goto Header;
}
yy6: yych = *++YYCURSOR;
yy7:
-#line 237
+#line 236
{ SyckLevel *lvl = CURRENT_LEVEL();
ENSURE_IEND(lvl, -1);
return 0;
@@ -276,7 +275,7 @@ yy7:
yy8: yych = *++YYCURSOR;
goto yy12;
yy9:
-#line 242
+#line 241
{ int indt_len;
GOBBLE_UP_INDENT( indt_len, YYTOKEN );
goto Header;
@@ -308,7 +307,7 @@ yy18: ++YYCURSOR;
yych = *YYCURSOR;
yy19: if(yybm[0+yych] & 128) goto yy18;
yy20:
-#line 219
+#line 218
{ SyckLevel *lvl = CURRENT_LEVEL();
if ( lvl->status == syck_lvl_header )
{
@@ -328,7 +327,7 @@ yy21: ++YYCURSOR;
yy22: if(yych == '\n') goto yy21;
goto yy20;
}
-#line 251
+#line 250
Document:
@@ -434,7 +433,7 @@ yy23:
yy25: yych = *++YYCURSOR;
goto yy77;
yy26:
-#line 265
+#line 264
{ // Isolate spaces
int indt_len;
GOBBLE_UP_INDENT( indt_len, YYTOKEN );
@@ -451,7 +450,7 @@ yy26:
}
yy27: yych = *++YYCURSOR;
yy28:
-#line 280
+#line 279
{ ENSURE_IOPEN(lvl, 0, 1);
lvl = CURRENT_LEVEL();
ADD_LEVEL(lvl->spaces + 1, syck_lvl_inline);
@@ -459,7 +458,7 @@ yy28:
}
yy29: yych = *++YYCURSOR;
yy30:
-#line 286
+#line 285
{ POP_LEVEL();
return YYTOKEN[0];
}
@@ -467,7 +466,7 @@ yy31: yych = *++YYCURSOR;
if(yych == '\n') goto yy74;
if(yych == ' ') goto yy71;
yy32:
-#line 335
+#line 334
{ ENSURE_IOPEN(lvl, 0, 1);
goto Plain;
}
@@ -485,15 +484,15 @@ yy35: yych = *++YYCURSOR;
goto yy32;
yy36: yych = *++YYCURSOR;
yy37:
-#line 312
+#line 311
{ goto TransferMethod; }
yy38: yych = *++YYCURSOR;
yy39:
-#line 314
+#line 313
{ goto SingleQuote; }
yy40: yych = *++YYCURSOR;
yy41:
-#line 316
+#line 315
{ goto DoubleQuote; }
yy42: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
@@ -514,18 +513,18 @@ yy42: yyaccept = 0;
}
yy43: yych = *++YYCURSOR;
yy44:
-#line 325
+#line 324
{ eat_comments( parser );
goto Document;
}
yy45: yych = *++YYCURSOR;
goto yy51;
yy46:
-#line 329
+#line 328
{ goto Document; }
yy47: yych = *++YYCURSOR;
yy48:
-#line 331
+#line 330
{ ENSURE_IEND(lvl, -1);
return 0;
}
@@ -560,7 +559,7 @@ yy55: ++YYCURSOR;
yych = *YYCURSOR;
yy56: if(yych == ' ') goto yy55;
yy57:
-#line 318
+#line 317
{ if ( *( YYCURSOR - 1 ) == '\n' )
{
YYCURSOR--;
@@ -577,7 +576,7 @@ yy60: ++YYCURSOR;
yych = *YYCURSOR;
yy61: if(yybm[0+yych] & 64) goto yy60;
yy62:
-#line 308
+#line 307
{ yylval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 );
return ALIAS;
}
@@ -588,7 +587,7 @@ yy64: if(yych <= '-') goto yy65;
if(yych == '`') goto yy65;
if(yych <= 'z') goto yy63;
yy65:
-#line 304
+#line 303
{ yylval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 );
return ANCHOR;
}
@@ -597,7 +596,7 @@ yy66: ++YYCURSOR;
yych = *YYCURSOR;
yy67: if(yych == ' ') goto yy66;
yy68:
-#line 294
+#line 293
{ ENSURE_IOPEN(lvl, YYTOKEN - YYLINEPTR, 1);
FORCE_NEXT_TOKEN(IOPEN);
if ( *( YYCURSOR - 1 ) == '\n' )
@@ -617,7 +616,7 @@ yy71: ++YYCURSOR;
yych = *YYCURSOR;
yy72: if(yych == ' ') goto yy71;
yy73:
-#line 290
+#line 289
{ YYPOS(1);
return YYTOKEN[0];
}
@@ -637,7 +636,7 @@ yy78: ++YYCURSOR;
yy79: if(yybm[0+yych] & 128) goto yy78;
goto yy26;
}
-#line 339
+#line 338
}
@@ -705,14 +704,14 @@ yy83: yyaccept = 0;
if(yych == '`') goto yy84;
if(yych <= 'z') goto yy90;
yy84:
-#line 352
+#line 351
{ YYCURSOR = YYTOKTMP;
return DOCSEP;
}
yy85: yych = *++YYCURSOR;
goto yy89;
yy86:
-#line 350
+#line 349
{ goto Directive; }
yy87: yych = *++YYCURSOR;
goto yy84;
@@ -734,10 +733,10 @@ yy93: ++YYCURSOR;
yych = *YYCURSOR;
yy94: if(yybm[0+yych] & 128) goto yy93;
yy95:
-#line 348
+#line 347
{ goto Directive; }
}
-#line 355
+#line 354
}
@@ -820,7 +819,7 @@ yy96:
yy98: yych = *++YYCURSOR;
goto yy122;
yy99:
-#line 375
+#line 374
{ int indt_len;
SyckLevel *lvl;
char *tok = YYTOKTMP;
@@ -839,11 +838,11 @@ yy100: yych = *++YYCURSOR;
if(yych == '\n') goto yy119;
if(yych == ' ') goto yy116;
yy101:
-#line 404
+#line 403
{ goto Plain2; }
yy102: yych = *++YYCURSOR;
yy103:
-#line 392
+#line 391
{ if ( plvl->status != syck_lvl_inline ) goto Plain2;
RETURN_IMPLICIT(multiLine);
}
@@ -853,18 +852,18 @@ yy104: yych = *++YYCURSOR;
goto yy101;
yy105: yych = *++YYCURSOR;
yy106:
-#line 396
+#line 395
{ RETURN_IMPLICIT(multiLine); }
yy107: yych = *++YYCURSOR;
if(yych == '#') goto yy110;
yy108:
-#line 402
+#line 401
{ goto Plain3; }
yy109: yych = *++YYCURSOR;
goto yy101;
yy110: yych = *++YYCURSOR;
yy111:
-#line 398
+#line 397
{ eat_comments( parser );
RETURN_IMPLICIT(multiLine);
}
@@ -883,7 +882,7 @@ yy116: ++YYCURSOR;
yych = *YYCURSOR;
yy117: if(yych == ' ') goto yy116;
yy118:
-#line 390
+#line 389
{ RETURN_IMPLICIT(multiLine); }
yy119: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
@@ -901,7 +900,7 @@ yy123: ++YYCURSOR;
yy124: if(yybm[0+yych] & 128) goto yy123;
goto yy99;
}
-#line 406
+#line 405
}
@@ -966,7 +965,7 @@ yy125:
yy127: yych = *++YYCURSOR;
goto yy137;
yy128:
-#line 420
+#line 419
{ int indt_len;
int nl_count = 0;
SyckLevel *lvl;
@@ -1005,7 +1004,7 @@ yy128:
yy129: yych = *++YYCURSOR;
if(yych == '\'') goto yy134;
yy130:
-#line 460
+#line 459
{ SyckLevel *lvl;
SyckNode *n = syck_alloc_str();
lvl = CURRENT_LEVEL();
@@ -1023,13 +1022,13 @@ yy131: yych = *++YYCURSOR;
goto yy130;
yy132: yych = *++YYCURSOR;
yy133:
-#line 474
+#line 473
{ QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1));
goto SingleQuote2;
}
yy134: yych = *++YYCURSOR;
yy135:
-#line 456
+#line 455
{ QUOTECAT(qstr, qcapa, qidx, '\'');
goto SingleQuote2;
}
@@ -1044,7 +1043,7 @@ yy138: ++YYCURSOR;
yy139: if(yybm[0+yych] & 128) goto yy138;
goto yy128;
}
-#line 478
+#line 477
}
@@ -1114,7 +1113,7 @@ yy140:
yy142: yych = *++YYCURSOR;
goto yy158;
yy143:
-#line 496
+#line 495
{ int indt_len;
int nl_count = 0;
SyckLevel *lvl;
@@ -1186,13 +1185,13 @@ yy144: yyaccept = 0;
}
}
yy145:
-#line 571
+#line 570
{ QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1));
goto DoubleQuote2;
}
yy146: yych = *++YYCURSOR;
yy147:
-#line 557
+#line 556
{ SyckLevel *lvl;
SyckNode *n = syck_alloc_str();
lvl = CURRENT_LEVEL();
@@ -1221,14 +1220,14 @@ yy152: YYCURSOR = YYMARKER;
}
yy153: yych = *++YYCURSOR;
yy154:
-#line 552
+#line 551
{ keep_nl = 0;
YYCURSOR--;
goto DoubleQuote2;
}
yy155: yych = *++YYCURSOR;
yy156:
-#line 536
+#line 535
{ char ch = *( YYCURSOR - 1 );
switch ( ch )
{
@@ -1255,7 +1254,7 @@ yy159: ++YYCURSOR;
yy160: if(yybm[0+yych] & 128) goto yy159;
goto yy143;
}
-#line 575
+#line 574
}
@@ -1316,7 +1315,7 @@ yy161:
yy163:yy164: yych = *++YYCURSOR;
goto yy172;
yy165:
-#line 584
+#line 583
{ SyckLevel *lvl;
YYCURSOR = YYTOKTMP;
if ( YYCURSOR == YYTOKEN + 1 )
@@ -1331,14 +1330,14 @@ yy165:
//
if ( *(YYTOKEN + 1) == '^' )
{
- yylval->name = S_ALLOC_N( char, YYCURSOR - YYTOKEN + strlen( lvl->domain ) );
+ yylval->name = S_ALLOC_N( char, ( YYCURSOR - YYTOKEN ) + strlen( lvl->domain ) );
yylval->name[0] = '\0';
strcat( yylval->name, lvl->domain );
- strncat( yylval->name, YYTOKEN + 2, YYCURSOR - YYTOKEN - 2 );
+ strncat( yylval->name, YYTOKEN + 2, ( YYCURSOR - YYTOKEN ) - 2 );
}
else
{
- char *carat = YYTOKEN + 1;
+ char *carat = YYTOKEN;
while ( (++carat) < YYCURSOR )
{
if ( *carat == '^' )
@@ -1347,30 +1346,26 @@ yy165:
if ( carat < YYCURSOR )
{
- lvl->domain = syck_strndup( YYTOKEN + 1, carat - YYTOKEN - 1 );
- yylval->name = S_ALLOC_N( char, YYCURSOR - carat + strlen( lvl->domain ) );
+ free( lvl->domain );
+ lvl->domain = syck_strndup( YYTOKEN + 1, ( carat - YYTOKEN ) - 1 );
+ yylval->name = S_ALLOC_N( char, ( YYCURSOR - 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, ( YYCURSOR - carat ) - 1 );
}
else
{
- yylval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 );
+ yylval->name = syck_strndup( YYTOKEN + 1, ( YYCURSOR - YYTOKEN ) - 1 );
}
}
- if ( *YYCURSOR == '\n' )
- {
- FORCE_NEXT_TOKEN(IOPEN);
- ADD_LEVEL(lvl->spaces, syck_lvl_doc);
- }
return TRANSFER;
}
yy166: yych = *++YYCURSOR;
goto yy170;
yy167: yych = *++YYCURSOR;
yy168:
-#line 634
+#line 629
{ goto TransferMethod; }
yy169: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
@@ -1383,7 +1378,7 @@ yy171: ++YYCURSOR;
yy172: if(yybm[0+yych] & 128) goto yy171;
goto yy165;
}
-#line 636
+#line 631
}
@@ -1476,7 +1471,7 @@ yy173:
yy175: yych = *++YYCURSOR;
goto yy184;
yy176:
-#line 678
+#line 673
{ int indt_len;
GOBBLE_UP_INDENT( indt_len, YYTOKTMP );
lvl = CURRENT_LEVEL();
@@ -1509,7 +1504,7 @@ yy176:
}
yy177: yych = *++YYCURSOR;
yy178:
-#line 710
+#line 705
{ lvl = CURRENT_LEVEL();
YYCURSOR--;
yylval->nodeData = syck_new_str2( YYTOKEN, YYCURSOR - YYTOKEN );
@@ -1519,7 +1514,7 @@ yy178:
}
yy179: yych = *++YYCURSOR;
yy180:
-#line 718
+#line 713
{ lvl = CURRENT_LEVEL();
if ( lvl->status != syck_lvl_block )
{
@@ -1530,7 +1525,7 @@ yy180:
}
yy181: yych = *++YYCURSOR;
yy182:
-#line 727
+#line 722
{ goto ScalarBlock2; }
yy183: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
@@ -1543,7 +1538,7 @@ yy185: ++YYCURSOR;
yy186: if(yybm[0+yych] & 128) goto yy185;
goto yy176;
}
-#line 729
+#line 724
}
@@ -1605,7 +1600,7 @@ yy187:
goto yy192;
yy189: yych = *++YYCURSOR;
yy190:
-#line 745
+#line 740
{ SyckLevel *lvl = CURRENT_LEVEL();
YYCURSOR = tok;
return;
@@ -1614,7 +1609,7 @@ yy191: yych = *++YYCURSOR;
goto yy195;
yy192: yych = *++YYCURSOR;
yy193:
-#line 750
+#line 745
{ goto Comment;
}
yy194: ++YYCURSOR;
@@ -1623,7 +1618,7 @@ yy194: ++YYCURSOR;
yy195: if(yybm[0+yych] & 128) goto yy194;
goto yy190;
}
-#line 753
+#line 748
}
@@ -1642,7 +1637,7 @@ yyerror( char *msg )
if ( syck_parser_ptr->error_handler == NULL )
syck_parser_ptr->error_handler = syck_default_error_handler;
- syck_parser_ptr->root = NULL;
+ syck_parser_ptr->root = 0;
(syck_parser_ptr->error_handler)(syck_parser_ptr, msg);
}