From 80fa3383fd03895cca85552124dd62c348387110 Mon Sep 17 00:00:00 2001
From: Robin Jadoul <robin.jadoul@gmail.com>
Date: Sun, 29 May 2016 13:14:08 +0200
Subject: [PATCH] Add more accepting state information to dot output

---
 src/automata.cpp | 39 ++++++++++++++++++++++++---------------
 1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/src/automata.cpp b/src/automata.cpp
index 88fd8c2..fd1d6d4 100644
--- a/src/automata.cpp
+++ b/src/automata.cpp
@@ -14,12 +14,15 @@ namespace lxs {
 
         for (State state = 0; state < d.numStates; state++)
         {
-            s += std::to_string(state) + " [label=\"" + std::to_string(state) + "\"";
+            std::string label = std::to_string(state);
+            s += std::to_string(state) + " [";
             if (state == d.starting)
-                s += " color=yellow";
-            if (d.accepting.count(state) > 0)
-                s += " color=green shape=doublecircle";
-            s += "]\n";
+                s += "color=yellow";
+            if (d.accepting.count(state) > 0) {
+                s += "color=green shape=doublecircle";
+                label += "\\np=" + std::to_string(d.priority.find(state)->second) + "\\nac=" + d.acceptingToken.find(state)->second;
+            }
+            s += " label=\"" + label + "\"]\n";
         }
 
         for (const auto& tmp : d.delta)
@@ -41,12 +44,15 @@ namespace lxs {
 
         for (State state = 0; state < n.numStates; state++)
         {
-            s += std::to_string(state) + " [label=\"" + std::to_string(state) + "\"";
+            std::string label = std::to_string(state);
+            s += std::to_string(state) + " [";
             if (state == n.starting)
-                s += " color=yellow";
-            if (n.accepting.count(state) > 0)
-                s += " color=green shape=doublecircle";
-            s += "]\n";
+                s += "color=yellow";
+            if (n.accepting.count(state) > 0) {
+                s += "color=green shape=doublecircle";
+                label += "\\np=" + std::to_string(n.priority.find(state)->second) + "\\nac=" + n.acceptingToken.find(state)->second;
+            }
+            s += " label=\"" + label + "\"]\n";
         }
 
         for (const auto& tmp : n.delta)
@@ -69,12 +75,15 @@ namespace lxs {
 
         for (State state = 0; state < e.numStates; state++)
         {
-            s += std::to_string(state) + " [label=\"" + std::to_string(state) + "\"";
+            std::string label = std::to_string(state);
+            s += std::to_string(state) + " [";
             if (state == e.starting)
-                s += " color=yellow";
-            if (e.accepting.count(state) > 0)
-                s += " color=green shape=doublecircle";
-            s += "]\n";
+                s += "color=yellow";
+            if (e.accepting.count(state) > 0) {
+                s += "color=green shape=doublecircle";
+                label += "\\np=" + std::to_string(e.priority.find(state)->second) + "\\nac=" + e.acceptingToken.find(state)->second;
+            }
+            s += " label=\"" + label + "\"]\n";
         }
 
         for (const auto& tmp : e.delta)