Skip to main content

Module parser_ffi

Module parser_ffi 

Source
Expand description

asdf/parser.h, asdf/event.h and asdf/yaml.h: the low-level event-based parser.

This is libasdf’s streaming interface: rather than building a tree, it walks a file and reports what it finds – the version headers, any comments, the block index, the tree’s extent, optionally the YAML events inside it, then each block, then the end.

§Ownership

The header’s contract is unusual and is reproduced rather than simplified:

  • asdf_parser_parse hands out an event the caller releases with asdf_event_free.
  • asdf_event_iterate releases the event it handed out last time before producing the next, so a loop over it frees nothing by hand.
  • Anything still outstanding is released by asdf_parser_destroy, so a caller that abandons a parse leaks nothing.

An event’s strings belong to the event and stay valid until it is freed.

Structs§

AsdfEvent
A parser event. Opaque to C.
AsdfParser
A parser handle. Opaque to C.

Functions§

asdf_event_block_info⚠
A block event’s position and header, or null for any other event.
asdf_event_comment⚠
A comment event’s text, without its leading #, or null.
asdf_event_free⚠
Release an event from asdf_parser_parse.
asdf_event_iterate⚠
Produce the next event, releasing the one this call produced last.
asdf_event_print⚠
Print an event, in the format asdf info --events uses.
asdf_event_tree_info⚠
A tree event’s extent, or null for any other event.
asdf_event_type⚠
An event’s type; ASDF_NONE_EVENT for a null event.
asdf_event_type_name
The name of an event type, as its enum member is spelled.
asdf_parser_create⚠
Create a parser.
asdf_parser_destroy⚠
Release a parser and everything it handed out.
asdf_parser_error_code⚠
The recorded error code.
asdf_parser_error_errno⚠
The recorded errno, meaningful only for a system error.
asdf_parser_get_error⚠
The recorded error message, or null.
asdf_parser_has_error⚠
Whether the parser has recorded an error.
asdf_parser_parse⚠
Produce the next event, or null at the end of the stream.
asdf_parser_set_input_file⚠
Read a file and lay out its event stream. Returns 0 on success.
asdf_parser_set_input_fp⚠
Read an already-open stream. Returns 0 on success.
asdf_parser_set_input_mem⚠
Read a buffer. Returns 0 on success.
asdf_yaml_event_scalar_value⚠
A scalar sub-event’s raw text, or null.
asdf_yaml_event_tag⚠
A YAML sub-event’s tag, or null.
asdf_yaml_event_type⚠
The YAML sub-event type, or ASDF_YAML_NONE_EVENT.
asdf_yaml_event_type_text⚠
A human-readable name for the YAML sub-event type.