forked from jasder/antlr
Add graphs describing ATNState relations
This commit is contained in:
parent
57295785d5
commit
93f7a448e7
|
@ -24,6 +24,32 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>sonatype-oss-release</id>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>us.bryon</groupId>
|
||||||
|
<artifactId>graphviz-maven-plugin</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>dot</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<destdir>${project.build.directory}/apidocs</destdir>
|
||||||
|
<output>svg</output>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
||||||
<sourceDirectory>src</sourceDirectory>
|
<sourceDirectory>src</sourceDirectory>
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
digraph "" {
|
||||||
|
graph[fontname="Consolas,Courier";rankdir="LR";pad="0.25"];
|
||||||
|
node[fontname="Consolas,Courier";target="_parent"];
|
||||||
|
edge[fontname="Consolas,Courier"];
|
||||||
|
subgraph cluster0 {
|
||||||
|
subgraph[color="white"];
|
||||||
|
{ node[shape="record"];
|
||||||
|
BasicBlockStartState[URL="../BasicBlockStartState.html";label="{BasicBlockStartState | {<alt1> alt 1 |<alt2> alt 2 | ·\n·\n· |<altn> alt n}}"];
|
||||||
|
BlockEndState[URL="../BlockEndState.html"];
|
||||||
|
}
|
||||||
|
|
||||||
|
{ node[style="dashed"];
|
||||||
|
content1[label="alt 1"];
|
||||||
|
content2[label="alt 2"];
|
||||||
|
more[label="alt n"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{ node[style="dashed"];
|
||||||
|
begin;
|
||||||
|
end;
|
||||||
|
}
|
||||||
|
|
||||||
|
begin -> BasicBlockStartState[style="dashed"];
|
||||||
|
BlockEndState -> end[label="ε"];
|
||||||
|
|
||||||
|
BasicBlockStartState:alt1 -> content1[label="ε"];
|
||||||
|
content1 -> BlockEndState[style="dashed"];
|
||||||
|
|
||||||
|
BasicBlockStartState:alt2 -> content2[label="ε"];
|
||||||
|
content2 -> BlockEndState[style="dashed"];
|
||||||
|
|
||||||
|
BasicBlockStartState:altn -> more[label="ε"];
|
||||||
|
more -> BlockEndState[style="dashed"];
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
digraph "" {
|
||||||
|
graph[fontname="Consolas,Courier";rankdir="LR";pad="0.25"];
|
||||||
|
node[fontname="Consolas,Courier";target="_parent"];
|
||||||
|
edge[fontname="Consolas,Courier"];
|
||||||
|
subgraph cluster0 {
|
||||||
|
subgraph[color="white"];
|
||||||
|
{ node[shape="record"];
|
||||||
|
StarLoopEntryState[URL="../StarLoopEntryState.html";label="{StarLoopEntryState | {<alt1> alt 1 |<alt2> alt 2}}"];
|
||||||
|
StarLoopbackState[URL="../StarLoopbackState.html"];
|
||||||
|
StarBlockStartState[URL="../StarBlockStartState.html";label="{StarBlockStartState | {<alt1> alt 1 |<alt2> alt 2 | ·\n·\n· |<altn> alt n}}"];
|
||||||
|
BlockEndState[URL="../BlockEndState.html"];
|
||||||
|
|
||||||
|
{ rank="sink";
|
||||||
|
LoopEndState[URL="../LoopEndState.html";rank="max"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{ node[style="dashed"];
|
||||||
|
content1[label="alt 1"];
|
||||||
|
content2[label="alt 2"];
|
||||||
|
more[label="alt n"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{ node[style="dashed"];
|
||||||
|
begin;
|
||||||
|
end;
|
||||||
|
}
|
||||||
|
|
||||||
|
begin -> StarLoopEntryState[style="dashed"];
|
||||||
|
LoopEndState -> end[label="ε"];
|
||||||
|
|
||||||
|
StarBlockStartState:alt1 -> content1[label="ε"];
|
||||||
|
content1 -> BlockEndState[style="dashed"];
|
||||||
|
|
||||||
|
StarBlockStartState:alt2 -> content2[label="ε"];
|
||||||
|
content2 -> BlockEndState[style="dashed"];
|
||||||
|
|
||||||
|
StarBlockStartState:altn -> more[label="ε"];
|
||||||
|
more -> BlockEndState[style="dashed"];
|
||||||
|
|
||||||
|
BlockEndState:e -> StarLoopbackState:w[label="ε"];
|
||||||
|
StarLoopEntryState:alt1 -> StarBlockStartState[label="ε"];
|
||||||
|
StarLoopEntryState:alt2 -> LoopEndState[label="ε"];
|
||||||
|
StarLoopbackState:n -> StarLoopEntryState:n[label="ε"];
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
digraph "" {
|
||||||
|
graph[fontname="Consolas,Courier";rankdir="LR";pad="0.25"];
|
||||||
|
node[fontname="Consolas,Courier";target="_parent"];
|
||||||
|
edge[fontname="Consolas,Courier"];
|
||||||
|
subgraph cluster0 {
|
||||||
|
subgraph[color="white"];
|
||||||
|
{ node[shape="record"];
|
||||||
|
StarLoopEntryState[URL="../StarLoopEntryState.html";label="{StarLoopEntryState | {<alt1> alt 1 |<alt2> alt 2}}"];
|
||||||
|
StarLoopbackState[URL="../StarLoopbackState.html"];
|
||||||
|
StarBlockStartState[URL="../StarBlockStartState.html";label="{StarBlockStartState | {<alt1> alt 1 |<alt2> alt 2 | ·\n·\n· |<altn> alt n}}"];
|
||||||
|
BlockEndState[URL="../BlockEndState.html"];
|
||||||
|
|
||||||
|
{ rank="sink";
|
||||||
|
LoopEndState[URL="../LoopEndState.html";rank="max"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{ node[style="dashed"];
|
||||||
|
content1[label="alt 1"];
|
||||||
|
content2[label="alt 2"];
|
||||||
|
more[label="alt n"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{ node[style="dashed"];
|
||||||
|
begin;
|
||||||
|
end;
|
||||||
|
}
|
||||||
|
|
||||||
|
begin -> StarLoopEntryState[style="dashed"];
|
||||||
|
LoopEndState -> end[label="ε"];
|
||||||
|
|
||||||
|
StarBlockStartState:alt1 -> content1[label="ε"];
|
||||||
|
content1 -> BlockEndState[style="dashed"];
|
||||||
|
|
||||||
|
StarBlockStartState:alt2 -> content2[label="ε"];
|
||||||
|
content2 -> BlockEndState[style="dashed"];
|
||||||
|
|
||||||
|
StarBlockStartState:altn -> more[label="ε"];
|
||||||
|
more -> BlockEndState[style="dashed"];
|
||||||
|
|
||||||
|
BlockEndState:e -> StarLoopbackState:w[label="ε"];
|
||||||
|
StarLoopEntryState:alt2 -> StarBlockStartState[label="ε"];
|
||||||
|
StarLoopEntryState:alt1 -> LoopEndState[label="ε"];
|
||||||
|
StarLoopbackState:s -> StarLoopEntryState:s[label="ε"];
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
digraph "" {
|
||||||
|
graph[fontname="Consolas,Courier";rankdir="LR";pad="0.25"];
|
||||||
|
node[fontname="Consolas,Courier";target="_parent"];
|
||||||
|
edge[fontname="Consolas,Courier"];
|
||||||
|
subgraph cluster0 {
|
||||||
|
subgraph[color="white"];
|
||||||
|
{ node[shape="record"];
|
||||||
|
BasicBlockStartState[URL="../BasicBlockStartState.html";label="{BasicBlockStartState | {<alt1> alt 1 |<alt2> alt 2}}"];
|
||||||
|
BlockEndState[URL="../BlockEndState.html"];
|
||||||
|
}
|
||||||
|
|
||||||
|
{ node[style="dashed"];
|
||||||
|
content[label="alt"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{ node[style="dashed"];
|
||||||
|
begin;
|
||||||
|
end;
|
||||||
|
}
|
||||||
|
|
||||||
|
begin -> BasicBlockStartState[style="dashed"];
|
||||||
|
BlockEndState -> end[label="ε"];
|
||||||
|
|
||||||
|
BasicBlockStartState:alt1 -> content[label="ε"];
|
||||||
|
content -> BlockEndState[style="dashed"];
|
||||||
|
|
||||||
|
BasicBlockStartState:alt2 -> BlockEndState[label="ε"];
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
digraph "" {
|
||||||
|
graph[fontname="Consolas,Courier";rankdir="LR";pad="0.25"];
|
||||||
|
node[fontname="Consolas,Courier";target="_parent"];
|
||||||
|
edge[fontname="Consolas,Courier"];
|
||||||
|
subgraph cluster0 {
|
||||||
|
subgraph[color="white"];
|
||||||
|
{ node[shape="record"];
|
||||||
|
BasicBlockStartState[URL="../BasicBlockStartState.html";label="{BasicBlockStartState | {<alt1> alt 1 |<alt2> alt 2}}"];
|
||||||
|
BlockEndState[URL="../BlockEndState.html"];
|
||||||
|
}
|
||||||
|
|
||||||
|
{ node[style="dashed"];
|
||||||
|
content[label="alt"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{ node[style="dashed"];
|
||||||
|
begin;
|
||||||
|
end;
|
||||||
|
}
|
||||||
|
|
||||||
|
begin -> BasicBlockStartState[style="dashed"];
|
||||||
|
BlockEndState -> end[label="ε"];
|
||||||
|
|
||||||
|
BasicBlockStartState:alt2 -> content[label="ε"];
|
||||||
|
content -> BlockEndState[style="dashed"];
|
||||||
|
|
||||||
|
BasicBlockStartState:alt1 -> BlockEndState[label="ε"];
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
digraph "" {
|
||||||
|
graph[fontname="Consolas,Courier";rankdir="LR";pad="0.25"];
|
||||||
|
node[fontname="Consolas,Courier";target="_parent"];
|
||||||
|
edge[fontname="Consolas,Courier"];
|
||||||
|
subgraph cluster0 {
|
||||||
|
subgraph[color="white"];
|
||||||
|
{ node[shape="record"];
|
||||||
|
{ rank="source";
|
||||||
|
PlusBlockStartState[URL="../PlusBlockStartState.html";label="{PlusBlockStartState | {<alt1> alt 1 |<alt2> alt 2 | ·\n·\n· |<altn> alt n}}"];
|
||||||
|
}
|
||||||
|
|
||||||
|
PlusLoopbackState[URL="../PlusLoopbackState.html";label="{PlusLoopbackState | {<alt1> alt 1 |<alt2> alt 2}}"];
|
||||||
|
BlockEndState[URL="../BlockEndState.html"];
|
||||||
|
|
||||||
|
{ rank="sink";
|
||||||
|
LoopEndState[URL="../LoopEndState.html"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{ node[style="dashed"];
|
||||||
|
content1[label="alt 1"];
|
||||||
|
content2[label="alt 2"];
|
||||||
|
more[label="alt n"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{ node[style="dashed"];
|
||||||
|
begin;
|
||||||
|
end;
|
||||||
|
}
|
||||||
|
|
||||||
|
begin -> PlusBlockStartState[style="dashed"];
|
||||||
|
LoopEndState -> end[label="ε"];
|
||||||
|
|
||||||
|
PlusBlockStartState:alt1 -> content1[label="ε"];
|
||||||
|
content1 -> BlockEndState[style="dashed"];
|
||||||
|
|
||||||
|
PlusBlockStartState:alt2 -> content2[label="ε"];
|
||||||
|
content2 -> BlockEndState[style="dashed"];
|
||||||
|
|
||||||
|
PlusBlockStartState:altn -> more[label="ε"];
|
||||||
|
more -> BlockEndState[style="dashed"];
|
||||||
|
|
||||||
|
BlockEndState -> PlusLoopbackState[label="ε"];
|
||||||
|
PlusLoopbackState:alt1:n -> PlusBlockStartState:n[label="ε"];
|
||||||
|
PlusLoopbackState:alt2 -> LoopEndState[label="ε"];
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
digraph "" {
|
||||||
|
graph[fontname="Consolas,Courier";rankdir="LR";pad="0.25"];
|
||||||
|
node[fontname="Consolas,Courier";target="_parent"];
|
||||||
|
edge[fontname="Consolas,Courier"];
|
||||||
|
subgraph cluster0 {
|
||||||
|
subgraph[color="white"];
|
||||||
|
{ node[shape="record"];
|
||||||
|
{ rank="source";
|
||||||
|
PlusBlockStartState[URL="../PlusBlockStartState.html";label="{PlusBlockStartState | {<alt1> alt 1 |<alt2> alt 2 | ·\n·\n· |<altn> alt n}}"];
|
||||||
|
}
|
||||||
|
|
||||||
|
PlusLoopbackState[URL="../PlusLoopbackState.html";label="{PlusLoopbackState | {<alt1> alt 1 |<alt2> alt 2}}"];
|
||||||
|
BlockEndState[URL="../BlockEndState.html"];
|
||||||
|
|
||||||
|
{ rank="sink";
|
||||||
|
LoopEndState[URL="../LoopEndState.html"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{ node[style="dashed"];
|
||||||
|
content1[label="alt 1"];
|
||||||
|
content2[label="alt 2"];
|
||||||
|
more[label="alt n"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{ node[style="dashed"];
|
||||||
|
begin;
|
||||||
|
end;
|
||||||
|
}
|
||||||
|
|
||||||
|
begin -> PlusBlockStartState[style="dashed"];
|
||||||
|
LoopEndState -> end[label="ε"];
|
||||||
|
|
||||||
|
PlusBlockStartState:alt1 -> content1[label="ε"];
|
||||||
|
content1 -> BlockEndState[style="dashed"];
|
||||||
|
|
||||||
|
PlusBlockStartState:alt2 -> content2[label="ε"];
|
||||||
|
content2 -> BlockEndState[style="dashed"];
|
||||||
|
|
||||||
|
PlusBlockStartState:altn -> more[label="ε"];
|
||||||
|
more -> BlockEndState[style="dashed"];
|
||||||
|
|
||||||
|
BlockEndState -> PlusLoopbackState[label="ε"];
|
||||||
|
PlusLoopbackState:alt2:s -> PlusBlockStartState:s[label="ε"];
|
||||||
|
PlusLoopbackState:alt1 -> LoopEndState[label="ε"];
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
digraph "" {
|
||||||
|
graph[fontname="Consolas,Courier";rankdir="LR";pad="0.25"];
|
||||||
|
node[fontname="Consolas,Courier";target="_parent"];
|
||||||
|
edge[fontname="Consolas,Courier"];
|
||||||
|
{ node[shape="box"];
|
||||||
|
RuleStartState[URL="../RuleStartState.html"];
|
||||||
|
RuleStopState[URL="../RuleStopState.html"];
|
||||||
|
}
|
||||||
|
{ node[style="dashed"];
|
||||||
|
content;
|
||||||
|
}
|
||||||
|
|
||||||
|
RuleStartState -> content[label="ε"];
|
||||||
|
content -> RuleStopState[style="dashed"];
|
||||||
|
}
|
|
@ -35,10 +35,60 @@ import org.antlr.v4.runtime.misc.IntervalSet;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The following images show the relation of states and
|
||||||
|
* {@link ATNState#transitions} for various grammar constructs.
|
||||||
|
*
|
||||||
|
* <ul>
|
||||||
|
* <li>Solid edges marked with an ε indicate a required
|
||||||
|
* {@link EpsilonTransition}.</li>
|
||||||
|
* <li>Dashed edges indicate locations where any transition derived from
|
||||||
|
* {@link Transition} might appear.</li>
|
||||||
|
* <li>Dashed nodes are place holders for either a sequence of linked
|
||||||
|
* {@link BasicState} states or the inclusion of a block representing a nested
|
||||||
|
* construct in one of the forms below.</li>
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* <h2>Basic Blocks</h2>
|
||||||
|
*
|
||||||
|
* <h3>Rule</h3>
|
||||||
|
*
|
||||||
|
* <embed src="images/Rule.svg" type="image/svg+xml"/>
|
||||||
|
*
|
||||||
|
* <h3>Block of 1 or more alternatives</h3>
|
||||||
|
*
|
||||||
|
* <embed src="images/Block.svg" type="image/svg+xml"/>
|
||||||
|
*
|
||||||
|
* <h2>Greedy Loops</h2>
|
||||||
|
*
|
||||||
|
* <h3>Greedy Closure: {@code (...)*}</h3>
|
||||||
|
*
|
||||||
|
* <embed src="images/ClosureGreedy.svg" type="image/svg+xml"/>
|
||||||
|
*
|
||||||
|
* <h3>Greedy Positive Closure: {@code (...)+}</h3>
|
||||||
|
*
|
||||||
|
* <embed src="images/PositiveClosureGreedy.svg" type="image/svg+xml"/>
|
||||||
|
*
|
||||||
|
* <h3>Greedy Optional: {@code (...)?}</h3>
|
||||||
|
*
|
||||||
|
* <embed src="images/OptionalGreedy.svg" type="image/svg+xml"/>
|
||||||
|
*
|
||||||
|
* <h2>Non-Greedy Loops</h2>
|
||||||
|
*
|
||||||
|
* <h3>Non-Greedy Closure: {@code (...)*?}</h3>
|
||||||
|
*
|
||||||
|
* <embed src="images/ClosureNonGreedy.svg" type="image/svg+xml"/>
|
||||||
|
*
|
||||||
|
* <h3>Non-Greedy Positive Closure: {@code (...)+?}</h3>
|
||||||
|
*
|
||||||
|
* <embed src="images/PositiveClosureNonGreedy.svg" type="image/svg+xml"/>
|
||||||
|
*
|
||||||
|
* <h3>Non-Greedy Optional: {@code (...)??}</h3>
|
||||||
|
*
|
||||||
|
* <embed src="images/OptionalNonGreedy.svg" type="image/svg+xml"/>
|
||||||
|
*/
|
||||||
public abstract class ATNState {
|
public abstract class ATNState {
|
||||||
public static final int INITIAL_NUM_TRANSITIONS = 4;
|
public static final int INITIAL_NUM_TRANSITIONS = 4;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue