Class IXML

java.lang.Object
org.libxmq.IXML

public final class IXML extends Object
A compiled ixml grammar, used to parse many inputs, see XMQ.compileIXML and XMQ.parseBufferWithIXML. Like an XMQDoc parsed with XMQ_CONTENT_IXML in xmq.h. A grammar that is LL(*) is parsed with the fast predictive parser, any other grammar with the Earley parser.
  • Method Details

    • compile

      public static IXML compile(String grammar) throws ParseException
      Compile an ixml grammar.
      Parameters:
      grammar - The ixml grammar source.
      Returns:
      The compiled grammar.
      Throws:
      ParseException - if the grammar has a syntax error.
    • source

      public String source()
      The ixml grammar source.
      Returns:
      The source.
    • parse

      public XMQDoc parse(String input) throws ParseException
      Parse an input with the grammar.
      Parameters:
      input - The input to parse.
      Returns:
      The parse tree.
      Throws:
      ParseException - if the input is rejected by the grammar.
    • parse

      public XMQDoc parse(byte[] input) throws ParseException
      Parse an UTF-8 input with the grammar. The Earley parser decodes the code points directly from the bytes, the input is not copied into a String.
      Parameters:
      input - The input to parse, UTF-8.
      Returns:
      The parse tree.
      Throws:
      ParseException - if the input is rejected by the grammar, or is not valid UTF-8.
    • parse

      public XMQDoc parse(byte[] buf, int start, int stop) throws ParseException
      Parse an UTF-8 input with the grammar, the bytes start to stop of the buffer.
      Parameters:
      buf - The buffer with the input, UTF-8.
      start - The first byte of the input.
      stop - The end of the input, exclusive.
      Returns:
      The parse tree.
      Throws:
      ParseException - if the input is rejected by the grammar, or is not valid UTF-8.