# Generated from HassILGrammar.g4 by ANTLR 4.11.1
# encoding: utf-8
import sys
from io import StringIO

from antlr4 import *

if sys.version_info[1] > 5:
    from typing import TextIO
else:
    from typing.io import TextIO


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


class HassILGrammarParser(Parser):

    grammarFileName = "HassILGrammar.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>",
        "STRING",
        "ESC",
        "CHARACTER",
        "EOL",
        "WS",
    ]

    RULE_document = 0
    RULE_sentence = 1
    RULE_expression = 2
    RULE_group = 3
    RULE_optional = 4
    RULE_alt = 5
    RULE_text_chunk = 6
    RULE_list = 7
    RULE_list_name = 8
    RULE_rule = 9
    RULE_rule_name = 10

    ruleNames = [
        "document",
        "sentence",
        "expression",
        "group",
        "optional",
        "alt",
        "text_chunk",
        "list",
        "list_name",
        "rule",
        "rule_name",
    ]

    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
    STRING = 10
    ESC = 11
    CHARACTER = 12
    EOL = 13
    WS = 14

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

    class DocumentContext(ParserRuleContext):
        __slots__ = "parser"

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

        def sentence(self, i: int = None):
            if i is None:
                return self.getTypedRuleContexts(HassILGrammarParser.SentenceContext)
            else:
                return self.getTypedRuleContext(HassILGrammarParser.SentenceContext, i)

        def getRuleIndex(self):
            return HassILGrammarParser.RULE_document

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

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

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

    def document(self):

        localctx = HassILGrammarParser.DocumentContext(self, self._ctx, self.state)
        self.enterRule(localctx, 0, self.RULE_document)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 23
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 22
                self.sentence()
                self.state = 25
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not (((_la) & ~0x3F) == 0 and ((1 << _la) & 17738) != 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 SentenceContext(ParserRuleContext):
        __slots__ = "parser"

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

        def expression(self):
            return self.getTypedRuleContext(HassILGrammarParser.ExpressionContext, 0)

        def EOL(self):
            return self.getToken(HassILGrammarParser.EOL, 0)

        def getRuleIndex(self):
            return HassILGrammarParser.RULE_sentence

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

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

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

    def sentence(self):

        localctx = HassILGrammarParser.SentenceContext(self, self._ctx, self.state)
        self.enterRule(localctx, 2, self.RULE_sentence)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 27
            self.expression()
            self.state = 28
            self.match(HassILGrammarParser.EOL)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ExpressionContext(ParserRuleContext):
        __slots__ = "parser"

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

        def group(self):
            return self.getTypedRuleContext(HassILGrammarParser.GroupContext, 0)

        def optional(self):
            return self.getTypedRuleContext(HassILGrammarParser.OptionalContext, 0)

        def list_(self):
            return self.getTypedRuleContext(HassILGrammarParser.ListContext, 0)

        def rule_(self):
            return self.getTypedRuleContext(HassILGrammarParser.RuleContext, 0)

        def text_chunk(self):
            return self.getTypedRuleContext(HassILGrammarParser.Text_chunkContext, 0)

        def expression(self, i: int = None):
            if i is None:
                return self.getTypedRuleContexts(HassILGrammarParser.ExpressionContext)
            else:
                return self.getTypedRuleContext(
                    HassILGrammarParser.ExpressionContext, i
                )

        def WS(self):
            return self.getToken(HassILGrammarParser.WS, 0)

        def alt(self, i: int = None):
            if i is None:
                return self.getTypedRuleContexts(HassILGrammarParser.AltContext)
            else:
                return self.getTypedRuleContext(HassILGrammarParser.AltContext, i)

        def getRuleIndex(self):
            return HassILGrammarParser.RULE_expression

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

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

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

    def expression(self):

        localctx = HassILGrammarParser.ExpressionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 4, self.RULE_expression)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 47
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input, 5, self._ctx)
            if la_ == 1:
                self.state = 31
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la == 14:
                    self.state = 30
                    self.match(HassILGrammarParser.WS)

                self.state = 33
                self.group()
                pass

            elif la_ == 2:
                self.state = 35
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la == 14:
                    self.state = 34
                    self.match(HassILGrammarParser.WS)

                self.state = 37
                self.optional()
                pass

            elif la_ == 3:
                self.state = 39
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la == 14:
                    self.state = 38
                    self.match(HassILGrammarParser.WS)

                self.state = 41
                self.list_()
                pass

            elif la_ == 4:
                self.state = 43
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la == 14:
                    self.state = 42
                    self.match(HassILGrammarParser.WS)

                self.state = 45
                self.rule_()
                pass

            elif la_ == 5:
                self.state = 46
                self.text_chunk()
                pass

            self.state = 55
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input, 7, self._ctx)
            while _alt != 2 and _alt != ATN.INVALID_ALT_NUMBER:
                if _alt == 1:
                    self.state = 50
                    self._errHandler.sync(self)
                    la_ = self._interp.adaptivePredict(self._input, 6, self._ctx)
                    if la_ == 1:
                        self.state = 49
                        self.alt()

                    self.state = 52
                    self.expression()
                self.state = 57
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input, 7, self._ctx)

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

    class GroupContext(ParserRuleContext):
        __slots__ = "parser"

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

        def expression(self):
            return self.getTypedRuleContext(HassILGrammarParser.ExpressionContext, 0)

        def WS(self, i: int = None):
            if i is None:
                return self.getTokens(HassILGrammarParser.WS)
            else:
                return self.getToken(HassILGrammarParser.WS, i)

        def getRuleIndex(self):
            return HassILGrammarParser.RULE_group

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

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

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

    def group(self):

        localctx = HassILGrammarParser.GroupContext(self, self._ctx, self.state)
        self.enterRule(localctx, 6, self.RULE_group)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 58
            self.match(HassILGrammarParser.T__0)
            self.state = 60
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input, 8, self._ctx)
            if la_ == 1:
                self.state = 59
                self.match(HassILGrammarParser.WS)

            self.state = 62
            self.expression()
            self.state = 64
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la == 14:
                self.state = 63
                self.match(HassILGrammarParser.WS)

            self.state = 66
            self.match(HassILGrammarParser.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 OptionalContext(ParserRuleContext):
        __slots__ = "parser"

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

        def expression(self):
            return self.getTypedRuleContext(HassILGrammarParser.ExpressionContext, 0)

        def WS(self, i: int = None):
            if i is None:
                return self.getTokens(HassILGrammarParser.WS)
            else:
                return self.getToken(HassILGrammarParser.WS, i)

        def getRuleIndex(self):
            return HassILGrammarParser.RULE_optional

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

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

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

    def optional(self):

        localctx = HassILGrammarParser.OptionalContext(self, self._ctx, self.state)
        self.enterRule(localctx, 8, self.RULE_optional)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 68
            self.match(HassILGrammarParser.T__2)
            self.state = 70
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input, 10, self._ctx)
            if la_ == 1:
                self.state = 69
                self.match(HassILGrammarParser.WS)

            self.state = 72
            self.expression()
            self.state = 74
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la == 14:
                self.state = 73
                self.match(HassILGrammarParser.WS)

            self.state = 76
            self.match(HassILGrammarParser.T__3)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class AltContext(ParserRuleContext):
        __slots__ = "parser"

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

        def WS(self, i: int = None):
            if i is None:
                return self.getTokens(HassILGrammarParser.WS)
            else:
                return self.getToken(HassILGrammarParser.WS, i)

        def getRuleIndex(self):
            return HassILGrammarParser.RULE_alt

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

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

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

    def alt(self):

        localctx = HassILGrammarParser.AltContext(self, self._ctx, self.state)
        self.enterRule(localctx, 10, self.RULE_alt)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 79
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la == 14:
                self.state = 78
                self.match(HassILGrammarParser.WS)

            self.state = 81
            self.match(HassILGrammarParser.T__4)
            self.state = 83
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input, 13, self._ctx)
            if la_ == 1:
                self.state = 82
                self.match(HassILGrammarParser.WS)

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

    class Text_chunkContext(ParserRuleContext):
        __slots__ = "parser"

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

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

        def WS(self, i: int = None):
            if i is None:
                return self.getTokens(HassILGrammarParser.WS)
            else:
                return self.getToken(HassILGrammarParser.WS, i)

        def getRuleIndex(self):
            return HassILGrammarParser.RULE_text_chunk

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

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

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

    def text_chunk(self):

        localctx = HassILGrammarParser.Text_chunkContext(self, self._ctx, self.state)
        self.enterRule(localctx, 12, self.RULE_text_chunk)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 86
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la == 14:
                self.state = 85
                self.match(HassILGrammarParser.WS)

            self.state = 88
            self.match(HassILGrammarParser.STRING)
            self.state = 90
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input, 15, self._ctx)
            if la_ == 1:
                self.state = 89
                self.match(HassILGrammarParser.WS)

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

    class ListContext(ParserRuleContext):
        __slots__ = "parser"

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

        def list_name(self):
            return self.getTypedRuleContext(HassILGrammarParser.List_nameContext, 0)

        def WS(self, i: int = None):
            if i is None:
                return self.getTokens(HassILGrammarParser.WS)
            else:
                return self.getToken(HassILGrammarParser.WS, i)

        def getRuleIndex(self):
            return HassILGrammarParser.RULE_list

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

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

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

    def list_(self):

        localctx = HassILGrammarParser.ListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 14, self.RULE_list)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 92
            self.match(HassILGrammarParser.T__5)
            self.state = 94
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la == 14:
                self.state = 93
                self.match(HassILGrammarParser.WS)

            self.state = 96
            self.list_name()
            self.state = 98
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la == 14:
                self.state = 97
                self.match(HassILGrammarParser.WS)

            self.state = 100
            self.match(HassILGrammarParser.T__6)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class List_nameContext(ParserRuleContext):
        __slots__ = "parser"

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

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

        def getRuleIndex(self):
            return HassILGrammarParser.RULE_list_name

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

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

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

    def list_name(self):

        localctx = HassILGrammarParser.List_nameContext(self, self._ctx, self.state)
        self.enterRule(localctx, 16, self.RULE_list_name)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 102
            self.match(HassILGrammarParser.STRING)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class RuleContext(ParserRuleContext):
        __slots__ = "parser"

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

        def rule_name(self):
            return self.getTypedRuleContext(HassILGrammarParser.Rule_nameContext, 0)

        def WS(self, i: int = None):
            if i is None:
                return self.getTokens(HassILGrammarParser.WS)
            else:
                return self.getToken(HassILGrammarParser.WS, i)

        def getRuleIndex(self):
            return HassILGrammarParser.RULE_rule

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

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

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

    def rule_(self):

        localctx = HassILGrammarParser.RuleContext(self, self._ctx, self.state)
        self.enterRule(localctx, 18, self.RULE_rule)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 104
            self.match(HassILGrammarParser.T__7)
            self.state = 106
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la == 14:
                self.state = 105
                self.match(HassILGrammarParser.WS)

            self.state = 108
            self.rule_name()
            self.state = 110
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la == 14:
                self.state = 109
                self.match(HassILGrammarParser.WS)

            self.state = 112
            self.match(HassILGrammarParser.T__8)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class Rule_nameContext(ParserRuleContext):
        __slots__ = "parser"

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

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

        def getRuleIndex(self):
            return HassILGrammarParser.RULE_rule_name

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

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

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

    def rule_name(self):

        localctx = HassILGrammarParser.Rule_nameContext(self, self._ctx, self.state)
        self.enterRule(localctx, 20, self.RULE_rule_name)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 114
            self.match(HassILGrammarParser.STRING)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx
