# flake8: noqa
# type: ignore
# Generated from Dot.g4 by ANTLR 4.8
# encoding: utf-8
from ....._vendor.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\32")
        buf.write("\u0082\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\3\2\5\2 \n\2\3\2\3\2\5\2$\n\2\3\2\3\2")
        buf.write("\3\2\3\2\3\3\3\3\5\3,\n\3\7\3.\n\3\f\3\16\3\61\13\3\3")
        buf.write("\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\5\4;\n\4\3\5\3\5\3\5\3")
        buf.write("\6\3\6\5\6B\n\6\3\6\6\6E\n\6\r\6\16\6F\3\7\3\7\3\7\5\7")
        buf.write("L\n\7\3\7\5\7O\n\7\6\7Q\n\7\r\7\16\7R\3\b\3\b\5\bW\n\b")
        buf.write("\3\b\3\b\5\b[\n\b\3\t\3\t\3\t\5\t`\n\t\6\tb\n\t\r\t\16")
        buf.write("\tc\3\n\3\n\3\13\3\13\5\13j\n\13\3\f\3\f\5\fn\n\f\3\r")
        buf.write("\3\r\3\r\3\r\5\rt\n\r\3\16\3\16\5\16x\n\16\5\16z\n\16")
        buf.write("\3\16\3\16\3\16\3\16\3\17\3\17\3\17\2\2\20\2\4\6\b\n\f")
        buf.write("\16\20\22\24\26\30\32\34\2\6\3\2\16\17\4\2\16\16\20\21")
        buf.write("\3\2\n\13\3\2\23\26\2\u0089\2\37\3\2\2\2\4/\3\2\2\2\6")
        buf.write(":\3\2\2\2\b<\3\2\2\2\nD\3\2\2\2\fP\3\2\2\2\16V\3\2\2\2")
        buf.write("\20a\3\2\2\2\22e\3\2\2\2\24g\3\2\2\2\26k\3\2\2\2\30o\3")
        buf.write("\2\2\2\32y\3\2\2\2\34\177\3\2\2\2\36 \7\r\2\2\37\36\3")
        buf.write("\2\2\2\37 \3\2\2\2 !\3\2\2\2!#\t\2\2\2\"$\5\34\17\2#\"")
        buf.write("\3\2\2\2#$\3\2\2\2$%\3\2\2\2%&\7\3\2\2&\'\5\4\3\2\'(\7")
        buf.write("\4\2\2(\3\3\2\2\2)+\5\6\4\2*,\7\5\2\2+*\3\2\2\2+,\3\2")
        buf.write("\2\2,.\3\2\2\2-)\3\2\2\2.\61\3\2\2\2/-\3\2\2\2/\60\3\2")
        buf.write("\2\2\60\5\3\2\2\2\61/\3\2\2\2\62;\5\24\13\2\63;\5\16\b")
        buf.write("\2\64;\5\b\5\2\65\66\5\34\17\2\66\67\7\6\2\2\678\5\34")
        buf.write("\17\28;\3\2\2\29;\5\32\16\2:\62\3\2\2\2:\63\3\2\2\2:\64")
        buf.write("\3\2\2\2:\65\3\2\2\2:9\3\2\2\2;\7\3\2\2\2<=\t\3\2\2=>")
        buf.write("\5\n\6\2>\t\3\2\2\2?A\7\7\2\2@B\5\f\7\2A@\3\2\2\2AB\3")
        buf.write("\2\2\2BC\3\2\2\2CE\7\b\2\2D?\3\2\2\2EF\3\2\2\2FD\3\2\2")
        buf.write("\2FG\3\2\2\2G\13\3\2\2\2HK\5\34\17\2IJ\7\6\2\2JL\5\34")
        buf.write("\17\2KI\3\2\2\2KL\3\2\2\2LN\3\2\2\2MO\7\t\2\2NM\3\2\2")
        buf.write("\2NO\3\2\2\2OQ\3\2\2\2PH\3\2\2\2QR\3\2\2\2RP\3\2\2\2R")
        buf.write("S\3\2\2\2S\r\3\2\2\2TW\5\26\f\2UW\5\32\16\2VT\3\2\2\2")
        buf.write("VU\3\2\2\2WX\3\2\2\2XZ\5\20\t\2Y[\5\n\6\2ZY\3\2\2\2Z[")
        buf.write("\3\2\2\2[\17\3\2\2\2\\_\5\22\n\2]`\5\26\f\2^`\5\32\16")
        buf.write("\2_]\3\2\2\2_^\3\2\2\2`b\3\2\2\2a\\\3\2\2\2bc\3\2\2\2")
        buf.write("ca\3\2\2\2cd\3\2\2\2d\21\3\2\2\2ef\t\4\2\2f\23\3\2\2\2")
        buf.write("gi\5\26\f\2hj\5\n\6\2ih\3\2\2\2ij\3\2\2\2j\25\3\2\2\2")
        buf.write("km\5\34\17\2ln\5\30\r\2ml\3\2\2\2mn\3\2\2\2n\27\3\2\2")
        buf.write("\2op\7\f\2\2ps\5\34\17\2qr\7\f\2\2rt\5\34\17\2sq\3\2\2")
        buf.write("\2st\3\2\2\2t\31\3\2\2\2uw\7\22\2\2vx\5\34\17\2wv\3\2")
        buf.write("\2\2wx\3\2\2\2xz\3\2\2\2yu\3\2\2\2yz\3\2\2\2z{\3\2\2\2")
        buf.write("{|\7\3\2\2|}\5\4\3\2}~\7\4\2\2~\33\3\2\2\2\177\u0080\t")
        buf.write("\5\2\2\u0080\35\3\2\2\2\25\37#+/:AFKNRVZ_cimswy")
        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>", "STRICT", "GRAPH", 
                      "DIGRAPH", "NODE", "EDGE", "SUBGRAPH", "NUMBER", "STRING", 
                      "IDENT", "HTML_STRING", "COMMENT", "LINE_COMMENT", 
                      "PREPROC", "WS" ]

    RULE_graph = 0
    RULE_stmtList = 1
    RULE_stmt = 2
    RULE_attrStmt = 3
    RULE_attrList = 4
    RULE_aList = 5
    RULE_edgeStmt = 6
    RULE_edgeRHS = 7
    RULE_edgeop = 8
    RULE_nodeStmt = 9
    RULE_nodeId = 10
    RULE_port = 11
    RULE_subgraph = 12
    RULE_ident = 13

    ruleNames =  [ "graph", "stmtList", "stmt", "attrStmt", "attrList", 
                   "aList", "edgeStmt", "edgeRHS", "edgeop", "nodeStmt", 
                   "nodeId", "port", "subgraph", "ident" ]

    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
    STRICT=11
    GRAPH=12
    DIGRAPH=13
    NODE=14
    EDGE=15
    SUBGRAPH=16
    NUMBER=17
    STRING=18
    IDENT=19
    HTML_STRING=20
    COMMENT=21
    LINE_COMMENT=22
    PREPROC=23
    WS=24

    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 stmtList(self):
            return self.getTypedRuleContext(DotParser.StmtListContext,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 ident(self):
            return self.getTypedRuleContext(DotParser.IdentContext,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 accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitGraph" ):
                return visitor.visitGraph(self)
            else:
                return visitor.visitChildren(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 = 29
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==DotParser.STRICT:
                self.state = 28
                self.match(DotParser.STRICT)


            self.state = 31
            _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 = 33
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << DotParser.NUMBER) | (1 << DotParser.STRING) | (1 << DotParser.IDENT) | (1 << DotParser.HTML_STRING))) != 0):
                self.state = 32
                self.ident()


            self.state = 35
            self.match(DotParser.T__0)
            self.state = 36
            self.stmtList()
            self.state = 37
            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 StmtListContext(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_stmtList

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

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

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitStmtList" ):
                return visitor.visitStmtList(self)
            else:
                return visitor.visitChildren(self)




    def stmtList(self):

        localctx = DotParser.StmtListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 2, self.RULE_stmtList)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 45
            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.IDENT) | (1 << DotParser.HTML_STRING))) != 0):
                self.state = 39
                self.stmt()
                self.state = 41
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==DotParser.T__2:
                    self.state = 40
                    self.match(DotParser.T__2)


                self.state = 47
                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 nodeStmt(self):
            return self.getTypedRuleContext(DotParser.NodeStmtContext,0)


        def edgeStmt(self):
            return self.getTypedRuleContext(DotParser.EdgeStmtContext,0)


        def attrStmt(self):
            return self.getTypedRuleContext(DotParser.AttrStmtContext,0)


        def ident(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(DotParser.IdentContext)
            else:
                return self.getTypedRuleContext(DotParser.IdentContext,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 accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitStmt" ):
                return visitor.visitStmt(self)
            else:
                return visitor.visitChildren(self)




    def stmt(self):

        localctx = DotParser.StmtContext(self, self._ctx, self.state)
        self.enterRule(localctx, 4, self.RULE_stmt)
        try:
            self.state = 56
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,4,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 48
                self.nodeStmt()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 49
                self.edgeStmt()
                pass

            elif la_ == 3:
                self.enterOuterAlt(localctx, 3)
                self.state = 50
                self.attrStmt()
                pass

            elif la_ == 4:
                self.enterOuterAlt(localctx, 4)
                self.state = 51
                self.ident()
                self.state = 52
                self.match(DotParser.T__3)
                self.state = 53
                self.ident()
                pass

            elif la_ == 5:
                self.enterOuterAlt(localctx, 5)
                self.state = 55
                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 AttrStmtContext(ParserRuleContext):

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

        def attrList(self):
            return self.getTypedRuleContext(DotParser.AttrListContext,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_attrStmt

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

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

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitAttrStmt" ):
                return visitor.visitAttrStmt(self)
            else:
                return visitor.visitChildren(self)




    def attrStmt(self):

        localctx = DotParser.AttrStmtContext(self, self._ctx, self.state)
        self.enterRule(localctx, 6, self.RULE_attrStmt)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 58
            _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 = 59
            self.attrList()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class AttrListContext(ParserRuleContext):

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

        def aList(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(DotParser.AListContext)
            else:
                return self.getTypedRuleContext(DotParser.AListContext,i)


        def getRuleIndex(self):
            return DotParser.RULE_attrList

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

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

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitAttrList" ):
                return visitor.visitAttrList(self)
            else:
                return visitor.visitChildren(self)




    def attrList(self):

        localctx = DotParser.AttrListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 8, self.RULE_attrList)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 66 
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 61
                self.match(DotParser.T__4)
                self.state = 63
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << DotParser.NUMBER) | (1 << DotParser.STRING) | (1 << DotParser.IDENT) | (1 << DotParser.HTML_STRING))) != 0):
                    self.state = 62
                    self.aList()


                self.state = 65
                self.match(DotParser.T__5)
                self.state = 68 
                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 AListContext(ParserRuleContext):

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

        def ident(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(DotParser.IdentContext)
            else:
                return self.getTypedRuleContext(DotParser.IdentContext,i)


        def getRuleIndex(self):
            return DotParser.RULE_aList

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

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

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitAList" ):
                return visitor.visitAList(self)
            else:
                return visitor.visitChildren(self)




    def aList(self):

        localctx = DotParser.AListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 10, self.RULE_aList)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 78 
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 70
                self.ident()
                self.state = 73
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==DotParser.T__3:
                    self.state = 71
                    self.match(DotParser.T__3)
                    self.state = 72
                    self.ident()


                self.state = 76
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==DotParser.T__6:
                    self.state = 75
                    self.match(DotParser.T__6)


                self.state = 80 
                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.IDENT) | (1 << DotParser.HTML_STRING))) != 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 EdgeStmtContext(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 nodeId(self):
            return self.getTypedRuleContext(DotParser.NodeIdContext,0)


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


        def attrList(self):
            return self.getTypedRuleContext(DotParser.AttrListContext,0)


        def getRuleIndex(self):
            return DotParser.RULE_edgeStmt

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

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

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitEdgeStmt" ):
                return visitor.visitEdgeStmt(self)
            else:
                return visitor.visitChildren(self)




    def edgeStmt(self):

        localctx = DotParser.EdgeStmtContext(self, self._ctx, self.state)
        self.enterRule(localctx, 12, self.RULE_edgeStmt)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 84
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [DotParser.NUMBER, DotParser.STRING, DotParser.IDENT, DotParser.HTML_STRING]:
                self.state = 82
                self.nodeId()
                pass
            elif token in [DotParser.T__0, DotParser.SUBGRAPH]:
                self.state = 83
                self.subgraph()
                pass
            else:
                raise NoViableAltException(self)

            self.state = 86
            self.edgeRHS()
            self.state = 88
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==DotParser.T__4:
                self.state = 87
                self.attrList()


        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 nodeId(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(DotParser.NodeIdContext)
            else:
                return self.getTypedRuleContext(DotParser.NodeIdContext,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 accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitEdgeRHS" ):
                return visitor.visitEdgeRHS(self)
            else:
                return visitor.visitChildren(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 = 95 
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 90
                self.edgeop()
                self.state = 93
                self._errHandler.sync(self)
                token = self._input.LA(1)
                if token in [DotParser.NUMBER, DotParser.STRING, DotParser.IDENT, DotParser.HTML_STRING]:
                    self.state = 91
                    self.nodeId()
                    pass
                elif token in [DotParser.T__0, DotParser.SUBGRAPH]:
                    self.state = 92
                    self.subgraph()
                    pass
                else:
                    raise NoViableAltException(self)

                self.state = 97 
                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 accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitEdgeop" ):
                return visitor.visitEdgeop(self)
            else:
                return visitor.visitChildren(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 = 99
            _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 NodeStmtContext(ParserRuleContext):

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

        def nodeId(self):
            return self.getTypedRuleContext(DotParser.NodeIdContext,0)


        def attrList(self):
            return self.getTypedRuleContext(DotParser.AttrListContext,0)


        def getRuleIndex(self):
            return DotParser.RULE_nodeStmt

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

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

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitNodeStmt" ):
                return visitor.visitNodeStmt(self)
            else:
                return visitor.visitChildren(self)




    def nodeStmt(self):

        localctx = DotParser.NodeStmtContext(self, self._ctx, self.state)
        self.enterRule(localctx, 18, self.RULE_nodeStmt)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 101
            self.nodeId()
            self.state = 103
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==DotParser.T__4:
                self.state = 102
                self.attrList()


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


    class NodeIdContext(ParserRuleContext):

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

        def ident(self):
            return self.getTypedRuleContext(DotParser.IdentContext,0)


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


        def getRuleIndex(self):
            return DotParser.RULE_nodeId

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

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

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitNodeId" ):
                return visitor.visitNodeId(self)
            else:
                return visitor.visitChildren(self)




    def nodeId(self):

        localctx = DotParser.NodeIdContext(self, self._ctx, self.state)
        self.enterRule(localctx, 20, self.RULE_nodeId)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 105
            self.ident()
            self.state = 107
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==DotParser.T__9:
                self.state = 106
                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 ident(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(DotParser.IdentContext)
            else:
                return self.getTypedRuleContext(DotParser.IdentContext,i)


        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 accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitPort" ):
                return visitor.visitPort(self)
            else:
                return visitor.visitChildren(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.enterOuterAlt(localctx, 1)
            self.state = 109
            self.match(DotParser.T__9)
            self.state = 110
            self.ident()
            self.state = 113
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==DotParser.T__9:
                self.state = 111
                self.match(DotParser.T__9)
                self.state = 112
                self.ident()


        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 stmtList(self):
            return self.getTypedRuleContext(DotParser.StmtListContext,0)


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

        def ident(self):
            return self.getTypedRuleContext(DotParser.IdentContext,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 accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitSubgraph" ):
                return visitor.visitSubgraph(self)
            else:
                return visitor.visitChildren(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 = 119
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==DotParser.SUBGRAPH:
                self.state = 115
                self.match(DotParser.SUBGRAPH)
                self.state = 117
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << DotParser.NUMBER) | (1 << DotParser.STRING) | (1 << DotParser.IDENT) | (1 << DotParser.HTML_STRING))) != 0):
                    self.state = 116
                    self.ident()




            self.state = 121
            self.match(DotParser.T__0)
            self.state = 122
            self.stmtList()
            self.state = 123
            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 IdentContext(ParserRuleContext):

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

        def IDENT(self):
            return self.getToken(DotParser.IDENT, 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_ident

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

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

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitIdent" ):
                return visitor.visitIdent(self)
            else:
                return visitor.visitChildren(self)




    def ident(self):

        localctx = DotParser.IdentContext(self, self._ctx, self.state)
        self.enterRule(localctx, 26, self.RULE_ident)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 125
            _la = self._input.LA(1)
            if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << DotParser.NUMBER) | (1 << DotParser.STRING) | (1 << DotParser.IDENT) | (1 << DotParser.HTML_STRING))) != 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
