net.ericaro.diezel.core.builder.DiezelLanguage Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of diezel-maven-plugin Show documentation
Show all versions of diezel-maven-plugin Show documentation
An Embedded Domain Specific Language Parser Generator PLugin compiler
The newest version!
package net.ericaro.diezel.core.builder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import edu.uci.ics.jung.graph.DirectedGraph;
public class DiezelLanguage implements Compilable{
String header ;
String expression; // the regexp defining the workfow
String packageName; // global conf: the target package name
String guideBaseName = "Guide";
List rootTypes = new ArrayList(); // the root state generics, always usefull to start with
List transitions = new ArrayList();
//List states = new ArrayList();
// result of compilation
transient DirectedGraph graph; // graph computed from the expression expression
transient State start, end;
DiezelLanguage() {
super();
}
public String getExpression() {
return expression;
}
public String getPackageName() {
return packageName;
}
public String getGuideName() {
return guideBaseName;
}
public String getHeader() {
return header;
}
public List getTransitions() {
return transitions;
}
public Collection getStates(){
return graph.getVertices();
}
public DirectedGraph getGraph() {
return graph;
}
/**
* print the current graph in a graphviz format.
*/
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("digraph {\n");
for (State s : graph.getVertices())
sb.append(s.toString()).append(";\n");
for (TransitionInstance t: graph.getEdges())
sb.append(t.toString()).append(";\n");
sb.append("}\n");
return sb.toString();
}
}