forked from jasder/antlr
v4: updated atn graphs
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9531]
This commit is contained in:
parent
cab803d5f3
commit
edc4224b56
|
@ -1,3 +1,3 @@
|
||||||
epsilon-edge(src,label,target,arrowhead) ::= <<
|
epsilon-edge(src,label,target,arrowhead,loopback=false) ::= <<
|
||||||
<src> -> <target> [fontname="Times-Italic", label = "e"];
|
<src> -> <target> [fontname="Times-Italic", label="ε"<if(loopback)>, style="dashed"<endif>];
|
||||||
>>
|
>>
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
state(state, label, name) ::= <<
|
state(state, label, name) ::= <<
|
||||||
node [fontsize=11, label="<label>", <if(useBox)>shape=box, fixedsize=false<else>shape=circle, fixedsize=true, width=.4<endif>, peripheries=1]; <name>
|
<name>[fontsize=11, label="<label>", <if(useBox)>shape=box, fixedsize=false<else>shape=circle, fixedsize=true, width=.55<endif>, peripheries=1];
|
||||||
>>
|
>>
|
|
@ -1,3 +1,3 @@
|
||||||
stopstate(name,label,actionIndex,useBox) ::= <<
|
stopstate(name,label,actionIndex,useBox) ::= <<
|
||||||
node [fontsize=11, label="<label><if(actionIndex)>,\naction:<actionIndex><endif>", <if(useBox)>shape=polygon,sides=4,peripheries=2,fixedsize=false<else>shape=doublecircle, fixedsize=true, width=.6<endif>]; <name>
|
<name>[fontsize=11, label="<label><if(actionIndex)>,\naction:<actionIndex><endif>", <if(useBox)>shape=polygon,sides=4,peripheries=2,fixedsize=false<else>shape=doublecircle, fixedsize=true, width=.6<endif>];
|
||||||
>>
|
>>
|
||||||
|
|
|
@ -237,6 +237,14 @@ public class DOTGenerator {
|
||||||
else if ( edge.isEpsilon() ) {
|
else if ( edge.isEpsilon() ) {
|
||||||
edgeST = stlib.getInstanceOf("epsilon-edge");
|
edgeST = stlib.getInstanceOf("epsilon-edge");
|
||||||
edgeST.add("label", getEdgeLabel(edge.toString()));
|
edgeST.add("label", getEdgeLabel(edge.toString()));
|
||||||
|
boolean loopback = false;
|
||||||
|
if (edge.target instanceof PlusBlockStartState) {
|
||||||
|
loopback = s.equals(((PlusBlockStartState)edge.target).loopBackState);
|
||||||
|
}
|
||||||
|
else if (edge.target instanceof StarLoopEntryState) {
|
||||||
|
loopback = s.equals(((StarLoopEntryState)edge.target).loopBackState);
|
||||||
|
}
|
||||||
|
edgeST.add("loopback", loopback);
|
||||||
}
|
}
|
||||||
else if ( edge instanceof AtomTransition ) {
|
else if ( edge instanceof AtomTransition ) {
|
||||||
edgeST = stlib.getInstanceOf("edge");
|
edgeST = stlib.getInstanceOf("edge");
|
||||||
|
@ -410,10 +418,28 @@ public class DOTGenerator {
|
||||||
|
|
||||||
protected String getStateLabel(ATNState s) {
|
protected String getStateLabel(ATNState s) {
|
||||||
if ( s==null ) return "null";
|
if ( s==null ) return "null";
|
||||||
String stateLabel = String.valueOf(s.stateNumber);
|
String stateLabel = "";
|
||||||
|
|
||||||
|
if (s instanceof BlockStartState) {
|
||||||
|
stateLabel += "→\\n";
|
||||||
|
}
|
||||||
|
else if (s instanceof BlockEndState) {
|
||||||
|
stateLabel += "←\\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
stateLabel += String.valueOf(s.stateNumber);
|
||||||
|
|
||||||
|
if (s instanceof PlusBlockStartState || s instanceof PlusLoopbackState) {
|
||||||
|
stateLabel += "+";
|
||||||
|
}
|
||||||
|
else if (s instanceof StarBlockStartState || s instanceof StarLoopEntryState || s instanceof StarLoopbackState) {
|
||||||
|
stateLabel += "*";
|
||||||
|
}
|
||||||
|
|
||||||
if ( s instanceof DecisionState && ((DecisionState)s).decision>=0 ) {
|
if ( s instanceof DecisionState && ((DecisionState)s).decision>=0 ) {
|
||||||
stateLabel = stateLabel+"\\nd="+((DecisionState)s).decision;
|
stateLabel = stateLabel+"\\nd="+((DecisionState)s).decision;
|
||||||
}
|
}
|
||||||
|
|
||||||
return stateLabel;
|
return stateLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue