summaryrefslogtreecommitdiff
path: root/ext/syck
diff options
context:
space:
mode:
authorwhy <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-09-13 03:58:33 +0000
committerwhy <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-09-13 03:58:33 +0000
commit176a7ab72a9bb763a97ad2dadc4ce3bf357b5976 (patch)
tree43d2fe12e0eb86c4a688a22cd043f898c7683872 /ext/syck
parent19dbb4c3c17e1ec458b02587fce49950dfca0648 (diff)
* lib/yaml.rb: reworking YAML::Stream to use the new
emitter. * lib/yaml/stream.rb: ditto. * lib/yaml/rubytypes.rb: added Object#yaml_new. * lib/yaml/tag.rb: the tag_subclasses? method now shows up in the class. allow taguri to be set using an accessor. continue support of Object#to_yaml_type. * ext/syck/rubyext.c: new emitter code. yaml_new and yaml_initialize get called, should they be present. consolidated all the diaspora of internal node types into the family below YAML::Syck::Node -- Map, Seq, Scalar -- all of whom are SyckNode structs pointing to Ruby data. moved Object#yaml_new into the node_import and made it the default behavior. the target_class is always called wih yaml_new, prepended a parameter, which is the klass. loaded nodes through GenericResolver show their style. new Resolver#tagurize converts type ids to taguris. * ext/syck/implicit.re: were 'y' and 'n' seriously omitted?? * ext/syck/emitter.c: renovated emitter, walks the tree in advance. consolidated redundant block_styles struct into the scalar_style struct. (this means loaded nodes can now be sent back to emitter and preserve at least its very basic formatting.) * ext/syck/gram.c: headless documents of any kind allowed. * ext/syck/node.c: new syck_replace_str methods and syck_empty_* methods for rewriting node contents, while keeping the ID and other setup info. added syck_seq_assign. * ext/syck/syck.h: reflect block_styles and new node functions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/syck')
-rw-r--r--ext/syck/bytecode.c4
-rw-r--r--ext/syck/emitter.c1024
-rw-r--r--ext/syck/gram.c1174
-rw-r--r--ext/syck/gram.h24
-rw-r--r--ext/syck/handler.c19
-rw-r--r--ext/syck/implicit.c83
-rw-r--r--ext/syck/node.c71
-rw-r--r--ext/syck/rubyext.c1828
-rw-r--r--ext/syck/syck.c18
-rw-r--r--ext/syck/syck.h103
-rw-r--r--ext/syck/token.c1300
-rw-r--r--ext/syck/yaml2byte.c2
12 files changed, 3776 insertions, 1874 deletions
diff --git a/ext/syck/bytecode.c b/ext/syck/bytecode.c
index ae5f19d..bae1f4f 100644
--- a/ext/syck/bytecode.c
+++ b/ext/syck/bytecode.c
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.9.3 on Fri Aug 13 11:47:50 2004 */
+/* Generated by re2c 0.9.3 on Tue Apr 12 20:34:14 2005 */
#line 1 "bytecode.re"
/*
* bytecode.re
@@ -89,7 +89,7 @@ char *get_inline( SyckParser *parser );
#define ENSURE_YAML_IOPEN(last_lvl, lvl_type, to_len, reset) \
if ( last_lvl->spaces < to_len ) \
{ \
- if ( last_lvl->status == syck_lvl_inline ) \
+ if ( last_lvl->status == syck_lvl_iseq || last_lvl->status == syck_lvl_imap ) \
{ \
goto Document; \
} \
diff --git a/ext/syck/emitter.c b/ext/syck/emitter.c
index 25437b2..a4b78b6 100644
--- a/ext/syck/emitter.c
+++ b/ext/syck/emitter.c
@@ -18,16 +18,11 @@
#define DEFAULT_ANCHOR_FORMAT "id%03d"
+const char hex_table[] =
+"0123456789ABCDEF";
static char b64_table[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-struct adjust_arg {
- /* Position to start adjusting */
- long startpos;
- /* Adjusting by an offset */
- int offset;
-};
-
/*
* Built-in base64 (from Ruby's pack.c)
*/
@@ -36,7 +31,7 @@ syck_base64enc( char *s, long len )
{
long i = 0;
int padding = '=';
- char *buff = S_ALLOCA_N(char, len * 4 / 3 + 6);
+ char *buff = S_ALLOC_N(char, len * 4 / 3 + 6);
while (len >= 3) {
buff[i++] = b64_table[077 & (*s >> 2)];
@@ -116,25 +111,29 @@ syck_new_emitter()
SyckEmitter *e;
e = S_ALLOC( SyckEmitter );
e->headless = 0;
- e->seq_map = 0;
e->use_header = 0;
e->use_version = 0;
e->sort_keys = 0;
e->anchor_format = NULL;
e->explicit_typing = 0;
e->best_width = 80;
- e->block_style = block_arbitrary;
+ e->style = scalar_none;
e->stage = doc_open;
e->indent = 2;
e->level = -1;
- e->ignore_id = 0;
e->anchors = NULL;
e->markers = NULL;
+ e->anchored = NULL;
e->bufsize = SYCK_BUFFERSIZE;
e->buffer = NULL;
e->marker = NULL;
e->bufpos = 0;
- e->handler = NULL;
+ e->emitter_handler = NULL;
+ e->output_handler = NULL;
+ e->lvl_idx = 0;
+ e->lvl_capa = ALLOC_CT;
+ e->levels = S_ALLOC_N( SyckLevel, e->lvl_capa );
+ syck_emitter_reset_levels( e );
e->bonus = NULL;
return e;
}
@@ -146,13 +145,6 @@ syck_st_free_anchors( char *key, char *name, char *arg )
return ST_CONTINUE;
}
-int
-syck_st_free_markers( char *key, SyckEmitterNode *n, char *arg )
-{
- S_FREE( n );
- return ST_CONTINUE;
-}
-
void
syck_emitter_st_free( SyckEmitter *e )
{
@@ -166,27 +158,94 @@ syck_emitter_st_free( SyckEmitter *e )
e->anchors = NULL;
}
+ if ( e->anchored != NULL )
+ {
+ st_free_table( e->anchored );
+ e->anchored = NULL;
+ }
+
/*
* Free the markers tables
*/
if ( e->markers != NULL )
{
- st_foreach( e->markers, syck_st_free_markers, 0 );
st_free_table( e->markers );
e->markers = NULL;
}
}
+SyckLevel *
+syck_emitter_current_level( SyckEmitter *e )
+{
+ return &e->levels[e->lvl_idx-1];
+}
+
+SyckLevel *
+syck_emitter_parent_level( SyckEmitter *e )
+{
+ return &e->levels[e->lvl_idx-2];
+}
+
+void
+syck_emitter_pop_level( SyckEmitter *e )
+{
+ ASSERT( e != NULL );
+
+ /* The root level should never be popped */
+ if ( e->lvl_idx <= 1 ) return;
+
+ e->lvl_idx -= 1;
+ free( e->levels[e->lvl_idx].domain );
+}
+
+void
+syck_emitter_add_level( SyckEmitter *e, int len, enum syck_level_status status )
+{
+ ASSERT( e != NULL );
+ if ( e->lvl_idx + 1 > e->lvl_capa )
+ {
+ e->lvl_capa += ALLOC_CT;
+ S_REALLOC_N( e->levels, SyckLevel, e->lvl_capa );
+ }
+
+ ASSERT( len > e->levels[e->lvl_idx-1].spaces );
+ e->levels[e->lvl_idx].spaces = len;
+ e->levels[e->lvl_idx].ncount = 0;
+ e->levels[e->lvl_idx].domain = syck_strndup( e->levels[e->lvl_idx-1].domain, strlen( e->levels[e->lvl_idx-1].domain ) );
+ e->levels[e->lvl_idx].status = status;
+ e->levels[e->lvl_idx].anctag = 0;
+ e->lvl_idx += 1;
+}
+
+void
+syck_emitter_reset_levels( SyckEmitter *e )
+{
+ while ( e->lvl_idx > 1 )
+ {
+ syck_emitter_pop_level( e );
+ }
+
+ if ( e->lvl_idx < 1 )
+ {
+ e->lvl_idx = 1;
+ e->levels[0].spaces = -1;
+ e->levels[0].ncount = 0;
+ e->levels[0].domain = syck_strndup( "", 0 );
+ e->levels[0].anctag = 0;
+ }
+ e->levels[0].status = syck_lvl_header;
+}
+
void
-syck_emitter_ignore_id( SyckEmitter *e, SYMID id )
+syck_emitter_handler( SyckEmitter *e, SyckEmitterHandler hdlr )
{
- e->ignore_id = id;
+ e->emitter_handler = hdlr;
}
void
-syck_emitter_handler( SyckEmitter *e, SyckOutputHandler hdlr )
+syck_output_handler( SyckEmitter *e, SyckOutputHandler hdlr )
{
- e->handler = hdlr;
+ e->output_handler = hdlr;
}
void
@@ -196,6 +255,9 @@ syck_free_emitter( SyckEmitter *e )
* Free tables
*/
syck_emitter_st_free( e );
+ syck_emitter_reset_levels( e );
+ S_FREE( e->levels[0].domain );
+ S_FREE( e->levels );
if ( e->buffer != NULL )
{
S_FREE( e->buffer );
@@ -252,6 +314,7 @@ syck_emitter_write( SyckEmitter *e, char *str, long len )
*/
S_MEMCPY( e->marker, str, char, len );
e->marker += len;
+ e->marker[0] = '\0';
}
/*
@@ -286,12 +349,12 @@ syck_emitter_flush( SyckEmitter *e, long check_room )
char *header = S_ALLOC_N( char, 64 );
S_MEMZERO( header, char, 64 );
sprintf( header, "--- %%YAML:%d.%d ", SYCK_YAML_MAJOR, SYCK_YAML_MINOR );
- (e->handler)( e, header, strlen( header ) );
+ (e->output_handler)( e, header, strlen( header ) );
S_FREE( header );
}
else
{
- (e->handler)( e, "--- ", 4 );
+ (e->output_handler)( e, "--- ", 4 );
}
e->stage = doc_processing;
}
@@ -303,142 +366,861 @@ syck_emitter_flush( SyckEmitter *e, long check_room )
{
check_room = e->marker - e->buffer;
}
- (e->handler)( e, e->buffer, check_room );
+ (e->output_handler)( e, e->buffer, check_room );
e->bufpos += check_room;
e->marker -= check_room;
}
/*
- * Emit a simple, unquoted string.
+ * Start emitting from the given node, check for anchoring and then
+ * issue the callback to the emitter handler.
*/
void
-syck_emitter_simple( SyckEmitter *e, char *str, long len )
+syck_emit( SyckEmitter *e, st_data_t n )
{
- e->seq_map = 0;
- syck_emitter_write( e, str, len );
+ SYMID oid;
+ char *anchor_name = NULL;
+ int indent = 0, x = 0;
+ SyckLevel *lvl = syck_emitter_current_level( e );
+
+ /* Add new level */
+ if ( lvl->spaces >= 0 ) {
+ indent = lvl->spaces + e->indent;
+ }
+ syck_emitter_add_level( e, indent, syck_lvl_open );
+ lvl = syck_emitter_current_level( e );
+
+ /* Look for anchor */
+ if ( e->anchors != NULL &&
+ st_lookup( e->markers, n, (st_data_t *)&oid ) &&
+ st_lookup( e->anchors, (st_data_t)oid, (st_data_t *)&anchor_name ) )
+ {
+ if ( e->anchored == NULL )
+ {
+ e->anchored = st_init_numtable();
+ }
+
+ if ( ! st_lookup( e->anchored, (st_data_t)anchor_name, (st_data_t *)&x ) )
+ {
+ char *an = S_ALLOC_N( char, strlen( anchor_name ) + 3 );
+ sprintf( an, "&%s ", anchor_name );
+ syck_emitter_write( e, an, strlen( anchor_name ) + 2 );
+ free( an );
+
+ x = 1;
+ st_insert( e->anchored, (st_data_t)anchor_name, (st_data_t)x );
+ lvl->anctag = 1;
+ }
+ else
+ {
+ char *an = S_ALLOC_N( char, strlen( anchor_name ) + 2 );
+ sprintf( an, "*%s", anchor_name );
+ syck_emitter_write( e, an, strlen( anchor_name ) + 1 );
+ free( an );
+
+ goto end_emit;
+ }
+ }
+
+ (e->emitter_handler)( e, n );
+
+ /* Pop the level */
+end_emit:
+ syck_emitter_pop_level( e );
+ if ( e->lvl_idx == 1 ) {
+ syck_emitter_write( e, "\n", 1 );
+ e->stage = doc_open;
+ }
}
/*
- * Shift the offsets of all applicable anchors
+ * Determine what tag needs to be written, based on the taguri of the node
+ * and the implicit tag which would be assigned to this node. If a tag is
+ * required, write the tag.
+ */
+void syck_emit_tag( SyckEmitter *e, char *tag, char *ignore )
+{
+ SyckLevel *lvl;
+ if ( tag == NULL ) return;
+ if ( ignore != NULL && syck_tagcmp( tag, ignore ) == 0 && e->explicit_typing == 0 ) return;
+ lvl = syck_emitter_current_level( e );
+
+ /* implicit */
+ if ( strlen( tag ) == 0 ) {
+ syck_emitter_write( e, "! ", 2 );
+
+ /* global types */
+ } else if ( strncmp( tag, "tag:", 4 ) == 0 ) {
+ int taglen = strlen( tag );
+ syck_emitter_write( e, "!", 1 );
+ if ( strncmp( tag + 4, YAML_DOMAIN, strlen( YAML_DOMAIN ) ) == 0 ) {
+ int skip = 4 + strlen( YAML_DOMAIN ) + 1;
+ syck_emitter_write( e, tag + skip, taglen - skip );
+ } else {
+ char *subd = tag + 4;
+ while ( *subd != ':' && *subd != '\0' ) subd++;
+ if ( *subd == ':' ) {
+ if ( subd - tag > ( strlen( YAML_DOMAIN ) + 5 ) &&
+ strncmp( subd - strlen( YAML_DOMAIN ), YAML_DOMAIN, strlen( YAML_DOMAIN ) ) == 0 ) {
+ syck_emitter_write( e, tag + 4, subd - strlen( YAML_DOMAIN ) - ( tag + 4 ) - 1 );
+ syck_emitter_write( e, "/", 1 );
+ syck_emitter_write( e, subd + 1, ( tag + taglen ) - ( subd + 1 ) );
+ } else {
+ syck_emitter_write( e, tag + 4, subd - ( tag + 4 ) );
+ syck_emitter_write( e, "/", 1 );
+ syck_emitter_write( e, subd + 1, ( tag + taglen ) - ( subd + 1 ) );
+ }
+ } else {
+ /* TODO: Invalid tag (no colon after domain) */
+ return;
+ }
+ }
+ syck_emitter_write( e, " ", 1 );
+
+ /* private types */
+ } else if ( strncmp( tag, "x-private:", 10 ) == 0 ) {
+ syck_emitter_write( e, "!!", 2 );
+ syck_emitter_write( e, tag + 10, strlen( tag ) - 10 );
+ syck_emitter_write( e, " ", 1 );
+ }
+ lvl->anctag = 1;
+}
+
+/*
+ * Emit a newline and an appropriately spaced indent.
+ */
+void syck_emit_indent( SyckEmitter *e )
+{
+ int i;
+ SyckLevel *lvl = syck_emitter_current_level( e );
+ if ( lvl->spaces >= 0 ) {
+ char *spcs = S_ALLOC_N( char, lvl->spaces + 2 );
+
+ spcs[0] = '\n'; spcs[lvl->spaces + 1] = '\0';
+ for ( i = 0; i < lvl->spaces; i++ ) spcs[i+1] = ' ';
+ syck_emitter_write( e, spcs, lvl->spaces + 1 );
+ free( spcs );
+ }
+}
+
+/* Clear the scan */
+#define SCAN_NONE 0
+/* All printable characters? */
+#define SCAN_NONPRINT 1
+/* Any indented lines? */
+#define SCAN_INDENTED 2
+/* Larger than the requested width? */
+#define SCAN_WIDE 4
+/* Opens with whitespace? */
+#define SCAN_WHITESTART 8
+/* Contains a newline */
+#define SCAN_NEWLINE 16
+/* Contains a single quote */
+#define SCAN_SINGLEQ 32
+/* Contains a double quote */
+#define SCAN_DOUBLEQ 64
+/* Starts with a token */
+#define SCAN_INDIC_S 128
+/* Contains a flow indicator */
+#define SCAN_INDIC_C 256
+/* Ends without newlines */
+#define SCAN_NONL_E 512
+/* Ends with many newlines */
+#define SCAN_MANYNL_E 1024
+/* Contains flow map indicators */
+#define SCAN_FLOWMAP 2048
+/* Contains flow seq indicators */
+#define SCAN_FLOWSEQ 4096
+/* Contains a valid doc separator */
+#define SCAN_DOCSEP 8192
+
+/*
+ * Basic printable test for LATIN-1 characters.
*/
int
-syck_adjust_anchors( char *key, SyckEmitterNode *n, struct adjust_arg *arg )
+syck_scan_scalar( int req_width, char *cursor, long len )
+{
+ long i = 0, start = 0;
+ int flags = SCAN_NONE;
+
+ if ( len < 1 ) return flags;
+
+ /* c-indicators from the spec */
+ if ( cursor[0] == '[' || cursor[0] == ']' ||
+ cursor[0] == '{' || cursor[0] == '}' ||
+ cursor[0] == '!' || cursor[0] == '*' ||
+ cursor[0] == '&' || cursor[0] == '|' ||
+ cursor[0] == '>' || cursor[0] == '\'' ||
+ cursor[0] == '"' || cursor[0] == '#' ||
+ cursor[0] == '%' || cursor[0] == '@' ||
+ cursor[0] == '&' ) {
+ flags |= SCAN_INDIC_S;
+ }
+ if ( ( cursor[0] == '-' || cursor[0] == ':' ||
+ cursor[0] == '?' || cursor[0] == ',' ) &&
+ cursor[1] == ' ' ) {
+ flags |= SCAN_INDIC_S;
+ }
+
+ /* ending newlines */
+ if ( cursor[len-1] != '\n' ) {
+ flags |= SCAN_NONL_E;
+ } else if ( len > 1 && cursor[len-2] == '\n' ) {
+ flags |= SCAN_MANYNL_E;
+ }
+
+ /* opening doc sep */
+ if ( len >= 3 && strncmp( cursor, "---", 3 ) == 0 )
+ flags |= SCAN_DOCSEP;
+
+ /* scan string */
+ for ( i = 0; i < len; i++ ) {
+
+ if ( ! ( cursor[i] == 0x9 ||
+ cursor[i] == 0xA ||
+ cursor[i] == 0xD ||
+ ( cursor[i] >= 0x20 && cursor[i] <= 0x7E ) )
+ ) {
+ flags |= SCAN_NONPRINT;
+ }
+ else if ( cursor[i] == '\n' ) {
+ flags |= SCAN_NEWLINE;
+ if ( len - i >= 3 && strncmp( &cursor[i+1], "---", 3 ) == 0 )
+ flags |= SCAN_DOCSEP;
+ if ( cursor[i+1] == ' ' || cursor[i+1] == '\t' )
+ flags |= SCAN_INDENTED;
+ if ( req_width > 0 && i - start > req_width )
+ flags |= SCAN_WIDE;
+ start = i;
+ }
+ else if ( cursor[i] == '\'' )
+ {
+ flags |= SCAN_SINGLEQ;
+ }
+ else if ( cursor[i] == '"' )
+ {
+ flags |= SCAN_DOUBLEQ;
+ }
+ else if ( cursor[i] == ']' )
+ {
+ flags |= SCAN_FLOWSEQ;
+ }
+ else if ( cursor[i] == '}' )
+ {
+ flags |= SCAN_FLOWMAP;
+ }
+ /* remember, if plain collections get implemented, to add nb-plain-flow-char */
+ else if ( ( cursor[i] == ' ' && cursor[i+1] == '#' ) ||
+ ( cursor[i] == ':' && cursor[i+1] == ' ' ) )
+ {
+ flags |= SCAN_INDIC_C;
+ }
+ else if ( cursor[i] == ',' && cursor[i+1] == ' ' )
+ {
+ flags |= SCAN_FLOWMAP;
+ flags |= SCAN_FLOWSEQ;
+ }
+
+ if ( i == 0 &&
+ ( cursor[i] == ' ' || cursor[i] == '\t' )
+ ) {
+ flags |= SCAN_WHITESTART;
+ }
+ }
+
+ /* printf( "---STR---\n%s\nFLAGS: %d\n", cursor, flags ); */
+ return flags;
+}
+/*
+ * All scalars should be emitted through this function, which determines an appropriate style,
+ * tag and indent.
+ */
+void syck_emit_scalar( SyckEmitter *e, char *tag, enum scalar_style force_style, int force_indent, int force_width,
+ char keep_nl, char *str, long len )
{
- if ( arg->startpos < n->pos )
+ enum scalar_style favor_style = scalar_literal;
+ SyckLevel *parent = syck_emitter_parent_level( e );
+ SyckLevel *lvl = syck_emitter_current_level( e );
+ int scan;
+ char *implicit;
+
+ if ( str == NULL ) str = "";
+
+ /* No empty nulls as map keys */
+ if ( len == 0 && ( parent->status == syck_lvl_map || parent->status == syck_lvl_imap ) &&
+ parent->ncount % 2 == 1 && syck_tagcmp( tag, "tag:yaml.org,2002:null" ) == 0 )
{
- n->pos += arg->offset;
+ str = "~";
+ len = 1;
+ }
+
+ scan = syck_scan_scalar( force_width, str, len );
+ implicit = syck_match_implicit( str, len );
+
+ /* quote strings which default to implicits */
+ implicit = syck_taguri( YAML_DOMAIN, implicit, strlen( implicit ) );
+ if ( syck_tagcmp( tag, implicit ) != 0 && syck_tagcmp( tag, "tag:yaml.org,2002:str" ) == 0 ) {
+ force_style = scalar_2quote;
+ } else {
+ syck_emit_tag( e, tag, implicit );
+ }
+ S_FREE( implicit );
+
+ /* if still arbitrary, sniff a good block style. */
+ if ( force_style == scalar_none ) {
+ if ( scan & SCAN_NEWLINE ) {
+ force_style = scalar_literal;
+ } else {
+ force_style = scalar_plain;
+ }
+ }
+
+ if ( e->style == scalar_fold ) {
+ favor_style = scalar_fold;
+ }
+
+ /* Determine block style */
+ if ( scan & SCAN_NONPRINT ) {
+ force_style = scalar_2quote;
+ } else if ( scan & SCAN_WHITESTART ) {
+ force_style = scalar_2quote;
+ } else if ( force_style != scalar_fold && ( scan & SCAN_INDENTED ) ) {
+ force_style = scalar_literal;
+ } else if ( force_style == scalar_plain && ( scan & SCAN_NEWLINE ) ) {
+ force_style = favor_style;
+ } else if ( force_style == scalar_plain && parent->status == syck_lvl_iseq && ( scan & SCAN_FLOWSEQ ) ) {
+ force_style = scalar_2quote;
+ } else if ( force_style == scalar_plain && parent->status == syck_lvl_imap && ( scan & SCAN_FLOWMAP ) ) {
+ force_style = scalar_2quote;
+ /* } else if ( force_style == scalar_fold && ( ! ( scan & SCAN_WIDE ) ) ) {
+ force_style = scalar_literal; */
+ } else if ( force_style == scalar_plain && ( scan & SCAN_INDIC_S || scan & SCAN_INDIC_C ) ) {
+ if ( scan & SCAN_NEWLINE ) {
+ force_style = favor_style;
+ } else {
+ force_style = scalar_2quote;
+ }
+ }
+
+ if ( force_indent > 0 ) {
+ lvl->spaces = parent->spaces + force_indent;
+ } else if ( scan & SCAN_DOCSEP ) {
+ lvl->spaces = parent->spaces + e->indent;
+ }
+
+ /* For now, all ambiguous keys are going to be double-quoted */
+ if ( parent->status == syck_lvl_map && parent->ncount % 2 == 1 ) {
+ if ( force_style != scalar_plain ) {
+ force_style = scalar_2quote;
+ }
+ }
+
+ /* If the parent is an inline, double quote anything complex */
+ if ( parent->status == syck_lvl_imap || parent->status == syck_lvl_iseq ) {
+ if ( force_style != scalar_plain && force_style != scalar_1quote ) {
+ force_style = scalar_2quote;
+ }
+ }
+
+ /* Fix the ending newlines */
+ if ( scan & SCAN_NONL_E ) {
+ keep_nl = NL_CHOMP;
+ } else if ( scan & SCAN_MANYNL_E ) {
+ keep_nl = NL_KEEP;
+ }
+
+ /* Write the text node */
+ switch ( force_style )
+ {
+ case scalar_1quote:
+ syck_emit_1quoted( e, force_width, str, len );
+ break;
+
+ case scalar_2quote:
+ syck_emit_2quoted( e, force_width, str, len );
+ break;
+
+ case scalar_fold:
+ syck_emit_folded( e, force_width, keep_nl, str, len );
+ break;
+
+ case scalar_literal:
+ syck_emit_literal( e, keep_nl, str, len );
+ break;
+
+ case scalar_plain:
+ syck_emitter_write( e, str, len );
+ break;
+ }
+}
+
+void
+syck_emitter_escape( SyckEmitter *e, char *src, long len )
+{
+ int i;
+ for( i = 0; i < len; i++ )
+ {
+ if( (src[i] < 0x20) || (0x7E < src[i]) )
+ {
+ syck_emitter_write( e, "\\", 1 );
+ if( '\0' == src[i] )
+ syck_emitter_write( e, "0", 1 );
+ else
+ {
+ syck_emitter_write( e, "x", 1 );
+ syck_emitter_write( e, (char *)hex_table + ((src[i] & 0xF0) >> 4), 1 );
+ syck_emitter_write( e, (char *)hex_table + (src[i] & 0x0F), 1 );
+ }
+ }
+ else
+ {
+ syck_emitter_write( e, src + i, 1 );
+ if( '\\' == src[i] )
+ syck_emitter_write( e, "\\", 1 );
+ }
}
- return ST_CONTINUE;
}
/*
- * call on start of an object's marshalling
- * (handles anchors, returns an alias)
+ * Outputs a single-quoted block.
*/
-char *
-syck_emitter_start_obj( SyckEmitter *e, SYMID oid )
+void syck_emit_1quoted( SyckEmitter *e, int width, char *str, long len )
{
- SyckEmitterNode *n = NULL;
- char *anchor_name = NULL;
+ char do_indent = 0;
+ char *mark = str;
+ char *start = str;
+ char *end = str;
+ syck_emitter_write( e, "'", 1 );
+ while ( mark < str + len ) {
+ if ( do_indent ) {
+ syck_emit_indent( e );
+ do_indent = 0;
+ }
+ switch ( *mark ) {
+ case '\'': syck_emitter_write( e, "'", 1 ); break;
+
+ case '\n':
+ end = mark + 1;
+ if ( *start != ' ' && *start != '\n' && *end != '\n' && *end != ' ' ) {
+ syck_emitter_write( e, "\n\n", 2 );
+ } else {
+ syck_emitter_write( e, "\n", 1 );
+ }
+ do_indent = 1;
+ start = mark + 1;
+ break;
+
+ case ' ':
+ if ( width > 0 && *start != ' ' && mark - end > width ) {
+ do_indent = 1;
+ end = mark + 1;
+ } else {
+ syck_emitter_write( e, " ", 1 );
+ }
+ break;
+
+ default:
+ syck_emitter_write( e, mark, 1 );
+ break;
+ }
+ mark++;
+ }
+ syck_emitter_write( e, "'", 1 );
+}
+
+/*
+ * Outputs a double-quoted block.
+ */
+void syck_emit_2quoted( SyckEmitter *e, int width, char *str, long len )
+{
+ char do_indent = 0;
+ char *mark = str;
+ char *start = str;
+ char *end = str;
+ syck_emitter_write( e, "\"", 1 );
+ while ( mark < str + len ) {
+ if ( do_indent > 0 ) {
+ if ( do_indent == 2 ) {
+ syck_emitter_write( e, "\\", 1 );
+ }
+ syck_emit_indent( e );
+ do_indent = 0;
+ }
+ switch ( *mark ) {
+
+ /* Escape sequences allowed within double quotes. */
+ case '"': syck_emitter_write( e, "\\\"", 2 ); break;
+ case '\\': syck_emitter_write( e, "\\\\", 2 ); break;
+ case '\0': syck_emitter_write( e, "\\0", 2 ); break;
+ case '\a': syck_emitter_write( e, "\\a", 2 ); break;
+ case '\b': syck_emitter_write( e, "\\b", 2 ); break;
+ case '\f': syck_emitter_write( e, "\\f", 2 ); break;
+ case '\r': syck_emitter_write( e, "\\r", 2 ); break;
+ case '\t': syck_emitter_write( e, "\\t", 2 ); break;
+ case '\v': syck_emitter_write( e, "\\v", 2 ); break;
+ case 0x1b: syck_emitter_write( e, "\\e", 2 ); break;
+
+ case '\n':
+ end = mark + 1;
+ syck_emitter_write( e, "\\n", 2 );
+ do_indent = 2;
+ start = mark + 1;
+ if ( start < str + len && ( *start == ' ' || *start == '\n' ) ) {
+ do_indent = 0;
+ }
+ break;
+
+ case ' ':
+ if ( width > 0 && *start != ' ' && mark - end > width ) {
+ do_indent = 1;
+ end = mark + 1;
+ } else {
+ syck_emitter_write( e, " ", 1 );
+ }
+ break;
+
+ default:
+ syck_emitter_escape( e, mark, 1 );
+ break;
+ }
+ mark++;
+ }
+ syck_emitter_write( e, "\"", 1 );
+}
- e->level++;
- if ( oid != e->ignore_id )
+/*
+ * Outputs a literal block.
+ */
+void syck_emit_literal( SyckEmitter *e, char keep_nl, char *str, long len )
+{
+ char *mark = str;
+ char *start = str;
+ char *end = str;
+ syck_emitter_write( e, "|", 1 );
+ if ( keep_nl == NL_CHOMP ) {
+ syck_emitter_write( e, "-", 1 );
+ } else if ( keep_nl == NL_KEEP ) {
+ syck_emitter_write( e, "+", 1 );
+ }
+ syck_emit_indent( e );
+ while ( mark < str + len ) {
+ if ( *mark == '\n' ) {
+ end = mark;
+ if ( *start != ' ' && *start != '\n' && *end != '\n' && *end != ' ' ) end += 1;
+ syck_emitter_write( e, start, end - start );
+ if ( mark + 1 == str + len ) {
+ if ( keep_nl != NL_KEEP ) syck_emitter_write( e, "\n", 1 );
+ } else {
+ syck_emit_indent( e );
+ }
+ start = mark + 1;
+ }
+ mark++;
+ }
+ end = str + len;
+ if ( start < end ) {
+ syck_emitter_write( e, start, end - start );
+ }
+}
+
+/*
+ * Outputs a folded block.
+ */
+void syck_emit_folded( SyckEmitter *e, int width, char keep_nl, char *str, long len )
+{
+ char *mark = str;
+ char *start = str;
+ char *end = str;
+ syck_emitter_write( e, ">", 1 );
+ if ( keep_nl == NL_CHOMP ) {
+ syck_emitter_write( e, "-", 1 );
+ } else if ( keep_nl == NL_KEEP ) {
+ syck_emitter_write( e, "+", 1 );
+ }
+ syck_emit_indent( e );
+ if ( width <= 0 ) width = e->best_width;
+ while ( mark < str + len ) {
+ switch ( *mark ) {
+ case '\n':
+ syck_emitter_write( e, end, mark - end );
+ end = mark + 1;
+ if ( *start != ' ' && *start != '\n' && *end != '\n' && *end != ' ' ) {
+ syck_emitter_write( e, "\n", 1 );
+ }
+ if ( mark + 1 == str + len ) {
+ if ( keep_nl != NL_KEEP ) syck_emitter_write( e, "\n", 1 );
+ } else {
+ syck_emit_indent( e );
+ }
+ start = mark + 1;
+ break;
+
+ case ' ':
+ if ( *start != ' ' ) {
+ if ( mark - end > width ) {
+ syck_emitter_write( e, end, mark - end );
+ syck_emit_indent( e );
+ end = mark + 1;
+ }
+ }
+ break;
+ }
+ mark++;
+ }
+ if ( end < mark ) {
+ syck_emitter_write( e, end, mark - end );
+ }
+}
+
+/*
+ * Begins emission of a sequence.
+ */
+void syck_emit_seq( SyckEmitter *e, char *tag, enum seq_style style )
+{
+ SyckLevel *parent = syck_emitter_parent_level( e );
+ SyckLevel *lvl = syck_emitter_current_level( e );
+ syck_emit_tag( e, tag, "tag:yaml.org,2002:seq" );
+ if ( style == seq_inline || ( parent->status == syck_lvl_imap || parent->status == syck_lvl_iseq ) ) {
+ syck_emitter_write( e, "[", 1 );
+ lvl->status = syck_lvl_iseq;
+ } else {
+ lvl->status = syck_lvl_seq;
+ }
+}
+
+/*
+ * Begins emission of a mapping.
+ */
+void syck_emit_map( SyckEmitter *e, char *tag, enum map_style style )
+{
+ SyckLevel *parent = syck_emitter_parent_level( e );
+ SyckLevel *lvl = syck_emitter_current_level( e );
+ syck_emit_tag( e, tag, "tag:yaml.org,2002:map" );
+ if ( style == map_inline || ( parent->status == syck_lvl_imap || parent->status == syck_lvl_iseq ) ) {
+ syck_emitter_write( e, "{", 1 );
+ lvl->status = syck_lvl_imap;
+ } else {
+ lvl->status = syck_lvl_map;
+ }
+}
+
+/*
+ * Handles emitting of a collection item (for both
+ * sequences and maps)
+ */
+void syck_emit_item( SyckEmitter *e, st_data_t n )
+{
+ SyckLevel *lvl = syck_emitter_current_level( e );
+ switch ( lvl->status )
{
- /*
- * Look for anchors
- */
- if ( e->markers == NULL )
+ case syck_lvl_seq:
{
- e->markers = st_init_numtable();
+ SyckLevel *parent = syck_emitter_parent_level( e );
+
+ /* seq-in-map shortcut */
+ if ( parent->status == syck_lvl_map && lvl->ncount == 0 ) {
+ /* complex key */
+ if ( parent->ncount % 2 == 1 ) {
+ syck_emitter_write( e, "?", 1 );
+ parent->status = syck_lvl_mapx;
+ /* shortcut -- the lvl->anctag check should be unneccesary but
+ * there is a nasty shift/reduce in the parser on this point and
+ * i'm not ready to tickle it. */
+ } else if ( lvl->anctag == 0 ) {
+ lvl->spaces = parent->spaces;
+ }
+ }
+
+ /* seq-in-seq shortcut */
+ else if ( lvl->anctag == 0 && parent->status == syck_lvl_seq && lvl->ncount == 0 ) {
+ int spcs = ( lvl->spaces - parent->spaces ) - 2;
+ if ( spcs >= 0 ) {
+ int i = 0;
+ for ( i = 0; i < spcs; i++ ) {
+ syck_emitter_write( e, " ", 1 );
+ }
+ syck_emitter_write( e, "- ", 2 );
+ break;
+ }
+ }
+
+ syck_emit_indent( e );
+ syck_emitter_write( e, "- ", 2 );
}
+ break;
- /*
- * Markers table initially marks the string position of the
- * object. Doesn't yet create an anchor, simply notes the
- * position.
- */
- if ( ! st_lookup( e->markers, (st_data_t)oid, (st_data_t *)&n ) )
+ case syck_lvl_iseq:
{
- /*
- * Store all markers
- */
- n = S_ALLOC( SyckEmitterNode );
- n->is_shortcut = 0;
- n->indent = e->level * e->indent;
- n->pos = e->bufpos + ( e->marker - e->buffer );
- st_insert( e->markers, (st_data_t)oid, (st_data_t)n );
+ if ( lvl->ncount > 0 ) {
+ syck_emitter_write( e, ", ", 2 );
+ }
}
- else
+ break;
+
+ case syck_lvl_map:
{
- if ( e->anchors == NULL )
- {
- e->anchors = st_init_numtable();
+ SyckLevel *parent = syck_emitter_parent_level( e );
+
+ /* map-in-map */
+ if ( parent->status == syck_lvl_map && lvl->ncount == 0 ) {
+ /* complex key */
+ if ( parent->ncount % 2 == 1 ) {
+ syck_emitter_write( e, "?", 1 );
+ parent->status = syck_lvl_mapx;
+ }
}
- if ( ! st_lookup( e->anchors, (st_data_t)oid, (st_data_t *)&anchor_name ) )
- {
- int idx = 0;
- /*
- * Second time hitting this object, let's give it an anchor
- */
- idx = e->anchors->num_entries + 1;
-
- /*
- * Create the anchor tag
- */
- if ( n->pos >= e->bufpos )
- {
- int alen;
- struct adjust_arg *args = S_ALLOC( struct adjust_arg );
- char *start = e->buffer + ( n->pos - e->bufpos );
-
- char *anc = ( e->anchor_format == NULL ? DEFAULT_ANCHOR_FORMAT : e->anchor_format );
- anchor_name = S_ALLOC_N( char, strlen( anc ) + 10 );
- S_MEMZERO( anchor_name, char, strlen( anc ) + 10 );
- sprintf( anchor_name, anc, idx );
-
- /*
- * Need to flush the buffer some, if there is not room for the anchor.
- */
- alen = strlen( anchor_name ) + 2;
- syck_emitter_flush( e, alen );
-
- /*
- * Write the anchor into the buffer
- */
- S_MEMMOVE( start + alen, start, char, e->marker - start );
- S_MEMCPY( start + 1, anchor_name, char, strlen( anchor_name ) );
- start[0] = '&';
- start[alen - 1] = ' ';
- e->marker += alen;
-
- /*
- * Cycle through anchors, modify for the size of the anchor.
- */
- args->startpos = n->pos;
- args->offset = alen;
- st_foreach( e->markers, syck_adjust_anchors, (st_data_t)args );
- S_FREE( args );
-
- /*
- * Insert into anchors table
- */
- st_insert( e->anchors, (st_data_t)oid, (st_data_t)anchor_name );
+ /* map-in-seq shortcut */
+ if ( lvl->anctag == 0 && parent->status == syck_lvl_seq && lvl->ncount == 0 ) {
+ int spcs = ( lvl->spaces - parent->spaces ) - 2;
+ if ( spcs >= 0 ) {
+ int i = 0;
+ for ( i = 0; i < spcs; i++ ) {
+ syck_emitter_write( e, " ", 1 );
+ }
+ break;
+ }
+ }
+
+ if ( lvl->ncount % 2 == 0 ) {
+ syck_emit_indent( e );
+ } else {
+ syck_emitter_write( e, ": ", 2 );
+ }
+ }
+ break;
+
+ case syck_lvl_mapx:
+ {
+ if ( lvl->ncount % 2 == 0 ) {
+ syck_emit_indent( e );
+ lvl->status = syck_lvl_map;
+ } else {
+ int i;
+ if ( lvl->spaces > 0 ) {
+ char *spcs = S_ALLOC_N( char, lvl->spaces + 1 );
+
+ spcs[lvl->spaces] = '\0';
+ for ( i = 0; i < lvl->spaces; i++ ) spcs[i] = ' ';
+ syck_emitter_write( e, spcs, lvl->spaces );
+ S_FREE( spcs );
}
+ syck_emitter_write( e, ": ", 2 );
}
+ }
+ break;
+ case syck_lvl_imap:
+ {
+ if ( lvl->ncount > 0 ) {
+ if ( lvl->ncount % 2 == 0 ) {
+ syck_emitter_write( e, ", ", 2 );
+ } else {
+ syck_emitter_write( e, ": ", 2 );
+ }
+ }
}
+ break;
}
+ lvl->ncount++;
- return anchor_name;
+ syck_emit( e, n );
}
/*
- * call on completion of an object's marshalling
+ * Closes emission of a collection.
*/
-void
-syck_emitter_end_obj( SyckEmitter *e )
+void syck_emit_end( SyckEmitter *e )
{
- e->level--;
+ SyckLevel *lvl = syck_emitter_current_level( e );
+ SyckLevel *parent = syck_emitter_parent_level( e );
+ switch ( lvl->status )
+ {
+ case syck_lvl_seq:
+ if ( lvl->ncount == 0 ) {
+ syck_emitter_write( e, "[]\n", 3 );
+ } else if ( parent->status == syck_lvl_mapx ) {
+ syck_emitter_write( e, "\n", 1 );
+ }
+ break;
+
+ case syck_lvl_iseq:
+ syck_emitter_write( e, "]\n", 1 );
+ break;
+
+ case syck_lvl_map:
+ if ( lvl->ncount == 0 ) {
+ syck_emitter_write( e, "{}\n", 3 );
+ } else if ( lvl->ncount % 2 == 1 ) {
+ syck_emitter_write( e, ":\n", 1 );
+ } else if ( parent->status == syck_lvl_mapx ) {
+ syck_emitter_write( e, "\n", 1 );
+ }
+ break;
+
+ case syck_lvl_imap:
+ syck_emitter_write( e, "}\n", 1 );
+ break;
+ }
+}
+
+/*
+ * Fill markers table with emitter nodes in the
+ * soon-to-be-emitted tree.
+ */
+SYMID
+syck_emitter_mark_node( SyckEmitter *e, st_data_t n )
+{
+ SYMID oid = 0;
+ char *anchor_name = NULL;
+
+ /*
+ * Ensure markers table is initialized.
+ */
+ if ( e->markers == NULL )
+ {
+ e->markers = st_init_numtable();
+ }
+
+ /*
+ * Markers table initially marks the string position of the
+ * object. Doesn't yet create an anchor, simply notes the
+ * position.
+ */
+ if ( ! st_lookup( e->markers, n, (st_data_t *)&oid ) )
+ {
+ /*
+ * Store all markers
+ */
+ oid = e->markers->num_entries + 1;
+ st_insert( e->markers, n, (st_data_t)oid );
+ }
+ else
+ {
+ if ( e->anchors == NULL )
+ {
+ e->anchors = st_init_numtable();
+ }
+
+ if ( ! st_lookup( e->anchors, (st_data_t)oid, (st_data_t *)&anchor_name ) )
+ {
+ int idx = 0;
+ char *anc = ( e->anchor_format == NULL ? DEFAULT_ANCHOR_FORMAT : e->anchor_format );
+
+ /*
+ * Second time hitting this object, let's give it an anchor
+ */
+ idx = e->anchors->num_entries + 1;
+ anchor_name = S_ALLOC_N( char, strlen( anc ) + 10 );
+ S_MEMZERO( anchor_name, char, strlen( anc ) + 10 );
+ sprintf( anchor_name, anc, idx );
+
+ /*
+ * Insert into anchors table
+ */
+ st_insert( e->anchors, (st_data_t)oid, (st_data_t)anchor_name );
+ }
+ }
+ return oid;
}
diff --git a/ext/syck/gram.c b/ext/syck/gram.c
index dd65ea1..615a594 100644
--- a/ext/syck/gram.c
+++ b/ext/syck/gram.c
@@ -1,7 +1,7 @@
-/* A Bison parser, made from gram.y, by GNU bison 1.75. */
+/* A Bison parser, made by GNU Bison 1.875d. */
/* Skeleton parser for Yacc-like parsing with Bison,
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -34,10 +34,13 @@
USER NAME SPACE" below. */
/* Identify Bison output. */
-#define YYBISON 1
+#define YYBISON 1
+
+/* Skeleton name. */
+#define YYSKELETON_NAME "yacc.c"
/* Pure parsers. */
-#define YYPURE 1
+#define YYPURE 1
/* Using locations. */
#define YYLSP_NEEDED 0
@@ -95,6 +98,8 @@
#include "syck.h"
+void apply_seq_in_map( SyckParser *parser, SyckNode *n );
+
#define YYPARSE_PARAM parser
#define YYLEX_PARAM parser
@@ -123,51 +128,49 @@
# define YYERROR_VERBOSE 0
#endif
-#ifndef YYSTYPE
-#line 33 "gram.y"
-typedef union {
+#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
+#line 35 "gram.y"
+typedef union YYSTYPE {
SYMID nodeId;
SyckNode *nodeData;
char *name;
-} yystype;
-/* Line 193 of /usr/local/share/bison/yacc.c. */
-#line 135 "y.tab.c"
-# define YYSTYPE yystype
+} YYSTYPE;
+/* Line 191 of yacc.c. */
+#line 140 "gram.c"
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
-#ifndef YYLTYPE
-typedef struct yyltype
-{
- int first_line;
- int first_column;
- int last_line;
- int last_column;
-} yyltype;
-# define YYLTYPE yyltype
-# define YYLTYPE_IS_TRIVIAL 1
-#endif
+
/* Copy the second part of user declarations. */
-/* Line 213 of /usr/local/share/bison/yacc.c. */
-#line 156 "y.tab.c"
+/* Line 214 of yacc.c. */
+#line 152 "gram.c"
#if ! defined (yyoverflow) || YYERROR_VERBOSE
+# ifndef YYFREE
+# define YYFREE free
+# endif
+# ifndef YYMALLOC
+# define YYMALLOC malloc
+# endif
+
/* The parser invokes alloca or malloc; define the necessary symbols. */
-# if YYSTACK_USE_ALLOCA
-# define YYSTACK_ALLOC alloca
+# ifdef YYSTACK_USE_ALLOCA
+# if YYSTACK_USE_ALLOCA
+# define YYSTACK_ALLOC alloca
+# endif
# else
-# ifndef YYSTACK_USE_ALLOCA
-# if defined (alloca) || defined (_ALLOCA_H)
-# define YYSTACK_ALLOC alloca
-# else
-# ifdef __GNUC__
-# define YYSTACK_ALLOC __builtin_alloca
-# endif
+# if defined (alloca) || defined (_ALLOCA_H)
+# define YYSTACK_ALLOC alloca
+# else
+# ifdef __GNUC__
+# define YYSTACK_ALLOC __builtin_alloca
# endif
# endif
# endif
@@ -180,36 +183,36 @@ typedef struct yyltype
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# endif
-# define YYSTACK_ALLOC malloc
-# define YYSTACK_FREE free
+# define YYSTACK_ALLOC YYMALLOC
+# define YYSTACK_FREE YYFREE
# endif
#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
#if (! defined (yyoverflow) \
&& (! defined (__cplusplus) \
- || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
+ || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
/* A type that is properly aligned for any stack member. */
union yyalloc
{
- short yyss;
+ short int yyss;
YYSTYPE yyvs;
};
/* The size of the maximum gap between one aligned stack and the next. */
-# define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
+# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
/* The size of an array large to enough to hold all stacks, each with
N elements. */
# define YYSTACK_BYTES(N) \
- ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
- + YYSTACK_GAP_MAX)
+ ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
+ + YYSTACK_GAP_MAXIMUM)
/* Copy COUNT objects from FROM to TO. The source and destination do
not overlap. */
# ifndef YYCOPY
-# if 1 < __GNUC__
+# if defined (__GNUC__) && 1 < __GNUC__
# define YYCOPY(To, From, Count) \
__builtin_memcpy (To, From, (Count) * sizeof (*(From)))
# else
@@ -218,7 +221,7 @@ union yyalloc
{ \
register YYSIZE_T yyi; \
for (yyi = 0; yyi < (Count); yyi++) \
- (To)[yyi] = (From)[yyi]; \
+ (To)[yyi] = (From)[yyi]; \
} \
while (0)
# endif
@@ -235,7 +238,7 @@ union yyalloc
YYSIZE_T yynewbytes; \
YYCOPY (&yyptr->Stack, Stack, yysize); \
Stack = &yyptr->Stack; \
- yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \
+ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
yyptr += yynewbytes / sizeof (*yyptr); \
} \
while (0)
@@ -245,19 +248,20 @@ union yyalloc
#if defined (__STDC__) || defined (__cplusplus)
typedef signed char yysigned_char;
#else
- typedef short yysigned_char;
+ typedef short int yysigned_char;
#endif
/* YYFINAL -- State number of the termination state. */
-#define YYFINAL 38
-#define YYLAST 422
+#define YYFINAL 52
+/* YYLAST -- Last index in YYTABLE. */
+#define YYLAST 396
/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 23
/* YYNNTS -- Number of nonterminals. */
-#define YYNNTS 28
+#define YYNNTS 29
/* YYNRULES -- Number of rules. */
-#define YYNRULES 75
+#define YYNRULES 79
/* YYNRULES -- Number of states. */
#define YYNSTATES 128
@@ -265,8 +269,8 @@ union yyalloc
#define YYUNDEFTOK 2
#define YYMAXUTOK 269
-#define YYTRANSLATE(X) \
- ((unsigned)(X) <= YYMAXUTOK ? yytranslate[X] : YYUNDEFTOK)
+#define YYTRANSLATE(YYX) \
+ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
static const unsigned char yytranslate[] =
@@ -305,54 +309,55 @@ static const unsigned char yytranslate[] =
YYRHS. */
static const unsigned char yyprhs[] =
{
- 0, 0, 3, 5, 8, 9, 11, 13, 15, 19,
- 21, 24, 27, 30, 34, 36, 39, 40, 42, 45,
- 47, 49, 51, 54, 57, 60, 63, 66, 68, 70,
- 72, 76, 78, 80, 82, 84, 86, 90, 93, 95,
- 99, 102, 106, 109, 113, 116, 118, 122, 125, 129,
- 132, 134, 138, 140, 142, 146, 150, 154, 157, 161,
- 164, 168, 171, 175, 177, 183, 185, 189, 193, 196,
- 200, 204, 207, 209, 213, 215
+ 0, 0, 3, 5, 8, 9, 11, 13, 15, 18,
+ 21, 24, 28, 30, 32, 36, 37, 40, 43, 46,
+ 49, 51, 54, 56, 58, 60, 63, 66, 69, 72,
+ 75, 77, 79, 81, 85, 87, 89, 91, 93, 95,
+ 99, 103, 106, 110, 113, 117, 120, 124, 127, 129,
+ 133, 136, 140, 143, 145, 149, 151, 153, 157, 161,
+ 165, 168, 172, 175, 179, 182, 184, 188, 190, 194,
+ 196, 200, 204, 207, 211, 215, 218, 220, 224, 226
};
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
static const yysigned_char yyrhs[] =
{
- 24, 0, -1, 26, -1, 11, 28, -1, -1, 33,
- -1, 27, -1, 34, -1, 29, 26, 32, -1, 34,
- -1, 5, 27, -1, 6, 27, -1, 3, 27, -1,
- 29, 27, 32, -1, 25, -1, 29, 30, -1, -1,
- 12, -1, 29, 13, -1, 14, -1, 13, -1, 14,
- -1, 31, 32, -1, 5, 33, -1, 6, 33, -1,
- 7, 33, -1, 3, 33, -1, 4, -1, 8, -1,
- 9, -1, 29, 33, 32, -1, 10, -1, 35, -1,
- 39, -1, 42, -1, 48, -1, 29, 37, 30, -1,
- 15, 28, -1, 38, -1, 5, 31, 37, -1, 5,
- 37, -1, 6, 31, 37, -1, 6, 37, -1, 3,
- 31, 37, -1, 3, 37, -1, 36, -1, 38, 31,
- 36, -1, 38, 31, -1, 17, 40, 18, -1, 17,
- 18, -1, 41, -1, 40, 21, 41, -1, 25, -1,
- 47, -1, 29, 43, 30, -1, 29, 46, 30, -1,
- 5, 31, 46, -1, 5, 43, -1, 6, 31, 46,
- -1, 6, 43, -1, 3, 31, 46, -1, 3, 43,
- -1, 33, 16, 28, -1, 44, -1, 22, 25, 31,
- 16, 28, -1, 45, -1, 46, 31, 36, -1, 46,
- 31, 45, -1, 46, 31, -1, 25, 16, 28, -1,
- 19, 49, 20, -1, 19, 20, -1, 50, -1, 49,
- 21, 50, -1, 25, -1, 47, -1
+ 24, 0, -1, 25, -1, 11, 27, -1, -1, 33,
+ -1, 26, -1, 34, -1, 5, 26, -1, 6, 26,
+ -1, 3, 26, -1, 29, 26, 32, -1, 25, -1,
+ 28, -1, 29, 28, 30, -1, -1, 7, 28, -1,
+ 5, 28, -1, 6, 28, -1, 3, 28, -1, 12,
+ -1, 29, 13, -1, 14, -1, 13, -1, 14, -1,
+ 31, 32, -1, 5, 33, -1, 6, 33, -1, 7,
+ 33, -1, 3, 33, -1, 4, -1, 8, -1, 9,
+ -1, 29, 33, 32, -1, 10, -1, 35, -1, 39,
+ -1, 42, -1, 49, -1, 29, 37, 30, -1, 29,
+ 38, 30, -1, 15, 27, -1, 5, 31, 38, -1,
+ 5, 37, -1, 6, 31, 38, -1, 6, 37, -1,
+ 3, 31, 38, -1, 3, 37, -1, 36, -1, 38,
+ 31, 36, -1, 38, 31, -1, 17, 40, 18, -1,
+ 17, 18, -1, 41, -1, 40, 21, 41, -1, 25,
+ -1, 48, -1, 29, 43, 30, -1, 29, 47, 30,
+ -1, 5, 31, 47, -1, 5, 43, -1, 6, 31,
+ 47, -1, 6, 43, -1, 3, 31, 47, -1, 3,
+ 43, -1, 33, -1, 22, 25, 31, -1, 27, -1,
+ 44, 16, 45, -1, 46, -1, 47, 31, 36, -1,
+ 47, 31, 46, -1, 47, 31, -1, 25, 16, 27,
+ -1, 19, 50, 20, -1, 19, 20, -1, 51, -1,
+ 50, 21, 51, -1, 25, -1, 48, -1
};
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
-static const unsigned short yyrline[] =
+static const unsigned short int yyrline[] =
{
- 0, 54, 54, 58, 62, 68, 69, 72, 73, 79,
- 80, 85, 90, 99, 105, 106, 111, 121, 122, 125,
- 128, 131, 132, 140, 145, 150, 158, 162, 170, 183,
- 184, 194, 195, 196, 197, 198, 204, 210, 216, 217,
- 222, 227, 232, 237, 241, 247, 251, 256, 265, 269,
- 275, 279, 286, 287, 293, 298, 305, 310, 315, 320,
- 325, 329, 335, 350, 351, 368, 369, 381, 389, 398,
- 406, 410, 416, 417, 426, 433
+ 0, 56, 56, 60, 65, 70, 71, 74, 75, 80,
+ 85, 94, 100, 101, 104, 109, 113, 121, 126, 131,
+ 145, 146, 149, 152, 155, 156, 164, 169, 174, 182,
+ 186, 194, 207, 208, 218, 219, 220, 221, 222, 228,
+ 232, 238, 244, 249, 254, 259, 264, 268, 274, 278,
+ 283, 292, 296, 302, 306, 313, 314, 320, 325, 332,
+ 337, 342, 347, 352, 356, 362, 363, 369, 379, 396,
+ 397, 409, 417, 426, 434, 438, 444, 445, 454, 461
};
#endif
@@ -361,24 +366,24 @@ static const unsigned short yyrline[] =
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] =
{
- "$end", "error", "$undefined", "YAML_ANCHOR", "YAML_ALIAS",
- "YAML_TRANSFER", "YAML_TAGURI", "YAML_ITRANSFER", "YAML_WORD",
- "YAML_PLAIN", "YAML_BLOCK", "YAML_DOCSEP", "YAML_IOPEN", "YAML_INDENT",
- "YAML_IEND", "'-'", "':'", "'['", "']'", "'{'", "'}'", "','", "'?'",
- "$accept", "doc", "atom", "doc_struct_rep", "ind_rep", "atom_or_empty",
- "indent_open", "indent_end", "indent_sep", "indent_flex_end",
- "word_rep", "struct_rep", "implicit_seq", "basic_seq", "top_imp_seq",
- "in_implicit_seq", "inline_seq", "in_inline_seq", "inline_seq_atom",
- "implicit_map", "top_imp_map", "basic_mapping", "complex_mapping",
- "in_implicit_map", "basic_mapping2", "inline_map", "in_inline_map",
- "inline_map_atom", 0
+ "$end", "error", "$undefined", "YAML_ANCHOR", "YAML_ALIAS",
+ "YAML_TRANSFER", "YAML_TAGURI", "YAML_ITRANSFER", "YAML_WORD",
+ "YAML_PLAIN", "YAML_BLOCK", "YAML_DOCSEP", "YAML_IOPEN", "YAML_INDENT",
+ "YAML_IEND", "'-'", "':'", "'['", "']'", "'{'", "'}'", "','", "'?'",
+ "$accept", "doc", "atom", "ind_rep", "atom_or_empty", "empty",
+ "indent_open", "indent_end", "indent_sep", "indent_flex_end", "word_rep",
+ "struct_rep", "implicit_seq", "basic_seq", "top_imp_seq",
+ "in_implicit_seq", "inline_seq", "in_inline_seq", "inline_seq_atom",
+ "implicit_map", "top_imp_map", "complex_key", "complex_value",
+ "complex_mapping", "in_implicit_map", "basic_mapping", "inline_map",
+ "in_inline_map", "inline_map_atom", 0
};
#endif
# ifdef YYPRINT
/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
token YYLEX-NUM. */
-static const unsigned short yytoknum[] =
+static const unsigned short int yytoknum[] =
{
0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
265, 266, 267, 268, 269, 45, 58, 91, 93, 123,
@@ -389,27 +394,27 @@ static const unsigned short yytoknum[] =
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const unsigned char yyr1[] =
{
- 0, 23, 24, 24, 24, 25, 25, 26, 26, 27,
- 27, 27, 27, 27, 28, 28, 28, 29, 29, 30,
- 31, 32, 32, 33, 33, 33, 33, 33, 33, 33,
- 33, 34, 34, 34, 34, 34, 35, 36, 37, 37,
- 37, 37, 37, 37, 37, 38, 38, 38, 39, 39,
- 40, 40, 41, 41, 42, 42, 43, 43, 43, 43,
- 43, 43, 44, 45, 45, 46, 46, 46, 46, 47,
- 48, 48, 49, 49, 50, 50
+ 0, 23, 24, 24, 24, 25, 25, 26, 26, 26,
+ 26, 26, 27, 27, 28, 28, 28, 28, 28, 28,
+ 29, 29, 30, 31, 32, 32, 33, 33, 33, 33,
+ 33, 33, 33, 33, 34, 34, 34, 34, 34, 35,
+ 35, 36, 37, 37, 37, 37, 37, 37, 38, 38,
+ 38, 39, 39, 40, 40, 41, 41, 42, 42, 43,
+ 43, 43, 43, 43, 43, 44, 44, 45, 46, 47,
+ 47, 47, 47, 48, 49, 49, 50, 50, 51, 51
};
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
static const unsigned char yyr2[] =
{
- 0, 2, 1, 2, 0, 1, 1, 1, 3, 1,
- 2, 2, 2, 3, 1, 2, 0, 1, 2, 1,
- 1, 1, 2, 2, 2, 2, 2, 1, 1, 1,
- 3, 1, 1, 1, 1, 1, 3, 2, 1, 3,
- 2, 3, 2, 3, 2, 1, 3, 2, 3, 2,
- 1, 3, 1, 1, 3, 3, 3, 2, 3, 2,
- 3, 2, 3, 1, 5, 1, 3, 3, 2, 3,
- 3, 2, 1, 3, 1, 1
+ 0, 2, 1, 2, 0, 1, 1, 1, 2, 2,
+ 2, 3, 1, 1, 3, 0, 2, 2, 2, 2,
+ 1, 2, 1, 1, 1, 2, 2, 2, 2, 2,
+ 1, 1, 1, 3, 1, 1, 1, 1, 1, 3,
+ 3, 2, 3, 2, 3, 2, 3, 2, 1, 3,
+ 2, 3, 2, 1, 3, 1, 1, 3, 3, 3,
+ 2, 3, 2, 3, 2, 1, 3, 1, 3, 1,
+ 3, 3, 2, 3, 3, 2, 1, 3, 1, 1
};
/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
@@ -417,173 +422,167 @@ static const unsigned char yyr2[] =
means the default is an error. */
static const unsigned char yydefact[] =
{
- 4, 31, 16, 17, 0, 0, 0, 2, 0, 7,
- 32, 33, 34, 35, 0, 27, 0, 0, 0, 28,
- 29, 14, 6, 3, 0, 5, 9, 49, 52, 0,
- 0, 50, 53, 71, 74, 75, 0, 72, 1, 0,
- 0, 0, 18, 16, 0, 0, 0, 0, 45, 0,
- 38, 0, 63, 65, 0, 12, 26, 10, 23, 11,
- 24, 0, 0, 0, 0, 25, 0, 0, 0, 19,
- 0, 15, 0, 16, 48, 0, 70, 0, 20, 0,
- 44, 61, 0, 40, 57, 0, 42, 59, 37, 0,
- 21, 0, 8, 16, 36, 47, 54, 55, 68, 0,
- 13, 30, 69, 51, 73, 0, 0, 0, 43, 60,
- 39, 56, 41, 58, 0, 22, 62, 46, 66, 67,
- 0, 0, 0, 16, 0, 0, 0, 64
+ 4, 0, 30, 0, 0, 0, 31, 32, 34, 15,
+ 20, 0, 0, 0, 2, 6, 0, 5, 7, 35,
+ 36, 37, 38, 10, 29, 8, 26, 9, 27, 0,
+ 0, 0, 0, 28, 15, 15, 15, 15, 12, 3,
+ 13, 15, 52, 55, 0, 53, 56, 75, 78, 79,
+ 0, 76, 1, 0, 0, 0, 21, 15, 0, 0,
+ 65, 48, 0, 0, 0, 0, 69, 0, 0, 19,
+ 17, 18, 15, 15, 15, 16, 15, 15, 15, 15,
+ 0, 15, 51, 0, 74, 0, 23, 0, 47, 64,
+ 0, 43, 60, 0, 45, 62, 41, 0, 24, 0,
+ 11, 33, 22, 39, 40, 50, 57, 15, 58, 72,
+ 14, 73, 54, 77, 65, 46, 63, 42, 59, 44,
+ 61, 66, 25, 49, 67, 68, 70, 71
};
/* YYDEFGOTO[NTERM-NUM]. */
static const yysigned_char yydefgoto[] =
{
- -1, 6, 21, 45, 22, 23, 64, 71, 91, 101,
- 25, 26, 10, 48, 49, 50, 11, 30, 31, 12,
- 51, 52, 53, 54, 32, 13, 36, 37
+ -1, 13, 38, 15, 39, 40, 16, 103, 99, 101,
+ 17, 18, 19, 61, 62, 63, 20, 44, 45, 21,
+ 64, 65, 125, 66, 67, 46, 22, 50, 51
};
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
-#define YYPACT_NINF -77
-static const short yypact[] =
+#define YYPACT_NINF -97
+static const short int yypact[] =
{
- 163, -77, 356, -77, 339, 304, 7, -77, 224, -77,
- -77, -77, -77, -77, 356, -77, 356, 356, 410, -77,
- -77, -77, -77, -77, 204, -77, -77, -77, -15, 244,
- 24, -77, -77, -77, -15, -77, 30, -77, -77, 373,
- 373, 373, -77, 356, 356, 41, 224, -3, -77, 18,
- 21, 18, -77, -77, 46, -77, -77, -77, -77, -77,
- -77, 410, 410, 410, 399, -77, 322, 322, 322, -77,
- 41, -77, 14, 356, -77, 356, -77, 356, -77, 264,
- -77, -77, 264, -77, -77, 264, -77, -77, -77, 21,
- -77, 41, -77, 356, -77, 33, -77, -77, 284, 41,
- -77, -77, -77, -77, -77, 386, 386, 386, -77, 21,
- -77, 21, -77, 21, 22, -77, -77, -77, -77, -77,
- 20, 20, 20, 356, 91, 91, 91, -77
+ 250, 318, -97, 318, 318, 374, -97, -97, -97, 335,
+ -97, 267, 232, 7, -97, -97, 192, -97, -97, -97,
+ -97, -97, -97, -97, -97, -97, -97, -97, -97, 374,
+ 374, 374, 352, -97, 335, 335, 335, 384, -97, -97,
+ -97, 212, -97, 10, 0, -97, -97, -97, 10, -97,
+ -4, -97, -97, 284, 284, 284, -97, 335, 318, 30,
+ 30, -97, -2, 36, -2, 16, -97, 36, 30, -97,
+ -97, -97, 384, 384, 384, -97, 363, 301, 301, 301,
+ -2, 335, -97, 318, -97, 318, -97, 158, -97, -97,
+ 158, -97, -97, 158, -97, -97, -97, 24, -97, 30,
+ -97, -97, -97, -97, -97, 26, -97, 335, -97, 158,
+ -97, -97, -97, -97, -97, 24, 24, 24, 24, 24,
+ 24, -97, -97, -97, -97, -97, -97, -97
};
/* YYPGOTO[NTERM-NUM]. */
-static const short yypgoto[] =
+static const yysigned_char yypgoto[] =
{
- -77, -77, 5, 56, 138, -40, 0, 25, 59, -34,
- 23, 12, -77, -76, 71, -77, -77, -77, -14, -77,
- 75, -77, -33, -64, 1, -77, -77, -7
+ -97, -97, 8, 81, -56, 109, 33, -53, 74, -54,
+ -1, -97, -97, -96, -31, -32, -97, -97, -44, -97,
+ 77, -97, -97, -52, 9, -6, -97, -97, -29
};
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
positive, shift that token. If negative, reduce the rule which
number is the opposite. If zero, do what YYDEFACT says.
- If YYTABLE_NINF, parse error. */
+ If YYTABLE_NINF, syntax error. */
#define YYTABLE_NINF -1
static const unsigned char yytable[] =
{
- 8, 73, 24, 88, 29, 29, 35, 38, 46, 28,
- 34, 92, 9, 93, 29, 109, 29, 29, 111, 117,
- 9, 113, 118, 124, 29, 125, 126, 78, 90, 29,
- 93, 47, 69, 102, 78, 43, 100, 56, 123, 58,
- 60, 65, 74, 24, 29, 75, 46, 72, 43, 89,
- 76, 77, 72, 116, 78, 90, 7, 115, 9, 78,
- 69, 103, 56, 58, 60, 119, 29, 29, 29, 72,
- 104, 0, 0, 24, 94, 29, 96, 29, 35, 97,
- 28, 0, 34, 127, 56, 58, 60, 99, 0, 56,
- 58, 60, 0, 24, 124, 0, 125, 126, 79, 82,
- 85, 0, 47, 0, 78, 47, 43, 0, 47, 95,
- 80, 83, 86, 98, 81, 84, 87, 0, 0, 0,
- 0, 47, 0, 24, 0, 79, 82, 85, 56, 58,
- 60, 0, 0, 0, 0, 0, 0, 80, 83, 86,
- 0, 81, 84, 87, 0, 0, 0, 0, 114, 0,
- 108, 0, 55, 110, 57, 59, 112, 0, 0, 0,
- 0, 0, 70, 0, 120, 121, 122, 70, 98, 0,
- 98, 0, 98, 1, 2, 3, 80, 83, 86, 0,
- 4, 0, 5, 120, 121, 122, 0, 0, 0, 0,
- 0, 108, 110, 112, 0, 80, 83, 86, 0, 0,
- 0, 0, 0, 0, 55, 57, 59, 66, 15, 67,
- 68, 18, 19, 20, 1, 0, 3, 42, 69, 43,
- 0, 4, 0, 5, 0, 0, 44, 39, 15, 40,
- 41, 18, 19, 20, 1, 0, 3, 42, 0, 43,
- 0, 4, 0, 5, 0, 0, 44, 66, 15, 67,
- 68, 18, 19, 20, 1, 0, 3, 42, 0, 43,
- 0, 4, 0, 5, 0, 0, 44, 105, 15, 106,
- 107, 18, 19, 20, 0, 0, 3, 0, 0, 43,
- 0, 0, 0, 0, 0, 0, 44, 61, 15, 62,
- 63, 18, 19, 20, 0, 0, 3, 0, 0, 43,
- 0, 0, 0, 0, 0, 0, 44, 14, 15, 16,
- 17, 18, 19, 20, 1, 0, 3, 0, 0, 0,
- 0, 4, 0, 5, 33, 66, 15, 67, 68, 18,
- 19, 20, 1, 0, 3, 78, 0, 43, 0, 4,
- 0, 5, 14, 15, 16, 17, 18, 19, 20, 1,
- 0, 3, 0, 0, 0, 0, 4, 27, 5, 14,
- 15, 16, 17, 18, 19, 20, 1, 0, 3, 0,
- 0, 0, 0, 4, 0, 5, 39, 15, 40, 41,
- 18, 19, 20, 0, 0, 3, 78, 0, 43, 105,
- 15, 106, 107, 18, 19, 20, 0, 0, 3, 78,
- 0, 43, 61, 15, 62, 63, 18, 19, 20, 0,
- 0, 3, 42, 61, 15, 62, 63, 18, 19, 20,
- 0, 0, 3
+ 24, 96, 26, 28, 33, 100, 49, 52, 14, 123,
+ 104, 106, 102, 126, 108, 60, 84, 85, 82, 43,
+ 48, 83, 88, 91, 94, 111, 81, 110, 24, 26,
+ 28, 68, 107, 24, 26, 28, 33, 86, 32, 112,
+ 60, 57, 41, 86, 98, 122, 88, 91, 94, 86,
+ 102, 124, 24, 26, 28, 115, 113, 127, 117, 0,
+ 0, 119, 32, 32, 32, 32, 97, 41, 41, 41,
+ 76, 24, 26, 28, 41, 68, 24, 26, 28, 49,
+ 0, 0, 23, 0, 25, 27, 114, 0, 0, 114,
+ 41, 43, 114, 48, 0, 0, 116, 59, 0, 118,
+ 0, 0, 120, 0, 0, 76, 76, 76, 114, 76,
+ 41, 41, 41, 0, 41, 23, 25, 27, 0, 0,
+ 32, 0, 59, 32, 0, 0, 32, 87, 90, 93,
+ 89, 92, 95, 0, 23, 25, 27, 105, 0, 0,
+ 41, 109, 32, 69, 70, 71, 75, 0, 0, 0,
+ 80, 87, 90, 93, 89, 92, 95, 0, 23, 25,
+ 27, 29, 2, 30, 31, 5, 6, 7, 0, 0,
+ 10, 121, 0, 57, 0, 0, 0, 0, 0, 0,
+ 58, 69, 70, 71, 0, 80, 69, 70, 71, 105,
+ 109, 105, 109, 105, 109, 53, 2, 54, 55, 5,
+ 6, 7, 8, 0, 10, 56, 0, 57, 0, 11,
+ 0, 12, 0, 0, 58, 77, 2, 78, 79, 37,
+ 6, 7, 8, 0, 10, 56, 0, 57, 0, 11,
+ 0, 12, 0, 0, 58, 1, 2, 3, 4, 5,
+ 6, 7, 8, 0, 10, 0, 0, 0, 0, 11,
+ 0, 12, 47, 1, 2, 3, 4, 5, 6, 7,
+ 8, 9, 10, 0, 0, 0, 0, 11, 0, 12,
+ 1, 2, 3, 4, 5, 6, 7, 8, 0, 10,
+ 0, 0, 0, 0, 11, 42, 12, 53, 2, 54,
+ 55, 5, 6, 7, 8, 0, 10, 86, 0, 0,
+ 0, 11, 0, 12, 77, 2, 78, 79, 37, 6,
+ 7, 8, 0, 10, 86, 0, 0, 0, 11, 0,
+ 12, 1, 2, 3, 4, 5, 6, 7, 8, 0,
+ 10, 0, 0, 0, 0, 11, 0, 12, 34, 2,
+ 35, 36, 37, 6, 7, 8, 0, 10, 0, 0,
+ 0, 0, 11, 0, 12, 29, 2, 30, 31, 5,
+ 6, 7, 0, 0, 10, 56, 72, 2, 73, 74,
+ 37, 6, 7, 0, 0, 10, 56, 29, 2, 30,
+ 31, 5, 6, 7, 0, 0, 10, 72, 2, 73,
+ 74, 37, 6, 7, 0, 0, 10
};
static const yysigned_char yycheck[] =
{
- 0, 16, 2, 43, 4, 5, 5, 0, 8, 4,
- 5, 45, 0, 16, 14, 79, 16, 17, 82, 95,
- 8, 85, 98, 3, 24, 5, 6, 13, 14, 29,
- 16, 8, 14, 73, 13, 15, 70, 14, 16, 16,
- 17, 18, 18, 43, 44, 21, 46, 24, 15, 44,
- 20, 21, 29, 93, 13, 14, 0, 91, 46, 13,
- 14, 75, 39, 40, 41, 98, 66, 67, 68, 46,
- 77, -1, -1, 73, 49, 75, 51, 77, 77, 54,
- 75, -1, 77, 123, 61, 62, 63, 64, -1, 66,
- 67, 68, -1, 93, 3, -1, 5, 6, 39, 40,
- 41, -1, 79, -1, 13, 82, 15, -1, 85, 50,
- 39, 40, 41, 54, 39, 40, 41, -1, -1, -1,
- -1, 98, -1, 123, -1, 66, 67, 68, 105, 106,
- 107, -1, -1, -1, -1, -1, -1, 66, 67, 68,
- -1, 66, 67, 68, -1, -1, -1, -1, 89, -1,
- 79, -1, 14, 82, 16, 17, 85, -1, -1, -1,
- -1, -1, 24, -1, 105, 106, 107, 29, 109, -1,
- 111, -1, 113, 10, 11, 12, 105, 106, 107, -1,
- 17, -1, 19, 124, 125, 126, -1, -1, -1, -1,
- -1, 120, 121, 122, -1, 124, 125, 126, -1, -1,
- -1, -1, -1, -1, 66, 67, 68, 3, 4, 5,
- 6, 7, 8, 9, 10, -1, 12, 13, 14, 15,
- -1, 17, -1, 19, -1, -1, 22, 3, 4, 5,
- 6, 7, 8, 9, 10, -1, 12, 13, -1, 15,
- -1, 17, -1, 19, -1, -1, 22, 3, 4, 5,
- 6, 7, 8, 9, 10, -1, 12, 13, -1, 15,
- -1, 17, -1, 19, -1, -1, 22, 3, 4, 5,
- 6, 7, 8, 9, -1, -1, 12, -1, -1, 15,
- -1, -1, -1, -1, -1, -1, 22, 3, 4, 5,
- 6, 7, 8, 9, -1, -1, 12, -1, -1, 15,
- -1, -1, -1, -1, -1, -1, 22, 3, 4, 5,
- 6, 7, 8, 9, 10, -1, 12, -1, -1, -1,
- -1, 17, -1, 19, 20, 3, 4, 5, 6, 7,
+ 1, 57, 3, 4, 5, 59, 12, 0, 0, 105,
+ 63, 64, 14, 109, 67, 16, 20, 21, 18, 11,
+ 12, 21, 53, 54, 55, 81, 16, 80, 29, 30,
+ 31, 32, 16, 34, 35, 36, 37, 13, 5, 83,
+ 41, 15, 9, 13, 14, 99, 77, 78, 79, 13,
+ 14, 107, 53, 54, 55, 87, 85, 109, 90, -1,
+ -1, 93, 29, 30, 31, 32, 58, 34, 35, 36,
+ 37, 72, 73, 74, 41, 76, 77, 78, 79, 85,
+ -1, -1, 1, -1, 3, 4, 87, -1, -1, 90,
+ 57, 83, 93, 85, -1, -1, 87, 16, -1, 90,
+ -1, -1, 93, -1, -1, 72, 73, 74, 109, 76,
+ 77, 78, 79, -1, 81, 34, 35, 36, -1, -1,
+ 87, -1, 41, 90, -1, -1, 93, 53, 54, 55,
+ 53, 54, 55, -1, 53, 54, 55, 63, -1, -1,
+ 107, 67, 109, 34, 35, 36, 37, -1, -1, -1,
+ 41, 77, 78, 79, 77, 78, 79, -1, 77, 78,
+ 79, 3, 4, 5, 6, 7, 8, 9, -1, -1,
+ 12, 97, -1, 15, -1, -1, -1, -1, -1, -1,
+ 22, 72, 73, 74, -1, 76, 77, 78, 79, 115,
+ 116, 117, 118, 119, 120, 3, 4, 5, 6, 7,
+ 8, 9, 10, -1, 12, 13, -1, 15, -1, 17,
+ -1, 19, -1, -1, 22, 3, 4, 5, 6, 7,
8, 9, 10, -1, 12, 13, -1, 15, -1, 17,
- -1, 19, 3, 4, 5, 6, 7, 8, 9, 10,
- -1, 12, -1, -1, -1, -1, 17, 18, 19, 3,
- 4, 5, 6, 7, 8, 9, 10, -1, 12, -1,
- -1, -1, -1, 17, -1, 19, 3, 4, 5, 6,
- 7, 8, 9, -1, -1, 12, 13, -1, 15, 3,
- 4, 5, 6, 7, 8, 9, -1, -1, 12, 13,
- -1, 15, 3, 4, 5, 6, 7, 8, 9, -1,
- -1, 12, 13, 3, 4, 5, 6, 7, 8, 9,
- -1, -1, 12
+ -1, 19, -1, -1, 22, 3, 4, 5, 6, 7,
+ 8, 9, 10, -1, 12, -1, -1, -1, -1, 17,
+ -1, 19, 20, 3, 4, 5, 6, 7, 8, 9,
+ 10, 11, 12, -1, -1, -1, -1, 17, -1, 19,
+ 3, 4, 5, 6, 7, 8, 9, 10, -1, 12,
+ -1, -1, -1, -1, 17, 18, 19, 3, 4, 5,
+ 6, 7, 8, 9, 10, -1, 12, 13, -1, -1,
+ -1, 17, -1, 19, 3, 4, 5, 6, 7, 8,
+ 9, 10, -1, 12, 13, -1, -1, -1, 17, -1,
+ 19, 3, 4, 5, 6, 7, 8, 9, 10, -1,
+ 12, -1, -1, -1, -1, 17, -1, 19, 3, 4,
+ 5, 6, 7, 8, 9, 10, -1, 12, -1, -1,
+ -1, -1, 17, -1, 19, 3, 4, 5, 6, 7,
+ 8, 9, -1, -1, 12, 13, 3, 4, 5, 6,
+ 7, 8, 9, -1, -1, 12, 13, 3, 4, 5,
+ 6, 7, 8, 9, -1, -1, 12, 3, 4, 5,
+ 6, 7, 8, 9, -1, -1, 12
};
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
symbol of state STATE-NUM. */
static const unsigned char yystos[] =
{
- 0, 10, 11, 12, 17, 19, 24, 26, 29, 34,
- 35, 39, 42, 48, 3, 4, 5, 6, 7, 8,
- 9, 25, 27, 28, 29, 33, 34, 18, 25, 29,
- 40, 41, 47, 20, 25, 47, 49, 50, 0, 3,
- 5, 6, 13, 15, 22, 26, 29, 33, 36, 37,
- 38, 43, 44, 45, 46, 27, 33, 27, 33, 27,
- 33, 3, 5, 6, 29, 33, 3, 5, 6, 14,
- 27, 30, 33, 16, 18, 21, 20, 21, 13, 31,
- 37, 43, 31, 37, 43, 31, 37, 43, 28, 25,
- 14, 31, 32, 16, 30, 31, 30, 30, 31, 33,
- 32, 32, 28, 41, 50, 3, 5, 6, 37, 46,
- 37, 46, 37, 46, 31, 32, 28, 36, 36, 45,
- 31, 31, 31, 16, 3, 5, 6, 28
+ 0, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 17, 19, 24, 25, 26, 29, 33, 34, 35,
+ 39, 42, 49, 26, 33, 26, 33, 26, 33, 3,
+ 5, 6, 29, 33, 3, 5, 6, 7, 25, 27,
+ 28, 29, 18, 25, 40, 41, 48, 20, 25, 48,
+ 50, 51, 0, 3, 5, 6, 13, 15, 22, 26,
+ 33, 36, 37, 38, 43, 44, 46, 47, 33, 28,
+ 28, 28, 3, 5, 6, 28, 29, 3, 5, 6,
+ 28, 16, 18, 21, 20, 21, 13, 31, 37, 43,
+ 31, 37, 43, 31, 37, 43, 27, 25, 14, 31,
+ 32, 32, 14, 30, 30, 31, 30, 16, 30, 31,
+ 30, 27, 41, 51, 33, 38, 47, 38, 47, 38,
+ 47, 31, 32, 36, 27, 45, 36, 46
};
#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
@@ -604,12 +603,13 @@ static const unsigned char yystos[] =
#define yyerrok (yyerrstatus = 0)
#define yyclearin (yychar = YYEMPTY)
-#define YYEMPTY -2
+#define YYEMPTY (-2)
#define YYEOF 0
#define YYACCEPT goto yyacceptlab
#define YYABORT goto yyabortlab
-#define YYERROR goto yyerrlab1
+#define YYERROR goto yyerrorlab
+
/* Like YYERROR except do call yyerror. This remains here temporarily
to ease the transition to the new meaning of YYERROR, for GCC.
@@ -625,13 +625,13 @@ do \
{ \
yychar = (Token); \
yylval = (Value); \
- yychar1 = YYTRANSLATE (yychar); \
+ yytoken = YYTRANSLATE (yychar); \
YYPOPSTACK; \
goto yybackup; \
} \
else \
{ \
- yyerror ("syntax error: cannot back up"); \
+ yyerror ("syntax error: cannot back up");\
YYERROR; \
} \
while (0)
@@ -643,19 +643,19 @@ while (0)
are run). */
#ifndef YYLLOC_DEFAULT
-# define YYLLOC_DEFAULT(Current, Rhs, N) \
- Current.first_line = Rhs[1].first_line; \
- Current.first_column = Rhs[1].first_column; \
- Current.last_line = Rhs[N].last_line; \
- Current.last_column = Rhs[N].last_column;
+# define YYLLOC_DEFAULT(Current, Rhs, N) \
+ ((Current).first_line = (Rhs)[1].first_line, \
+ (Current).first_column = (Rhs)[1].first_column, \
+ (Current).last_line = (Rhs)[N].last_line, \
+ (Current).last_column = (Rhs)[N].last_column)
#endif
/* YYLEX -- calling `yylex' with the right arguments. */
#ifdef YYLEX_PARAM
-# define YYLEX yylex (&yylval, YYLEX_PARAM)
+# define YYLEX yylex (&yylval, YYLEX_PARAM)
#else
-# define YYLEX yylex (&yylval)
+# define YYLEX yylex (&yylval)
#endif
/* Enable debugging if requested. */
@@ -671,19 +671,93 @@ do { \
if (yydebug) \
YYFPRINTF Args; \
} while (0)
+
# define YYDSYMPRINT(Args) \
do { \
if (yydebug) \
yysymprint Args; \
} while (0)
+
+# define YYDSYMPRINTF(Title, Token, Value, Location) \
+do { \
+ if (yydebug) \
+ { \
+ YYFPRINTF (stderr, "%s ", Title); \
+ yysymprint (stderr, \
+ Token, Value); \
+ YYFPRINTF (stderr, "\n"); \
+ } \
+} while (0)
+
+/*------------------------------------------------------------------.
+| yy_stack_print -- Print the state stack from its BOTTOM up to its |
+| TOP (included). |
+`------------------------------------------------------------------*/
+
+#if defined (__STDC__) || defined (__cplusplus)
+static void
+yy_stack_print (short int *bottom, short int *top)
+#else
+static void
+yy_stack_print (bottom, top)
+ short int *bottom;
+ short int *top;
+#endif
+{
+ YYFPRINTF (stderr, "Stack now");
+ for (/* Nothing. */; bottom <= top; ++bottom)
+ YYFPRINTF (stderr, " %d", *bottom);
+ YYFPRINTF (stderr, "\n");
+}
+
+# define YY_STACK_PRINT(Bottom, Top) \
+do { \
+ if (yydebug) \
+ yy_stack_print ((Bottom), (Top)); \
+} while (0)
+
+
+/*------------------------------------------------.
+| Report that the YYRULE is going to be reduced. |
+`------------------------------------------------*/
+
+#if defined (__STDC__) || defined (__cplusplus)
+static void
+yy_reduce_print (int yyrule)
+#else
+static void
+yy_reduce_print (yyrule)
+ int yyrule;
+#endif
+{
+ int yyi;
+ unsigned int yylno = yyrline[yyrule];
+ YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
+ yyrule - 1, yylno);
+ /* Print the symbols being reduced, and their result. */
+ for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
+ YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
+ YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
+}
+
+# define YY_REDUCE_PRINT(Rule) \
+do { \
+ if (yydebug) \
+ yy_reduce_print (Rule); \
+} while (0)
+
/* Nonzero means print parse trace. It is left uninitialized so that
multiple parsers can coexist. */
int yydebug;
#else /* !YYDEBUG */
# define YYDPRINTF(Args)
# define YYDSYMPRINT(Args)
+# define YYDSYMPRINTF(Title, Token, Value, Location)
+# define YY_STACK_PRINT(Bottom, Top)
+# define YY_REDUCE_PRINT(Rule)
#endif /* !YYDEBUG */
+
/* YYINITDEPTH -- initial size of the parser's stacks. */
#ifndef YYINITDEPTH
# define YYINITDEPTH 200
@@ -696,7 +770,7 @@ int yydebug;
SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
evaluated with infinite-precision integer arithmetic. */
-#if YYMAXDEPTH == 0
+#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0
# undef YYMAXDEPTH
#endif
@@ -762,102 +836,111 @@ yystpcpy (yydest, yysrc)
#if YYDEBUG
-/*-----------------------------.
-| Print this symbol on YYOUT. |
-`-----------------------------*/
+/*--------------------------------.
+| Print this symbol on YYOUTPUT. |
+`--------------------------------*/
-static void
#if defined (__STDC__) || defined (__cplusplus)
-yysymprint (FILE* yyout, int yytype, YYSTYPE yyvalue)
+static void
+yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
#else
-yysymprint (yyout, yytype, yyvalue)
- FILE* yyout;
+static void
+yysymprint (yyoutput, yytype, yyvaluep)
+ FILE *yyoutput;
int yytype;
- YYSTYPE yyvalue;
+ YYSTYPE *yyvaluep;
#endif
{
/* Pacify ``unused variable'' warnings. */
- (void) yyvalue;
+ (void) yyvaluep;
if (yytype < YYNTOKENS)
{
- YYFPRINTF (yyout, "token %s (", yytname[yytype]);
+ YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
# ifdef YYPRINT
- YYPRINT (yyout, yytoknum[yytype], yyvalue);
+ YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
# endif
}
else
- YYFPRINTF (yyout, "nterm %s (", yytname[yytype]);
+ YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
switch (yytype)
{
default:
break;
}
- YYFPRINTF (yyout, ")");
+ YYFPRINTF (yyoutput, ")");
}
-#endif /* YYDEBUG. */
-
+#endif /* ! YYDEBUG */
/*-----------------------------------------------.
| Release the memory associated to this symbol. |
`-----------------------------------------------*/
-static void
#if defined (__STDC__) || defined (__cplusplus)
-yydestruct (int yytype, YYSTYPE yyvalue)
+static void
+yydestruct (int yytype, YYSTYPE *yyvaluep)
#else
-yydestruct (yytype, yyvalue)
+static void
+yydestruct (yytype, yyvaluep)
int yytype;
- YYSTYPE yyvalue;
+ YYSTYPE *yyvaluep;
#endif
{
/* Pacify ``unused variable'' warnings. */
- (void) yyvalue;
+ (void) yyvaluep;
switch (yytype)
{
+
default:
break;
}
}
-
-/* The user can define YYPARSE_PARAM as the name of an argument to be passed
- into yyparse. The argument should have type void *.
- It should actually point to an object.
- Grammar actions can access the variable by casting it
- to the proper pointer type. */
+/* Prevent warnings from -Wmissing-prototypes. */
#ifdef YYPARSE_PARAM
# if defined (__STDC__) || defined (__cplusplus)
-# define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
-# define YYPARSE_PARAM_DECL
+int yyparse (void *YYPARSE_PARAM);
# else
-# define YYPARSE_PARAM_ARG YYPARSE_PARAM
-# define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
+int yyparse ();
# endif
-#else /* !YYPARSE_PARAM */
-# define YYPARSE_PARAM_ARG
-# define YYPARSE_PARAM_DECL
-#endif /* !YYPARSE_PARAM */
-
-/* Prevent warning if -Wstrict-prototypes. */
-#ifdef __GNUC__
-# ifdef YYPARSE_PARAM
-int yyparse (void *);
-# else
+#else /* ! YYPARSE_PARAM */
+#if defined (__STDC__) || defined (__cplusplus)
int yyparse (void);
-# endif
+#else
+int yyparse ();
#endif
+#endif /* ! YYPARSE_PARAM */
+
+
+/*----------.
+| yyparse. |
+`----------*/
+
+#ifdef YYPARSE_PARAM
+# if defined (__STDC__) || defined (__cplusplus)
+int yyparse (void *YYPARSE_PARAM)
+# else
+int yyparse (YYPARSE_PARAM)
+ void *YYPARSE_PARAM;
+# endif
+#else /* ! YYPARSE_PARAM */
+#if defined (__STDC__) || defined (__cplusplus)
int
-yyparse (YYPARSE_PARAM_ARG)
- YYPARSE_PARAM_DECL
+yyparse (void)
+#else
+int
+yyparse ()
+
+#endif
+#endif
{
/* The lookahead symbol. */
int yychar;
@@ -865,7 +948,7 @@ int yychar;
/* The semantic value of the lookahead symbol. */
YYSTYPE yylval;
-/* Number of parse errors so far. */
+/* Number of syntax errors so far. */
int yynerrs;
register int yystate;
@@ -874,7 +957,7 @@ int yynerrs;
/* Number of tokens to shift before error messages enabled. */
int yyerrstatus;
/* Lookahead token as an internal (translated) token number. */
- int yychar1 = 0;
+ int yytoken = 0;
/* Three stacks and their tools:
`yyss': related to states,
@@ -885,9 +968,9 @@ int yynerrs;
to reallocate them elsewhere. */
/* The state stack. */
- short yyssa[YYINITDEPTH];
- short *yyss = yyssa;
- register short *yyssp;
+ short int yyssa[YYINITDEPTH];
+ short int *yyss = yyssa;
+ register short int *yyssp;
/* The semantic value stack. */
YYSTYPE yyvsa[YYINITDEPTH];
@@ -924,6 +1007,7 @@ int yynerrs;
yyssp = yyss;
yyvsp = yyvs;
+
goto yysetstate;
/*------------------------------------------------------------.
@@ -938,7 +1022,7 @@ int yynerrs;
yysetstate:
*yyssp = yystate;
- if (yyssp >= yyss + yystacksize - 1)
+ if (yyss + yystacksize - 1 <= yyssp)
{
/* Get the current used size of the three stacks, in elements. */
YYSIZE_T yysize = yyssp - yyss + 1;
@@ -949,7 +1033,7 @@ int yynerrs;
these so that the &'s don't force the real ones into
memory. */
YYSTYPE *yyvs1 = yyvs;
- short *yyss1 = yyss;
+ short int *yyss1 = yyss;
/* Each stack pointer address is followed by the size of the
@@ -970,14 +1054,14 @@ int yynerrs;
goto yyoverflowlab;
# else
/* Extend the stack our own way. */
- if (yystacksize >= YYMAXDEPTH)
+ if (YYMAXDEPTH <= yystacksize)
goto yyoverflowlab;
yystacksize *= 2;
- if (yystacksize > YYMAXDEPTH)
+ if (YYMAXDEPTH < yystacksize)
yystacksize = YYMAXDEPTH;
{
- short *yyss1 = yyss;
+ short int *yyss1 = yyss;
union yyalloc *yyptr =
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
if (! yyptr)
@@ -999,7 +1083,7 @@ int yynerrs;
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
(unsigned long int) yystacksize));
- if (yyssp >= yyss + yystacksize - 1)
+ if (yyss + yystacksize - 1 <= yyssp)
YYABORT;
}
@@ -1024,39 +1108,28 @@ yybackup:
/* Not known => get a lookahead token if don't already have one. */
- /* yychar is either YYEMPTY or YYEOF
- or a valid token in external form. */
-
+ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
if (yychar == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token: "));
yychar = YYLEX;
}
- /* Convert token to internal form (in yychar1) for indexing tables with. */
-
- if (yychar <= 0) /* This means end of input. */
+ if (yychar <= YYEOF)
{
- yychar1 = 0;
- yychar = YYEOF; /* Don't call YYLEX any more. */
-
+ yychar = yytoken = YYEOF;
YYDPRINTF ((stderr, "Now at end of input.\n"));
}
else
{
- yychar1 = YYTRANSLATE (yychar);
-
- /* We have to keep this `#if YYDEBUG', since we use variables
- which are defined only if `YYDEBUG' is set. */
- YYDPRINTF ((stderr, "Next token is "));
- YYDSYMPRINT ((stderr, yychar1, yylval));
- YYDPRINTF ((stderr, "\n"));
+ yytoken = YYTRANSLATE (yychar);
+ YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
}
- /* If the proper action on seeing token YYCHAR1 is to reduce or to
+ /* If the proper action on seeing token YYTOKEN is to reduce or to
detect an error, take that action. */
- yyn += yychar1;
- if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yychar1)
+ yyn += yytoken;
+ if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
goto yydefault;
yyn = yytable[yyn];
if (yyn <= 0)
@@ -1071,8 +1144,7 @@ yybackup:
YYACCEPT;
/* Shift the lookahead token. */
- YYDPRINTF ((stderr, "Shifting token %d (%s), ",
- yychar, yytname[yychar1]));
+ YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
/* Discard the token being shifted unless it is eof. */
if (yychar != YYEOF)
@@ -1118,71 +1190,48 @@ yyreduce:
yyval = yyvsp[1-yylen];
-
-#if YYDEBUG
- /* We have to keep this `#if YYDEBUG', since we use variables which
- are defined only if `YYDEBUG' is set. */
- if (yydebug)
- {
- int yyi;
-
- YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
- yyn - 1, yyrline[yyn]);
-
- /* Print the symbols being reduced, and their result. */
- for (yyi = yyprhs[yyn]; yyrhs[yyi] >= 0; yyi++)
- YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
- YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]);
- }
-#endif
+ YY_REDUCE_PRINT (yyn);
switch (yyn)
{
case 2:
-#line 55 "gram.y"
+#line 57 "gram.y"
{
((SyckParser *)parser)->root = syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData );
}
break;
case 3:
-#line 59 "gram.y"
+#line 61 "gram.y"
{
((SyckParser *)parser)->root = syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData );
}
break;
case 4:
-#line 63 "gram.y"
+#line 65 "gram.y"
{
((SyckParser *)parser)->eof = 1;
}
break;
case 8:
-#line 74 "gram.y"
- {
- yyval.nodeData = yyvsp[-1].nodeData;
- }
- break;
-
- case 10:
-#line 81 "gram.y"
+#line 76 "gram.y"
{
syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion );
yyval.nodeData = yyvsp[0].nodeData;
}
break;
- case 11:
-#line 86 "gram.y"
+ case 9:
+#line 81 "gram.y"
{
syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, 0 );
yyval.nodeData = yyvsp[0].nodeData;
}
break;
- case 12:
-#line 91 "gram.y"
+ case 10:
+#line 86 "gram.y"
{
/*
* _Anchors_: The language binding must keep a separate symbol table
@@ -1193,15 +1242,22 @@ yyreduce:
}
break;
- case 13:
-#line 100 "gram.y"
+ case 11:
+#line 95 "gram.y"
{
yyval.nodeData = yyvsp[-1].nodeData;
}
break;
+ case 14:
+#line 105 "gram.y"
+ {
+ yyval.nodeData = yyvsp[-1].nodeData;
+ }
+ break;
+
case 15:
-#line 107 "gram.y"
+#line 109 "gram.y"
{
NULL_NODE( parser, n );
yyval.nodeData = n;
@@ -1209,31 +1265,62 @@ yyreduce:
break;
case 16:
-#line 112 "gram.y"
+#line 114 "gram.y"
+ {
+ if ( ((SyckParser *)parser)->implicit_typing == 1 )
+ {
+ try_tag_implicit( yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion );
+ }
+ yyval.nodeData = yyvsp[0].nodeData;
+ }
+ break;
+
+ case 17:
+#line 122 "gram.y"
+ {
+ syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion );
+ yyval.nodeData = yyvsp[0].nodeData;
+ }
+ break;
+
+ case 18:
+#line 127 "gram.y"
{
- NULL_NODE( parser, n );
- yyval.nodeData = n;
+ syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, 0 );
+ yyval.nodeData = yyvsp[0].nodeData;
+ }
+ break;
+
+ case 19:
+#line 132 "gram.y"
+ {
+ /*
+ * _Anchors_: The language binding must keep a separate symbol table
+ * for anchors. The actual ID in the symbol table is returned to the
+ * higher nodes, though.
+ */
+ yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-1].name, yyvsp[0].nodeData );
}
break;
- case 23:
-#line 141 "gram.y"
+ case 26:
+#line 165 "gram.y"
{
syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion );
yyval.nodeData = yyvsp[0].nodeData;
}
break;
- case 24:
-#line 146 "gram.y"
+ case 27:
+#line 170 "gram.y"
{
syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, 0 );
yyval.nodeData = yyvsp[0].nodeData;
}
break;
- case 25:
-#line 151 "gram.y"
+ case 28:
+#line 175 "gram.y"
{
if ( ((SyckParser *)parser)->implicit_typing == 1 )
{
@@ -1243,15 +1330,15 @@ yyreduce:
}
break;
- case 26:
-#line 159 "gram.y"
+ case 29:
+#line 183 "gram.y"
{
yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-1].name, yyvsp[0].nodeData );
}
break;
- case 27:
-#line 163 "gram.y"
+ case 30:
+#line 187 "gram.y"
{
/*
* _Aliases_: The anchor symbol table is scanned for the anchor name.
@@ -1261,8 +1348,8 @@ yyreduce:
}
break;
- case 28:
-#line 171 "gram.y"
+ case 31:
+#line 195 "gram.y"
{
SyckNode *n = yyvsp[0].nodeData;
if ( ((SyckParser *)parser)->taguri_expansion == 1 )
@@ -1277,207 +1364,212 @@ yyreduce:
}
break;
- case 30:
-#line 185 "gram.y"
+ case 33:
+#line 209 "gram.y"
{
yyval.nodeData = yyvsp[-1].nodeData;
}
break;
- case 36:
-#line 205 "gram.y"
+ case 39:
+#line 229 "gram.y"
{
yyval.nodeData = yyvsp[-1].nodeData;
}
break;
- case 37:
-#line 211 "gram.y"
+ case 40:
+#line 233 "gram.y"
+ {
+ yyval.nodeData = yyvsp[-1].nodeData;
+ }
+ break;
+
+ case 41:
+#line 239 "gram.y"
{
yyval.nodeId = syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData );
}
break;
- case 39:
-#line 218 "gram.y"
+ case 42:
+#line 245 "gram.y"
{
syck_add_transfer( yyvsp[-2].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion );
yyval.nodeData = yyvsp[0].nodeData;
}
break;
- case 40:
-#line 223 "gram.y"
+ case 43:
+#line 250 "gram.y"
{
syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion );
yyval.nodeData = yyvsp[0].nodeData;
}
break;
- case 41:
-#line 228 "gram.y"
+ case 44:
+#line 255 "gram.y"
{
syck_add_transfer( yyvsp[-2].name, yyvsp[0].nodeData, 0 );
yyval.nodeData = yyvsp[0].nodeData;
}
break;
- case 42:
-#line 233 "gram.y"
+ case 45:
+#line 260 "gram.y"
{
syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, 0 );
yyval.nodeData = yyvsp[0].nodeData;
}
break;
- case 43:
-#line 238 "gram.y"
+ case 46:
+#line 265 "gram.y"
{
yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-2].name, yyvsp[0].nodeData );
}
break;
- case 44:
-#line 242 "gram.y"
+ case 47:
+#line 269 "gram.y"
{
yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-1].name, yyvsp[0].nodeData );
}
break;
- case 45:
-#line 248 "gram.y"
+ case 48:
+#line 275 "gram.y"
{
yyval.nodeData = syck_new_seq( yyvsp[0].nodeId );
}
break;
- case 46:
-#line 252 "gram.y"
+ case 49:
+#line 279 "gram.y"
{
syck_seq_add( yyvsp[-2].nodeData, yyvsp[0].nodeId );
yyval.nodeData = yyvsp[-2].nodeData;
}
break;
- case 47:
-#line 257 "gram.y"
+ case 50:
+#line 284 "gram.y"
{
yyval.nodeData = yyvsp[-1].nodeData;
}
break;
- case 48:
-#line 266 "gram.y"
+ case 51:
+#line 293 "gram.y"
{
yyval.nodeData = yyvsp[-1].nodeData;
}
break;
- case 49:
-#line 270 "gram.y"
+ case 52:
+#line 297 "gram.y"
{
yyval.nodeData = syck_alloc_seq();
}
break;
- case 50:
-#line 276 "gram.y"
+ case 53:
+#line 303 "gram.y"
{
yyval.nodeData = syck_new_seq( syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ) );
}
break;
- case 51:
-#line 280 "gram.y"
+ case 54:
+#line 307 "gram.y"
{
syck_seq_add( yyvsp[-2].nodeData, syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ) );
yyval.nodeData = yyvsp[-2].nodeData;
}
break;
- case 54:
-#line 294 "gram.y"
+ case 57:
+#line 321 "gram.y"
{
apply_seq_in_map( (SyckParser *)parser, yyvsp[-1].nodeData );
yyval.nodeData = yyvsp[-1].nodeData;
}
break;
- case 55:
-#line 299 "gram.y"
+ case 58:
+#line 326 "gram.y"
{
apply_seq_in_map( (SyckParser *)parser, yyvsp[-1].nodeData );
yyval.nodeData = yyvsp[-1].nodeData;
}
break;
- case 56:
-#line 306 "gram.y"
+ case 59:
+#line 333 "gram.y"
{
syck_add_transfer( yyvsp[-2].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion );
yyval.nodeData = yyvsp[0].nodeData;
}
break;
- case 57:
-#line 311 "gram.y"
+ case 60:
+#line 338 "gram.y"
{
syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion );
yyval.nodeData = yyvsp[0].nodeData;
}
break;
- case 58:
-#line 316 "gram.y"
+ case 61:
+#line 343 "gram.y"
{
syck_add_transfer( yyvsp[-2].name, yyvsp[0].nodeData, 0 );
yyval.nodeData = yyvsp[0].nodeData;
}
break;
- case 59:
-#line 321 "gram.y"
+ case 62:
+#line 348 "gram.y"
{
syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, 0 );
yyval.nodeData = yyvsp[0].nodeData;
}
break;
- case 60:
-#line 326 "gram.y"
+ case 63:
+#line 353 "gram.y"
{
yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-2].name, yyvsp[0].nodeData );
}
break;
- case 61:
-#line 330 "gram.y"
+ case 64:
+#line 357 "gram.y"
{
yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-1].name, yyvsp[0].nodeData );
}
break;
- case 62:
-#line 336 "gram.y"
+ case 66:
+#line 364 "gram.y"
{
- yyval.nodeData = syck_new_map(
- syck_hdlr_add_node( (SyckParser *)parser, yyvsp[-2].nodeData ),
- syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ) );
+ yyval.nodeData = yyvsp[-1].nodeData;
}
break;
- case 64:
-#line 352 "gram.y"
+ case 68:
+#line 380 "gram.y"
{
yyval.nodeData = syck_new_map(
- syck_hdlr_add_node( (SyckParser *)parser, yyvsp[-3].nodeData ),
+ syck_hdlr_add_node( (SyckParser *)parser, yyvsp[-2].nodeData ),
syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ) );
}
break;
- case 66:
-#line 370 "gram.y"
- {
+ case 70:
+#line 398 "gram.y"
+ {
if ( yyvsp[-2].nodeData->shortcut == NULL )
{
yyvsp[-2].nodeData->shortcut = syck_new_seq( yyvsp[0].nodeId );
@@ -1490,9 +1582,9 @@ yyreduce:
}
break;
- case 67:
-#line 382 "gram.y"
- {
+ case 71:
+#line 410 "gram.y"
+ {
apply_seq_in_map( (SyckParser *)parser, yyvsp[-2].nodeData );
syck_map_update( yyvsp[-2].nodeData, yyvsp[0].nodeData );
syck_free_node( yyvsp[0].nodeData );
@@ -1501,15 +1593,15 @@ yyreduce:
}
break;
- case 68:
-#line 390 "gram.y"
- {
+ case 72:
+#line 418 "gram.y"
+ {
yyval.nodeData = yyvsp[-1].nodeData;
}
break;
- case 69:
-#line 399 "gram.y"
+ case 73:
+#line 427 "gram.y"
{
yyval.nodeData = syck_new_map(
syck_hdlr_add_node( (SyckParser *)parser, yyvsp[-2].nodeData ),
@@ -1517,22 +1609,22 @@ yyreduce:
}
break;
- case 70:
-#line 407 "gram.y"
+ case 74:
+#line 435 "gram.y"
{
yyval.nodeData = yyvsp[-1].nodeData;
}
break;
- case 71:
-#line 411 "gram.y"
+ case 75:
+#line 439 "gram.y"
{
yyval.nodeData = syck_alloc_map();
}
break;
- case 73:
-#line 418 "gram.y"
+ case 77:
+#line 446 "gram.y"
{
syck_map_update( yyvsp[-2].nodeData, yyvsp[0].nodeData );
syck_free_node( yyvsp[0].nodeData );
@@ -1541,8 +1633,8 @@ yyreduce:
}
break;
- case 74:
-#line 427 "gram.y"
+ case 78:
+#line 455 "gram.y"
{
NULL_NODE( parser, n );
yyval.nodeData = syck_new_map(
@@ -1554,23 +1646,14 @@ yyreduce:
}
-/* Line 1016 of /usr/local/share/bison/yacc.c. */
-#line 1559 "y.tab.c"
+/* Line 1010 of yacc.c. */
+#line 1651 "gram.c"
yyvsp -= yylen;
yyssp -= yylen;
-#if YYDEBUG
- if (yydebug)
- {
- short *yyssp1 = yyss - 1;
- YYFPRINTF (stderr, "state stack now");
- while (yyssp1 != yyssp)
- YYFPRINTF (stderr, " %d", *++yyssp1);
- YYFPRINTF (stderr, "\n");
- }
-#endif
+ YY_STACK_PRINT (yyss, yyssp);
*++yyvsp = yyval;
@@ -1605,88 +1688,118 @@ yyerrlab:
{
YYSIZE_T yysize = 0;
int yytype = YYTRANSLATE (yychar);
+ const char* yyprefix;
char *yymsg;
- int yyx, yycount;
+ int yyx;
- yycount = 0;
/* Start YYX at -YYN if negative to avoid negative indexes in
YYCHECK. */
- for (yyx = yyn < 0 ? -yyn : 0;
- yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
+ int yyxbegin = yyn < 0 ? -yyn : 0;
+
+ /* Stay within bounds of both yycheck and yytname. */
+ int yychecklim = YYLAST - yyn;
+ int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
+ int yycount = 0;
+
+ yyprefix = ", expecting ";
+ for (yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
- yysize += yystrlen (yytname[yyx]) + 15, yycount++;
- yysize += yystrlen ("parse error, unexpected ") + 1;
- yysize += yystrlen (yytname[yytype]);
+ {
+ yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]);
+ yycount += 1;
+ if (yycount == 5)
+ {
+ yysize = 0;
+ break;
+ }
+ }
+ yysize += (sizeof ("syntax error, unexpected ")
+ + yystrlen (yytname[yytype]));
yymsg = (char *) YYSTACK_ALLOC (yysize);
if (yymsg != 0)
{
- char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
+ char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
yyp = yystpcpy (yyp, yytname[yytype]);
if (yycount < 5)
{
- yycount = 0;
- for (yyx = yyn < 0 ? -yyn : 0;
- yyx < (int) (sizeof (yytname) / sizeof (char *));
- yyx++)
+ yyprefix = ", expecting ";
+ for (yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
{
- const char *yyq = ! yycount ? ", expecting " : " or ";
- yyp = yystpcpy (yyp, yyq);
+ yyp = yystpcpy (yyp, yyprefix);
yyp = yystpcpy (yyp, yytname[yyx]);
- yycount++;
+ yyprefix = " or ";
}
}
yyerror (yymsg);
YYSTACK_FREE (yymsg);
}
else
- yyerror ("parse error; also virtual memory exhausted");
+ yyerror ("syntax error; also virtual memory exhausted");
}
else
#endif /* YYERROR_VERBOSE */
- yyerror ("parse error");
+ yyerror ("syntax error");
}
- goto yyerrlab1;
-/*----------------------------------------------------.
-| yyerrlab1 -- error raised explicitly by an action. |
-`----------------------------------------------------*/
-yyerrlab1:
+
if (yyerrstatus == 3)
{
/* If just tried and failed to reuse lookahead token after an
error, discard it. */
- /* Return failure if at end of input. */
- if (yychar == YYEOF)
+ if (yychar <= YYEOF)
{
- /* Pop the error token. */
- YYPOPSTACK;
- /* Pop the rest of the stack. */
- while (yyssp > yyss)
- {
- YYDPRINTF ((stderr, "Error: popping "));
- YYDSYMPRINT ((stderr,
- yystos[*yyssp],
- *yyvsp));
- YYDPRINTF ((stderr, "\n"));
- yydestruct (yystos[*yyssp], *yyvsp);
- YYPOPSTACK;
- }
- YYABORT;
+ /* If at end of input, pop the error token,
+ then the rest of the stack, then return failure. */
+ if (yychar == YYEOF)
+ for (;;)
+ {
+ YYPOPSTACK;
+ if (yyssp == yyss)
+ YYABORT;
+ YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
+ yydestruct (yystos[*yyssp], yyvsp);
+ }
}
+ else
+ {
+ YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
+ yydestruct (yytoken, &yylval);
+ yychar = YYEMPTY;
- YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
- yychar, yytname[yychar1]));
- yydestruct (yychar1, yylval);
- yychar = YYEMPTY;
+ }
}
/* Else will try to reuse lookahead token after shifting the error
token. */
+ goto yyerrlab1;
+
+
+/*---------------------------------------------------.
+| yyerrorlab -- error raised explicitly by YYERROR. |
+`---------------------------------------------------*/
+yyerrorlab:
+
+#ifdef __GNUC__
+ /* Pacify GCC when the user code never invokes YYERROR and the label
+ yyerrorlab therefore never appears in user code. */
+ if (0)
+ goto yyerrorlab;
+#endif
+
+ yyvsp -= yylen;
+ yyssp -= yylen;
+ yystate = *yyssp;
+ goto yyerrlab1;
+
+/*-------------------------------------------------------------.
+| yyerrlab1 -- common code for both syntax error and YYERROR. |
+`-------------------------------------------------------------*/
+yyerrlab1:
yyerrstatus = 3; /* Each real token shifted decrements this. */
for (;;)
@@ -1707,26 +1820,11 @@ yyerrlab1:
if (yyssp == yyss)
YYABORT;
- YYDPRINTF ((stderr, "Error: popping "));
- YYDSYMPRINT ((stderr,
- yystos[*yyssp], *yyvsp));
- YYDPRINTF ((stderr, "\n"));
-
- yydestruct (yystos[yystate], *yyvsp);
- yyvsp--;
- yystate = *--yyssp;
-
-
-#if YYDEBUG
- if (yydebug)
- {
- short *yyssp1 = yyss - 1;
- YYFPRINTF (stderr, "Error: state stack now");
- while (yyssp1 != yyssp)
- YYFPRINTF (stderr, " %d", *++yyssp1);
- YYFPRINTF (stderr, "\n");
- }
-#endif
+ YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
+ yydestruct (yystos[yystate], yyvsp);
+ YYPOPSTACK;
+ yystate = *yyssp;
+ YY_STACK_PRINT (yyss, yyssp);
}
if (yyn == YYFINAL)
@@ -1774,7 +1872,7 @@ yyreturn:
}
-#line 436 "gram.y"
+#line 464 "gram.y"
void
diff --git a/ext/syck/gram.h b/ext/syck/gram.h
index 4c0e199..547149a 100644
--- a/ext/syck/gram.h
+++ b/ext/syck/gram.h
@@ -1,7 +1,7 @@
-/* A Bison parser, made from gram.y, by GNU bison 1.75. */
+/* A Bison parser, made by GNU Bison 1.875d. */
/* Skeleton parser for Yacc-like parsing with Bison,
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -23,9 +23,6 @@
This special exception was added by the Free Software Foundation
in version 1.24 of Bison. */
-#ifndef BISON_Y_TAB_H
-# define BISON_Y_TAB_H
-
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
@@ -62,20 +59,21 @@
-#ifndef YYSTYPE
-#line 33 "gram.y"
-typedef union {
+#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
+#line 35 "gram.y"
+typedef union YYSTYPE {
SYMID nodeId;
SyckNode *nodeData;
char *name;
-} yystype;
-/* Line 1281 of /usr/local/share/bison/yacc.c. */
-#line 74 "y.tab.h"
-# define YYSTYPE yystype
+} YYSTYPE;
+/* Line 1285 of yacc.c. */
+#line 71 "gram.h"
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+# define YYSTYPE_IS_TRIVIAL 1
#endif
-#endif /* not BISON_Y_TAB_H */
diff --git a/ext/syck/handler.c b/ext/syck/handler.c
index 563feb1..d070efa 100644
--- a/ext/syck/handler.c
+++ b/ext/syck/handler.c
@@ -31,6 +31,9 @@ syck_hdlr_add_node( SyckParser *p, SyckNode *n )
SyckNode *
syck_hdlr_add_anchor( SyckParser *p, char *a, SyckNode *n )
{
+ char *atmp = NULL;
+ SyckNode *ntmp = NULL;
+
n->anchor = a;
if ( p->bad_anchors != NULL )
{
@@ -48,6 +51,13 @@ syck_hdlr_add_anchor( SyckParser *p, char *a, SyckNode *n )
{
p->anchors = st_init_strtable();
}
+ if ( st_lookup( p->anchors, (st_data_t)a, (st_data_t *)&ntmp ) )
+ {
+ if ( ntmp != (void *)1 )
+ {
+ syck_free_node( ntmp );
+ }
+ }
st_insert( p->anchors, (st_data_t)a, (st_data_t)n );
return n;
}
@@ -55,10 +65,19 @@ syck_hdlr_add_anchor( SyckParser *p, char *a, SyckNode *n )
void
syck_hdlr_remove_anchor( SyckParser *p, char *a )
{
+ char *atmp = a;
+ SyckNode *ntmp;
if ( p->anchors == NULL )
{
p->anchors = st_init_strtable();
}
+ if ( st_delete( p->anchors, (st_data_t *)&atmp, (st_data_t *)&ntmp ) )
+ {
+ if ( ntmp != (void *)1 )
+ {
+ syck_free_node( ntmp );
+ }
+ }
st_insert( p->anchors, (st_data_t)a, (st_data_t)1 );
}
diff --git a/ext/syck/implicit.c b/ext/syck/implicit.c
index 66f0520..cce7a9f 100644
--- a/ext/syck/implicit.c
+++ b/ext/syck/implicit.c
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.9.3 on Fri Aug 13 11:47:51 2004 */
+/* Generated by re2c 0.9.3 on Wed Mar 30 08:27:25 2005 */
#line 1 "implicit.re"
/*
* implicit.re
@@ -36,6 +36,7 @@ try_tag_implicit( SyckNode *n, int taguri )
tid = "map";
break;
}
+ if ( n->type_id != NULL ) S_FREE( n->type_id );
if ( taguri == 1 )
{
n->type_id = syck_taguri( YAML_DOMAIN, tid, strlen( tid ) );
@@ -94,7 +95,7 @@ yy2: ++YYCURSOR;
if((yych = *YYCURSOR) <= '\000') goto yy6;
goto yy3;
yy3:
-#line 122 "implicit.re"
+#line 123 "implicit.re"
{ return "str"; }
#line 51 "<stdout>"
yy4: yyaccept = 0;
@@ -115,7 +116,7 @@ yy5: yyaccept = 0;
yy6: ++YYCURSOR;
goto yy7;
yy7:
-#line 84 "implicit.re"
+#line 85 "implicit.re"
{ return "null"; }
#line 72 "<stdout>"
yy8: yyaccept = 0;
@@ -273,13 +274,13 @@ yy25: YYCURSOR = YYMARKER;
yy26: ++YYCURSOR;
goto yy27;
yy27:
-#line 120 "implicit.re"
+#line 121 "implicit.re"
{ return "merge"; }
#line 230 "<stdout>"
yy28: ++YYCURSOR;
goto yy29;
yy29:
-#line 118 "implicit.re"
+#line 119 "implicit.re"
{ return "default"; }
#line 236 "<stdout>"
yy30: yych = *++YYCURSOR;
@@ -320,7 +321,7 @@ yy36: yych = *++YYCURSOR;
yy37: ++YYCURSOR;
goto yy38;
yy38:
-#line 104 "implicit.re"
+#line 105 "implicit.re"
{ return "float#inf"; }
#line 277 "<stdout>"
yy39: yych = *++YYCURSOR;
@@ -344,7 +345,7 @@ yy42: yych = *++YYCURSOR;
yy43: ++YYCURSOR;
goto yy44;
yy44:
-#line 108 "implicit.re"
+#line 109 "implicit.re"
{ return "float#nan"; }
#line 301 "<stdout>"
yy45: yych = *++YYCURSOR;
@@ -426,7 +427,7 @@ yy51: switch(yych){
yy52: ++YYCURSOR;
goto yy53;
yy53:
-#line 96 "implicit.re"
+#line 97 "implicit.re"
{ return "int"; }
#line 386 "<stdout>"
yy54: ++YYCURSOR;
@@ -450,7 +451,7 @@ yy55: switch(yych){
yy56: ++YYCURSOR;
goto yy57;
yy57:
-#line 98 "implicit.re"
+#line 99 "implicit.re"
{ return "float#fix"; }
#line 411 "<stdout>"
yy58: ++YYCURSOR;
@@ -500,7 +501,7 @@ yy63: switch(yych){
yy64: ++YYCURSOR;
goto yy65;
yy65:
-#line 100 "implicit.re"
+#line 101 "implicit.re"
{ return "float#exp"; }
#line 463 "<stdout>"
yy66: ++YYCURSOR;
@@ -552,13 +553,13 @@ yy69: switch(yych){
yy70: ++YYCURSOR;
goto yy71;
yy71:
-#line 94 "implicit.re"
+#line 95 "implicit.re"
{ return "int#base60"; }
#line 518 "<stdout>"
yy72: ++YYCURSOR;
goto yy73;
yy73:
-#line 102 "implicit.re"
+#line 103 "implicit.re"
{ return "float#base60"; }
#line 524 "<stdout>"
yy74: yych = *++YYCURSOR;
@@ -661,7 +662,7 @@ yy81: yych = *++YYCURSOR;
yy82: ++YYCURSOR;
goto yy83;
yy83:
-#line 110 "implicit.re"
+#line 111 "implicit.re"
{ return "timestamp#ymd"; }
#line 627 "<stdout>"
yy84: yych = *++YYCURSOR;
@@ -878,7 +879,7 @@ yy104: yych = *++YYCURSOR;
yy105: ++YYCURSOR;
goto yy106;
yy106:
-#line 114 "implicit.re"
+#line 115 "implicit.re"
{ return "timestamp#spaced"; }
#line 847 "<stdout>"
yy107: yych = *++YYCURSOR;
@@ -1063,7 +1064,7 @@ yy122: yych = *++YYCURSOR;
yy123: ++YYCURSOR;
goto yy124;
yy124:
-#line 112 "implicit.re"
+#line 113 "implicit.re"
{ return "timestamp#iso8601"; }
#line 1033 "<stdout>"
yy125: yych = *++YYCURSOR;
@@ -1301,13 +1302,13 @@ yy146: switch(yych){
yy147: ++YYCURSOR;
goto yy148;
yy148:
-#line 90 "implicit.re"
+#line 91 "implicit.re"
{ return "int#hex"; }
#line 1275 "<stdout>"
yy149: ++YYCURSOR;
goto yy150;
yy150:
-#line 92 "implicit.re"
+#line 93 "implicit.re"
{ return "int#oct"; }
#line 1281 "<stdout>"
yy151: ++YYCURSOR;
@@ -1406,7 +1407,7 @@ yy163: yych = *++YYCURSOR;
yy164: ++YYCURSOR;
goto yy165;
yy165:
-#line 106 "implicit.re"
+#line 107 "implicit.re"
{ return "float#neginf"; }
#line 1381 "<stdout>"
yy166: yych = *++YYCURSOR;
@@ -1446,7 +1447,7 @@ yy172: yych = *++YYCURSOR;
yy173: ++YYCURSOR;
goto yy174;
yy174:
-#line 88 "implicit.re"
+#line 89 "implicit.re"
{ return "bool#no"; }
#line 1421 "<stdout>"
yy175: yych = *++YYCURSOR;
@@ -1490,7 +1491,7 @@ yy182: yych = *++YYCURSOR;
yy183: ++YYCURSOR;
goto yy184;
yy184:
-#line 86 "implicit.re"
+#line 87 "implicit.re"
{ return "bool#yes"; }
#line 1465 "<stdout>"
yy185: yych = *++YYCURSOR;
@@ -1577,11 +1578,36 @@ yy201: ++YYCURSOR;
default: goto yy25;
}
}
-#line 124 "implicit.re"
+#line 125 "implicit.re"
}
+/* Remove ending fragment and compare types */
+int
+syck_tagcmp( char *tag1, char *tag2 )
+{
+ if ( tag1 == tag2 ) return 1;
+ if ( tag1 == NULL || tag2 == NULL ) return 0;
+ else {
+ int i;
+ char *othorpe;
+ char *tmp1 = syck_strndup( tag1, strlen( tag1 ) );
+ char *tmp2 = syck_strndup( tag2, strlen( tag2 ) );
+ othorpe = strstr( tmp1, "#" );
+ if ( othorpe != NULL ) {
+ othorpe[0] = '\0';
+ }
+ othorpe = strstr( tmp2, "#" );
+ if ( othorpe != NULL ) {
+ othorpe[0] = '\0';
+ }
+ i = strcmp( tmp1, tmp2 );
+ S_FREE( tmp1 ); S_FREE( tmp2 );
+ return i;
+ }
+}
+
char *
syck_type_id_to_uri( char *type_id )
{
@@ -1737,7 +1763,7 @@ yy205: yyaccept = 0;
default: goto yy206;
}
yy206:
-#line 176 "implicit.re"
+#line 202 "implicit.re"
{ return syck_taguri( YAML_DOMAIN, type_id, strlen( type_id ) ); }
#line 1700 "<stdout>"
yy207: yyaccept = 0;
@@ -1811,7 +1837,7 @@ yy207: yyaccept = 0;
yy208: ++YYCURSOR;
goto yy209;
yy209:
-#line 150 "implicit.re"
+#line 176 "implicit.re"
{ return syck_xprivate( type_id + 1, strlen( type_id ) - 1 ); }
#line 1774 "<stdout>"
yy210: yyaccept = 0;
@@ -2107,7 +2133,7 @@ yy217: ++YYCURSOR;
yy218: ++YYCURSOR;
goto yy219;
yy219:
-#line 152 "implicit.re"
+#line 178 "implicit.re"
{ char *domain = S_ALLOC_N( char, ( YYCURSOR - type_id ) + 15 );
char *uri;
@@ -2325,7 +2351,7 @@ yy228: yych = *++YYCURSOR;
yy229: ++YYCURSOR;
goto yy230;
yy230:
-#line 165 "implicit.re"
+#line 191 "implicit.re"
{ char *domain = S_ALLOC_N( char, YYCURSOR - type_id );
char *uri;
@@ -2454,7 +2480,7 @@ yy243: yych = *++YYCURSOR;
yy244: ++YYCURSOR;
goto yy245;
yy245:
-#line 148 "implicit.re"
+#line 174 "implicit.re"
{ return type_id; }
#line 2422 "<stdout>"
yy246: yych = *++YYCURSOR;
@@ -2901,7 +2927,7 @@ yy263: yych = *++YYCURSOR;
yy264: ++YYCURSOR;
goto yy265;
yy265:
-#line 146 "implicit.re"
+#line 172 "implicit.re"
{ return type_id; }
#line 2874 "<stdout>"
yy266: yych = *++YYCURSOR;
@@ -2958,8 +2984,7 @@ yy270: ++YYCURSOR;
default: goto yy204;
}
}
-#line 178 "implicit.re"
+#line 204 "implicit.re"
}
-
diff --git a/ext/syck/node.c b/ext/syck/node.c
index 500ede2..72db016 100644
--- a/ext/syck/node.c
+++ b/ext/syck/node.c
@@ -33,9 +33,15 @@ syck_free_node( SyckNode *n )
{
syck_free_members( n );
if ( n->type_id != NULL )
+ {
S_FREE( n->type_id );
+ n->type_id = NULL;
+ }
if ( n->anchor != NULL )
+ {
S_FREE( n->anchor );
+ n->anchor = NULL;
+ }
S_FREE( n );
}
@@ -46,6 +52,7 @@ syck_alloc_map()
struct SyckMap *m;
m = S_ALLOC( struct SyckMap );
+ m->style = map_none;
m->idx = 0;
m->capa = ALLOC_CT;
m->keys = S_ALLOC_N( SYMID, m->capa );
@@ -64,6 +71,7 @@ syck_alloc_seq()
struct SyckSeq *s;
s = S_ALLOC( struct SyckSeq );
+ s->style = seq_none;
s->idx = 0;
s->capa = ALLOC_CT;
s->items = S_ALLOC_N( SYMID, s->capa );
@@ -113,6 +121,28 @@ syck_new_str2( char *str, long len, enum scalar_style style )
}
void
+syck_replace_str( SyckNode *n, char *str, enum scalar_style style )
+{
+ return syck_replace_str2( n, str, strlen( str ), style );
+}
+
+void
+syck_replace_str2( SyckNode *n, char *str, long len, enum scalar_style style )
+{
+ if ( n->data.str != NULL )
+ {
+ S_FREE( n->data.str->ptr );
+ n->data.str->ptr = NULL;
+ n->data.str->len = 0;
+ }
+ 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';
+}
+
+void
syck_str_blow_away_commas( SyckNode *n )
{
char *go, *end;
@@ -149,6 +179,22 @@ syck_new_map( SYMID key, SYMID value )
}
void
+syck_map_empty( SyckNode *n )
+{
+ struct SyckMap *m;
+ ASSERT( n != NULL );
+ ASSERT( n->data.list != NULL );
+
+ S_FREE( n->data.pairs->keys );
+ S_FREE( n->data.pairs->values );
+ m = n->data.pairs;
+ m->idx = 0;
+ m->capa = ALLOC_CT;
+ m->keys = S_ALLOC_N( SYMID, m->capa );
+ m->values = S_ALLOC_N( SYMID, m->capa );
+}
+
+void
syck_map_add( SyckNode *map, SYMID key, SYMID value )
{
struct SyckMap *m;
@@ -258,6 +304,20 @@ syck_new_seq( SYMID value )
}
void
+syck_seq_empty( SyckNode *n )
+{
+ struct SyckSeq *s;
+ ASSERT( n != NULL );
+ ASSERT( n->data.list != NULL );
+
+ S_FREE( n->data.list->items );
+ s = n->data.list;
+ s->idx = 0;
+ s->capa = ALLOC_CT;
+ s->items = S_ALLOC_N( SYMID, s->capa );
+}
+
+void
syck_seq_add( SyckNode *arr, SYMID value )
{
struct SyckSeq *s;
@@ -285,6 +345,17 @@ syck_seq_count( SyckNode *seq )
return seq->data.list->idx;
}
+void
+syck_seq_assign( SyckNode *seq, long idx, SYMID id )
+{
+ struct SyckSeq *s;
+
+ ASSERT( map != NULL );
+ s = seq->data.list;
+ ASSERT( m != NULL );
+ s->items[idx] = id;
+}
+
SYMID
syck_seq_read( SyckNode *seq, long idx )
{
diff --git a/ext/syck/rubyext.c b/ext/syck/rubyext.c
index a84bb43..27e7ada 100644
--- a/ext/syck/rubyext.c
+++ b/ext/syck/rubyext.c
@@ -5,7 +5,7 @@
* $Author$
* $Date$
*
- * Copyright (C) 2003 why the lucky stiff
+ * Copyright (C) 2003-2005 why the lucky stiff
*/
#include "ruby.h"
@@ -16,23 +16,23 @@
typedef struct RVALUE {
union {
#if 0
- struct {
- unsigned long flags; /* always 0 for freed obj */
- struct RVALUE *next;
- } free;
+ 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 RArray array;
- /*struct RRegexp regexp;*/
- struct RHash hash;
- /*struct RData data;*/
- struct RStruct rstruct;
- /*struct RBignum bignum;*/
- /*struct RFile file;*/
+ struct RBasic basic;
+ struct RObject object;
+ struct RClass klass;
+ /*struct RFloat flonum;*/
+ /*struct RString string;*/
+ struct RArray array;
+ /*struct RRegexp regexp;*/
+ struct RHash hash;
+ /*struct RData data;*/
+ struct RStruct rstruct;
+ /*struct RBignum bignum;*/
+ /*struct RFile file;*/
} as;
} RVALUE;
@@ -46,15 +46,23 @@ typedef struct {
#define RUBY_DOMAIN "ruby.yaml.org,2002"
+#ifndef StringValue
+#define StringValue(v) (v)
+#endif
+#ifndef rb_attr_get
+#define rb_attr_get(o, i) rb_ivar_get(o, i)
+#endif
+
/*
* symbols and constants
*/
-static ID s_new, s_utc, s_at, s_to_f, s_to_i, s_read, s_binmode, s_call, s_cmp, s_transfer, s_update, s_dup, s_match, s_keys, s_unpack, s_tr_bang, s_anchors, s_default_set;
-static ID s_anchors, s_domain, s_families, s_kind, s_name, s_options, s_private_types, s_type_id, s_value;
+static ID s_new, s_utc, s_at, s_to_f, s_to_i, s_read, s_binmode, s_call, s_cmp, s_transfer, s_update, s_dup, s_haskey, s_match, s_keys, s_unpack, s_tr_bang, s_default_set, s_tag_read_class, s_tag_subclasses, s_resolver, s_push, s_emitter, s_level, s_detect_implicit, s_node_import, s_out, s_input, s_intern, s_transform, s_yaml_new, s_yaml_initialize, s_node_export, s_to_yaml, s_write, s_set_resolver;
+static ID s_tags, s_domain, s_kind, s_name, s_options, s_type_id, s_type_id_set, s_style, s_style_set, s_value, s_value_set;
static VALUE sym_model, sym_generic, sym_input, sym_bytecode;
static VALUE sym_scalar, sym_seq, sym_map;
-VALUE cDate, cParser, cLoader, cNode, cPrivateType, cDomainType, cBadAlias, cDefaultKey, cMergeKey, cEmitter;
-VALUE oDefaultLoader;
+static VALUE sym_1quote, sym_2quote, sym_fold, sym_literal, sym_plain, sym_inline;
+static VALUE cDate, cNode, cMap, cSeq, cScalar, cOut, cParser, cResolver, cPrivateType, cDomainType, cYObject, cBadAlias, cDefaultKey, cMergeKey, cEmitter;
+static VALUE oDefaultResolver, oGenericResolver;
/*
* my private collection of numerical oddities.
@@ -69,19 +77,26 @@ static VALUE syck_node_transform( VALUE );
/*
* handler prototypes
*/
-SYMID rb_syck_parse_handler _((SyckParser *, SyckNode *));
SYMID rb_syck_load_handler _((SyckParser *, SyckNode *));
void rb_syck_err_handler _((SyckParser *, char *));
SyckNode * rb_syck_bad_anchor_handler _((SyckParser *, char *));
void rb_syck_output_handler _((SyckEmitter *, char *, long));
+void rb_syck_emitter_handler _((SyckEmitter *, st_data_t));
int syck_parser_assign_io _((SyckParser *, VALUE));
struct parser_xtra {
VALUE data; /* Borrowed this idea from marshal.c to fix [ruby-core:8067] problem */
VALUE proc;
+ VALUE resolver;
int taint;
};
+struct emitter_xtra {
+ VALUE oid;
+ VALUE data;
+ VALUE port;
+};
+
/*
* Convert YAML to bytecode
*/
@@ -93,7 +108,7 @@ rb_syck_compile(self, port)
int taint;
char *ret;
VALUE bc;
- bytestring_t *sav;
+ bytestring_t *sav;
SyckParser *parser = syck_new_parser();
taint = syck_parser_assign_io(parser, port);
@@ -159,7 +174,6 @@ syck_parser_assign_io(parser, port)
{
int taint = Qtrue;
VALUE tmp;
-
if (!NIL_P(tmp = rb_check_string_type(port))) {
taint = OBJ_TAINTED(port); /* original taintedness */
port = tmp;
@@ -185,7 +199,7 @@ syck_get_hash_aref(hsh, key)
VALUE hsh, key;
{
VALUE val = rb_hash_aref( hsh, key );
- if ( NIL_P( val ) )
+ if ( NIL_P( val ) )
{
val = rb_hash_new();
rb_hash_aset(hsh, key, val);
@@ -197,52 +211,70 @@ syck_get_hash_aref(hsh, key)
* creating timestamps
*/
SYMID
-rb_syck_mktime(str)
+rb_syck_mktime(str, len)
char *str;
+ long len;
{
VALUE time;
char *ptr = str;
- VALUE year, mon, day, hour, min, sec;
+ VALUE year = INT2FIX(0);
+ VALUE mon = INT2FIX(0);
+ VALUE day = INT2FIX(0);
+ VALUE hour = INT2FIX(0);
+ VALUE min = INT2FIX(0);
+ VALUE sec = INT2FIX(0);
long usec;
/* Year*/
- ptr[4] = '\0';
- year = INT2FIX(strtol(ptr, NULL, 10));
+ if ( ptr[0] != '\0' && len > 0 ) {
+ year = INT2FIX(strtol(ptr, NULL, 10));
+ }
/* Month*/
ptr += 4;
- while ( !ISDIGIT( *ptr ) ) ptr++;
- mon = INT2FIX(strtol(ptr, NULL, 10));
+ if ( ptr[0] != '\0' && len > ptr - str ) {
+ while ( !ISDIGIT( *ptr ) ) ptr++;
+ mon = INT2FIX(strtol(ptr, NULL, 10));
+ }
/* Day*/
ptr += 2;
- while ( !ISDIGIT( *ptr ) ) ptr++;
- day = INT2FIX(strtol(ptr, NULL, 10));
+ if ( ptr[0] != '\0' && len > ptr - str ) {
+ while ( !ISDIGIT( *ptr ) ) ptr++;
+ day = INT2FIX(strtol(ptr, NULL, 10));
+ }
/* Hour*/
ptr += 2;
- while ( !ISDIGIT( *ptr ) ) ptr++;
- hour = INT2FIX(strtol(ptr, NULL, 10));
+ if ( ptr[0] != '\0' && len > ptr - str ) {
+ while ( !ISDIGIT( *ptr ) ) ptr++;
+ hour = INT2FIX(strtol(ptr, NULL, 10));
+ }
/* Minute */
ptr += 2;
- while ( !ISDIGIT( *ptr ) ) ptr++;
- min = INT2FIX(strtol(ptr, NULL, 10));
+ if ( ptr[0] != '\0' && len > ptr - str ) {
+ while ( !ISDIGIT( *ptr ) ) ptr++;
+ min = INT2FIX(strtol(ptr, NULL, 10));
+ }
/* Second */
ptr += 2;
- while ( !ISDIGIT( *ptr ) ) ptr++;
- sec = INT2FIX(strtol(ptr, NULL, 10));
+ if ( ptr[0] != '\0' && len > ptr - str ) {
+ while ( !ISDIGIT( *ptr ) ) ptr++;
+ sec = INT2FIX(strtol(ptr, NULL, 10));
+ }
/* Millisecond */
ptr += 2;
- if ( *ptr == '.' )
+ if ( len > ptr - str && *ptr == '.' )
{
char *padded = syck_strndup( "000000", 6 );
char *end = ptr + 1;
while ( isdigit( *end ) ) end++;
MEMCPY(padded, ptr + 1, char, end - (ptr + 1));
usec = strtol(padded, NULL, 10);
+ S_FREE(padded);
}
else
{
@@ -250,8 +282,8 @@ rb_syck_mktime(str)
}
/* Time Zone*/
- while ( *ptr != 'Z' && *ptr != '+' && *ptr != '-' && *ptr != '\0' ) ptr++;
- if ( *ptr == '-' || *ptr == '+' )
+ while ( len > ptr - str && *ptr != 'Z' && *ptr != '+' && *ptr != '-' && *ptr != '\0' ) ptr++;
+ if ( len > ptr - str && ( *ptr == '-' || *ptr == '+' ) )
{
time_t tz_offset = strtol(ptr, NULL, 10) * 3600;
time_t tmp;
@@ -279,71 +311,10 @@ rb_syck_mktime(str)
{
/* Make UTC time*/
return rb_funcall(rb_cTime, s_utc, 7, year, mon, day, hour, min, sec, LONG2NUM(usec));
-
}
}
/*
- * {generic mode} node handler
- * - Loads data into Node classes
- */
-SYMID
-rb_syck_parse_handler(p, n)
- SyckParser *p;
- SyckNode *n;
-{
- VALUE t, obj, v = Qnil;
- int i;
- struct parser_xtra *bonus;
-
- obj = rb_obj_alloc(cNode);
- if ( n->type_id != NULL )
- {
- t = rb_str_new2(n->type_id);
- rb_ivar_set(obj, s_type_id, t);
- }
-
- switch (n->kind)
- {
- case syck_str_kind:
- rb_ivar_set(obj, s_kind, sym_scalar);
- v = rb_str_new( n->data.str->ptr, n->data.str->len );
- break;
-
- case syck_seq_kind:
- rb_ivar_set(obj, s_kind, sym_seq);
- v = rb_ary_new2( n->data.list->idx );
- for ( i = 0; i < n->data.list->idx; i++ )
- {
- rb_ary_store( v, i, syck_seq_read( n, i ) );
- }
- break;
-
- case syck_map_kind:
- rb_ivar_set(obj, s_kind, sym_map);
- v = rb_hash_new();
- for ( i = 0; i < n->data.pairs->idx; i++ )
- {
- VALUE key = syck_node_transform( syck_map_read( n, map_key, i ) );
- VALUE val = rb_ary_new();
- rb_ary_push(val, syck_map_read( n, map_key, i ));
- rb_ary_push(val, syck_map_read( n, map_value, i ));
-
- rb_hash_aset( v, key, val );
- }
- break;
- }
-
- bonus = (struct parser_xtra *)p->bonus;
- if ( bonus->taint) OBJ_TAINT( obj );
- 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);
- return obj;
-}
-
-/*
* handles merging of an array of hashes
* (see http://www.yaml.org/type/merge/)
*/
@@ -351,62 +322,16 @@ VALUE
syck_merge_i( entry, hsh )
VALUE entry, hsh;
{
- if ( rb_obj_is_kind_of( entry, rb_cHash ) )
+ VALUE tmp;
+ if ( !NIL_P(tmp = rb_check_convert_type(entry, T_HASH, "Hash", "to_hash")) )
{
+ entry = tmp;
rb_funcall( hsh, s_update, 1, entry );
}
return Qnil;
}
/*
- * build a syck node from a Ruby VALUE
- */
-SyckNode *
-rb_new_syck_node( obj, type_id )
- VALUE obj, type_id;
-{
- long i = 0;
- SyckNode *n = NULL;
- VALUE tmp;
-
- if (!NIL_P(tmp = rb_check_string_type(obj)))
- {
- obj = tmp;
- n = syck_alloc_str();
- n->data.str->ptr = RSTRING(obj)->ptr;
- n->data.str->len = RSTRING(obj)->len;
- }
- else if (!NIL_P(tmp = rb_check_array_type(obj)))
- {
- obj = tmp;
- n = syck_alloc_seq();
- for ( i = 0; i < RARRAY(obj)->len; i++ )
- {
- syck_seq_add(n, rb_ary_entry(obj, i));
- }
- }
- else if (!NIL_P(tmp = rb_check_convert_type(obj, T_HASH, "Hash", "to_hash")))
- {
- VALUE keys;
- n = syck_alloc_map();
- keys = rb_funcall( obj, s_keys, 0 );
- for ( i = 0; i < RARRAY(keys)->len; i++ )
- {
- VALUE key = rb_ary_entry(keys, i);
- syck_map_add(n, key, rb_hash_aref(obj, key));
- }
- }
-
- if (n != NULL && !NIL_P(tmp = rb_check_string_type(type_id)))
- {
- type_id = tmp;
- n->type_id = syck_strndup( RSTRING(type_id)->ptr, RSTRING(type_id)->len );
- }
-
- return n;
-}
-
-/*
* default handler for ruby.yaml.org types
*/
int
@@ -419,6 +344,11 @@ yaml_org_handler( n, ref )
long i = 0;
VALUE obj = Qnil;
+ if ( type_id != NULL && strncmp( type_id, "tag:yaml.org,2002:", 18 ) == 0 )
+ {
+ type_id += 18;
+ }
+
switch (n->kind)
{
case syck_str_kind:
@@ -473,7 +403,7 @@ yaml_org_handler( n, ref )
{
colon--;
}
- if ( *colon == ':' ) *colon = '\0';
+ if ( colon >= ptr && *colon == ':' ) *colon = '\0';
bnum = strtol( colon + 1, NULL, 10 );
total += bnum * sixty;
@@ -503,7 +433,7 @@ yaml_org_handler( n, ref )
{
colon--;
}
- if ( *colon == ':' ) *colon = '\0';
+ if ( colon >= ptr && *colon == ':' ) *colon = '\0';
bnum = strtod( colon + 1, NULL );
total += bnum * sixty;
@@ -533,11 +463,11 @@ yaml_org_handler( n, ref )
}
else if ( strcmp( type_id, "timestamp#iso8601" ) == 0 )
{
- obj = rb_syck_mktime( n->data.str->ptr );
+ obj = rb_syck_mktime( n->data.str->ptr, n->data.str->len );
}
else if ( strcmp( type_id, "timestamp#spaced" ) == 0 )
{
- obj = rb_syck_mktime( n->data.str->ptr );
+ obj = rb_syck_mktime( n->data.str->ptr, n->data.str->len );
}
else if ( strcmp( type_id, "timestamp#ymd" ) == 0 )
{
@@ -570,7 +500,7 @@ yaml_org_handler( n, ref )
}
else if ( strncmp( type_id, "timestamp", 9 ) == 0 )
{
- obj = rb_syck_mktime( n->data.str->ptr );
+ obj = rb_syck_mktime( n->data.str->ptr, n->data.str->len );
}
else if ( strncmp( type_id, "merge", 5 ) == 0 )
{
@@ -581,11 +511,11 @@ yaml_org_handler( n, ref )
obj = rb_funcall( cDefaultKey, s_new, 0 );
}
else if ( n->data.str->style == scalar_plain &&
- n->data.str->len > 1 &&
+ n->data.str->len > 1 &&
strncmp( n->data.str->ptr, ":", 1 ) == 0 )
{
- obj = rb_funcall( oDefaultLoader, s_transfer, 2,
- rb_str_new2( "ruby/sym" ),
+ obj = rb_funcall( oDefaultResolver, s_transfer, 2,
+ rb_str_new2( "tag:ruby.yaml.org,2002:sym" ),
rb_str_new( n->data.str->ptr + 1, n->data.str->len - 1 ) );
}
else if ( strcmp( type_id, "str" ) == 0 )
@@ -628,22 +558,24 @@ yaml_org_handler( n, ref )
*/
if ( rb_obj_is_kind_of( k, cMergeKey ) )
{
- if ( rb_obj_is_kind_of( v, rb_cHash ) )
+ VALUE tmp;
+ if ( !NIL_P(tmp = rb_check_convert_type(v, T_HASH, "Hash", "to_hash")) )
{
- VALUE dup = rb_funcall( v, s_dup, 0 );
+ VALUE dup = rb_funcall( tmp, s_dup, 0 );
rb_funcall( dup, s_update, 1, obj );
obj = dup;
skip_aset = 1;
}
- else if ( rb_obj_is_kind_of( v, rb_cArray ) )
+ else if ( !NIL_P(tmp = rb_check_array_type(v)) )
{
- VALUE end = rb_ary_pop( v );
- if ( rb_obj_is_kind_of( end, rb_cHash ) )
+ VALUE end = rb_ary_pop( tmp );
+ VALUE tmph = rb_check_convert_type(end, T_HASH, "Hash", "to_hash");
+ if ( !NIL_P(tmph) )
{
- VALUE dup = rb_funcall( end, s_dup, 0 );
- v = rb_ary_reverse( v );
- rb_ary_push( v, obj );
- rb_iterate( rb_each, v, syck_merge_i, dup );
+ VALUE dup = rb_funcall( tmph, s_dup, 0 );
+ tmp = rb_ary_reverse( tmp );
+ rb_ary_push( tmp, obj );
+ rb_iterate( rb_each, tmp, syck_merge_i, dup );
obj = dup;
skip_aset = 1;
}
@@ -677,16 +609,17 @@ rb_syck_load_handler(p, n)
SyckNode *n;
{
VALUE obj = Qnil;
- struct parser_xtra *bonus;
+ struct parser_xtra *bonus = (struct parser_xtra *)p->bonus;
+ VALUE resolver = bonus->resolver;
+ if ( NIL_P( resolver ) )
+ {
+ resolver = oDefaultResolver;
+ }
/*
- * Attempt common transfers
+ * Create node,
*/
- int transferred = yaml_org_handler(n, &obj);
- if ( transferred == 0 && n->type_id != NULL )
- {
- obj = rb_funcall( oDefaultLoader, s_transfer, 2, rb_str_new2( n->type_id ), obj );
- }
+ obj = rb_funcall( resolver, s_node_import, 1, Data_Wrap_Struct( cNode, NULL, NULL, n ) );
/*
* ID already set, let's alter the symbol table to accept the new object
@@ -698,7 +631,6 @@ rb_syck_load_handler(p, n)
obj = n->id;
}
- bonus = (struct parser_xtra *)p->bonus;
if ( bonus->taint) OBJ_TAINT( obj );
if ( bonus->proc != 0 ) rb_funcall(bonus->proc, s_call, 1, obj);
@@ -721,10 +653,10 @@ rb_syck_err_handler(p, msg)
endl[0] = '\0';
rb_raise(rb_eArgError, "%s on line %d, col %d: `%s'",
- msg,
- p->linect,
- p->cursor - p->lineptr,
- p->lineptr);
+ msg,
+ p->linect,
+ p->cursor - p->lineptr,
+ p->lineptr);
}
/*
@@ -745,26 +677,32 @@ rb_syck_bad_anchor_handler(p, a)
* data loaded based on the model requested.
*/
void
-syck_set_model( parser, input, model )
- SyckParser *parser;
- VALUE input, model;
+syck_set_model( p, input, model )
+ VALUE p, input, model;
{
+ SyckParser *parser;
+ Data_Get_Struct(p, SyckParser, parser);
+ syck_parser_handler( parser, rb_syck_load_handler );
+ /* WARN: gonna be obsoleted soon!! */
if ( model == sym_generic )
{
- syck_parser_handler( parser, rb_syck_parse_handler );
- syck_parser_implicit_typing( parser, 1 );
- syck_parser_taguri_expansion( parser, 1 );
+ rb_funcall( p, s_set_resolver, 1, oGenericResolver );
}
- else
+ syck_parser_implicit_typing( parser, 1 );
+ syck_parser_taguri_expansion( parser, 1 );
+
+ if ( NIL_P( input ) )
{
- syck_parser_handler( parser, rb_syck_load_handler );
- syck_parser_implicit_typing( parser, 1 );
- syck_parser_taguri_expansion( parser, 0 );
+ input = rb_ivar_get( p, s_input );
}
if ( input == sym_bytecode )
{
syck_parser_set_input_type( parser, syck_bytecode_utf8 );
}
+ else
+ {
+ syck_parser_set_input_type( parser, syck_yaml_utf8 );
+ }
syck_parser_error_handler( parser, rb_syck_err_handler );
syck_parser_bad_anchor_handler( parser, rb_syck_bad_anchor_handler );
}
@@ -776,29 +714,49 @@ static void
syck_mark_parser(parser)
SyckParser *parser;
{
+ struct parser_xtra *bonus;
rb_gc_mark(parser->root);
rb_gc_mark(parser->root_on_error);
+ if ( parser->bonus != NULL )
+ {
+ bonus = (struct parser_xtra *)parser->bonus;
+ rb_gc_mark( bonus->data );
+ rb_gc_mark( bonus->proc );
+ }
}
/*
- * YAML::Syck::Parser.new
+ * Free the parser and any bonus attachment.
+ */
+void
+rb_syck_free_parser(p)
+ SyckParser *p;
+{
+ struct parser_xtra *bonus = (struct parser_xtra *)p->bonus;
+ if ( bonus != NULL ) S_FREE( bonus );
+ syck_free_parser(p);
+}
+
+/*
+ * YAML::Syck::Parser.allocate
*/
VALUE syck_parser_s_alloc _((VALUE));
-VALUE
+VALUE
syck_parser_s_alloc(class)
VALUE class;
{
VALUE pobj;
SyckParser *parser = syck_new_parser();
- pobj = Data_Wrap_Struct( class, syck_mark_parser, syck_free_parser, parser );
+ pobj = Data_Wrap_Struct( class, syck_mark_parser, rb_syck_free_parser, parser );
+
syck_parser_set_root_on_error( parser, Qnil );
return pobj;
}
/*
- * YAML::Syck::Parser.initialize( options )
+ * YAML::Syck::Parser.initialize( resolver, options )
*/
static VALUE
syck_parser_initialize(argc, argv, self)
@@ -807,12 +765,12 @@ syck_parser_initialize(argc, argv, self)
VALUE self;
{
VALUE options;
-
if (rb_scan_args(argc, argv, "01", &options) == 0)
{
options = rb_hash_new();
}
- else {
+ else
+ {
Check_Type(options, T_HASH);
}
rb_ivar_set(self, s_options, options);
@@ -830,7 +788,6 @@ syck_parser_bufsize_set( self, size )
if ( rb_respond_to( size, s_to_i ) ) {
int n = NUM2INT(rb_funcall(size, s_to_i, 0));
-
Data_Get_Struct(self, SyckParser, parser);
parser->bufsize = n;
}
@@ -861,22 +818,23 @@ syck_parser_load(argc, argv, self)
{
VALUE port, proc, model, input;
SyckParser *parser;
- struct parser_xtra bonus;
- volatile VALUE hash; /* protect from GC */
+ struct parser_xtra *bonus = S_ALLOC_N( struct parser_xtra, 1 );
+ volatile VALUE hash; /* protect from GC */
rb_scan_args(argc, argv, "11", &port, &proc);
input = rb_hash_aref( rb_attr_get( self, s_options ), sym_input );
model = rb_hash_aref( rb_attr_get( self, s_options ), sym_model );
Data_Get_Struct(self, SyckParser, parser);
- syck_set_model( parser, input, model );
+ syck_set_model( self, input, model );
- bonus.taint = syck_parser_assign_io(parser, port);
- bonus.data = hash = rb_hash_new();
- if ( NIL_P( proc ) ) bonus.proc = 0;
- else bonus.proc = proc;
-
- parser->bonus = (void *)&bonus;
+ bonus->taint = syck_parser_assign_io(parser, port);
+ bonus->data = hash = rb_hash_new();
+ bonus->resolver = rb_attr_get( self, s_resolver );
+ if ( NIL_P( proc ) ) bonus->proc = 0;
+ else bonus->proc = proc;
+
+ parser->bonus = (void *)bonus;
return syck_parse( parser );
}
@@ -892,7 +850,7 @@ syck_parser_load_documents(argc, argv, self)
{
VALUE port, proc, v, input, model;
SyckParser *parser;
- struct parser_xtra bonus;
+ struct parser_xtra *bonus = S_ALLOC_N( struct parser_xtra, 1 );
volatile VALUE hash;
rb_scan_args(argc, argv, "1&", &port, &proc);
@@ -900,15 +858,17 @@ syck_parser_load_documents(argc, argv, self)
input = rb_hash_aref( rb_attr_get( self, s_options ), sym_input );
model = rb_hash_aref( rb_attr_get( self, s_options ), sym_model );
Data_Get_Struct(self, SyckParser, parser);
- syck_set_model( parser, input, model );
+ syck_set_model( self, input, model );
+
+ bonus->taint = syck_parser_assign_io(parser, port);
+ bonus->resolver = rb_attr_get( self, s_resolver );
+ bonus->proc = 0;
+ parser->bonus = (void *)bonus;
- 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;
+ bonus->data = hash = rb_hash_new();
/* Parse a document */
v = syck_parse( parser );
@@ -925,118 +885,335 @@ syck_parser_load_documents(argc, argv, self)
}
/*
- * YAML::Syck::Loader.initialize
+ * YAML::Syck::Parser#set_resolver
+ */
+VALUE
+syck_parser_set_resolver( self, resolver )
+ VALUE self, resolver;
+{
+ rb_ivar_set( self, s_resolver, resolver );
+ return self;
+}
+
+/*
+ * YAML::Syck::Resolver.initialize
*/
static VALUE
-syck_loader_initialize( self )
+syck_resolver_initialize( self )
VALUE self;
{
- VALUE families;
-
- families = rb_hash_new();
- rb_ivar_set(self, s_families, families);
- rb_ivar_set(self, s_private_types, rb_hash_new());
- rb_ivar_set(self, s_anchors, rb_hash_new());
-
- rb_hash_aset(families, rb_str_new2( YAML_DOMAIN ), rb_hash_new());
- rb_hash_aset(families, rb_str_new2( RUBY_DOMAIN ), rb_hash_new());
-
+ VALUE tags = rb_hash_new();
+ rb_ivar_set(self, s_tags, rb_hash_new());
return self;
}
/*
- * Add type family, used by add_*_type methods.
+ * YAML::Syck::Resolver#add_type
*/
VALUE
-syck_loader_add_type_family( self, domain, type_re, proc )
- VALUE self, domain, type_re, proc;
+syck_resolver_add_type( self, taguri, cls )
+ VALUE self, taguri, cls;
{
- VALUE families, domain_types;
-
- families = rb_attr_get(self, s_families);
- domain_types = syck_get_hash_aref(families, domain);
- rb_hash_aset( domain_types, type_re, proc );
+ VALUE tags = rb_attr_get(self, s_tags);
+ rb_hash_aset( tags, taguri, cls );
return Qnil;
}
/*
- * YAML::Syck::Loader.add_domain_type
+ * YAML::Syck::Resolver#use_types_at
*/
VALUE
-syck_loader_add_domain_type( argc, argv, self )
- int argc;
- VALUE *argv;
- VALUE self;
+syck_resolver_use_types_at( self, hsh )
+ VALUE self, hsh;
{
- VALUE domain, type_re, proc;
-
- rb_scan_args(argc, argv, "2&", &domain, &type_re, &proc);
- syck_loader_add_type_family( self, domain, type_re, proc );
+ rb_ivar_set( self, s_tags, hsh );
return Qnil;
}
+/*
+ * YAML::Syck::Resolver#detect_implicit
+ */
+VALUE
+syck_resolver_detect_implicit( self, val )
+ VALUE self, val;
+{
+ char *type_id;
+ return rb_str_new2( "" );
+}
/*
- * YAML::Syck::Loader.add_builtin_type
+ * YAML::Syck::Resolver#node_import
*/
VALUE
-syck_loader_add_builtin_type( argc, argv, self )
- int argc;
- VALUE *argv;
- VALUE self;
+syck_resolver_node_import( self, node )
+ VALUE self, node;
{
- VALUE type_re, proc;
+ SyckNode *n;
+ VALUE obj;
+ int i = 0;
+ Data_Get_Struct(node, SyckNode, n);
+
+ switch (n->kind)
+ {
+ case syck_str_kind:
+ obj = rb_str_new( n->data.str->ptr, n->data.str->len );
+ break;
+
+ case syck_seq_kind:
+ obj = rb_ary_new2( n->data.list->idx );
+ for ( i = 0; i < n->data.list->idx; i++ )
+ {
+ rb_ary_store( obj, i, syck_seq_read( n, i ) );
+ }
+ break;
+
+ case syck_map_kind:
+ obj = rb_hash_new();
+ for ( i = 0; i < n->data.pairs->idx; i++ )
+ {
+ VALUE k = syck_map_read( n, map_key, i );
+ VALUE v = syck_map_read( n, map_value, i );
+ int skip_aset = 0;
+
+ /*
+ * Handle merge keys
+ */
+ if ( rb_obj_is_kind_of( k, cMergeKey ) )
+ {
+ if ( rb_obj_is_kind_of( v, rb_cHash ) )
+ {
+ VALUE dup = rb_funcall( v, s_dup, 0 );
+ rb_funcall( dup, s_update, 1, obj );
+ obj = dup;
+ skip_aset = 1;
+ }
+ else if ( rb_obj_is_kind_of( v, rb_cArray ) )
+ {
+ VALUE end = rb_ary_pop( v );
+ if ( rb_obj_is_kind_of( end, rb_cHash ) )
+ {
+ VALUE dup = rb_funcall( end, s_dup, 0 );
+ v = rb_ary_reverse( v );
+ rb_ary_push( v, obj );
+ rb_iterate( rb_each, v, syck_merge_i, dup );
+ obj = dup;
+ skip_aset = 1;
+ }
+ }
+ }
+ else if ( rb_obj_is_kind_of( k, cDefaultKey ) )
+ {
+ rb_funcall( obj, s_default_set, 1, v );
+ skip_aset = 1;
+ }
+
+ if ( ! skip_aset )
+ {
+ rb_hash_aset( obj, k, v );
+ }
+ }
+ break;
+ }
- rb_scan_args(argc, argv, "1&", &type_re, &proc);
- syck_loader_add_type_family( self, rb_str_new2( YAML_DOMAIN ), type_re, proc );
+ if ( n->type_id != NULL )
+ {
+ obj = rb_funcall( self, s_transfer, 2, rb_str_new2( n->type_id ), obj );
+ }
+ return obj;
+}
+
+/*
+ * Set instance variables
+ */
+VALUE
+syck_set_ivars( vars, obj )
+ VALUE vars, obj;
+{
+ VALUE ivname = rb_ary_entry( vars, 0 );
+ char *ivn;
+ StringValue( ivname );
+ ivn = S_ALLOC_N( char, RSTRING(ivname)->len + 2 );
+ ivn[0] = '@';
+ ivn[1] = '\0';
+ strncat( ivn, RSTRING(ivname)->ptr, RSTRING(ivname)->len );
+ rb_iv_set( obj, ivn, rb_ary_entry( vars, 1 ) );
+ S_FREE( ivn );
return Qnil;
}
/*
- * YAML::Syck::Loader.add_ruby_type
+ * YAML::Syck::Resolver#const_find
*/
VALUE
-syck_loader_add_ruby_type( argc, argv, self )
- int argc;
- VALUE *argv;
- VALUE self;
+syck_const_find( const_name )
+ VALUE const_name;
{
- VALUE type_re, proc;
+ VALUE tclass = rb_cObject;
+ VALUE tparts = rb_str_split( const_name, "::" );
+ int i = 0;
+ for ( i = 0; i < RARRAY(tparts)->len; i++ ) {
+ VALUE tpart = rb_to_id( rb_ary_entry( tparts, i ) );
+ if ( !rb_const_defined( tclass, tpart ) ) return Qnil;
+ tclass = rb_const_get( tclass, tpart );
+ }
+ return tclass;
+}
- rb_scan_args(argc, argv, "1&", &type_re, &proc);
- syck_loader_add_type_family( self, rb_str_new2( RUBY_DOMAIN ), type_re, proc );
- return Qnil;
+/*
+ * YAML::Syck::Resolver#transfer
+ */
+VALUE
+syck_resolver_transfer( self, type, val )
+ VALUE self, type, val;
+{
+ if (NIL_P(type) || RSTRING(StringValue(type))->len == 0)
+ {
+ type = rb_funcall( self, s_detect_implicit, 1, val );
+ }
+
+ if ( ! (NIL_P(type) || RSTRING(StringValue(type))->len == 0) )
+ {
+ VALUE str_xprivate = rb_str_new2( "x-private" );
+ VALUE colon = rb_str_new2( ":" );
+ VALUE tags = rb_attr_get(self, s_tags);
+ VALUE target_class = rb_hash_aref( tags, type );
+ VALUE subclass = target_class;
+ VALUE obj = Qnil;
+
+ /*
+ * Should no tag match exactly, check for subclass format
+ */
+ if ( NIL_P( target_class ) )
+ {
+ VALUE subclass_parts = rb_ary_new();
+ VALUE parts = rb_str_split( type, ":" );
+
+ while ( RARRAY(parts)->len > 1 )
+ {
+ VALUE partial;
+ rb_ary_unshift( subclass_parts, rb_ary_pop( parts ) );
+ partial = rb_ary_join( parts, colon );
+ target_class = rb_hash_aref( tags, partial );
+ if ( NIL_P( target_class ) )
+ {
+ rb_str_append( partial, colon );
+ target_class = rb_hash_aref( tags, partial );
+ }
+
+ /*
+ * Possible subclass found, see if it supports subclassing
+ */
+ if ( ! NIL_P( target_class ) )
+ {
+ subclass = target_class;
+ if ( RARRAY(subclass_parts)->len > 0 && rb_respond_to( target_class, s_tag_subclasses ) &&
+ RTEST( rb_funcall( target_class, s_tag_subclasses, 0 ) ) )
+ {
+ VALUE subclass_v;
+ subclass = rb_ary_join( subclass_parts, colon );
+ subclass = rb_funcall( target_class, s_tag_read_class, 1, subclass );
+ subclass_v = syck_const_find( subclass );
+
+ if ( subclass_v != Qnil )
+ {
+ subclass = subclass_v;
+ }
+ else if ( rb_cObject == target_class && subclass_v == Qnil )
+ {
+ // StringValue(subclass);
+ // printf( "No class: %s\n", RSTRING(subclass)->ptr );
+ target_class = cYObject;
+ type = subclass;
+ subclass = cYObject;
+ }
+ }
+ break;
+ }
+ }
+ }
+
+ /* rb_raise(rb_eTypeError, "invalid typing scheme: %s given",
+ * scheme);
+ */
+
+ if ( rb_respond_to( target_class, s_call ) )
+ {
+ obj = rb_funcall( target_class, s_call, 2, type, val );
+ }
+ else
+ {
+ if ( rb_respond_to( target_class, s_yaml_new ) )
+ {
+ obj = rb_funcall( target_class, s_yaml_new, 3, subclass, type, val );
+ }
+ else if ( !NIL_P( target_class ) )
+ {
+ obj = rb_obj_alloc( subclass );
+ if ( rb_respond_to( obj, s_yaml_initialize ) )
+ {
+ rb_funcall( obj, s_yaml_initialize, 2, type, val );
+ }
+ else if ( !NIL_P( obj ) && rb_obj_is_instance_of( val, rb_cHash ) )
+ {
+ rb_iterate( rb_each, val, syck_set_ivars, obj );
+ }
+ }
+ else
+ {
+ VALUE parts = rb_str_split( type, ":" );
+ VALUE scheme = rb_ary_shift( parts );
+ if ( rb_str_cmp( scheme, str_xprivate ) == 0 )
+ {
+ VALUE name = rb_ary_join( parts, colon );
+ obj = rb_funcall( cPrivateType, s_new, 2, name, val );
+ }
+ else
+ {
+ VALUE domain = rb_ary_shift( parts );
+ VALUE name = rb_ary_join( parts, colon );
+ obj = rb_funcall( cDomainType, s_new, 3, domain, name, val );
+ }
+ }
+ }
+ val = obj;
+ }
+
+ return val;
}
/*
- * YAML::Syck::Loader.add_private_type
+ * YAML::Syck::Resolver#tagurize
*/
VALUE
-syck_loader_add_private_type( argc, argv, self )
- int argc;
- VALUE *argv;
- VALUE self;
+syck_resolver_tagurize( self, val )
+ VALUE self, val;
{
- VALUE type_re, proc, priv_types;
+ VALUE tmp = rb_check_string_type(val);
- rb_scan_args(argc, argv, "1&", &type_re, &proc);
+ if ( !NIL_P(tmp) )
+ {
+ char *taguri;
+ val = tmp;
+ taguri = syck_type_id_to_uri( RSTRING(val)->ptr );
+ return rb_str_new2( taguri );
+ }
- priv_types = rb_attr_get(self, s_private_types);
- rb_hash_aset( priv_types, type_re, proc );
- return Qnil;
+ return val;
}
/*
- * YAML::Syck::Loader#detect
+ * YAML::Syck::DefaultResolver#detect_implicit
*/
VALUE
-syck_loader_detect_implicit( self, val )
+syck_defaultresolver_detect_implicit( self, val )
VALUE self, val;
{
char *type_id;
+ VALUE tmp = rb_check_string_type(val);
- if ( TYPE(val) == T_STRING )
+ if ( !NIL_P(tmp) )
{
+ val = tmp;
type_id = syck_match_implicit( RSTRING(val)->ptr, RSTRING(val)->len );
return rb_str_new2( type_id );
}
@@ -1045,130 +1222,98 @@ syck_loader_detect_implicit( self, val )
}
/*
- * iterator to search a type hash for a match.
+ * YAML::Syck::DefaultResolver#node_import
*/
-static VALUE
-transfer_find_i(entry, col)
- VALUE entry, col;
+VALUE
+syck_defaultresolver_node_import( self, node )
+ VALUE self, node;
{
- VALUE key = rb_ary_entry( entry, 0 );
- VALUE tid = rb_ary_entry( col, 0 );
- if ( rb_respond_to( key, s_match ) )
+ SyckNode *n;
+ VALUE obj;
+ Data_Get_Struct( node, SyckNode, n );
+ if ( !yaml_org_handler( n, &obj ) )
{
- 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();
- }
+ obj = rb_funcall( self, s_transfer, 2, rb_str_new2( n->type_id ), obj );
}
- return Qnil;
+ return obj;
}
/*
- * YAML::Syck::Loader#transfer
+ * YAML::Syck::GenericResolver#node_import
*/
VALUE
-syck_loader_transfer( self, type, val )
- VALUE self, type, val;
+syck_genericresolver_node_import( self, node )
+ VALUE self, node;
{
- char *taguri = NULL;
+ SyckNode *n;
+ int i = 0;
+ VALUE t = Qnil, obj = Qnil, v = Qnil, style = Qnil;
+ Data_Get_Struct(node, SyckNode, n);
- if (NIL_P(type) || RSTRING(StringValue(type))->len == 0)
- {
- /*
- * Empty transfer, detect type
- */
- VALUE tmp = rb_check_string_type(val);
- if (!NIL_P(tmp))
- {
- val = tmp;
- taguri = syck_match_implicit( RSTRING(val)->ptr, RSTRING(val)->len );
- taguri = syck_taguri( YAML_DOMAIN, taguri, strlen( taguri ) );
- }
- }
- else
+ if ( n->type_id != NULL )
{
- taguri = syck_type_id_to_uri( RSTRING(type)->ptr );
+ t = rb_str_new2(n->type_id);
}
- if ( taguri != NULL )
+ switch (n->kind)
{
- int transferred = 0;
- VALUE scheme, name, type_hash, domain = Qnil, type_proc = Qnil;
- VALUE type_uri = rb_str_new2( taguri );
- VALUE str_taguri = rb_str_new2("tag");
- VALUE str_xprivate = rb_str_new2("x-private");
- VALUE str_yaml_domain = rb_str_new2(YAML_DOMAIN);
- VALUE parts = rb_str_split( type_uri, ":" );
-
- scheme = rb_ary_shift( parts );
-
- if ( rb_str_cmp( scheme, str_xprivate ) == 0 )
- {
- name = rb_ary_join( parts, rb_str_new2( ":" ) );
- type_hash = rb_attr_get(self, s_private_types);
- }
- else if ( rb_str_cmp( scheme, str_taguri ) == 0 )
+ case syck_str_kind:
{
- domain = rb_ary_shift( parts );
- name = rb_ary_join( parts, rb_str_new2( ":" ) );
- type_hash = rb_attr_get(self, s_families);
- type_hash = rb_hash_aref(type_hash, domain);
-
- /*
- * Route yaml.org types through the transfer
- * method here in this extension
- */
- if ( rb_str_cmp( domain, str_yaml_domain ) == 0 )
+ v = rb_str_new( n->data.str->ptr, n->data.str->len );
+ if ( n->data.str->style == scalar_1quote )
{
- SyckNode *n = rb_new_syck_node(val, name);
- if ( n != NULL )
- {
- transferred = yaml_org_handler(n, &val);
- S_FREE( n );
- }
+ style = sym_1quote;
+ }
+ else if ( n->data.str->style == scalar_2quote )
+ {
+ style = sym_2quote;
+ }
+ else if ( n->data.str->style == scalar_fold )
+ {
+ style = sym_fold;
+ }
+ else if ( n->data.str->style == scalar_literal )
+ {
+ style = sym_literal;
+ }
+ else if ( n->data.str->style == scalar_plain )
+ {
+ style = sym_plain;
}
-
- }
- else
- {
- rb_raise(rb_eTypeError, "invalid typing scheme: %s given",
- scheme);
+ obj = rb_funcall( cScalar, s_new, 3, t, v, style );
}
+ break;
- if ( ! transferred )
- {
- if ( rb_obj_is_instance_of( type_hash, rb_cHash ) )
+ case syck_seq_kind:
+ rb_iv_set(obj, "@kind", sym_seq);
+ v = rb_ary_new2( syck_seq_count( n ) );
+ for ( i = 0; i < syck_seq_count( n ); i++ )
{
- type_proc = rb_hash_aref( type_hash, name );
- if ( NIL_P( type_proc ) )
- {
- VALUE col = rb_ary_new();
- rb_ary_push( col, name );
- rb_iterate(rb_each, type_hash, transfer_find_i, col );
- name = rb_ary_shift( col );
- type_proc = rb_ary_shift( col );
- }
+ rb_ary_store( v, i, syck_seq_read( n, i ) );
}
-
- if ( rb_respond_to( type_proc, s_call ) )
+ if ( n->data.list->style == seq_inline )
{
- val = rb_funcall(type_proc, s_call, 2, type_uri, val);
- }
- else if ( rb_str_cmp( scheme, str_xprivate ) == 0 )
+ style = sym_inline;
+ }
+ obj = rb_funcall( cSeq, s_new, 3, t, v, style );
+ break;
+
+ case syck_map_kind:
+ rb_iv_set(obj, "@kind", sym_map);
+ v = rb_hash_new();
+ for ( i = 0; i < syck_map_count( n ); i++ )
{
- val = rb_funcall(cPrivateType, s_new, 2, name, val);
+ rb_hash_aset( v, syck_map_read( n, map_key, i ), syck_map_read( n, map_value, i ) );
}
- else
+ if ( n->data.pairs->style == map_inline )
{
- val = rb_funcall(cDomainType, s_new, 3, domain, name, val);
- }
- transferred = 1;
- }
+ style = sym_inline;
+ }
+ obj = rb_funcall( cMap, s_new, 3, t, v, style );
+ break;
}
- return val;
+ return obj;
}
/*
@@ -1178,7 +1323,7 @@ VALUE
syck_badalias_initialize( self, val )
VALUE self, val;
{
- rb_ivar_set( self, s_name, val );
+ rb_iv_set( self, "@name", val );
return self;
}
@@ -1189,67 +1334,468 @@ VALUE
syck_badalias_cmp( alias1, alias2 )
VALUE alias1, alias2;
{
- VALUE str1 = rb_ivar_get( alias1, s_name );
- VALUE str2 = rb_ivar_get( alias2, s_name );
+ VALUE str1 = rb_ivar_get( alias1, s_name );
+ VALUE str2 = rb_ivar_get( alias2, s_name );
VALUE val = rb_funcall( str1, s_cmp, 1, str2 );
return val;
}
/*
- * YAML::Syck::DomainType.initialize
+ * YAML::DomainType.initialize
*/
VALUE
syck_domaintype_initialize( self, domain, type_id, val )
VALUE self, type_id, val;
{
- rb_ivar_set( self, s_domain, domain );
- rb_ivar_set( self, s_type_id, type_id );
- rb_ivar_set( self, s_value, val );
+ rb_iv_set( self, "@domain", domain );
+ rb_iv_set( self, "@type_id", type_id );
+ rb_iv_set( self, "@value", val );
return self;
}
/*
- * YAML::Syck::PrivateType.initialize
+ * YAML::Object.initialize
+ */
+VALUE
+syck_yobject_initialize( self, klass, ivars )
+ VALUE self, klass, ivars;
+{
+ rb_iv_set( self, "@class", klass );
+ rb_iv_set( self, "@ivars", ivars );
+ return self;
+}
+
+/*
+ * YAML::PrivateType.initialize
*/
VALUE
syck_privatetype_initialize( self, type_id, val )
VALUE self, type_id, val;
{
- rb_ivar_set( self, s_type_id, type_id );
- rb_ivar_set( self, s_value, val );
+ rb_iv_set( self, "@type_id", type_id );
+ rb_iv_set( self, "@value", val );
return self;
}
/*
- * YAML::Syck::Node.initialize
+ * Mark node contents.
+ */
+static void
+syck_node_mark( n )
+ SyckNode *n;
+{
+ int i;
+ switch ( n->kind )
+ {
+ case syck_seq_kind:
+ for ( i = 0; i < n->data.list->idx; i++ )
+ {
+ rb_gc_mark( syck_seq_read( n, i ) );
+ }
+ break;
+
+ case syck_map_kind:
+ for ( i = 0; i < n->data.pairs->idx; i++ )
+ {
+ rb_gc_mark( syck_map_read( n, map_key, i ) );
+ rb_gc_mark( syck_map_read( n, map_value, i ) );
+ }
+ break;
+ }
+}
+
+/*
+ * Don't free Ruby data, Ruby will do that
+ */
+void
+rb_syck_free_node( SyckNode *n )
+{
+ switch ( n->kind )
+ {
+ case syck_str_kind:
+ S_FREE( n->data.str );
+ n->data.str = NULL;
+ break;
+
+ case syck_seq_kind:
+ if ( n->data.list != NULL )
+ {
+ S_FREE( n->data.list->items );
+ S_FREE( n->data.list );
+ n->data.list = NULL;
+ }
+ break;
+
+ case syck_map_kind:
+ if ( n->data.pairs != NULL )
+ {
+ S_FREE( n->data.pairs->keys );
+ S_FREE( n->data.pairs->values );
+ S_FREE( n->data.pairs );
+ n->data.pairs = NULL;
+ }
+ break;
+ }
+
+ S_FREE( n );
+}
+
+/*
+ * YAML::Syck::Scalar.allocate
*/
VALUE
-syck_node_initialize( self, type_id, val )
- VALUE self, type_id, val;
+syck_scalar_alloc( class )
+ VALUE class;
{
- rb_ivar_set( self, s_type_id, type_id );
- rb_ivar_set( self, s_value, val );
+ SyckNode *node = syck_alloc_str();
+ VALUE obj = Data_Wrap_Struct( class, syck_node_mark, rb_syck_free_node, node );
+ node->id = obj;
+ return obj;
+}
+
+/*
+ * YAML::Syck::Scalar.initialize
+ */
+VALUE
+syck_scalar_initialize( self, type_id, val, style )
+ VALUE self, type_id, val, style;
+{
+ rb_iv_set( self, "@kind", sym_scalar );
+ rb_funcall( self, s_type_id_set, 1, type_id );
+ rb_funcall( self, s_value_set, 1, val );
+ rb_funcall( self, s_style_set, 1, style );
return self;
}
+/*
+ * YAML::Syck::Scalar.style=
+ */
VALUE
-syck_node_thash( entry, t )
- VALUE entry, t;
+syck_scalar_style_set( self, style )
+ VALUE self, style;
{
- VALUE key, val;
- key = rb_ary_entry( entry, 0 );
- val = syck_node_transform( rb_ary_entry( rb_ary_entry( entry, 1 ), 1 ) );
- rb_hash_aset( t, key, val );
- return Qnil;
+ SyckNode *node;
+ Data_Get_Struct( self, SyckNode, node );
+
+ if ( NIL_P( style ) )
+ {
+ node->data.str->style = scalar_none;
+ }
+ else if ( style == sym_1quote )
+ {
+ node->data.str->style = scalar_1quote;
+ }
+ else if ( style == sym_2quote )
+ {
+ node->data.str->style = scalar_2quote;
+ }
+ else if ( style == sym_fold )
+ {
+ node->data.str->style = scalar_fold;
+ }
+ else if ( style == sym_literal )
+ {
+ node->data.str->style = scalar_literal;
+ }
+ else if ( style == sym_plain )
+ {
+ node->data.str->style = scalar_plain;
+ }
+
+ rb_iv_set( self, "@style", style );
+ return self;
+}
+
+/*
+ * YAML::Syck::Scalar.value=
+ */
+VALUE
+syck_scalar_value_set( self, val )
+ VALUE self, val;
+{
+ SyckNode *node;
+ Data_Get_Struct( self, SyckNode, node );
+
+ StringValue( val );
+ node->data.str->ptr = RSTRING(val)->ptr;
+ node->data.str->len = RSTRING(val)->len;
+ node->data.str->style = scalar_none;
+
+ rb_iv_set( self, "@value", val );
+ return val;
+}
+
+/*
+ * YAML::Syck::Seq.allocate
+ */
+VALUE
+syck_seq_alloc( class )
+ VALUE class;
+{
+ SyckNode *node;
+ VALUE obj;
+ node = syck_alloc_seq();
+ obj = Data_Wrap_Struct( class, syck_node_mark, rb_syck_free_node, node );
+ node->id = obj;
+ return obj;
}
+/*
+ * YAML::Syck::Seq.initialize
+ */
VALUE
-syck_node_ahash( entry, t )
- VALUE entry, t;
+syck_seq_initialize( self, type_id, val, style )
+ VALUE self, type_id, val, style;
{
- VALUE val = syck_node_transform( entry );
- rb_ary_push( t, val );
- return Qnil;
+ SyckNode *node;
+ Data_Get_Struct( self, SyckNode, node );
+
+ rb_iv_set( self, "@kind", sym_seq );
+ rb_funcall( self, s_type_id_set, 1, type_id );
+ rb_funcall( self, s_value_set, 1, val );
+ rb_funcall( self, s_style_set, 1, style );
+ return self;
+}
+
+/*
+ * YAML::Syck::Seq.value=
+ */
+VALUE
+syck_seq_value_set( self, val )
+ VALUE self, val;
+{
+ SyckNode *node;
+ Data_Get_Struct( self, SyckNode, node );
+
+ val = rb_check_array_type( val );
+ if ( !NIL_P( val ) ) {
+ int i;
+ syck_seq_empty( node );
+ for ( i = 0; i < RARRAY( val )->len; i++ )
+ {
+ syck_seq_add( node, rb_ary_entry(val, i) );
+ }
+ }
+
+ rb_iv_set( self, "@value", val );
+ return val;
+}
+
+/*
+ * YAML::Syck::Seq.add
+ */
+VALUE
+syck_seq_add_m( self, val )
+ VALUE self, val;
+{
+ SyckNode *node;
+ VALUE emitter = rb_ivar_get( self, s_emitter );
+ Data_Get_Struct( self, SyckNode, node );
+
+ if ( rb_respond_to( emitter, s_node_export ) ) {
+ val = rb_funcall( emitter, s_node_export, 1, val );
+ }
+ syck_seq_add( node, val );
+ rb_ary_push( rb_ivar_get( self, s_value ), val );
+
+ return self;
+}
+
+/*
+ * YAML::Syck::Seq.style=
+ */
+VALUE
+syck_seq_style_set( self, style )
+ VALUE self, style;
+{
+ SyckNode *node;
+ Data_Get_Struct( self, SyckNode, node );
+
+ if ( style == sym_inline )
+ {
+ node->data.list->style = seq_inline;
+ }
+ else
+ {
+ node->data.list->style = seq_none;
+ }
+
+ rb_iv_set( self, "@style", style );
+ return self;
+}
+
+/*
+ * YAML::Syck::Map.allocate
+ */
+VALUE
+syck_map_alloc( class )
+ VALUE class;
+{
+ SyckNode *node;
+ VALUE obj;
+ node = syck_alloc_map();
+ obj = Data_Wrap_Struct( class, syck_node_mark, rb_syck_free_node, node );
+ node->id = obj;
+ return obj;
+}
+
+/*
+ * YAML::Syck::Map.initialize
+ */
+VALUE
+syck_map_initialize( self, type_id, val, style )
+ VALUE self, type_id, val, style;
+{
+ SyckNode *node;
+ Data_Get_Struct( self, SyckNode, node );
+
+ if ( !NIL_P( val ) )
+ {
+ VALUE hsh = rb_check_convert_type(val, T_HASH, "Hash", "to_hash");
+ VALUE keys;
+ int i;
+ if ( NIL_P(hsh) )
+ {
+ rb_raise( rb_eTypeError, "wrong argument type" );
+ }
+
+ keys = rb_funcall( hsh, s_keys, 0 );
+ for ( i = 0; i < RARRAY(keys)->len; i++ )
+ {
+ VALUE key = rb_ary_entry(keys, i);
+ syck_map_add( node, key, rb_hash_aref(hsh, key) );
+ }
+ }
+
+ rb_iv_set( self, "@kind", sym_seq );
+ rb_funcall( self, s_type_id_set, 1, type_id );
+ rb_funcall( self, s_value_set, 1, val );
+ rb_funcall( self, s_style_set, 1, style );
+ return self;
+}
+
+/*
+ * YAML::Syck::Map.value=
+ */
+VALUE
+syck_map_value_set( self, val )
+ VALUE self, val;
+{
+ SyckNode *node;
+ Data_Get_Struct( self, SyckNode, node );
+
+ if ( !NIL_P( val ) )
+ {
+ VALUE hsh = rb_check_convert_type(val, T_HASH, "Hash", "to_hash");
+ VALUE keys;
+ int i;
+ if ( NIL_P(hsh) )
+ {
+ rb_raise( rb_eTypeError, "wrong argument type" );
+ }
+
+ syck_map_empty( node );
+ keys = rb_funcall( hsh, s_keys, 0 );
+ for ( i = 0; i < RARRAY(keys)->len; i++ )
+ {
+ VALUE key = rb_ary_entry(keys, i);
+ syck_map_add( node, key, rb_hash_aref(hsh, key) );
+ }
+ }
+
+ rb_iv_set( self, "@value", val );
+ return val;
+}
+
+/*
+ * YAML::Syck::Map.add
+ */
+VALUE
+syck_map_add_m( self, key, val )
+ VALUE self, key, val;
+{
+ SyckNode *node;
+ VALUE emitter = rb_ivar_get( self, s_emitter );
+ Data_Get_Struct( self, SyckNode, node );
+
+ if ( rb_respond_to( emitter, s_node_export ) ) {
+ key = rb_funcall( emitter, s_node_export, 1, key );
+ val = rb_funcall( emitter, s_node_export, 1, val );
+ }
+ syck_map_add( node, key, val );
+ rb_hash_aset( rb_ivar_get( self, s_value ), key, val );
+
+ return self;
+}
+
+/*
+ * YAML::Syck::Map.style=
+ */
+VALUE
+syck_map_style_set( self, style )
+ VALUE self, style;
+{
+ SyckNode *node;
+ Data_Get_Struct( self, SyckNode, node );
+
+ if ( style == sym_inline )
+ {
+ node->data.pairs->style = map_inline;
+ }
+ else
+ {
+ node->data.pairs->style = map_none;
+ }
+
+ rb_iv_set( self, "@style", style );
+ return self;
+}
+
+/*
+ * Cloning method for all node types
+ */
+VALUE
+syck_node_init_copy( copy, orig )
+ VALUE copy, orig;
+{
+ SyckNode *copy_n;
+ SyckNode *orig_n;
+
+ if ( copy == orig )
+ return copy;
+
+ if ( TYPE( orig ) != T_DATA ||
+ RDATA( orig )->dfree != ( RUBY_DATA_FUNC )rb_syck_free_node )
+ {
+ rb_raise( rb_eTypeError, "wrong argument type" );
+ }
+
+ Data_Get_Struct( orig, SyckNode, orig_n );
+ Data_Get_Struct( copy, SyckNode, copy_n );
+ MEMCPY( copy_n, orig_n, SyckNode, 1 );
+ return copy;
+}
+
+/*
+ * YAML::Syck::Node#type_id=
+ */
+VALUE
+syck_node_type_id_set( self, type_id )
+ VALUE self, type_id;
+{
+ SyckNode *node;
+ Data_Get_Struct( self, SyckNode, node );
+
+ if ( node->type_id != NULL ) S_FREE( node->type_id );
+
+ if ( NIL_P( type_id ) ) {
+ node->type_id = NULL;
+ } else {
+ node->type_id = StringValuePtr( type_id );
+ }
+
+ rb_iv_set( self, "@type_id", type_id );
+ return type_id;
}
/*
@@ -1259,36 +1805,115 @@ VALUE
syck_node_transform( self )
VALUE self;
{
- VALUE t = Qnil;
- VALUE type_id = rb_attr_get( self, s_type_id );
- VALUE val = rb_attr_get( self, s_value );
- if ( rb_obj_is_instance_of( val, rb_cHash ) )
+ VALUE t;
+ SyckNode *n;
+ SyckNode *orig_n;
+ Data_Get_Struct(self, SyckNode, orig_n);
+
+ switch (orig_n->kind)
{
- t = rb_hash_new();
- rb_iterate( rb_each, val, syck_node_thash, t );
+ case syck_map_kind:
+ {
+ int i;
+ n = syck_alloc_map();
+ for ( i = 0; i < orig_n->data.pairs->idx; i++ )
+ {
+ syck_map_add( n, rb_funcall( syck_map_read( orig_n, map_key, i ), s_transform, 0 ),
+ rb_funcall( syck_map_read( orig_n, map_value, i ), s_transform, 0 ) );
+ }
+ }
+ break;
+
+ case syck_seq_kind:
+ {
+ int i;
+ n = syck_alloc_seq();
+ for ( i = 0; i < orig_n->data.list->idx; i++ )
+ {
+ syck_seq_add( n, rb_funcall( syck_seq_read( orig_n, i ), s_transform, 0 ) );
+ }
+ }
+ break;
+
+ case syck_str_kind:
+ n = syck_new_str2( orig_n->data.str->ptr, orig_n->data.str->len, orig_n->data.str->style );
+ break;
}
- else if ( rb_obj_is_instance_of( val, rb_cArray ) )
+
+ if ( orig_n->type_id != NULL )
{
- t = rb_ary_new();
- rb_iterate( rb_each, val, syck_node_ahash, t );
+ n->type_id = syck_strndup( orig_n->type_id, strlen( orig_n->type_id ) );
}
- else
+ if ( orig_n->anchor != NULL )
{
- t = val;
+ n->anchor = syck_strndup( orig_n->anchor, strlen( orig_n->anchor ) );
}
- return rb_funcall( oDefaultLoader, s_transfer, 2, type_id, t );
+ t = Data_Wrap_Struct( cNode, NULL, NULL, n );
+ n->id = t;
+ t = rb_funcall( oDefaultResolver, s_node_import, 1, t );
+ syck_free_node( n );
+ return t;
}
/*
- * Handle output from the emitter
+ * Emitter callback: assembles YAML document events from
+ * Ruby symbols. This is a brilliant way to do it.
+ * No one could possibly object.
*/
void
+rb_syck_emitter_handler(e, data)
+ SyckEmitter *e;
+ st_data_t data;
+{
+ SyckNode *n;
+ Data_Get_Struct((VALUE)data, SyckNode, n);
+
+ switch (n->kind)
+ {
+ case syck_map_kind:
+ {
+ int i;
+ syck_emit_map( e, n->type_id, n->data.pairs->style );
+ for ( i = 0; i < n->data.pairs->idx; i++ )
+ {
+ syck_emit_item( e, syck_map_read( n, map_key, i ) );
+ syck_emit_item( e, syck_map_read( n, map_value, i ) );
+ }
+ syck_emit_end( e );
+ }
+ break;
+
+ case syck_seq_kind:
+ {
+ int i;
+ syck_emit_seq( e, n->type_id, n->data.list->style );
+ for ( i = 0; i < n->data.list->idx; i++ )
+ {
+ syck_emit_item( e, syck_seq_read( n, i ) );
+ }
+ syck_emit_end( e );
+ }
+ break;
+
+ case syck_str_kind:
+ {
+ syck_emit_scalar( e, n->type_id, n->data.str->style, 0, 0, 0, n->data.str->ptr, n->data.str->len );
+ }
+ break;
+ }
+}
+
+/*
+ * Handle output from the emitter
+ */
+void
rb_syck_output_handler( emitter, str, len )
SyckEmitter *emitter;
char *str;
long len;
{
- VALUE dest = (VALUE)emitter->bonus;
+ struct emitter_xtra *bonus = (struct emitter_xtra *)emitter->bonus;
+ VALUE dest = bonus->port;
if (TYPE(dest) == T_STRING) {
rb_str_cat( dest, str, len );
} else {
@@ -1297,155 +1922,250 @@ rb_syck_output_handler( emitter, str, len )
}
/*
+ * Helper function for marking nodes in the anchor
+ * symbol table.
+ */
+void
+syck_out_mark( emitter, node )
+ VALUE emitter, node;
+{
+ SyckEmitter *emitterPtr;
+ struct emitter_xtra *bonus;
+ Data_Get_Struct(emitter, SyckEmitter, emitterPtr);
+ bonus = (struct emitter_xtra *)emitterPtr->bonus;
+ rb_ivar_set( node, s_emitter, emitter );
+ /* syck_emitter_mark_node( emitterPtr, (st_data_t)node ); */
+ if ( !NIL_P( bonus->oid ) ) {
+ rb_hash_aset( bonus->data, bonus->oid, node );
+ }
+}
+
+/*
* Mark emitter values.
*/
static void
syck_mark_emitter(emitter)
SyckEmitter *emitter;
{
- rb_gc_mark(emitter->ignore_id);
+ struct emitter_xtra *bonus;
if ( emitter->bonus != NULL )
{
- rb_gc_mark( (VALUE)emitter->bonus );
+ bonus = (struct emitter_xtra *)emitter->bonus;
+ rb_gc_mark( bonus->data );
+ rb_gc_mark( bonus->port );
}
}
/*
- * YAML::Syck::Emitter.new
+ * Free the emitter and any bonus attachment.
+ */
+void
+rb_syck_free_emitter(e)
+ SyckEmitter *e;
+{
+ struct emitter_xtra *bonus = (struct emitter_xtra *)e->bonus;
+ if ( bonus != NULL ) S_FREE( bonus );
+ syck_free_emitter(e);
+}
+
+/*
+ * YAML::Syck::Emitter.allocate
*/
VALUE syck_emitter_s_alloc _((VALUE));
-VALUE
+VALUE
syck_emitter_s_alloc(class)
VALUE class;
{
VALUE pobj;
SyckEmitter *emitter = syck_new_emitter();
- pobj = Data_Wrap_Struct( class, syck_mark_emitter, syck_free_emitter, emitter );
- syck_emitter_ignore_id( emitter, Qnil );
- syck_emitter_handler( emitter, rb_syck_output_handler );
- emitter->bonus = (void *)rb_str_new2( "" );
+ pobj = Data_Wrap_Struct( class, syck_mark_emitter, rb_syck_free_emitter, emitter );
+ syck_emitter_handler( emitter, rb_syck_emitter_handler );
+ syck_output_handler( emitter, rb_syck_output_handler );
+ rb_ivar_set( pobj, s_out, rb_funcall( cOut, s_new, 1, pobj ) );
return pobj;
}
/*
- * YAML::Syck::Emitter.initialize( options )
+ * YAML::Syck::Emitter.reset( options )
*/
-static VALUE
-syck_emitter_initialize(argc, argv, self)
+VALUE
+syck_emitter_reset( argc, argv, self )
int argc;
VALUE *argv;
VALUE self;
{
- VALUE options;
+ VALUE options, tmp;
+ SyckEmitter *emitter;
+ struct emitter_xtra *bonus;
+ volatile VALUE hash; /* protect from GC */
+
+ Data_Get_Struct(self, SyckEmitter, emitter);
+ bonus = (struct emitter_xtra *)emitter->bonus;
+ if ( bonus != NULL ) S_FREE( bonus );
+
+ bonus = S_ALLOC_N( struct emitter_xtra, 1 );
+ bonus->port = rb_str_new2( "" );
+ bonus->data = hash = rb_hash_new();
if (rb_scan_args(argc, argv, "01", &options) == 0)
{
options = rb_hash_new();
+ rb_ivar_set(self, s_options, options);
}
- else {
+ else if ( !NIL_P(tmp = rb_check_string_type(options)) )
+ {
+ bonus->port = tmp;
+ }
+ else if ( rb_respond_to( options, s_write ) )
+ {
+ bonus->port = options;
+ }
+ else
+ {
Check_Type(options, T_HASH);
+ rb_ivar_set(self, s_options, options);
}
- rb_ivar_set(self, s_options, options);
+
+ emitter->bonus = (void *)bonus;
+ rb_ivar_set(self, s_level, INT2FIX(0));
+ rb_ivar_set(self, s_resolver, Qnil);
return self;
}
/*
- * YAML::Syck::Emitter.level
+ * YAML::Syck::Emitter.emit( object_id ) { |out| ... }
*/
VALUE
-syck_emitter_level_m( self )
+syck_emitter_emit( argc, argv, self )
+ int argc;
+ VALUE *argv;
VALUE self;
{
+ VALUE oid, proc;
+ char *anchor_name;
SyckEmitter *emitter;
+ struct emitter_xtra *bonus;
+ SYMID symple;
+ int level = FIX2INT(rb_ivar_get(self, s_level)) + 1;
+ rb_ivar_set(self, s_level, INT2FIX(level));
+ rb_scan_args(argc, argv, "1&", &oid, &proc);
Data_Get_Struct(self, SyckEmitter, emitter);
- return LONG2NUM( emitter->level );
+ bonus = (struct emitter_xtra *)emitter->bonus;
+
+ /* Calculate anchors, normalize nodes, build a simpler symbol table */
+ bonus->oid = oid;
+ if ( !NIL_P( oid ) && RTEST( rb_funcall( bonus->data, s_haskey, 1, oid ) ) ) {
+ symple = rb_hash_aref( bonus->data, oid );
+ } else {
+ symple = rb_funcall( proc, s_call, 1, rb_ivar_get( self, s_out ) );
+ }
+ syck_emitter_mark_node( emitter, (st_data_t)symple );
+
+ /* Second pass, build emitted string */
+ level -= 1;
+ rb_ivar_set(self, s_level, INT2FIX(level));
+ if ( level == 0 )
+ {
+ syck_emit(emitter, (st_data_t)symple);
+ syck_emitter_flush(emitter, 0);
+
+ return bonus->port;
+ }
+
+ return symple;
}
/*
- * YAML::Syck::Emitter.flush
+ * YAML::Syck::Emitter#node_export
*/
VALUE
-syck_emitter_flush_m( self )
- VALUE self;
+syck_emitter_node_export( self, node )
+ VALUE self, node;
{
- SyckEmitter *emitter;
-
- Data_Get_Struct(self, SyckEmitter, emitter);
- syck_emitter_flush( emitter, 0 );
- return self;
+ return rb_funcall( node, s_to_yaml, 1, self );
}
/*
- * YAML::Syck::Emitter.write( str )
+ * YAML::Syck::Emitter#set_resolver
*/
VALUE
-syck_emitter_write_m( self, str )
- VALUE self, str;
+syck_emitter_set_resolver( self, resolver )
+ VALUE self, resolver;
{
- SyckEmitter *emitter;
-
- StringValue(str);
- Data_Get_Struct(self, SyckEmitter, emitter);
- syck_emitter_write( emitter, RSTRING(str)->ptr, RSTRING(str)->len );
+ rb_ivar_set( self, s_resolver, resolver );
return self;
}
/*
- * YAML::Syck::Emitter.simple( str )
+ * YAML::Syck::Out::initialize
*/
VALUE
-syck_emitter_simple_write( self, str )
- VALUE self, str;
+syck_out_initialize( self, emitter )
+ VALUE self, emitter;
{
- SyckEmitter *emitter;
-
- StringValue(str);
- Data_Get_Struct(self, SyckEmitter, emitter);
- syck_emitter_simple( emitter, RSTRING(str)->ptr, RSTRING(str)->len );
+ rb_ivar_set( self, s_emitter, emitter );
return self;
}
/*
- * YAML::Syck::Emitter.start_object( object_id )
+ * YAML::Syck::Out::map
*/
VALUE
-syck_emitter_start_object( self, oid )
- VALUE self, oid;
+syck_out_map( argc, argv, self )
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
- char *anchor_name;
- SyckEmitter *emitter;
-
- Data_Get_Struct(self, SyckEmitter, emitter);
- anchor_name = syck_emitter_start_obj( emitter, oid );
-
- if ( anchor_name == NULL )
- {
- return Qnil;
+ VALUE type_id, style, map;
+ if (rb_scan_args(argc, argv, "11", &type_id, &style) == 1) {
+ style = Qnil;
}
-
- return rb_str_new2( anchor_name );
+ map = rb_funcall( cMap, s_new, 3, type_id, rb_hash_new(), style );
+ syck_out_mark( rb_ivar_get( self, s_emitter ), map );
+ rb_yield( map );
+ return map;
}
/*
- * YAML::Syck::Emitter.end_object
+ * YAML::Syck::Out::seq
*/
VALUE
-syck_emitter_end_object( self )
+syck_out_seq( argc, argv, self )
+ int argc;
+ VALUE *argv;
VALUE self;
{
- SyckEmitter *emitter;
-
- Data_Get_Struct(self, SyckEmitter, emitter);
- syck_emitter_end_obj( emitter );
+ VALUE type_id, style, seq;
+ if (rb_scan_args(argc, argv, "11", &type_id, &style) == 1) {
+ style = Qnil;
+ }
+ seq = rb_funcall( cSeq, s_new, 3, type_id, rb_ary_new(), style );
+ syck_out_mark( rb_ivar_get( self, s_emitter ), seq );
+ rb_yield( seq );
+ return seq;
+}
- if ( emitter->level < 0 )
- {
- syck_emitter_flush( emitter, 0 );
+/*
+ * YAML::Syck::Out::scalar
+syck_out_scalar( self, type_id, str, style )
+ VALUE self, type_id, str, style;
+ */
+VALUE
+syck_out_scalar( argc, argv, self )
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE type_id, str, style, scalar;
+ if (rb_scan_args(argc, argv, "21", &type_id, &str, &style) == 2) {
+ style = Qnil;
}
- return (VALUE)emitter->bonus;
+ scalar = rb_funcall( cScalar, s_new, 3, type_id, str, style );
+ syck_out_mark( rb_ivar_get( self, s_emitter ), scalar );
+ return scalar;
}
/*
@@ -1468,96 +2188,160 @@ Init_syck()
s_to_f = rb_intern("to_f");
s_to_i = rb_intern("to_i");
s_read = rb_intern("read");
- s_anchors = rb_intern("anchors");
s_binmode = rb_intern("binmode");
s_transfer = rb_intern("transfer");
s_call = rb_intern("call");
s_cmp = rb_intern("<=>");
+ s_intern = rb_intern("intern");
s_update = rb_intern("update");
+ s_detect_implicit = rb_intern("detect_implicit");
s_dup = rb_intern("dup");
s_default_set = rb_intern("default=");
s_match = rb_intern("match");
+ s_push = rb_intern("push");
+ s_haskey = rb_intern("has_key?");
s_keys = rb_intern("keys");
+ s_node_import = rb_intern("node_import");
s_tr_bang = rb_intern("tr!");
s_unpack = rb_intern("unpack");
-
- s_anchors = rb_intern("@anchors");
- s_domain = rb_intern("@domain");
- s_families = rb_intern("@families");
- s_kind = rb_intern("@kind");
+ s_write = rb_intern("write");
+ s_tag_read_class = rb_intern( "yaml_tag_read_class" );
+ s_tag_subclasses = rb_intern( "yaml_tag_subclasses?" );
+ s_emitter = rb_intern( "emitter" );
+ s_set_resolver = rb_intern( "set_resolver" );
+ s_node_export = rb_intern( "node_export" );
+ s_to_yaml = rb_intern( "to_yaml" );
+ s_transform = rb_intern( "transform" );
+ s_yaml_new = rb_intern("yaml_new");
+ s_yaml_initialize = rb_intern("yaml_initialize");
+
+ s_tags = rb_intern("@tags");
s_name = rb_intern("@name");
s_options = rb_intern("@options");
- s_private_types = rb_intern("@private_types");
+ s_kind = rb_intern("@kind");
s_type_id = rb_intern("@type_id");
+ s_type_id_set = rb_intern("type_id=");
+ s_resolver = rb_intern("@resolver");
+ s_level = rb_intern( "@level" );
+ s_style = rb_intern("@style");
+ s_style_set = rb_intern("style=");
s_value = rb_intern("@value");
+ s_value_set = rb_intern("value=");
+ s_out = rb_intern("@out");
+ s_input = rb_intern("@input");
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_bytecode = ID2SYM(rb_intern("bytecode"));
sym_map = ID2SYM(rb_intern("map"));
sym_scalar = ID2SYM(rb_intern("scalar"));
sym_seq = ID2SYM(rb_intern("seq"));
+ sym_1quote = ID2SYM(rb_intern("quote1"));
+ sym_2quote = ID2SYM(rb_intern("quote2"));
+ sym_fold = ID2SYM(rb_intern("fold"));
+ sym_literal = ID2SYM(rb_intern("literal"));
+ sym_plain = ID2SYM(rb_intern("plain"));
+ sym_inline = ID2SYM(rb_intern("inline"));
/*
- * Define YAML::Syck::Loader class
+ * Define YAML::Syck::Resolver class
*/
- cLoader = rb_define_class_under( rb_syck, "Loader", rb_cObject );
- rb_define_attr( cLoader, "families", 1, 1 );
- rb_define_attr( cLoader, "private_types", 1, 1 );
- rb_define_attr( cLoader, "anchors", 1, 1 );
- rb_define_method( cLoader, "initialize", syck_loader_initialize, 0 );
- rb_define_method( cLoader, "add_domain_type", syck_loader_add_domain_type, -1 );
- rb_define_method( cLoader, "add_builtin_type", syck_loader_add_builtin_type, -1 );
- rb_define_method( cLoader, "add_ruby_type", syck_loader_add_ruby_type, -1 );
- rb_define_method( cLoader, "add_private_type", syck_loader_add_private_type, -1 );
- rb_define_method( cLoader, "bufsize=", syck_parser_bufsize_set, 1 );
- rb_define_method( cLoader, "bufsize", syck_parser_bufsize_get, 0 );
- rb_define_method( cLoader, "detect_implicit", syck_loader_detect_implicit, 1 );
- rb_define_method( cLoader, "transfer", syck_loader_transfer, 2 );
-
- oDefaultLoader = rb_funcall( cLoader, rb_intern( "new" ), 0 );
- rb_define_const( rb_syck, "DefaultLoader", oDefaultLoader );
+ cResolver = rb_define_class_under( rb_syck, "Resolver", rb_cObject );
+ rb_define_attr( cResolver, "tags", 1, 1 );
+ rb_define_method( cResolver, "initialize", syck_resolver_initialize, 0 );
+ rb_define_method( cResolver, "add_type", syck_resolver_add_type, 2 );
+ rb_define_method( cResolver, "use_types_at", syck_resolver_use_types_at, 1 );
+ rb_define_method( cResolver, "detect_implicit", syck_resolver_detect_implicit, 1 );
+ rb_define_method( cResolver, "transfer", syck_resolver_transfer, 2 );
+ rb_define_method( cResolver, "node_import", syck_resolver_node_import, 1 );
+ rb_define_method( cResolver, "tagurize", syck_resolver_tagurize, 1 );
+
+ oDefaultResolver = rb_funcall( cResolver, rb_intern( "new" ), 0 );
+ rb_define_singleton_method( oDefaultResolver, "node_import", syck_defaultresolver_node_import, 1 );
+ rb_define_singleton_method( oDefaultResolver, "detect_implicit", syck_defaultresolver_detect_implicit, 1 );
+ rb_define_const( rb_syck, "DefaultResolver", oDefaultResolver );
+ oGenericResolver = rb_funcall( cResolver, rb_intern( "new" ), 0 );
+ rb_define_singleton_method( oGenericResolver, "node_import", syck_genericresolver_node_import, 1 );
+ rb_define_const( rb_syck, "GenericResolver", oGenericResolver );
/*
* Define YAML::Syck::Parser class
*/
cParser = rb_define_class_under( rb_syck, "Parser", rb_cObject );
rb_define_attr( cParser, "options", 1, 1 );
+ rb_define_attr( cParser, "resolver", 1, 1 );
+ rb_define_attr( cParser, "input", 1, 1 );
rb_define_alloc_func( cParser, syck_parser_s_alloc );
- rb_define_method(cParser, "initialize", syck_parser_initialize, -1);
+ rb_define_method(cParser, "initialize", syck_parser_initialize, -1 );
+ rb_define_method(cParser, "bufsize=", syck_parser_bufsize_set, 1 );
+ rb_define_method(cParser, "bufsize", syck_parser_bufsize_get, 0 );
rb_define_method(cParser, "load", syck_parser_load, -1);
rb_define_method(cParser, "load_documents", syck_parser_load_documents, -1);
+ rb_define_method(cParser, "set_resolver", syck_parser_set_resolver, 1);
/*
* Define YAML::Syck::Node class
*/
cNode = rb_define_class_under( rb_syck, "Node", rb_cObject );
- rb_define_attr( cNode, "kind", 1, 1 );
- rb_define_attr( cNode, "type_id", 1, 1 );
- rb_define_attr( cNode, "value", 1, 1 );
- rb_define_attr( cNode, "anchor", 1, 1 );
- rb_define_method( cNode, "initialize", syck_node_initialize, 2);
+ rb_define_method( cNode, "initialize_copy", syck_node_init_copy, 1 );
+ rb_define_attr( cNode, "emitter", 1, 1 );
+ rb_define_attr( cNode, "resolver", 1, 1 );
+ rb_define_attr( cNode, "kind", 1, 0 );
+ rb_define_attr( cNode, "type_id", 1, 0 );
+ rb_define_attr( cNode, "value", 1, 0 );
+ rb_define_method( cNode, "type_id=", syck_node_type_id_set, 1 );
rb_define_method( cNode, "transform", syck_node_transform, 0);
/*
- * Define YAML::Syck::PrivateType class
+ * Define YAML::Syck::Scalar, YAML::Syck::Seq, YAML::Syck::Map --
+ * all are the publicly usable variants of YAML::Syck::Node
+ */
+ cScalar = rb_define_class_under( rb_syck, "Scalar", cNode );
+ rb_define_alloc_func( cScalar, syck_scalar_alloc );
+ rb_define_attr( cNode, "value", 1, 0 );
+ rb_define_method( cScalar, "initialize", syck_scalar_initialize, 3 );
+ rb_define_method( cScalar, "value=", syck_scalar_value_set, 1 );
+ rb_define_method( cScalar, "style=", syck_scalar_style_set, 1 );
+ cSeq = rb_define_class_under( rb_syck, "Seq", cNode );
+ rb_define_alloc_func( cSeq, syck_seq_alloc );
+ rb_define_method( cSeq, "initialize", syck_seq_initialize, 3 );
+ rb_define_method( cSeq, "value=", syck_seq_value_set, 1 );
+ rb_define_method( cSeq, "add", syck_seq_add_m, 1 );
+ rb_define_method( cSeq, "style=", syck_seq_style_set, 1 );
+ cMap = rb_define_class_under( rb_syck, "Map", cNode );
+ rb_define_alloc_func( cMap, syck_map_alloc );
+ rb_define_method( cMap, "initialize", syck_map_initialize, 3 );
+ rb_define_method( cMap, "value=", syck_map_value_set, 1 );
+ rb_define_method( cMap, "add", syck_map_add_m, 2 );
+ rb_define_method( cMap, "style=", syck_map_style_set, 1 );
+
+ /*
+ * Define YAML::PrivateType class
*/
- cPrivateType = rb_define_class_under( rb_syck, "PrivateType", rb_cObject );
+ cPrivateType = rb_define_class_under( rb_yaml, "PrivateType", rb_cObject );
rb_define_attr( cPrivateType, "type_id", 1, 1 );
rb_define_attr( cPrivateType, "value", 1, 1 );
rb_define_method( cPrivateType, "initialize", syck_privatetype_initialize, 2);
/*
- * Define YAML::Syck::DomainType class
+ * Define YAML::DomainType class
*/
- cDomainType = rb_define_class_under( rb_syck, "DomainType", rb_cObject );
+ cDomainType = rb_define_class_under( rb_yaml, "DomainType", rb_cObject );
rb_define_attr( cDomainType, "domain", 1, 1 );
rb_define_attr( cDomainType, "type_id", 1, 1 );
rb_define_attr( cDomainType, "value", 1, 1 );
rb_define_method( cDomainType, "initialize", syck_domaintype_initialize, 3);
/*
+ * Define YAML::Object class
+ */
+ cYObject = rb_define_class_under( rb_yaml, "Object", rb_cObject );
+ rb_define_attr( cYObject, "class", 1, 1 );
+ rb_define_attr( cYObject, "ivars", 1, 1 );
+ rb_define_method( cYObject, "initialize", syck_yobject_initialize, 2);
+ rb_define_method( cYObject, "yaml_initialize", syck_yobject_initialize, 2);
+
+ /*
* Define YAML::Syck::BadAlias class
*/
cBadAlias = rb_define_class_under( rb_syck, "BadAlias", rb_cObject );
@@ -1577,17 +2361,25 @@ Init_syck()
cDefaultKey = rb_define_class_under( rb_syck, "DefaultKey", rb_cObject );
/*
+ * Define YAML::Syck::Out classes
+ */
+ cOut = rb_define_class_under( rb_syck, "Out", rb_cObject );
+ rb_define_attr( cOut, "emitter", 1, 1 );
+ rb_define_method( cOut, "initialize", syck_out_initialize, 1 );
+ rb_define_method( cOut, "map", syck_out_map, -1 );
+ rb_define_method( cOut, "seq", syck_out_seq, -1 );
+ rb_define_method( cOut, "scalar", syck_out_scalar, -1 );
+
+ /*
* Define YAML::Syck::Emitter class
*/
cEmitter = rb_define_class_under( rb_syck, "Emitter", rb_cObject );
+ rb_define_attr( cEmitter, "level", 1, 1 );
rb_define_alloc_func( cEmitter, syck_emitter_s_alloc );
- 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 );
- rb_define_method( cEmitter, "<<", syck_emitter_write_m, 1 );
- rb_define_method( cEmitter, "simple", syck_emitter_simple_write, 1 );
- rb_define_method( cEmitter, "flush", syck_emitter_flush_m, 0 );
- rb_define_method( cEmitter, "start_object", syck_emitter_start_object, 1 );
- rb_define_method( cEmitter, "end_object", syck_emitter_end_object, 0 );
+ rb_define_method( cEmitter, "initialize", syck_emitter_reset, -1 );
+ rb_define_method( cEmitter, "reset", syck_emitter_reset, -1 );
+ rb_define_method( cEmitter, "emit", syck_emitter_emit, -1 );
+ rb_define_method( cEmitter, "set_resolver", syck_emitter_set_resolver, 1);
+ rb_define_method( cEmitter, "node_export", syck_emitter_node_export, 1);
}
diff --git a/ext/syck/syck.c b/ext/syck/syck.c
index 5a15ab4..33f9bf2 100644
--- a/ext/syck/syck.c
+++ b/ext/syck/syck.c
@@ -209,15 +209,6 @@ void
syck_st_free( SyckParser *p )
{
/*
- * Free the adhoc symbol table
- */
- if ( p->syms != NULL )
- {
- st_free_table( p->syms );
- p->syms = NULL;
- }
-
- /*
* Free the anchor tables
*/
if ( p->anchors != NULL )
@@ -239,6 +230,15 @@ void
syck_free_parser( SyckParser *p )
{
/*
+ * Free the adhoc symbol table
+ */
+ if ( p->syms != NULL )
+ {
+ st_free_table( p->syms );
+ p->syms = NULL;
+ }
+
+ /*
* Free tables, levels
*/
syck_st_free( p );
diff --git a/ext/syck/syck.h b/ext/syck/syck.h
index 02dbce9..ec3eed0 100644
--- a/ext/syck/syck.h
+++ b/ext/syck/syck.h
@@ -13,7 +13,7 @@
#define SYCK_YAML_MAJOR 1
#define SYCK_YAML_MINOR 0
-#define SYCK_VERSION "0.45"
+#define SYCK_VERSION "0.55"
#define YAML_DOMAIN "yaml.org,2002"
#include <stdio.h>
@@ -63,12 +63,16 @@ extern "C" {
#define BLOCK_FOLD 10
#define BLOCK_LIT 20
#define BLOCK_PLAIN 30
-#define NL_CHOMP 130
-#define NL_KEEP 140
+#define NL_CHOMP 40
+#define NL_KEEP 50
/*
* Node definitions
*/
+#ifndef ST_DATA_T_DEFINED
+typedef long st_data_t;
+#endif
+
#define SYMID unsigned long
typedef struct _syck_node SyckNode;
@@ -84,12 +88,23 @@ enum map_part {
map_value
};
+enum map_style {
+ map_none,
+ map_inline
+};
+
+enum seq_style {
+ seq_none,
+ seq_inline
+};
+
enum scalar_style {
scalar_none,
- scalar_plain,
scalar_1quote,
scalar_2quote,
- scalar_block
+ scalar_fold,
+ scalar_literal,
+ scalar_plain
};
/*
@@ -107,6 +122,7 @@ struct _syck_node {
union {
/* Storage for map data */
struct SyckMap {
+ enum map_style style;
SYMID *keys;
SYMID *values;
long capa;
@@ -114,6 +130,7 @@ struct _syck_node {
} *pairs;
/* Storage for sequence data */
struct SyckSeq {
+ enum seq_style style;
SYMID *items;
long capa;
long idx;
@@ -163,9 +180,13 @@ enum syck_level_status {
syck_lvl_map,
syck_lvl_block,
syck_lvl_str,
- syck_lvl_inline,
+ syck_lvl_iseq,
+ syck_lvl_imap,
syck_lvl_end,
- syck_lvl_pause
+ syck_lvl_pause,
+ syck_lvl_anctag,
+ syck_lvl_mapx,
+ syck_lvl_seqx
};
/*
@@ -186,9 +207,16 @@ struct _syck_str {
};
struct _syck_level {
+ /* Indent */
int spaces;
+ /* Counts nodes emitted at this level, useful for parsing
+ * keys and pairs in bytecode */
int ncount;
+ /* Does node have anchors or tags? */
+ int anctag;
+ /* Domain prefixing at the given level */
char *domain;
+ /* Keeps a node status */
enum syck_level_status status;
};
@@ -231,6 +259,7 @@ struct _syck_parser {
SyckLevel *levels;
int lvl_idx;
int lvl_capa;
+ /* Pointer for extension's use */
void *bonus;
};
@@ -241,6 +270,7 @@ typedef struct _syck_emitter SyckEmitter;
typedef struct _syck_emitter_node SyckEmitterNode;
typedef void (*SyckOutputHandler)(SyckEmitter *, char *, long);
+typedef void (*SyckEmitterHandler)(SyckEmitter *, st_data_t);
enum doc_stage {
doc_open,
@@ -248,20 +278,12 @@ enum doc_stage {
doc_processing
};
-enum block_styles {
- block_arbitrary,
- block_fold,
- block_literal
-};
-
/*
* Emitter struct
*/
struct _syck_emitter {
/* Headerless doc flag */
int headless;
- /* Sequence map shortcut flag */
- int seq_map;
/* Force header? */
int use_header;
/* Force version? */
@@ -275,7 +297,7 @@ struct _syck_emitter {
/* Best width on folded scalars */
int best_width;
/* Use literal[1] or folded[2] blocks on all text? */
- enum block_styles block_style;
+ enum scalar_style style;
/* Stage of written document */
enum doc_stage stage;
/* Level counter */
@@ -285,15 +307,21 @@ struct _syck_emitter {
/* Object ignore ID */
SYMID ignore_id;
/* Symbol table for anchors */
- st_table *markers, *anchors;
+ st_table *markers, *anchors, *anchored;
/* Custom buffer size */
size_t bufsize;
/* Buffer */
char *buffer, *marker;
/* Absolute position of the buffer */
long bufpos;
+ /* Handler for emitter nodes */
+ SyckEmitterHandler emitter_handler;
/* Handler for output */
- SyckOutputHandler handler;
+ SyckOutputHandler output_handler;
+ /* Levels of indentation */
+ SyckLevel *levels;
+ int lvl_idx;
+ int lvl_capa;
/* Pointer for extension's use */
void *bonus;
};
@@ -320,6 +348,7 @@ SyckNode *syck_hdlr_get_anchor( SyckParser *, char * );
void syck_add_transfer( char *, SyckNode *, int );
char *syck_xprivate( char *, int );
char *syck_taguri( char *, char *, int );
+int syck_tagcmp( char *, char * );
int syck_add_sym( SyckParser *, char * );
int syck_lookup_sym( SyckParser *, SYMID, char ** );
int syck_try_implicit( SyckNode * );
@@ -336,20 +365,38 @@ long syck_io_str_read( char *, SyckIoStr *, long, long );
char *syck_base64enc( char *, long );
char *syck_base64dec( char *, long );
SyckEmitter *syck_new_emitter();
+SYMID syck_emitter_mark_node( SyckEmitter *, st_data_t );
void syck_emitter_ignore_id( SyckEmitter *, SYMID );
-void syck_emitter_handler( SyckEmitter *, SyckOutputHandler );
+void syck_output_handler( SyckEmitter *, SyckOutputHandler );
+void syck_emitter_handler( SyckEmitter *, SyckEmitterHandler );
void syck_free_emitter( SyckEmitter * );
void syck_emitter_clear( SyckEmitter * );
-void syck_emitter_simple( SyckEmitter *, char *, long );
void syck_emitter_write( SyckEmitter *, char *, long );
+void syck_emitter_escape( SyckEmitter *, char *, long );
void syck_emitter_flush( SyckEmitter *, long );
-char *syck_emitter_start_obj( SyckEmitter *, SYMID );
-void syck_emitter_end_obj( SyckEmitter * );
+void syck_emit( SyckEmitter *, st_data_t );
+void syck_emit_scalar( SyckEmitter *, char *, enum scalar_style, int, int, char, char *, long );
+void syck_emit_1quoted( SyckEmitter *, int, char *, long );
+void syck_emit_2quoted( SyckEmitter *, int, char *, long );
+void syck_emit_folded( SyckEmitter *, int, char, char *, long );
+void syck_emit_literal( SyckEmitter *, char, char *, long );
+void syck_emit_seq( SyckEmitter *, char *, enum seq_style );
+void syck_emit_item( SyckEmitter *, st_data_t );
+void syck_emit_map( SyckEmitter *, char *, enum map_style );
+void syck_emit_end( SyckEmitter * );
+void syck_emit_tag( SyckEmitter *, char *, char * );
+void syck_emit_indent( SyckEmitter * );
+SyckLevel *syck_emitter_current_level( SyckEmitter * );
+SyckLevel *syck_emitter_parent_level( SyckEmitter * );
+void syck_emitter_pop_level( SyckEmitter * );
+void syck_emitter_add_level( SyckEmitter *, int, enum syck_level_status );
+void syck_emitter_reset_levels( SyckEmitter * );
SyckParser *syck_new_parser();
void syck_free_parser( SyckParser * );
void syck_parser_set_root_on_error( SyckParser *, SYMID );
void syck_parser_implicit_typing( SyckParser *, int );
void syck_parser_taguri_expansion( SyckParser *, int );
+int syck_scan_scalar( int, char *, long );
void syck_parser_handler( SyckParser *, SyckNodeHandler );
void syck_parser_error_handler( SyckParser *, SyckErrorHandler );
void syck_parser_bad_anchor_handler( SyckParser *, SyckBadAnchorHandler );
@@ -362,7 +409,6 @@ void syck_parser_pop_level( SyckParser * );
void free_any_io( SyckParser * );
long syck_parser_read( SyckParser * );
long syck_parser_readlen( SyckParser *, long );
-void syck_parser_init( SyckParser *, int );
SYMID syck_parse( SyckParser * );
void syck_default_error_handler( SyckParser *, char * );
SYMID syck_yaml2byte_handler( SyckParser *, SyckNode * );
@@ -378,30 +424,29 @@ void syck_free_node( SyckNode * );
void syck_free_members( SyckNode * );
SyckNode *syck_new_str( char *, enum scalar_style );
SyckNode *syck_new_str2( char *, long, enum scalar_style );
+void syck_replace_str( SyckNode *, char *, enum scalar_style );
+void syck_replace_str2( SyckNode *, char *, long, enum scalar_style );
void syck_str_blow_away_commas( SyckNode * );
char *syck_str_read( SyckNode * );
SyckNode *syck_new_map( SYMID, SYMID );
+void syck_map_empty( SyckNode * );
void syck_map_add( SyckNode *, SYMID, SYMID );
SYMID syck_map_read( SyckNode *, enum map_part, long );
void syck_map_assign( SyckNode *, enum map_part, long, SYMID );
long syck_map_count( SyckNode * );
void syck_map_update( SyckNode *, SyckNode * );
SyckNode *syck_new_seq( SYMID );
+void syck_seq_empty( SyckNode * );
void syck_seq_add( SyckNode *, SYMID );
+void syck_seq_assign( SyckNode *, long, SYMID );
SYMID syck_seq_read( SyckNode *, long );
long syck_seq_count( SyckNode * );
-void apply_seq_in_map( SyckParser *, SyckNode * );
-
/*
* Lexer prototypes
*/
void syckerror( char * );
-#ifndef ST_DATA_T_DEFINED
-typedef long st_data_t;
-#endif
-
#if defined(__cplusplus)
} /* extern "C" { */
#endif
diff --git a/ext/syck/token.c b/ext/syck/token.c
index 85a4e10..fd41a61 100644
--- a/ext/syck/token.c
+++ b/ext/syck/token.c
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.9.3 on Fri Aug 13 11:47:50 2004 */
+/* Generated by re2c 0.9.3 on Tue Apr 12 21:11:14 2005 */
#line 1 "token.re"
/*
* token.re
@@ -61,7 +61,7 @@
#define ENSURE_YAML_IOPEN(last_lvl, to_len, reset) \
if ( last_lvl->spaces < to_len ) \
{ \
- if ( last_lvl->status == syck_lvl_inline ) \
+ if ( last_lvl->status == syck_lvl_iseq || last_lvl->status == syck_lvl_imap ) \
{ \
goto Document; \
} \
@@ -131,6 +131,25 @@
return YAML_PLAIN; \
}
+/* concat the inline characters to the plain scalar */
+#define PLAIN_NOT_INL() \
+ if ( *(YYCURSOR - 1) == ' ' || is_newline( YYCURSOR - 1 ) ) \
+ { \
+ YYCURSOR--; \
+ } \
+ QUOTECATS(qstr, qcapa, qidx, YYTOKEN, YYCURSOR - YYTOKEN); \
+ goto Plain2;
+
+/* trim spaces off the end in case of indent */
+#define PLAIN_IS_INL() \
+ char *walker = qstr + qidx - 1; \
+ while ( walker > qstr && ( *walker == '\n' || *walker == ' ' ) ) \
+ { \
+ qidx--; \
+ walker[0] = '\0'; \
+ walker--; \
+ }
+
/*
* Keep or chomp block?
* * Use only in "ScalarBlock" section *
@@ -138,10 +157,21 @@
#define RETURN_YAML_BLOCK() \
{ \
SyckNode *n = syck_alloc_str(); \
- n->type_id = syck_strndup( "str", 3 ); \
+ if ( ((SyckParser *)parser)->taguri_expansion == 1 ) \
+ { \
+ n->type_id = syck_taguri( YAML_DOMAIN, "str", 3 ); \
+ } \
+ else \
+ { \
+ n->type_id = syck_strndup( "str", 3 ); \
+ } \
n->data.str->ptr = qstr; \
n->data.str->len = qidx; \
- n->data.str->style = scalar_block; \
+ if ( blockType == BLOCK_LIT ) { \
+ n->data.str->style = scalar_literal; \
+ } else { \
+ n->data.str->style = scalar_fold; \
+ } \
if ( qidx > 0 ) \
{ \
if ( nlDoWhat != NL_KEEP ) \
@@ -260,7 +290,7 @@ sycklex_yaml_utf8( YYSTYPE *sycklval, SyckParser *parser )
return t;
}
-#line 279 "token.re"
+#line 312 "token.re"
if ( YYLINEPTR != YYCURSOR )
@@ -299,7 +329,7 @@ yy2: yyaccept = 0;
default: goto yy3;
}
yy3:
-#line 338 "token.re"
+#line 371 "token.re"
{ YYPOS(0);
goto Document;
}
@@ -313,7 +343,7 @@ yy4: yyaccept = 0;
yy5: ++YYCURSOR;
goto yy6;
yy6:
-#line 320 "token.re"
+#line 353 "token.re"
{ eat_comments( parser );
goto Header;
}
@@ -321,7 +351,7 @@ yy6:
yy7: ++YYCURSOR;
goto yy8;
yy8:
-#line 324 "token.re"
+#line 357 "token.re"
{ SyckLevel *lvl = CURRENT_LEVEL();
ENSURE_YAML_IEND(lvl, -1);
YYPOS(0);
@@ -332,7 +362,7 @@ yy9: yyaccept = 1;
yych = *(YYMARKER = ++YYCURSOR);
goto yy18;
yy10:
-#line 330 "token.re"
+#line 363 "token.re"
{ GOBBLE_UP_YAML_INDENT( doc_level, YYTOKEN );
goto Header;
}
@@ -346,7 +376,7 @@ yy12: ++YYCURSOR;
yych = *YYCURSOR;
goto yy16;
yy13:
-#line 334 "token.re"
+#line 367 "token.re"
{ doc_level = YYCURSOR - YYLINEPTR;
goto Header;
}
@@ -398,7 +428,7 @@ yy22: yych = *++YYCURSOR;
yy23: ++YYCURSOR;
goto yy24;
yy24:
-#line 306 "token.re"
+#line 339 "token.re"
{ SyckLevel *lvl = CURRENT_LEVEL();
if ( lvl->status == syck_lvl_header )
{
@@ -441,7 +471,7 @@ yy29: yych = *++YYCURSOR;
yy30: ++YYCURSOR;
goto yy31;
yy31:
-#line 292 "token.re"
+#line 325 "token.re"
{ SyckLevel *lvl = CURRENT_LEVEL();
if ( lvl->status == syck_lvl_header )
{
@@ -470,7 +500,7 @@ yy34: ++YYCURSOR;
default: goto yy20;
}
}
-#line 342 "token.re"
+#line 375 "token.re"
Document:
@@ -494,28 +524,29 @@ yy35:
if((YYLIMIT - YYCURSOR) < 3) YYFILL(3);
yych = *YYCURSOR;
switch(yych){
- case '\000': goto yy60;
+ case '\000': goto yy62;
case '\n': goto yy37;
case '\r': goto yy39;
- case ' ': goto yy58;
- case '!': goto yy49;
- case '"': goto yy53;
- case '#': goto yy56;
- case '&': goto yy47;
- case '\'': goto yy51;
- case '*': goto yy48;
- case ',': case ':': goto yy45;
- case '-': case '?': goto yy46;
- case '>': case '|': goto yy55;
- case '[': case '{': goto yy41;
- case ']': case '}': goto yy43;
- default: goto yy62;
+ case ' ': goto yy60;
+ case '!': goto yy51;
+ case '"': goto yy55;
+ case '#': goto yy58;
+ case '&': goto yy49;
+ case '\'': goto yy53;
+ case '*': goto yy50;
+ case ',': case ':': goto yy47;
+ case '-': case '?': goto yy48;
+ case '>': case '|': goto yy57;
+ case '[': goto yy41;
+ case ']': case '}': goto yy45;
+ case '{': goto yy43;
+ default: goto yy64;
}
yy37: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
- goto yy90;
+ goto yy92;
yy38:
-#line 356 "token.re"
+#line 389 "token.re"
{ /* Isolate spaces */
int indt_len;
GOBBLE_UP_YAML_INDENT( indt_len, YYTOKEN );
@@ -529,7 +560,7 @@ yy38:
}
/* Ignore indentation inside inlines */
- if ( lvl->status == syck_lvl_inline )
+ if ( lvl->status == syck_lvl_iseq || lvl->status == syck_lvl_imap )
{
goto Document;
}
@@ -543,53 +574,63 @@ yy38:
}
return YAML_INDENT;
}
-#line 268 "<stdout>"
+#line 269 "<stdout>"
yy39: ++YYCURSOR;
switch((yych = *YYCURSOR)) {
- case '\n': goto yy89;
+ case '\n': goto yy91;
default: goto yy40;
}
yy40:
-#line 454 "token.re"
+#line 493 "token.re"
{ ENSURE_YAML_IOPEN(lvl, doc_level, 1);
goto Plain;
}
-#line 279 "<stdout>"
+#line 280 "<stdout>"
yy41: ++YYCURSOR;
goto yy42;
yy42:
-#line 384 "token.re"
+#line 417 "token.re"
{ ENSURE_YAML_IOPEN(lvl, doc_level, 1);
lvl = CURRENT_LEVEL();
- ADD_LEVEL(lvl->spaces + 1, syck_lvl_inline);
+ ADD_LEVEL(lvl->spaces + 1, syck_lvl_iseq);
return YYTOKEN[0];
}
-#line 289 "<stdout>"
+#line 290 "<stdout>"
yy43: ++YYCURSOR;
goto yy44;
yy44:
-#line 390 "token.re"
+#line 423 "token.re"
+{ ENSURE_YAML_IOPEN(lvl, doc_level, 1);
+ lvl = CURRENT_LEVEL();
+ ADD_LEVEL(lvl->spaces + 1, syck_lvl_imap);
+ return YYTOKEN[0];
+ }
+#line 300 "<stdout>"
+yy45: ++YYCURSOR;
+ goto yy46;
+yy46:
+#line 429 "token.re"
{ POP_LEVEL();
return YYTOKEN[0];
}
-#line 297 "<stdout>"
-yy45: yyaccept = 1;
+#line 308 "<stdout>"
+yy47: yyaccept = 1;
yych = *(YYMARKER = ++YYCURSOR);
switch(yych){
- case '\n': goto yy84;
- case '\r': goto yy88;
- case ' ': goto yy86;
+ case '\n': goto yy86;
+ case '\r': goto yy90;
+ case ' ': goto yy88;
default: goto yy40;
}
-yy46: yyaccept = 1;
+yy48: yyaccept = 1;
yych = *(YYMARKER = ++YYCURSOR);
switch(yych){
- case '\n': goto yy79;
- case '\r': goto yy83;
- case ' ': goto yy81;
+ case '\n': goto yy81;
+ case '\r': goto yy85;
+ case ' ': goto yy83;
default: goto yy40;
}
-yy47: yych = *++YYCURSOR;
+yy49: yych = *++YYCURSOR;
switch(yych){
case '-': case '0':
case '1':
@@ -650,10 +691,10 @@ yy47: yych = *++YYCURSOR;
case 'w':
case 'x':
case 'y':
- case 'z': goto yy76;
+ case 'z': goto yy78;
default: goto yy40;
}
-yy48: yych = *++YYCURSOR;
+yy50: yych = *++YYCURSOR;
switch(yych){
case '-': case '0':
case '1':
@@ -714,35 +755,35 @@ yy48: yych = *++YYCURSOR;
case 'w':
case 'x':
case 'y':
- case 'z': goto yy73;
+ case 'z': goto yy75;
default: goto yy40;
}
-yy49: ++YYCURSOR;
- goto yy50;
-yy50:
-#line 428 "token.re"
-{ goto TransferMethod; }
-#line 447 "<stdout>"
yy51: ++YYCURSOR;
goto yy52;
yy52:
-#line 430 "token.re"
-{ ENSURE_YAML_IOPEN(lvl, doc_level, 1);
- goto SingleQuote; }
-#line 454 "<stdout>"
+#line 467 "token.re"
+{ goto TransferMethod; }
+#line 458 "<stdout>"
yy53: ++YYCURSOR;
goto yy54;
yy54:
-#line 433 "token.re"
+#line 469 "token.re"
+{ ENSURE_YAML_IOPEN(lvl, doc_level, 1);
+ goto SingleQuote; }
+#line 465 "<stdout>"
+yy55: ++YYCURSOR;
+ goto yy56;
+yy56:
+#line 472 "token.re"
{ ENSURE_YAML_IOPEN(lvl, doc_level, 1);
goto DoubleQuote; }
-#line 461 "<stdout>"
-yy55: yyaccept = 1;
+#line 472 "<stdout>"
+yy57: yyaccept = 1;
yych = *(YYMARKER = ++YYCURSOR);
switch(yych){
- case '\n': goto yy68;
- case '\r': goto yy72;
- case ' ': goto yy70;
+ case '\n': goto yy70;
+ case '\r': goto yy74;
+ case ' ': goto yy72;
case '+': case '-': case '0':
case '1':
case '2':
@@ -752,51 +793,51 @@ yy55: yyaccept = 1;
case '6':
case '7':
case '8':
- case '9': goto yy65;
+ case '9': goto yy67;
default: goto yy40;
}
-yy56: ++YYCURSOR;
- goto yy57;
-yy57:
-#line 443 "token.re"
+yy58: ++YYCURSOR;
+ goto yy59;
+yy59:
+#line 482 "token.re"
{ eat_comments( parser );
goto Document;
}
-#line 487 "<stdout>"
-yy58: ++YYCURSOR;
- yych = *YYCURSOR;
- goto yy64;
-yy59:
-#line 447 "token.re"
-{ goto Document; }
-#line 493 "<stdout>"
+#line 498 "<stdout>"
yy60: ++YYCURSOR;
- goto yy61;
+ yych = *YYCURSOR;
+ goto yy66;
yy61:
-#line 449 "token.re"
+#line 486 "token.re"
+{ goto Document; }
+#line 504 "<stdout>"
+yy62: ++YYCURSOR;
+ goto yy63;
+yy63:
+#line 488 "token.re"
{ ENSURE_YAML_IEND(lvl, -1);
YYPOS(0);
return 0;
}
-#line 502 "<stdout>"
-yy62: yych = *++YYCURSOR;
+#line 513 "<stdout>"
+yy64: yych = *++YYCURSOR;
goto yy40;
-yy63: ++YYCURSOR;
- if(YYLIMIT == YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
- goto yy64;
-yy64: switch(yych){
- case ' ': goto yy63;
- default: goto yy59;
- }
yy65: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
goto yy66;
yy66: switch(yych){
- case '\n': goto yy68;
- case '\r': goto yy72;
- case ' ': goto yy70;
+ case ' ': goto yy65;
+ default: goto yy61;
+ }
+yy67: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy68;
+yy68: switch(yych){
+ case '\n': goto yy70;
+ case '\r': goto yy74;
+ case ' ': goto yy72;
case '+': case '-': case '0':
case '1':
case '2':
@@ -806,43 +847,43 @@ yy66: switch(yych){
case '6':
case '7':
case '8':
- case '9': goto yy65;
- default: goto yy67;
+ case '9': goto yy67;
+ default: goto yy69;
}
-yy67: YYCURSOR = YYMARKER;
+yy69: YYCURSOR = YYMARKER;
switch(yyaccept){
case 0: goto yy38;
case 1: goto yy40;
}
-yy68: ++YYCURSOR;
- goto yy69;
-yy69:
-#line 436 "token.re"
+yy70: ++YYCURSOR;
+ goto yy71;
+yy71:
+#line 475 "token.re"
{ if ( is_newline( YYCURSOR - 1 ) )
{
YYCURSOR--;
}
goto ScalarBlock;
}
-#line 550 "<stdout>"
-yy70: ++YYCURSOR;
+#line 561 "<stdout>"
+yy72: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
- goto yy71;
-yy71: switch(yych){
- case ' ': goto yy70;
- default: goto yy69;
+ goto yy73;
+yy73: switch(yych){
+ case ' ': goto yy72;
+ default: goto yy71;
}
-yy72: yych = *++YYCURSOR;
+yy74: yych = *++YYCURSOR;
switch(yych){
- case '\n': goto yy68;
- default: goto yy67;
+ case '\n': goto yy70;
+ default: goto yy69;
}
-yy73: ++YYCURSOR;
+yy75: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
- goto yy74;
-yy74: switch(yych){
+ goto yy76;
+yy76: switch(yych){
case '-': case '0':
case '1':
case '2':
@@ -902,21 +943,21 @@ yy74: switch(yych){
case 'w':
case 'x':
case 'y':
- case 'z': goto yy73;
- default: goto yy75;
+ case 'z': goto yy75;
+ default: goto yy77;
}
-yy75:
-#line 423 "token.re"
+yy77:
+#line 462 "token.re"
{ ENSURE_YAML_IOPEN(lvl, doc_level, 1);
sycklval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 );
return YAML_ALIAS;
}
-#line 639 "<stdout>"
-yy76: ++YYCURSOR;
+#line 650 "<stdout>"
+yy78: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
- goto yy77;
-yy77: switch(yych){
+ goto yy79;
+yy79: switch(yych){
case '-': case '0':
case '1':
case '2':
@@ -976,11 +1017,11 @@ yy77: switch(yych){
case 'w':
case 'x':
case 'y':
- case 'z': goto yy76;
- default: goto yy78;
+ case 'z': goto yy78;
+ default: goto yy80;
}
-yy78:
-#line 412 "token.re"
+yy80:
+#line 451 "token.re"
{ sycklval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 );
/*
@@ -991,11 +1032,11 @@ yy78:
syck_hdlr_remove_anchor(parser, sycklval->name);
return YAML_ANCHOR;
}
-#line 720 "<stdout>"
-yy79: ++YYCURSOR;
- goto yy80;
-yy80:
-#line 398 "token.re"
+#line 731 "<stdout>"
+yy81: ++YYCURSOR;
+ goto yy82;
+yy82:
+#line 437 "token.re"
{ ENSURE_YAML_IOPEN(lvl, YYTOKEN - YYLINEPTR, 1);
FORCE_NEXT_TOKEN(YAML_IOPEN);
if ( *YYCURSOR == '#' || is_newline( YYCURSOR ) || is_newline( YYCURSOR - 1 ) )
@@ -1009,60 +1050,60 @@ yy80:
}
return YYTOKEN[0];
}
-#line 738 "<stdout>"
-yy81: ++YYCURSOR;
+#line 749 "<stdout>"
+yy83: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
- goto yy82;
-yy82: switch(yych){
- case ' ': goto yy81;
- default: goto yy80;
+ goto yy84;
+yy84: switch(yych){
+ case ' ': goto yy83;
+ default: goto yy82;
}
-yy83: yych = *++YYCURSOR;
+yy85: yych = *++YYCURSOR;
switch(yych){
- case '\n': goto yy79;
- default: goto yy67;
+ case '\n': goto yy81;
+ default: goto yy69;
}
-yy84: ++YYCURSOR;
- goto yy85;
-yy85:
-#line 394 "token.re"
+yy86: ++YYCURSOR;
+ goto yy87;
+yy87:
+#line 433 "token.re"
{ YYPOS(1);
return YYTOKEN[0];
}
-#line 760 "<stdout>"
-yy86: ++YYCURSOR;
+#line 771 "<stdout>"
+yy88: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
- goto yy87;
-yy87: switch(yych){
- case ' ': goto yy86;
- default: goto yy85;
+ goto yy89;
+yy89: switch(yych){
+ case ' ': goto yy88;
+ default: goto yy87;
}
-yy88: yych = *++YYCURSOR;
+yy90: yych = *++YYCURSOR;
switch(yych){
- case '\n': goto yy84;
- default: goto yy67;
+ case '\n': goto yy86;
+ default: goto yy69;
}
-yy89: yyaccept = 0;
+yy91: yyaccept = 0;
YYMARKER = ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
- goto yy90;
-yy90: switch(yych){
- case '\n': case ' ': goto yy89;
- case '\r': goto yy91;
+ goto yy92;
+yy92: switch(yych){
+ case '\n': case ' ': goto yy91;
+ case '\r': goto yy93;
default: goto yy38;
}
-yy91: ++YYCURSOR;
+yy93: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
switch(yych){
- case '\n': goto yy89;
- default: goto yy67;
+ case '\n': goto yy91;
+ default: goto yy69;
}
}
-#line 458 "token.re"
+#line 497 "token.re"
}
@@ -1071,26 +1112,26 @@ Directive:
YYTOKTMP = YYCURSOR;
-#line 796 "<stdout>"
+#line 807 "<stdout>"
{
YYCTYPE yych;
unsigned int yyaccept;
- goto yy92;
-yy93: ++YYCURSOR;
-yy92:
+ goto yy94;
+yy95: ++YYCURSOR;
+yy94:
if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
yych = *YYCURSOR;
switch(yych){
- case '\000': goto yy94;
- case ' ': goto yy97;
- case '%': goto yy95;
- default: goto yy99;
+ case '\000': goto yy96;
+ case ' ': goto yy99;
+ case '%': goto yy97;
+ default: goto yy101;
}
-yy94: YYCURSOR = YYMARKER;
+yy96: YYCURSOR = YYMARKER;
switch(yyaccept){
- case 0: goto yy96;
+ case 0: goto yy98;
}
-yy95: yyaccept = 0;
+yy97: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
switch(yych){
case '.':
@@ -1167,37 +1208,37 @@ yy95: yyaccept = 0;
case 'w':
case 'x':
case 'y':
- case 'z': goto yy102;
- default: goto yy96;
+ case 'z': goto yy104;
+ default: goto yy98;
}
-yy96:
-#line 471 "token.re"
+yy98:
+#line 510 "token.re"
{ YYCURSOR = YYTOKTMP;
return YAML_DOCSEP;
}
-#line 900 "<stdout>"
-yy97: ++YYCURSOR;
+#line 911 "<stdout>"
+yy99: ++YYCURSOR;
yych = *YYCURSOR;
- goto yy101;
-yy98:
-#line 469 "token.re"
+ goto yy103;
+yy100:
+#line 508 "token.re"
{ goto Directive; }
-#line 906 "<stdout>"
-yy99: yych = *++YYCURSOR;
- goto yy96;
-yy100: ++YYCURSOR;
- if(YYLIMIT == YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
- goto yy101;
-yy101: switch(yych){
- case ' ': goto yy100;
- default: goto yy98;
- }
+#line 917 "<stdout>"
+yy101: yych = *++YYCURSOR;
+ goto yy98;
yy102: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
goto yy103;
yy103: switch(yych){
+ case ' ': goto yy102;
+ default: goto yy100;
+ }
+yy104: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy105;
+yy105: switch(yych){
case '.':
case '/':
case '0':
@@ -1270,11 +1311,11 @@ yy103: switch(yych){
case 'w':
case 'x':
case 'y':
- case 'z': goto yy102;
- case ':': goto yy104;
- default: goto yy94;
+ case 'z': goto yy104;
+ case ':': goto yy106;
+ default: goto yy96;
}
-yy104: yych = *++YYCURSOR;
+yy106: yych = *++YYCURSOR;
switch(yych){
case '.':
case '/':
@@ -1350,14 +1391,14 @@ yy104: yych = *++YYCURSOR;
case 'w':
case 'x':
case 'y':
- case 'z': goto yy105;
- default: goto yy94;
+ case 'z': goto yy107;
+ default: goto yy96;
}
-yy105: ++YYCURSOR;
+yy107: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
- goto yy106;
-yy106: switch(yych){
+ goto yy108;
+yy108: switch(yych){
case '.':
case '/':
case '0':
@@ -1432,15 +1473,15 @@ yy106: switch(yych){
case 'w':
case 'x':
case 'y':
- case 'z': goto yy105;
- default: goto yy107;
+ case 'z': goto yy107;
+ default: goto yy109;
}
-yy107:
-#line 467 "token.re"
+yy109:
+#line 506 "token.re"
{ goto Directive; }
-#line 1165 "<stdout>"
+#line 1176 "<stdout>"
}
-#line 474 "token.re"
+#line 513 "token.re"
}
@@ -1463,30 +1504,31 @@ Plain2:
Plain3:
-#line 1169 "<stdout>"
+#line 1180 "<stdout>"
{
YYCTYPE yych;
unsigned int yyaccept;
- goto yy108;
-yy109: ++YYCURSOR;
-yy108:
+ goto yy110;
+yy111: ++YYCURSOR;
+yy110:
if((YYLIMIT - YYCURSOR) < 3) YYFILL(3);
yych = *YYCURSOR;
switch(yych){
- case '\000': goto yy120;
- case '\n': goto yy110;
- case '\r': goto yy112;
- case ' ': goto yy118;
+ case '\000': goto yy124;
+ case '\n': goto yy112;
+ case '\r': goto yy114;
+ case ' ': goto yy122;
case ',': goto yy117;
- case ':': goto yy114;
- case ']': case '}': goto yy115;
- default: goto yy122;
+ case ':': goto yy116;
+ case ']': goto yy120;
+ case '}': goto yy118;
+ default: goto yy126;
}
-yy110: yyaccept = 0;
+yy112: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
- goto yy136;
-yy111:
-#line 497 "token.re"
+ goto yy141;
+yy113:
+#line 536 "token.re"
{ int indt_len, nl_count = 0;
SyckLevel *lvl;
char *tok = YYTOKEN;
@@ -1522,144 +1564,160 @@ yy111:
goto Plain2;
}
-#line 1228 "<stdout>"
-yy112: ++YYCURSOR;
+#line 1240 "<stdout>"
+yy114: ++YYCURSOR;
switch((yych = *YYCURSOR)) {
- case '\n': goto yy135;
- default: goto yy113;
+ case '\n': goto yy140;
+ default: goto yy115;
}
-yy113:
-#line 566 "token.re"
+yy115:
+#line 615 "token.re"
{ QUOTECATS(qstr, qcapa, qidx, YYTOKEN, YYCURSOR - YYTOKEN);
goto Plain2;
}
-#line 1239 "<stdout>"
-yy114: yyaccept = 1;
+#line 1251 "<stdout>"
+yy116: yyaccept = 1;
yych = *(YYMARKER = ++YYCURSOR);
switch(yych){
- case '\n': goto yy130;
- case '\r': goto yy134;
- case ' ': goto yy132;
- default: goto yy113;
+ case '\n': goto yy135;
+ case '\r': goto yy139;
+ case ' ': goto yy137;
+ default: goto yy115;
}
-yy115: ++YYCURSOR;
- goto yy116;
-yy116:
-#line 535 "token.re"
-{ if ( plvl->status != syck_lvl_inline )
+yy117: yyaccept = 1;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case '\n': goto yy129;
+ case '\r': goto yy133;
+ case ' ': goto yy131;
+ default: goto yy115;
+ }
+yy118: ++YYCURSOR;
+ goto yy119;
+yy119:
+#line 585 "token.re"
+{ if ( plvl->status != syck_lvl_imap )
{
- if ( *(YYCURSOR - 1) == ' ' || is_newline( YYCURSOR - 1 ) )
- {
- YYCURSOR--;
- }
- QUOTECATS(qstr, qcapa, qidx, YYTOKEN, YYCURSOR - YYTOKEN);
- goto Plain2;
+ PLAIN_NOT_INL();
}
else
{
- /* trim spaces off the end in case of indent */
- char *walker = qstr + qidx - 1;
- while ( walker > qstr && ( *walker == '\n' || *walker == ' ' ) )
- {
- qidx--;
- walker[0] = '\0';
- walker--;
- }
+ PLAIN_IS_INL();
}
RETURN_IMPLICIT();
}
-#line 1274 "<stdout>"
-yy117: yyaccept = 1;
- yych = *(YYMARKER = ++YYCURSOR);
- switch(yych){
- case '\n': goto yy125;
- case '\r': goto yy128;
- case ' ': goto yy126;
- default: goto yy113;
- }
-yy118: ++YYCURSOR;
- switch((yych = *YYCURSOR)) {
- case '#': goto yy123;
- default: goto yy119;
- }
-yy119:
-#line 564 "token.re"
-{ goto Plain3; }
-#line 1291 "<stdout>"
+#line 1282 "<stdout>"
yy120: ++YYCURSOR;
goto yy121;
yy121:
-#line 562 "token.re"
-{ RETURN_IMPLICIT(); }
+#line 596 "token.re"
+{ if ( plvl->status != syck_lvl_iseq )
+ {
+ PLAIN_NOT_INL();
+ }
+ else
+ {
+ PLAIN_IS_INL();
+ }
+ RETURN_IMPLICIT();
+ }
#line 1297 "<stdout>"
-yy122: yych = *++YYCURSOR;
- goto yy113;
-yy123: ++YYCURSOR;
- goto yy124;
-yy124:
-#line 558 "token.re"
+yy122: ++YYCURSOR;
+ switch((yych = *YYCURSOR)) {
+ case '#': goto yy127;
+ default: goto yy123;
+ }
+yy123:
+#line 613 "token.re"
+{ goto Plain3; }
+#line 1306 "<stdout>"
+yy124: ++YYCURSOR;
+ goto yy125;
+yy125:
+#line 611 "token.re"
+{ RETURN_IMPLICIT(); }
+#line 1312 "<stdout>"
+yy126: yych = *++YYCURSOR;
+ goto yy115;
+yy127: ++YYCURSOR;
+ goto yy128;
+yy128:
+#line 607 "token.re"
{ eat_comments( parser );
RETURN_IMPLICIT();
}
-#line 1307 "<stdout>"
-yy125: yych = *++YYCURSOR;
- goto yy116;
-yy126: ++YYCURSOR;
+#line 1322 "<stdout>"
+yy129: ++YYCURSOR;
+ goto yy130;
+yy130:
+#line 574 "token.re"
+{ if ( plvl->status != syck_lvl_iseq && plvl->status != syck_lvl_imap )
+ {
+ PLAIN_NOT_INL();
+ }
+ else
+ {
+ PLAIN_IS_INL();
+ }
+ RETURN_IMPLICIT();
+ }
+#line 1337 "<stdout>"
+yy131: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
- goto yy127;
-yy127: switch(yych){
- case ' ': goto yy126;
- default: goto yy116;
+ goto yy132;
+yy132: switch(yych){
+ case ' ': goto yy131;
+ default: goto yy130;
}
-yy128: yych = *++YYCURSOR;
+yy133: yych = *++YYCURSOR;
switch(yych){
- case '\n': goto yy125;
- default: goto yy129;
+ case '\n': goto yy129;
+ default: goto yy134;
}
-yy129: YYCURSOR = YYMARKER;
+yy134: YYCURSOR = YYMARKER;
switch(yyaccept){
- case 0: goto yy111;
- case 1: goto yy113;
+ case 0: goto yy113;
+ case 1: goto yy115;
}
-yy130: ++YYCURSOR;
- goto yy131;
-yy131:
-#line 533 "token.re"
+yy135: ++YYCURSOR;
+ goto yy136;
+yy136:
+#line 572 "token.re"
{ RETURN_IMPLICIT(); }
-#line 1334 "<stdout>"
-yy132: ++YYCURSOR;
+#line 1362 "<stdout>"
+yy137: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
- goto yy133;
-yy133: switch(yych){
- case ' ': goto yy132;
- default: goto yy131;
+ goto yy138;
+yy138: switch(yych){
+ case ' ': goto yy137;
+ default: goto yy136;
}
-yy134: yych = *++YYCURSOR;
+yy139: yych = *++YYCURSOR;
switch(yych){
- case '\n': goto yy130;
- default: goto yy129;
+ case '\n': goto yy135;
+ default: goto yy134;
}
-yy135: yyaccept = 0;
+yy140: yyaccept = 0;
YYMARKER = ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
- goto yy136;
-yy136: switch(yych){
- case '\n': case ' ': goto yy135;
- case '\r': goto yy137;
- default: goto yy111;
+ goto yy141;
+yy141: switch(yych){
+ case '\n': case ' ': goto yy140;
+ case '\r': goto yy142;
+ default: goto yy113;
}
-yy137: ++YYCURSOR;
+yy142: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
switch(yych){
- case '\n': goto yy135;
- default: goto yy129;
+ case '\n': goto yy140;
+ default: goto yy134;
}
}
-#line 570 "token.re"
+#line 619 "token.re"
}
@@ -1673,27 +1731,27 @@ SingleQuote2:
YYTOKEN = YYCURSOR;
-#line 1370 "<stdout>"
+#line 1398 "<stdout>"
{
YYCTYPE yych;
unsigned int yyaccept;
- goto yy138;
-yy139: ++YYCURSOR;
-yy138:
+ goto yy143;
+yy144: ++YYCURSOR;
+yy143:
if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
yych = *YYCURSOR;
switch(yych){
- case '\000': goto yy146;
- case '\n': goto yy140;
- case '\r': goto yy142;
- case '\'': goto yy144;
- default: goto yy147;
+ case '\000': goto yy151;
+ case '\n': goto yy145;
+ case '\r': goto yy147;
+ case '\'': goto yy149;
+ default: goto yy152;
}
-yy140: yyaccept = 0;
+yy145: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
- goto yy151;
-yy141:
-#line 584 "token.re"
+ goto yy156;
+yy146:
+#line 633 "token.re"
{ int indt_len;
int nl_count = 0;
SyckLevel *lvl;
@@ -1733,25 +1791,25 @@ yy141:
goto SingleQuote2;
}
-#line 1430 "<stdout>"
-yy142: ++YYCURSOR;
+#line 1458 "<stdout>"
+yy147: ++YYCURSOR;
switch((yych = *YYCURSOR)) {
- case '\n': goto yy150;
- default: goto yy143;
+ case '\n': goto yy155;
+ default: goto yy148;
}
-yy143:
-#line 644 "token.re"
+yy148:
+#line 700 "token.re"
{ QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1));
goto SingleQuote2;
}
-#line 1441 "<stdout>"
-yy144: ++YYCURSOR;
+#line 1469 "<stdout>"
+yy149: ++YYCURSOR;
switch((yych = *YYCURSOR)) {
- case '\'': goto yy148;
- default: goto yy145;
+ case '\'': goto yy153;
+ default: goto yy150;
}
-yy145:
-#line 628 "token.re"
+yy150:
+#line 677 "token.re"
{ SyckLevel *lvl;
SyckNode *n = syck_alloc_str();
lvl = CURRENT_LEVEL();
@@ -1760,49 +1818,56 @@ yy145:
{
POP_LEVEL();
}
- n->type_id = syck_strndup( "str", 3 );
+ if ( ((SyckParser *)parser)->taguri_expansion == 1 )
+ {
+ n->type_id = syck_taguri( YAML_DOMAIN, "str", 3 );
+ }
+ else
+ {
+ 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;
}
-#line 1464 "<stdout>"
-yy146: yych = *++YYCURSOR;
- goto yy145;
-yy147: yych = *++YYCURSOR;
- goto yy143;
-yy148: ++YYCURSOR;
- goto yy149;
-yy149:
-#line 624 "token.re"
+#line 1499 "<stdout>"
+yy151: yych = *++YYCURSOR;
+ goto yy150;
+yy152: yych = *++YYCURSOR;
+ goto yy148;
+yy153: ++YYCURSOR;
+ goto yy154;
+yy154:
+#line 673 "token.re"
{ QUOTECAT(qstr, qcapa, qidx, '\'');
goto SingleQuote2;
}
-#line 1476 "<stdout>"
-yy150: yyaccept = 0;
+#line 1511 "<stdout>"
+yy155: yyaccept = 0;
YYMARKER = ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
- goto yy151;
-yy151: switch(yych){
- case '\n': case ' ': goto yy150;
- case '\r': goto yy152;
- default: goto yy141;
+ goto yy156;
+yy156: switch(yych){
+ case '\n': case ' ': goto yy155;
+ case '\r': goto yy157;
+ default: goto yy146;
}
-yy152: ++YYCURSOR;
+yy157: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
switch(yych){
- case '\n': goto yy150;
- default: goto yy153;
+ case '\n': goto yy155;
+ default: goto yy158;
}
-yy153: YYCURSOR = YYMARKER;
+yy158: YYCURSOR = YYMARKER;
switch(yyaccept){
- case 0: goto yy141;
+ case 0: goto yy146;
}
}
-#line 648 "token.re"
+#line 704 "token.re"
}
@@ -1820,28 +1885,28 @@ DoubleQuote2:
-#line 1502 "<stdout>"
+#line 1537 "<stdout>"
{
YYCTYPE yych;
unsigned int yyaccept;
- goto yy154;
-yy155: ++YYCURSOR;
-yy154:
+ goto yy159;
+yy160: ++YYCURSOR;
+yy159:
if((YYLIMIT - YYCURSOR) < 4) YYFILL(4);
yych = *YYCURSOR;
switch(yych){
- case '\000': goto yy161;
- case '\n': goto yy156;
- case '\r': goto yy158;
- case '"': goto yy163;
- case '\\': goto yy160;
- default: goto yy164;
- }
-yy156: yyaccept = 0;
+ case '\000': goto yy166;
+ case '\n': goto yy161;
+ case '\r': goto yy163;
+ case '"': goto yy168;
+ case '\\': goto yy165;
+ default: goto yy169;
+ }
+yy161: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
- goto yy178;
-yy157:
-#line 666 "token.re"
+ goto yy183;
+yy162:
+#line 722 "token.re"
{ int indt_len;
int nl_count = 0;
SyckLevel *lvl;
@@ -1885,34 +1950,34 @@ yy157:
keep_nl = 1;
goto DoubleQuote2;
}
-#line 1567 "<stdout>"
-yy158: ++YYCURSOR;
+#line 1602 "<stdout>"
+yy163: ++YYCURSOR;
switch((yych = *YYCURSOR)) {
- case '\n': goto yy177;
- default: goto yy159;
+ case '\n': goto yy182;
+ default: goto yy164;
}
-yy159:
-#line 745 "token.re"
+yy164:
+#line 808 "token.re"
{ QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1));
goto DoubleQuote2;
}
-#line 1578 "<stdout>"
-yy160: yyaccept = 1;
+#line 1613 "<stdout>"
+yy165: yyaccept = 1;
yych = *(YYMARKER = ++YYCURSOR);
switch(yych){
- case '\n': goto yy168;
- case '\r': goto yy170;
- case ' ': goto yy165;
+ case '\n': goto yy173;
+ case '\r': goto yy175;
+ case ' ': goto yy170;
case '"': case '0': case '\\': case 'a':
case 'b': case 'e':
- case 'f': case 'n': case 'r': case 't': case 'v': goto yy172;
- case 'x': goto yy171;
- default: goto yy159;
+ case 'f': case 'n': case 'r': case 't': case 'v': goto yy177;
+ case 'x': goto yy176;
+ default: goto yy164;
}
-yy161: ++YYCURSOR;
- goto yy162;
-yy162:
-#line 729 "token.re"
+yy166: ++YYCURSOR;
+ goto yy167;
+yy167:
+#line 785 "token.re"
{ SyckLevel *lvl;
SyckNode *n = syck_alloc_str();
lvl = CURRENT_LEVEL();
@@ -1921,48 +1986,55 @@ yy162:
{
POP_LEVEL();
}
- n->type_id = syck_strndup( "str", 3 );
+ if ( ((SyckParser *)parser)->taguri_expansion == 1 )
+ {
+ n->type_id = syck_taguri( YAML_DOMAIN, "str", 3 );
+ }
+ else
+ {
+ 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;
}
-#line 1610 "<stdout>"
-yy163: yych = *++YYCURSOR;
- goto yy162;
-yy164: yych = *++YYCURSOR;
- goto yy159;
-yy165: ++YYCURSOR;
+#line 1652 "<stdout>"
+yy168: yych = *++YYCURSOR;
+ goto yy167;
+yy169: yych = *++YYCURSOR;
+ goto yy164;
+yy170: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
- goto yy166;
-yy166: switch(yych){
- case '\n': goto yy168;
- case '\r': goto yy170;
- case ' ': goto yy165;
- default: goto yy167;
- }
-yy167: YYCURSOR = YYMARKER;
+ goto yy171;
+yy171: switch(yych){
+ case '\n': goto yy173;
+ case '\r': goto yy175;
+ case ' ': goto yy170;
+ default: goto yy172;
+ }
+yy172: YYCURSOR = YYMARKER;
switch(yyaccept){
- case 0: goto yy157;
- case 1: goto yy159;
+ case 0: goto yy162;
+ case 1: goto yy164;
}
-yy168: ++YYCURSOR;
- goto yy169;
-yy169:
-#line 724 "token.re"
+yy173: ++YYCURSOR;
+ goto yy174;
+yy174:
+#line 780 "token.re"
{ keep_nl = 0;
YYCURSOR--;
goto DoubleQuote2;
}
-#line 1639 "<stdout>"
-yy170: yych = *++YYCURSOR;
+#line 1681 "<stdout>"
+yy175: yych = *++YYCURSOR;
switch(yych){
- case '\n': goto yy168;
- default: goto yy167;
+ case '\n': goto yy173;
+ default: goto yy172;
}
-yy171: yych = *++YYCURSOR;
+yy176: yych = *++YYCURSOR;
switch(yych){
case '0':
case '1':
@@ -1983,19 +2055,19 @@ yy171: yych = *++YYCURSOR;
case 'c':
case 'd':
case 'e':
- case 'f': goto yy174;
- default: goto yy167;
+ case 'f': goto yy179;
+ default: goto yy172;
}
-yy172: ++YYCURSOR;
- goto yy173;
-yy173:
-#line 710 "token.re"
+yy177: ++YYCURSOR;
+ goto yy178;
+yy178:
+#line 766 "token.re"
{ char ch = *( YYCURSOR - 1 );
QUOTECAT(qstr, qcapa, qidx, escape_seq( ch ));
goto DoubleQuote2;
}
-#line 1677 "<stdout>"
-yy174: yych = *++YYCURSOR;
+#line 1719 "<stdout>"
+yy179: yych = *++YYCURSOR;
switch(yych){
case '0':
case '1':
@@ -2016,13 +2088,13 @@ yy174: yych = *++YYCURSOR;
case 'c':
case 'd':
case 'e':
- case 'f': goto yy175;
- default: goto yy167;
+ case 'f': goto yy180;
+ default: goto yy172;
}
-yy175: ++YYCURSOR;
- goto yy176;
-yy176:
-#line 715 "token.re"
+yy180: ++YYCURSOR;
+ goto yy181;
+yy181:
+#line 771 "token.re"
{ long ch;
char *chr_text = syck_strndup( YYTOKEN, 4 );
chr_text[0] = '0';
@@ -2031,26 +2103,26 @@ yy176:
QUOTECAT(qstr, qcapa, qidx, ch);
goto DoubleQuote2;
}
-#line 1714 "<stdout>"
-yy177: yyaccept = 0;
+#line 1756 "<stdout>"
+yy182: yyaccept = 0;
YYMARKER = ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
- goto yy178;
-yy178: switch(yych){
- case '\n': case ' ': goto yy177;
- case '\r': goto yy179;
- default: goto yy157;
+ goto yy183;
+yy183: switch(yych){
+ case '\n': case ' ': goto yy182;
+ case '\r': goto yy184;
+ default: goto yy162;
}
-yy179: ++YYCURSOR;
+yy184: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
switch(yych){
- case '\n': goto yy177;
- default: goto yy167;
+ case '\n': goto yy182;
+ default: goto yy172;
}
}
-#line 749 "token.re"
+#line 812 "token.re"
}
@@ -2064,31 +2136,27 @@ TransferMethod2:
YYTOKTMP = YYCURSOR;
-#line 1736 "<stdout>"
+#line 1778 "<stdout>"
{
YYCTYPE yych;
unsigned int yyaccept;
- goto yy180;
-yy181: ++YYCURSOR;
-yy180:
+ goto yy185;
+yy186: ++YYCURSOR;
+yy185:
if((YYLIMIT - YYCURSOR) < 4) YYFILL(4);
yych = *YYCURSOR;
switch(yych){
- case '\000': goto yy182;
- case '\n': goto yy183;
- case '\r': goto yy186;
- case ' ': goto yy185;
- case '\\': goto yy188;
- default: goto yy189;
- }
-yy182: YYCURSOR = YYMARKER;
- switch(yyaccept){
- case 0: goto yy187;
- }
-yy183: ++YYCURSOR;
- goto yy184;
-yy184:
-#line 763 "token.re"
+ case '\000': goto yy187;
+ case '\n': goto yy189;
+ case '\r': goto yy191;
+ case ' ': goto yy190;
+ case '\\': goto yy193;
+ default: goto yy194;
+ }
+yy187: ++YYCURSOR;
+ goto yy188;
+yy188:
+#line 826 "token.re"
{ SyckLevel *lvl;
YYCURSOR = YYTOKTMP;
if ( YYCURSOR == YYTOKEN + 1 )
@@ -2138,32 +2206,34 @@ yy184:
return YAML_TRANSFER;
}
-#line 1810 "<stdout>"
-yy185: yych = *++YYCURSOR;
- goto yy198;
-yy186: ++YYCURSOR;
+#line 1848 "<stdout>"
+yy189: yych = *++YYCURSOR;
+ goto yy188;
+yy190: yych = *++YYCURSOR;
+ goto yy203;
+yy191: ++YYCURSOR;
switch((yych = *YYCURSOR)) {
- case '\n': goto yy196;
- default: goto yy187;
+ case '\n': goto yy187;
+ default: goto yy192;
}
-yy187:
-#line 830 "token.re"
+yy192:
+#line 893 "token.re"
{ QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1));
goto TransferMethod2;
}
-#line 1823 "<stdout>"
-yy188: yyaccept = 0;
+#line 1863 "<stdout>"
+yy193: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
switch(yych){
case '"': case '0': case '\\': case 'a':
case 'b': case 'e':
- case 'f': case 'n': case 'r': case 't': case 'v': goto yy191;
- case 'x': goto yy190;
- default: goto yy187;
+ case 'f': case 'n': case 'r': case 't': case 'v': goto yy197;
+ case 'x': goto yy195;
+ default: goto yy192;
}
-yy189: yych = *++YYCURSOR;
- goto yy187;
-yy190: yych = *++YYCURSOR;
+yy194: yych = *++YYCURSOR;
+ goto yy192;
+yy195: yych = *++YYCURSOR;
switch(yych){
case '0':
case '1':
@@ -2184,19 +2254,23 @@ yy190: yych = *++YYCURSOR;
case 'c':
case 'd':
case 'e':
- case 'f': goto yy193;
- default: goto yy182;
+ case 'f': goto yy199;
+ default: goto yy196;
}
-yy191: ++YYCURSOR;
- goto yy192;
-yy192:
-#line 816 "token.re"
+yy196: YYCURSOR = YYMARKER;
+ switch(yyaccept){
+ case 0: goto yy192;
+ }
+yy197: ++YYCURSOR;
+ goto yy198;
+yy198:
+#line 879 "token.re"
{ char ch = *( YYCURSOR - 1 );
QUOTECAT(qstr, qcapa, qidx, escape_seq( ch ));
goto TransferMethod2;
}
-#line 1867 "<stdout>"
-yy193: yych = *++YYCURSOR;
+#line 1911 "<stdout>"
+yy199: yych = *++YYCURSOR;
switch(yych){
case '0':
case '1':
@@ -2217,13 +2291,13 @@ yy193: yych = *++YYCURSOR;
case 'c':
case 'd':
case 'e':
- case 'f': goto yy194;
- default: goto yy182;
+ case 'f': goto yy200;
+ default: goto yy196;
}
-yy194: ++YYCURSOR;
- goto yy195;
-yy195:
-#line 821 "token.re"
+yy200: ++YYCURSOR;
+ goto yy201;
+yy201:
+#line 884 "token.re"
{ long ch;
char *chr_text = syck_strndup( YYTOKTMP, 4 );
chr_text[0] = '0';
@@ -2232,19 +2306,17 @@ yy195:
QUOTECAT(qstr, qcapa, qidx, ch);
goto TransferMethod2;
}
-#line 1904 "<stdout>"
-yy196: yych = *++YYCURSOR;
- goto yy184;
-yy197: ++YYCURSOR;
+#line 1948 "<stdout>"
+yy202: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
- goto yy198;
-yy198: switch(yych){
- case ' ': goto yy197;
- default: goto yy184;
+ goto yy203;
+yy203: switch(yych){
+ case ' ': goto yy202;
+ default: goto yy188;
}
}
-#line 835 "token.re"
+#line 898 "token.re"
}
@@ -2291,28 +2363,28 @@ ScalarBlock2:
YYTOKEN = YYCURSOR;
-#line 1919 "<stdout>"
+#line 1961 "<stdout>"
{
YYCTYPE yych;
unsigned int yyaccept;
- goto yy199;
-yy200: ++YYCURSOR;
-yy199:
+ goto yy204;
+yy205: ++YYCURSOR;
+yy204:
if((YYLIMIT - YYCURSOR) < 5) YYFILL(5);
yych = *YYCURSOR;
switch(yych){
- case '\000': goto yy207;
- case '\n': goto yy201;
- case '\r': goto yy203;
- case '#': goto yy205;
- case '-': goto yy209;
- default: goto yy210;
- }
-yy201: yyaccept = 0;
+ case '\000': goto yy212;
+ case '\n': goto yy206;
+ case '\r': goto yy208;
+ case '#': goto yy210;
+ case '-': goto yy214;
+ default: goto yy215;
+ }
+yy206: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
- goto yy220;
-yy202:
-#line 882 "token.re"
+ goto yy225;
+yy207:
+#line 945 "token.re"
{ char *pacer;
char *tok = YYTOKEN;
int indt_len = 0, nl_count = 0, fold_nl = 0, nl_begin = 0;
@@ -2382,22 +2454,22 @@ yy202:
}
goto ScalarBlock2;
}
-#line 2010 "<stdout>"
-yy203: ++YYCURSOR;
+#line 2052 "<stdout>"
+yy208: ++YYCURSOR;
switch((yych = *YYCURSOR)) {
- case '\n': goto yy219;
- default: goto yy204;
+ case '\n': goto yy224;
+ default: goto yy209;
}
-yy204:
-#line 991 "token.re"
+yy209:
+#line 1054 "token.re"
{ QUOTECAT(qstr, qcapa, qidx, *YYTOKEN);
goto ScalarBlock2;
}
-#line 2021 "<stdout>"
-yy205: ++YYCURSOR;
- goto yy206;
-yy206:
-#line 953 "token.re"
+#line 2063 "<stdout>"
+yy210: ++YYCURSOR;
+ goto yy211;
+yy211:
+#line 1016 "token.re"
{ lvl = CURRENT_LEVEL();
if ( lvl->status != syck_lvl_block )
{
@@ -2410,45 +2482,45 @@ yy206:
}
goto ScalarBlock2;
}
-#line 2038 "<stdout>"
-yy207: ++YYCURSOR;
- goto yy208;
-yy208:
-#line 967 "token.re"
+#line 2080 "<stdout>"
+yy212: ++YYCURSOR;
+ goto yy213;
+yy213:
+#line 1030 "token.re"
{ YYCURSOR--;
POP_LEVEL();
RETURN_YAML_BLOCK();
}
-#line 2047 "<stdout>"
-yy209: yyaccept = 1;
+#line 2089 "<stdout>"
+yy214: yyaccept = 1;
yych = *(YYMARKER = ++YYCURSOR);
switch(yych){
- case '-': goto yy211;
- default: goto yy204;
+ case '-': goto yy216;
+ default: goto yy209;
}
-yy210: yych = *++YYCURSOR;
- goto yy204;
-yy211: yych = *++YYCURSOR;
+yy215: yych = *++YYCURSOR;
+ goto yy209;
+yy216: yych = *++YYCURSOR;
switch(yych){
- case '-': goto yy213;
- default: goto yy212;
+ case '-': goto yy218;
+ default: goto yy217;
}
-yy212: YYCURSOR = YYMARKER;
+yy217: YYCURSOR = YYMARKER;
switch(yyaccept){
- case 0: goto yy202;
- case 1: goto yy204;
+ case 0: goto yy207;
+ case 1: goto yy209;
}
-yy213: yych = *++YYCURSOR;
+yy218: yych = *++YYCURSOR;
switch(yych){
- case '\n': goto yy214;
- case '\r': goto yy218;
- case ' ': goto yy216;
- default: goto yy212;
- }
-yy214: ++YYCURSOR;
- goto yy215;
-yy215:
-#line 972 "token.re"
+ case '\n': goto yy219;
+ case '\r': goto yy223;
+ case ' ': goto yy221;
+ default: goto yy217;
+ }
+yy219: ++YYCURSOR;
+ goto yy220;
+yy220:
+#line 1035 "token.re"
{ if ( YYTOKEN == YYLINEPTR )
{
if ( blockType == BLOCK_FOLD && qidx > 0 )
@@ -2467,39 +2539,39 @@ yy215:
goto ScalarBlock2;
}
}
-#line 2095 "<stdout>"
-yy216: ++YYCURSOR;
+#line 2137 "<stdout>"
+yy221: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
- goto yy217;
-yy217: switch(yych){
- case ' ': goto yy216;
- default: goto yy215;
+ goto yy222;
+yy222: switch(yych){
+ case ' ': goto yy221;
+ default: goto yy220;
}
-yy218: yych = *++YYCURSOR;
+yy223: yych = *++YYCURSOR;
switch(yych){
- case '\n': goto yy214;
- default: goto yy212;
+ case '\n': goto yy219;
+ default: goto yy217;
}
-yy219: yyaccept = 0;
+yy224: yyaccept = 0;
YYMARKER = ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
- goto yy220;
-yy220: switch(yych){
- case '\n': case ' ': goto yy219;
- case '\r': goto yy221;
- default: goto yy202;
+ goto yy225;
+yy225: switch(yych){
+ case '\n': case ' ': goto yy224;
+ case '\r': goto yy226;
+ default: goto yy207;
}
-yy221: ++YYCURSOR;
+yy226: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
switch(yych){
- case '\n': goto yy219;
- default: goto yy212;
+ case '\n': goto yy224;
+ default: goto yy217;
}
}
-#line 996 "token.re"
+#line 1059 "token.re"
}
@@ -2515,67 +2587,67 @@ Comment:
YYTOKEN = YYCURSOR;
-#line 2131 "<stdout>"
+#line 2173 "<stdout>"
{
YYCTYPE yych;
unsigned int yyaccept;
- goto yy222;
-yy223: ++YYCURSOR;
-yy222:
+ goto yy227;
+yy228: ++YYCURSOR;
+yy227:
if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
yych = *YYCURSOR;
switch(yych){
- case '\000': goto yy224;
- case '\n': goto yy226;
- case '\r': goto yy227;
- default: goto yy229;
+ case '\000': goto yy229;
+ case '\n': goto yy231;
+ case '\r': goto yy232;
+ default: goto yy234;
}
-yy224: ++YYCURSOR;
- goto yy225;
-yy225:
-#line 1012 "token.re"
+yy229: ++YYCURSOR;
+ goto yy230;
+yy230:
+#line 1075 "token.re"
{ YYCURSOR = YYTOKEN;
return;
}
-#line 2153 "<stdout>"
-yy226: yyaccept = 0;
+#line 2195 "<stdout>"
+yy231: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
- goto yy231;
-yy227: ++YYCURSOR;
+ goto yy236;
+yy232: ++YYCURSOR;
switch((yych = *YYCURSOR)) {
- case '\n': goto yy230;
- default: goto yy228;
+ case '\n': goto yy235;
+ default: goto yy233;
}
-yy228:
-#line 1016 "token.re"
+yy233:
+#line 1079 "token.re"
{ goto Comment;
}
-#line 2166 "<stdout>"
-yy229: yych = *++YYCURSOR;
- goto yy228;
-yy230: yyaccept = 0;
+#line 2208 "<stdout>"
+yy234: yych = *++YYCURSOR;
+ goto yy233;
+yy235: yyaccept = 0;
YYMARKER = ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
- goto yy231;
-yy231: switch(yych){
- case '\n': goto yy230;
- case '\r': goto yy232;
- default: goto yy225;
+ goto yy236;
+yy236: switch(yych){
+ case '\n': goto yy235;
+ case '\r': goto yy237;
+ default: goto yy230;
}
-yy232: ++YYCURSOR;
+yy237: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
switch(yych){
- case '\n': goto yy230;
- default: goto yy233;
+ case '\n': goto yy235;
+ default: goto yy238;
}
-yy233: YYCURSOR = YYMARKER;
+yy238: YYCURSOR = YYMARKER;
switch(yyaccept){
- case 0: goto yy225;
+ case 0: goto yy230;
}
}
-#line 1019 "token.re"
+#line 1082 "token.re"
}
diff --git a/ext/syck/yaml2byte.c b/ext/syck/yaml2byte.c
index b2dc450..46173e8 100644
--- a/ext/syck/yaml2byte.c
+++ b/ext/syck/yaml2byte.c
@@ -1,5 +1,5 @@
/*
- * ybext.c
+ * yaml2byte.c
*
* $Author$
* $Date$