Changes between Version 10 and Version 11 of LibYAML
- Timestamp:
- 08/01/06 05:30:13 (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
LibYAML
v10 v11 1 1 = LibYAML = 2 2 3 LibYAML is a YAML 1.1 parser and emitter written in C. It's in an early stage of development. 4 5 You may leave your remarks here at the end of the page or post your comments to 3 '''LibYAML is a YAML 1.1 parser and emitter written in C. It's in an early stage of development.''' 4 5 [[PageOutline]] 6 7 8 == Download and Installation == 9 10 You may check out the latest development code of LibYAML from the Subversion repository 11 http://svn.pyyaml.org/libyaml/trunk: 12 13 {{{ 14 $ svn checkout http://svn.pyyaml.org/libyaml/trunk libyaml-trunk 15 }}} 16 17 If you checked out the LibYAML source code from the Subversion repository, you may 18 build LibYAML with the commands: 19 20 {{{ 21 $ ./bootstrap 22 $ ./configure 23 $ make 24 # make install 25 }}} 26 27 == Development and bug reports == 28 29 You may check out the LibYAML source code from 30 [http://svn.pyyaml.org/libyaml LibYAML SVN repository]. 31 32 If you find a bug in LibYAML, please 33 [http://pyyaml.org/newticket?component=libyaml file a bug report]. 34 You may review open bugs through 35 [http://pyyaml.org/query?action=view&component=libyaml&order=priority the list of open tickets]. 36 37 You may discuss LibYAML at 6 38 [http://lists.sourceforge.net/lists/listinfo/yaml-core the YAML-core mailing list]. 7 39 8 [[PageOutline]]9 10 == Important Note ==11 12 ~~From June 26 to July 7, I'm at [http://www.imar.ro/~ot/ the OT21 conference].~~ Unfortunately, I'm not.13 14 15 == Progress ==16 17 * ~~''Scanner''~~18 * ''Parser''19 * ''Emitter''20 40 21 41 == Scope == … … 36 56 Although some of these processes may be covered in the latter releases, they are not in the scope 37 57 of the initial release of LibYAML. 58 38 59 39 60 == Events == … … 77 98 * `quoted_implicit` - `True` if the node tag may be omitted whenever the scalar value 78 99 is presented in any non-plain style. 79 * `value` - the scalar value; a valid utf-8 sequence; `NULL` means empty. 100 * `value` - the scalar value; a valid utf-8 sequence and may contain `NUL` characters; not `NULL`. 101 * `length` - the length of the scalar value. 80 102 * `SEQUENCE-START` 81 103 * `anchor` - the node anchor; `[0-9a-zA-Z_-]+`; may be `NULL`. … … 102 124 * `tag_directives` - a set of tag handles and the corresponding tag prefixes specified with the `%TAG` directive; 103 125 tag handles should match `!|!!|![0-9a-zA-Z_-]+!` while tag prefixes should be prefixes of valid local 104 or global tags; may be `NULL`.126 or global tags; may be empty. 105 127 * `implicit` - `True` if the document start indicator `---` is not present. 106 128 * `DOCUMENT-END` … … 113 135 * `style` - the mapping style; `block|flow`. 114 136 * ''any event'' 115 * `start_mark` - the position of the event beginning; `offset` (in bytes),`index` (in characters),137 * `start_mark` - the position of the event beginning; attributes: `index` (in characters), 116 138 `line` and `column` (starting from `0`). 117 * `end_mark` - the position of the event end; `offset` (in bytes),`index` (in characters),139 * `end_mark` - the position of the event end; attributes: `index` (in characters), 118 140 `line` and `column` (starting from `0`). 119 141 120 == API == 121 122 Note: the API may change drastically. You may also check the header files: 123 http://pyyaml.org/browser/libyaml/trunk/include/yaml/. 142 143 == Documentation == 144 145 Note: the API may change drastically. You may also check the header file: 146 http://pyyaml.org/browser/libyaml/trunk/include/yaml.h. 124 147 125 148 === Parser API Synopsis === … … 160 183 /* Read the event sequence. */ 161 184 do { 162 int result;163 185 164 186 /* Get the next event. */ 165 result = yaml_parser_parse(&parser, &event); 166 167 if (!result) goto error; 187 if (!yaml_parser_parse(&parser, &event)) 188 goto error; 168 189 169 190 /* … … 181 202 yaml_parser_delete(&parser); 182 203 204 return 1; 205 183 206 /* On error. */ 184 error: /* FIXME */ 185 186 /* Error type: YAML_READER_ERROR, YAML_SCANNER_ERROR, YAML_PARSER_ERROR. */ 187 yaml_error_t error; 188 189 /* What parser was doing when the problem occured (may be NULL). */ 190 char *context; 191 192 /* The starting position of the context (valid only if context != NULL). */ 193 yaml_mark_t context_mark; 194 195 /* The problem description. */ 196 char *problem; 197 198 /* The exact position of the problematic place in the stream. */ 199 yaml_mark_t problem_mark; 200 201 /* Get the error data. */ 202 yaml_parser_get_error(parser, &error, &context, &context_mark, &problem, &problem_mark); 203 204 /* 205 ... 206 Report the problem to the user. 207 ... 208 */ 207 error: 209 208 210 209 /* Destroy the Parser object. */ 211 yaml_parser_delete(parser); 210 yaml_parser_delete(&parser); 211 212 return 0; 212 213 }}} 213 214 … … 219 220 220 221 yaml_emitter_t emitter; 222 yaml_event_t event; 221 223 222 224 /* Create the Emitter object. */ … … 241 243 yaml_emitter_set_output(&emitter, write_handler, ext); 242 244 243 /* Emit the STREAM-START event. */244 int result = yaml_emitter_emit_stream_start(&emitter, YAML_UTF8_ENCODING);245 246 if (!result)goto error;245 /* Create and emit the STREAM-START event. */ 246 yaml_stream_start_event_initialize(&event, YAML_UTF8_ENCODING); 247 if (!yaml_emitter_emit(&emitter, &event)) 248 goto error; 247 249 248 250 /* … … 252 254 */ 253 255 254 /* EMIT the STREAM-END event. */ 255 if (!yaml_emitter_emit_stream_end(&emitter) goto error; 256 /* Create and emit the STREAM-END event. */ 257 yaml_stream_end_event_initialize(&event); 258 if (!yaml_emitter_emit(&emitter, &event)) 259 goto error; 256 260 257 261 /* Destroy the Emitter object. */ 258 262 yaml_emitter_delete(&emitter); 259 263 264 return 1; 265 260 266 /* On error. */ 261 error: /* FIXME */ 262 263 /* Error type: YAML_WRITER_ERROR, YAML_EMITTER_ERROR. */ 264 yaml_error_t error; 265 266 /* The problem description. */ 267 char *problem; 268 269 /* Get the error data. */ 270 yaml_emitter_get_error(emitter, &error, &problem); 271 272 /* 273 ... 274 Report the problem to the user. 275 ... 276 */ 267 error: 277 268 278 269 /* Destroy the Emitter object. */ 279 270 yaml_emitter_delete(emitter); 280 }}} 281 282 == Feedback == 283 284 ''Leave your comments here.'' 271 272 return 0; 273 }}} 274 275 === Examples === 276 277 You may check the examples 278 [http://pyyaml.org/browser/libyaml/trunk/tests/example-reformatter.c example-reformatter] 279 and [http://pyyaml.org/browser/libyaml/trunk/tests/example-deconstructor.c example-deconstructor] 280 in the source distribution. 281 282 283 == Copyright == 284 285 The LibYAML library is written by [mailto:xi@resolvent.net Kirill Simonov]. 286 287 LibYAML is released under the MIT license. 288 289 This project is developed for [http://www.python.org/psf/ Python Software Foundation] 290 as a part of [http://code.google.com/summerofcode.html Google Summer of Code] 291 under the mentorship of [http://clarkevans.com/ Clark Evans].
