|
Pep 0.4 API Documentation | ||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.osu.ling.pep.Grammar
public class Grammar
Represents a context-free grammar (set of production rules).
Grammars maintain their rules indexed by
left side category
. The rule sets contained for
any given left category
are not guaranteed to be
maintained in the order of insertion.
Constructor Summary | |
---|---|
Grammar(String name)
Creates a grammar with the given name, initializes its internal data structure. |
Method Summary | |
---|---|
boolean |
addRule(Rule rule)
Adds a production rule. |
boolean |
containsRules(Category left)
Tests whether this grammar contains rules for the specified left side category. |
Set<Rule> |
getAllRules()
Gets every rule in this grammar. |
String |
getName()
Gets the name of this grammar. |
Set<Rule> |
getRules(Category left)
Gets the set of rules contained by this grammar with the given left side category. |
String |
toString()
Gets a string representation of this grammar. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Grammar(String name)
name
- The mnemonic name for this grammar.Method Detail |
---|
public boolean addRule(Rule rule)
left side
of the specified rule, a new rule
set is created.
rule
- The rule to add.
true
iff this grammar did not already contain
the specified rule.
NullPointerException
- If rule
is null
.public boolean containsRules(Category left)
left
- The left category of the rules to test for.
true
iff this grammar contains rules with the
specified category as their left side
.public Set<Rule> getAllRules()
public String getName()
public Set<Rule> getRules(Category left)
left
- The left side
of the rules to find.
left side
is
the same
as left
, or
null
if no such rules are contained in this grammar. The
rule set returned by this method is not guaranteed to contain
the rules in the order in which they were added
.public String toString()
toString
in class Object
Rule.toString()
|
Pep: Pep is an Earley parser | ||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the overview file.