Class Grammar

java.lang.Object
org.libxmq.imp.ixml.earley.Grammar

public final class Grammar extends Object
The ixml grammar as the Earley parser sees it: rules with productions, where each production is a sequence of symbols. The grammar is read by IXMLGrammar, which has already rewritten the ixml repetitions, options and groups into hidden generated rules (/1, /2, ...). So here there are only four kinds of symbols: - Call a nonterminal, a call of another rule, eg the M in S = M, '+', M. - Chars a terminal, matches one code point from a set, eg '+' or [L]. - Insertion +'text' inserts text into the output and matches nothing. - Not a negative lookahead !'x', matches nothing (see EarleyParser). Insertion and Not are zero width: the parser steps over them without reading input.
  • Field Details

    • start

      public final Grammar.Rule start
      The start rule.
    • rules

      public final Map<String, Grammar.Rule> rules
      All rules by name, in grammar order.
    • productions

      public final List<Grammar.Production> productions
      All productions, numbered from 0.
    • tokens

      public final Tokens tokens
      The tokens: the code points of the literals of the grammar and of the inputs parsed so far.
  • Constructor Details

    • Grammar

      public Grammar(IXMLGrammar ixml)
      Build the Earley grammar from an ixml grammar.
      Parameters:
      ixml - the grammar read by IXMLGrammar (without left recursion elimination)
  • Method Details

    • isNullable

      public boolean isNullable(Grammar.Rule rule)
      Returns true if the rule can match the empty input.
      Parameters:
      rule - the rule
      Returns:
      true if nullable