# Generated from FoostacheParser.g4 by ANTLR 4.5.1
# encoding: utf-8
from __future__ import print_function
from antlr4 import *
from io import StringIO

def serializedATN():
    with StringIO() as buf:
        buf.write(u"\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\3")
        buf.write(u".\u0139\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t")
        buf.write(u"\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r\t\r")
        buf.write(u"\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22\4")
        buf.write(u"\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30")
        buf.write(u"\t\30\4\31\t\31\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t")
        buf.write(u"\35\4\36\t\36\4\37\t\37\3\2\3\2\3\2\3\3\7\3C\n\3\f\3")
        buf.write(u"\16\3F\13\3\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\5\4P\n\4")
        buf.write(u"\3\5\6\5S\n\5\r\5\16\5T\3\6\3\6\3\6\3\6\3\7\7\7\\\n\7")
        buf.write(u"\f\7\16\7_\13\7\3\b\3\b\3\b\7\bd\n\b\f\b\16\bg\13\b\3")
        buf.write(u"\b\3\b\3\t\3\t\3\t\3\t\7\to\n\t\f\t\16\tr\13\t\3\t\3")
        buf.write(u"\t\3\n\3\n\3\n\3\13\3\13\5\13{\n\13\3\13\5\13~\n\13\3")
        buf.write(u"\13\3\13\5\13\u0082\n\13\3\13\3\13\3\f\3\f\3\f\7\f\u0089")
        buf.write(u"\n\f\f\f\16\f\u008c\13\f\3\f\5\f\u008f\n\f\3\f\3\f\3")
        buf.write(u"\f\3\f\3\r\3\r\3\r\3\r\3\r\3\16\3\16\3\16\3\17\3\17\3")
        buf.write(u"\17\3\17\3\17\3\20\3\20\3\20\3\20\3\20\3\21\3\21\3\21")
        buf.write(u"\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3")
        buf.write(u"\21\3\21\5\21\u00b6\n\21\3\21\3\21\3\21\3\21\3\21\3\21")
        buf.write(u"\7\21\u00be\n\21\f\21\16\21\u00c1\13\21\3\22\3\22\7\22")
        buf.write(u"\u00c5\n\22\f\22\16\22\u00c8\13\22\3\22\3\22\3\22\3\22")
        buf.write(u"\3\22\5\22\u00cf\n\22\3\22\3\22\3\22\3\22\3\22\3\22\7")
        buf.write(u"\22\u00d7\n\22\f\22\16\22\u00da\13\22\5\22\u00dc\n\22")
        buf.write(u"\5\22\u00de\n\22\3\23\3\23\3\23\7\23\u00e3\n\23\f\23")
        buf.write(u"\16\23\u00e6\13\23\3\23\5\23\u00e9\n\23\3\24\3\24\3\25")
        buf.write(u"\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\26\3\26\3")
        buf.write(u"\26\3\26\3\26\3\26\3\26\7\26\u00fd\n\26\f\26\16\26\u0100")
        buf.write(u"\13\26\3\26\3\26\3\26\3\26\3\27\5\27\u0107\n\27\3\27")
        buf.write(u"\5\27\u010a\n\27\3\30\3\30\5\30\u010e\n\30\3\30\5\30")
        buf.write(u"\u0111\n\30\3\31\3\31\3\31\3\32\3\32\3\32\3\32\5\32\u011a")
        buf.write(u"\n\32\3\33\3\33\3\33\3\33\3\33\3\34\3\34\3\34\3\34\3")
        buf.write(u"\34\3\35\3\35\3\35\3\35\3\35\3\36\3\36\3\36\3\36\3\36")
        buf.write(u"\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\2")
        buf.write(u"\3  \2\4\6\b\n\f\16\20\22\24\26\30\32\34\36 \"$&(*,.")
        buf.write(u"\60\62\64\668:<\2\3\4\2,,..\u0141\2>\3\2\2\2\4D\3\2\2")
        buf.write(u"\2\6O\3\2\2\2\bR\3\2\2\2\nV\3\2\2\2\f]\3\2\2\2\16`\3")
        buf.write(u"\2\2\2\20j\3\2\2\2\22u\3\2\2\2\24x\3\2\2\2\26\u0085\3")
        buf.write(u"\2\2\2\30\u0094\3\2\2\2\32\u0099\3\2\2\2\34\u009c\3\2")
        buf.write(u"\2\2\36\u00a1\3\2\2\2 \u00b5\3\2\2\2\"\u00dd\3\2\2\2")
        buf.write(u"$\u00e8\3\2\2\2&\u00ea\3\2\2\2(\u00ec\3\2\2\2*\u00f5")
        buf.write(u"\3\2\2\2,\u0106\3\2\2\2.\u010b\3\2\2\2\60\u0112\3\2\2")
        buf.write(u"\2\62\u0119\3\2\2\2\64\u011b\3\2\2\2\66\u0120\3\2\2\2")
        buf.write(u"8\u0125\3\2\2\2:\u012a\3\2\2\2<\u012f\3\2\2\2>?\5\4\3")
        buf.write(u"\2?@\7\2\2\3@\3\3\2\2\2AC\5\6\4\2BA\3\2\2\2CF\3\2\2\2")
        buf.write(u"DB\3\2\2\2DE\3\2\2\2E\5\3\2\2\2FD\3\2\2\2GP\5\b\5\2H")
        buf.write(u"P\5\n\6\2IP\5\16\b\2JP\5\20\t\2KP\5\26\f\2LP\5(\25\2")
        buf.write(u"MP\5*\26\2NP\5<\37\2OG\3\2\2\2OH\3\2\2\2OI\3\2\2\2OJ")
        buf.write(u"\3\2\2\2OK\3\2\2\2OL\3\2\2\2OM\3\2\2\2ON\3\2\2\2P\7\3")
        buf.write(u"\2\2\2QS\7\6\2\2RQ\3\2\2\2ST\3\2\2\2TR\3\2\2\2TU\3\2")
        buf.write(u"\2\2U\t\3\2\2\2VW\7\4\2\2WX\5\f\7\2XY\7\7\2\2Y\13\3\2")
        buf.write(u"\2\2Z\\\7\b\2\2[Z\3\2\2\2\\_\3\2\2\2][\3\2\2\2]^\3\2")
        buf.write(u"\2\2^\r\3\2\2\2_]\3\2\2\2`a\7\5\2\2ae\5\"\22\2bd\5\22")
        buf.write(u"\n\2cb\3\2\2\2dg\3\2\2\2ec\3\2\2\2ef\3\2\2\2fh\3\2\2")
        buf.write(u"\2ge\3\2\2\2hi\7\t\2\2i\17\3\2\2\2jk\7\5\2\2kl\5\"\22")
        buf.write(u"\2lp\5\24\13\2mo\5\22\n\2nm\3\2\2\2or\3\2\2\2pn\3\2\2")
        buf.write(u"\2pq\3\2\2\2qs\3\2\2\2rp\3\2\2\2st\7\t\2\2t\21\3\2\2")
        buf.write(u"\2uv\7$\2\2vw\7\'\2\2w\23\3\2\2\2xz\7%\2\2y{\7(\2\2z")
        buf.write(u"y\3\2\2\2z{\3\2\2\2{}\3\2\2\2|~\7*\2\2}|\3\2\2\2}~\3")
        buf.write(u"\2\2\2~\u0081\3\2\2\2\177\u0080\7)\2\2\u0080\u0082\7")
        buf.write(u"*\2\2\u0081\177\3\2\2\2\u0081\u0082\3\2\2\2\u0082\u0083")
        buf.write(u"\3\2\2\2\u0083\u0084\7+\2\2\u0084\25\3\2\2\2\u0085\u0086")
        buf.write(u"\5\30\r\2\u0086\u008a\5\4\3\2\u0087\u0089\5\32\16\2\u0088")
        buf.write(u"\u0087\3\2\2\2\u0089\u008c\3\2\2\2\u008a\u0088\3\2\2")
        buf.write(u"\2\u008a\u008b\3\2\2\2\u008b\u008e\3\2\2\2\u008c\u008a")
        buf.write(u"\3\2\2\2\u008d\u008f\5\36\20\2\u008e\u008d\3\2\2\2\u008e")
        buf.write(u"\u008f\3\2\2\2\u008f\u0090\3\2\2\2\u0090\u0091\7\5\2")
        buf.write(u"\2\u0091\u0092\7\21\2\2\u0092\u0093\7\t\2\2\u0093\27")
        buf.write(u"\3\2\2\2\u0094\u0095\7\5\2\2\u0095\u0096\7\24\2\2\u0096")
        buf.write(u"\u0097\5 \21\2\u0097\u0098\7\t\2\2\u0098\31\3\2\2\2\u0099")
        buf.write(u"\u009a\5\34\17\2\u009a\u009b\5\4\3\2\u009b\33\3\2\2\2")
        buf.write(u"\u009c\u009d\7\5\2\2\u009d\u009e\7\20\2\2\u009e\u009f")
        buf.write(u"\5 \21\2\u009f\u00a0\7\t\2\2\u00a0\35\3\2\2\2\u00a1\u00a2")
        buf.write(u"\7\5\2\2\u00a2\u00a3\7\17\2\2\u00a3\u00a4\7\t\2\2\u00a4")
        buf.write(u"\u00a5\5\4\3\2\u00a5\37\3\2\2\2\u00a6\u00a7\b\21\1\2")
        buf.write(u"\u00a7\u00a8\7\33\2\2\u00a8\u00b6\5 \21\6\u00a9\u00b6")
        buf.write(u"\5\"\22\2\u00aa\u00ab\5\"\22\2\u00ab\u00ac\7\31\2\2\u00ac")
        buf.write(u"\u00b6\3\2\2\2\u00ad\u00ae\5\"\22\2\u00ae\u00af\7\32")
        buf.write(u"\2\2\u00af\u00b0\7\27\2\2\u00b0\u00b6\3\2\2\2\u00b1\u00b2")
        buf.write(u"\7\35\2\2\u00b2\u00b3\5 \21\2\u00b3\u00b4\7\36\2\2\u00b4")
        buf.write(u"\u00b6\3\2\2\2\u00b5\u00a6\3\2\2\2\u00b5\u00a9\3\2\2")
        buf.write(u"\2\u00b5\u00aa\3\2\2\2\u00b5\u00ad\3\2\2\2\u00b5\u00b1")
        buf.write(u"\3\2\2\2\u00b6\u00bf\3\2\2\2\u00b7\u00b8\f\5\2\2\u00b8")
        buf.write(u"\u00b9\7\30\2\2\u00b9\u00be\5 \21\6\u00ba\u00bb\f\4\2")
        buf.write(u"\2\u00bb\u00bc\7\34\2\2\u00bc\u00be\5 \21\5\u00bd\u00b7")
        buf.write(u"\3\2\2\2\u00bd\u00ba\3\2\2\2\u00be\u00c1\3\2\2\2\u00bf")
        buf.write(u"\u00bd\3\2\2\2\u00bf\u00c0\3\2\2\2\u00c0!\3\2\2\2\u00c1")
        buf.write(u"\u00bf\3\2\2\2\u00c2\u00de\7\37\2\2\u00c3\u00c5\7\"\2")
        buf.write(u"\2\u00c4\u00c3\3\2\2\2\u00c5\u00c8\3\2\2\2\u00c6\u00c4")
        buf.write(u"\3\2\2\2\u00c6\u00c7\3\2\2\2\u00c7\u00db\3\2\2\2\u00c8")
        buf.write(u"\u00c6\3\2\2\2\u00c9\u00cf\5$\23\2\u00ca\u00cb\7 \2\2")
        buf.write(u"\u00cb\u00cc\5&\24\2\u00cc\u00cd\7!\2\2\u00cd\u00cf\3")
        buf.write(u"\2\2\2\u00ce\u00c9\3\2\2\2\u00ce\u00ca\3\2\2\2\u00cf")
        buf.write(u"\u00d8\3\2\2\2\u00d0\u00d1\7\37\2\2\u00d1\u00d7\5$\23")
        buf.write(u"\2\u00d2\u00d3\7 \2\2\u00d3\u00d4\5&\24\2\u00d4\u00d5")
        buf.write(u"\7!\2\2\u00d5\u00d7\3\2\2\2\u00d6\u00d0\3\2\2\2\u00d6")
        buf.write(u"\u00d2\3\2\2\2\u00d7\u00da\3\2\2\2\u00d8\u00d6\3\2\2")
        buf.write(u"\2\u00d8\u00d9\3\2\2\2\u00d9\u00dc\3\2\2\2\u00da\u00d8")
        buf.write(u"\3\2\2\2\u00db\u00ce\3\2\2\2\u00db\u00dc\3\2\2\2\u00dc")
        buf.write(u"\u00de\3\2\2\2\u00dd\u00c2\3\2\2\2\u00dd\u00c6\3\2\2")
        buf.write(u"\2\u00de#\3\2\2\2\u00df\u00e9\7\'\2\2\u00e0\u00e4\7\13")
        buf.write(u"\2\2\u00e1\u00e3\t\2\2\2\u00e2\u00e1\3\2\2\2\u00e3\u00e6")
        buf.write(u"\3\2\2\2\u00e4\u00e2\3\2\2\2\u00e4\u00e5\3\2\2\2\u00e5")
        buf.write(u"\u00e7\3\2\2\2\u00e6\u00e4\3\2\2\2\u00e7\u00e9\7-\2\2")
        buf.write(u"\u00e8\u00df\3\2\2\2\u00e8\u00e0\3\2\2\2\u00e9%\3\2\2")
        buf.write(u"\2\u00ea\u00eb\7&\2\2\u00eb\'\3\2\2\2\u00ec\u00ed\7\5")
        buf.write(u"\2\2\u00ed\u00ee\7\26\2\2\u00ee\u00ef\5\"\22\2\u00ef")
        buf.write(u"\u00f0\7\t\2\2\u00f0\u00f1\5\4\3\2\u00f1\u00f2\7\5\2")
        buf.write(u"\2\u00f2\u00f3\7\21\2\2\u00f3\u00f4\7\t\2\2\u00f4)\3")
        buf.write(u"\2\2\2\u00f5\u00f6\7\5\2\2\u00f6\u00f7\7\25\2\2\u00f7")
        buf.write(u"\u00f8\5\"\22\2\u00f8\u00f9\5,\27\2\u00f9\u00fa\7\t\2")
        buf.write(u"\2\u00fa\u00fe\5\4\3\2\u00fb\u00fd\5\62\32\2\u00fc\u00fb")
        buf.write(u"\3\2\2\2\u00fd\u0100\3\2\2\2\u00fe\u00fc\3\2\2\2\u00fe")
        buf.write(u"\u00ff\3\2\2\2\u00ff\u0101\3\2\2\2\u0100\u00fe\3\2\2")
        buf.write(u"\2\u0101\u0102\7\5\2\2\u0102\u0103\7\21\2\2\u0103\u0104")
        buf.write(u"\7\t\2\2\u0104+\3\2\2\2\u0105\u0107\7&\2\2\u0106\u0105")
        buf.write(u"\3\2\2\2\u0106\u0107\3\2\2\2\u0107\u0109\3\2\2\2\u0108")
        buf.write(u"\u010a\5.\30\2\u0109\u0108\3\2\2\2\u0109\u010a\3\2\2")
        buf.write(u"\2\u010a-\3\2\2\2\u010b\u010d\7#\2\2\u010c\u010e\7&\2")
        buf.write(u"\2\u010d\u010c\3\2\2\2\u010d\u010e\3\2\2\2\u010e\u0110")
        buf.write(u"\3\2\2\2\u010f\u0111\5\60\31\2\u0110\u010f\3\2\2\2\u0110")
        buf.write(u"\u0111\3\2\2\2\u0111/\3\2\2\2\u0112\u0113\7#\2\2\u0113")
        buf.write(u"\u0114\7&\2\2\u0114\61\3\2\2\2\u0115\u011a\5\64\33\2")
        buf.write(u"\u0116\u011a\5\66\34\2\u0117\u011a\58\35\2\u0118\u011a")
        buf.write(u"\5:\36\2\u0119\u0115\3\2\2\2\u0119\u0116\3\2\2\2\u0119")
        buf.write(u"\u0117\3\2\2\2\u0119\u0118\3\2\2\2\u011a\63\3\2\2\2\u011b")
        buf.write(u"\u011c\7\5\2\2\u011c\u011d\7\r\2\2\u011d\u011e\7\t\2")
        buf.write(u"\2\u011e\u011f\5\4\3\2\u011f\65\3\2\2\2\u0120\u0121\7")
        buf.write(u"\5\2\2\u0121\u0122\7\f\2\2\u0122\u0123\7\t\2\2\u0123")
        buf.write(u"\u0124\5\4\3\2\u0124\67\3\2\2\2\u0125\u0126\7\5\2\2\u0126")
        buf.write(u"\u0127\7\16\2\2\u0127\u0128\7\t\2\2\u0128\u0129\5\4\3")
        buf.write(u"\2\u01299\3\2\2\2\u012a\u012b\7\5\2\2\u012b\u012c\7\17")
        buf.write(u"\2\2\u012c\u012d\7\t\2\2\u012d\u012e\5\4\3\2\u012e;\3")
        buf.write(u"\2\2\2\u012f\u0130\7\5\2\2\u0130\u0131\7\23\2\2\u0131")
        buf.write(u"\u0132\7\'\2\2\u0132\u0133\7\t\2\2\u0133\u0134\5\4\3")
        buf.write(u"\2\u0134\u0135\7\5\2\2\u0135\u0136\7\21\2\2\u0136\u0137")
        buf.write(u"\7\t\2\2\u0137=\3\2\2\2\36DOT]epz}\u0081\u008a\u008e")
        buf.write(u"\u00b5\u00bd\u00bf\u00c6\u00ce\u00d6\u00d8\u00db\u00dd")
        buf.write(u"\u00e4\u00e8\u00fe\u0106\u0109\u010d\u0110\u0119")
        return buf.getvalue()


class FoostacheParser ( Parser ):

    grammarFileName = "FoostacheParser.g4"

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

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

    sharedContextCache = PredictionContextCache()

    literalNames = [ u"<INVALID>", u"<INVALID>", u"'{{\"'", u"'{{'", u"<INVALID>", 
                     u"'\"}}'", u"<INVALID>", u"'}}'", u"<INVALID>", u"<INVALID>", 
                     u"':after'", u"':before'", u"':between'", u"':else'", 
                     u"':elseif'", u"':end'", u"':escape'", u"':filter'", 
                     u"':if'", u"':iterate'", u"':with'", u"<INVALID>", 
                     u"'and'", u"'exists'", u"'is'", u"'not'", u"'or'", 
                     u"'('", u"')'", u"<INVALID>", u"'['", u"']'", u"'^'", 
                     u"':'", u"'|'", u"'%'", u"<INVALID>", u"<INVALID>", 
                     u"'0'" ]

    symbolicNames = [ u"<INVALID>", u"COMMENT", u"OPENL", u"OPEN", u"TEXT", 
                      u"CLOSEL", u"TEXTL", u"CLOSE", u"WS", u"OPENQS", u"AFTER", 
                      u"BEFORE", u"BETWEEN", u"ELSE", u"ELSEIF", u"END", 
                      u"ESCAPE", u"FILTER", u"IF", u"ITERATE", u"WITH", 
                      u"TYPE", u"AND", u"EXISTS", u"IS", u"NOT", u"OR", 
                      u"LPAREN", u"RPAREN", u"DOT", u"LBRACKET", u"RBRACKET", 
                      u"CARET", u"COLON", u"PIPE", u"PERCENT", u"INTEGER", 
                      u"ID", u"ZERO", u"DOTN", u"PINTEGERN", u"NUMBER_SPECIFIER", 
                      u"ESCCHARQS", u"CLOSEQS", u"CHARQS" ]

    RULE_template = 0
    RULE_statements = 1
    RULE_statement = 2
    RULE_rawText = 3
    RULE_literal = 4
    RULE_literalText = 5
    RULE_stringField = 6
    RULE_numberField = 7
    RULE_inlineFilter = 8
    RULE_numberFormat = 9
    RULE_ifBlock = 10
    RULE_ifTag = 11
    RULE_elseifBlock = 12
    RULE_elseifTag = 13
    RULE_elseBlock = 14
    RULE_expression = 15
    RULE_path = 16
    RULE_objectKey = 17
    RULE_arrayIndex = 18
    RULE_withBlock = 19
    RULE_iterateBlock = 20
    RULE_indexRange = 21
    RULE_indexRangeB = 22
    RULE_indexRangeC = 23
    RULE_iterateClause = 24
    RULE_iterateBeforeClause = 25
    RULE_iterateAfterClause = 26
    RULE_iterateBetweenClause = 27
    RULE_iterateElseClause = 28
    RULE_filterBlock = 29

    ruleNames =  [ u"template", u"statements", u"statement", u"rawText", 
                   u"literal", u"literalText", u"stringField", u"numberField", 
                   u"inlineFilter", u"numberFormat", u"ifBlock", u"ifTag", 
                   u"elseifBlock", u"elseifTag", u"elseBlock", u"expression", 
                   u"path", u"objectKey", u"arrayIndex", u"withBlock", u"iterateBlock", 
                   u"indexRange", u"indexRangeB", u"indexRangeC", u"iterateClause", 
                   u"iterateBeforeClause", u"iterateAfterClause", u"iterateBetweenClause", 
                   u"iterateElseClause", u"filterBlock" ]

    EOF = Token.EOF
    COMMENT=1
    OPENL=2
    OPEN=3
    TEXT=4
    CLOSEL=5
    TEXTL=6
    CLOSE=7
    WS=8
    OPENQS=9
    AFTER=10
    BEFORE=11
    BETWEEN=12
    ELSE=13
    ELSEIF=14
    END=15
    ESCAPE=16
    FILTER=17
    IF=18
    ITERATE=19
    WITH=20
    TYPE=21
    AND=22
    EXISTS=23
    IS=24
    NOT=25
    OR=26
    LPAREN=27
    RPAREN=28
    DOT=29
    LBRACKET=30
    RBRACKET=31
    CARET=32
    COLON=33
    PIPE=34
    PERCENT=35
    INTEGER=36
    ID=37
    ZERO=38
    DOTN=39
    PINTEGERN=40
    NUMBER_SPECIFIER=41
    ESCCHARQS=42
    CLOSEQS=43
    CHARQS=44

    def __init__(self, input):
        super(FoostacheParser, self).__init__(input)
        self.checkVersion("4.5.1")
        self._interp = ParserATNSimulator(self, self.atn, self.decisionsToDFA, self.sharedContextCache)
        self._predicates = None



    class TemplateContext(ParserRuleContext):

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

        def statements(self):
            return self.getTypedRuleContext(FoostacheParser.StatementsContext,0)


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

        def getRuleIndex(self):
            return FoostacheParser.RULE_template

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

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

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




    def template(self):

        localctx = FoostacheParser.TemplateContext(self, self._ctx, self.state)
        self.enterRule(localctx, 0, self.RULE_template)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 60
            self.statements()
            self.state = 61
            self.match(FoostacheParser.EOF)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class StatementsContext(ParserRuleContext):

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

        def statement(self, i=None):
            if i is None:
                return self.getTypedRuleContexts(FoostacheParser.StatementContext)
            else:
                return self.getTypedRuleContext(FoostacheParser.StatementContext,i)


        def getRuleIndex(self):
            return FoostacheParser.RULE_statements

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

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

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




    def statements(self):

        localctx = FoostacheParser.StatementsContext(self, self._ctx, self.state)
        self.enterRule(localctx, 2, self.RULE_statements)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 66
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,0,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 63
                    self.statement() 
                self.state = 68
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,0,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 StatementContext(ParserRuleContext):

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

        def rawText(self):
            return self.getTypedRuleContext(FoostacheParser.RawTextContext,0)


        def literal(self):
            return self.getTypedRuleContext(FoostacheParser.LiteralContext,0)


        def stringField(self):
            return self.getTypedRuleContext(FoostacheParser.StringFieldContext,0)


        def numberField(self):
            return self.getTypedRuleContext(FoostacheParser.NumberFieldContext,0)


        def ifBlock(self):
            return self.getTypedRuleContext(FoostacheParser.IfBlockContext,0)


        def withBlock(self):
            return self.getTypedRuleContext(FoostacheParser.WithBlockContext,0)


        def iterateBlock(self):
            return self.getTypedRuleContext(FoostacheParser.IterateBlockContext,0)


        def filterBlock(self):
            return self.getTypedRuleContext(FoostacheParser.FilterBlockContext,0)


        def getRuleIndex(self):
            return FoostacheParser.RULE_statement

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

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

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




    def statement(self):

        localctx = FoostacheParser.StatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 4, self.RULE_statement)
        try:
            self.state = 77
            la_ = self._interp.adaptivePredict(self._input,1,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 69
                self.rawText()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 70
                self.literal()
                pass

            elif la_ == 3:
                self.enterOuterAlt(localctx, 3)
                self.state = 71
                self.stringField()
                pass

            elif la_ == 4:
                self.enterOuterAlt(localctx, 4)
                self.state = 72
                self.numberField()
                pass

            elif la_ == 5:
                self.enterOuterAlt(localctx, 5)
                self.state = 73
                self.ifBlock()
                pass

            elif la_ == 6:
                self.enterOuterAlt(localctx, 6)
                self.state = 74
                self.withBlock()
                pass

            elif la_ == 7:
                self.enterOuterAlt(localctx, 7)
                self.state = 75
                self.iterateBlock()
                pass

            elif la_ == 8:
                self.enterOuterAlt(localctx, 8)
                self.state = 76
                self.filterBlock()
                pass


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

    class RawTextContext(ParserRuleContext):

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

        def TEXT(self, i=None):
            if i is None:
                return self.getTokens(FoostacheParser.TEXT)
            else:
                return self.getToken(FoostacheParser.TEXT, i)

        def getRuleIndex(self):
            return FoostacheParser.RULE_rawText

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

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

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




    def rawText(self):

        localctx = FoostacheParser.RawTextContext(self, self._ctx, self.state)
        self.enterRule(localctx, 6, self.RULE_rawText)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 80 
            self._errHandler.sync(self)
            _alt = 1
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt == 1:
                    self.state = 79
                    self.match(FoostacheParser.TEXT)

                else:
                    raise NoViableAltException(self)
                self.state = 82 
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,2,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 LiteralContext(ParserRuleContext):

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

        def OPENL(self):
            return self.getToken(FoostacheParser.OPENL, 0)

        def literalText(self):
            return self.getTypedRuleContext(FoostacheParser.LiteralTextContext,0)


        def CLOSEL(self):
            return self.getToken(FoostacheParser.CLOSEL, 0)

        def getRuleIndex(self):
            return FoostacheParser.RULE_literal

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

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

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




    def literal(self):

        localctx = FoostacheParser.LiteralContext(self, self._ctx, self.state)
        self.enterRule(localctx, 8, self.RULE_literal)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 84
            self.match(FoostacheParser.OPENL)
            self.state = 85
            self.literalText()
            self.state = 86
            self.match(FoostacheParser.CLOSEL)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class LiteralTextContext(ParserRuleContext):

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

        def TEXTL(self, i=None):
            if i is None:
                return self.getTokens(FoostacheParser.TEXTL)
            else:
                return self.getToken(FoostacheParser.TEXTL, i)

        def getRuleIndex(self):
            return FoostacheParser.RULE_literalText

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

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

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




    def literalText(self):

        localctx = FoostacheParser.LiteralTextContext(self, self._ctx, self.state)
        self.enterRule(localctx, 10, self.RULE_literalText)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 91
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==FoostacheParser.TEXTL:
                self.state = 88
                self.match(FoostacheParser.TEXTL)
                self.state = 93
                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 StringFieldContext(ParserRuleContext):

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

        def OPEN(self):
            return self.getToken(FoostacheParser.OPEN, 0)

        def path(self):
            return self.getTypedRuleContext(FoostacheParser.PathContext,0)


        def CLOSE(self):
            return self.getToken(FoostacheParser.CLOSE, 0)

        def inlineFilter(self, i=None):
            if i is None:
                return self.getTypedRuleContexts(FoostacheParser.InlineFilterContext)
            else:
                return self.getTypedRuleContext(FoostacheParser.InlineFilterContext,i)


        def getRuleIndex(self):
            return FoostacheParser.RULE_stringField

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

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

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




    def stringField(self):

        localctx = FoostacheParser.StringFieldContext(self, self._ctx, self.state)
        self.enterRule(localctx, 12, self.RULE_stringField)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 94
            self.match(FoostacheParser.OPEN)
            self.state = 95
            self.path()
            self.state = 99
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==FoostacheParser.PIPE:
                self.state = 96
                self.inlineFilter()
                self.state = 101
                self._errHandler.sync(self)
                _la = self._input.LA(1)

            self.state = 102
            self.match(FoostacheParser.CLOSE)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class NumberFieldContext(ParserRuleContext):

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

        def OPEN(self):
            return self.getToken(FoostacheParser.OPEN, 0)

        def path(self):
            return self.getTypedRuleContext(FoostacheParser.PathContext,0)


        def numberFormat(self):
            return self.getTypedRuleContext(FoostacheParser.NumberFormatContext,0)


        def CLOSE(self):
            return self.getToken(FoostacheParser.CLOSE, 0)

        def inlineFilter(self, i=None):
            if i is None:
                return self.getTypedRuleContexts(FoostacheParser.InlineFilterContext)
            else:
                return self.getTypedRuleContext(FoostacheParser.InlineFilterContext,i)


        def getRuleIndex(self):
            return FoostacheParser.RULE_numberField

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

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

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




    def numberField(self):

        localctx = FoostacheParser.NumberFieldContext(self, self._ctx, self.state)
        self.enterRule(localctx, 14, self.RULE_numberField)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 104
            self.match(FoostacheParser.OPEN)
            self.state = 105
            self.path()
            self.state = 106
            self.numberFormat()
            self.state = 110
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==FoostacheParser.PIPE:
                self.state = 107
                self.inlineFilter()
                self.state = 112
                self._errHandler.sync(self)
                _la = self._input.LA(1)

            self.state = 113
            self.match(FoostacheParser.CLOSE)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class InlineFilterContext(ParserRuleContext):

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

        def PIPE(self):
            return self.getToken(FoostacheParser.PIPE, 0)

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

        def getRuleIndex(self):
            return FoostacheParser.RULE_inlineFilter

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

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

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




    def inlineFilter(self):

        localctx = FoostacheParser.InlineFilterContext(self, self._ctx, self.state)
        self.enterRule(localctx, 16, self.RULE_inlineFilter)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 115
            self.match(FoostacheParser.PIPE)
            self.state = 116
            self.match(FoostacheParser.ID)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class NumberFormatContext(ParserRuleContext):

        def __init__(self, parser, parent=None, invokingState=-1):
            super(FoostacheParser.NumberFormatContext, self).__init__(parent, invokingState)
            self.parser = parser
            self.flags = None # Token
            self.width = None # Token
            self.precision = None # Token
            self.specifier = None # Token

        def PERCENT(self):
            return self.getToken(FoostacheParser.PERCENT, 0)

        def NUMBER_SPECIFIER(self):
            return self.getToken(FoostacheParser.NUMBER_SPECIFIER, 0)

        def DOTN(self):
            return self.getToken(FoostacheParser.DOTN, 0)

        def ZERO(self):
            return self.getToken(FoostacheParser.ZERO, 0)

        def PINTEGERN(self, i=None):
            if i is None:
                return self.getTokens(FoostacheParser.PINTEGERN)
            else:
                return self.getToken(FoostacheParser.PINTEGERN, i)

        def getRuleIndex(self):
            return FoostacheParser.RULE_numberFormat

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

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

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




    def numberFormat(self):

        localctx = FoostacheParser.NumberFormatContext(self, self._ctx, self.state)
        self.enterRule(localctx, 18, self.RULE_numberFormat)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 118
            self.match(FoostacheParser.PERCENT)
            self.state = 120
            _la = self._input.LA(1)
            if _la==FoostacheParser.ZERO:
                self.state = 119
                localctx.flags = self.match(FoostacheParser.ZERO)


            self.state = 123
            _la = self._input.LA(1)
            if _la==FoostacheParser.PINTEGERN:
                self.state = 122
                localctx.width = self.match(FoostacheParser.PINTEGERN)


            self.state = 127
            _la = self._input.LA(1)
            if _la==FoostacheParser.DOTN:
                self.state = 125
                self.match(FoostacheParser.DOTN)
                self.state = 126
                localctx.precision = self.match(FoostacheParser.PINTEGERN)


            self.state = 129
            localctx.specifier = self.match(FoostacheParser.NUMBER_SPECIFIER)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class IfBlockContext(ParserRuleContext):

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

        def ifTag(self):
            return self.getTypedRuleContext(FoostacheParser.IfTagContext,0)


        def statements(self):
            return self.getTypedRuleContext(FoostacheParser.StatementsContext,0)


        def OPEN(self):
            return self.getToken(FoostacheParser.OPEN, 0)

        def END(self):
            return self.getToken(FoostacheParser.END, 0)

        def CLOSE(self):
            return self.getToken(FoostacheParser.CLOSE, 0)

        def elseifBlock(self, i=None):
            if i is None:
                return self.getTypedRuleContexts(FoostacheParser.ElseifBlockContext)
            else:
                return self.getTypedRuleContext(FoostacheParser.ElseifBlockContext,i)


        def elseBlock(self):
            return self.getTypedRuleContext(FoostacheParser.ElseBlockContext,0)


        def getRuleIndex(self):
            return FoostacheParser.RULE_ifBlock

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

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

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




    def ifBlock(self):

        localctx = FoostacheParser.IfBlockContext(self, self._ctx, self.state)
        self.enterRule(localctx, 20, self.RULE_ifBlock)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 131
            self.ifTag()
            self.state = 132
            self.statements()
            self.state = 136
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,9,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 133
                    self.elseifBlock() 
                self.state = 138
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,9,self._ctx)

            self.state = 140
            la_ = self._interp.adaptivePredict(self._input,10,self._ctx)
            if la_ == 1:
                self.state = 139
                self.elseBlock()


            self.state = 142
            self.match(FoostacheParser.OPEN)
            self.state = 143
            self.match(FoostacheParser.END)
            self.state = 144
            self.match(FoostacheParser.CLOSE)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class IfTagContext(ParserRuleContext):

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

        def OPEN(self):
            return self.getToken(FoostacheParser.OPEN, 0)

        def IF(self):
            return self.getToken(FoostacheParser.IF, 0)

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


        def CLOSE(self):
            return self.getToken(FoostacheParser.CLOSE, 0)

        def getRuleIndex(self):
            return FoostacheParser.RULE_ifTag

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

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

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




    def ifTag(self):

        localctx = FoostacheParser.IfTagContext(self, self._ctx, self.state)
        self.enterRule(localctx, 22, self.RULE_ifTag)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 146
            self.match(FoostacheParser.OPEN)
            self.state = 147
            self.match(FoostacheParser.IF)
            self.state = 148
            self.expression(0)
            self.state = 149
            self.match(FoostacheParser.CLOSE)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ElseifBlockContext(ParserRuleContext):

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

        def elseifTag(self):
            return self.getTypedRuleContext(FoostacheParser.ElseifTagContext,0)


        def statements(self):
            return self.getTypedRuleContext(FoostacheParser.StatementsContext,0)


        def getRuleIndex(self):
            return FoostacheParser.RULE_elseifBlock

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

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

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




    def elseifBlock(self):

        localctx = FoostacheParser.ElseifBlockContext(self, self._ctx, self.state)
        self.enterRule(localctx, 24, self.RULE_elseifBlock)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 151
            self.elseifTag()
            self.state = 152
            self.statements()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ElseifTagContext(ParserRuleContext):

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

        def OPEN(self):
            return self.getToken(FoostacheParser.OPEN, 0)

        def ELSEIF(self):
            return self.getToken(FoostacheParser.ELSEIF, 0)

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


        def CLOSE(self):
            return self.getToken(FoostacheParser.CLOSE, 0)

        def getRuleIndex(self):
            return FoostacheParser.RULE_elseifTag

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

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

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




    def elseifTag(self):

        localctx = FoostacheParser.ElseifTagContext(self, self._ctx, self.state)
        self.enterRule(localctx, 26, self.RULE_elseifTag)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 154
            self.match(FoostacheParser.OPEN)
            self.state = 155
            self.match(FoostacheParser.ELSEIF)
            self.state = 156
            self.expression(0)
            self.state = 157
            self.match(FoostacheParser.CLOSE)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ElseBlockContext(ParserRuleContext):

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

        def OPEN(self):
            return self.getToken(FoostacheParser.OPEN, 0)

        def ELSE(self):
            return self.getToken(FoostacheParser.ELSE, 0)

        def CLOSE(self):
            return self.getToken(FoostacheParser.CLOSE, 0)

        def statements(self):
            return self.getTypedRuleContext(FoostacheParser.StatementsContext,0)


        def getRuleIndex(self):
            return FoostacheParser.RULE_elseBlock

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

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

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




    def elseBlock(self):

        localctx = FoostacheParser.ElseBlockContext(self, self._ctx, self.state)
        self.enterRule(localctx, 28, self.RULE_elseBlock)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 159
            self.match(FoostacheParser.OPEN)
            self.state = 160
            self.match(FoostacheParser.ELSE)
            self.state = 161
            self.match(FoostacheParser.CLOSE)
            self.state = 162
            self.statements()
        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):

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


        def getRuleIndex(self):
            return FoostacheParser.RULE_expression

     
        def copyFrom(self, ctx):
            super(FoostacheParser.ExpressionContext, self).copyFrom(ctx)


    class OrExpressionContext(ExpressionContext):

        def __init__(self, parser, ctx): # actually a FoostacheParser.ExpressionContext)
            super(FoostacheParser.OrExpressionContext, self).__init__(parser)
            self.expr1 = None # ExpressionContext
            self.expr2 = None # ExpressionContext
            self.copyFrom(ctx)

        def OR(self):
            return self.getToken(FoostacheParser.OR, 0)
        def expression(self, i=None):
            if i is None:
                return self.getTypedRuleContexts(FoostacheParser.ExpressionContext)
            else:
                return self.getTypedRuleContext(FoostacheParser.ExpressionContext,i)


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

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

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


    class AndExpressionContext(ExpressionContext):

        def __init__(self, parser, ctx): # actually a FoostacheParser.ExpressionContext)
            super(FoostacheParser.AndExpressionContext, self).__init__(parser)
            self.expr1 = None # ExpressionContext
            self.expr2 = None # ExpressionContext
            self.copyFrom(ctx)

        def AND(self):
            return self.getToken(FoostacheParser.AND, 0)
        def expression(self, i=None):
            if i is None:
                return self.getTypedRuleContexts(FoostacheParser.ExpressionContext)
            else:
                return self.getTypedRuleContext(FoostacheParser.ExpressionContext,i)


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

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

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


    class BoolExpressionContext(ExpressionContext):

        def __init__(self, parser, ctx): # actually a FoostacheParser.ExpressionContext)
            super(FoostacheParser.BoolExpressionContext, self).__init__(parser)
            self.copyFrom(ctx)

        def path(self):
            return self.getTypedRuleContext(FoostacheParser.PathContext,0)


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

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

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


    class ExistsExpressionContext(ExpressionContext):

        def __init__(self, parser, ctx): # actually a FoostacheParser.ExpressionContext)
            super(FoostacheParser.ExistsExpressionContext, self).__init__(parser)
            self.copyFrom(ctx)

        def path(self):
            return self.getTypedRuleContext(FoostacheParser.PathContext,0)

        def EXISTS(self):
            return self.getToken(FoostacheParser.EXISTS, 0)

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

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

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


    class NotExpressionContext(ExpressionContext):

        def __init__(self, parser, ctx): # actually a FoostacheParser.ExpressionContext)
            super(FoostacheParser.NotExpressionContext, self).__init__(parser)
            self.copyFrom(ctx)

        def NOT(self):
            return self.getToken(FoostacheParser.NOT, 0)
        def expression(self):
            return self.getTypedRuleContext(FoostacheParser.ExpressionContext,0)


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

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

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


    class ParenExpressionContext(ExpressionContext):

        def __init__(self, parser, ctx): # actually a FoostacheParser.ExpressionContext)
            super(FoostacheParser.ParenExpressionContext, self).__init__(parser)
            self.copyFrom(ctx)

        def LPAREN(self):
            return self.getToken(FoostacheParser.LPAREN, 0)
        def expression(self):
            return self.getTypedRuleContext(FoostacheParser.ExpressionContext,0)

        def RPAREN(self):
            return self.getToken(FoostacheParser.RPAREN, 0)

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

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

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


    class TypeExpressionContext(ExpressionContext):

        def __init__(self, parser, ctx): # actually a FoostacheParser.ExpressionContext)
            super(FoostacheParser.TypeExpressionContext, self).__init__(parser)
            self.copyFrom(ctx)

        def path(self):
            return self.getTypedRuleContext(FoostacheParser.PathContext,0)

        def IS(self):
            return self.getToken(FoostacheParser.IS, 0)
        def TYPE(self):
            return self.getToken(FoostacheParser.TYPE, 0)

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

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

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



    def expression(self, _p=0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = FoostacheParser.ExpressionContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 30
        self.enterRecursionRule(localctx, 30, self.RULE_expression, _p)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 179
            la_ = self._interp.adaptivePredict(self._input,11,self._ctx)
            if la_ == 1:
                localctx = FoostacheParser.NotExpressionContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx

                self.state = 165
                self.match(FoostacheParser.NOT)
                self.state = 166
                self.expression(4)
                pass

            elif la_ == 2:
                localctx = FoostacheParser.BoolExpressionContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 167
                self.path()
                pass

            elif la_ == 3:
                localctx = FoostacheParser.ExistsExpressionContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 168
                self.path()
                self.state = 169
                self.match(FoostacheParser.EXISTS)
                pass

            elif la_ == 4:
                localctx = FoostacheParser.TypeExpressionContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 171
                self.path()
                self.state = 172
                self.match(FoostacheParser.IS)
                self.state = 173
                self.match(FoostacheParser.TYPE)
                pass

            elif la_ == 5:
                localctx = FoostacheParser.ParenExpressionContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 175
                self.match(FoostacheParser.LPAREN)
                self.state = 176
                self.expression(0)
                self.state = 177
                self.match(FoostacheParser.RPAREN)
                pass


            self._ctx.stop = self._input.LT(-1)
            self.state = 189
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,13,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 = 187
                    la_ = self._interp.adaptivePredict(self._input,12,self._ctx)
                    if la_ == 1:
                        localctx = FoostacheParser.AndExpressionContext(self, FoostacheParser.ExpressionContext(self, _parentctx, _parentState))
                        localctx.expr1 = _prevctx
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expression)
                        self.state = 181
                        if not self.precpred(self._ctx, 3):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 3)")
                        self.state = 182
                        self.match(FoostacheParser.AND)
                        self.state = 183
                        localctx.expr2 = self.expression(4)
                        pass

                    elif la_ == 2:
                        localctx = FoostacheParser.OrExpressionContext(self, FoostacheParser.ExpressionContext(self, _parentctx, _parentState))
                        localctx.expr1 = _prevctx
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expression)
                        self.state = 184
                        if not self.precpred(self._ctx, 2):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
                        self.state = 185
                        self.match(FoostacheParser.OR)
                        self.state = 186
                        localctx.expr2 = self.expression(3)
                        pass

             
                self.state = 191
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,13,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 PathContext(ParserRuleContext):

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


        def getRuleIndex(self):
            return FoostacheParser.RULE_path

     
        def copyFrom(self, ctx):
            super(FoostacheParser.PathContext, self).copyFrom(ctx)



    class CaretPathContext(PathContext):

        def __init__(self, parser, ctx): # actually a FoostacheParser.PathContext)
            super(FoostacheParser.CaretPathContext, self).__init__(parser)
            self.copyFrom(ctx)

        def CARET(self, i=None):
            if i is None:
                return self.getTokens(FoostacheParser.CARET)
            else:
                return self.getToken(FoostacheParser.CARET, i)
        def objectKey(self, i=None):
            if i is None:
                return self.getTypedRuleContexts(FoostacheParser.ObjectKeyContext)
            else:
                return self.getTypedRuleContext(FoostacheParser.ObjectKeyContext,i)

        def LBRACKET(self, i=None):
            if i is None:
                return self.getTokens(FoostacheParser.LBRACKET)
            else:
                return self.getToken(FoostacheParser.LBRACKET, i)
        def arrayIndex(self, i=None):
            if i is None:
                return self.getTypedRuleContexts(FoostacheParser.ArrayIndexContext)
            else:
                return self.getTypedRuleContext(FoostacheParser.ArrayIndexContext,i)

        def RBRACKET(self, i=None):
            if i is None:
                return self.getTokens(FoostacheParser.RBRACKET)
            else:
                return self.getToken(FoostacheParser.RBRACKET, i)
        def DOT(self, i=None):
            if i is None:
                return self.getTokens(FoostacheParser.DOT)
            else:
                return self.getToken(FoostacheParser.DOT, i)

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

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

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


    class DotPathContext(PathContext):

        def __init__(self, parser, ctx): # actually a FoostacheParser.PathContext)
            super(FoostacheParser.DotPathContext, self).__init__(parser)
            self.copyFrom(ctx)

        def DOT(self):
            return self.getToken(FoostacheParser.DOT, 0)

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

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

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



    def path(self):

        localctx = FoostacheParser.PathContext(self, self._ctx, self.state)
        self.enterRule(localctx, 32, self.RULE_path)
        try:
            self.state = 219
            la_ = self._interp.adaptivePredict(self._input,19,self._ctx)
            if la_ == 1:
                localctx = FoostacheParser.DotPathContext(self, localctx)
                self.enterOuterAlt(localctx, 1)
                self.state = 192
                self.match(FoostacheParser.DOT)
                pass

            elif la_ == 2:
                localctx = FoostacheParser.CaretPathContext(self, localctx)
                self.enterOuterAlt(localctx, 2)
                self.state = 196
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,14,self._ctx)
                while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                    if _alt==1:
                        self.state = 193
                        self.match(FoostacheParser.CARET) 
                    self.state = 198
                    self._errHandler.sync(self)
                    _alt = self._interp.adaptivePredict(self._input,14,self._ctx)

                self.state = 217
                la_ = self._interp.adaptivePredict(self._input,18,self._ctx)
                if la_ == 1:
                    self.state = 204
                    token = self._input.LA(1)
                    if token in [FoostacheParser.OPENQS, FoostacheParser.ID]:
                        self.state = 199
                        self.objectKey()

                    elif token in [FoostacheParser.LBRACKET]:
                        self.state = 200
                        self.match(FoostacheParser.LBRACKET)
                        self.state = 201
                        self.arrayIndex()
                        self.state = 202
                        self.match(FoostacheParser.RBRACKET)

                    else:
                        raise NoViableAltException(self)

                    self.state = 214
                    self._errHandler.sync(self)
                    _alt = self._interp.adaptivePredict(self._input,17,self._ctx)
                    while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                        if _alt==1:
                            self.state = 212
                            token = self._input.LA(1)
                            if token in [FoostacheParser.DOT]:
                                self.state = 206
                                self.match(FoostacheParser.DOT)
                                self.state = 207
                                self.objectKey()

                            elif token in [FoostacheParser.LBRACKET]:
                                self.state = 208
                                self.match(FoostacheParser.LBRACKET)
                                self.state = 209
                                self.arrayIndex()
                                self.state = 210
                                self.match(FoostacheParser.RBRACKET)

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



                pass


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

    class ObjectKeyContext(ParserRuleContext):

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


        def getRuleIndex(self):
            return FoostacheParser.RULE_objectKey

     
        def copyFrom(self, ctx):
            super(FoostacheParser.ObjectKeyContext, self).copyFrom(ctx)



    class IdObjectKeyContext(ObjectKeyContext):

        def __init__(self, parser, ctx): # actually a FoostacheParser.ObjectKeyContext)
            super(FoostacheParser.IdObjectKeyContext, self).__init__(parser)
            self.copyFrom(ctx)

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

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

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

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


    class QsObjectKeyContext(ObjectKeyContext):

        def __init__(self, parser, ctx): # actually a FoostacheParser.ObjectKeyContext)
            super(FoostacheParser.QsObjectKeyContext, self).__init__(parser)
            self.copyFrom(ctx)

        def OPENQS(self):
            return self.getToken(FoostacheParser.OPENQS, 0)
        def CLOSEQS(self):
            return self.getToken(FoostacheParser.CLOSEQS, 0)
        def CHARQS(self, i=None):
            if i is None:
                return self.getTokens(FoostacheParser.CHARQS)
            else:
                return self.getToken(FoostacheParser.CHARQS, i)
        def ESCCHARQS(self, i=None):
            if i is None:
                return self.getTokens(FoostacheParser.ESCCHARQS)
            else:
                return self.getToken(FoostacheParser.ESCCHARQS, i)

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

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

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



    def objectKey(self):

        localctx = FoostacheParser.ObjectKeyContext(self, self._ctx, self.state)
        self.enterRule(localctx, 34, self.RULE_objectKey)
        self._la = 0 # Token type
        try:
            self.state = 230
            token = self._input.LA(1)
            if token in [FoostacheParser.ID]:
                localctx = FoostacheParser.IdObjectKeyContext(self, localctx)
                self.enterOuterAlt(localctx, 1)
                self.state = 221
                self.match(FoostacheParser.ID)

            elif token in [FoostacheParser.OPENQS]:
                localctx = FoostacheParser.QsObjectKeyContext(self, localctx)
                self.enterOuterAlt(localctx, 2)
                self.state = 222
                self.match(FoostacheParser.OPENQS)
                self.state = 226
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while _la==FoostacheParser.ESCCHARQS or _la==FoostacheParser.CHARQS:
                    self.state = 223
                    _la = self._input.LA(1)
                    if not(_la==FoostacheParser.ESCCHARQS or _la==FoostacheParser.CHARQS):
                        self._errHandler.recoverInline(self)
                    else:
                        self.consume()
                    self.state = 228
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)

                self.state = 229
                self.match(FoostacheParser.CLOSEQS)

            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 ArrayIndexContext(ParserRuleContext):

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

        def INTEGER(self):
            return self.getToken(FoostacheParser.INTEGER, 0)

        def getRuleIndex(self):
            return FoostacheParser.RULE_arrayIndex

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

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

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




    def arrayIndex(self):

        localctx = FoostacheParser.ArrayIndexContext(self, self._ctx, self.state)
        self.enterRule(localctx, 36, self.RULE_arrayIndex)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 232
            self.match(FoostacheParser.INTEGER)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class WithBlockContext(ParserRuleContext):

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

        def OPEN(self, i=None):
            if i is None:
                return self.getTokens(FoostacheParser.OPEN)
            else:
                return self.getToken(FoostacheParser.OPEN, i)

        def WITH(self):
            return self.getToken(FoostacheParser.WITH, 0)

        def path(self):
            return self.getTypedRuleContext(FoostacheParser.PathContext,0)


        def CLOSE(self, i=None):
            if i is None:
                return self.getTokens(FoostacheParser.CLOSE)
            else:
                return self.getToken(FoostacheParser.CLOSE, i)

        def statements(self):
            return self.getTypedRuleContext(FoostacheParser.StatementsContext,0)


        def END(self):
            return self.getToken(FoostacheParser.END, 0)

        def getRuleIndex(self):
            return FoostacheParser.RULE_withBlock

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

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

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




    def withBlock(self):

        localctx = FoostacheParser.WithBlockContext(self, self._ctx, self.state)
        self.enterRule(localctx, 38, self.RULE_withBlock)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 234
            self.match(FoostacheParser.OPEN)
            self.state = 235
            self.match(FoostacheParser.WITH)
            self.state = 236
            self.path()
            self.state = 237
            self.match(FoostacheParser.CLOSE)
            self.state = 238
            self.statements()
            self.state = 239
            self.match(FoostacheParser.OPEN)
            self.state = 240
            self.match(FoostacheParser.END)
            self.state = 241
            self.match(FoostacheParser.CLOSE)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class IterateBlockContext(ParserRuleContext):

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

        def OPEN(self, i=None):
            if i is None:
                return self.getTokens(FoostacheParser.OPEN)
            else:
                return self.getToken(FoostacheParser.OPEN, i)

        def ITERATE(self):
            return self.getToken(FoostacheParser.ITERATE, 0)

        def path(self):
            return self.getTypedRuleContext(FoostacheParser.PathContext,0)


        def indexRange(self):
            return self.getTypedRuleContext(FoostacheParser.IndexRangeContext,0)


        def CLOSE(self, i=None):
            if i is None:
                return self.getTokens(FoostacheParser.CLOSE)
            else:
                return self.getToken(FoostacheParser.CLOSE, i)

        def statements(self):
            return self.getTypedRuleContext(FoostacheParser.StatementsContext,0)


        def END(self):
            return self.getToken(FoostacheParser.END, 0)

        def iterateClause(self, i=None):
            if i is None:
                return self.getTypedRuleContexts(FoostacheParser.IterateClauseContext)
            else:
                return self.getTypedRuleContext(FoostacheParser.IterateClauseContext,i)


        def getRuleIndex(self):
            return FoostacheParser.RULE_iterateBlock

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

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

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




    def iterateBlock(self):

        localctx = FoostacheParser.IterateBlockContext(self, self._ctx, self.state)
        self.enterRule(localctx, 40, self.RULE_iterateBlock)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 243
            self.match(FoostacheParser.OPEN)
            self.state = 244
            self.match(FoostacheParser.ITERATE)
            self.state = 245
            self.path()
            self.state = 246
            self.indexRange()
            self.state = 247
            self.match(FoostacheParser.CLOSE)
            self.state = 248
            self.statements()
            self.state = 252
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,22,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 249
                    self.iterateClause() 
                self.state = 254
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,22,self._ctx)

            self.state = 255
            self.match(FoostacheParser.OPEN)
            self.state = 256
            self.match(FoostacheParser.END)
            self.state = 257
            self.match(FoostacheParser.CLOSE)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class IndexRangeContext(ParserRuleContext):

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

        def INTEGER(self):
            return self.getToken(FoostacheParser.INTEGER, 0)

        def indexRangeB(self):
            return self.getTypedRuleContext(FoostacheParser.IndexRangeBContext,0)


        def getRuleIndex(self):
            return FoostacheParser.RULE_indexRange

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

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

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




    def indexRange(self):

        localctx = FoostacheParser.IndexRangeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 42, self.RULE_indexRange)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 260
            _la = self._input.LA(1)
            if _la==FoostacheParser.INTEGER:
                self.state = 259
                self.match(FoostacheParser.INTEGER)


            self.state = 263
            _la = self._input.LA(1)
            if _la==FoostacheParser.COLON:
                self.state = 262
                self.indexRangeB()


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

    class IndexRangeBContext(ParserRuleContext):

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

        def COLON(self):
            return self.getToken(FoostacheParser.COLON, 0)

        def INTEGER(self):
            return self.getToken(FoostacheParser.INTEGER, 0)

        def indexRangeC(self):
            return self.getTypedRuleContext(FoostacheParser.IndexRangeCContext,0)


        def getRuleIndex(self):
            return FoostacheParser.RULE_indexRangeB

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

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

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




    def indexRangeB(self):

        localctx = FoostacheParser.IndexRangeBContext(self, self._ctx, self.state)
        self.enterRule(localctx, 44, self.RULE_indexRangeB)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 265
            self.match(FoostacheParser.COLON)
            self.state = 267
            _la = self._input.LA(1)
            if _la==FoostacheParser.INTEGER:
                self.state = 266
                self.match(FoostacheParser.INTEGER)


            self.state = 270
            _la = self._input.LA(1)
            if _la==FoostacheParser.COLON:
                self.state = 269
                self.indexRangeC()


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

    class IndexRangeCContext(ParserRuleContext):

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

        def COLON(self):
            return self.getToken(FoostacheParser.COLON, 0)

        def INTEGER(self):
            return self.getToken(FoostacheParser.INTEGER, 0)

        def getRuleIndex(self):
            return FoostacheParser.RULE_indexRangeC

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

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

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




    def indexRangeC(self):

        localctx = FoostacheParser.IndexRangeCContext(self, self._ctx, self.state)
        self.enterRule(localctx, 46, self.RULE_indexRangeC)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 272
            self.match(FoostacheParser.COLON)
            self.state = 273
            self.match(FoostacheParser.INTEGER)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class IterateClauseContext(ParserRuleContext):

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

        def iterateBeforeClause(self):
            return self.getTypedRuleContext(FoostacheParser.IterateBeforeClauseContext,0)


        def iterateAfterClause(self):
            return self.getTypedRuleContext(FoostacheParser.IterateAfterClauseContext,0)


        def iterateBetweenClause(self):
            return self.getTypedRuleContext(FoostacheParser.IterateBetweenClauseContext,0)


        def iterateElseClause(self):
            return self.getTypedRuleContext(FoostacheParser.IterateElseClauseContext,0)


        def getRuleIndex(self):
            return FoostacheParser.RULE_iterateClause

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

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

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




    def iterateClause(self):

        localctx = FoostacheParser.IterateClauseContext(self, self._ctx, self.state)
        self.enterRule(localctx, 48, self.RULE_iterateClause)
        try:
            self.state = 279
            la_ = self._interp.adaptivePredict(self._input,27,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 275
                self.iterateBeforeClause()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 276
                self.iterateAfterClause()
                pass

            elif la_ == 3:
                self.enterOuterAlt(localctx, 3)
                self.state = 277
                self.iterateBetweenClause()
                pass

            elif la_ == 4:
                self.enterOuterAlt(localctx, 4)
                self.state = 278
                self.iterateElseClause()
                pass


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

    class IterateBeforeClauseContext(ParserRuleContext):

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

        def OPEN(self):
            return self.getToken(FoostacheParser.OPEN, 0)

        def BEFORE(self):
            return self.getToken(FoostacheParser.BEFORE, 0)

        def CLOSE(self):
            return self.getToken(FoostacheParser.CLOSE, 0)

        def statements(self):
            return self.getTypedRuleContext(FoostacheParser.StatementsContext,0)


        def getRuleIndex(self):
            return FoostacheParser.RULE_iterateBeforeClause

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

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

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




    def iterateBeforeClause(self):

        localctx = FoostacheParser.IterateBeforeClauseContext(self, self._ctx, self.state)
        self.enterRule(localctx, 50, self.RULE_iterateBeforeClause)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 281
            self.match(FoostacheParser.OPEN)
            self.state = 282
            self.match(FoostacheParser.BEFORE)
            self.state = 283
            self.match(FoostacheParser.CLOSE)
            self.state = 284
            self.statements()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class IterateAfterClauseContext(ParserRuleContext):

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

        def OPEN(self):
            return self.getToken(FoostacheParser.OPEN, 0)

        def AFTER(self):
            return self.getToken(FoostacheParser.AFTER, 0)

        def CLOSE(self):
            return self.getToken(FoostacheParser.CLOSE, 0)

        def statements(self):
            return self.getTypedRuleContext(FoostacheParser.StatementsContext,0)


        def getRuleIndex(self):
            return FoostacheParser.RULE_iterateAfterClause

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

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

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




    def iterateAfterClause(self):

        localctx = FoostacheParser.IterateAfterClauseContext(self, self._ctx, self.state)
        self.enterRule(localctx, 52, self.RULE_iterateAfterClause)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 286
            self.match(FoostacheParser.OPEN)
            self.state = 287
            self.match(FoostacheParser.AFTER)
            self.state = 288
            self.match(FoostacheParser.CLOSE)
            self.state = 289
            self.statements()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class IterateBetweenClauseContext(ParserRuleContext):

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

        def OPEN(self):
            return self.getToken(FoostacheParser.OPEN, 0)

        def BETWEEN(self):
            return self.getToken(FoostacheParser.BETWEEN, 0)

        def CLOSE(self):
            return self.getToken(FoostacheParser.CLOSE, 0)

        def statements(self):
            return self.getTypedRuleContext(FoostacheParser.StatementsContext,0)


        def getRuleIndex(self):
            return FoostacheParser.RULE_iterateBetweenClause

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

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

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




    def iterateBetweenClause(self):

        localctx = FoostacheParser.IterateBetweenClauseContext(self, self._ctx, self.state)
        self.enterRule(localctx, 54, self.RULE_iterateBetweenClause)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 291
            self.match(FoostacheParser.OPEN)
            self.state = 292
            self.match(FoostacheParser.BETWEEN)
            self.state = 293
            self.match(FoostacheParser.CLOSE)
            self.state = 294
            self.statements()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class IterateElseClauseContext(ParserRuleContext):

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

        def OPEN(self):
            return self.getToken(FoostacheParser.OPEN, 0)

        def ELSE(self):
            return self.getToken(FoostacheParser.ELSE, 0)

        def CLOSE(self):
            return self.getToken(FoostacheParser.CLOSE, 0)

        def statements(self):
            return self.getTypedRuleContext(FoostacheParser.StatementsContext,0)


        def getRuleIndex(self):
            return FoostacheParser.RULE_iterateElseClause

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

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

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




    def iterateElseClause(self):

        localctx = FoostacheParser.IterateElseClauseContext(self, self._ctx, self.state)
        self.enterRule(localctx, 56, self.RULE_iterateElseClause)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 296
            self.match(FoostacheParser.OPEN)
            self.state = 297
            self.match(FoostacheParser.ELSE)
            self.state = 298
            self.match(FoostacheParser.CLOSE)
            self.state = 299
            self.statements()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class FilterBlockContext(ParserRuleContext):

        def __init__(self, parser, parent=None, invokingState=-1):
            super(FoostacheParser.FilterBlockContext, self).__init__(parent, invokingState)
            self.parser = parser
            self.filterName = None # Token

        def OPEN(self, i=None):
            if i is None:
                return self.getTokens(FoostacheParser.OPEN)
            else:
                return self.getToken(FoostacheParser.OPEN, i)

        def FILTER(self):
            return self.getToken(FoostacheParser.FILTER, 0)

        def CLOSE(self, i=None):
            if i is None:
                return self.getTokens(FoostacheParser.CLOSE)
            else:
                return self.getToken(FoostacheParser.CLOSE, i)

        def statements(self):
            return self.getTypedRuleContext(FoostacheParser.StatementsContext,0)


        def END(self):
            return self.getToken(FoostacheParser.END, 0)

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

        def getRuleIndex(self):
            return FoostacheParser.RULE_filterBlock

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

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

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




    def filterBlock(self):

        localctx = FoostacheParser.FilterBlockContext(self, self._ctx, self.state)
        self.enterRule(localctx, 58, self.RULE_filterBlock)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 301
            self.match(FoostacheParser.OPEN)
            self.state = 302
            self.match(FoostacheParser.FILTER)
            self.state = 303
            localctx.filterName = self.match(FoostacheParser.ID)
            self.state = 304
            self.match(FoostacheParser.CLOSE)
            self.state = 305
            self.statements()
            self.state = 306
            self.match(FoostacheParser.OPEN)
            self.state = 307
            self.match(FoostacheParser.END)
            self.state = 308
            self.match(FoostacheParser.CLOSE)
        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, ruleIndex, predIndex):
        if self._predicates == None:
            self._predicates = dict()
        self._predicates[15] = self.expression_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 expression_sempred(self, localctx, predIndex):
            if predIndex == 0:
                return self.precpred(self._ctx, 3)
         

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




