Changes between Version 10 and Version 11 of LibYAML


Ignore:
Timestamp:
08/01/06 05:30:13 (8 years ago)
Author:
xi
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • LibYAML

    v10 v11  
    11= LibYAML = 
    22 
    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 
     10You may check out the latest development code of LibYAML from the Subversion repository 
     11http://svn.pyyaml.org/libyaml/trunk: 
     12 
     13{{{ 
     14$ svn checkout http://svn.pyyaml.org/libyaml/trunk libyaml-trunk 
     15}}} 
     16 
     17If you checked out the LibYAML source code from the Subversion repository, you may 
     18build LibYAML with the commands: 
     19 
     20{{{ 
     21$ ./bootstrap 
     22$ ./configure 
     23$ make 
     24# make install 
     25}}} 
     26 
     27== Development and bug reports == 
     28 
     29You may check out the LibYAML source code from 
     30[http://svn.pyyaml.org/libyaml LibYAML SVN repository]. 
     31 
     32If you find a bug in LibYAML, please 
     33[http://pyyaml.org/newticket?component=libyaml file a bug report]. 
     34You may review open bugs through 
     35[http://pyyaml.org/query?action=view&component=libyaml&order=priority the list of open tickets]. 
     36 
     37You may discuss LibYAML at 
    638[http://lists.sourceforge.net/lists/listinfo/yaml-core the YAML-core mailing list]. 
    739 
    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'' 
    2040 
    2141== Scope == 
     
    3656Although some of these processes may be covered in the latter releases, they are not in the scope 
    3757of the initial release of LibYAML. 
     58 
    3859 
    3960== Events == 
     
    7798   * `quoted_implicit` - `True` if the node tag may be omitted whenever the scalar value 
    7899     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. 
    80102 * `SEQUENCE-START` 
    81103   * `anchor` - the node anchor; `[0-9a-zA-Z_-]+`; may be `NULL`. 
     
    102124   * `tag_directives` - a set of tag handles and the corresponding tag prefixes specified with the `%TAG` directive; 
    103125     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. 
    105127   * `implicit` - `True` if the document start indicator `---` is not present. 
    106128 * `DOCUMENT-END` 
     
    113135   * `style` - the mapping style; `block|flow`. 
    114136 * ''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), 
    116138     `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), 
    118140     `line` and `column` (starting from `0`). 
    119141 
    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 
     145Note: the API may change drastically. You may also check the header file: 
     146http://pyyaml.org/browser/libyaml/trunk/include/yaml.h. 
    124147 
    125148=== Parser API Synopsis === 
     
    160183/* Read the event sequence. */ 
    161184do { 
    162     int result; 
    163185 
    164186    /* 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; 
    168189 
    169190    /* 
     
    181202yaml_parser_delete(&parser); 
    182203 
     204return 1; 
     205 
    183206/* 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 */ 
     207error: 
    209208 
    210209/* Destroy the Parser object. */ 
    211 yaml_parser_delete(parser); 
     210yaml_parser_delete(&parser); 
     211 
     212return 0; 
    212213}}} 
    213214 
     
    219220 
    220221yaml_emitter_t emitter; 
     222yaml_event_t event; 
    221223 
    222224/* Create the Emitter object. */ 
     
    241243yaml_emitter_set_output(&emitter, write_handler, ext); 
    242244 
    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. */ 
     246yaml_stream_start_event_initialize(&event, YAML_UTF8_ENCODING); 
     247if (!yaml_emitter_emit(&emitter, &event)) 
     248    goto error; 
    247249 
    248250/* 
     
    252254*/ 
    253255 
    254 /* EMIT the STREAM-END event. */ 
    255 if (!yaml_emitter_emit_stream_end(&emitter) goto error; 
     256/* Create and emit the STREAM-END event. */ 
     257yaml_stream_end_event_initialize(&event); 
     258if (!yaml_emitter_emit(&emitter, &event)) 
     259    goto error; 
    256260 
    257261/* Destroy the Emitter object. */ 
    258262yaml_emitter_delete(&emitter); 
    259263 
     264return 1; 
     265 
    260266/* 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 */ 
     267error: 
    277268 
    278269/* Destroy the Emitter object. */ 
    279270yaml_emitter_delete(emitter); 
    280 }}} 
    281  
    282 == Feedback == 
    283  
    284 ''Leave your comments here.'' 
     271 
     272return 0; 
     273}}} 
     274 
     275=== Examples === 
     276 
     277You may check the examples  
     278[http://pyyaml.org/browser/libyaml/trunk/tests/example-reformatter.c example-reformatter] 
     279and [http://pyyaml.org/browser/libyaml/trunk/tests/example-deconstructor.c example-deconstructor] 
     280in the source distribution. 
     281 
     282 
     283== Copyright == 
     284 
     285The LibYAML library is written by [mailto:xi@resolvent.net Kirill Simonov]. 
     286 
     287LibYAML is released under the MIT license. 
     288 
     289This project is developed for [http://www.python.org/psf/ Python Software Foundation] 
     290as a part of [http://code.google.com/summerofcode.html Google Summer of Code] 
     291under the mentorship of [http://clarkevans.com/ Clark Evans].