summaryrefslogtreecommitdiff
path: root/ext/syck
diff options
context:
space:
mode:
authorwhy <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-05-15 03:11:28 +0000
committerwhy <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-05-15 03:11:28 +0000
commitc474911e5b78749c5a85db39256240db5fb9e3be (patch)
treef333f1c306d07933ceb2f4098b8aefde5d34d29e /ext/syck
parent094290e68fd4dfed851e8f7254d60a1301fe97e2 (diff)
* lib/yaml.rb: removed fallback to pure Ruby parser.
* lib/yaml/baseemitter.rb (node_text): rewriting folded scalars. * ext/syck/syck.h: reports style of scalars now, be they plain, block single-, or double-quoted. * ext/syck/syck.c: ditto. * ext/syck/gram.c: ditto. * ext/syck/node.c: ditto. * ext/syck/token.c: ditto. * ext/syck/rubyext.c (yaml_org_handler): symbols loaded only if scalar style is plain. * test/yaml/test_yaml.rb (test_perl_regexp): updated test to match new regexp serialization. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6315 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/syck')
-rw-r--r--ext/syck/gram.c2
-rw-r--r--ext/syck/gram.h2
-rw-r--r--ext/syck/node.c8
-rw-r--r--ext/syck/rubyext.c240
-rw-r--r--ext/syck/syck.h13
-rw-r--r--ext/syck/token.c132
6 files changed, 203 insertions, 194 deletions
diff --git a/ext/syck/gram.c b/ext/syck/gram.c
index 0e016950085..cf97516b27c 100644
--- a/ext/syck/gram.c
+++ b/ext/syck/gram.c
@@ -99,7 +99,7 @@
#define YYLEX_PARAM parser
#define NULL_NODE(parser, node) \
- SyckNode *node = syck_new_str( "" ); \
+ SyckNode *node = syck_new_str( "", scalar_plain ); \
if ( ((SyckParser *)parser)->taguri_expansion == 1 ) \
{ \
node->type_id = syck_taguri( YAML_DOMAIN, "null", 4 ); \
diff --git a/ext/syck/gram.h b/ext/syck/gram.h
index d1e577b0eea..4c0e1998321 100644
--- a/ext/syck/gram.h
+++ b/ext/syck/gram.h
@@ -63,7 +63,7 @@
#ifndef YYSTYPE
-#line 23 "gram.y"
+#line 33 "gram.y"
typedef union {
SYMID nodeId;
SyckNode *nodeData;
diff --git a/ext/syck/node.c b/ext/syck/node.c
index 86c4086bc72..500ede2a4c4 100644
--- a/ext/syck/node.c
+++ b/ext/syck/node.c
@@ -83,6 +83,7 @@ syck_alloc_str()
s = S_ALLOC( struct SyckStr );
s->len = 0;
s->ptr = NULL;
+ s->style = scalar_none;
n = syck_alloc_node( syck_str_kind );
n->data.str = s;
@@ -91,19 +92,20 @@ syck_alloc_str()
}
SyckNode *
-syck_new_str( char *str )
+syck_new_str( char *str, enum scalar_style style )
{
- return syck_new_str2( str, strlen( str ) );
+ return syck_new_str2( str, strlen( str ), style );
}
SyckNode *
-syck_new_str2( char *str, long len )
+syck_new_str2( char *str, long len, enum scalar_style style )
{
SyckNode *n;
n = syck_alloc_str();
n->data.str->ptr = S_ALLOC_N( char, len + 1 );
n->data.str->len = len;
+ n->data.str->style = style;
memcpy( n->data.str->ptr, str, len );
n->data.str->ptr[len] = '\0';
diff --git a/ext/syck/rubyext.c b/ext/syck/rubyext.c
index d6687a32c0a..c7c0ef1dbd2 100644
--- a/ext/syck/rubyext.c
+++ b/ext/syck/rubyext.c
@@ -15,33 +15,25 @@
typedef struct RVALUE {
union {
+#if 0
struct {
unsigned long flags; /* always 0 for freed obj */
struct RVALUE *next;
} free;
+#endif
struct RBasic basic;
struct RObject object;
struct RClass klass;
- struct RFloat flonum;
- struct RString string;
+ /*struct RFloat flonum;*/
+ /*struct RString string;*/
struct RArray array;
- struct RRegexp regexp;
+ /*struct RRegexp regexp;*/
struct RHash hash;
- struct RData data;
+ /*struct RData data;*/
struct RStruct rstruct;
- struct RBignum bignum;
- struct RFile file;
-#if 0
- struct RNode node;
- struct RMatch match;
- struct RVarmap varmap;
- struct SCOPE scope;
-#endif
+ /*struct RBignum bignum;*/
+ /*struct RFile file;*/
} as;
-#ifdef GC_DEBUG
- char *file;
- int line;
-#endif
} RVALUE;
typedef struct {
@@ -95,7 +87,7 @@ struct parser_xtra {
*/
VALUE
rb_syck_compile(self, port)
- VALUE self, port;
+ VALUE self, port;
{
SYMID oid;
int taint;
@@ -104,7 +96,7 @@ rb_syck_compile(self, port)
bytestring_t *sav;
SyckParser *parser = syck_new_parser();
- taint = syck_parser_assign_io(parser, port);
+ taint = syck_parser_assign_io(parser, port);
syck_parser_handler( parser, syck_yaml2byte_handler );
syck_parser_error_handler( parser, NULL );
syck_parser_implicit_typing( parser, 0 );
@@ -161,14 +153,14 @@ rb_syck_io_str_read( char *buf, SyckIoStr *str, long max_size, long skip )
*/
int
syck_parser_assign_io(parser, port)
- SyckParser *parser;
- VALUE port;
+ SyckParser *parser;
+ VALUE port;
{
int taint = Qtrue;
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 );
+ taint = OBJ_TAINTED(port); /* original taintedness */
+ StringValue(port); /* possible conversion */
+ syck_parser_str( parser, RSTRING(port)->ptr, RSTRING(port)->len, NULL );
}
else if (rb_respond_to(port, s_read)) {
if (rb_respond_to(port, s_binmode)) {
@@ -341,7 +333,7 @@ rb_syck_parse_handler(p, n)
bonus = (struct parser_xtra *)p->bonus;
if ( bonus->taint) OBJ_TAINT( obj );
- if ( bonus->proc != 0 ) rb_funcall(bonus->proc, s_call, 1, v);
+ if ( bonus->proc != 0 ) rb_funcall(bonus->proc, s_call, 1, v);
rb_ivar_set(obj, s_value, v);
rb_hash_aset(bonus->data, INT2FIX(RHASH(bonus->data)->tbl->num_entries), obj);
@@ -356,10 +348,10 @@ VALUE
syck_merge_i( entry, hsh )
VALUE entry, hsh;
{
- if ( rb_obj_is_kind_of( entry, rb_cHash ) )
- {
- rb_funcall( hsh, s_update, 1, entry );
- }
+ if ( rb_obj_is_kind_of( entry, rb_cHash ) )
+ {
+ rb_funcall( hsh, s_update, 1, entry );
+ }
return Qnil;
}
@@ -375,12 +367,12 @@ rb_new_syck_node( obj, type_id )
if (rb_respond_to(obj, s_to_str))
{
- StringValue(obj); /* possible conversion */
+ 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 ) )
+ else if ( rb_obj_is_kind_of( obj, rb_cArray ) )
{
n = syck_alloc_seq();
for ( i = 0; i < RARRAY(obj)->len; i++ )
@@ -535,7 +527,7 @@ yaml_org_handler( n, ref )
ptr += 2;
while ( !ISDIGIT( *ptr ) ) ptr++;
day = INT2FIX(strtol(ptr, NULL, 10));
-
+
if ( !cDate ) {
/*
* Load Date module
@@ -558,7 +550,9 @@ yaml_org_handler( n, ref )
{
obj = rb_funcall( cDefaultKey, s_new, 0 );
}
- else if ( n->data.str->len > 1 && strncmp( n->data.str->ptr, ":", 1 ) == 0 )
+ else if ( n->data.str->style == scalar_plain &&
+ n->data.str->len > 1 &&
+ strncmp( n->data.str->ptr, ":", 1 ) == 0 )
{
obj = rb_funcall( oDefaultLoader, s_transfer, 2,
rb_str_new2( "ruby/sym" ),
@@ -676,7 +670,7 @@ rb_syck_load_handler(p, n)
bonus = (struct parser_xtra *)p->bonus;
if ( bonus->taint) OBJ_TAINT( obj );
- if ( bonus->proc != 0 ) rb_funcall(bonus->proc, s_call, 1, obj);
+ if ( bonus->proc != 0 ) rb_funcall(bonus->proc, s_call, 1, obj);
rb_hash_aset(bonus->data, INT2FIX(RHASH(bonus->data)->tbl->num_entries), obj);
return obj;
@@ -722,21 +716,21 @@ rb_syck_bad_anchor_handler(p, a)
*/
void
syck_set_model( parser, input, model )
- SyckParser *parser;
- VALUE input, model;
+ SyckParser *parser;
+ VALUE input, model;
{
- if ( model == sym_generic )
- {
- syck_parser_handler( parser, rb_syck_parse_handler );
- syck_parser_implicit_typing( parser, 1 );
- syck_parser_taguri_expansion( parser, 1 );
- }
- else
- {
- syck_parser_handler( parser, rb_syck_load_handler );
- syck_parser_implicit_typing( parser, 1 );
- syck_parser_taguri_expansion( parser, 0 );
- }
+ if ( model == sym_generic )
+ {
+ syck_parser_handler( parser, rb_syck_parse_handler );
+ syck_parser_implicit_typing( parser, 1 );
+ syck_parser_taguri_expansion( parser, 1 );
+ }
+ else
+ {
+ syck_parser_handler( parser, rb_syck_load_handler );
+ syck_parser_implicit_typing( parser, 1 );
+ syck_parser_taguri_expansion( parser, 0 );
+ }
if ( input == sym_bytecode )
{
syck_parser_set_input_type( parser, syck_bytecode_utf8 );
@@ -763,13 +757,13 @@ VALUE
syck_parser_new(argc, argv, class)
int argc;
VALUE *argv;
- VALUE class;
+ VALUE class;
{
- VALUE pobj, options, init_argv[1];
+ VALUE pobj, options, init_argv[1];
SyckParser *parser = syck_new_parser();
rb_scan_args(argc, argv, "01", &options);
- pobj = Data_Wrap_Struct( class, syck_mark_parser, syck_free_parser, parser );
+ pobj = Data_Wrap_Struct( class, syck_mark_parser, syck_free_parser, parser );
syck_parser_set_root_on_error( parser, Qnil );
@@ -777,9 +771,9 @@ syck_parser_new(argc, argv, class)
{
options = rb_hash_new();
}
- init_argv[0] = options;
- rb_obj_call_init(pobj, 1, init_argv);
- return pobj;
+ init_argv[0] = options;
+ rb_obj_call_init(pobj, 1, init_argv);
+ return pobj;
}
/*
@@ -790,7 +784,7 @@ syck_parser_initialize( self, options )
VALUE self, options;
{
rb_ivar_set(self, s_options, options);
- return self;
+ return self;
}
/*
@@ -800,13 +794,13 @@ static VALUE
syck_parser_bufsize_set( self, size )
VALUE self, size;
{
- SyckParser *parser;
+ SyckParser *parser;
- Data_Get_Struct(self, SyckParser, parser);
+ Data_Get_Struct(self, SyckParser, parser);
if ( rb_respond_to( size, s_to_i ) ) {
parser->bufsize = NUM2INT(rb_funcall(size, s_to_i, 0));
}
- return self;
+ return self;
}
/*
@@ -816,10 +810,10 @@ static VALUE
syck_parser_bufsize_get( self )
VALUE self;
{
- SyckParser *parser;
+ SyckParser *parser;
- Data_Get_Struct(self, SyckParser, parser);
- return INT2FIX( parser->bufsize );
+ Data_Get_Struct(self, SyckParser, parser);
+ return INT2FIX( parser->bufsize );
}
/*
@@ -829,26 +823,26 @@ VALUE
syck_parser_load(argc, argv, self)
int argc;
VALUE *argv;
- VALUE self;
+ VALUE self;
{
VALUE port, proc, model, input;
- SyckParser *parser;
+ SyckParser *parser;
struct parser_xtra bonus;
volatile VALUE hash; /* protect from GC */
rb_scan_args(argc, argv, "11", &port, &proc);
- Data_Get_Struct(self, SyckParser, parser);
+ Data_Get_Struct(self, SyckParser, parser);
input = rb_hash_aref( rb_attr_get( self, s_options ), sym_input );
model = rb_hash_aref( rb_attr_get( self, s_options ), sym_model );
- syck_set_model( parser, input, model );
+ syck_set_model( parser, input, model );
- bonus.taint = syck_parser_assign_io(parser, port);
+ bonus.taint = syck_parser_assign_io(parser, port);
bonus.data = hash = rb_hash_new();
- if ( NIL_P( proc ) ) bonus.proc = 0;
+ if ( NIL_P( proc ) ) bonus.proc = 0;
else bonus.proc = proc;
-
- parser->bonus = (void *)&bonus;
+
+ parser->bonus = (void *)&bonus;
return syck_parse( parser );
}
@@ -860,38 +854,38 @@ VALUE
syck_parser_load_documents(argc, argv, self)
int argc;
VALUE *argv;
- VALUE self;
+ VALUE self;
{
VALUE port, proc, v, input, model;
- SyckParser *parser;
+ SyckParser *parser;
struct parser_xtra bonus;
volatile VALUE hash;
rb_scan_args(argc, argv, "1&", &port, &proc);
- Data_Get_Struct(self, SyckParser, parser);
+ Data_Get_Struct(self, SyckParser, parser);
input = rb_hash_aref( rb_attr_get( self, s_options ), sym_input );
model = rb_hash_aref( rb_attr_get( self, s_options ), sym_model );
- syck_set_model( parser, input, model );
+ syck_set_model( parser, input, model );
- bonus.taint = syck_parser_assign_io(parser, port);
+ bonus.taint = syck_parser_assign_io(parser, port);
while ( 1 )
- {
+ {
/* Reset hash for tracking nodes */
bonus.data = hash = rb_hash_new();
bonus.proc = 0;
parser->bonus = (void *)&bonus;
/* Parse a document */
- v = syck_parse( parser );
+ v = syck_parse( parser );
if ( parser->eof == 1 )
{
break;
}
/* Pass document to block */
- rb_funcall( proc, s_call, 1, v );
- }
+ rb_funcall( proc, s_call, 1, v );
+ }
return Qnil;
}
@@ -913,7 +907,7 @@ syck_loader_initialize( self )
rb_hash_aset(families, rb_str_new2( YAML_DOMAIN ), rb_hash_new());
rb_hash_aset(families, rb_str_new2( RUBY_DOMAIN ), rb_hash_new());
- return self;
+ return self;
}
/*
@@ -1025,15 +1019,15 @@ transfer_find_i(entry, col)
{
VALUE key = rb_ary_entry( entry, 0 );
VALUE tid = rb_ary_entry( col, 0 );
- if ( rb_respond_to( key, s_match ) )
- {
- VALUE match = rb_funcall( key, rb_intern("match"), 1, tid );
- if ( ! NIL_P( match ) )
- {
- rb_ary_push( col, rb_ary_entry( entry, 1 ) );
- rb_iter_break();
- }
- }
+ if ( rb_respond_to( key, s_match ) )
+ {
+ VALUE match = rb_funcall( key, rb_intern("match"), 1, tid );
+ if ( ! NIL_P( match ) )
+ {
+ rb_ary_push( col, rb_ary_entry( entry, 1 ) );
+ rb_iter_break();
+ }
+ }
return Qnil;
}
@@ -1288,9 +1282,9 @@ VALUE
syck_emitter_new(argc, argv, class)
int argc;
VALUE *argv;
- VALUE class;
+ VALUE class;
{
- VALUE pobj, options, init_argv[1];
+ VALUE pobj, options, init_argv[1];
SyckEmitter *emitter = syck_new_emitter();
syck_emitter_ignore_id( emitter, Qnil );
syck_emitter_handler( emitter, rb_syck_output_handler );
@@ -1298,15 +1292,15 @@ syck_emitter_new(argc, argv, class)
emitter->bonus = (void *)rb_str_new2( "" );
rb_scan_args(argc, argv, "01", &options);
- pobj = Data_Wrap_Struct( class, syck_mark_emitter, syck_free_emitter, emitter );
+ pobj = Data_Wrap_Struct( class, syck_mark_emitter, syck_free_emitter, emitter );
if ( ! rb_obj_is_instance_of( options, rb_cHash ) )
{
options = rb_hash_new();
}
- init_argv[0] = options;
- rb_obj_call_init(pobj, 1, init_argv);
- return pobj;
+ init_argv[0] = options;
+ rb_obj_call_init(pobj, 1, init_argv);
+ return pobj;
}
/*
@@ -1317,7 +1311,7 @@ syck_emitter_initialize( self, options )
VALUE self, options;
{
rb_ivar_set(self, s_options, options);
- return self;
+ return self;
}
/*
@@ -1329,7 +1323,7 @@ syck_emitter_level_m( self )
{
SyckEmitter *emitter;
- Data_Get_Struct(self, SyckEmitter, emitter);
+ Data_Get_Struct(self, SyckEmitter, emitter);
return LONG2NUM( emitter->level );
}
@@ -1342,7 +1336,7 @@ syck_emitter_flush_m( self )
{
SyckEmitter *emitter;
- Data_Get_Struct(self, SyckEmitter, emitter);
+ Data_Get_Struct(self, SyckEmitter, emitter);
syck_emitter_flush( emitter, 0 );
return self;
}
@@ -1356,7 +1350,7 @@ syck_emitter_write_m( self, str )
{
SyckEmitter *emitter;
- Data_Get_Struct(self, SyckEmitter, emitter);
+ Data_Get_Struct(self, SyckEmitter, emitter);
StringValue(str);
syck_emitter_write( emitter, RSTRING(str)->ptr, RSTRING(str)->len );
return self;
@@ -1371,7 +1365,7 @@ syck_emitter_simple_write( self, str )
{
SyckEmitter *emitter;
- Data_Get_Struct(self, SyckEmitter, emitter);
+ Data_Get_Struct(self, SyckEmitter, emitter);
StringValue(str);
syck_emitter_simple( emitter, RSTRING(str)->ptr, RSTRING(str)->len );
return self;
@@ -1387,7 +1381,7 @@ syck_emitter_start_object( self, oid )
char *anchor_name;
SyckEmitter *emitter;
- Data_Get_Struct(self, SyckEmitter, emitter);
+ Data_Get_Struct(self, SyckEmitter, emitter);
anchor_name = syck_emitter_start_obj( emitter, oid );
if ( anchor_name == NULL )
@@ -1407,7 +1401,7 @@ syck_emitter_end_object( self )
{
SyckEmitter *emitter;
- Data_Get_Struct(self, SyckEmitter, emitter);
+ Data_Get_Struct(self, SyckEmitter, emitter);
syck_emitter_end_obj( emitter );
if ( emitter->level < 0 )
@@ -1428,9 +1422,9 @@ Init_syck()
rb_define_const( rb_syck, "VERSION", rb_str_new2( SYCK_VERSION ) );
rb_define_module_function( rb_syck, "compile", rb_syck_compile, 1 );
- /*
- * Global symbols
- */
+ /*
+ * Global symbols
+ */
s_new = rb_intern("new");
s_utc = rb_intern("utc");
s_at = rb_intern("at");
@@ -1442,13 +1436,13 @@ Init_syck()
s_transfer = rb_intern("transfer");
s_call = rb_intern("call");
s_cmp = rb_intern("<=>");
- s_update = rb_intern("update");
- s_dup = rb_intern("dup");
+ s_update = rb_intern("update");
+ s_dup = rb_intern("dup");
s_default_set = rb_intern("default=");
- s_match = rb_intern("match");
- s_keys = rb_intern("keys");
- s_to_str = rb_intern("to_str");
- s_tr_bang = rb_intern("tr!");
+ 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");
s_anchors = rb_intern("@anchors");
@@ -1461,10 +1455,10 @@ Init_syck()
s_type_id = rb_intern("@type_id");
s_value = rb_intern("@value");
- sym_model = ID2SYM(rb_intern("Model"));
- sym_generic = ID2SYM(rb_intern("Generic"));
- sym_input = ID2SYM(rb_intern("Input"));
- sym_bytecode = ID2SYM(rb_intern("Bytecode"));
+ sym_model = ID2SYM(rb_intern("Model"));
+ sym_generic = ID2SYM(rb_intern("Generic"));
+ sym_input = ID2SYM(rb_intern("Input"));
+ sym_bytecode = ID2SYM(rb_intern("Bytecode"));
sym_map = ID2SYM(rb_intern("map"));
sym_scalar = ID2SYM(rb_intern("scalar"));
sym_seq = ID2SYM(rb_intern("seq"));
@@ -1494,7 +1488,7 @@ Init_syck()
*/
cParser = rb_define_class_under( rb_syck, "Parser", rb_cObject );
rb_define_attr( cParser, "options", 1, 1 );
- rb_define_singleton_method( cParser, "new", syck_parser_new, -1 );
+ rb_define_singleton_method( cParser, "new", syck_parser_new, -1 );
rb_define_method(cParser, "initialize", syck_parser_initialize, 1);
rb_define_method(cParser, "load", syck_parser_load, -1);
rb_define_method(cParser, "load_documents", syck_parser_load_documents, -1);
@@ -1536,21 +1530,21 @@ Init_syck()
rb_define_method( cBadAlias, "<=>", syck_badalias_cmp, 1);
rb_include_module( cBadAlias, rb_const_get( rb_cObject, rb_intern("Comparable") ) );
- /*
- * Define YAML::Syck::MergeKey class
- */
- cMergeKey = rb_define_class_under( rb_syck, "MergeKey", rb_cObject );
+ /*
+ * Define YAML::Syck::MergeKey class
+ */
+ cMergeKey = rb_define_class_under( rb_syck, "MergeKey", rb_cObject );
- /*
- * Define YAML::Syck::DefaultKey class
- */
- cDefaultKey = rb_define_class_under( rb_syck, "DefaultKey", rb_cObject );
+ /*
+ * Define YAML::Syck::DefaultKey class
+ */
+ cDefaultKey = rb_define_class_under( rb_syck, "DefaultKey", rb_cObject );
/*
* Define YAML::Syck::Emitter class
*/
cEmitter = rb_define_class_under( rb_syck, "Emitter", rb_cObject );
- rb_define_singleton_method( cEmitter, "new", syck_emitter_new, -1 );
+ rb_define_singleton_method( cEmitter, "new", syck_emitter_new, -1 );
rb_define_method( cEmitter, "initialize", syck_emitter_initialize, 1 );
rb_define_method( cEmitter, "level", syck_emitter_level_m, 0 );
rb_define_method( cEmitter, "write", syck_emitter_write_m, 1 );
diff --git a/ext/syck/syck.h b/ext/syck/syck.h
index 60c06c0cb8f..51604b4a0cd 100644
--- a/ext/syck/syck.h
+++ b/ext/syck/syck.h
@@ -84,6 +84,14 @@ enum map_part {
map_value
};
+enum scalar_style {
+ scalar_none,
+ scalar_plain,
+ scalar_1quote,
+ scalar_2quote,
+ scalar_block
+};
+
/*
* Node metadata struct
*/
@@ -112,6 +120,7 @@ struct _syck_node {
} *list;
/* Storage for string data */
struct SyckStr {
+ enum scalar_style style;
char *ptr;
long len;
} *str;
@@ -367,8 +376,8 @@ SyckNode *syck_alloc_seq();
SyckNode *syck_alloc_str();
void syck_free_node( SyckNode * );
void syck_free_members( SyckNode * );
-SyckNode *syck_new_str( char * );
-SyckNode *syck_new_str2( char *, long );
+SyckNode *syck_new_str( char *, enum scalar_style );
+SyckNode *syck_new_str2( char *, long, enum scalar_style );
void syck_str_blow_away_commas( SyckNode * );
char *syck_str_read( SyckNode * );
SyckNode *syck_new_map( SYMID, SYMID );
diff --git a/ext/syck/token.c b/ext/syck/token.c
index 5874c27c8f9..ac9986f5645 100644
--- a/ext/syck/token.c
+++ b/ext/syck/token.c
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.5 on Tue Nov 25 12:10:28 2003 */
+/* Generated by re2c 0.5 on Thu May 13 01:45:26 2004 */
#line 1 "token.re"
/*
* token.re
@@ -122,6 +122,7 @@
YYCURSOR = YYTOKEN; \
n->data.str->ptr = qstr; \
n->data.str->len = qidx; \
+ n->data.str->style = scalar_plain; \
sycklval->nodeData = n; \
if ( parser->implicit_typing == 1 ) \
{ \
@@ -140,6 +141,7 @@
n->type_id = syck_strndup( "str", 3 ); \
n->data.str->ptr = qstr; \
n->data.str->len = qidx; \
+ n->data.str->style = scalar_block; \
if ( qidx > 0 ) \
{ \
if ( nlDoWhat != NL_KEEP ) \
@@ -257,7 +259,7 @@ sycklex_yaml_utf8( YYSTYPE *sycklval, SyckParser *parser )
return t;
}
-#line 276
+#line 278
if ( YYLINEPTR != YYCURSOR )
@@ -294,7 +296,7 @@ yy2: yyaccept = 0;
default: goto yy3;
}
yy3:
-#line 335
+#line 337
{ YYPOS(0);
goto Document;
}
@@ -306,13 +308,13 @@ yy4: yyaccept = 0;
}
yy5: yych = *++YYCURSOR;
yy6:
-#line 317
+#line 319
{ eat_comments( parser );
goto Header;
}
yy7: yych = *++YYCURSOR;
yy8:
-#line 321
+#line 323
{ SyckLevel *lvl = CURRENT_LEVEL();
ENSURE_YAML_IEND(lvl, -1);
YYPOS(0);
@@ -322,7 +324,7 @@ yy9: yyaccept = 1;
yych = *(YYMARKER = ++YYCURSOR);
goto yy18;
yy10:
-#line 327
+#line 329
{ GOBBLE_UP_YAML_INDENT( doc_level, YYTOKEN );
goto Header;
}
@@ -334,7 +336,7 @@ yy11: yych = *++YYCURSOR;
yy12: yych = *++YYCURSOR;
goto yy16;
yy13:
-#line 331
+#line 333
{ doc_level = YYCURSOR - YYLINEPTR;
goto Header;
}
@@ -382,7 +384,7 @@ yy22: yych = *++YYCURSOR;
}
yy23: yych = *++YYCURSOR;
yy24:
-#line 303
+#line 305
{ SyckLevel *lvl = CURRENT_LEVEL();
if ( lvl->status == syck_lvl_header )
{
@@ -422,7 +424,7 @@ yy29: yych = *++YYCURSOR;
}
yy30: yych = *++YYCURSOR;
yy31:
-#line 289
+#line 291
{ SyckLevel *lvl = CURRENT_LEVEL();
if ( lvl->status == syck_lvl_header )
{
@@ -449,7 +451,7 @@ yy34: yych = *++YYCURSOR;
default: goto yy20;
}
}
-#line 339
+#line 341
Document:
@@ -492,7 +494,7 @@ yy37: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
goto yy90;
yy38:
-#line 353
+#line 355
{ /* Isolate spaces */
int indt_len;
GOBBLE_UP_YAML_INDENT( indt_len, YYTOKEN );
@@ -520,13 +522,13 @@ yy39: yych = *++YYCURSOR;
default: goto yy40;
}
yy40:
-#line 445
+#line 447
{ ENSURE_YAML_IOPEN(lvl, doc_level, 1);
goto Plain;
}
yy41: yych = *++YYCURSOR;
yy42:
-#line 375
+#line 377
{ ENSURE_YAML_IOPEN(lvl, doc_level, 1);
lvl = CURRENT_LEVEL();
ADD_LEVEL(lvl->spaces + 1, syck_lvl_inline);
@@ -534,7 +536,7 @@ yy42:
}
yy43: yych = *++YYCURSOR;
yy44:
-#line 381
+#line 383
{ POP_LEVEL();
return YYTOKEN[0];
}
@@ -684,16 +686,16 @@ yy48: yych = *++YYCURSOR;
}
yy49: yych = *++YYCURSOR;
yy50:
-#line 419
+#line 421
{ goto TransferMethod; }
yy51: yych = *++YYCURSOR;
yy52:
-#line 421
+#line 423
{ ENSURE_YAML_IOPEN(lvl, doc_level, 1);
goto SingleQuote; }
yy53: yych = *++YYCURSOR;
yy54:
-#line 424
+#line 426
{ ENSURE_YAML_IOPEN(lvl, doc_level, 1);
goto DoubleQuote; }
yy55: yyaccept = 1;
@@ -716,18 +718,18 @@ yy55: yyaccept = 1;
}
yy56: yych = *++YYCURSOR;
yy57:
-#line 434
+#line 436
{ eat_comments( parser );
goto Document;
}
yy58: yych = *++YYCURSOR;
goto yy64;
yy59:
-#line 438
+#line 440
{ goto Document; }
yy60: yych = *++YYCURSOR;
yy61:
-#line 440
+#line 442
{ ENSURE_YAML_IEND(lvl, -1);
YYPOS(0);
return 0;
@@ -767,7 +769,7 @@ yy67: YYCURSOR = YYMARKER;
}
yy68: yych = *++YYCURSOR;
yy69:
-#line 427
+#line 429
{ if ( is_newline( YYCURSOR - 1 ) )
{
YYCURSOR--;
@@ -853,7 +855,7 @@ yy74: switch(yych){
default: goto yy75;
}
yy75:
-#line 414
+#line 416
{ ENSURE_YAML_IOPEN(lvl, doc_level, 1);
sycklval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 );
return YAML_ALIAS;
@@ -925,7 +927,7 @@ yy77: switch(yych){
default: goto yy78;
}
yy78:
-#line 403
+#line 405
{ sycklval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 );
/*
@@ -938,7 +940,7 @@ yy78:
}
yy79: yych = *++YYCURSOR;
yy80:
-#line 389
+#line 391
{ ENSURE_YAML_IOPEN(lvl, YYTOKEN - YYLINEPTR, 1);
FORCE_NEXT_TOKEN(YAML_IOPEN);
if ( is_newline( YYCURSOR ) || is_newline( YYCURSOR - 1 ) )
@@ -966,7 +968,7 @@ yy83: yych = *++YYCURSOR;
}
yy84: yych = *++YYCURSOR;
yy85:
-#line 385
+#line 387
{ YYPOS(1);
return YYTOKEN[0];
}
@@ -999,7 +1001,7 @@ yy91: ++YYCURSOR;
default: goto yy67;
}
}
-#line 449
+#line 451
}
@@ -1106,14 +1108,14 @@ yy95: yyaccept = 0;
default: goto yy96;
}
yy96:
-#line 462
+#line 464
{ YYCURSOR = YYTOKTMP;
return YAML_DOCSEP;
}
yy97: yych = *++YYCURSOR;
goto yy101;
yy98:
-#line 460
+#line 462
{ goto Directive; }
yy99: yych = *++YYCURSOR;
goto yy96;
@@ -1365,10 +1367,10 @@ yy106: switch(yych){
default: goto yy107;
}
yy107:
-#line 458
+#line 460
{ goto Directive; }
}
-#line 465
+#line 467
}
@@ -1412,7 +1414,7 @@ yy110: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
goto yy136;
yy111:
-#line 488
+#line 490
{ int indt_len, nl_count = 0;
SyckLevel *lvl;
char *tok = YYTOKEN;
@@ -1450,7 +1452,7 @@ yy112: yych = *++YYCURSOR;
default: goto yy113;
}
yy113:
-#line 542
+#line 544
{ QUOTECATS(qstr, qcapa, qidx, YYTOKEN, YYCURSOR - YYTOKEN);
goto Plain2;
}
@@ -1464,7 +1466,7 @@ yy114: yyaccept = 1;
}
yy115: yych = *++YYCURSOR;
yy116:
-#line 522
+#line 524
{ if ( plvl->status != syck_lvl_inline )
{
if ( *(YYCURSOR - 1) == ' ' || is_newline( YYCURSOR - 1 ) )
@@ -1490,17 +1492,17 @@ yy118: yych = *++YYCURSOR;
default: goto yy119;
}
yy119:
-#line 540
+#line 542
{ goto Plain3; }
yy120: yych = *++YYCURSOR;
yy121:
-#line 538
+#line 540
{ RETURN_IMPLICIT(); }
yy122: yych = *++YYCURSOR;
goto yy113;
yy123: yych = *++YYCURSOR;
yy124:
-#line 534
+#line 536
{ eat_comments( parser );
RETURN_IMPLICIT();
}
@@ -1525,7 +1527,7 @@ yy129: YYCURSOR = YYMARKER;
}
yy130: yych = *++YYCURSOR;
yy131:
-#line 520
+#line 522
{ RETURN_IMPLICIT(); }
yy132: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
@@ -1556,7 +1558,7 @@ yy137: ++YYCURSOR;
default: goto yy129;
}
}
-#line 546
+#line 548
}
@@ -1588,7 +1590,7 @@ yy140: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
goto yy151;
yy141:
-#line 560
+#line 562
{ int indt_len;
int nl_count = 0;
SyckLevel *lvl;
@@ -1630,7 +1632,7 @@ yy142: yych = *++YYCURSOR;
default: goto yy143;
}
yy143:
-#line 615
+#line 618
{ QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1));
goto SingleQuote2;
}
@@ -1640,7 +1642,7 @@ yy144: yych = *++YYCURSOR;
default: goto yy145;
}
yy145:
-#line 600
+#line 602
{ SyckLevel *lvl;
SyckNode *n = syck_alloc_str();
lvl = CURRENT_LEVEL();
@@ -1652,6 +1654,7 @@ yy145:
n->type_id = syck_strndup( "str", 3 );
n->data.str->ptr = qstr;
n->data.str->len = qidx;
+ n->data.str->style = scalar_1quote;
sycklval->nodeData = n;
return YAML_PLAIN;
}
@@ -1661,7 +1664,7 @@ yy147: yych = *++YYCURSOR;
goto yy143;
yy148: yych = *++YYCURSOR;
yy149:
-#line 596
+#line 598
{ QUOTECAT(qstr, qcapa, qidx, '\'');
goto SingleQuote2;
}
@@ -1686,7 +1689,7 @@ yy153: YYCURSOR = YYMARKER;
case 0: goto yy141;
}
}
-#line 619
+#line 622
}
@@ -1723,7 +1726,7 @@ yy156: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
goto yy178;
yy157:
-#line 637
+#line 640
{ int indt_len;
int nl_count = 0;
SyckLevel *lvl;
@@ -1769,7 +1772,7 @@ yy158: yych = *++YYCURSOR;
default: goto yy159;
}
yy159:
-#line 711
+#line 715
{ QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1));
goto DoubleQuote2;
}
@@ -1787,7 +1790,7 @@ yy160: yyaccept = 1;
}
yy161: yych = *++YYCURSOR;
yy162:
-#line 696
+#line 699
{ SyckLevel *lvl;
SyckNode *n = syck_alloc_str();
lvl = CURRENT_LEVEL();
@@ -1799,6 +1802,7 @@ yy162:
n->type_id = syck_strndup( "str", 3 );
n->data.str->ptr = qstr;
n->data.str->len = qidx;
+ n->data.str->style = scalar_2quote;
sycklval->nodeData = n;
return YAML_PLAIN;
}
@@ -1822,7 +1826,7 @@ yy167: YYCURSOR = YYMARKER;
}
yy168: yych = *++YYCURSOR;
yy169:
-#line 691
+#line 694
{ keep_nl = 0;
YYCURSOR--;
goto DoubleQuote2;
@@ -1858,7 +1862,7 @@ yy171: yych = *++YYCURSOR;
}
yy172: yych = *++YYCURSOR;
yy173:
-#line 677
+#line 680
{ char ch = *( YYCURSOR - 1 );
QUOTECAT(qstr, qcapa, qidx, escape_seq( ch ));
goto DoubleQuote2;
@@ -1889,7 +1893,7 @@ yy174: yych = *++YYCURSOR;
}
yy175: yych = *++YYCURSOR;
yy176:
-#line 682
+#line 685
{ long ch;
char *chr_text = syck_strndup( YYTOKEN, 4 );
chr_text[0] = '0';
@@ -1915,7 +1919,7 @@ yy179: ++YYCURSOR;
default: goto yy167;
}
}
-#line 715
+#line 719
}
@@ -1950,7 +1954,7 @@ yy182: YYCURSOR = YYMARKER;
}
yy183: yych = *++YYCURSOR;
yy184:
-#line 729
+#line 733
{ SyckLevel *lvl;
YYCURSOR = YYTOKTMP;
if ( YYCURSOR == YYTOKEN + 1 )
@@ -2008,7 +2012,7 @@ yy186: yych = *++YYCURSOR;
default: goto yy187;
}
yy187:
-#line 796
+#line 800
{ QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1));
goto TransferMethod2;
}
@@ -2049,7 +2053,7 @@ yy190: yych = *++YYCURSOR;
}
yy191: yych = *++YYCURSOR;
yy192:
-#line 782
+#line 786
{ char ch = *( YYCURSOR - 1 );
QUOTECAT(qstr, qcapa, qidx, escape_seq( ch ));
goto TransferMethod2;
@@ -2080,7 +2084,7 @@ yy193: yych = *++YYCURSOR;
}
yy194: yych = *++YYCURSOR;
yy195:
-#line 787
+#line 791
{ long ch;
char *chr_text = syck_strndup( YYTOKTMP, 4 );
chr_text[0] = '0';
@@ -2099,7 +2103,7 @@ yy198: switch(yych){
default: goto yy184;
}
}
-#line 801
+#line 805
}
@@ -2165,7 +2169,7 @@ yy201: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
goto yy220;
yy202:
-#line 848
+#line 852
{ char *pacer;
char *tok = YYTOKEN;
int indt_len = 0, nl_count = 0, fold_nl = 0, nl_begin = 0;
@@ -2237,13 +2241,13 @@ yy203: yych = *++YYCURSOR;
default: goto yy204;
}
yy204:
-#line 953
+#line 957
{ QUOTECAT(qstr, qcapa, qidx, *YYTOKEN);
goto ScalarBlock2;
}
yy205: yych = *++YYCURSOR;
yy206:
-#line 915
+#line 919
{ lvl = CURRENT_LEVEL();
if ( lvl->status != syck_lvl_block )
{
@@ -2258,7 +2262,7 @@ yy206:
}
yy207: yych = *++YYCURSOR;
yy208:
-#line 929
+#line 933
{ YYCURSOR--;
POP_LEVEL();
RETURN_YAML_BLOCK();
@@ -2290,7 +2294,7 @@ yy213: yych = *++YYCURSOR;
}
yy214: yych = *++YYCURSOR;
yy215:
-#line 934
+#line 938
{ if ( YYTOKEN == YYLINEPTR )
{
if ( blockType == BLOCK_FOLD )
@@ -2338,7 +2342,7 @@ yy221: ++YYCURSOR;
default: goto yy212;
}
}
-#line 958
+#line 962
}
@@ -2369,7 +2373,7 @@ yy222:
}
yy224: yych = *++YYCURSOR;
yy225:
-#line 974
+#line 978
{ YYCURSOR = YYTOKEN;
return;
}
@@ -2382,7 +2386,7 @@ yy227: yych = *++YYCURSOR;
default: goto yy228;
}
yy228:
-#line 978
+#line 982
{ goto Comment;
}
yy229: yych = *++YYCURSOR;
@@ -2408,7 +2412,7 @@ yy233: YYCURSOR = YYMARKER;
case 0: goto yy225;
}
}
-#line 981
+#line 985
}