# Generated from Depsearch.g4 by ANTLR 4.13.2
# 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():
    return [
        4,1,18,130,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,
        6,2,7,7,7,2,8,7,8,2,9,7,9,1,0,3,0,22,8,0,1,0,1,0,1,0,5,0,27,8,0,
        10,0,12,0,30,9,0,1,0,1,0,1,1,1,1,1,1,1,2,1,2,1,2,1,2,1,2,1,2,1,2,
        1,2,3,2,45,8,2,1,2,1,2,1,2,1,2,4,2,51,8,2,11,2,12,2,52,1,2,3,2,56,
        8,2,1,2,1,2,1,2,1,2,1,2,1,2,5,2,64,8,2,10,2,12,2,67,9,2,1,3,1,3,
        1,3,3,3,72,8,3,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,3,4,85,
        8,4,3,4,87,8,4,1,5,1,5,1,5,1,6,1,6,1,6,1,6,3,6,96,8,6,1,6,1,6,1,
        6,5,6,101,8,6,10,6,12,6,104,9,6,1,7,1,7,1,7,1,7,1,7,1,7,3,7,112,
        8,7,1,7,3,7,115,8,7,1,7,3,7,118,8,7,3,7,120,8,7,1,8,1,8,3,8,124,
        8,8,1,9,1,9,3,9,128,8,9,1,9,0,2,4,12,10,0,2,4,6,8,10,12,14,16,18,
        0,0,142,0,21,1,0,0,0,2,33,1,0,0,0,4,55,1,0,0,0,6,71,1,0,0,0,8,86,
        1,0,0,0,10,88,1,0,0,0,12,95,1,0,0,0,14,119,1,0,0,0,16,123,1,0,0,
        0,18,127,1,0,0,0,20,22,3,2,1,0,21,20,1,0,0,0,21,22,1,0,0,0,22,23,
        1,0,0,0,23,28,3,4,2,0,24,25,5,1,0,0,25,27,3,4,2,0,26,24,1,0,0,0,
        27,30,1,0,0,0,28,26,1,0,0,0,28,29,1,0,0,0,29,31,1,0,0,0,30,28,1,
        0,0,0,31,32,5,0,0,1,32,1,1,0,0,0,33,34,3,8,4,0,34,35,5,2,0,0,35,
        3,1,0,0,0,36,37,6,2,-1,0,37,38,3,8,4,0,38,39,5,5,0,0,39,40,3,8,4,
        0,40,56,1,0,0,0,41,42,3,8,4,0,42,44,5,14,0,0,43,45,3,18,9,0,44,43,
        1,0,0,0,44,45,1,0,0,0,45,46,1,0,0,0,46,47,3,8,4,0,47,56,1,0,0,0,
        48,50,3,6,3,0,49,51,3,10,5,0,50,49,1,0,0,0,51,52,1,0,0,0,52,50,1,
        0,0,0,52,53,1,0,0,0,53,56,1,0,0,0,54,56,3,6,3,0,55,36,1,0,0,0,55,
        41,1,0,0,0,55,48,1,0,0,0,55,54,1,0,0,0,56,65,1,0,0,0,57,58,10,6,
        0,0,58,59,5,3,0,0,59,64,3,4,2,7,60,61,10,5,0,0,61,62,5,4,0,0,62,
        64,3,4,2,6,63,57,1,0,0,0,63,60,1,0,0,0,64,67,1,0,0,0,65,63,1,0,0,
        0,65,66,1,0,0,0,66,5,1,0,0,0,67,65,1,0,0,0,68,69,5,15,0,0,69,72,
        3,8,4,0,70,72,3,8,4,0,71,68,1,0,0,0,71,70,1,0,0,0,72,7,1,0,0,0,73,
        74,5,6,0,0,74,75,3,4,2,0,75,76,5,7,0,0,76,87,1,0,0,0,77,87,5,8,0,
        0,78,87,5,17,0,0,79,87,5,18,0,0,80,81,5,17,0,0,81,84,5,9,0,0,82,
        85,5,17,0,0,83,85,5,18,0,0,84,82,1,0,0,0,84,83,1,0,0,0,85,87,1,0,
        0,0,86,73,1,0,0,0,86,77,1,0,0,0,86,78,1,0,0,0,86,79,1,0,0,0,86,80,
        1,0,0,0,87,9,1,0,0,0,88,89,3,12,6,0,89,90,3,6,3,0,90,11,1,0,0,0,
        91,92,6,6,-1,0,92,93,5,15,0,0,93,96,3,14,7,0,94,96,3,14,7,0,95,91,
        1,0,0,0,95,94,1,0,0,0,96,102,1,0,0,0,97,98,10,3,0,0,98,99,5,4,0,
        0,99,101,3,12,6,4,100,97,1,0,0,0,101,104,1,0,0,0,102,100,1,0,0,0,
        102,103,1,0,0,0,103,13,1,0,0,0,104,102,1,0,0,0,105,106,5,6,0,0,106,
        107,3,12,6,0,107,108,5,7,0,0,108,120,1,0,0,0,109,114,3,16,8,0,110,
        112,5,15,0,0,111,110,1,0,0,0,111,112,1,0,0,0,112,113,1,0,0,0,113,
        115,5,17,0,0,114,111,1,0,0,0,114,115,1,0,0,0,115,117,1,0,0,0,116,
        118,3,18,9,0,117,116,1,0,0,0,117,118,1,0,0,0,118,120,1,0,0,0,119,
        105,1,0,0,0,119,109,1,0,0,0,120,15,1,0,0,0,121,124,5,10,0,0,122,
        124,5,11,0,0,123,121,1,0,0,0,123,122,1,0,0,0,124,17,1,0,0,0,125,
        128,5,12,0,0,126,128,5,13,0,0,127,125,1,0,0,0,127,126,1,0,0,0,128,
        19,1,0,0,0,18,21,28,44,52,55,63,65,71,84,86,95,102,111,114,117,119,
        123,127
    ]

class DepsearchParser ( Parser ):

    grammarFileName = "Depsearch.g4"

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

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

    sharedContextCache = PredictionContextCache()

    literalNames = [ "<INVALID>", "'+'", "'->'", "'&'", "'|'", "'.'", "'('", 
                     "')'", "'_'", "'='", "'>'", "'<'", "'@L'", "'@R'", 
                     "<INVALID>", "'!'" ]

    symbolicNames = [ "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                      "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                      "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                      "<INVALID>", "<INVALID>", "LinearDistance", "Neg", 
                      "WhiteSpace", "Value", "String" ]

    RULE_query = 0
    RULE_allQuantified = 1
    RULE_tokenExpression = 2
    RULE_negatedToken = 3
    RULE_atomicToken = 4
    RULE_dependencyDescription = 5
    RULE_dependencyExpression = 6
    RULE_atomicDependency = 7
    RULE_dependencyOperator = 8
    RULE_orderModifier = 9

    ruleNames =  [ "query", "allQuantified", "tokenExpression", "negatedToken", 
                   "atomicToken", "dependencyDescription", "dependencyExpression", 
                   "atomicDependency", "dependencyOperator", "orderModifier" ]

    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
    T__11=12
    T__12=13
    LinearDistance=14
    Neg=15
    WhiteSpace=16
    Value=17
    String=18

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




    class QueryContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def tokenExpression(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(DepsearchParser.TokenExpressionContext)
            else:
                return self.getTypedRuleContext(DepsearchParser.TokenExpressionContext,i)


        def EOF(self):
            return self.getToken(DepsearchParser.EOF, 0)

        def allQuantified(self):
            return self.getTypedRuleContext(DepsearchParser.AllQuantifiedContext,0)


        def getRuleIndex(self):
            return DepsearchParser.RULE_query




    def query(self):

        localctx = DepsearchParser.QueryContext(self, self._ctx, self.state)
        self.enterRule(localctx, 0, self.RULE_query)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 21
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,0,self._ctx)
            if la_ == 1:
                self.state = 20
                self.allQuantified()


            self.state = 23
            self.tokenExpression(0)
            self.state = 28
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==1:
                self.state = 24
                self.match(DepsearchParser.T__0)
                self.state = 25
                self.tokenExpression(0)
                self.state = 30
                self._errHandler.sync(self)
                _la = self._input.LA(1)

            self.state = 31
            self.match(DepsearchParser.EOF)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class AllQuantifiedContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def atomicToken(self):
            return self.getTypedRuleContext(DepsearchParser.AtomicTokenContext,0)


        def getRuleIndex(self):
            return DepsearchParser.RULE_allQuantified




    def allQuantified(self):

        localctx = DepsearchParser.AllQuantifiedContext(self, self._ctx, self.state)
        self.enterRule(localctx, 2, self.RULE_allQuantified)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 33
            self.atomicToken()
            self.state = 34
            self.match(DepsearchParser.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 TokenExpressionContext(ParserRuleContext):
        __slots__ = 'parser'

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


        def getRuleIndex(self):
            return DepsearchParser.RULE_tokenExpression

     
        def copyFrom(self, ctx:ParserRuleContext):
            super().copyFrom(ctx)


    class ConjunctionTokenContext(TokenExpressionContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a DepsearchParser.TokenExpressionContext
            super().__init__(parser)
            self.lhs = None # TokenExpressionContext
            self.rhs = None # TokenExpressionContext
            self.copyFrom(ctx)

        def tokenExpression(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(DepsearchParser.TokenExpressionContext)
            else:
                return self.getTypedRuleContext(DepsearchParser.TokenExpressionContext,i)



    class DisjunctionTokenContext(TokenExpressionContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a DepsearchParser.TokenExpressionContext
            super().__init__(parser)
            self.lhs = None # TokenExpressionContext
            self.rhs = None # TokenExpressionContext
            self.copyFrom(ctx)

        def tokenExpression(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(DepsearchParser.TokenExpressionContext)
            else:
                return self.getTypedRuleContext(DepsearchParser.TokenExpressionContext,i)



    class SequenceTokenContext(TokenExpressionContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a DepsearchParser.TokenExpressionContext
            super().__init__(parser)
            self.lhs = None # AtomicTokenContext
            self.rhs = None # AtomicTokenContext
            self.copyFrom(ctx)

        def atomicToken(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(DepsearchParser.AtomicTokenContext)
            else:
                return self.getTypedRuleContext(DepsearchParser.AtomicTokenContext,i)



    class PossiblyNegatedTokenContext(TokenExpressionContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a DepsearchParser.TokenExpressionContext
            super().__init__(parser)
            self.exp = None # NegatedTokenContext
            self.copyFrom(ctx)

        def negatedToken(self):
            return self.getTypedRuleContext(DepsearchParser.NegatedTokenContext,0)



    class DistanceTokenContext(TokenExpressionContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a DepsearchParser.TokenExpressionContext
            super().__init__(parser)
            self.lhs = None # AtomicTokenContext
            self.rhs = None # AtomicTokenContext
            self.copyFrom(ctx)

        def LinearDistance(self):
            return self.getToken(DepsearchParser.LinearDistance, 0)
        def atomicToken(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(DepsearchParser.AtomicTokenContext)
            else:
                return self.getTypedRuleContext(DepsearchParser.AtomicTokenContext,i)

        def orderModifier(self):
            return self.getTypedRuleContext(DepsearchParser.OrderModifierContext,0)



    class DependenciesTokenContext(TokenExpressionContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a DepsearchParser.TokenExpressionContext
            super().__init__(parser)
            self.src = None # NegatedTokenContext
            self.copyFrom(ctx)

        def negatedToken(self):
            return self.getTypedRuleContext(DepsearchParser.NegatedTokenContext,0)

        def dependencyDescription(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(DepsearchParser.DependencyDescriptionContext)
            else:
                return self.getTypedRuleContext(DepsearchParser.DependencyDescriptionContext,i)




    def tokenExpression(self, _p:int=0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = DepsearchParser.TokenExpressionContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 4
        self.enterRecursionRule(localctx, 4, self.RULE_tokenExpression, _p)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 55
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,4,self._ctx)
            if la_ == 1:
                localctx = DepsearchParser.SequenceTokenContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx

                self.state = 37
                localctx.lhs = self.atomicToken()
                self.state = 38
                self.match(DepsearchParser.T__4)
                self.state = 39
                localctx.rhs = self.atomicToken()
                pass

            elif la_ == 2:
                localctx = DepsearchParser.DistanceTokenContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 41
                localctx.lhs = self.atomicToken()
                self.state = 42
                self.match(DepsearchParser.LinearDistance)
                self.state = 44
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==12 or _la==13:
                    self.state = 43
                    self.orderModifier()


                self.state = 46
                localctx.rhs = self.atomicToken()
                pass

            elif la_ == 3:
                localctx = DepsearchParser.DependenciesTokenContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 48
                localctx.src = self.negatedToken()
                self.state = 50 
                self._errHandler.sync(self)
                _alt = 1
                while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                    if _alt == 1:
                        self.state = 49
                        self.dependencyDescription()

                    else:
                        raise NoViableAltException(self)
                    self.state = 52 
                    self._errHandler.sync(self)
                    _alt = self._interp.adaptivePredict(self._input,3,self._ctx)

                pass

            elif la_ == 4:
                localctx = DepsearchParser.PossiblyNegatedTokenContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 54
                localctx.exp = self.negatedToken()
                pass


            self._ctx.stop = self._input.LT(-1)
            self.state = 65
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,6,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    if self._parseListeners is not None:
                        self.triggerExitRuleEvent()
                    _prevctx = localctx
                    self.state = 63
                    self._errHandler.sync(self)
                    la_ = self._interp.adaptivePredict(self._input,5,self._ctx)
                    if la_ == 1:
                        localctx = DepsearchParser.ConjunctionTokenContext(self, DepsearchParser.TokenExpressionContext(self, _parentctx, _parentState))
                        localctx.lhs = _prevctx
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_tokenExpression)
                        self.state = 57
                        if not self.precpred(self._ctx, 6):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 6)")
                        self.state = 58
                        self.match(DepsearchParser.T__2)
                        self.state = 59
                        localctx.rhs = self.tokenExpression(7)
                        pass

                    elif la_ == 2:
                        localctx = DepsearchParser.DisjunctionTokenContext(self, DepsearchParser.TokenExpressionContext(self, _parentctx, _parentState))
                        localctx.lhs = _prevctx
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_tokenExpression)
                        self.state = 60
                        if not self.precpred(self._ctx, 5):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 5)")
                        self.state = 61
                        self.match(DepsearchParser.T__3)
                        self.state = 62
                        localctx.rhs = self.tokenExpression(6)
                        pass

             
                self.state = 67
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,6,self._ctx)

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


    class NegatedTokenContext(ParserRuleContext):
        __slots__ = 'parser'

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


        def getRuleIndex(self):
            return DepsearchParser.RULE_negatedToken

     
        def copyFrom(self, ctx:ParserRuleContext):
            super().copyFrom(ctx)



    class NegationTokenContext(NegatedTokenContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a DepsearchParser.NegatedTokenContext
            super().__init__(parser)
            self.exp = None # AtomicTokenContext
            self.copyFrom(ctx)

        def Neg(self):
            return self.getToken(DepsearchParser.Neg, 0)
        def atomicToken(self):
            return self.getTypedRuleContext(DepsearchParser.AtomicTokenContext,0)



    class JustATokenContext(NegatedTokenContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a DepsearchParser.NegatedTokenContext
            super().__init__(parser)
            self.exp = None # AtomicTokenContext
            self.copyFrom(ctx)

        def atomicToken(self):
            return self.getTypedRuleContext(DepsearchParser.AtomicTokenContext,0)




    def negatedToken(self):

        localctx = DepsearchParser.NegatedTokenContext(self, self._ctx, self.state)
        self.enterRule(localctx, 6, self.RULE_negatedToken)
        try:
            self.state = 71
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [15]:
                localctx = DepsearchParser.NegationTokenContext(self, localctx)
                self.enterOuterAlt(localctx, 1)
                self.state = 68
                self.match(DepsearchParser.Neg)
                self.state = 69
                localctx.exp = self.atomicToken()
                pass
            elif token in [6, 8, 17, 18]:
                localctx = DepsearchParser.JustATokenContext(self, localctx)
                self.enterOuterAlt(localctx, 2)
                self.state = 70
                localctx.exp = self.atomicToken()
                pass
            else:
                raise NoViableAltException(self)

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


    class AtomicTokenContext(ParserRuleContext):
        __slots__ = 'parser'

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


        def getRuleIndex(self):
            return DepsearchParser.RULE_atomicToken

     
        def copyFrom(self, ctx:ParserRuleContext):
            super().copyFrom(ctx)



    class WordOrTagTokenContext(AtomicTokenContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a DepsearchParser.AtomicTokenContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def Value(self):
            return self.getToken(DepsearchParser.Value, 0)


    class ArbitraryTokenContext(AtomicTokenContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a DepsearchParser.AtomicTokenContext
            super().__init__(parser)
            self.copyFrom(ctx)



    class ParenthesizedTokenContext(AtomicTokenContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a DepsearchParser.AtomicTokenContext
            super().__init__(parser)
            self.exp = None # TokenExpressionContext
            self.copyFrom(ctx)

        def tokenExpression(self):
            return self.getTypedRuleContext(DepsearchParser.TokenExpressionContext,0)



    class AttributeTokenContext(AtomicTokenContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a DepsearchParser.AtomicTokenContext
            super().__init__(parser)
            self.key = None # Token
            self.value = None # Token
            self.regex = None # Token
            self.copyFrom(ctx)

        def Value(self, i:int=None):
            if i is None:
                return self.getTokens(DepsearchParser.Value)
            else:
                return self.getToken(DepsearchParser.Value, i)
        def String(self):
            return self.getToken(DepsearchParser.String, 0)


    class WordformTokenContext(AtomicTokenContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a DepsearchParser.AtomicTokenContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def String(self):
            return self.getToken(DepsearchParser.String, 0)



    def atomicToken(self):

        localctx = DepsearchParser.AtomicTokenContext(self, self._ctx, self.state)
        self.enterRule(localctx, 8, self.RULE_atomicToken)
        try:
            self.state = 86
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,9,self._ctx)
            if la_ == 1:
                localctx = DepsearchParser.ParenthesizedTokenContext(self, localctx)
                self.enterOuterAlt(localctx, 1)
                self.state = 73
                self.match(DepsearchParser.T__5)
                self.state = 74
                localctx.exp = self.tokenExpression(0)
                self.state = 75
                self.match(DepsearchParser.T__6)
                pass

            elif la_ == 2:
                localctx = DepsearchParser.ArbitraryTokenContext(self, localctx)
                self.enterOuterAlt(localctx, 2)
                self.state = 77
                self.match(DepsearchParser.T__7)
                pass

            elif la_ == 3:
                localctx = DepsearchParser.WordOrTagTokenContext(self, localctx)
                self.enterOuterAlt(localctx, 3)
                self.state = 78
                self.match(DepsearchParser.Value)
                pass

            elif la_ == 4:
                localctx = DepsearchParser.WordformTokenContext(self, localctx)
                self.enterOuterAlt(localctx, 4)
                self.state = 79
                self.match(DepsearchParser.String)
                pass

            elif la_ == 5:
                localctx = DepsearchParser.AttributeTokenContext(self, localctx)
                self.enterOuterAlt(localctx, 5)
                self.state = 80
                localctx.key = self.match(DepsearchParser.Value)
                self.state = 81
                self.match(DepsearchParser.T__8)
                self.state = 84
                self._errHandler.sync(self)
                token = self._input.LA(1)
                if token in [17]:
                    self.state = 82
                    localctx.value = self.match(DepsearchParser.Value)
                    pass
                elif token in [18]:
                    self.state = 83
                    localctx.regex = self.match(DepsearchParser.String)
                    pass
                else:
                    raise NoViableAltException(self)

                pass


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


    class DependencyDescriptionContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def dependencyExpression(self):
            return self.getTypedRuleContext(DepsearchParser.DependencyExpressionContext,0)


        def negatedToken(self):
            return self.getTypedRuleContext(DepsearchParser.NegatedTokenContext,0)


        def getRuleIndex(self):
            return DepsearchParser.RULE_dependencyDescription




    def dependencyDescription(self):

        localctx = DepsearchParser.DependencyDescriptionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 10, self.RULE_dependencyDescription)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 88
            self.dependencyExpression(0)
            self.state = 89
            localctx.dst = self.negatedToken()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class DependencyExpressionContext(ParserRuleContext):
        __slots__ = 'parser'

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


        def getRuleIndex(self):
            return DepsearchParser.RULE_dependencyExpression

     
        def copyFrom(self, ctx:ParserRuleContext):
            super().copyFrom(ctx)


    class NegationDependencyContext(DependencyExpressionContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a DepsearchParser.DependencyExpressionContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def Neg(self):
            return self.getToken(DepsearchParser.Neg, 0)
        def atomicDependency(self):
            return self.getTypedRuleContext(DepsearchParser.AtomicDependencyContext,0)



    class JustADependencyContext(DependencyExpressionContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a DepsearchParser.DependencyExpressionContext
            super().__init__(parser)
            self.exp = None # AtomicDependencyContext
            self.copyFrom(ctx)

        def atomicDependency(self):
            return self.getTypedRuleContext(DepsearchParser.AtomicDependencyContext,0)



    class DisjunctionDependencyContext(DependencyExpressionContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a DepsearchParser.DependencyExpressionContext
            super().__init__(parser)
            self.lhs = None # DependencyExpressionContext
            self.rhs = None # DependencyExpressionContext
            self.copyFrom(ctx)

        def dependencyExpression(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(DepsearchParser.DependencyExpressionContext)
            else:
                return self.getTypedRuleContext(DepsearchParser.DependencyExpressionContext,i)




    def dependencyExpression(self, _p:int=0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = DepsearchParser.DependencyExpressionContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 12
        self.enterRecursionRule(localctx, 12, self.RULE_dependencyExpression, _p)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 95
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [15]:
                localctx = DepsearchParser.NegationDependencyContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx

                self.state = 92
                self.match(DepsearchParser.Neg)
                self.state = 93
                self.atomicDependency()
                pass
            elif token in [6, 10, 11]:
                localctx = DepsearchParser.JustADependencyContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 94
                localctx.exp = self.atomicDependency()
                pass
            else:
                raise NoViableAltException(self)

            self._ctx.stop = self._input.LT(-1)
            self.state = 102
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,11,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    if self._parseListeners is not None:
                        self.triggerExitRuleEvent()
                    _prevctx = localctx
                    localctx = DepsearchParser.DisjunctionDependencyContext(self, DepsearchParser.DependencyExpressionContext(self, _parentctx, _parentState))
                    localctx.lhs = _prevctx
                    self.pushNewRecursionContext(localctx, _startState, self.RULE_dependencyExpression)
                    self.state = 97
                    if not self.precpred(self._ctx, 3):
                        from antlr4.error.Errors import FailedPredicateException
                        raise FailedPredicateException(self, "self.precpred(self._ctx, 3)")
                    self.state = 98
                    self.match(DepsearchParser.T__3)
                    self.state = 99
                    localctx.rhs = self.dependencyExpression(4) 
                self.state = 104
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,11,self._ctx)

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


    class AtomicDependencyContext(ParserRuleContext):
        __slots__ = 'parser'

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


        def getRuleIndex(self):
            return DepsearchParser.RULE_atomicDependency

     
        def copyFrom(self, ctx:ParserRuleContext):
            super().copyFrom(ctx)



    class ParenthesizedDependencyContext(AtomicDependencyContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a DepsearchParser.AtomicDependencyContext
            super().__init__(parser)
            self.exp = None # DependencyExpressionContext
            self.copyFrom(ctx)

        def dependencyExpression(self):
            return self.getTypedRuleContext(DepsearchParser.DependencyExpressionContext,0)



    class DependencyContext(AtomicDependencyContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a DepsearchParser.AtomicDependencyContext
            super().__init__(parser)
            self.negatedType = None # Token
            self.copyFrom(ctx)

        def dependencyOperator(self):
            return self.getTypedRuleContext(DepsearchParser.DependencyOperatorContext,0)

        def Value(self):
            return self.getToken(DepsearchParser.Value, 0)
        def orderModifier(self):
            return self.getTypedRuleContext(DepsearchParser.OrderModifierContext,0)

        def Neg(self):
            return self.getToken(DepsearchParser.Neg, 0)



    def atomicDependency(self):

        localctx = DepsearchParser.AtomicDependencyContext(self, self._ctx, self.state)
        self.enterRule(localctx, 14, self.RULE_atomicDependency)
        self._la = 0 # Token type
        try:
            self.state = 119
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [6]:
                localctx = DepsearchParser.ParenthesizedDependencyContext(self, localctx)
                self.enterOuterAlt(localctx, 1)
                self.state = 105
                self.match(DepsearchParser.T__5)
                self.state = 106
                localctx.exp = self.dependencyExpression(0)
                self.state = 107
                self.match(DepsearchParser.T__6)
                pass
            elif token in [10, 11]:
                localctx = DepsearchParser.DependencyContext(self, localctx)
                self.enterOuterAlt(localctx, 2)
                self.state = 109
                self.dependencyOperator()
                self.state = 114
                self._errHandler.sync(self)
                la_ = self._interp.adaptivePredict(self._input,13,self._ctx)
                if la_ == 1:
                    self.state = 111
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)
                    if _la==15:
                        self.state = 110
                        localctx.negatedType = self.match(DepsearchParser.Neg)


                    self.state = 113
                    self.match(DepsearchParser.Value)


                self.state = 117
                self._errHandler.sync(self)
                la_ = self._interp.adaptivePredict(self._input,14,self._ctx)
                if la_ == 1:
                    self.state = 116
                    self.orderModifier()


                pass
            else:
                raise NoViableAltException(self)

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


    class DependencyOperatorContext(ParserRuleContext):
        __slots__ = 'parser'

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


        def getRuleIndex(self):
            return DepsearchParser.RULE_dependencyOperator

     
        def copyFrom(self, ctx:ParserRuleContext):
            super().copyFrom(ctx)



    class GovernsContext(DependencyOperatorContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a DepsearchParser.DependencyOperatorContext
            super().__init__(parser)
            self.copyFrom(ctx)



    class GovernedByContext(DependencyOperatorContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a DepsearchParser.DependencyOperatorContext
            super().__init__(parser)
            self.copyFrom(ctx)




    def dependencyOperator(self):

        localctx = DepsearchParser.DependencyOperatorContext(self, self._ctx, self.state)
        self.enterRule(localctx, 16, self.RULE_dependencyOperator)
        try:
            self.state = 123
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [10]:
                localctx = DepsearchParser.GovernsContext(self, localctx)
                self.enterOuterAlt(localctx, 1)
                self.state = 121
                self.match(DepsearchParser.T__9)
                pass
            elif token in [11]:
                localctx = DepsearchParser.GovernedByContext(self, localctx)
                self.enterOuterAlt(localctx, 2)
                self.state = 122
                self.match(DepsearchParser.T__10)
                pass
            else:
                raise NoViableAltException(self)

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


    class OrderModifierContext(ParserRuleContext):
        __slots__ = 'parser'

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


        def getRuleIndex(self):
            return DepsearchParser.RULE_orderModifier

     
        def copyFrom(self, ctx:ParserRuleContext):
            super().copyFrom(ctx)



    class LeftOfContext(OrderModifierContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a DepsearchParser.OrderModifierContext
            super().__init__(parser)
            self.copyFrom(ctx)



    class RightOfContext(OrderModifierContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a DepsearchParser.OrderModifierContext
            super().__init__(parser)
            self.copyFrom(ctx)




    def orderModifier(self):

        localctx = DepsearchParser.OrderModifierContext(self, self._ctx, self.state)
        self.enterRule(localctx, 18, self.RULE_orderModifier)
        try:
            self.state = 127
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [12]:
                localctx = DepsearchParser.LeftOfContext(self, localctx)
                self.enterOuterAlt(localctx, 1)
                self.state = 125
                self.match(DepsearchParser.T__11)
                pass
            elif token in [13]:
                localctx = DepsearchParser.RightOfContext(self, localctx)
                self.enterOuterAlt(localctx, 2)
                self.state = 126
                self.match(DepsearchParser.T__12)
                pass
            else:
                raise NoViableAltException(self)

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



    def sempred(self, localctx:RuleContext, ruleIndex:int, predIndex:int):
        if self._predicates == None:
            self._predicates = dict()
        self._predicates[2] = self.tokenExpression_sempred
        self._predicates[6] = self.dependencyExpression_sempred
        pred = self._predicates.get(ruleIndex, None)
        if pred is None:
            raise Exception("No predicate with index:" + str(ruleIndex))
        else:
            return pred(localctx, predIndex)

    def tokenExpression_sempred(self, localctx:TokenExpressionContext, predIndex:int):
            if predIndex == 0:
                return self.precpred(self._ctx, 6)
         

            if predIndex == 1:
                return self.precpred(self._ctx, 5)
         

    def dependencyExpression_sempred(self, localctx:DependencyExpressionContext, predIndex:int):
            if predIndex == 2:
                return self.precpred(self._ctx, 3)
         




