# Generated from \DOT.g4 by ANTLR 4.8
# encoding: utf-8
from antlr4 import *
from io import StringIO
import sys
if sys.version_info[1] > 5:
    from typing import TextIO
else:
    from typing.io import TextIO


def serializedATN():
    with StringIO() as buf:
        buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\35")
        buf.write("\u008a\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7")
        buf.write("\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r\t\r\4\16")
        buf.write("\t\16\4\17\t\17\4\20\t\20\3\2\5\2\"\n\2\3\2\3\2\5\2&\n")
        buf.write("\2\3\2\3\2\3\2\3\2\3\3\3\3\5\3.\n\3\7\3\60\n\3\f\3\16")
        buf.write("\3\63\13\3\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\5\4=\n\4\3")
        buf.write("\5\3\5\3\5\3\6\3\6\5\6D\n\6\3\6\6\6G\n\6\r\6\16\6H\3\7")
        buf.write("\3\7\3\7\5\7N\n\7\3\7\5\7Q\n\7\6\7S\n\7\r\7\16\7T\3\b")
        buf.write("\3\b\5\bY\n\b\3\b\3\b\5\b]\n\b\3\t\3\t\3\t\5\tb\n\t\6")
        buf.write("\td\n\t\r\t\16\te\3\n\3\n\3\13\3\13\5\13l\n\13\3\f\3\f")
        buf.write("\5\fp\n\f\3\r\3\r\3\r\3\r\5\rv\n\r\3\r\3\r\5\rz\n\r\3")
        buf.write("\16\3\16\5\16~\n\16\5\16\u0080\n\16\3\16\3\16\3\16\3\16")
        buf.write("\3\17\3\17\3\20\3\20\3\20\2\2\21\2\4\6\b\n\f\16\20\22")
        buf.write("\24\26\30\32\34\36\2\7\3\2\17\20\4\2\17\17\21\22\3\2\n")
        buf.write("\13\4\2\r\r\31\31\4\2\24\26\31\31\2\u0091\2!\3\2\2\2\4")
        buf.write("\61\3\2\2\2\6<\3\2\2\2\b>\3\2\2\2\nF\3\2\2\2\fR\3\2\2")
        buf.write("\2\16X\3\2\2\2\20c\3\2\2\2\22g\3\2\2\2\24i\3\2\2\2\26")
        buf.write("m\3\2\2\2\30y\3\2\2\2\32\177\3\2\2\2\34\u0085\3\2\2\2")
        buf.write("\36\u0087\3\2\2\2 \"\7\16\2\2! \3\2\2\2!\"\3\2\2\2\"#")
        buf.write("\3\2\2\2#%\t\2\2\2$&\5\36\20\2%$\3\2\2\2%&\3\2\2\2&\'")
        buf.write("\3\2\2\2\'(\7\3\2\2()\5\4\3\2)*\7\4\2\2*\3\3\2\2\2+-\5")
        buf.write("\6\4\2,.\7\5\2\2-,\3\2\2\2-.\3\2\2\2.\60\3\2\2\2/+\3\2")
        buf.write("\2\2\60\63\3\2\2\2\61/\3\2\2\2\61\62\3\2\2\2\62\5\3\2")
        buf.write("\2\2\63\61\3\2\2\2\64=\5\24\13\2\65=\5\16\b\2\66=\5\b")
        buf.write("\5\2\678\5\36\20\289\7\6\2\29:\5\36\20\2:=\3\2\2\2;=\5")
        buf.write("\32\16\2<\64\3\2\2\2<\65\3\2\2\2<\66\3\2\2\2<\67\3\2\2")
        buf.write("\2<;\3\2\2\2=\7\3\2\2\2>?\t\3\2\2?@\5\n\6\2@\t\3\2\2\2")
        buf.write("AC\7\7\2\2BD\5\f\7\2CB\3\2\2\2CD\3\2\2\2DE\3\2\2\2EG\7")
        buf.write("\b\2\2FA\3\2\2\2GH\3\2\2\2HF\3\2\2\2HI\3\2\2\2I\13\3\2")
        buf.write("\2\2JM\5\36\20\2KL\7\6\2\2LN\5\36\20\2MK\3\2\2\2MN\3\2")
        buf.write("\2\2NP\3\2\2\2OQ\7\t\2\2PO\3\2\2\2PQ\3\2\2\2QS\3\2\2\2")
        buf.write("RJ\3\2\2\2ST\3\2\2\2TR\3\2\2\2TU\3\2\2\2U\r\3\2\2\2VY")
        buf.write("\5\26\f\2WY\5\32\16\2XV\3\2\2\2XW\3\2\2\2YZ\3\2\2\2Z\\")
        buf.write("\5\20\t\2[]\5\n\6\2\\[\3\2\2\2\\]\3\2\2\2]\17\3\2\2\2")
        buf.write("^a\5\22\n\2_b\5\26\f\2`b\5\32\16\2a_\3\2\2\2a`\3\2\2\2")
        buf.write("bd\3\2\2\2c^\3\2\2\2de\3\2\2\2ec\3\2\2\2ef\3\2\2\2f\21")
        buf.write("\3\2\2\2gh\t\4\2\2h\23\3\2\2\2ik\5\26\f\2jl\5\n\6\2kj")
        buf.write("\3\2\2\2kl\3\2\2\2l\25\3\2\2\2mo\5\36\20\2np\5\30\r\2")
        buf.write("on\3\2\2\2op\3\2\2\2p\27\3\2\2\2qr\7\f\2\2ru\5\36\20\2")
        buf.write("st\7\f\2\2tv\5\34\17\2us\3\2\2\2uv\3\2\2\2vz\3\2\2\2w")
        buf.write("x\7\f\2\2xz\5\34\17\2yq\3\2\2\2yw\3\2\2\2z\31\3\2\2\2")
        buf.write("{}\7\23\2\2|~\5\36\20\2}|\3\2\2\2}~\3\2\2\2~\u0080\3\2")
        buf.write("\2\2\177{\3\2\2\2\177\u0080\3\2\2\2\u0080\u0081\3\2\2")
        buf.write("\2\u0081\u0082\7\3\2\2\u0082\u0083\5\4\3\2\u0083\u0084")
        buf.write("\7\4\2\2\u0084\33\3\2\2\2\u0085\u0086\t\5\2\2\u0086\35")
        buf.write("\3\2\2\2\u0087\u0088\t\6\2\2\u0088\37\3\2\2\2\26!%-\61")
        buf.write("<CHMPTX\\aekouy}\177")
        return buf.getvalue()


class DOTParser (Parser):

    grammarFileName = "DOT.g4"

    atn = ATNDeserializer().deserialize(serializedATN())

    decisionsToDFA = [DFA(ds, i) for i, ds in enumerate(atn.decisionToState)]

    sharedContextCache = PredictionContextCache()

    literalNames = ["<INVALID>", "'{'", "'}'", "';'", "'='", "'['", "']'",
                    "','", "'->'", "'--'", "':'", "'_'"]

    symbolicNames = ["<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
                     "STRICT", "GRAPH", "DIGRAPH", "NODE", "EDGE", "SUBGRAPH",
                     "NUMBER", "STRING", "HTML_STRING", "TAG", "EntityRef",
                     "ID", "COMMENT", "LINE_COMMENT", "PREPROC", "WS"]

    RULE_graph = 0
    RULE_stmt_list = 1
    RULE_stmt = 2
    RULE_attr_stmt = 3
    RULE_attr_list = 4
    RULE_a_list = 5
    RULE_edge_stmt = 6
    RULE_edgeRHS = 7
    RULE_edgeop = 8
    RULE_node_stmt = 9
    RULE_node_id = 10
    RULE_port = 11
    RULE_subgraph = 12
    RULE_compass_pt = 13
    RULE_gid = 14

    ruleNames = ["graph", "stmt_list", "stmt", "attr_stmt", "attr_list",
                 "a_list", "edge_stmt", "edgeRHS", "edgeop", "node_stmt",
                 "node_id", "port", "subgraph", "compass_pt", "gid"]

    EOF = Token.EOF
    T__0 = 1
    T__1 = 2
    T__2 = 3
    T__3 = 4
    T__4 = 5
    T__5 = 6
    T__6 = 7
    T__7 = 8
    T__8 = 9
    T__9 = 10
    T__10 = 11
    STRICT = 12
    GRAPH = 13
    DIGRAPH = 14
    NODE = 15
    EDGE = 16
    SUBGRAPH = 17
    NUMBER = 18
    STRING = 19
    HTML_STRING = 20
    TAG = 21
    EntityRef = 22
    ID = 23
    COMMENT = 24
    LINE_COMMENT = 25
    PREPROC = 26
    WS = 27

    def __init__(self, input: TokenStream, output: TextIO = sys.stdout):
        super().__init__(input, output)
        self.checkVersion("4.8")
        self._interp = ParserATNSimulator(
            self, self.atn, self.decisionsToDFA, self.sharedContextCache)
        self._predicates = None

    class GraphContext(ParserRuleContext):

        def __init__(self, parser, parent: ParserRuleContext = None, invokingState: int = -1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def stmt_list(self):
            return self.getTypedRuleContext(DOTParser.Stmt_listContext, 0)

        def GRAPH(self):
            return self.getToken(DOTParser.GRAPH, 0)

        def DIGRAPH(self):
            return self.getToken(DOTParser.DIGRAPH, 0)

        def STRICT(self):
            return self.getToken(DOTParser.STRICT, 0)

        def gid(self):
            return self.getTypedRuleContext(DOTParser.GidContext, 0)

        def getRuleIndex(self):
            return DOTParser.RULE_graph

        def enterRule(self, listener: ParseTreeListener):
            if hasattr(listener, "enterGraph"):
                listener.enterGraph(self)

        def exitRule(self, listener: ParseTreeListener):
            if hasattr(listener, "exitGraph"):
                listener.exitGraph(self)

    def graph(self):

        localctx = DOTParser.GraphContext(self, self._ctx, self.state)
        self.enterRule(localctx, 0, self.RULE_graph)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 31
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la == DOTParser.STRICT:
                self.state = 30
                self.match(DOTParser.STRICT)

            self.state = 33
            _la = self._input.LA(1)
            if not(_la == DOTParser.GRAPH or _la == DOTParser.DIGRAPH):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
            self.state = 35
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << DOTParser.NUMBER) | (1 << DOTParser.STRING) | (1 << DOTParser.HTML_STRING) | (1 << DOTParser.ID))) != 0):
                self.state = 34
                self.gid()

            self.state = 37
            self.match(DOTParser.T__0)
            self.state = 38
            self.stmt_list()
            self.state = 39
            self.match(DOTParser.T__1)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class Stmt_listContext(ParserRuleContext):

        def __init__(self, parser, parent: ParserRuleContext = None, invokingState: int = -1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def stmt(self, i: int = None):
            if i is None:
                return self.getTypedRuleContexts(DOTParser.StmtContext)
            else:
                return self.getTypedRuleContext(DOTParser.StmtContext, i)

        def getRuleIndex(self):
            return DOTParser.RULE_stmt_list

        def enterRule(self, listener: ParseTreeListener):
            if hasattr(listener, "enterStmt_list"):
                listener.enterStmt_list(self)

        def exitRule(self, listener: ParseTreeListener):
            if hasattr(listener, "exitStmt_list"):
                listener.exitStmt_list(self)

    def stmt_list(self):

        localctx = DOTParser.Stmt_listContext(self, self._ctx, self.state)
        self.enterRule(localctx, 2, self.RULE_stmt_list)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 47
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << DOTParser.T__0) | (1 << DOTParser.GRAPH) | (1 << DOTParser.NODE) | (1 << DOTParser.EDGE) | (1 << DOTParser.SUBGRAPH) | (1 << DOTParser.NUMBER) | (1 << DOTParser.STRING) | (1 << DOTParser.HTML_STRING) | (1 << DOTParser.ID))) != 0):
                self.state = 41
                self.stmt()
                self.state = 43
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la == DOTParser.T__2:
                    self.state = 42
                    self.match(DOTParser.T__2)

                self.state = 49
                self._errHandler.sync(self)
                _la = self._input.LA(1)

        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class StmtContext(ParserRuleContext):

        def __init__(self, parser, parent: ParserRuleContext = None, invokingState: int = -1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def node_stmt(self):
            return self.getTypedRuleContext(DOTParser.Node_stmtContext, 0)

        def edge_stmt(self):
            return self.getTypedRuleContext(DOTParser.Edge_stmtContext, 0)

        def attr_stmt(self):
            return self.getTypedRuleContext(DOTParser.Attr_stmtContext, 0)

        def gid(self, i: int = None):
            if i is None:
                return self.getTypedRuleContexts(DOTParser.GidContext)
            else:
                return self.getTypedRuleContext(DOTParser.GidContext, i)

        def subgraph(self):
            return self.getTypedRuleContext(DOTParser.SubgraphContext, 0)

        def getRuleIndex(self):
            return DOTParser.RULE_stmt

        def enterRule(self, listener: ParseTreeListener):
            if hasattr(listener, "enterStmt"):
                listener.enterStmt(self)

        def exitRule(self, listener: ParseTreeListener):
            if hasattr(listener, "exitStmt"):
                listener.exitStmt(self)

    def stmt(self):

        localctx = DOTParser.StmtContext(self, self._ctx, self.state)
        self.enterRule(localctx, 4, self.RULE_stmt)
        try:
            self.state = 58
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input, 4, self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 50
                self.node_stmt()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 51
                self.edge_stmt()
                pass

            elif la_ == 3:
                self.enterOuterAlt(localctx, 3)
                self.state = 52
                self.attr_stmt()
                pass

            elif la_ == 4:
                self.enterOuterAlt(localctx, 4)
                self.state = 53
                self.gid()
                self.state = 54
                self.match(DOTParser.T__3)
                self.state = 55
                self.gid()
                pass

            elif la_ == 5:
                self.enterOuterAlt(localctx, 5)
                self.state = 57
                self.subgraph()
                pass

        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class Attr_stmtContext(ParserRuleContext):

        def __init__(self, parser, parent: ParserRuleContext = None, invokingState: int = -1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def attr_list(self):
            return self.getTypedRuleContext(DOTParser.Attr_listContext, 0)

        def GRAPH(self):
            return self.getToken(DOTParser.GRAPH, 0)

        def NODE(self):
            return self.getToken(DOTParser.NODE, 0)

        def EDGE(self):
            return self.getToken(DOTParser.EDGE, 0)

        def getRuleIndex(self):
            return DOTParser.RULE_attr_stmt

        def enterRule(self, listener: ParseTreeListener):
            if hasattr(listener, "enterAttr_stmt"):
                listener.enterAttr_stmt(self)

        def exitRule(self, listener: ParseTreeListener):
            if hasattr(listener, "exitAttr_stmt"):
                listener.exitAttr_stmt(self)

    def attr_stmt(self):

        localctx = DOTParser.Attr_stmtContext(self, self._ctx, self.state)
        self.enterRule(localctx, 6, self.RULE_attr_stmt)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 60
            _la = self._input.LA(1)
            if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << DOTParser.GRAPH) | (1 << DOTParser.NODE) | (1 << DOTParser.EDGE))) != 0)):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
            self.state = 61
            self.attr_list()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class Attr_listContext(ParserRuleContext):

        def __init__(self, parser, parent: ParserRuleContext = None, invokingState: int = -1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def a_list(self, i: int = None):
            if i is None:
                return self.getTypedRuleContexts(DOTParser.A_listContext)
            else:
                return self.getTypedRuleContext(DOTParser.A_listContext, i)

        def getRuleIndex(self):
            return DOTParser.RULE_attr_list

        def enterRule(self, listener: ParseTreeListener):
            if hasattr(listener, "enterAttr_list"):
                listener.enterAttr_list(self)

        def exitRule(self, listener: ParseTreeListener):
            if hasattr(listener, "exitAttr_list"):
                listener.exitAttr_list(self)

    def attr_list(self):

        localctx = DOTParser.Attr_listContext(self, self._ctx, self.state)
        self.enterRule(localctx, 8, self.RULE_attr_list)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 68
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 63
                self.match(DOTParser.T__4)
                self.state = 65
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << DOTParser.NUMBER) | (1 << DOTParser.STRING) | (1 << DOTParser.HTML_STRING) | (1 << DOTParser.ID))) != 0):
                    self.state = 64
                    self.a_list()

                self.state = 67
                self.match(DOTParser.T__5)
                self.state = 70
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not (_la == DOTParser.T__4):
                    break

        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class A_listContext(ParserRuleContext):

        def __init__(self, parser, parent: ParserRuleContext = None, invokingState: int = -1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def gid(self, i: int = None):
            if i is None:
                return self.getTypedRuleContexts(DOTParser.GidContext)
            else:
                return self.getTypedRuleContext(DOTParser.GidContext, i)

        def getRuleIndex(self):
            return DOTParser.RULE_a_list

        def enterRule(self, listener: ParseTreeListener):
            if hasattr(listener, "enterA_list"):
                listener.enterA_list(self)

        def exitRule(self, listener: ParseTreeListener):
            if hasattr(listener, "exitA_list"):
                listener.exitA_list(self)

    def a_list(self):

        localctx = DOTParser.A_listContext(self, self._ctx, self.state)
        self.enterRule(localctx, 10, self.RULE_a_list)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 80
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 72
                self.gid()
                self.state = 75
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la == DOTParser.T__3:
                    self.state = 73
                    self.match(DOTParser.T__3)
                    self.state = 74
                    self.gid()

                self.state = 78
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la == DOTParser.T__6:
                    self.state = 77
                    self.match(DOTParser.T__6)

                self.state = 82
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << DOTParser.NUMBER) | (1 << DOTParser.STRING) | (1 << DOTParser.HTML_STRING) | (1 << DOTParser.ID))) != 0)):
                    break

        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class Edge_stmtContext(ParserRuleContext):

        def __init__(self, parser, parent: ParserRuleContext = None, invokingState: int = -1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def edgeRHS(self):
            return self.getTypedRuleContext(DOTParser.EdgeRHSContext, 0)

        def node_id(self):
            return self.getTypedRuleContext(DOTParser.Node_idContext, 0)

        def subgraph(self):
            return self.getTypedRuleContext(DOTParser.SubgraphContext, 0)

        def attr_list(self):
            return self.getTypedRuleContext(DOTParser.Attr_listContext, 0)

        def getRuleIndex(self):
            return DOTParser.RULE_edge_stmt

        def enterRule(self, listener: ParseTreeListener):
            if hasattr(listener, "enterEdge_stmt"):
                listener.enterEdge_stmt(self)

        def exitRule(self, listener: ParseTreeListener):
            if hasattr(listener, "exitEdge_stmt"):
                listener.exitEdge_stmt(self)

    def edge_stmt(self):

        localctx = DOTParser.Edge_stmtContext(self, self._ctx, self.state)
        self.enterRule(localctx, 12, self.RULE_edge_stmt)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 86
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [DOTParser.NUMBER, DOTParser.STRING, DOTParser.HTML_STRING, DOTParser.ID]:
                self.state = 84
                self.node_id()
                pass
            elif token in [DOTParser.T__0, DOTParser.SUBGRAPH]:
                self.state = 85
                self.subgraph()
                pass
            else:
                raise NoViableAltException(self)

            self.state = 88
            self.edgeRHS()
            self.state = 90
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la == DOTParser.T__4:
                self.state = 89
                self.attr_list()

        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class EdgeRHSContext(ParserRuleContext):

        def __init__(self, parser, parent: ParserRuleContext = None, invokingState: int = -1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def edgeop(self, i: int = None):
            if i is None:
                return self.getTypedRuleContexts(DOTParser.EdgeopContext)
            else:
                return self.getTypedRuleContext(DOTParser.EdgeopContext, i)

        def node_id(self, i: int = None):
            if i is None:
                return self.getTypedRuleContexts(DOTParser.Node_idContext)
            else:
                return self.getTypedRuleContext(DOTParser.Node_idContext, i)

        def subgraph(self, i: int = None):
            if i is None:
                return self.getTypedRuleContexts(DOTParser.SubgraphContext)
            else:
                return self.getTypedRuleContext(DOTParser.SubgraphContext, i)

        def getRuleIndex(self):
            return DOTParser.RULE_edgeRHS

        def enterRule(self, listener: ParseTreeListener):
            if hasattr(listener, "enterEdgeRHS"):
                listener.enterEdgeRHS(self)

        def exitRule(self, listener: ParseTreeListener):
            if hasattr(listener, "exitEdgeRHS"):
                listener.exitEdgeRHS(self)

    def edgeRHS(self):

        localctx = DOTParser.EdgeRHSContext(self, self._ctx, self.state)
        self.enterRule(localctx, 14, self.RULE_edgeRHS)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 97
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 92
                self.edgeop()
                self.state = 95
                self._errHandler.sync(self)
                token = self._input.LA(1)
                if token in [DOTParser.NUMBER, DOTParser.STRING, DOTParser.HTML_STRING, DOTParser.ID]:
                    self.state = 93
                    self.node_id()
                    pass
                elif token in [DOTParser.T__0, DOTParser.SUBGRAPH]:
                    self.state = 94
                    self.subgraph()
                    pass
                else:
                    raise NoViableAltException(self)

                self.state = 99
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not (_la == DOTParser.T__7 or _la == DOTParser.T__8):
                    break

        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class EdgeopContext(ParserRuleContext):

        def __init__(self, parser, parent: ParserRuleContext = None, invokingState: int = -1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def getRuleIndex(self):
            return DOTParser.RULE_edgeop

        def enterRule(self, listener: ParseTreeListener):
            if hasattr(listener, "enterEdgeop"):
                listener.enterEdgeop(self)

        def exitRule(self, listener: ParseTreeListener):
            if hasattr(listener, "exitEdgeop"):
                listener.exitEdgeop(self)

    def edgeop(self):

        localctx = DOTParser.EdgeopContext(self, self._ctx, self.state)
        self.enterRule(localctx, 16, self.RULE_edgeop)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 101
            _la = self._input.LA(1)
            if not(_la == DOTParser.T__7 or _la == DOTParser.T__8):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class Node_stmtContext(ParserRuleContext):

        def __init__(self, parser, parent: ParserRuleContext = None, invokingState: int = -1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def node_id(self):
            return self.getTypedRuleContext(DOTParser.Node_idContext, 0)

        def attr_list(self):
            return self.getTypedRuleContext(DOTParser.Attr_listContext, 0)

        def getRuleIndex(self):
            return DOTParser.RULE_node_stmt

        def enterRule(self, listener: ParseTreeListener):
            if hasattr(listener, "enterNode_stmt"):
                listener.enterNode_stmt(self)

        def exitRule(self, listener: ParseTreeListener):
            if hasattr(listener, "exitNode_stmt"):
                listener.exitNode_stmt(self)

    def node_stmt(self):

        localctx = DOTParser.Node_stmtContext(self, self._ctx, self.state)
        self.enterRule(localctx, 18, self.RULE_node_stmt)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 103
            self.node_id()
            self.state = 105
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la == DOTParser.T__4:
                self.state = 104
                self.attr_list()

        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class Node_idContext(ParserRuleContext):

        def __init__(self, parser, parent: ParserRuleContext = None, invokingState: int = -1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def gid(self):
            return self.getTypedRuleContext(DOTParser.GidContext, 0)

        def port(self):
            return self.getTypedRuleContext(DOTParser.PortContext, 0)

        def getRuleIndex(self):
            return DOTParser.RULE_node_id

        def enterRule(self, listener: ParseTreeListener):
            if hasattr(listener, "enterNode_id"):
                listener.enterNode_id(self)

        def exitRule(self, listener: ParseTreeListener):
            if hasattr(listener, "exitNode_id"):
                listener.exitNode_id(self)

    def node_id(self):

        localctx = DOTParser.Node_idContext(self, self._ctx, self.state)
        self.enterRule(localctx, 20, self.RULE_node_id)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 107
            self.gid()
            self.state = 109
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la == DOTParser.T__9:
                self.state = 108
                self.port()

        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class PortContext(ParserRuleContext):

        def __init__(self, parser, parent: ParserRuleContext = None, invokingState: int = -1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def gid(self):
            return self.getTypedRuleContext(DOTParser.GidContext, 0)

        def compass_pt(self):
            return self.getTypedRuleContext(DOTParser.Compass_ptContext, 0)

        def getRuleIndex(self):
            return DOTParser.RULE_port

        def enterRule(self, listener: ParseTreeListener):
            if hasattr(listener, "enterPort"):
                listener.enterPort(self)

        def exitRule(self, listener: ParseTreeListener):
            if hasattr(listener, "exitPort"):
                listener.exitPort(self)

    def port(self):

        localctx = DOTParser.PortContext(self, self._ctx, self.state)
        self.enterRule(localctx, 22, self.RULE_port)
        self._la = 0  # Token type
        try:
            self.state = 119
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input, 17, self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 111
                self.match(DOTParser.T__9)
                self.state = 112
                self.gid()
                self.state = 115
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la == DOTParser.T__9:
                    self.state = 113
                    self.match(DOTParser.T__9)
                    self.state = 114
                    self.compass_pt()

                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 117
                self.match(DOTParser.T__9)
                self.state = 118
                self.compass_pt()
                pass

        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class SubgraphContext(ParserRuleContext):

        def __init__(self, parser, parent: ParserRuleContext = None, invokingState: int = -1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def stmt_list(self):
            return self.getTypedRuleContext(DOTParser.Stmt_listContext, 0)

        def SUBGRAPH(self):
            return self.getToken(DOTParser.SUBGRAPH, 0)

        def gid(self):
            return self.getTypedRuleContext(DOTParser.GidContext, 0)

        def getRuleIndex(self):
            return DOTParser.RULE_subgraph

        def enterRule(self, listener: ParseTreeListener):
            if hasattr(listener, "enterSubgraph"):
                listener.enterSubgraph(self)

        def exitRule(self, listener: ParseTreeListener):
            if hasattr(listener, "exitSubgraph"):
                listener.exitSubgraph(self)

    def subgraph(self):

        localctx = DOTParser.SubgraphContext(self, self._ctx, self.state)
        self.enterRule(localctx, 24, self.RULE_subgraph)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 125
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la == DOTParser.SUBGRAPH:
                self.state = 121
                self.match(DOTParser.SUBGRAPH)
                self.state = 123
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << DOTParser.NUMBER) | (1 << DOTParser.STRING) | (1 << DOTParser.HTML_STRING) | (1 << DOTParser.ID))) != 0):
                    self.state = 122
                    self.gid()

            self.state = 127
            self.match(DOTParser.T__0)
            self.state = 128
            self.stmt_list()
            self.state = 129
            self.match(DOTParser.T__1)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class Compass_ptContext(ParserRuleContext):

        def __init__(self, parser, parent: ParserRuleContext = None, invokingState: int = -1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def ID(self):
            return self.getToken(DOTParser.ID, 0)

        def getRuleIndex(self):
            return DOTParser.RULE_compass_pt

        def enterRule(self, listener: ParseTreeListener):
            if hasattr(listener, "enterCompass_pt"):
                listener.enterCompass_pt(self)

        def exitRule(self, listener: ParseTreeListener):
            if hasattr(listener, "exitCompass_pt"):
                listener.exitCompass_pt(self)

    def compass_pt(self):

        localctx = DOTParser.Compass_ptContext(self, self._ctx, self.state)
        self.enterRule(localctx, 26, self.RULE_compass_pt)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 131
            _la = self._input.LA(1)
            if not(_la == DOTParser.T__10 or _la == DOTParser.ID):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class GidContext(ParserRuleContext):

        def __init__(self, parser, parent: ParserRuleContext = None, invokingState: int = -1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def ID(self):
            return self.getToken(DOTParser.ID, 0)

        def STRING(self):
            return self.getToken(DOTParser.STRING, 0)

        def HTML_STRING(self):
            return self.getToken(DOTParser.HTML_STRING, 0)

        def NUMBER(self):
            return self.getToken(DOTParser.NUMBER, 0)

        def getRuleIndex(self):
            return DOTParser.RULE_gid

        def enterRule(self, listener: ParseTreeListener):
            if hasattr(listener, "enterGid"):
                listener.enterGid(self)

        def exitRule(self, listener: ParseTreeListener):
            if hasattr(listener, "exitGid"):
                listener.exitGid(self)

    def gid(self):

        localctx = DOTParser.GidContext(self, self._ctx, self.state)
        self.enterRule(localctx, 28, self.RULE_gid)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 133
            _la = self._input.LA(1)
            if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << DOTParser.NUMBER) | (1 << DOTParser.STRING) | (1 << DOTParser.HTML_STRING) | (1 << DOTParser.ID))) != 0)):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx
