Output from -atn flag shows the order of outgoing edges from decision states.

This commit is contained in:
Sam Harwell 2012-10-28 11:17:39 -05:00
parent 950f588ac0
commit 4adef1e455
6 changed files with 22 additions and 9 deletions

View File

@ -126,7 +126,13 @@ public class ATNState {
return String.valueOf(stateNumber);
}
public int getNumberOfTransitions() { return transitions.size(); }
public Transition[] getTransitions() {
return transitions.toArray(new Transition[transitions.size()]);
}
public int getNumberOfTransitions() {
return transitions.size();
}
public void addTransition(Transition e) {
if (transitions.isEmpty()) {

View File

@ -1,3 +1,3 @@
action-edge(src,target,label,arrowhead) ::= <<
<src> -> <target> [fontsize=11, fontname="Courier", arrowsize=.7, label = "<label>"<if(arrowhead)>, arrowhead = <arrowhead><endif>];
action-edge(src,target,label,arrowhead,transitionIndex) ::= <<
<src><if(transitionIndex)>:p<transitionIndex><endif> -> <target> [fontsize=11, fontname="Courier", arrowsize=.7, label = "<label>"<if(arrowhead)>, arrowhead = <arrowhead><endif>];
>>

View File

@ -1,4 +1,4 @@
edge(src,target,label,arrowhead) ::= <<
<src> -> <target> [fontsize=11, fontname="Courier", arrowsize=.7, label = "<label>"<if(arrowhead)>, arrowhead = <arrowhead><endif>];
edge(src,target,label,arrowhead,transitionIndex) ::= <<
<src><if(transitionIndex)>:p<transitionIndex><endif> -> <target> [fontsize=11, fontname="Courier", arrowsize=.7, label = "<label>"<if(arrowhead)>, arrowhead = <arrowhead><endif>];
>>

View File

@ -1,3 +1,3 @@
epsilon-edge(src,label,target,arrowhead,loopback=false) ::= <<
<src> -> <target> [fontname="Times-Italic", label="&epsilon;"<if(loopback)>, style="dashed"<endif>];
epsilon-edge(src,label,target,arrowhead,transitionIndex,loopback=false) ::= <<
<src><if(transitionIndex)>:p<transitionIndex><endif> -> <target> [fontname="Times-Italic", label="&epsilon;"<if(loopback)>, style="dashed"<endif>];
>>

View File

@ -1,3 +1,3 @@
state(state, label, name) ::= <<
<name>[fontsize=11, label="<label>", <if(useBox)>shape=box, fixedsize=false<else>shape=circle, fixedsize=true, width=.55<endif>, peripheries=1];
state(state, label, name, transitions) ::= <<
<name>[fontsize=11, label="<if(rest(transitions))>{<endif><label><if(rest(transitions))>|{<transitions:{t|\<p<i0>\>}; separator="|">}}<endif>", <if(rest(transitions))>shape=record, fixedsize=false<else>shape=circle, fixedsize=true, width=.55<endif>, peripheries=1];
>>

View File

@ -304,6 +304,11 @@ public class DOTGenerator {
edgeST.add("src", "s"+s.stateNumber);
edgeST.add("target", "s"+edge.target.stateNumber);
edgeST.add("arrowhead", arrowhead);
if (s.getNumberOfTransitions() > 1) {
edgeST.add("transitionIndex", i);
} else {
edgeST.add("transitionIndex", false);
}
dot.add("edges", edgeST);
work.add(edge.target);
}
@ -327,11 +332,13 @@ public class DOTGenerator {
st.add("label", getStateLabel(s));
dot.add("states", st);
}
for (ATNState s : markedStates) {
if ( s instanceof RuleStopState ) continue;
ST st = stlib.getInstanceOf("state");
st.add("name", "s"+s.stateNumber);
st.add("label", getStateLabel(s));
st.add("transitions", s.getTransitions());
dot.add("states", st);
}