N
- the enum class that lists all nonterminal symbols for this
grammar.public class FlexibleGrammar<N extends Enum<N>> extends Object implements Grammar<N>
Constructor and Description |
---|
FlexibleGrammar(Class<N> nonterminalClass,
N axiom) |
Modifier and Type | Method and Description |
---|---|
void |
addRule(N left,
ProductionRule<N> rule)
Adds a production rule to this grammar.
|
boolean |
containsGaps()
This should return true if and only if this grammar contains
at least one production rule with the OperationType DELETION
or INSERTION.
|
boolean |
containsSkips()
This should return true if and only if this grammar contains
at least one production rule with the OperationType SKIPDELETION
or SKIPINSERTION.
|
N[] |
dependencySort()
Returns the nonterminals of this grammar sorted according to their
dependencies on one another.
|
EnumSet<N> |
getAccepting()
Returns the set of all accepting nonterminals of this grammar.
|
N |
getAxiom()
Returns the axiom of this grammar.
|
Class<N> |
getNonterminalClass()
Returns the enum class that lists the nonterminal symbols of
this grammar.
|
ArrayList<ProductionRule<N>> |
getPossibleRules(N nonterminal,
int leftSize,
int rightSize)
Returns all production rules of this grammar that can be applied
in the current situation.
|
EnumMap<N,ArrayList<ProductionRule<N>>> |
getRules()
Returns all production rules that are stored in this grammar.
|
String |
toString() |
void |
validate()
This ensures that the grammar is terminal, that is:
1.) There is at least one possible path of production rules that leads
from the axiom to an accepting nonterminal.
|
public Class<N> getNonterminalClass()
getNonterminalClass
in interface Grammar<N extends Enum<N>>
public N getAxiom()
public EnumMap<N,ArrayList<ProductionRule<N>>> getRules()
public void addRule(N left, ProductionRule<N> rule)
left
- the left hand side of the production rule.rule
- the right hand side of the production rule.public EnumSet<N> getAccepting()
getAccepting
in interface Grammar<N extends Enum<N>>
public void validate()
public N[] dependencySort()
dependencySort
in interface Grammar<N extends Enum<N>>
public ArrayList<ProductionRule<N>> getPossibleRules(N nonterminal, int leftSize, int rightSize)
getPossibleRules
in interface Grammar<N extends Enum<N>>
nonterminal
- the nonterminal symbol on the left side of all
returned production rules.leftSize
- the nodes available in the left input sequence.rightSize
- the nodes available in the right right sequence.public boolean containsGaps()
containsGaps
in interface Grammar<N extends Enum<N>>
public boolean containsSkips()
containsSkips
in interface Grammar<N extends Enum<N>>
Copyright (C) 2013-2015 Benjamin Paaßen, Georg Zentgraf, AG Theoretical Computer Science, Centre of Excellence Cognitive Interaction Technology (CITEC), University of Bielefeld, licensed under the AGPL v. 3: http://openresearch.cit-ec.de/projects/tcs