Use a group file instead of loose templates (easier to understand the interactions)

This commit is contained in:
Sam Harwell 2012-10-28 11:24:08 -05:00
parent 4adef1e455
commit 85e2802d66
10 changed files with 44 additions and 39 deletions

View File

@ -1,3 +0,0 @@
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,8 +0,0 @@
atn(startState, states, edges, rankdir, decisionRanks, useBox) ::= <<
digraph ATN {
rankdir=LR;
<decisionRanks; separator="\n">
<states; separator="\n">
<edges; separator="\n">
}
>>

View File

@ -1,4 +0,0 @@
decision-rank(states) ::= <<
{rank=same; rankdir=TB; <states:{s | s<s>}; separator="; ">}
>>

View File

@ -1,8 +0,0 @@
dfa(name, startState, states, edges, rankdir, decisionRanks, useBox) ::= <<
digraph <name> {
<if(rankdir)>rankdir=<rankdir>;<endif>
<decisionRanks; separator="\n">
<states; separator="\n">
<edges; separator="\n">
}
>>

View File

@ -1,4 +0,0 @@
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 +0,0 @@
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

@ -0,0 +1,41 @@
atn(startState, states, edges, rankdir, decisionRanks, useBox) ::= <<
digraph ATN {
rankdir=LR;
<decisionRanks; separator="\n">
<states; separator="\n">
<edges; separator="\n">
}
>>
dfa(name, startState, states, edges, rankdir, decisionRanks, useBox) ::= <<
digraph <name> {
<if(rankdir)>rankdir=<rankdir>;<endif>
<decisionRanks; separator="\n">
<states; separator="\n">
<edges; separator="\n">
}
>>
decision-rank(states) ::= <<
{rank=same; rankdir=TB; <states:{s | s<s>}; separator="; ">}
>>
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>];
>>
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>];
>>
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>];
>>
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];
>>
stopstate(name,label,actionIndex,useBox) ::= <<
<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>];
>>

View File

@ -1,3 +0,0 @@
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

@ -1,3 +0,0 @@
stopstate(name,label,actionIndex,useBox) ::= <<
<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>];
>>

View File

@ -54,7 +54,7 @@ import org.antlr.v4.runtime.dfa.DFAState;
import org.antlr.v4.runtime.misc.IntegerList;
import org.stringtemplate.v4.ST;
import org.stringtemplate.v4.STGroup;
import org.stringtemplate.v4.STGroupDir;
import org.stringtemplate.v4.STGroupFile;
import java.util.ArrayList;
import java.util.HashSet;
@ -70,8 +70,8 @@ public class DOTGenerator {
protected String arrowhead="normal";
protected String rankdir="LR";
/** Library of output templates; use <attrname> format */
public static STGroup stlib = new STGroupDir("org/antlr/v4/tool/templates/dot");
/** Library of output templates; use {@code <attrname>} format. */
public static STGroup stlib = new STGroupFile("org/antlr/v4/tool/templates/dot/graphs.stg");
protected Grammar grammar;