Commit 61202372 authored by Sergio Pérez's avatar Sergio Pérez
Browse files

* Production class created and used

* LiteralConstraint and its stack behaviour implemented
parent 243dcc9b
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -92,6 +92,12 @@ public abstract class AccessConstraint extends EdgeConstraint {
	protected List<Constraints> resolve(Phase phase, EDG edg, Edge edge, Constraints constraints, StructuralConstraint topConstraint, int productionDepth) {
		return super.wrap();
	}
	protected List<Constraints> resolve(Phase phase, EDG edg, Edge edge, Constraints constraints, LiteralConstraint topConstraint, int productionDepth){
		if (this.operation == Operation.Add)
			return super.wrap(super.push(phase, constraints));
		return super.wrap();
	}

	protected List<Constraints> resolve(Phase phase, EDG edg, Edge edge, Constraints constraints, GrammarConstraint topConstraint, int productionDepth)
	{
		super.check(phase, Phase.SummaryGeneration);
+4 −0
Original line number Diff line number Diff line
@@ -44,6 +44,10 @@ public class AddNodeConstraint extends EdgeConstraint {
		constraints.nodeConstraints.add(this.nodeConstraint);
		return super.wrap(constraints);
	}
	protected List<Constraints> resolve(Phase phase, EDG edg, Edge edge, Constraints constraints, LiteralConstraint topConstraint, int productionDepth) {
		constraints.nodeConstraints.add(this.nodeConstraint);
		return super.wrap(constraints);
	}
	protected List<Constraints> resolve(Phase phase, EDG edg, Edge edge, Constraints constraints, GrammarConstraint topConstraint, int productionDepth)
	{
		super.check(phase, Phase.SummaryGeneration);
+9 −0
Original line number Diff line number Diff line
@@ -75,6 +75,15 @@ public class AsteriskConstraint extends EdgeConstraint
		final EdgeConstraint peekConstraint = newConstraints.peekEdgeConstraint();
		return super.resolve(phase, edg, edge, newConstraints, peekConstraint, productionDepth);
	}
	protected List<Constraints> resolve(Phase phase, EDG edg, Edge edge, Constraints constraints, LiteralConstraint topConstraint, int productionDepth) {
		if (phase.isInstanceof(Phase.Slicing))
			return super.wrap(new Constraints());
		super.check(phase, Phase.SummaryGeneration);

		if (existsPreviousAsteriskConstraint(constraints))
			return super.wrap(this.popToAsteriskConstraint(constraints));
		return super.wrap(super.push(phase, constraints));
	}
	protected List<Constraints> resolve(Phase phase, EDG edg, Edge edge, Constraints constraints, GrammarConstraint topConstraint, int productionDepth)
	{
		super.check(phase, Phase.SummaryGeneration);
+2 −2
Original line number Diff line number Diff line
@@ -7,8 +7,8 @@ import java.util.Stack;
public class Constraints {
	public enum Type {Node, Edge}

	protected final Set<NodeConstraint> nodeConstraints = new HashSet<>();
	protected final Stack<EdgeConstraint> edgeConstraints = new Stack<>();
	protected Set<NodeConstraint> nodeConstraints = new HashSet<>();
	protected Stack<EdgeConstraint> edgeConstraints = new Stack<>();

	public Set<NodeConstraint> getNodeConstraints()
	{
+3 −0
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ public abstract class EdgeConstraint extends Constraint
			return this.resolve(phase, edg, edge, constraints, (AccessConstraint) topConstraint, productionDepth);
		else if (topConstraint instanceof StructuralConstraint)
			return this.resolve(phase, edg, edge, constraints, (StructuralConstraint) topConstraint, productionDepth);
		else if (topConstraint instanceof LiteralConstraint)
			return this.resolve(phase, edg, edge, constraints, (LiteralConstraint) topConstraint, productionDepth);
		else if (topConstraint instanceof EmptyConstraint)
			return this.resolve(phase, edg, edge, constraints, (EmptyConstraint) topConstraint, productionDepth);
		else if (topConstraint instanceof PhaseConstraint)
@@ -36,6 +38,7 @@ public abstract class EdgeConstraint extends Constraint
	protected abstract List<Constraints> resolve(Phase phase, EDG edg, Edge edge, Constraints constraints, int productionDepth);
	protected abstract List<Constraints> resolve(Phase phase, EDG edg, Edge edge, Constraints constraints, AccessConstraint topConstraint, int productionDepth);
	protected abstract List<Constraints> resolve(Phase phase, EDG edg, Edge edge, Constraints constraints, StructuralConstraint topConstraint, int productionDepth);
	protected abstract List<Constraints> resolve(Phase phase, EDG edg, Edge edge, Constraints constraints, LiteralConstraint topConstraint, int productionDepth);

	protected final List<Constraints> resolve(Phase phase, EDG edg, Edge edge, Constraints constraints, AddNodeConstraint topConstraint, int productionDepth)
	{
Loading