rubysl-syck 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +25 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/ext/rubysl/syck/bytecode.c +1166 -0
- data/ext/rubysl/syck/emitter.c +1242 -0
- data/ext/rubysl/syck/extconf.rb +5 -0
- data/ext/rubysl/syck/gram.c +1894 -0
- data/ext/rubysl/syck/gram.h +79 -0
- data/ext/rubysl/syck/handler.c +174 -0
- data/ext/rubysl/syck/implicit.c +2990 -0
- data/ext/rubysl/syck/node.c +408 -0
- data/ext/rubysl/syck/rubyext.c +2366 -0
- data/ext/rubysl/syck/st.c +576 -0
- data/ext/rubysl/syck/st.h +72 -0
- data/ext/rubysl/syck/syck.c +504 -0
- data/ext/rubysl/syck/syck.h +458 -0
- data/ext/rubysl/syck/token.c +2725 -0
- data/ext/rubysl/syck/yaml2byte.c +257 -0
- data/ext/rubysl/syck/yamlbyte.h +170 -0
- data/lib/rubysl/syck/version.rb +5 -0
- data/lib/rubysl/syck.rb +7 -0
- data/rubysl-syck.gemspec +22 -0
- metadata +97 -0
@@ -0,0 +1,79 @@
|
|
1
|
+
/* A Bison parser, made by GNU Bison 1.875d. */
|
2
|
+
|
3
|
+
/* Skeleton parser for Yacc-like parsing with Bison,
|
4
|
+
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
5
|
+
|
6
|
+
This program is free software; you can redistribute it and/or modify
|
7
|
+
it under the terms of the GNU General Public License as published by
|
8
|
+
the Free Software Foundation; either version 2, or (at your option)
|
9
|
+
any later version.
|
10
|
+
|
11
|
+
This program is distributed in the hope that it will be useful,
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
GNU General Public License for more details.
|
15
|
+
|
16
|
+
You should have received a copy of the GNU General Public License
|
17
|
+
along with this program; if not, write to the Free Software
|
18
|
+
Foundation, Inc., 59 Temple Place - Suite 330,
|
19
|
+
Boston, MA 02111-1307, USA. */
|
20
|
+
|
21
|
+
/* As a special exception, when this file is copied by Bison into a
|
22
|
+
Bison output file, you may use that output file without restriction.
|
23
|
+
This special exception was added by the Free Software Foundation
|
24
|
+
in version 1.24 of Bison. */
|
25
|
+
|
26
|
+
/* Tokens. */
|
27
|
+
#ifndef YYTOKENTYPE
|
28
|
+
# define YYTOKENTYPE
|
29
|
+
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
30
|
+
know about them. */
|
31
|
+
enum yytokentype {
|
32
|
+
YAML_ANCHOR = 258,
|
33
|
+
YAML_ALIAS = 259,
|
34
|
+
YAML_TRANSFER = 260,
|
35
|
+
YAML_TAGURI = 261,
|
36
|
+
YAML_ITRANSFER = 262,
|
37
|
+
YAML_WORD = 263,
|
38
|
+
YAML_PLAIN = 264,
|
39
|
+
YAML_BLOCK = 265,
|
40
|
+
YAML_DOCSEP = 266,
|
41
|
+
YAML_IOPEN = 267,
|
42
|
+
YAML_INDENT = 268,
|
43
|
+
YAML_IEND = 269
|
44
|
+
};
|
45
|
+
#endif
|
46
|
+
#define YAML_ANCHOR 258
|
47
|
+
#define YAML_ALIAS 259
|
48
|
+
#define YAML_TRANSFER 260
|
49
|
+
#define YAML_TAGURI 261
|
50
|
+
#define YAML_ITRANSFER 262
|
51
|
+
#define YAML_WORD 263
|
52
|
+
#define YAML_PLAIN 264
|
53
|
+
#define YAML_BLOCK 265
|
54
|
+
#define YAML_DOCSEP 266
|
55
|
+
#define YAML_IOPEN 267
|
56
|
+
#define YAML_INDENT 268
|
57
|
+
#define YAML_IEND 269
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
|
63
|
+
#line 35 "gram.y"
|
64
|
+
typedef union YYSTYPE {
|
65
|
+
SYMID nodeId;
|
66
|
+
SyckNode *nodeData;
|
67
|
+
char *name;
|
68
|
+
} YYSTYPE;
|
69
|
+
/* Line 1285 of yacc.c. */
|
70
|
+
#line 71 "gram.h"
|
71
|
+
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
72
|
+
# define YYSTYPE_IS_DECLARED 1
|
73
|
+
# define YYSTYPE_IS_TRIVIAL 1
|
74
|
+
#endif
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
@@ -0,0 +1,174 @@
|
|
1
|
+
/*
|
2
|
+
* handler.c
|
3
|
+
*
|
4
|
+
* $Author: shyouhei $
|
5
|
+
* $Date: 2007-02-12 15:01:19 -0800 (Mon, 12 Feb 2007) $
|
6
|
+
*
|
7
|
+
* Copyright (C) 2003 why the lucky stiff
|
8
|
+
*/
|
9
|
+
|
10
|
+
#include "ruby.h"
|
11
|
+
#include "syck.h"
|
12
|
+
|
13
|
+
SYMID
|
14
|
+
syck_hdlr_add_node( SyckParser *p, SyckNode *n )
|
15
|
+
{
|
16
|
+
SYMID id;
|
17
|
+
|
18
|
+
if ( ! n->id )
|
19
|
+
{
|
20
|
+
n->id = (p->handler)( p, n );
|
21
|
+
}
|
22
|
+
id = n->id;
|
23
|
+
|
24
|
+
if ( n->anchor == NULL )
|
25
|
+
{
|
26
|
+
syck_free_node( n );
|
27
|
+
}
|
28
|
+
return id;
|
29
|
+
}
|
30
|
+
|
31
|
+
SyckNode *
|
32
|
+
syck_hdlr_add_anchor( SyckParser *p, char *a, SyckNode *n )
|
33
|
+
{
|
34
|
+
SyckNode *ntmp = NULL;
|
35
|
+
|
36
|
+
n->anchor = a;
|
37
|
+
if ( p->bad_anchors != NULL )
|
38
|
+
{
|
39
|
+
SyckNode *bad;
|
40
|
+
if ( st_lookup( p->bad_anchors, (st_data_t)a, (st_data_t *)&bad ) )
|
41
|
+
{
|
42
|
+
if ( n->kind != syck_str_kind )
|
43
|
+
{
|
44
|
+
n->id = bad->id;
|
45
|
+
(p->handler)( p, n );
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|
49
|
+
if ( p->anchors == NULL )
|
50
|
+
{
|
51
|
+
p->anchors = st_init_strtable();
|
52
|
+
}
|
53
|
+
if ( st_lookup( p->anchors, (st_data_t)a, (st_data_t *)&ntmp ) )
|
54
|
+
{
|
55
|
+
if ( ntmp != (void *)1 )
|
56
|
+
{
|
57
|
+
syck_free_node( ntmp );
|
58
|
+
}
|
59
|
+
}
|
60
|
+
st_insert( p->anchors, (st_data_t)a, (st_data_t)n );
|
61
|
+
return n;
|
62
|
+
}
|
63
|
+
|
64
|
+
void
|
65
|
+
syck_hdlr_remove_anchor( SyckParser *p, char *a )
|
66
|
+
{
|
67
|
+
char *atmp = a;
|
68
|
+
SyckNode *ntmp;
|
69
|
+
if ( p->anchors == NULL )
|
70
|
+
{
|
71
|
+
p->anchors = st_init_strtable();
|
72
|
+
}
|
73
|
+
if ( st_delete( p->anchors, (st_data_t *)&atmp, (st_data_t *)&ntmp ) )
|
74
|
+
{
|
75
|
+
if ( ntmp != (void *)1 )
|
76
|
+
{
|
77
|
+
syck_free_node( ntmp );
|
78
|
+
}
|
79
|
+
}
|
80
|
+
st_insert( p->anchors, (st_data_t)a, (st_data_t)1 );
|
81
|
+
}
|
82
|
+
|
83
|
+
SyckNode *
|
84
|
+
syck_hdlr_get_anchor( SyckParser *p, char *a )
|
85
|
+
{
|
86
|
+
SyckNode *n = NULL;
|
87
|
+
|
88
|
+
if ( p->anchors != NULL )
|
89
|
+
{
|
90
|
+
if ( st_lookup( p->anchors, (st_data_t)a, (st_data_t *)&n ) )
|
91
|
+
{
|
92
|
+
if ( n != (void *)1 )
|
93
|
+
{
|
94
|
+
S_FREE( a );
|
95
|
+
return n;
|
96
|
+
}
|
97
|
+
else
|
98
|
+
{
|
99
|
+
if ( p->bad_anchors == NULL )
|
100
|
+
{
|
101
|
+
p->bad_anchors = st_init_strtable();
|
102
|
+
}
|
103
|
+
if ( ! st_lookup( p->bad_anchors, (st_data_t)a, (st_data_t *)&n ) )
|
104
|
+
{
|
105
|
+
n = (p->bad_anchor_handler)( p, a );
|
106
|
+
st_insert( p->bad_anchors, (st_data_t)a, (st_data_t)n );
|
107
|
+
}
|
108
|
+
}
|
109
|
+
}
|
110
|
+
}
|
111
|
+
|
112
|
+
if ( n == NULL )
|
113
|
+
{
|
114
|
+
n = (p->bad_anchor_handler)( p, a );
|
115
|
+
}
|
116
|
+
|
117
|
+
if ( n->anchor )
|
118
|
+
{
|
119
|
+
S_FREE( a );
|
120
|
+
}
|
121
|
+
else
|
122
|
+
{
|
123
|
+
n->anchor = a;
|
124
|
+
}
|
125
|
+
|
126
|
+
return n;
|
127
|
+
}
|
128
|
+
|
129
|
+
void
|
130
|
+
syck_add_transfer( char *uri, SyckNode *n, int taguri )
|
131
|
+
{
|
132
|
+
if ( n->type_id != NULL )
|
133
|
+
{
|
134
|
+
S_FREE( n->type_id );
|
135
|
+
}
|
136
|
+
|
137
|
+
if ( taguri == 0 )
|
138
|
+
{
|
139
|
+
n->type_id = uri;
|
140
|
+
return;
|
141
|
+
}
|
142
|
+
|
143
|
+
n->type_id = syck_type_id_to_uri( uri );
|
144
|
+
S_FREE( uri );
|
145
|
+
}
|
146
|
+
|
147
|
+
char *
|
148
|
+
syck_xprivate( char *type_id, int type_len )
|
149
|
+
{
|
150
|
+
char *uri = S_ALLOC_N( char, type_len + 14 );
|
151
|
+
uri[0] = '\0';
|
152
|
+
strcat( uri, "x-private:" );
|
153
|
+
strncat( uri, type_id, type_len );
|
154
|
+
return uri;
|
155
|
+
}
|
156
|
+
|
157
|
+
char *
|
158
|
+
syck_taguri( char *domain, char *type_id, int type_len )
|
159
|
+
{
|
160
|
+
char *uri = S_ALLOC_N( char, strlen( domain ) + type_len + 14 );
|
161
|
+
uri[0] = '\0';
|
162
|
+
strcat( uri, "tag:" );
|
163
|
+
strcat( uri, domain );
|
164
|
+
strcat( uri, ":" );
|
165
|
+
strncat( uri, type_id, type_len );
|
166
|
+
return uri;
|
167
|
+
}
|
168
|
+
|
169
|
+
int
|
170
|
+
syck_try_implicit( SyckNode *n )
|
171
|
+
{
|
172
|
+
return 1;
|
173
|
+
}
|
174
|
+
|