forked from jasder/antlr
Use a group file instead of loose templates (easier to understand the interactions)
This commit is contained in:
parent
4adef1e455
commit
85e2802d66
|
@ -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>];
|
||||
>>
|
|
@ -1,8 +0,0 @@
|
|||
atn(startState, states, edges, rankdir, decisionRanks, useBox) ::= <<
|
||||
digraph ATN {
|
||||
rankdir=LR;
|
||||
<decisionRanks; separator="\n">
|
||||
<states; separator="\n">
|
||||
<edges; separator="\n">
|
||||
}
|
||||
>>
|
|
@ -1,4 +0,0 @@
|
|||
decision-rank(states) ::= <<
|
||||
{rank=same; rankdir=TB; <states:{s | s<s>}; separator="; ">}
|
||||
>>
|
||||
|
|
@ -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">
|
||||
}
|
||||
>>
|
|
@ -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>];
|
||||
>>
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
epsilon-edge(src,label,target,arrowhead,transitionIndex,loopback=false) ::= <<
|
||||
<src><if(transitionIndex)>:p<transitionIndex><endif> -> <target> [fontname="Times-Italic", label="ε"<if(loopback)>, style="dashed"<endif>];
|
||||
>>
|
|
@ -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="ε"<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>];
|
||||
>>
|
|
@ -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];
|
||||
>>
|
|
@ -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>];
|
||||
>>
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue