mkrf 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/MIT-LICENSE +7 -0
- data/README +54 -0
- data/Rakefile +107 -0
- data/lib/mkrf.rb +4 -0
- data/lib/mkrf/availability.rb +219 -0
- data/lib/mkrf/generator.rb +146 -0
- data/test/abstract_unit.rb +4 -0
- data/test/fixtures/down_a_directory/header_down_a_directory.h +1 -0
- data/test/fixtures/stdmkrf.h +1 -0
- data/test/sample_files/libtrivial/Rakefile +31 -0
- data/test/sample_files/libtrivial/extconf.rb +3 -0
- data/test/sample_files/libtrivial/lib/libtrivial.c +5 -0
- data/test/sample_files/libtrivial/lib/libtrivial.o +0 -0
- data/test/sample_files/libtrivial/libtrivial_so.bundle +0 -0
- data/test/sample_files/libtrivial/mkrf.log +1 -0
- data/test/sample_files/libxml-ruby-0.3.8/CHANGELOG +74 -0
- data/test/sample_files/libxml-ruby-0.3.8/LICENSE +22 -0
- data/test/sample_files/libxml-ruby-0.3.8/README +144 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/cbg.c +76 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/extconf.rb +49 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.c +86 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.h +82 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.rb +107 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/mkrf.log +1 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/old_extconf.rb +95 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attr.c +372 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attr.h +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attribute.c +224 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attribute.h +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_document.c +1159 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_document.h +27 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_dtd.c +168 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_dtd.h +17 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_input_cbg.c +167 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_input_cbg.h +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node.c +2139 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node.h +28 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node_set.c +248 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node_set.h +26 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_ns.c +153 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_ns.h +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser.c +1417 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser.h +31 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser_context.c +715 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser_context.h +22 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_sax_parser.c +426 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_sax_parser.h +52 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_schema.c +142 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_schema.h +16 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_tree.c +43 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_tree.h +12 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xinclude.c +20 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xinclude.h +13 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath.c +363 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath.h +24 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath_context.c +125 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath_context.h +24 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer.c +100 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer.h +27 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer_context.c +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer_context.h +18 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/sax_parser_callbacks.inc +202 -0
- data/test/sample_files/syck-0.55/CHANGELOG +186 -0
- data/test/sample_files/syck-0.55/COPYING +54 -0
- data/test/sample_files/syck-0.55/Makefile +582 -0
- data/test/sample_files/syck-0.55/Makefile.am +5 -0
- data/test/sample_files/syck-0.55/Makefile.in +582 -0
- data/test/sample_files/syck-0.55/README +105 -0
- data/test/sample_files/syck-0.55/README.BYTECODE +484 -0
- data/test/sample_files/syck-0.55/README.EXT +444 -0
- data/test/sample_files/syck-0.55/RELEASE +123 -0
- data/test/sample_files/syck-0.55/TODO +25 -0
- data/test/sample_files/syck-0.55/aclocal.m4 +883 -0
- data/test/sample_files/syck-0.55/bootstrap +7 -0
- data/test/sample_files/syck-0.55/config.h +79 -0
- data/test/sample_files/syck-0.55/config.h.in +78 -0
- data/test/sample_files/syck-0.55/config.status +1197 -0
- data/test/sample_files/syck-0.55/config/README +14 -0
- data/test/sample_files/syck-0.55/config/depcomp +529 -0
- data/test/sample_files/syck-0.55/config/install-sh +323 -0
- data/test/sample_files/syck-0.55/config/missing +357 -0
- data/test/sample_files/syck-0.55/configure +6728 -0
- data/test/sample_files/syck-0.55/configure.in +36 -0
- data/test/sample_files/syck-0.55/ext/ruby/CHANGELOG +303 -0
- data/test/sample_files/syck-0.55/ext/ruby/README +400 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/MANIFEST +1 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/bytecode.c +1170 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/emitter.c +1224 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/extconf.rb +10 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/gram.c +1894 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/gram.h +79 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/handler.c +174 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/implicit.c +2989 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/mkrf.log +1 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/node.c +407 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/rubyext.c +2385 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/syck.c +504 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/syck.h +458 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/token.c +2707 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/yaml2byte.c +250 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/yamlbyte.h +170 -0
- data/test/sample_files/syck-0.55/ext/ruby/install.rb +1022 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/okay.rb +161 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/okay/news.rb +69 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/okay/rpc.rb +434 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml.rb +436 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/baseemitter.rb +247 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/basenode.rb +216 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/compat.rb +26 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/constants.rb +45 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/dbm.rb +111 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/emitter.rb +107 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/encoding.rb +33 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/error.rb +34 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/rubytypes.rb +438 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/store.rb +29 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/stream.rb +40 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/stringio.rb +83 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/syck.rb +19 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/tag.rb +86 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/types.rb +188 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/yamlnode.rb +54 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/ypath.rb +52 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yod.rb +1168 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayNews-modules.rb +27 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayNews-sample.rb +336 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayNews-validate.rb +341 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayRpc-client.rb +51 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayRpc-server.rb +85 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/yaml-sortHashKeys.rb +128 -0
- data/test/sample_files/syck-0.55/ext/ruby/tests/basic.rb +1653 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsAnchorAlias.yml +51 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsBasicTests.yml +282 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsBlockMapping.yml +78 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsBlockSequence.yml +0 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsDocumentSeparator.yml +102 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsErrorTests.yml +23 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsFlowCollections.yml +73 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsFoldedScalars.yml +215 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsMapInSeq.yml +0 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsNullsAndEmpties.yml +66 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsRubyTests.yml +182 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsSpecificationExamples.yml +2699 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsTypeTransfers.yml +265 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsYpath.yml +221 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/cookbook.rb +159 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/index.yml +10 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/yts.rb +193 -0
- data/test/sample_files/syck-0.55/lib/Makefile +497 -0
- data/test/sample_files/syck-0.55/lib/Makefile.am +27 -0
- data/test/sample_files/syck-0.55/lib/Makefile.in +497 -0
- data/test/sample_files/syck-0.55/lib/bytecode.c +1170 -0
- data/test/sample_files/syck-0.55/lib/bytecode.re +525 -0
- data/test/sample_files/syck-0.55/lib/emitter.c +1224 -0
- data/test/sample_files/syck-0.55/lib/gram.c +1894 -0
- data/test/sample_files/syck-0.55/lib/gram.h +79 -0
- data/test/sample_files/syck-0.55/lib/gram.output +2005 -0
- data/test/sample_files/syck-0.55/lib/gram.y +481 -0
- data/test/sample_files/syck-0.55/lib/handler.c +174 -0
- data/test/sample_files/syck-0.55/lib/implicit.c +2989 -0
- data/test/sample_files/syck-0.55/lib/implicit.re +206 -0
- data/test/sample_files/syck-0.55/lib/node.c +407 -0
- data/test/sample_files/syck-0.55/lib/syck.c +504 -0
- data/test/sample_files/syck-0.55/lib/syck.h +458 -0
- data/test/sample_files/syck-0.55/lib/syck_st.c +577 -0
- data/test/sample_files/syck-0.55/lib/syck_st.h +46 -0
- data/test/sample_files/syck-0.55/lib/token.c +2707 -0
- data/test/sample_files/syck-0.55/lib/token.re +1139 -0
- data/test/sample_files/syck-0.55/lib/yaml2byte.c +250 -0
- data/test/sample_files/syck-0.55/lib/yamlbyte.h +170 -0
- data/test/sample_files/syck-0.55/stamp-h1 +1 -0
- data/test/sample_files/syck-0.55/tests/Basic.c +141 -0
- data/test/sample_files/syck-0.55/tests/CuTest.c +294 -0
- data/test/sample_files/syck-0.55/tests/CuTest.h +84 -0
- data/test/sample_files/syck-0.55/tests/Emit.c +87 -0
- data/test/sample_files/syck-0.55/tests/Makefile +480 -0
- data/test/sample_files/syck-0.55/tests/Makefile.am +13 -0
- data/test/sample_files/syck-0.55/tests/Makefile.in +480 -0
- data/test/sample_files/syck-0.55/tests/Parse.c +208 -0
- data/test/sample_files/syck-0.55/tests/YTS.c +2310 -0
- data/test/sample_files/syck-0.55/tests/YTS.c.erb +326 -0
- data/test/sample_files/syck-0.55/tests/YTS.c.rb +44 -0
- data/test/test_availability.rb +68 -0
- data/test/test_generator.rb +74 -0
- metadata +252 -0
@@ -0,0 +1,525 @@
|
|
1
|
+
/*
|
2
|
+
* bytecode.re
|
3
|
+
*
|
4
|
+
* $Author: why $
|
5
|
+
* $Date: 2005/04/13 06:27:54 $
|
6
|
+
*
|
7
|
+
* Copyright (C) 2003 why the lucky stiff
|
8
|
+
*/
|
9
|
+
#include "syck.h"
|
10
|
+
#include "gram.h"
|
11
|
+
|
12
|
+
#define QUOTELEN 128
|
13
|
+
|
14
|
+
/*
|
15
|
+
* They do my bidding...
|
16
|
+
*/
|
17
|
+
#define YYCTYPE char
|
18
|
+
#define YYCURSOR parser->cursor
|
19
|
+
#define YYMARKER parser->marker
|
20
|
+
#define YYLIMIT parser->limit
|
21
|
+
#define YYTOKEN parser->token
|
22
|
+
#define YYTOKTMP parser->toktmp
|
23
|
+
#define YYLINEPTR parser->lineptr
|
24
|
+
#define YYLINECTPTR parser->linectptr
|
25
|
+
#define YYLINE parser->linect
|
26
|
+
#define YYFILL(n) syck_parser_read(parser)
|
27
|
+
|
28
|
+
extern SyckParser *syck_parser_ptr;
|
29
|
+
|
30
|
+
char *get_inline( SyckParser *parser );
|
31
|
+
|
32
|
+
/*
|
33
|
+
* Repositions the cursor at `n' offset from the token start.
|
34
|
+
* Only works in `Header' and `Document' sections.
|
35
|
+
*/
|
36
|
+
#define YYPOS(n) YYCURSOR = YYTOKEN + n
|
37
|
+
|
38
|
+
/*
|
39
|
+
* Track line numbers
|
40
|
+
*/
|
41
|
+
#define CHK_NL(ptr) if ( *( ptr - 1 ) == '\n' && ptr > YYLINECTPTR ) { YYLINEPTR = ptr; YYLINE++; YYLINECTPTR = YYLINEPTR; }
|
42
|
+
|
43
|
+
/*
|
44
|
+
* I like seeing the level operations as macros...
|
45
|
+
*/
|
46
|
+
#define ADD_LEVEL(len, status) syck_parser_add_level( parser, len, status )
|
47
|
+
#define POP_LEVEL() syck_parser_pop_level( parser )
|
48
|
+
#define CURRENT_LEVEL() syck_parser_current_level( parser )
|
49
|
+
|
50
|
+
/*
|
51
|
+
* Force a token next time around sycklex()
|
52
|
+
*/
|
53
|
+
#define FORCE_NEXT_TOKEN(tok) parser->force_token = tok;
|
54
|
+
|
55
|
+
/*
|
56
|
+
* Adding levels in bytecode requires us to make sure
|
57
|
+
* we've got all our tokens worked out.
|
58
|
+
*/
|
59
|
+
#define ADD_BYTE_LEVEL(lvl, len, s ) \
|
60
|
+
switch ( lvl->status ) \
|
61
|
+
{ \
|
62
|
+
case syck_lvl_seq: \
|
63
|
+
lvl->ncount++; \
|
64
|
+
ADD_LEVEL(len, syck_lvl_open); \
|
65
|
+
YYPOS(0); \
|
66
|
+
return '-'; \
|
67
|
+
\
|
68
|
+
case syck_lvl_map: \
|
69
|
+
lvl->ncount++; \
|
70
|
+
ADD_LEVEL(len, s); \
|
71
|
+
break; \
|
72
|
+
\
|
73
|
+
case syck_lvl_open: \
|
74
|
+
lvl->status = s; \
|
75
|
+
break; \
|
76
|
+
\
|
77
|
+
default: \
|
78
|
+
ADD_LEVEL(len, s); \
|
79
|
+
break; \
|
80
|
+
}
|
81
|
+
|
82
|
+
/*
|
83
|
+
* Nice little macro to ensure we're YAML_IOPENed to the current level.
|
84
|
+
* * Only use this macro in the "Document" section *
|
85
|
+
*/
|
86
|
+
#define ENSURE_YAML_IOPEN(last_lvl, lvl_type, to_len, reset) \
|
87
|
+
if ( last_lvl->spaces < to_len ) \
|
88
|
+
{ \
|
89
|
+
if ( last_lvl->status == syck_lvl_iseq || last_lvl->status == syck_lvl_imap ) \
|
90
|
+
{ \
|
91
|
+
goto Document; \
|
92
|
+
} \
|
93
|
+
else \
|
94
|
+
{ \
|
95
|
+
ADD_LEVEL( to_len, lvl_type ); \
|
96
|
+
if ( reset == 1 ) YYPOS(0); \
|
97
|
+
return YAML_IOPEN; \
|
98
|
+
} \
|
99
|
+
}
|
100
|
+
|
101
|
+
/*
|
102
|
+
* Nice little macro to ensure closure of levels.
|
103
|
+
* * Only use this macro in the "Document" section *
|
104
|
+
*/
|
105
|
+
#define ENSURE_YAML_IEND(last_lvl, to_len) \
|
106
|
+
if ( last_lvl->spaces > to_len ) \
|
107
|
+
{ \
|
108
|
+
syck_parser_pop_level( parser ); \
|
109
|
+
YYPOS(0); \
|
110
|
+
return YAML_IEND; \
|
111
|
+
}
|
112
|
+
|
113
|
+
/*
|
114
|
+
* Concatenates string items and manages allocation
|
115
|
+
* to the string
|
116
|
+
*/
|
117
|
+
#define CAT(s, c, i, l) \
|
118
|
+
{ \
|
119
|
+
if ( i + 1 >= c ) \
|
120
|
+
{ \
|
121
|
+
c += QUOTELEN; \
|
122
|
+
S_REALLOC_N( s, char, c ); \
|
123
|
+
} \
|
124
|
+
s[i++] = l; \
|
125
|
+
s[i] = '\0'; \
|
126
|
+
}
|
127
|
+
|
128
|
+
/*
|
129
|
+
* Parser for standard YAML Bytecode [UTF-8]
|
130
|
+
*/
|
131
|
+
int
|
132
|
+
sycklex_bytecode_utf8( YYSTYPE *sycklval, SyckParser *parser )
|
133
|
+
{
|
134
|
+
SyckLevel *lvl;
|
135
|
+
int doc_level = 0;
|
136
|
+
syck_parser_ptr = parser;
|
137
|
+
if ( YYCURSOR == NULL )
|
138
|
+
{
|
139
|
+
syck_parser_read( parser );
|
140
|
+
}
|
141
|
+
|
142
|
+
if ( parser->force_token != 0 )
|
143
|
+
{
|
144
|
+
int t = parser->force_token;
|
145
|
+
parser->force_token = 0;
|
146
|
+
return t;
|
147
|
+
}
|
148
|
+
|
149
|
+
/*!re2c
|
150
|
+
|
151
|
+
LF = ( "\n" | "\r\n" ) ;
|
152
|
+
NULL = [\000] ;
|
153
|
+
ANY = [\001-\377] ;
|
154
|
+
YWORDC = [A-Za-z0-9_-] ;
|
155
|
+
YWORDP = [A-Za-z0-9_-\.] ;
|
156
|
+
|
157
|
+
DOC = "D" LF ;
|
158
|
+
DIR = "V" YWORDP+ ":" YWORDP+ LF ;
|
159
|
+
PAU = "P" LF ;
|
160
|
+
MAP = "M" LF ;
|
161
|
+
SEQ = "Q" LF ;
|
162
|
+
END = "E" LF ;
|
163
|
+
SCA = "S" ;
|
164
|
+
SCC = "C" ;
|
165
|
+
NNL = "N" [0-9]*;
|
166
|
+
NLZ = "Z" ;
|
167
|
+
ANC = "A" ;
|
168
|
+
REF = "R" ;
|
169
|
+
TAG = "T" ;
|
170
|
+
|
171
|
+
COM = "c" ;
|
172
|
+
|
173
|
+
*/
|
174
|
+
|
175
|
+
lvl = CURRENT_LEVEL();
|
176
|
+
if ( lvl->status == syck_lvl_doc )
|
177
|
+
{
|
178
|
+
goto Document;
|
179
|
+
}
|
180
|
+
|
181
|
+
Header:
|
182
|
+
|
183
|
+
YYTOKEN = YYCURSOR;
|
184
|
+
|
185
|
+
/*!re2c
|
186
|
+
|
187
|
+
DOC { if ( lvl->status == syck_lvl_header )
|
188
|
+
{
|
189
|
+
CHK_NL(YYCURSOR);
|
190
|
+
goto Directive;
|
191
|
+
}
|
192
|
+
else
|
193
|
+
{
|
194
|
+
ENSURE_YAML_IEND(lvl, -1);
|
195
|
+
YYPOS(0);
|
196
|
+
return 0;
|
197
|
+
}
|
198
|
+
}
|
199
|
+
|
200
|
+
ANY { YYPOS(0);
|
201
|
+
goto Document;
|
202
|
+
}
|
203
|
+
|
204
|
+
*/
|
205
|
+
|
206
|
+
Document:
|
207
|
+
{
|
208
|
+
lvl = CURRENT_LEVEL();
|
209
|
+
if ( lvl->status == syck_lvl_header )
|
210
|
+
{
|
211
|
+
lvl->status = syck_lvl_doc;
|
212
|
+
}
|
213
|
+
|
214
|
+
YYTOKEN = YYCURSOR;
|
215
|
+
|
216
|
+
/*!re2c
|
217
|
+
|
218
|
+
DOC | PAU { ENSURE_YAML_IEND(lvl, -1);
|
219
|
+
YYPOS(0);
|
220
|
+
return 0;
|
221
|
+
}
|
222
|
+
|
223
|
+
MAP { int complex = 0;
|
224
|
+
if ( lvl->ncount % 2 == 0 && ( lvl->status == syck_lvl_map || lvl->status == syck_lvl_seq ) )
|
225
|
+
{
|
226
|
+
complex = 1;
|
227
|
+
}
|
228
|
+
ADD_BYTE_LEVEL(lvl, lvl->spaces + 1, syck_lvl_map);
|
229
|
+
CHK_NL(YYCURSOR);
|
230
|
+
if ( complex )
|
231
|
+
{
|
232
|
+
FORCE_NEXT_TOKEN( YAML_IOPEN );
|
233
|
+
return '?';
|
234
|
+
}
|
235
|
+
return YAML_IOPEN;
|
236
|
+
}
|
237
|
+
|
238
|
+
SEQ { int complex = 0;
|
239
|
+
if ( lvl->ncount % 2 == 0 && ( lvl->status == syck_lvl_map || lvl->status == syck_lvl_seq ) )
|
240
|
+
{
|
241
|
+
complex = 1;
|
242
|
+
}
|
243
|
+
ADD_BYTE_LEVEL(lvl, lvl->spaces + 1, syck_lvl_seq);
|
244
|
+
CHK_NL(YYCURSOR);
|
245
|
+
if ( complex )
|
246
|
+
{
|
247
|
+
FORCE_NEXT_TOKEN( YAML_IOPEN );
|
248
|
+
return '?';
|
249
|
+
}
|
250
|
+
return YAML_IOPEN;
|
251
|
+
}
|
252
|
+
|
253
|
+
END { if ( lvl->status == syck_lvl_seq && lvl->ncount == 0 )
|
254
|
+
{
|
255
|
+
lvl->ncount++;
|
256
|
+
YYPOS(0);
|
257
|
+
FORCE_NEXT_TOKEN( ']' );
|
258
|
+
return '[';
|
259
|
+
}
|
260
|
+
else if ( lvl->status == syck_lvl_map && lvl->ncount == 0 )
|
261
|
+
{
|
262
|
+
lvl->ncount++;
|
263
|
+
YYPOS(0);
|
264
|
+
FORCE_NEXT_TOKEN( '}' );
|
265
|
+
return '{';
|
266
|
+
}
|
267
|
+
|
268
|
+
POP_LEVEL();
|
269
|
+
lvl = CURRENT_LEVEL();
|
270
|
+
if ( lvl->status == syck_lvl_seq )
|
271
|
+
{
|
272
|
+
FORCE_NEXT_TOKEN(YAML_INDENT);
|
273
|
+
}
|
274
|
+
else if ( lvl->status == syck_lvl_map )
|
275
|
+
{
|
276
|
+
if ( lvl->ncount % 2 == 1 )
|
277
|
+
{
|
278
|
+
FORCE_NEXT_TOKEN(':');
|
279
|
+
}
|
280
|
+
else
|
281
|
+
{
|
282
|
+
FORCE_NEXT_TOKEN(YAML_INDENT);
|
283
|
+
}
|
284
|
+
}
|
285
|
+
CHK_NL(YYCURSOR);
|
286
|
+
return YAML_IEND;
|
287
|
+
}
|
288
|
+
|
289
|
+
SCA { ADD_BYTE_LEVEL(lvl, lvl->spaces + 1, syck_lvl_str);
|
290
|
+
goto Scalar;
|
291
|
+
}
|
292
|
+
|
293
|
+
ANC { ADD_BYTE_LEVEL(lvl, lvl->spaces + 1, syck_lvl_open);
|
294
|
+
sycklval->name = get_inline( parser );
|
295
|
+
syck_hdlr_remove_anchor( parser, sycklval->name );
|
296
|
+
CHK_NL(YYCURSOR);
|
297
|
+
return YAML_ANCHOR;
|
298
|
+
}
|
299
|
+
|
300
|
+
REF { ADD_BYTE_LEVEL(lvl, lvl->spaces + 1, syck_lvl_str);
|
301
|
+
sycklval->name = get_inline( parser );
|
302
|
+
POP_LEVEL();
|
303
|
+
if ( *( YYCURSOR - 1 ) == '\n' ) YYCURSOR--;
|
304
|
+
return YAML_ALIAS;
|
305
|
+
}
|
306
|
+
|
307
|
+
TAG { char *qstr;
|
308
|
+
ADD_BYTE_LEVEL(lvl, lvl->spaces + 1, syck_lvl_open);
|
309
|
+
qstr = get_inline( parser );
|
310
|
+
CHK_NL(YYCURSOR);
|
311
|
+
if ( qstr[0] == '!' )
|
312
|
+
{
|
313
|
+
int qidx = strlen( qstr );
|
314
|
+
if ( qstr[1] == '\0' )
|
315
|
+
{
|
316
|
+
free( qstr );
|
317
|
+
return YAML_ITRANSFER;
|
318
|
+
}
|
319
|
+
|
320
|
+
lvl = CURRENT_LEVEL();
|
321
|
+
|
322
|
+
/*
|
323
|
+
* URL Prefixing
|
324
|
+
*/
|
325
|
+
if ( qstr[1] == '^' )
|
326
|
+
{
|
327
|
+
sycklval->name = S_ALLOC_N( char, qidx + strlen( lvl->domain ) );
|
328
|
+
sycklval->name[0] = '\0';
|
329
|
+
strcat( sycklval->name, lvl->domain );
|
330
|
+
strncat( sycklval->name, qstr + 2, qidx - 2 );
|
331
|
+
free( qstr );
|
332
|
+
}
|
333
|
+
else
|
334
|
+
{
|
335
|
+
char *carat = qstr + 1;
|
336
|
+
char *qend = qstr + qidx;
|
337
|
+
while ( (++carat) < qend )
|
338
|
+
{
|
339
|
+
if ( *carat == '^' )
|
340
|
+
break;
|
341
|
+
}
|
342
|
+
|
343
|
+
if ( carat < qend )
|
344
|
+
{
|
345
|
+
free( lvl->domain );
|
346
|
+
lvl->domain = syck_strndup( qstr + 1, carat - ( qstr + 1 ) );
|
347
|
+
sycklval->name = S_ALLOC_N( char, ( qend - carat ) + strlen( lvl->domain ) );
|
348
|
+
sycklval->name[0] = '\0';
|
349
|
+
strcat( sycklval->name, lvl->domain );
|
350
|
+
strncat( sycklval->name, carat + 1, ( qend - carat ) - 1 );
|
351
|
+
free( qstr );
|
352
|
+
}
|
353
|
+
else
|
354
|
+
{
|
355
|
+
sycklval->name = S_ALLOC_N( char, strlen( qstr ) );
|
356
|
+
sycklval->name[0] = '\0';
|
357
|
+
S_MEMCPY( sycklval->name, qstr + 1, char, strlen( qstr ) );
|
358
|
+
free( qstr );
|
359
|
+
}
|
360
|
+
}
|
361
|
+
return YAML_TRANSFER;
|
362
|
+
}
|
363
|
+
sycklval->name = qstr;
|
364
|
+
return YAML_TAGURI;
|
365
|
+
}
|
366
|
+
|
367
|
+
COM { goto Comment; }
|
368
|
+
|
369
|
+
LF { CHK_NL(YYCURSOR);
|
370
|
+
if ( lvl->status == syck_lvl_seq )
|
371
|
+
{
|
372
|
+
return YAML_INDENT;
|
373
|
+
}
|
374
|
+
else if ( lvl->status == syck_lvl_map )
|
375
|
+
{
|
376
|
+
if ( lvl->ncount % 2 == 1 ) return ':';
|
377
|
+
else return YAML_INDENT;
|
378
|
+
}
|
379
|
+
goto Document;
|
380
|
+
}
|
381
|
+
|
382
|
+
NULL { ENSURE_YAML_IEND(lvl, -1);
|
383
|
+
YYPOS(0);
|
384
|
+
return 0;
|
385
|
+
}
|
386
|
+
|
387
|
+
*/
|
388
|
+
|
389
|
+
}
|
390
|
+
|
391
|
+
Directive:
|
392
|
+
{
|
393
|
+
YYTOKEN = YYCURSOR;
|
394
|
+
|
395
|
+
/*!re2c
|
396
|
+
|
397
|
+
DIR { CHK_NL(YYCURSOR);
|
398
|
+
goto Directive; }
|
399
|
+
|
400
|
+
ANY { YYCURSOR = YYTOKEN;
|
401
|
+
return YAML_DOCSEP;
|
402
|
+
}
|
403
|
+
*/
|
404
|
+
|
405
|
+
}
|
406
|
+
|
407
|
+
Comment:
|
408
|
+
{
|
409
|
+
YYTOKEN = YYCURSOR;
|
410
|
+
|
411
|
+
/*!re2c
|
412
|
+
|
413
|
+
LF { CHK_NL(YYCURSOR);
|
414
|
+
goto Document; }
|
415
|
+
|
416
|
+
ANY { goto Comment; }
|
417
|
+
|
418
|
+
*/
|
419
|
+
|
420
|
+
}
|
421
|
+
|
422
|
+
Scalar:
|
423
|
+
{
|
424
|
+
int idx = 0;
|
425
|
+
int cap = 100;
|
426
|
+
char *str = S_ALLOC_N( char, cap );
|
427
|
+
char *tok;
|
428
|
+
|
429
|
+
str[0] = '\0';
|
430
|
+
|
431
|
+
Scalar2:
|
432
|
+
tok = YYCURSOR;
|
433
|
+
|
434
|
+
/*!re2c
|
435
|
+
|
436
|
+
LF SCC { CHK_NL(tok+1);
|
437
|
+
goto Scalar2; }
|
438
|
+
|
439
|
+
LF NNL { CHK_NL(tok+1);
|
440
|
+
if ( tok + 2 < YYCURSOR )
|
441
|
+
{
|
442
|
+
char *count = tok + 2;
|
443
|
+
int total = strtod( count, NULL );
|
444
|
+
int i;
|
445
|
+
for ( i = 0; i < total; i++ )
|
446
|
+
{
|
447
|
+
CAT(str, cap, idx, '\n');
|
448
|
+
}
|
449
|
+
}
|
450
|
+
else
|
451
|
+
{
|
452
|
+
CAT(str, cap, idx, '\n');
|
453
|
+
}
|
454
|
+
goto Scalar2;
|
455
|
+
}
|
456
|
+
|
457
|
+
LF NLZ { CHK_NL(tok+1);
|
458
|
+
CAT(str, cap, idx, '\0');
|
459
|
+
goto Scalar2;
|
460
|
+
}
|
461
|
+
|
462
|
+
LF { YYCURSOR = tok;
|
463
|
+
goto ScalarEnd;
|
464
|
+
}
|
465
|
+
|
466
|
+
NULL { YYCURSOR = tok;
|
467
|
+
goto ScalarEnd;
|
468
|
+
}
|
469
|
+
|
470
|
+
ANY { CAT(str, cap, idx, tok[0]);
|
471
|
+
goto Scalar2;
|
472
|
+
}
|
473
|
+
|
474
|
+
*/
|
475
|
+
|
476
|
+
ScalarEnd:
|
477
|
+
{
|
478
|
+
SyckNode *n = syck_alloc_str();
|
479
|
+
n->data.str->ptr = str;
|
480
|
+
n->data.str->len = idx;
|
481
|
+
sycklval->nodeData = n;
|
482
|
+
POP_LEVEL();
|
483
|
+
if ( parser->implicit_typing == 1 )
|
484
|
+
{
|
485
|
+
try_tag_implicit( sycklval->nodeData, parser->taguri_expansion );
|
486
|
+
}
|
487
|
+
return YAML_PLAIN;
|
488
|
+
}
|
489
|
+
}
|
490
|
+
|
491
|
+
}
|
492
|
+
|
493
|
+
char *
|
494
|
+
get_inline( SyckParser *parser )
|
495
|
+
{
|
496
|
+
int idx = 0;
|
497
|
+
int cap = 100;
|
498
|
+
char *str = S_ALLOC_N( char, cap );
|
499
|
+
char *tok;
|
500
|
+
|
501
|
+
str[0] = '\0';
|
502
|
+
|
503
|
+
Inline:
|
504
|
+
{
|
505
|
+
tok = YYCURSOR;
|
506
|
+
|
507
|
+
/*!re2c
|
508
|
+
|
509
|
+
LF { CHK_NL(YYCURSOR);
|
510
|
+
return str; }
|
511
|
+
|
512
|
+
NULL { YYCURSOR = tok;
|
513
|
+
return str;
|
514
|
+
}
|
515
|
+
|
516
|
+
ANY { CAT(str, cap, idx, tok[0]);
|
517
|
+
goto Inline;
|
518
|
+
}
|
519
|
+
|
520
|
+
*/
|
521
|
+
|
522
|
+
}
|
523
|
+
|
524
|
+
}
|
525
|
+
|