Class IXMLGenerateJava

java.lang.Object
org.libxmq.imp.ixml.IXMLGenerateJava

public final class IXMLGenerateJava extends Object
Generate a Java parser from an LL(*) ixml grammar. The same top down parser as IXMLGenerateC: every rule is a method, every decision is predicted by its lookahead DFA, there is no backtracking and the ixml parse tree (an org.libxmq.imp.xml.XmlDocument) is built while parsing. Java limits a method (also the static initializer) to 64 KiB of byte code, so the character sets and the DFAs are stored as string constants, decoded when the class is loaded, and the prediction is table driven. The generated class has a main method that parses a file or stdin and prints the tree like xmq does, so that: xmq grammar.ixml input.txt and: java Grammar input.txt print the same.
  • Method Details

    • generate

      public static String generate(String source, String pkg, String cls, String source_name)
      Generate the Java source of a parser for the grammar.
      Parameters:
      source - The ixml grammar.
      pkg - The package of the generated class, or null for the default package.
      cls - The name of the generated class.
      source_name - The grammar file name, used in comments.
      Returns:
      The Java source code.
      Throws:
      IllegalArgumentException - if the grammar is not LL(*).