Class YamlParser
java.lang.Object
org.libxmq.imp.XMQParser
org.libxmq.imp.XMQParseIntoDOM
org.libxmq.imp.YamlParser
Parse (a subset of) yaml into the xmq DOM, a port of the parser in yaml.c.
Like the C code, the yaml is translated into calls of the same parse
callbacks as the xmq parser uses, so the DOM is built by XMQParseIntoDOM.
The input is copied into a char array with a 0 sentinel, lines are 0
terminated when they are read and quoted scalars are decoded in place,
exactly like the private buffer of the C parser, so that the scanning code
can be kept close to the C code (indexes instead of pointers).
Supported: nested mappings, nested sequences, plain, single and double
quoted scalars, comments, flow collections, block scalars | and >, anchors
(id attribute), aliases (ref attribute) and tags (tag and ltag attributes).
All content is text, see yaml.c.
-
Field Summary
Fields inherited from class XMQParser
MAX_NESTING_DEPTHModifier and TypeFieldDescriptionstatic final intThe parsers recurse for every nested xmq body or json object or array, deeper nesting is an error (XMQ_ERROR_TOO_DEEP) instead of a stack overflow. -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class XMQParseIntoDOM
do_apar_left, do_apar_right, do_attr_key, do_attr_ns, do_attr_value_compound_entity, do_attr_value_compound_quote, do_attr_value_entity, do_attr_value_quote, do_attr_value_text, do_brace_left, do_brace_right, do_colon, do_comment, do_comment_continuation, do_cpar_left, do_cpar_right, do_element_key, do_element_name, do_element_ns, do_element_value_compound_entity, do_element_value_compound_quote, do_element_value_entity, do_element_value_quote, do_element_value_text, do_entity, do_equals, do_equals_done, do_ns_colon, do_ns_declaration, do_quote, do_whitespace, doc, setDoc, setImplicitRoot, setMergeText, setNoTrimQuotesModifier and TypeMethodDescriptionprotected voiddo_apar_left(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a left parenthesis is parsed.protected voiddo_apar_right(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a right parenthesis is parsed.protected voiddo_attr_key(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an attribute key is parsed.protected voiddo_attr_ns(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an attribute namespace is parsed.protected voiddo_attr_value_compound_entity(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an entity inside a compound attribute value is parsed.protected voiddo_attr_value_compound_quote(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a compound attribute value quote is parsed.protected voiddo_attr_value_entity(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an entity inside an attribute value is parsed.protected voiddo_attr_value_quote(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a quoted attribute value is parsed.protected voiddo_attr_value_text(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when unquoted attribute value text is parsed.protected voiddo_brace_left(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a left brace is parsed.protected voiddo_brace_right(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a right brace is parsed.protected voiddo_colon(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a colon is parsed.protected voiddo_comment(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a comment is parsed.protected voiddo_comment_continuation(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a continued comment is parsed.protected voiddo_cpar_left(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a left square bracket is parsed.protected voiddo_cpar_right(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a right square bracket is parsed.protected voiddo_element_key(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an element key is parsed.protected voiddo_element_name(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an element name is parsed.protected voiddo_element_ns(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an element namespace is parsed.protected voiddo_element_value_compound_entity(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an entity inside a compound element value is parsed.protected voiddo_element_value_compound_quote(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a compound element value quote is parsed.protected voiddo_element_value_entity(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an entity inside an element value is parsed.protected voiddo_element_value_quote(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a quoted element value is parsed.protected voiddo_element_value_text(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when unquoted element value text is parsed.protected voiddo_entity(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an entity is parsed.protected voiddo_equals(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an equals sign is parsed.protected voiddo_equals_done(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an equals sign completes a construct.protected voiddo_ns_colon(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a namespace colon is parsed.protected voiddo_ns_declaration(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a namespace declaration is parsed.protected voiddo_quote(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a quote is parsed.protected voiddo_whitespace(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when whitespace is parsed.doc()Returns the parsed document.setDoc(XmlDocument doc) Use an existing document to parse into.setImplicitRoot(String name) Set the implicit root element name.setMergeText(boolean merge) Control whether adjacent text nodes should be merged (the default) or kept separate, like the --no-merge option.setNoTrimQuotes(boolean no_trim) Do not trim the incidental indentation of quotes, used when the quotes were generated from json strings.Methods inherited from class XMQParser
parse, parse_xmq_whitespaceModifier and TypeMethodDescriptionbooleanParses an xmq buffer.protected voidParses xmq whitespace and invokes the whitespace callback.
-
Constructor Details
-
YamlParser
public YamlParser()Creates the yaml parser.
-
-
Method Details
-
parseYaml
Parse yaml.- Parameters:
input- The yaml source.source- A description of where the buffer comes from, for error messages.- Returns:
- True on success.
- Throws:
ParseException- If the yaml cannot be parsed.
-