Class GrammarConstraintProvider.Constraint
- java.lang.Object
-
- org.eclipse.xtext.serializer.analysis.GrammarConstraintProvider.Constraint
-
- All Implemented Interfaces:
java.lang.Comparable<IGrammarConstraintProvider.IConstraint>
,IGrammarConstraintProvider.IConstraint
- Enclosing class:
- GrammarConstraintProvider
protected static class GrammarConstraintProvider.Constraint extends java.lang.Object implements IGrammarConstraintProvider.IConstraint
-
-
Constructor Summary
Constructors Constructor Description Constraint(Grammar grammar, org.eclipse.emf.ecore.EClass type, org.eclipse.xtext.util.formallang.Nfa<ISemanticSequencerNfaProvider.ISemState> nfa)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(IGrammarConstraintProvider.IConstraint o)
protected int[]
computeLowerBounds()
protected int[]
computeUpperBounds()
Computing the upper bounds is equivalent to the longest path problem.boolean
equals(java.lang.Object obj)
IGrammarConstraintProvider.IConstraintElement
getBody()
java.util.List<ISerializationContext>
getContexts()
IGrammarConstraintProvider.IFeatureInfo[]
getFeatures()
protected java.lang.String
getIdentity()
java.lang.String
getName()
org.eclipse.xtext.util.formallang.Nfa<ISemanticSequencerNfaProvider.ISemState>
getNfa()
java.lang.String
getSimpleName()
org.eclipse.emf.ecore.EClass
getType()
int
hashCode()
protected void
setName(java.lang.String name)
java.lang.String
toString()
-
-
-
Constructor Detail
-
Constraint
public Constraint(Grammar grammar, org.eclipse.emf.ecore.EClass type, org.eclipse.xtext.util.formallang.Nfa<ISemanticSequencerNfaProvider.ISemState> nfa)
-
-
Method Detail
-
computeLowerBounds
protected int[] computeLowerBounds()
-
computeUpperBounds
protected int[] computeUpperBounds()
Computing the upper bounds is equivalent to the longest path problem. While this is NP-hard if constrained to simple paths, it becomes easily solvable in our case since we include infinite paths. All features that are assigned inside a cycle have infinity as upper bound. For the remaining features we can handle each cycle as if it was a single node because it is not relevant where we enter the cycle and where we exit it (traversing the cycle has zero weight). The resulting simplified graph is acyclic, and in such graphs the longest path can be computed in linear time with a simple recursive algorithm.
-
compareTo
public int compareTo(IGrammarConstraintProvider.IConstraint o)
- Specified by:
compareTo
in interfacejava.lang.Comparable<IGrammarConstraintProvider.IConstraint>
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
getBody
public IGrammarConstraintProvider.IConstraintElement getBody()
- Specified by:
getBody
in interfaceIGrammarConstraintProvider.IConstraint
- Returns:
- the root of the tree of
IGrammarConstraintProvider.IConstraintElement
that defines this constraint.
-
getContexts
public java.util.List<ISerializationContext> getContexts()
- Specified by:
getContexts
in interfaceIGrammarConstraintProvider.IConstraint
-
getFeatures
public IGrammarConstraintProvider.IFeatureInfo[] getFeatures()
- Specified by:
getFeatures
in interfaceIGrammarConstraintProvider.IConstraint
- Returns:
- a list of
IGrammarConstraintProvider.IFeatureInfo
for allEStructuralFeature
s from theEClass
returned byIGrammarConstraintProvider.IConstraint.getType()
that have an assignment if this constraint. If there is no assignment for anEStructuralFeature
in this constraint, the array's item is null.
-
getIdentity
protected java.lang.String getIdentity()
-
getName
public java.lang.String getName()
- Specified by:
getName
in interfaceIGrammarConstraintProvider.IConstraint
- Returns:
- a name that is unique for a grammar and that aims to be human-readable.
-
getNfa
public org.eclipse.xtext.util.formallang.Nfa<ISemanticSequencerNfaProvider.ISemState> getNfa()
- Specified by:
getNfa
in interfaceIGrammarConstraintProvider.IConstraint
-
getSimpleName
public java.lang.String getSimpleName()
- Specified by:
getSimpleName
in interfaceIGrammarConstraintProvider.IConstraint
-
getType
public org.eclipse.emf.ecore.EClass getType()
- Specified by:
getType
in interfaceIGrammarConstraintProvider.IConstraint
- Returns:
- This constraint only applies to EObjects of this type.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
setName
protected void setName(java.lang.String name)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-