Class Grammar
java.lang.Object
org.libxmq.imp.ixml.earley.Grammar
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA call of a rule.static final recordA terminal: one code point from a set.static final recordAn insertion, +'text': outputs the text, matches no input.static final recordA negative lookahead, !'static final classOne alternative of a rule: rule → symbol symbol ...static final classA rule: the left hand side of its productions.static interfaceA symbol in a production. -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal List<Grammar.Production> All productions, numbered from 0.final Map<String, Grammar.Rule> All rules by name, in grammar order.final Grammar.RuleThe start rule.final TokensThe tokens: the code points of the literals of the grammar and of the inputs parsed so far. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanisNullable(Grammar.Rule rule) Returns true if the rule can match the empty input.
-
Field Details
-
start
The start rule. -
rules
All rules by name, in grammar order. -
productions
All productions, numbered from 0. -
tokens
The tokens: the code points of the literals of the grammar and of the inputs parsed so far.
-
-
Constructor Details
-
Grammar
Build the Earley grammar from an ixml grammar.- Parameters:
ixml- the grammar read by IXMLGrammar (without left recursion elimination)
-
-
Method Details
-
isNullable
Returns true if the rule can match the empty input.- Parameters:
rule- the rule- Returns:
- true if nullable
-