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

def serializedATN():
    return [
        4,1,173,1602,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,
        7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,
        13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2,
        20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,26,7,
        26,2,27,7,27,2,28,7,28,2,29,7,29,2,30,7,30,2,31,7,31,2,32,7,32,2,
        33,7,33,2,34,7,34,2,35,7,35,2,36,7,36,2,37,7,37,2,38,7,38,2,39,7,
        39,2,40,7,40,2,41,7,41,2,42,7,42,2,43,7,43,2,44,7,44,2,45,7,45,2,
        46,7,46,2,47,7,47,2,48,7,48,2,49,7,49,2,50,7,50,2,51,7,51,2,52,7,
        52,2,53,7,53,2,54,7,54,2,55,7,55,2,56,7,56,2,57,7,57,2,58,7,58,2,
        59,7,59,2,60,7,60,2,61,7,61,2,62,7,62,2,63,7,63,2,64,7,64,2,65,7,
        65,2,66,7,66,2,67,7,67,2,68,7,68,2,69,7,69,2,70,7,70,2,71,7,71,2,
        72,7,72,2,73,7,73,2,74,7,74,2,75,7,75,2,76,7,76,2,77,7,77,2,78,7,
        78,2,79,7,79,2,80,7,80,2,81,7,81,2,82,7,82,2,83,7,83,2,84,7,84,2,
        85,7,85,2,86,7,86,2,87,7,87,2,88,7,88,2,89,7,89,2,90,7,90,2,91,7,
        91,2,92,7,92,2,93,7,93,2,94,7,94,2,95,7,95,2,96,7,96,2,97,7,97,2,
        98,7,98,2,99,7,99,2,100,7,100,2,101,7,101,2,102,7,102,2,103,7,103,
        2,104,7,104,2,105,7,105,2,106,7,106,2,107,7,107,2,108,7,108,2,109,
        7,109,2,110,7,110,2,111,7,111,2,112,7,112,2,113,7,113,2,114,7,114,
        2,115,7,115,2,116,7,116,2,117,7,117,2,118,7,118,2,119,7,119,2,120,
        7,120,2,121,7,121,2,122,7,122,2,123,7,123,2,124,7,124,2,125,7,125,
        2,126,7,126,2,127,7,127,2,128,7,128,2,129,7,129,2,130,7,130,2,131,
        7,131,2,132,7,132,2,133,7,133,2,134,7,134,2,135,7,135,2,136,7,136,
        2,137,7,137,2,138,7,138,2,139,7,139,2,140,7,140,2,141,7,141,2,142,
        7,142,2,143,7,143,2,144,7,144,2,145,7,145,2,146,7,146,2,147,7,147,
        2,148,7,148,2,149,7,149,2,150,7,150,2,151,7,151,2,152,7,152,2,153,
        7,153,2,154,7,154,2,155,7,155,2,156,7,156,2,157,7,157,2,158,7,158,
        1,0,1,0,5,0,321,8,0,10,0,12,0,324,9,0,1,0,1,0,1,1,1,1,1,1,1,1,1,
        1,1,1,1,1,3,1,335,8,1,1,2,1,2,1,2,1,2,1,3,1,3,1,4,1,4,1,4,1,5,5,
        5,347,8,5,10,5,12,5,350,9,5,1,6,1,6,1,6,1,6,1,7,1,7,1,7,1,7,1,8,
        1,8,5,8,362,8,8,10,8,12,8,365,9,8,1,8,1,8,1,9,1,9,1,9,1,9,1,10,1,
        10,3,10,375,8,10,1,10,1,10,1,11,1,11,1,11,1,11,5,11,383,8,11,10,
        11,12,11,386,9,11,1,11,1,11,1,11,1,12,1,12,1,12,3,12,394,8,12,1,
        13,1,13,1,14,4,14,399,8,14,11,14,12,14,400,1,15,4,15,404,8,15,11,
        15,12,15,405,1,16,4,16,409,8,16,11,16,12,16,410,1,17,1,17,1,17,1,
        17,3,17,417,8,17,1,17,5,17,420,8,17,10,17,12,17,423,9,17,1,17,3,
        17,426,8,17,1,18,1,18,1,18,1,18,1,18,1,19,1,19,1,20,1,20,1,21,1,
        21,1,21,1,21,1,21,1,21,3,21,443,8,21,1,21,1,21,1,22,1,22,1,22,1,
        22,1,22,1,22,1,22,1,23,1,23,1,24,1,24,1,24,5,24,459,8,24,10,24,12,
        24,462,9,24,1,24,1,24,1,25,1,25,1,26,1,26,3,26,470,8,26,1,26,5,26,
        473,8,26,10,26,12,26,476,9,26,1,26,3,26,479,8,26,1,27,1,27,1,27,
        3,27,484,8,27,1,27,1,27,1,27,1,28,1,28,1,29,1,29,1,29,1,29,1,29,
        1,29,5,29,497,8,29,10,29,12,29,500,9,29,1,29,1,29,3,29,504,8,29,
        1,30,1,30,1,30,1,30,1,30,1,30,3,30,512,8,30,1,31,1,31,1,31,3,31,
        517,8,31,1,31,1,31,3,31,521,8,31,1,32,1,32,1,33,1,33,1,34,1,34,1,
        34,5,34,530,8,34,10,34,12,34,533,9,34,1,34,1,34,1,35,1,35,1,35,1,
        35,1,35,1,35,1,35,1,35,3,35,545,8,35,1,35,1,35,1,35,1,35,1,35,1,
        35,1,35,3,35,554,8,35,1,35,1,35,1,35,1,35,1,35,4,35,561,8,35,11,
        35,12,35,562,1,35,3,35,566,8,35,1,36,1,36,1,37,1,37,1,37,3,37,573,
        8,37,3,37,575,8,37,1,38,1,38,3,38,579,8,38,1,38,1,38,1,38,1,39,1,
        39,3,39,586,8,39,1,39,1,39,1,39,1,40,1,40,3,40,593,8,40,1,40,5,40,
        596,8,40,10,40,12,40,599,9,40,1,40,3,40,602,8,40,1,41,1,41,1,41,
        1,41,1,41,1,42,1,42,3,42,611,8,42,1,42,5,42,614,8,42,10,42,12,42,
        617,9,42,1,42,3,42,620,8,42,1,43,1,43,1,43,1,43,1,43,1,44,1,44,1,
        45,1,45,1,46,1,46,3,46,633,8,46,1,46,1,46,1,47,1,47,3,47,639,8,47,
        1,47,1,47,1,47,1,47,1,47,3,47,646,8,47,1,47,1,47,1,47,1,47,1,47,
        3,47,653,8,47,1,47,1,47,1,47,3,47,658,8,47,1,48,1,48,1,48,1,49,1,
        49,1,49,3,49,666,8,49,1,50,1,50,1,50,1,50,1,50,1,50,5,50,674,8,50,
        10,50,12,50,677,9,50,1,50,1,50,3,50,681,8,50,1,51,1,51,1,52,1,52,
        1,52,3,52,688,8,52,1,52,1,52,1,53,1,53,1,53,3,53,695,8,53,1,53,1,
        53,1,53,1,53,1,53,1,53,1,53,1,53,1,53,5,53,706,8,53,10,53,12,53,
        709,9,53,3,53,711,8,53,1,53,1,53,1,53,3,53,716,8,53,1,53,1,53,1,
        53,1,53,1,53,1,53,1,53,1,53,1,53,3,53,727,8,53,1,53,1,53,1,53,1,
        53,1,53,5,53,734,8,53,10,53,12,53,737,9,53,1,54,1,54,1,54,5,54,742,
        8,54,10,54,12,54,745,9,54,1,54,1,54,1,55,1,55,1,55,1,55,1,55,1,55,
        1,55,1,55,1,55,1,55,3,55,759,8,55,1,56,1,56,1,57,1,57,1,58,1,58,
        3,58,767,8,58,1,58,5,58,770,8,58,10,58,12,58,773,9,58,1,58,3,58,
        776,8,58,1,59,1,59,1,59,1,59,1,59,1,59,3,59,784,8,59,1,60,1,60,3,
        60,788,8,60,1,60,5,60,791,8,60,10,60,12,60,794,9,60,1,60,3,60,797,
        8,60,1,61,1,61,1,61,1,61,3,61,803,8,61,1,61,1,61,1,61,1,61,1,61,
        1,61,1,61,1,61,3,61,813,8,61,1,62,1,62,1,62,1,62,1,62,1,62,1,62,
        3,62,822,8,62,1,62,1,62,1,62,5,62,827,8,62,10,62,12,62,830,9,62,
        1,63,1,63,1,63,1,63,1,63,3,63,837,8,63,1,64,1,64,1,64,3,64,842,8,
        64,1,65,1,65,1,65,5,65,847,8,65,10,65,12,65,850,9,65,1,65,1,65,1,
        66,1,66,3,66,856,8,66,1,66,5,66,859,8,66,10,66,12,66,862,9,66,1,
        66,3,66,865,8,66,1,67,1,67,1,67,1,67,1,67,1,68,1,68,1,69,1,69,1,
        69,1,69,1,69,1,69,1,69,3,69,881,8,69,1,70,5,70,884,8,70,10,70,12,
        70,887,9,70,1,70,1,70,3,70,891,8,70,1,70,1,70,1,70,1,70,5,70,897,
        8,70,10,70,12,70,900,9,70,1,70,1,70,3,70,904,8,70,1,70,1,70,3,70,
        908,8,70,3,70,910,8,70,1,71,1,71,1,72,1,72,3,72,916,8,72,1,73,1,
        73,1,73,5,73,921,8,73,10,73,12,73,924,9,73,1,73,1,73,1,74,1,74,1,
        74,5,74,931,8,74,10,74,12,74,934,9,74,1,74,3,74,937,8,74,1,75,1,
        75,3,75,941,8,75,1,75,1,75,3,75,945,8,75,1,76,1,76,1,76,1,77,1,77,
        1,78,1,78,1,78,1,78,1,78,3,78,957,8,78,1,79,1,79,1,79,5,79,962,8,
        79,10,79,12,79,965,9,79,1,79,3,79,968,8,79,1,80,1,80,1,80,1,81,1,
        81,1,81,1,82,1,82,3,82,978,8,82,1,82,5,82,981,8,82,10,82,12,82,984,
        9,82,1,82,3,82,987,8,82,1,83,1,83,1,84,5,84,992,8,84,10,84,12,84,
        995,9,84,1,84,1,84,1,84,1,84,1,85,1,85,1,85,1,86,1,86,1,86,5,86,
        1007,8,86,10,86,12,86,1010,9,86,1,86,3,86,1013,8,86,1,87,1,87,1,
        87,1,87,1,87,1,87,1,87,1,87,1,87,1,87,1,87,1,87,1,87,1,87,1,87,1,
        87,1,87,1,87,1,87,3,87,1034,8,87,1,88,1,88,1,89,1,89,1,89,1,89,1,
        90,1,90,3,90,1044,8,90,1,90,5,90,1047,8,90,10,90,12,90,1050,9,90,
        1,90,3,90,1053,8,90,1,91,1,91,3,91,1057,8,91,1,92,1,92,1,92,1,92,
        1,93,1,93,3,93,1065,8,93,1,93,5,93,1068,8,93,10,93,12,93,1071,9,
        93,1,93,3,93,1074,8,93,1,94,1,94,1,94,1,94,3,94,1080,8,94,1,94,1,
        94,1,95,1,95,1,95,1,95,1,96,1,96,1,96,1,96,1,97,1,97,1,97,1,97,1,
        98,1,98,1,98,1,98,5,98,1100,8,98,10,98,12,98,1103,9,98,1,98,3,98,
        1106,8,98,1,99,1,99,1,99,1,99,5,99,1112,8,99,10,99,12,99,1115,9,
        99,1,99,3,99,1118,8,99,1,100,1,100,1,100,1,101,1,101,3,101,1125,
        8,101,1,101,5,101,1128,8,101,10,101,12,101,1131,9,101,1,101,3,101,
        1134,8,101,1,102,1,102,3,102,1138,8,102,1,102,3,102,1141,8,102,1,
        103,1,103,1,103,1,104,1,104,1,104,1,104,3,104,1150,8,104,1,105,1,
        105,1,105,1,106,1,106,1,106,3,106,1158,8,106,1,106,3,106,1161,8,
        106,1,107,1,107,3,107,1165,8,107,1,107,5,107,1168,8,107,10,107,12,
        107,1171,9,107,1,108,1,108,1,108,1,108,3,108,1177,8,108,1,109,1,
        109,1,109,1,110,1,110,1,110,1,111,1,111,1,112,1,112,1,113,1,113,
        1,114,1,114,1,115,1,115,1,116,1,116,3,116,1197,8,116,1,117,1,117,
        1,118,1,118,1,119,1,119,1,120,1,120,1,120,1,120,1,120,1,120,1,120,
        1,120,1,120,3,120,1214,8,120,1,121,1,121,1,121,1,121,1,121,1,121,
        1,121,3,121,1223,8,121,1,122,1,122,1,123,1,123,1,124,1,124,1,125,
        1,125,1,126,1,126,1,127,1,127,3,127,1237,8,127,1,128,1,128,1,128,
        1,128,1,128,1,128,1,128,5,128,1246,8,128,10,128,12,128,1249,9,128,
        1,128,3,128,1252,8,128,1,128,1,128,1,128,1,128,1,128,1,128,5,128,
        1260,8,128,10,128,12,128,1263,9,128,1,128,1,128,1,128,1,128,1,128,
        1,128,1,128,1,128,1,128,1,128,1,128,1,128,1,128,1,128,1,128,3,128,
        1280,8,128,1,128,1,128,1,128,3,128,1285,8,128,1,128,1,128,1,128,
        1,128,1,128,1,128,1,128,3,128,1294,8,128,1,128,1,128,1,128,1,128,
        1,128,1,128,1,128,1,128,1,128,1,128,1,128,3,128,1307,8,128,1,128,
        1,128,1,128,1,128,1,128,3,128,1314,8,128,3,128,1316,8,128,1,128,
        3,128,1319,8,128,1,128,1,128,3,128,1323,8,128,1,128,1,128,1,128,
        1,128,1,128,1,128,1,128,1,128,1,128,5,128,1334,8,128,10,128,12,128,
        1337,9,128,1,128,1,128,3,128,1341,8,128,1,128,1,128,1,128,1,128,
        1,128,1,128,1,128,1,128,1,128,1,128,1,128,1,128,1,128,1,128,1,128,
        3,128,1358,8,128,1,128,1,128,1,128,1,128,1,128,1,128,1,128,1,128,
        1,128,1,128,1,128,1,128,1,128,1,128,1,128,1,128,1,128,1,128,1,128,
        1,128,1,128,1,128,1,128,1,128,1,128,1,128,1,128,1,128,1,128,1,128,
        1,128,1,128,1,128,1,128,1,128,1,128,1,128,1,128,3,128,1398,8,128,
        1,128,1,128,1,128,3,128,1403,8,128,1,128,1,128,1,128,1,128,1,128,
        1,128,1,128,1,128,5,128,1413,8,128,10,128,12,128,1416,9,128,1,129,
        1,129,1,129,1,130,1,130,1,130,3,130,1424,8,130,1,130,3,130,1427,
        8,130,1,131,1,131,1,131,1,131,1,131,1,131,3,131,1435,8,131,1,132,
        1,132,1,132,5,132,1440,8,132,10,132,12,132,1443,9,132,1,133,4,133,
        1446,8,133,11,133,12,133,1447,1,133,1,133,3,133,1452,8,133,1,134,
        1,134,3,134,1456,8,134,1,134,1,134,1,134,1,135,1,135,3,135,1463,
        8,135,1,135,4,135,1466,8,135,11,135,12,135,1467,1,135,1,135,3,135,
        1472,8,135,1,135,1,135,1,136,1,136,1,136,1,136,1,136,1,137,1,137,
        1,138,1,138,1,138,1,138,3,138,1487,8,138,1,138,3,138,1490,8,138,
        1,139,1,139,1,139,5,139,1495,8,139,10,139,12,139,1498,9,139,1,139,
        3,139,1501,8,139,1,140,1,140,3,140,1505,8,140,1,140,5,140,1508,8,
        140,10,140,12,140,1511,9,140,1,141,1,141,3,141,1515,8,141,1,141,
        5,141,1518,8,141,10,141,12,141,1521,9,141,1,141,3,141,1524,8,141,
        1,142,1,142,1,142,3,142,1529,8,142,1,142,1,142,3,142,1533,8,142,
        1,143,1,143,1,143,1,143,4,143,1539,8,143,11,143,12,143,1540,1,143,
        1,143,1,144,1,144,1,144,3,144,1548,8,144,1,145,1,145,1,145,1,145,
        1,145,1,145,1,145,3,145,1557,8,145,1,146,1,146,1,146,3,146,1562,
        8,146,1,147,1,147,1,147,5,147,1567,8,147,10,147,12,147,1570,9,147,
        1,148,1,148,1,149,1,149,1,150,1,150,1,151,1,151,1,152,1,152,1,153,
        1,153,1,154,1,154,1,155,1,155,3,155,1588,8,155,1,156,1,156,1,156,
        1,157,1,157,1,157,1,158,1,158,1,158,1,158,1,158,1,158,1,158,0,3,
        106,124,256,159,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,
        36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,
        80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,
        118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,
        150,152,154,156,158,160,162,164,166,168,170,172,174,176,178,180,
        182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,212,
        214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,
        246,248,250,252,254,256,258,260,262,264,266,268,270,272,274,276,
        278,280,282,284,286,288,290,292,294,296,298,300,302,304,306,308,
        310,312,314,316,0,20,2,0,1,1,9,9,2,0,70,70,86,87,3,0,15,15,25,25,
        27,27,4,0,60,60,67,67,73,73,89,89,2,0,41,41,52,52,4,0,58,58,101,
        101,163,163,165,165,4,0,42,42,48,48,75,76,93,93,5,0,43,43,50,50,
        82,82,91,91,98,99,2,0,137,142,150,151,1,0,117,118,1,0,109,110,1,
        0,164,165,2,0,58,58,101,101,2,0,119,119,162,162,7,0,51,51,64,64,
        77,78,88,88,90,90,103,103,106,106,2,0,38,38,56,56,3,0,145,145,147,
        147,152,152,1,0,143,144,3,0,111,111,113,113,115,115,3,0,112,112,
        114,114,116,116,1710,0,322,1,0,0,0,2,334,1,0,0,0,4,336,1,0,0,0,6,
        340,1,0,0,0,8,342,1,0,0,0,10,348,1,0,0,0,12,351,1,0,0,0,14,355,1,
        0,0,0,16,359,1,0,0,0,18,368,1,0,0,0,20,372,1,0,0,0,22,378,1,0,0,
        0,24,390,1,0,0,0,26,395,1,0,0,0,28,398,1,0,0,0,30,403,1,0,0,0,32,
        408,1,0,0,0,34,412,1,0,0,0,36,427,1,0,0,0,38,432,1,0,0,0,40,434,
        1,0,0,0,42,436,1,0,0,0,44,446,1,0,0,0,46,453,1,0,0,0,48,455,1,0,
        0,0,50,465,1,0,0,0,52,467,1,0,0,0,54,480,1,0,0,0,56,488,1,0,0,0,
        58,503,1,0,0,0,60,511,1,0,0,0,62,513,1,0,0,0,64,522,1,0,0,0,66,524,
        1,0,0,0,68,526,1,0,0,0,70,565,1,0,0,0,72,567,1,0,0,0,74,574,1,0,
        0,0,76,576,1,0,0,0,78,583,1,0,0,0,80,590,1,0,0,0,82,603,1,0,0,0,
        84,608,1,0,0,0,86,621,1,0,0,0,88,626,1,0,0,0,90,628,1,0,0,0,92,630,
        1,0,0,0,94,657,1,0,0,0,96,659,1,0,0,0,98,665,1,0,0,0,100,680,1,0,
        0,0,102,682,1,0,0,0,104,687,1,0,0,0,106,715,1,0,0,0,108,738,1,0,
        0,0,110,758,1,0,0,0,112,760,1,0,0,0,114,762,1,0,0,0,116,764,1,0,
        0,0,118,783,1,0,0,0,120,785,1,0,0,0,122,812,1,0,0,0,124,821,1,0,
        0,0,126,836,1,0,0,0,128,841,1,0,0,0,130,843,1,0,0,0,132,853,1,0,
        0,0,134,866,1,0,0,0,136,871,1,0,0,0,138,880,1,0,0,0,140,909,1,0,
        0,0,142,911,1,0,0,0,144,915,1,0,0,0,146,917,1,0,0,0,148,927,1,0,
        0,0,150,944,1,0,0,0,152,946,1,0,0,0,154,949,1,0,0,0,156,956,1,0,
        0,0,158,958,1,0,0,0,160,969,1,0,0,0,162,972,1,0,0,0,164,975,1,0,
        0,0,166,988,1,0,0,0,168,993,1,0,0,0,170,1000,1,0,0,0,172,1003,1,
        0,0,0,174,1033,1,0,0,0,176,1035,1,0,0,0,178,1037,1,0,0,0,180,1041,
        1,0,0,0,182,1056,1,0,0,0,184,1058,1,0,0,0,186,1062,1,0,0,0,188,1075,
        1,0,0,0,190,1083,1,0,0,0,192,1087,1,0,0,0,194,1091,1,0,0,0,196,1095,
        1,0,0,0,198,1107,1,0,0,0,200,1119,1,0,0,0,202,1122,1,0,0,0,204,1137,
        1,0,0,0,206,1142,1,0,0,0,208,1149,1,0,0,0,210,1151,1,0,0,0,212,1160,
        1,0,0,0,214,1162,1,0,0,0,216,1172,1,0,0,0,218,1178,1,0,0,0,220,1181,
        1,0,0,0,222,1184,1,0,0,0,224,1186,1,0,0,0,226,1188,1,0,0,0,228,1190,
        1,0,0,0,230,1192,1,0,0,0,232,1196,1,0,0,0,234,1198,1,0,0,0,236,1200,
        1,0,0,0,238,1202,1,0,0,0,240,1213,1,0,0,0,242,1222,1,0,0,0,244,1224,
        1,0,0,0,246,1226,1,0,0,0,248,1228,1,0,0,0,250,1230,1,0,0,0,252,1232,
        1,0,0,0,254,1236,1,0,0,0,256,1340,1,0,0,0,258,1417,1,0,0,0,260,1426,
        1,0,0,0,262,1434,1,0,0,0,264,1436,1,0,0,0,266,1445,1,0,0,0,268,1453,
        1,0,0,0,270,1460,1,0,0,0,272,1475,1,0,0,0,274,1480,1,0,0,0,276,1489,
        1,0,0,0,278,1491,1,0,0,0,280,1502,1,0,0,0,282,1512,1,0,0,0,284,1528,
        1,0,0,0,286,1534,1,0,0,0,288,1544,1,0,0,0,290,1556,1,0,0,0,292,1561,
        1,0,0,0,294,1563,1,0,0,0,296,1571,1,0,0,0,298,1573,1,0,0,0,300,1575,
        1,0,0,0,302,1577,1,0,0,0,304,1579,1,0,0,0,306,1581,1,0,0,0,308,1583,
        1,0,0,0,310,1587,1,0,0,0,312,1589,1,0,0,0,314,1592,1,0,0,0,316,1595,
        1,0,0,0,318,321,3,2,1,0,319,321,5,149,0,0,320,318,1,0,0,0,320,319,
        1,0,0,0,321,324,1,0,0,0,322,320,1,0,0,0,322,323,1,0,0,0,323,325,
        1,0,0,0,324,322,1,0,0,0,325,326,5,0,0,1,326,1,1,0,0,0,327,335,3,
        4,2,0,328,335,3,6,3,0,329,335,3,20,10,0,330,335,3,14,7,0,331,335,
        3,28,14,0,332,335,3,30,15,0,333,335,3,316,158,0,334,327,1,0,0,0,
        334,328,1,0,0,0,334,329,1,0,0,0,334,330,1,0,0,0,334,331,1,0,0,0,
        334,332,1,0,0,0,334,333,1,0,0,0,335,3,1,0,0,0,336,337,3,10,5,0,337,
        338,5,33,0,0,338,339,3,52,26,0,339,5,1,0,0,0,340,341,3,34,17,0,341,
        7,1,0,0,0,342,343,3,10,5,0,343,344,3,106,53,0,344,9,1,0,0,0,345,
        347,5,121,0,0,346,345,1,0,0,0,347,350,1,0,0,0,348,346,1,0,0,0,348,
        349,1,0,0,0,349,11,1,0,0,0,350,348,1,0,0,0,351,352,3,10,5,0,352,
        353,5,68,0,0,353,354,3,10,5,0,354,13,1,0,0,0,355,356,3,10,5,0,356,
        357,5,30,0,0,357,358,3,8,4,0,358,15,1,0,0,0,359,363,5,169,0,0,360,
        362,3,18,9,0,361,360,1,0,0,0,362,365,1,0,0,0,363,361,1,0,0,0,363,
        364,1,0,0,0,364,366,1,0,0,0,365,363,1,0,0,0,366,367,5,173,0,0,367,
        17,1,0,0,0,368,369,5,172,0,0,369,370,3,106,53,0,370,371,5,130,0,
        0,371,19,1,0,0,0,372,374,5,65,0,0,373,375,3,22,11,0,374,373,1,0,
        0,0,374,375,1,0,0,0,375,376,1,0,0,0,376,377,3,26,13,0,377,21,1,0,
        0,0,378,379,5,129,0,0,379,384,3,24,12,0,380,381,5,135,0,0,381,383,
        3,24,12,0,382,380,1,0,0,0,383,386,1,0,0,0,384,382,1,0,0,0,384,385,
        1,0,0,0,385,387,1,0,0,0,386,384,1,0,0,0,387,388,5,130,0,0,388,389,
        5,62,0,0,389,23,1,0,0,0,390,393,3,248,124,0,391,392,5,68,0,0,392,
        394,3,248,124,0,393,391,1,0,0,0,393,394,1,0,0,0,394,25,1,0,0,0,395,
        396,3,232,116,0,396,27,1,0,0,0,397,399,5,120,0,0,398,397,1,0,0,0,
        399,400,1,0,0,0,400,398,1,0,0,0,400,401,1,0,0,0,401,29,1,0,0,0,402,
        404,5,121,0,0,403,402,1,0,0,0,404,405,1,0,0,0,405,403,1,0,0,0,405,
        406,1,0,0,0,406,31,1,0,0,0,407,409,5,120,0,0,408,407,1,0,0,0,409,
        410,1,0,0,0,410,408,1,0,0,0,410,411,1,0,0,0,411,33,1,0,0,0,412,413,
        3,10,5,0,413,414,5,28,0,0,414,421,3,36,18,0,415,417,5,135,0,0,416,
        415,1,0,0,0,416,417,1,0,0,0,417,418,1,0,0,0,418,420,3,36,18,0,419,
        416,1,0,0,0,420,423,1,0,0,0,421,419,1,0,0,0,421,422,1,0,0,0,422,
        425,1,0,0,0,423,421,1,0,0,0,424,426,5,135,0,0,425,424,1,0,0,0,425,
        426,1,0,0,0,426,35,1,0,0,0,427,428,3,10,5,0,428,429,3,50,25,0,429,
        430,3,12,6,0,430,431,3,106,53,0,431,37,1,0,0,0,432,433,5,143,0,0,
        433,39,1,0,0,0,434,435,3,248,124,0,435,41,1,0,0,0,436,437,3,46,23,
        0,437,438,5,136,0,0,438,439,5,94,0,0,439,442,5,125,0,0,440,443,3,
        16,8,0,441,443,3,234,117,0,442,440,1,0,0,0,442,441,1,0,0,0,443,444,
        1,0,0,0,444,445,5,126,0,0,445,43,1,0,0,0,446,447,3,46,23,0,447,448,
        5,136,0,0,448,449,5,95,0,0,449,450,5,125,0,0,450,451,3,244,122,0,
        451,452,5,126,0,0,452,45,1,0,0,0,453,454,3,248,124,0,454,47,1,0,
        0,0,455,460,5,129,0,0,456,459,3,174,87,0,457,459,5,149,0,0,458,456,
        1,0,0,0,458,457,1,0,0,0,459,462,1,0,0,0,460,458,1,0,0,0,460,461,
        1,0,0,0,461,463,1,0,0,0,462,460,1,0,0,0,463,464,5,130,0,0,464,49,
        1,0,0,0,465,466,3,248,124,0,466,51,1,0,0,0,467,474,3,54,27,0,468,
        470,5,135,0,0,469,468,1,0,0,0,469,470,1,0,0,0,470,471,1,0,0,0,471,
        473,3,54,27,0,472,469,1,0,0,0,473,476,1,0,0,0,474,472,1,0,0,0,474,
        475,1,0,0,0,475,478,1,0,0,0,476,474,1,0,0,0,477,479,5,135,0,0,478,
        477,1,0,0,0,478,479,1,0,0,0,479,53,1,0,0,0,480,481,3,10,5,0,481,
        483,3,66,33,0,482,484,3,58,29,0,483,482,1,0,0,0,483,484,1,0,0,0,
        484,485,1,0,0,0,485,486,3,12,6,0,486,487,3,56,28,0,487,55,1,0,0,
        0,488,489,3,106,53,0,489,57,1,0,0,0,490,491,5,125,0,0,491,504,5,
        126,0,0,492,493,5,125,0,0,493,498,3,62,31,0,494,495,5,135,0,0,495,
        497,3,62,31,0,496,494,1,0,0,0,497,500,1,0,0,0,498,496,1,0,0,0,498,
        499,1,0,0,0,499,501,1,0,0,0,500,498,1,0,0,0,501,502,5,126,0,0,502,
        504,1,0,0,0,503,490,1,0,0,0,503,492,1,0,0,0,504,59,1,0,0,0,505,512,
        3,228,114,0,506,507,5,59,0,0,507,508,5,137,0,0,508,509,3,228,114,
        0,509,510,5,138,0,0,510,512,1,0,0,0,511,505,1,0,0,0,511,506,1,0,
        0,0,512,61,1,0,0,0,513,516,3,64,32,0,514,515,5,131,0,0,515,517,3,
        60,30,0,516,514,1,0,0,0,516,517,1,0,0,0,517,520,1,0,0,0,518,519,
        5,68,0,0,519,521,3,256,128,0,520,518,1,0,0,0,520,521,1,0,0,0,521,
        63,1,0,0,0,522,523,3,248,124,0,523,65,1,0,0,0,524,525,3,248,124,
        0,525,67,1,0,0,0,526,531,5,129,0,0,527,530,3,70,35,0,528,530,5,149,
        0,0,529,527,1,0,0,0,529,528,1,0,0,0,530,533,1,0,0,0,531,529,1,0,
        0,0,531,532,1,0,0,0,532,534,1,0,0,0,533,531,1,0,0,0,534,535,5,130,
        0,0,535,69,1,0,0,0,536,566,3,78,39,0,537,566,3,76,38,0,538,566,3,
        94,47,0,539,566,3,160,80,0,540,541,5,24,0,0,541,566,3,298,149,0,
        542,544,3,10,5,0,543,545,3,72,36,0,544,543,1,0,0,0,544,545,1,0,0,
        0,545,546,1,0,0,0,546,547,5,29,0,0,547,548,3,80,40,0,548,566,1,0,
        0,0,549,550,7,0,0,0,550,566,3,280,140,0,551,553,3,10,5,0,552,554,
        3,72,36,0,553,552,1,0,0,0,553,554,1,0,0,0,554,555,1,0,0,0,555,556,
        5,36,0,0,556,557,3,164,82,0,557,566,1,0,0,0,558,566,3,220,110,0,
        559,561,5,121,0,0,560,559,1,0,0,0,561,562,1,0,0,0,562,560,1,0,0,
        0,562,563,1,0,0,0,563,566,1,0,0,0,564,566,3,32,16,0,565,536,1,0,
        0,0,565,537,1,0,0,0,565,538,1,0,0,0,565,539,1,0,0,0,565,540,1,0,
        0,0,565,542,1,0,0,0,565,549,1,0,0,0,565,551,1,0,0,0,565,558,1,0,
        0,0,565,560,1,0,0,0,565,564,1,0,0,0,566,71,1,0,0,0,567,568,7,1,0,
        0,568,73,1,0,0,0,569,575,3,280,140,0,570,572,5,145,0,0,571,573,3,
        286,143,0,572,571,1,0,0,0,572,573,1,0,0,0,573,575,1,0,0,0,574,569,
        1,0,0,0,574,570,1,0,0,0,575,75,1,0,0,0,576,578,3,10,5,0,577,579,
        3,72,36,0,578,577,1,0,0,0,578,579,1,0,0,0,579,580,1,0,0,0,580,581,
        5,20,0,0,581,582,3,84,42,0,582,77,1,0,0,0,583,585,3,10,5,0,584,586,
        3,72,36,0,585,584,1,0,0,0,585,586,1,0,0,0,586,587,1,0,0,0,587,588,
        5,7,0,0,588,589,3,84,42,0,589,79,1,0,0,0,590,597,3,82,41,0,591,593,
        5,135,0,0,592,591,1,0,0,0,592,593,1,0,0,0,593,594,1,0,0,0,594,596,
        3,82,41,0,595,592,1,0,0,0,596,599,1,0,0,0,597,595,1,0,0,0,597,598,
        1,0,0,0,598,601,1,0,0,0,599,597,1,0,0,0,600,602,5,135,0,0,601,600,
        1,0,0,0,601,602,1,0,0,0,602,81,1,0,0,0,603,604,3,10,5,0,604,605,
        3,298,149,0,605,606,3,12,6,0,606,607,3,298,149,0,607,83,1,0,0,0,
        608,615,3,86,43,0,609,611,5,135,0,0,610,609,1,0,0,0,610,611,1,0,
        0,0,611,612,1,0,0,0,612,614,3,86,43,0,613,610,1,0,0,0,614,617,1,
        0,0,0,615,613,1,0,0,0,615,616,1,0,0,0,616,619,1,0,0,0,617,615,1,
        0,0,0,618,620,5,135,0,0,619,618,1,0,0,0,619,620,1,0,0,0,620,85,1,
        0,0,0,621,622,3,10,5,0,622,623,3,88,44,0,623,624,3,12,6,0,624,625,
        3,256,128,0,625,87,1,0,0,0,626,627,3,248,124,0,627,89,1,0,0,0,628,
        629,3,248,124,0,629,91,1,0,0,0,630,632,5,6,0,0,631,633,3,72,36,0,
        632,631,1,0,0,0,632,633,1,0,0,0,633,634,1,0,0,0,634,635,3,84,42,
        0,635,93,1,0,0,0,636,638,3,10,5,0,637,639,3,72,36,0,638,637,1,0,
        0,0,638,639,1,0,0,0,639,640,1,0,0,0,640,641,5,17,0,0,641,642,3,132,
        66,0,642,658,1,0,0,0,643,645,3,10,5,0,644,646,3,72,36,0,645,644,
        1,0,0,0,645,646,1,0,0,0,646,647,1,0,0,0,647,648,5,18,0,0,648,649,
        3,132,66,0,649,658,1,0,0,0,650,652,3,10,5,0,651,653,3,72,36,0,652,
        651,1,0,0,0,652,653,1,0,0,0,653,654,1,0,0,0,654,655,5,16,0,0,655,
        656,3,132,66,0,656,658,1,0,0,0,657,636,1,0,0,0,657,643,1,0,0,0,657,
        650,1,0,0,0,658,95,1,0,0,0,659,660,5,10,0,0,660,661,3,130,65,0,661,
        97,1,0,0,0,662,666,3,94,47,0,663,666,3,160,80,0,664,666,3,92,46,
        0,665,662,1,0,0,0,665,663,1,0,0,0,665,664,1,0,0,0,666,99,1,0,0,0,
        667,668,5,125,0,0,668,681,5,126,0,0,669,670,5,125,0,0,670,675,3,
        104,52,0,671,672,5,135,0,0,672,674,3,104,52,0,673,671,1,0,0,0,674,
        677,1,0,0,0,675,673,1,0,0,0,675,676,1,0,0,0,676,678,1,0,0,0,677,
        675,1,0,0,0,678,679,5,126,0,0,679,681,1,0,0,0,680,667,1,0,0,0,680,
        669,1,0,0,0,681,101,1,0,0,0,682,683,3,248,124,0,683,103,1,0,0,0,
        684,685,3,102,51,0,685,686,5,68,0,0,686,688,1,0,0,0,687,684,1,0,
        0,0,687,688,1,0,0,0,688,689,1,0,0,0,689,690,3,256,128,0,690,105,
        1,0,0,0,691,692,6,53,-1,0,692,694,3,248,124,0,693,695,3,100,50,0,
        694,693,1,0,0,0,694,695,1,0,0,0,695,716,1,0,0,0,696,697,5,125,0,
        0,697,698,3,106,53,0,698,699,5,126,0,0,699,716,1,0,0,0,700,701,5,
        49,0,0,701,710,5,125,0,0,702,707,3,106,53,0,703,704,5,135,0,0,704,
        706,3,106,53,0,705,703,1,0,0,0,706,709,1,0,0,0,707,705,1,0,0,0,707,
        708,1,0,0,0,708,711,1,0,0,0,709,707,1,0,0,0,710,702,1,0,0,0,710,
        711,1,0,0,0,711,712,1,0,0,0,712,716,5,126,0,0,713,716,3,44,22,0,
        714,716,3,42,21,0,715,691,1,0,0,0,715,696,1,0,0,0,715,700,1,0,0,
        0,715,713,1,0,0,0,715,714,1,0,0,0,716,735,1,0,0,0,717,718,10,6,0,
        0,718,719,5,143,0,0,719,734,3,124,62,0,720,721,10,5,0,0,721,722,
        5,123,0,0,722,734,3,124,62,0,723,726,10,4,0,0,724,725,5,66,0,0,725,
        727,3,108,54,0,726,724,1,0,0,0,726,727,1,0,0,0,727,728,1,0,0,0,728,
        729,5,57,0,0,729,734,3,68,34,0,730,731,10,3,0,0,731,732,5,66,0,0,
        732,734,3,108,54,0,733,717,1,0,0,0,733,720,1,0,0,0,733,723,1,0,0,
        0,733,730,1,0,0,0,734,737,1,0,0,0,735,733,1,0,0,0,735,736,1,0,0,
        0,736,107,1,0,0,0,737,735,1,0,0,0,738,743,5,129,0,0,739,742,3,110,
        55,0,740,742,5,149,0,0,741,739,1,0,0,0,741,740,1,0,0,0,742,745,1,
        0,0,0,743,741,1,0,0,0,743,744,1,0,0,0,744,746,1,0,0,0,745,743,1,
        0,0,0,746,747,5,130,0,0,747,109,1,0,0,0,748,749,3,10,5,0,749,750,
        3,114,57,0,750,751,3,120,60,0,751,759,1,0,0,0,752,759,3,120,60,0,
        753,754,3,10,5,0,754,755,5,9,0,0,755,756,3,116,58,0,756,759,1,0,
        0,0,757,759,3,112,56,0,758,748,1,0,0,0,758,752,1,0,0,0,758,753,1,
        0,0,0,758,757,1,0,0,0,759,111,1,0,0,0,760,761,5,121,0,0,761,113,
        1,0,0,0,762,763,7,2,0,0,763,115,1,0,0,0,764,771,3,118,59,0,765,767,
        5,135,0,0,766,765,1,0,0,0,766,767,1,0,0,0,767,768,1,0,0,0,768,770,
        3,118,59,0,769,766,1,0,0,0,770,773,1,0,0,0,771,769,1,0,0,0,771,772,
        1,0,0,0,772,775,1,0,0,0,773,771,1,0,0,0,774,776,5,135,0,0,775,774,
        1,0,0,0,775,776,1,0,0,0,776,117,1,0,0,0,777,778,3,10,5,0,778,779,
        3,294,147,0,779,784,1,0,0,0,780,781,3,10,5,0,781,782,3,284,142,0,
        782,784,1,0,0,0,783,777,1,0,0,0,783,780,1,0,0,0,784,119,1,0,0,0,
        785,792,3,122,61,0,786,788,5,135,0,0,787,786,1,0,0,0,787,788,1,0,
        0,0,788,789,1,0,0,0,789,791,3,122,61,0,790,787,1,0,0,0,791,794,1,
        0,0,0,792,790,1,0,0,0,792,793,1,0,0,0,793,796,1,0,0,0,794,792,1,
        0,0,0,795,797,5,135,0,0,796,795,1,0,0,0,796,797,1,0,0,0,797,121,
        1,0,0,0,798,802,3,10,5,0,799,800,3,298,149,0,800,801,3,12,6,0,801,
        803,1,0,0,0,802,799,1,0,0,0,802,803,1,0,0,0,803,804,1,0,0,0,804,
        805,3,294,147,0,805,813,1,0,0,0,806,807,3,10,5,0,807,808,3,294,147,
        0,808,813,1,0,0,0,809,810,3,10,5,0,810,811,3,284,142,0,811,813,1,
        0,0,0,812,798,1,0,0,0,812,806,1,0,0,0,812,809,1,0,0,0,813,123,1,
        0,0,0,814,815,6,62,-1,0,815,822,3,294,147,0,816,822,3,48,24,0,817,
        818,5,125,0,0,818,819,3,126,63,0,819,820,5,126,0,0,820,822,1,0,0,
        0,821,814,1,0,0,0,821,816,1,0,0,0,821,817,1,0,0,0,822,828,1,0,0,
        0,823,824,10,1,0,0,824,825,5,143,0,0,825,827,3,124,62,2,826,823,
        1,0,0,0,827,830,1,0,0,0,828,826,1,0,0,0,828,829,1,0,0,0,829,125,
        1,0,0,0,830,828,1,0,0,0,831,837,3,124,62,0,832,833,3,124,62,0,833,
        834,5,123,0,0,834,835,3,126,63,0,835,837,1,0,0,0,836,831,1,0,0,0,
        836,832,1,0,0,0,837,127,1,0,0,0,838,842,3,78,39,0,839,842,3,76,38,
        0,840,842,3,94,47,0,841,838,1,0,0,0,841,839,1,0,0,0,841,840,1,0,
        0,0,842,129,1,0,0,0,843,848,5,129,0,0,844,847,3,128,64,0,845,847,
        5,149,0,0,846,844,1,0,0,0,846,845,1,0,0,0,847,850,1,0,0,0,848,846,
        1,0,0,0,848,849,1,0,0,0,849,851,1,0,0,0,850,848,1,0,0,0,851,852,
        5,130,0,0,852,131,1,0,0,0,853,860,3,140,70,0,854,856,5,135,0,0,855,
        854,1,0,0,0,855,856,1,0,0,0,856,857,1,0,0,0,857,859,3,140,70,0,858,
        855,1,0,0,0,859,862,1,0,0,0,860,858,1,0,0,0,860,861,1,0,0,0,861,
        864,1,0,0,0,862,860,1,0,0,0,863,865,5,135,0,0,864,863,1,0,0,0,864,
        865,1,0,0,0,865,133,1,0,0,0,866,867,3,10,5,0,867,868,5,68,0,0,868,
        869,3,10,5,0,869,870,3,106,53,0,870,135,1,0,0,0,871,872,7,3,0,0,
        872,137,1,0,0,0,873,881,3,90,45,0,874,875,3,90,45,0,875,876,3,100,
        50,0,876,881,1,0,0,0,877,878,3,90,45,0,878,879,3,134,67,0,879,881,
        1,0,0,0,880,873,1,0,0,0,880,874,1,0,0,0,880,877,1,0,0,0,881,139,
        1,0,0,0,882,884,5,121,0,0,883,882,1,0,0,0,884,887,1,0,0,0,885,883,
        1,0,0,0,885,886,1,0,0,0,886,888,1,0,0,0,887,885,1,0,0,0,888,890,
        3,138,69,0,889,891,3,136,68,0,890,889,1,0,0,0,890,891,1,0,0,0,891,
        892,1,0,0,0,892,893,5,105,0,0,893,894,3,256,128,0,894,910,1,0,0,
        0,895,897,5,121,0,0,896,895,1,0,0,0,897,900,1,0,0,0,898,896,1,0,
        0,0,898,899,1,0,0,0,899,901,1,0,0,0,900,898,1,0,0,0,901,907,3,138,
        69,0,902,904,3,136,68,0,903,902,1,0,0,0,903,904,1,0,0,0,904,905,
        1,0,0,0,905,906,5,83,0,0,906,908,3,142,71,0,907,903,1,0,0,0,907,
        908,1,0,0,0,908,910,1,0,0,0,909,885,1,0,0,0,909,898,1,0,0,0,910,
        141,1,0,0,0,911,912,3,256,128,0,912,143,1,0,0,0,913,916,3,160,80,
        0,914,916,3,162,81,0,915,913,1,0,0,0,915,914,1,0,0,0,916,145,1,0,
        0,0,917,922,5,129,0,0,918,921,3,156,78,0,919,921,5,149,0,0,920,918,
        1,0,0,0,920,919,1,0,0,0,921,924,1,0,0,0,922,920,1,0,0,0,922,923,
        1,0,0,0,923,925,1,0,0,0,924,922,1,0,0,0,925,926,5,130,0,0,926,147,
        1,0,0,0,927,932,3,150,75,0,928,929,5,135,0,0,929,931,3,150,75,0,
        930,928,1,0,0,0,931,934,1,0,0,0,932,930,1,0,0,0,932,933,1,0,0,0,
        933,936,1,0,0,0,934,932,1,0,0,0,935,937,5,135,0,0,936,935,1,0,0,
        0,936,937,1,0,0,0,937,149,1,0,0,0,938,940,3,256,128,0,939,941,7,
        4,0,0,940,939,1,0,0,0,940,941,1,0,0,0,941,945,1,0,0,0,942,945,5,
        41,0,0,943,945,5,52,0,0,944,938,1,0,0,0,944,942,1,0,0,0,944,943,
        1,0,0,0,945,151,1,0,0,0,946,947,5,22,0,0,947,948,3,148,74,0,948,
        153,1,0,0,0,949,950,3,206,103,0,950,155,1,0,0,0,951,957,3,160,80,
        0,952,957,3,196,98,0,953,957,3,152,76,0,954,957,3,154,77,0,955,957,
        3,198,99,0,956,951,1,0,0,0,956,952,1,0,0,0,956,953,1,0,0,0,956,954,
        1,0,0,0,956,955,1,0,0,0,957,157,1,0,0,0,958,963,3,256,128,0,959,
        960,5,135,0,0,960,962,3,256,128,0,961,959,1,0,0,0,962,965,1,0,0,
        0,963,961,1,0,0,0,963,964,1,0,0,0,964,967,1,0,0,0,965,963,1,0,0,
        0,966,968,5,135,0,0,967,966,1,0,0,0,967,968,1,0,0,0,968,159,1,0,
        0,0,969,970,5,35,0,0,970,971,3,158,79,0,971,161,1,0,0,0,972,973,
        5,13,0,0,973,974,3,158,79,0,974,163,1,0,0,0,975,982,3,168,84,0,976,
        978,5,135,0,0,977,976,1,0,0,0,977,978,1,0,0,0,978,979,1,0,0,0,979,
        981,3,168,84,0,980,977,1,0,0,0,981,984,1,0,0,0,982,980,1,0,0,0,982,
        983,1,0,0,0,983,986,1,0,0,0,984,982,1,0,0,0,985,987,5,135,0,0,986,
        985,1,0,0,0,986,987,1,0,0,0,987,165,1,0,0,0,988,989,3,248,124,0,
        989,167,1,0,0,0,990,992,5,121,0,0,991,990,1,0,0,0,992,995,1,0,0,
        0,993,991,1,0,0,0,993,994,1,0,0,0,994,996,1,0,0,0,995,993,1,0,0,
        0,996,997,3,166,83,0,997,998,3,12,6,0,998,999,3,126,63,0,999,169,
        1,0,0,0,1000,1001,5,8,0,0,1001,1002,3,172,86,0,1002,171,1,0,0,0,
        1003,1008,3,256,128,0,1004,1005,5,135,0,0,1005,1007,3,256,128,0,
        1006,1004,1,0,0,0,1007,1010,1,0,0,0,1008,1006,1,0,0,0,1008,1009,
        1,0,0,0,1009,1012,1,0,0,0,1010,1008,1,0,0,0,1011,1013,5,135,0,0,
        1012,1011,1,0,0,0,1012,1013,1,0,0,0,1013,173,1,0,0,0,1014,1034,3,
        178,89,0,1015,1034,3,92,46,0,1016,1034,3,176,88,0,1017,1034,3,96,
        48,0,1018,1034,3,194,97,0,1019,1034,3,216,108,0,1020,1034,3,190,
        95,0,1021,1034,3,192,96,0,1022,1034,3,210,105,0,1023,1034,3,206,
        103,0,1024,1034,3,200,100,0,1025,1034,3,160,80,0,1026,1034,3,162,
        81,0,1027,1034,3,184,92,0,1028,1034,3,218,109,0,1029,1034,3,220,
        110,0,1030,1034,3,170,85,0,1031,1034,3,222,111,0,1032,1034,3,32,
        16,0,1033,1014,1,0,0,0,1033,1015,1,0,0,0,1033,1016,1,0,0,0,1033,
        1017,1,0,0,0,1033,1018,1,0,0,0,1033,1019,1,0,0,0,1033,1020,1,0,0,
        0,1033,1021,1,0,0,0,1033,1022,1,0,0,0,1033,1023,1,0,0,0,1033,1024,
        1,0,0,0,1033,1025,1,0,0,0,1033,1026,1,0,0,0,1033,1027,1,0,0,0,1033,
        1028,1,0,0,0,1033,1029,1,0,0,0,1033,1030,1,0,0,0,1033,1031,1,0,0,
        0,1033,1032,1,0,0,0,1034,175,1,0,0,0,1035,1036,3,94,47,0,1036,177,
        1,0,0,0,1037,1038,3,10,5,0,1038,1039,5,11,0,0,1039,1040,3,180,90,
        0,1040,179,1,0,0,0,1041,1048,3,182,91,0,1042,1044,5,135,0,0,1043,
        1042,1,0,0,0,1043,1044,1,0,0,0,1044,1045,1,0,0,0,1045,1047,3,182,
        91,0,1046,1043,1,0,0,0,1047,1050,1,0,0,0,1048,1046,1,0,0,0,1048,
        1049,1,0,0,0,1049,1052,1,0,0,0,1050,1048,1,0,0,0,1051,1053,5,135,
        0,0,1052,1051,1,0,0,0,1052,1053,1,0,0,0,1053,181,1,0,0,0,1054,1057,
        3,288,144,0,1055,1057,3,86,43,0,1056,1054,1,0,0,0,1056,1055,1,0,
        0,0,1057,183,1,0,0,0,1058,1059,3,10,5,0,1059,1060,5,21,0,0,1060,
        1061,3,186,93,0,1061,185,1,0,0,0,1062,1069,3,188,94,0,1063,1065,
        5,135,0,0,1064,1063,1,0,0,0,1064,1065,1,0,0,0,1065,1066,1,0,0,0,
        1066,1068,3,188,94,0,1067,1064,1,0,0,0,1068,1071,1,0,0,0,1069,1067,
        1,0,0,0,1069,1070,1,0,0,0,1070,1073,1,0,0,0,1071,1069,1,0,0,0,1072,
        1074,5,135,0,0,1073,1072,1,0,0,0,1073,1074,1,0,0,0,1074,187,1,0,
        0,0,1075,1079,3,10,5,0,1076,1077,3,50,25,0,1077,1078,3,12,6,0,1078,
        1080,1,0,0,0,1079,1076,1,0,0,0,1079,1080,1,0,0,0,1080,1081,1,0,0,
        0,1081,1082,3,126,63,0,1082,189,1,0,0,0,1083,1084,3,10,5,0,1084,
        1085,5,2,0,0,1085,1086,3,180,90,0,1086,191,1,0,0,0,1087,1088,3,10,
        5,0,1088,1089,5,3,0,0,1089,1090,3,180,90,0,1090,193,1,0,0,0,1091,
        1092,3,10,5,0,1092,1093,5,32,0,0,1093,1094,3,282,141,0,1094,195,
        1,0,0,0,1095,1096,5,23,0,0,1096,1101,3,248,124,0,1097,1098,5,135,
        0,0,1098,1100,3,248,124,0,1099,1097,1,0,0,0,1100,1103,1,0,0,0,1101,
        1099,1,0,0,0,1101,1102,1,0,0,0,1102,1105,1,0,0,0,1103,1101,1,0,0,
        0,1104,1106,5,135,0,0,1105,1104,1,0,0,0,1105,1106,1,0,0,0,1106,197,
        1,0,0,0,1107,1108,5,12,0,0,1108,1113,3,248,124,0,1109,1110,5,135,
        0,0,1110,1112,3,248,124,0,1111,1109,1,0,0,0,1112,1115,1,0,0,0,1113,
        1111,1,0,0,0,1113,1114,1,0,0,0,1114,1117,1,0,0,0,1115,1113,1,0,0,
        0,1116,1118,5,135,0,0,1117,1116,1,0,0,0,1117,1118,1,0,0,0,1118,199,
        1,0,0,0,1119,1120,5,22,0,0,1120,1121,3,202,101,0,1121,201,1,0,0,
        0,1122,1129,3,204,102,0,1123,1125,5,135,0,0,1124,1123,1,0,0,0,1124,
        1125,1,0,0,0,1125,1126,1,0,0,0,1126,1128,3,204,102,0,1127,1124,1,
        0,0,0,1128,1131,1,0,0,0,1129,1127,1,0,0,0,1129,1130,1,0,0,0,1130,
        1133,1,0,0,0,1131,1129,1,0,0,0,1132,1134,5,135,0,0,1133,1132,1,0,
        0,0,1133,1134,1,0,0,0,1134,203,1,0,0,0,1135,1138,5,165,0,0,1136,
        1138,3,298,149,0,1137,1135,1,0,0,0,1137,1136,1,0,0,0,1138,1140,1,
        0,0,0,1139,1141,7,4,0,0,1140,1139,1,0,0,0,1140,1141,1,0,0,0,1141,
        205,1,0,0,0,1142,1143,5,19,0,0,1143,1144,5,165,0,0,1144,207,1,0,
        0,0,1145,1146,5,44,0,0,1146,1150,3,298,149,0,1147,1148,5,44,0,0,
        1148,1150,3,256,128,0,1149,1145,1,0,0,0,1149,1147,1,0,0,0,1150,209,
        1,0,0,0,1151,1152,5,34,0,0,1152,1153,5,165,0,0,1153,211,1,0,0,0,
        1154,1157,3,294,147,0,1155,1156,5,136,0,0,1156,1158,5,145,0,0,1157,
        1155,1,0,0,0,1157,1158,1,0,0,0,1158,1161,1,0,0,0,1159,1161,5,145,
        0,0,1160,1154,1,0,0,0,1160,1159,1,0,0,0,1161,213,1,0,0,0,1162,1169,
        3,212,106,0,1163,1165,5,135,0,0,1164,1163,1,0,0,0,1164,1165,1,0,
        0,0,1165,1166,1,0,0,0,1166,1168,3,212,106,0,1167,1164,1,0,0,0,1168,
        1171,1,0,0,0,1169,1167,1,0,0,0,1169,1170,1,0,0,0,1170,215,1,0,0,
        0,1171,1169,1,0,0,0,1172,1173,5,14,0,0,1173,1176,3,214,107,0,1174,
        1175,5,44,0,0,1175,1177,3,298,149,0,1176,1174,1,0,0,0,1176,1177,
        1,0,0,0,1177,217,1,0,0,0,1178,1179,5,31,0,0,1179,1180,3,224,112,
        0,1180,219,1,0,0,0,1181,1182,5,37,0,0,1182,1183,3,232,116,0,1183,
        221,1,0,0,0,1184,1185,5,121,0,0,1185,223,1,0,0,0,1186,1187,7,5,0,
        0,1187,225,1,0,0,0,1188,1189,7,6,0,0,1189,227,1,0,0,0,1190,1191,
        7,7,0,0,1191,229,1,0,0,0,1192,1193,7,8,0,0,1193,231,1,0,0,0,1194,
        1197,3,234,117,0,1195,1197,3,16,8,0,1196,1194,1,0,0,0,1196,1195,
        1,0,0,0,1197,233,1,0,0,0,1198,1199,7,9,0,0,1199,235,1,0,0,0,1200,
        1201,7,10,0,0,1201,237,1,0,0,0,1202,1203,7,11,0,0,1203,239,1,0,0,
        0,1204,1214,3,232,116,0,1205,1214,3,236,118,0,1206,1214,3,238,119,
        0,1207,1214,3,242,121,0,1208,1214,5,81,0,0,1209,1214,7,12,0,0,1210,
        1214,5,108,0,0,1211,1214,3,310,155,0,1212,1214,5,80,0,0,1213,1204,
        1,0,0,0,1213,1205,1,0,0,0,1213,1206,1,0,0,0,1213,1207,1,0,0,0,1213,
        1208,1,0,0,0,1213,1209,1,0,0,0,1213,1210,1,0,0,0,1213,1211,1,0,0,
        0,1213,1212,1,0,0,0,1214,241,1,0,0,0,1215,1223,5,155,0,0,1216,1223,
        5,156,0,0,1217,1223,5,157,0,0,1218,1223,5,160,0,0,1219,1223,5,159,
        0,0,1220,1223,5,158,0,0,1221,1223,5,161,0,0,1222,1215,1,0,0,0,1222,
        1216,1,0,0,0,1222,1217,1,0,0,0,1222,1218,1,0,0,0,1222,1219,1,0,0,
        0,1222,1220,1,0,0,0,1222,1221,1,0,0,0,1223,243,1,0,0,0,1224,1225,
        3,232,116,0,1225,245,1,0,0,0,1226,1227,3,232,116,0,1227,247,1,0,
        0,0,1228,1229,7,13,0,0,1229,249,1,0,0,0,1230,1231,7,14,0,0,1231,
        251,1,0,0,0,1232,1233,7,15,0,0,1233,253,1,0,0,0,1234,1237,3,228,
        114,0,1235,1237,3,232,116,0,1236,1234,1,0,0,0,1236,1235,1,0,0,0,
        1237,255,1,0,0,0,1238,1239,6,128,-1,0,1239,1341,3,294,147,0,1240,
        1341,3,240,120,0,1241,1242,5,127,0,0,1242,1247,3,256,128,0,1243,
        1244,5,135,0,0,1244,1246,3,256,128,0,1245,1243,1,0,0,0,1246,1249,
        1,0,0,0,1247,1245,1,0,0,0,1247,1248,1,0,0,0,1248,1251,1,0,0,0,1249,
        1247,1,0,0,0,1250,1252,5,135,0,0,1251,1250,1,0,0,0,1251,1252,1,0,
        0,0,1252,1253,1,0,0,0,1253,1254,5,128,0,0,1254,1341,1,0,0,0,1255,
        1256,5,129,0,0,1256,1261,3,276,138,0,1257,1258,5,135,0,0,1258,1260,
        3,276,138,0,1259,1257,1,0,0,0,1260,1263,1,0,0,0,1261,1259,1,0,0,
        0,1261,1262,1,0,0,0,1262,1264,1,0,0,0,1263,1261,1,0,0,0,1264,1265,
        5,130,0,0,1265,1341,1,0,0,0,1266,1267,5,144,0,0,1267,1341,3,256,
        128,25,1268,1269,5,79,0,0,1269,1341,3,256,128,13,1270,1271,5,46,
        0,0,1271,1272,5,125,0,0,1272,1273,3,256,128,0,1273,1274,5,40,0,0,
        1274,1275,3,254,127,0,1275,1276,5,126,0,0,1276,1341,1,0,0,0,1277,
        1278,5,92,0,0,1278,1280,5,136,0,0,1279,1277,1,0,0,0,1279,1280,1,
        0,0,0,1280,1281,1,0,0,0,1281,1282,3,226,113,0,1282,1284,5,125,0,
        0,1283,1285,3,256,128,0,1284,1283,1,0,0,0,1284,1285,1,0,0,0,1285,
        1286,1,0,0,0,1286,1287,5,126,0,0,1287,1341,1,0,0,0,1288,1289,3,294,
        147,0,1289,1290,5,136,0,0,1290,1291,3,226,113,0,1291,1293,5,125,
        0,0,1292,1294,3,256,128,0,1293,1292,1,0,0,0,1293,1294,1,0,0,0,1294,
        1295,1,0,0,0,1295,1296,5,126,0,0,1296,1341,1,0,0,0,1297,1298,5,125,
        0,0,1298,1299,3,256,128,0,1299,1300,5,126,0,0,1300,1341,1,0,0,0,
        1301,1302,3,294,147,0,1302,1303,5,136,0,0,1303,1304,3,248,124,0,
        1304,1306,5,125,0,0,1305,1307,3,278,139,0,1306,1305,1,0,0,0,1306,
        1307,1,0,0,0,1307,1308,1,0,0,0,1308,1309,5,126,0,0,1309,1341,1,0,
        0,0,1310,1315,3,248,124,0,1311,1313,5,133,0,0,1312,1314,3,228,114,
        0,1313,1312,1,0,0,0,1313,1314,1,0,0,0,1314,1316,1,0,0,0,1315,1311,
        1,0,0,0,1315,1316,1,0,0,0,1316,1319,1,0,0,0,1317,1319,3,250,125,
        0,1318,1310,1,0,0,0,1318,1317,1,0,0,0,1319,1320,1,0,0,0,1320,1322,
        5,125,0,0,1321,1323,3,278,139,0,1322,1321,1,0,0,0,1322,1323,1,0,
        0,0,1323,1324,1,0,0,0,1324,1325,5,126,0,0,1325,1341,1,0,0,0,1326,
        1341,3,266,133,0,1327,1341,3,270,135,0,1328,1329,3,252,126,0,1329,
        1330,5,125,0,0,1330,1335,3,256,128,0,1331,1332,5,135,0,0,1332,1334,
        3,298,149,0,1333,1331,1,0,0,0,1334,1337,1,0,0,0,1335,1333,1,0,0,
        0,1335,1336,1,0,0,0,1336,1338,1,0,0,0,1337,1335,1,0,0,0,1338,1339,
        5,126,0,0,1339,1341,1,0,0,0,1340,1238,1,0,0,0,1340,1240,1,0,0,0,
        1340,1241,1,0,0,0,1340,1255,1,0,0,0,1340,1266,1,0,0,0,1340,1268,
        1,0,0,0,1340,1270,1,0,0,0,1340,1279,1,0,0,0,1340,1288,1,0,0,0,1340,
        1297,1,0,0,0,1340,1301,1,0,0,0,1340,1318,1,0,0,0,1340,1326,1,0,0,
        0,1340,1327,1,0,0,0,1340,1328,1,0,0,0,1341,1414,1,0,0,0,1342,1343,
        10,24,0,0,1343,1344,7,16,0,0,1344,1413,3,256,128,25,1345,1346,10,
        23,0,0,1346,1347,7,17,0,0,1347,1413,3,256,128,24,1348,1349,10,22,
        0,0,1349,1350,5,100,0,0,1350,1413,3,256,128,23,1351,1352,10,18,0,
        0,1352,1353,3,230,115,0,1353,1354,3,256,128,19,1354,1413,1,0,0,0,
        1355,1357,10,17,0,0,1356,1358,5,79,0,0,1357,1356,1,0,0,0,1357,1358,
        1,0,0,0,1358,1359,1,0,0,0,1359,1360,5,74,0,0,1360,1413,3,256,128,
        18,1361,1362,10,12,0,0,1362,1363,5,39,0,0,1363,1413,3,256,128,13,
        1364,1365,10,11,0,0,1365,1366,5,84,0,0,1366,1413,3,256,128,12,1367,
        1368,10,10,0,0,1368,1369,5,153,0,0,1369,1413,3,256,128,11,1370,1371,
        10,30,0,0,1371,1413,3,146,73,0,1372,1373,10,29,0,0,1373,1413,3,250,
        125,0,1374,1375,10,28,0,0,1375,1376,5,136,0,0,1376,1413,3,250,125,
        0,1377,1378,10,27,0,0,1378,1379,5,131,0,0,1379,1413,3,254,127,0,
        1380,1381,10,26,0,0,1381,1382,5,132,0,0,1382,1413,3,254,127,0,1383,
        1384,10,21,0,0,1384,1385,5,61,0,0,1385,1386,3,256,128,0,1386,1387,
        3,250,125,0,1387,1413,1,0,0,0,1388,1389,10,20,0,0,1389,1390,5,122,
        0,0,1390,1413,3,262,131,0,1391,1392,10,19,0,0,1392,1393,5,148,0,
        0,1393,1413,3,262,131,0,1394,1395,10,16,0,0,1395,1397,5,68,0,0,1396,
        1398,5,79,0,0,1397,1396,1,0,0,0,1397,1398,1,0,0,0,1398,1399,1,0,
        0,0,1399,1413,5,81,0,0,1400,1402,10,15,0,0,1401,1403,5,79,0,0,1402,
        1401,1,0,0,0,1402,1403,1,0,0,0,1403,1404,1,0,0,0,1404,1405,5,69,
        0,0,1405,1406,5,125,0,0,1406,1407,3,264,132,0,1407,1408,5,126,0,
        0,1408,1413,1,0,0,0,1409,1410,10,14,0,0,1410,1411,5,154,0,0,1411,
        1413,3,262,131,0,1412,1342,1,0,0,0,1412,1345,1,0,0,0,1412,1348,1,
        0,0,0,1412,1351,1,0,0,0,1412,1355,1,0,0,0,1412,1361,1,0,0,0,1412,
        1364,1,0,0,0,1412,1367,1,0,0,0,1412,1370,1,0,0,0,1412,1372,1,0,0,
        0,1412,1374,1,0,0,0,1412,1377,1,0,0,0,1412,1380,1,0,0,0,1412,1383,
        1,0,0,0,1412,1388,1,0,0,0,1412,1391,1,0,0,0,1412,1394,1,0,0,0,1412,
        1400,1,0,0,0,1412,1409,1,0,0,0,1413,1416,1,0,0,0,1414,1412,1,0,0,
        0,1414,1415,1,0,0,0,1415,257,1,0,0,0,1416,1414,1,0,0,0,1417,1418,
        3,230,115,0,1418,1419,3,256,128,0,1419,259,1,0,0,0,1420,1427,3,258,
        129,0,1421,1423,5,68,0,0,1422,1424,5,79,0,0,1423,1422,1,0,0,0,1423,
        1424,1,0,0,0,1424,1425,1,0,0,0,1425,1427,5,81,0,0,1426,1420,1,0,
        0,0,1426,1421,1,0,0,0,1427,261,1,0,0,0,1428,1435,3,260,130,0,1429,
        1430,5,125,0,0,1430,1431,3,260,130,0,1431,1432,5,126,0,0,1432,1435,
        1,0,0,0,1433,1435,3,256,128,0,1434,1428,1,0,0,0,1434,1429,1,0,0,
        0,1434,1433,1,0,0,0,1435,263,1,0,0,0,1436,1441,3,256,128,0,1437,
        1438,5,135,0,0,1438,1440,3,256,128,0,1439,1437,1,0,0,0,1440,1443,
        1,0,0,0,1441,1439,1,0,0,0,1441,1442,1,0,0,0,1442,265,1,0,0,0,1443,
        1441,1,0,0,0,1444,1446,3,268,134,0,1445,1444,1,0,0,0,1446,1447,1,
        0,0,0,1447,1445,1,0,0,0,1447,1448,1,0,0,0,1448,1451,1,0,0,0,1449,
        1450,5,54,0,0,1450,1452,3,256,128,0,1451,1449,1,0,0,0,1451,1452,
        1,0,0,0,1452,267,1,0,0,0,1453,1455,5,85,0,0,1454,1456,3,256,128,
        0,1455,1454,1,0,0,0,1455,1456,1,0,0,0,1456,1457,1,0,0,0,1457,1458,
        5,104,0,0,1458,1459,3,262,131,0,1459,269,1,0,0,0,1460,1462,5,45,
        0,0,1461,1463,3,256,128,0,1462,1461,1,0,0,0,1462,1463,1,0,0,0,1463,
        1465,1,0,0,0,1464,1466,3,272,136,0,1465,1464,1,0,0,0,1466,1467,1,
        0,0,0,1467,1465,1,0,0,0,1467,1468,1,0,0,0,1468,1471,1,0,0,0,1469,
        1470,5,54,0,0,1470,1472,3,256,128,0,1471,1469,1,0,0,0,1471,1472,
        1,0,0,0,1472,1473,1,0,0,0,1473,1474,5,55,0,0,1474,271,1,0,0,0,1475,
        1476,5,104,0,0,1476,1477,3,256,128,0,1477,1478,5,96,0,0,1478,1479,
        3,256,128,0,1479,273,1,0,0,0,1480,1481,3,248,124,0,1481,275,1,0,
        0,0,1482,1490,3,294,147,0,1483,1484,3,274,137,0,1484,1485,5,68,0,
        0,1485,1487,1,0,0,0,1486,1483,1,0,0,0,1486,1487,1,0,0,0,1487,1488,
        1,0,0,0,1488,1490,3,256,128,0,1489,1482,1,0,0,0,1489,1486,1,0,0,
        0,1490,277,1,0,0,0,1491,1496,3,256,128,0,1492,1493,5,135,0,0,1493,
        1495,3,256,128,0,1494,1492,1,0,0,0,1495,1498,1,0,0,0,1496,1494,1,
        0,0,0,1496,1497,1,0,0,0,1497,1500,1,0,0,0,1498,1496,1,0,0,0,1499,
        1501,5,135,0,0,1500,1499,1,0,0,0,1500,1501,1,0,0,0,1501,279,1,0,
        0,0,1502,1509,3,298,149,0,1503,1505,5,135,0,0,1504,1503,1,0,0,0,
        1504,1505,1,0,0,0,1505,1506,1,0,0,0,1506,1508,3,298,149,0,1507,1504,
        1,0,0,0,1508,1511,1,0,0,0,1509,1507,1,0,0,0,1509,1510,1,0,0,0,1510,
        281,1,0,0,0,1511,1509,1,0,0,0,1512,1519,3,292,146,0,1513,1515,5,
        135,0,0,1514,1513,1,0,0,0,1514,1515,1,0,0,0,1515,1516,1,0,0,0,1516,
        1518,3,292,146,0,1517,1514,1,0,0,0,1518,1521,1,0,0,0,1519,1517,1,
        0,0,0,1519,1520,1,0,0,0,1520,1523,1,0,0,0,1521,1519,1,0,0,0,1522,
        1524,5,135,0,0,1523,1522,1,0,0,0,1523,1524,1,0,0,0,1524,283,1,0,
        0,0,1525,1526,3,294,147,0,1526,1527,5,136,0,0,1527,1529,1,0,0,0,
        1528,1525,1,0,0,0,1528,1529,1,0,0,0,1529,1530,1,0,0,0,1530,1532,
        5,145,0,0,1531,1533,3,286,143,0,1532,1531,1,0,0,0,1532,1533,1,0,
        0,0,1533,285,1,0,0,0,1534,1538,5,129,0,0,1535,1536,5,9,0,0,1536,
        1539,3,280,140,0,1537,1539,5,135,0,0,1538,1535,1,0,0,0,1538,1537,
        1,0,0,0,1539,1540,1,0,0,0,1540,1538,1,0,0,0,1540,1541,1,0,0,0,1541,
        1542,1,0,0,0,1542,1543,5,130,0,0,1543,287,1,0,0,0,1544,1545,3,10,
        5,0,1545,1547,3,294,147,0,1546,1548,3,290,145,0,1547,1546,1,0,0,
        0,1547,1548,1,0,0,0,1548,289,1,0,0,0,1549,1550,5,136,0,0,1550,1557,
        3,250,125,0,1551,1552,5,136,0,0,1552,1553,3,226,113,0,1553,1554,
        5,125,0,0,1554,1555,5,126,0,0,1555,1557,1,0,0,0,1556,1549,1,0,0,
        0,1556,1551,1,0,0,0,1557,291,1,0,0,0,1558,1562,3,288,144,0,1559,
        1562,3,284,142,0,1560,1562,3,86,43,0,1561,1558,1,0,0,0,1561,1559,
        1,0,0,0,1561,1560,1,0,0,0,1562,293,1,0,0,0,1563,1568,3,298,149,0,
        1564,1565,5,136,0,0,1565,1567,3,298,149,0,1566,1564,1,0,0,0,1567,
        1570,1,0,0,0,1568,1566,1,0,0,0,1568,1569,1,0,0,0,1569,295,1,0,0,
        0,1570,1568,1,0,0,0,1571,1572,3,248,124,0,1572,297,1,0,0,0,1573,
        1574,3,248,124,0,1574,299,1,0,0,0,1575,1576,3,248,124,0,1576,301,
        1,0,0,0,1577,1578,3,248,124,0,1578,303,1,0,0,0,1579,1580,3,232,116,
        0,1580,305,1,0,0,0,1581,1582,7,18,0,0,1582,307,1,0,0,0,1583,1584,
        7,19,0,0,1584,309,1,0,0,0,1585,1588,3,306,153,0,1586,1588,3,308,
        154,0,1587,1585,1,0,0,0,1587,1586,1,0,0,0,1588,311,1,0,0,0,1589,
        1590,3,256,128,0,1590,1591,5,0,0,1,1591,313,1,0,0,0,1592,1593,3,
        262,131,0,1593,1594,5,0,0,1,1594,315,1,0,0,0,1595,1596,5,149,0,0,
        1596,1597,5,149,0,0,1597,1598,5,127,0,0,1598,1599,3,232,116,0,1599,
        1600,5,128,0,0,1600,317,1,0,0,0,176,320,322,334,348,363,374,384,
        393,400,405,410,416,421,425,442,458,460,469,474,478,483,498,503,
        511,516,520,529,531,544,553,562,565,572,574,578,585,592,597,601,
        610,615,619,632,638,645,652,657,665,675,680,687,694,707,710,715,
        726,733,735,741,743,758,766,771,775,783,787,792,796,802,812,821,
        828,836,841,846,848,855,860,864,880,885,890,898,903,907,909,915,
        920,922,932,936,940,944,956,963,967,977,982,986,993,1008,1012,1033,
        1043,1048,1052,1056,1064,1069,1073,1079,1101,1105,1113,1117,1124,
        1129,1133,1137,1140,1149,1157,1160,1164,1169,1176,1196,1213,1222,
        1236,1247,1251,1261,1279,1284,1293,1306,1313,1315,1318,1322,1335,
        1340,1357,1397,1402,1412,1414,1423,1426,1434,1441,1447,1451,1455,
        1462,1467,1471,1486,1489,1496,1500,1504,1509,1514,1519,1523,1528,
        1532,1538,1540,1547,1556,1561,1568,1587
    ]

class MalloyParser ( Parser ):

    grammarFileName = "MalloyParser.g4"

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

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

    sharedContextCache = PredictionContextCache()

    literalNames = [ "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "'&'", "'->'", "'=>'", "'('", 
                     "')'", "'['", "']'", "'{'", "'}'", "'::'", "':::'", 
                     "'!'", "':'", "','", "'.'", "'<'", "'>'", "'='", "'!='", 
                     "'<='", "'>='", "'+'", "'-'", "'*'", "'**'", "'/'", 
                     "'|'", "';'", "'!~'", "'~'", "'%'", "'??'", "'?'", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "'\"\"\"'" ]

    symbolicNames = [ "<INVALID>", "ACCEPT", "AGGREGATE", "CALCULATE", "CALCULATION", 
                      "CONNECTION", "DECLARE", "DIMENSION", "DRILL", "EXCEPT", 
                      "EXTENDQ", "GROUP_BY", "GROUPED_BY", "HAVING", "INDEX", 
                      "INTERNAL", "JOIN_CROSS", "JOIN_ONE", "JOIN_MANY", 
                      "LIMIT", "MEASURE", "NEST", "ORDER_BY", "PARTITION_BY", 
                      "PRIMARY_KEY", "PRIVATE", "PROJECT", "PUBLIC", "QUERY", 
                      "RENAME", "RUN", "SAMPLE", "SELECT", "SOURCE", "TOP", 
                      "WHERE", "VIEW", "TIMEZONE", "ALL", "AND", "AS", "ASC", 
                      "AVG", "BOOLEAN", "BY", "CASE", "CAST", "CONDITION", 
                      "COUNT", "COMPOSE", "DATE", "DAY", "DESC", "DISTINCT", 
                      "ELSE", "END", "EXCLUDE", "EXTEND", "FALSE", "FILTER", 
                      "FULL", "FOR", "FROM", "HAS", "HOUR", "IMPORT", "INCLUDE", 
                      "INNER", "IS", "IN", "INTERNAL_KW", "JSON", "LAST", 
                      "LEFT", "LIKE", "MAX", "MIN", "MINUTE", "MONTH", "NOT", 
                      "NOW", "NULL", "NUMBER", "ON", "OR", "PICK", "PRIVATE_KW", 
                      "PUBLIC_KW", "QUARTER", "RIGHT", "SECOND", "STRING", 
                      "SOURCE_KW", "SUM", "SQL", "TABLE", "THEN", "THIS", 
                      "TIMESTAMPTZ", "TIMESTAMP", "TO", "TRUE", "TURTLE", 
                      "WEEK", "WHEN", "WITH", "YEAR", "UNGROUPED", "HACKY_REGEX", 
                      "RAW_SQ", "RAW_DQ", "SQ3_FILTER", "SQ_FILTER", "DQ3_FILTER", 
                      "DQ_FILTER", "BQ3_FILTER", "BQ_FILTER", "SQ_STRING", 
                      "DQ_STRING", "BQ_STRING", "DOC_ANNOTATION", "ANNOTATION", 
                      "AMPER", "ARROW", "FAT_ARROW", "OPAREN", "CPAREN", 
                      "OBRACK", "CBRACK", "OCURLY", "CCURLY", "DOUBLECOLON", 
                      "TRIPLECOLON", "EXCLAM", "COLON", "COMMA", "DOT", 
                      "LT", "GT", "EQ", "NE", "LTE", "GTE", "PLUS", "MINUS", 
                      "STAR", "STARSTAR", "SLASH", "BAR", "SEMI", "NOT_MATCH", 
                      "MATCH", "PERCENT", "DOUBLE_QMARK", "QMARK", "LITERAL_TIMESTAMP", 
                      "LITERAL_HOUR", "LITERAL_DAY", "LITERAL_QUARTER", 
                      "LITERAL_MONTH", "LITERAL_WEEK", "LITERAL_YEAR", "IDENTIFIER", 
                      "PERCENT_LITERAL", "NUMERIC_LITERAL", "INTEGER_LITERAL", 
                      "BLOCK_COMMENT", "COMMENT_TO_EOL", "WHITE_SPACE", 
                      "SQL_BEGIN", "UNWATED_CHARS_TRAILING_NUMBERS", "UNEXPECTED_CHAR", 
                      "OPEN_CODE", "SQL_END" ]

    RULE_malloyDocument = 0
    RULE_malloyStatement = 1
    RULE_defineSourceStatement = 2
    RULE_defineQuery = 3
    RULE_topLevelAnonQueryDef = 4
    RULE_tags = 5
    RULE_isDefine = 6
    RULE_runStatement = 7
    RULE_sqlString = 8
    RULE_sqlInterpolation = 9
    RULE_importStatement = 10
    RULE_importSelect = 11
    RULE_importItem = 12
    RULE_importURL = 13
    RULE_docAnnotations = 14
    RULE_ignoredObjectAnnotations = 15
    RULE_ignoredModelAnnotations = 16
    RULE_topLevelQueryDefs = 17
    RULE_topLevelQueryDef = 18
    RULE_refineOperator = 19
    RULE_turtleName = 20
    RULE_sqlSource = 21
    RULE_exploreTable = 22
    RULE_connectionId = 23
    RULE_queryProperties = 24
    RULE_queryName = 25
    RULE_sourcePropertyList = 26
    RULE_sourceDefinition = 27
    RULE_sqExplore = 28
    RULE_sourceParameters = 29
    RULE_legalParamType = 30
    RULE_sourceParameter = 31
    RULE_parameterNameDef = 32
    RULE_sourceNameDef = 33
    RULE_exploreProperties = 34
    RULE_exploreStatement = 35
    RULE_accessLabel = 36
    RULE_accessModifierList = 37
    RULE_defMeasures = 38
    RULE_defDimensions = 39
    RULE_renameList = 40
    RULE_renameEntry = 41
    RULE_defList = 42
    RULE_fieldDef = 43
    RULE_fieldNameDef = 44
    RULE_joinNameDef = 45
    RULE_declareStatement = 46
    RULE_joinStatement = 47
    RULE_queryExtend = 48
    RULE_modEither = 49
    RULE_sourceArguments = 50
    RULE_argumentId = 51
    RULE_sourceArgument = 52
    RULE_sqExpr = 53
    RULE_includeBlock = 54
    RULE_includeItem = 55
    RULE_orphanedAnnotation = 56
    RULE_accessLabelProp = 57
    RULE_includeExceptList = 58
    RULE_includeExceptListItem = 59
    RULE_includeList = 60
    RULE_includeField = 61
    RULE_segExpr = 62
    RULE_vExpr = 63
    RULE_queryExtendStatement = 64
    RULE_queryExtendStatementList = 65
    RULE_joinList = 66
    RULE_isExplore = 67
    RULE_matrixOperation = 68
    RULE_joinFrom = 69
    RULE_joinDef = 70
    RULE_joinExpression = 71
    RULE_filterStatement = 72
    RULE_fieldProperties = 73
    RULE_aggregateOrdering = 74
    RULE_aggregateOrderBySpec = 75
    RULE_aggregateOrderByStatement = 76
    RULE_fieldPropertyLimitStatement = 77
    RULE_fieldPropertyStatement = 78
    RULE_filterClauseList = 79
    RULE_whereStatement = 80
    RULE_havingStatement = 81
    RULE_subQueryDefList = 82
    RULE_exploreQueryNameDef = 83
    RULE_exploreQueryDef = 84
    RULE_drillStatement = 85
    RULE_drillClauseList = 86
    RULE_queryStatement = 87
    RULE_queryJoinStatement = 88
    RULE_groupByStatement = 89
    RULE_queryFieldList = 90
    RULE_queryFieldEntry = 91
    RULE_nestStatement = 92
    RULE_nestedQueryList = 93
    RULE_nestEntry = 94
    RULE_aggregateStatement = 95
    RULE_calculateStatement = 96
    RULE_projectStatement = 97
    RULE_partitionByStatement = 98
    RULE_groupedByStatement = 99
    RULE_orderByStatement = 100
    RULE_ordering = 101
    RULE_orderBySpec = 102
    RULE_limitStatement = 103
    RULE_bySpec = 104
    RULE_topStatement = 105
    RULE_indexElement = 106
    RULE_indexFields = 107
    RULE_indexStatement = 108
    RULE_sampleStatement = 109
    RULE_timezoneStatement = 110
    RULE_queryAnnotation = 111
    RULE_sampleSpec = 112
    RULE_aggregate = 113
    RULE_malloyType = 114
    RULE_compareOp = 115
    RULE_string = 116
    RULE_shortString = 117
    RULE_rawString = 118
    RULE_numericLiteral = 119
    RULE_literal = 120
    RULE_dateLiteral = 121
    RULE_tablePath = 122
    RULE_tableURI = 123
    RULE_id = 124
    RULE_timeframe = 125
    RULE_ungroup = 126
    RULE_malloyOrSQLType = 127
    RULE_fieldExpr = 128
    RULE_partialCompare = 129
    RULE_partialTest = 130
    RULE_partialAllowedFieldExpr = 131
    RULE_fieldExprList = 132
    RULE_pickStatement = 133
    RULE_pick = 134
    RULE_caseStatement = 135
    RULE_caseWhen = 136
    RULE_recordKey = 137
    RULE_recordElement = 138
    RULE_argumentList = 139
    RULE_fieldNameList = 140
    RULE_fieldCollection = 141
    RULE_collectionWildCard = 142
    RULE_starQualified = 143
    RULE_taggedRef = 144
    RULE_refExpr = 145
    RULE_collectionMember = 146
    RULE_fieldPath = 147
    RULE_joinName = 148
    RULE_fieldName = 149
    RULE_sqlExploreNameRef = 150
    RULE_nameSQLBlock = 151
    RULE_connectionName = 152
    RULE_tripFilterString = 153
    RULE_tickFilterString = 154
    RULE_filterString = 155
    RULE_debugExpr = 156
    RULE_debugPartial = 157
    RULE_experimentalStatementForTesting = 158

    ruleNames =  [ "malloyDocument", "malloyStatement", "defineSourceStatement", 
                   "defineQuery", "topLevelAnonQueryDef", "tags", "isDefine", 
                   "runStatement", "sqlString", "sqlInterpolation", "importStatement", 
                   "importSelect", "importItem", "importURL", "docAnnotations", 
                   "ignoredObjectAnnotations", "ignoredModelAnnotations", 
                   "topLevelQueryDefs", "topLevelQueryDef", "refineOperator", 
                   "turtleName", "sqlSource", "exploreTable", "connectionId", 
                   "queryProperties", "queryName", "sourcePropertyList", 
                   "sourceDefinition", "sqExplore", "sourceParameters", 
                   "legalParamType", "sourceParameter", "parameterNameDef", 
                   "sourceNameDef", "exploreProperties", "exploreStatement", 
                   "accessLabel", "accessModifierList", "defMeasures", "defDimensions", 
                   "renameList", "renameEntry", "defList", "fieldDef", "fieldNameDef", 
                   "joinNameDef", "declareStatement", "joinStatement", "queryExtend", 
                   "modEither", "sourceArguments", "argumentId", "sourceArgument", 
                   "sqExpr", "includeBlock", "includeItem", "orphanedAnnotation", 
                   "accessLabelProp", "includeExceptList", "includeExceptListItem", 
                   "includeList", "includeField", "segExpr", "vExpr", "queryExtendStatement", 
                   "queryExtendStatementList", "joinList", "isExplore", 
                   "matrixOperation", "joinFrom", "joinDef", "joinExpression", 
                   "filterStatement", "fieldProperties", "aggregateOrdering", 
                   "aggregateOrderBySpec", "aggregateOrderByStatement", 
                   "fieldPropertyLimitStatement", "fieldPropertyStatement", 
                   "filterClauseList", "whereStatement", "havingStatement", 
                   "subQueryDefList", "exploreQueryNameDef", "exploreQueryDef", 
                   "drillStatement", "drillClauseList", "queryStatement", 
                   "queryJoinStatement", "groupByStatement", "queryFieldList", 
                   "queryFieldEntry", "nestStatement", "nestedQueryList", 
                   "nestEntry", "aggregateStatement", "calculateStatement", 
                   "projectStatement", "partitionByStatement", "groupedByStatement", 
                   "orderByStatement", "ordering", "orderBySpec", "limitStatement", 
                   "bySpec", "topStatement", "indexElement", "indexFields", 
                   "indexStatement", "sampleStatement", "timezoneStatement", 
                   "queryAnnotation", "sampleSpec", "aggregate", "malloyType", 
                   "compareOp", "string", "shortString", "rawString", "numericLiteral", 
                   "literal", "dateLiteral", "tablePath", "tableURI", "id", 
                   "timeframe", "ungroup", "malloyOrSQLType", "fieldExpr", 
                   "partialCompare", "partialTest", "partialAllowedFieldExpr", 
                   "fieldExprList", "pickStatement", "pick", "caseStatement", 
                   "caseWhen", "recordKey", "recordElement", "argumentList", 
                   "fieldNameList", "fieldCollection", "collectionWildCard", 
                   "starQualified", "taggedRef", "refExpr", "collectionMember", 
                   "fieldPath", "joinName", "fieldName", "sqlExploreNameRef", 
                   "nameSQLBlock", "connectionName", "tripFilterString", 
                   "tickFilterString", "filterString", "debugExpr", "debugPartial", 
                   "experimentalStatementForTesting" ]

    EOF = Token.EOF
    ACCEPT=1
    AGGREGATE=2
    CALCULATE=3
    CALCULATION=4
    CONNECTION=5
    DECLARE=6
    DIMENSION=7
    DRILL=8
    EXCEPT=9
    EXTENDQ=10
    GROUP_BY=11
    GROUPED_BY=12
    HAVING=13
    INDEX=14
    INTERNAL=15
    JOIN_CROSS=16
    JOIN_ONE=17
    JOIN_MANY=18
    LIMIT=19
    MEASURE=20
    NEST=21
    ORDER_BY=22
    PARTITION_BY=23
    PRIMARY_KEY=24
    PRIVATE=25
    PROJECT=26
    PUBLIC=27
    QUERY=28
    RENAME=29
    RUN=30
    SAMPLE=31
    SELECT=32
    SOURCE=33
    TOP=34
    WHERE=35
    VIEW=36
    TIMEZONE=37
    ALL=38
    AND=39
    AS=40
    ASC=41
    AVG=42
    BOOLEAN=43
    BY=44
    CASE=45
    CAST=46
    CONDITION=47
    COUNT=48
    COMPOSE=49
    DATE=50
    DAY=51
    DESC=52
    DISTINCT=53
    ELSE=54
    END=55
    EXCLUDE=56
    EXTEND=57
    FALSE=58
    FILTER=59
    FULL=60
    FOR=61
    FROM=62
    HAS=63
    HOUR=64
    IMPORT=65
    INCLUDE=66
    INNER=67
    IS=68
    IN=69
    INTERNAL_KW=70
    JSON=71
    LAST=72
    LEFT=73
    LIKE=74
    MAX=75
    MIN=76
    MINUTE=77
    MONTH=78
    NOT=79
    NOW=80
    NULL=81
    NUMBER=82
    ON=83
    OR=84
    PICK=85
    PRIVATE_KW=86
    PUBLIC_KW=87
    QUARTER=88
    RIGHT=89
    SECOND=90
    STRING=91
    SOURCE_KW=92
    SUM=93
    SQL=94
    TABLE=95
    THEN=96
    THIS=97
    TIMESTAMPTZ=98
    TIMESTAMP=99
    TO=100
    TRUE=101
    TURTLE=102
    WEEK=103
    WHEN=104
    WITH=105
    YEAR=106
    UNGROUPED=107
    HACKY_REGEX=108
    RAW_SQ=109
    RAW_DQ=110
    SQ3_FILTER=111
    SQ_FILTER=112
    DQ3_FILTER=113
    DQ_FILTER=114
    BQ3_FILTER=115
    BQ_FILTER=116
    SQ_STRING=117
    DQ_STRING=118
    BQ_STRING=119
    DOC_ANNOTATION=120
    ANNOTATION=121
    AMPER=122
    ARROW=123
    FAT_ARROW=124
    OPAREN=125
    CPAREN=126
    OBRACK=127
    CBRACK=128
    OCURLY=129
    CCURLY=130
    DOUBLECOLON=131
    TRIPLECOLON=132
    EXCLAM=133
    COLON=134
    COMMA=135
    DOT=136
    LT=137
    GT=138
    EQ=139
    NE=140
    LTE=141
    GTE=142
    PLUS=143
    MINUS=144
    STAR=145
    STARSTAR=146
    SLASH=147
    BAR=148
    SEMI=149
    NOT_MATCH=150
    MATCH=151
    PERCENT=152
    DOUBLE_QMARK=153
    QMARK=154
    LITERAL_TIMESTAMP=155
    LITERAL_HOUR=156
    LITERAL_DAY=157
    LITERAL_QUARTER=158
    LITERAL_MONTH=159
    LITERAL_WEEK=160
    LITERAL_YEAR=161
    IDENTIFIER=162
    PERCENT_LITERAL=163
    NUMERIC_LITERAL=164
    INTEGER_LITERAL=165
    BLOCK_COMMENT=166
    COMMENT_TO_EOL=167
    WHITE_SPACE=168
    SQL_BEGIN=169
    UNWATED_CHARS_TRAILING_NUMBERS=170
    UNEXPECTED_CHAR=171
    OPEN_CODE=172
    SQL_END=173

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




    class MalloyDocumentContext(ParserRuleContext):
        __slots__ = 'parser'

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

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

        def malloyStatement(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.MalloyStatementContext)
            else:
                return self.getTypedRuleContext(MalloyParser.MalloyStatementContext,i)


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

        def getRuleIndex(self):
            return MalloyParser.RULE_malloyDocument

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

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

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




    def malloyDocument(self):

        localctx = MalloyParser.MalloyDocumentContext(self, self._ctx, self.state)
        self.enterRule(localctx, 0, self.RULE_malloyDocument)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 322
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while ((((_la - 28)) & ~0x3f) == 0 and ((1 << (_la - 28)) & 137438953509) != 0) or ((((_la - 120)) & ~0x3f) == 0 and ((1 << (_la - 120)) & 536870915) != 0):
                self.state = 320
                self._errHandler.sync(self)
                la_ = self._interp.adaptivePredict(self._input,0,self._ctx)
                if la_ == 1:
                    self.state = 318
                    self.malloyStatement()
                    pass

                elif la_ == 2:
                    self.state = 319
                    self.match(MalloyParser.SEMI)
                    pass


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

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


    class MalloyStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def defineSourceStatement(self):
            return self.getTypedRuleContext(MalloyParser.DefineSourceStatementContext,0)


        def defineQuery(self):
            return self.getTypedRuleContext(MalloyParser.DefineQueryContext,0)


        def importStatement(self):
            return self.getTypedRuleContext(MalloyParser.ImportStatementContext,0)


        def runStatement(self):
            return self.getTypedRuleContext(MalloyParser.RunStatementContext,0)


        def docAnnotations(self):
            return self.getTypedRuleContext(MalloyParser.DocAnnotationsContext,0)


        def ignoredObjectAnnotations(self):
            return self.getTypedRuleContext(MalloyParser.IgnoredObjectAnnotationsContext,0)


        def experimentalStatementForTesting(self):
            return self.getTypedRuleContext(MalloyParser.ExperimentalStatementForTestingContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_malloyStatement

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

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

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




    def malloyStatement(self):

        localctx = MalloyParser.MalloyStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 2, self.RULE_malloyStatement)
        try:
            self.state = 334
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,2,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 327
                self.defineSourceStatement()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 328
                self.defineQuery()
                pass

            elif la_ == 3:
                self.enterOuterAlt(localctx, 3)
                self.state = 329
                self.importStatement()
                pass

            elif la_ == 4:
                self.enterOuterAlt(localctx, 4)
                self.state = 330
                self.runStatement()
                pass

            elif la_ == 5:
                self.enterOuterAlt(localctx, 5)
                self.state = 331
                self.docAnnotations()
                pass

            elif la_ == 6:
                self.enterOuterAlt(localctx, 6)
                self.state = 332
                self.ignoredObjectAnnotations()
                pass

            elif la_ == 7:
                self.enterOuterAlt(localctx, 7)
                self.state = 333
                self.experimentalStatementForTesting()
                pass


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


    class DefineSourceStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def tags(self):
            return self.getTypedRuleContext(MalloyParser.TagsContext,0)


        def SOURCE(self):
            return self.getToken(MalloyParser.SOURCE, 0)

        def sourcePropertyList(self):
            return self.getTypedRuleContext(MalloyParser.SourcePropertyListContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_defineSourceStatement

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

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

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




    def defineSourceStatement(self):

        localctx = MalloyParser.DefineSourceStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 4, self.RULE_defineSourceStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 336
            self.tags()
            self.state = 337
            self.match(MalloyParser.SOURCE)
            self.state = 338
            self.sourcePropertyList()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class DefineQueryContext(ParserRuleContext):
        __slots__ = 'parser'

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


        def getRuleIndex(self):
            return MalloyParser.RULE_defineQuery

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



    class Use_top_level_query_defsContext(DefineQueryContext):

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

        def topLevelQueryDefs(self):
            return self.getTypedRuleContext(MalloyParser.TopLevelQueryDefsContext,0)


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

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

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



    def defineQuery(self):

        localctx = MalloyParser.DefineQueryContext(self, self._ctx, self.state)
        self.enterRule(localctx, 6, self.RULE_defineQuery)
        try:
            localctx = MalloyParser.Use_top_level_query_defsContext(self, localctx)
            self.enterOuterAlt(localctx, 1)
            self.state = 340
            self.topLevelQueryDefs()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class TopLevelAnonQueryDefContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def tags(self):
            return self.getTypedRuleContext(MalloyParser.TagsContext,0)


        def sqExpr(self):
            return self.getTypedRuleContext(MalloyParser.SqExprContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_topLevelAnonQueryDef

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

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

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




    def topLevelAnonQueryDef(self):

        localctx = MalloyParser.TopLevelAnonQueryDefContext(self, self._ctx, self.state)
        self.enterRule(localctx, 8, self.RULE_topLevelAnonQueryDef)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 342
            self.tags()
            self.state = 343
            self.sqExpr(0)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class TagsContext(ParserRuleContext):
        __slots__ = 'parser'

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

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

        def getRuleIndex(self):
            return MalloyParser.RULE_tags

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

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

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




    def tags(self):

        localctx = MalloyParser.TagsContext(self, self._ctx, self.state)
        self.enterRule(localctx, 10, self.RULE_tags)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 348
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==121:
                self.state = 345
                self.match(MalloyParser.ANNOTATION)
                self.state = 350
                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 IsDefineContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def IS(self):
            return self.getToken(MalloyParser.IS, 0)

        def tags(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.TagsContext)
            else:
                return self.getTypedRuleContext(MalloyParser.TagsContext,i)


        def getRuleIndex(self):
            return MalloyParser.RULE_isDefine

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

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

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




    def isDefine(self):

        localctx = MalloyParser.IsDefineContext(self, self._ctx, self.state)
        self.enterRule(localctx, 12, self.RULE_isDefine)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 351
            localctx.beforeIs = self.tags()
            self.state = 352
            self.match(MalloyParser.IS)
            self.state = 353
            localctx.afterIs = self.tags()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class RunStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def tags(self):
            return self.getTypedRuleContext(MalloyParser.TagsContext,0)


        def RUN(self):
            return self.getToken(MalloyParser.RUN, 0)

        def topLevelAnonQueryDef(self):
            return self.getTypedRuleContext(MalloyParser.TopLevelAnonQueryDefContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_runStatement

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

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

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




    def runStatement(self):

        localctx = MalloyParser.RunStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 14, self.RULE_runStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 355
            self.tags()
            self.state = 356
            self.match(MalloyParser.RUN)
            self.state = 357
            self.topLevelAnonQueryDef()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class SqlStringContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def SQL_BEGIN(self):
            return self.getToken(MalloyParser.SQL_BEGIN, 0)

        def SQL_END(self):
            return self.getToken(MalloyParser.SQL_END, 0)

        def sqlInterpolation(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.SqlInterpolationContext)
            else:
                return self.getTypedRuleContext(MalloyParser.SqlInterpolationContext,i)


        def getRuleIndex(self):
            return MalloyParser.RULE_sqlString

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

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

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




    def sqlString(self):

        localctx = MalloyParser.SqlStringContext(self, self._ctx, self.state)
        self.enterRule(localctx, 16, self.RULE_sqlString)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 359
            self.match(MalloyParser.SQL_BEGIN)
            self.state = 363
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==172:
                self.state = 360
                self.sqlInterpolation()
                self.state = 365
                self._errHandler.sync(self)
                _la = self._input.LA(1)

            self.state = 366
            self.match(MalloyParser.SQL_END)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class SqlInterpolationContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def OPEN_CODE(self):
            return self.getToken(MalloyParser.OPEN_CODE, 0)

        def sqExpr(self):
            return self.getTypedRuleContext(MalloyParser.SqExprContext,0)


        def CCURLY(self):
            return self.getToken(MalloyParser.CCURLY, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_sqlInterpolation

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

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

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




    def sqlInterpolation(self):

        localctx = MalloyParser.SqlInterpolationContext(self, self._ctx, self.state)
        self.enterRule(localctx, 18, self.RULE_sqlInterpolation)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 368
            self.match(MalloyParser.OPEN_CODE)
            self.state = 369
            self.sqExpr(0)
            self.state = 370
            self.match(MalloyParser.CCURLY)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class ImportStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def IMPORT(self):
            return self.getToken(MalloyParser.IMPORT, 0)

        def importURL(self):
            return self.getTypedRuleContext(MalloyParser.ImportURLContext,0)


        def importSelect(self):
            return self.getTypedRuleContext(MalloyParser.ImportSelectContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_importStatement

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

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

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




    def importStatement(self):

        localctx = MalloyParser.ImportStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 20, self.RULE_importStatement)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 372
            self.match(MalloyParser.IMPORT)
            self.state = 374
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==129:
                self.state = 373
                self.importSelect()


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


    class ImportSelectContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def OCURLY(self):
            return self.getToken(MalloyParser.OCURLY, 0)

        def importItem(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.ImportItemContext)
            else:
                return self.getTypedRuleContext(MalloyParser.ImportItemContext,i)


        def CCURLY(self):
            return self.getToken(MalloyParser.CCURLY, 0)

        def FROM(self):
            return self.getToken(MalloyParser.FROM, 0)

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

        def getRuleIndex(self):
            return MalloyParser.RULE_importSelect

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

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

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




    def importSelect(self):

        localctx = MalloyParser.ImportSelectContext(self, self._ctx, self.state)
        self.enterRule(localctx, 22, self.RULE_importSelect)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 378
            self.match(MalloyParser.OCURLY)
            self.state = 379
            self.importItem()
            self.state = 384
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==135:
                self.state = 380
                self.match(MalloyParser.COMMA)
                self.state = 381
                self.importItem()
                self.state = 386
                self._errHandler.sync(self)
                _la = self._input.LA(1)

            self.state = 387
            self.match(MalloyParser.CCURLY)
            self.state = 388
            self.match(MalloyParser.FROM)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class ImportItemContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def id_(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.IdContext)
            else:
                return self.getTypedRuleContext(MalloyParser.IdContext,i)


        def IS(self):
            return self.getToken(MalloyParser.IS, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_importItem

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

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

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




    def importItem(self):

        localctx = MalloyParser.ImportItemContext(self, self._ctx, self.state)
        self.enterRule(localctx, 24, self.RULE_importItem)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 390
            self.id_()
            self.state = 393
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==68:
                self.state = 391
                self.match(MalloyParser.IS)
                self.state = 392
                self.id_()


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


    class ImportURLContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def string(self):
            return self.getTypedRuleContext(MalloyParser.StringContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_importURL

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

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

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




    def importURL(self):

        localctx = MalloyParser.ImportURLContext(self, self._ctx, self.state)
        self.enterRule(localctx, 26, self.RULE_importURL)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 395
            self.string()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class DocAnnotationsContext(ParserRuleContext):
        __slots__ = 'parser'

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

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

        def getRuleIndex(self):
            return MalloyParser.RULE_docAnnotations

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

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

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




    def docAnnotations(self):

        localctx = MalloyParser.DocAnnotationsContext(self, self._ctx, self.state)
        self.enterRule(localctx, 28, self.RULE_docAnnotations)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 398 
            self._errHandler.sync(self)
            _alt = 1
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt == 1:
                    self.state = 397
                    self.match(MalloyParser.DOC_ANNOTATION)

                else:
                    raise NoViableAltException(self)
                self.state = 400 
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,8,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 IgnoredObjectAnnotationsContext(ParserRuleContext):
        __slots__ = 'parser'

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

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

        def getRuleIndex(self):
            return MalloyParser.RULE_ignoredObjectAnnotations

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

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

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




    def ignoredObjectAnnotations(self):

        localctx = MalloyParser.IgnoredObjectAnnotationsContext(self, self._ctx, self.state)
        self.enterRule(localctx, 30, self.RULE_ignoredObjectAnnotations)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 403 
            self._errHandler.sync(self)
            _alt = 1
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt == 1:
                    self.state = 402
                    self.match(MalloyParser.ANNOTATION)

                else:
                    raise NoViableAltException(self)
                self.state = 405 
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,9,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 IgnoredModelAnnotationsContext(ParserRuleContext):
        __slots__ = 'parser'

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

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

        def getRuleIndex(self):
            return MalloyParser.RULE_ignoredModelAnnotations

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

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

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




    def ignoredModelAnnotations(self):

        localctx = MalloyParser.IgnoredModelAnnotationsContext(self, self._ctx, self.state)
        self.enterRule(localctx, 32, self.RULE_ignoredModelAnnotations)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 408 
            self._errHandler.sync(self)
            _alt = 1
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt == 1:
                    self.state = 407
                    self.match(MalloyParser.DOC_ANNOTATION)

                else:
                    raise NoViableAltException(self)
                self.state = 410 
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,10,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 TopLevelQueryDefsContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def tags(self):
            return self.getTypedRuleContext(MalloyParser.TagsContext,0)


        def QUERY(self):
            return self.getToken(MalloyParser.QUERY, 0)

        def topLevelQueryDef(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.TopLevelQueryDefContext)
            else:
                return self.getTypedRuleContext(MalloyParser.TopLevelQueryDefContext,i)


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

        def getRuleIndex(self):
            return MalloyParser.RULE_topLevelQueryDefs

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

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

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




    def topLevelQueryDefs(self):

        localctx = MalloyParser.TopLevelQueryDefsContext(self, self._ctx, self.state)
        self.enterRule(localctx, 34, self.RULE_topLevelQueryDefs)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 412
            self.tags()
            self.state = 413
            self.match(MalloyParser.QUERY)
            self.state = 414
            self.topLevelQueryDef()
            self.state = 421
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,12,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 416
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)
                    if _la==135:
                        self.state = 415
                        self.match(MalloyParser.COMMA)


                    self.state = 418
                    self.topLevelQueryDef() 
                self.state = 423
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,12,self._ctx)

            self.state = 425
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==135:
                self.state = 424
                self.match(MalloyParser.COMMA)


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


    class TopLevelQueryDefContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def tags(self):
            return self.getTypedRuleContext(MalloyParser.TagsContext,0)


        def queryName(self):
            return self.getTypedRuleContext(MalloyParser.QueryNameContext,0)


        def isDefine(self):
            return self.getTypedRuleContext(MalloyParser.IsDefineContext,0)


        def sqExpr(self):
            return self.getTypedRuleContext(MalloyParser.SqExprContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_topLevelQueryDef

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

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

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




    def topLevelQueryDef(self):

        localctx = MalloyParser.TopLevelQueryDefContext(self, self._ctx, self.state)
        self.enterRule(localctx, 36, self.RULE_topLevelQueryDef)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 427
            self.tags()
            self.state = 428
            self.queryName()
            self.state = 429
            self.isDefine()
            self.state = 430
            self.sqExpr(0)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class RefineOperatorContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def PLUS(self):
            return self.getToken(MalloyParser.PLUS, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_refineOperator

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

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

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




    def refineOperator(self):

        localctx = MalloyParser.RefineOperatorContext(self, self._ctx, self.state)
        self.enterRule(localctx, 38, self.RULE_refineOperator)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 432
            self.match(MalloyParser.PLUS)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class TurtleNameContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def id_(self):
            return self.getTypedRuleContext(MalloyParser.IdContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_turtleName

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

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

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




    def turtleName(self):

        localctx = MalloyParser.TurtleNameContext(self, self._ctx, self.state)
        self.enterRule(localctx, 40, self.RULE_turtleName)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 434
            self.id_()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class SqlSourceContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def connectionId(self):
            return self.getTypedRuleContext(MalloyParser.ConnectionIdContext,0)


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

        def SQL(self):
            return self.getToken(MalloyParser.SQL, 0)

        def OPAREN(self):
            return self.getToken(MalloyParser.OPAREN, 0)

        def CPAREN(self):
            return self.getToken(MalloyParser.CPAREN, 0)

        def sqlString(self):
            return self.getTypedRuleContext(MalloyParser.SqlStringContext,0)


        def shortString(self):
            return self.getTypedRuleContext(MalloyParser.ShortStringContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_sqlSource

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

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

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




    def sqlSource(self):

        localctx = MalloyParser.SqlSourceContext(self, self._ctx, self.state)
        self.enterRule(localctx, 42, self.RULE_sqlSource)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 436
            self.connectionId()
            self.state = 437
            self.match(MalloyParser.DOT)
            self.state = 438
            self.match(MalloyParser.SQL)
            self.state = 439
            self.match(MalloyParser.OPAREN)
            self.state = 442
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [169]:
                self.state = 440
                self.sqlString()
                pass
            elif token in [117, 118]:
                self.state = 441
                self.shortString()
                pass
            else:
                raise NoViableAltException(self)

            self.state = 444
            self.match(MalloyParser.CPAREN)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class ExploreTableContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def connectionId(self):
            return self.getTypedRuleContext(MalloyParser.ConnectionIdContext,0)


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

        def TABLE(self):
            return self.getToken(MalloyParser.TABLE, 0)

        def OPAREN(self):
            return self.getToken(MalloyParser.OPAREN, 0)

        def tablePath(self):
            return self.getTypedRuleContext(MalloyParser.TablePathContext,0)


        def CPAREN(self):
            return self.getToken(MalloyParser.CPAREN, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_exploreTable

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

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

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




    def exploreTable(self):

        localctx = MalloyParser.ExploreTableContext(self, self._ctx, self.state)
        self.enterRule(localctx, 44, self.RULE_exploreTable)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 446
            self.connectionId()
            self.state = 447
            self.match(MalloyParser.DOT)
            self.state = 448
            self.match(MalloyParser.TABLE)
            self.state = 449
            self.match(MalloyParser.OPAREN)
            self.state = 450
            self.tablePath()
            self.state = 451
            self.match(MalloyParser.CPAREN)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class ConnectionIdContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def id_(self):
            return self.getTypedRuleContext(MalloyParser.IdContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_connectionId

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

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

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




    def connectionId(self):

        localctx = MalloyParser.ConnectionIdContext(self, self._ctx, self.state)
        self.enterRule(localctx, 46, self.RULE_connectionId)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 453
            self.id_()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class QueryPropertiesContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def OCURLY(self):
            return self.getToken(MalloyParser.OCURLY, 0)

        def CCURLY(self):
            return self.getToken(MalloyParser.CCURLY, 0)

        def queryStatement(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.QueryStatementContext)
            else:
                return self.getTypedRuleContext(MalloyParser.QueryStatementContext,i)


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

        def getRuleIndex(self):
            return MalloyParser.RULE_queryProperties

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

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

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




    def queryProperties(self):

        localctx = MalloyParser.QueryPropertiesContext(self, self._ctx, self.state)
        self.enterRule(localctx, 48, self.RULE_queryProperties)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 455
            self.match(MalloyParser.OCURLY)
            self.state = 460
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while (((_la) & ~0x3f) == 0 and ((1 << _la) & 195428314444) != 0) or ((((_la - 70)) & ~0x3f) == 0 and ((1 << (_la - 70)) & 3377699720724481) != 0) or _la==149:
                self.state = 458
                self._errHandler.sync(self)
                token = self._input.LA(1)
                if token in [2, 3, 6, 8, 10, 11, 13, 14, 16, 17, 18, 19, 21, 22, 31, 32, 34, 35, 37, 70, 86, 87, 120, 121]:
                    self.state = 456
                    self.queryStatement()
                    pass
                elif token in [149]:
                    self.state = 457
                    self.match(MalloyParser.SEMI)
                    pass
                else:
                    raise NoViableAltException(self)

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

            self.state = 463
            self.match(MalloyParser.CCURLY)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class QueryNameContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def id_(self):
            return self.getTypedRuleContext(MalloyParser.IdContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_queryName

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

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

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




    def queryName(self):

        localctx = MalloyParser.QueryNameContext(self, self._ctx, self.state)
        self.enterRule(localctx, 50, self.RULE_queryName)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 465
            self.id_()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class SourcePropertyListContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def sourceDefinition(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.SourceDefinitionContext)
            else:
                return self.getTypedRuleContext(MalloyParser.SourceDefinitionContext,i)


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

        def getRuleIndex(self):
            return MalloyParser.RULE_sourcePropertyList

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

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

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




    def sourcePropertyList(self):

        localctx = MalloyParser.SourcePropertyListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 52, self.RULE_sourcePropertyList)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 467
            self.sourceDefinition()
            self.state = 474
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,18,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 469
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)
                    if _la==135:
                        self.state = 468
                        self.match(MalloyParser.COMMA)


                    self.state = 471
                    self.sourceDefinition() 
                self.state = 476
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,18,self._ctx)

            self.state = 478
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==135:
                self.state = 477
                self.match(MalloyParser.COMMA)


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


    class SourceDefinitionContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def tags(self):
            return self.getTypedRuleContext(MalloyParser.TagsContext,0)


        def sourceNameDef(self):
            return self.getTypedRuleContext(MalloyParser.SourceNameDefContext,0)


        def isDefine(self):
            return self.getTypedRuleContext(MalloyParser.IsDefineContext,0)


        def sqExplore(self):
            return self.getTypedRuleContext(MalloyParser.SqExploreContext,0)


        def sourceParameters(self):
            return self.getTypedRuleContext(MalloyParser.SourceParametersContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_sourceDefinition

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

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

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




    def sourceDefinition(self):

        localctx = MalloyParser.SourceDefinitionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 54, self.RULE_sourceDefinition)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 480
            self.tags()
            self.state = 481
            self.sourceNameDef()
            self.state = 483
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==125:
                self.state = 482
                self.sourceParameters()


            self.state = 485
            self.isDefine()
            self.state = 486
            self.sqExplore()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class SqExploreContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def sqExpr(self):
            return self.getTypedRuleContext(MalloyParser.SqExprContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_sqExplore

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

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

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




    def sqExplore(self):

        localctx = MalloyParser.SqExploreContext(self, self._ctx, self.state)
        self.enterRule(localctx, 56, self.RULE_sqExplore)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 488
            self.sqExpr(0)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class SourceParametersContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def OPAREN(self):
            return self.getToken(MalloyParser.OPAREN, 0)

        def CPAREN(self):
            return self.getToken(MalloyParser.CPAREN, 0)

        def sourceParameter(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.SourceParameterContext)
            else:
                return self.getTypedRuleContext(MalloyParser.SourceParameterContext,i)


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

        def getRuleIndex(self):
            return MalloyParser.RULE_sourceParameters

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

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

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




    def sourceParameters(self):

        localctx = MalloyParser.SourceParametersContext(self, self._ctx, self.state)
        self.enterRule(localctx, 58, self.RULE_sourceParameters)
        self._la = 0 # Token type
        try:
            self.state = 503
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,22,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 490
                self.match(MalloyParser.OPAREN)
                self.state = 491
                self.match(MalloyParser.CPAREN)
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 492
                self.match(MalloyParser.OPAREN)
                self.state = 493
                self.sourceParameter()
                self.state = 498
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while _la==135:
                    self.state = 494
                    self.match(MalloyParser.COMMA)
                    self.state = 495
                    self.sourceParameter()
                    self.state = 500
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)

                self.state = 501
                self.match(MalloyParser.CPAREN)
                pass


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


    class LegalParamTypeContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def malloyType(self):
            return self.getTypedRuleContext(MalloyParser.MalloyTypeContext,0)


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

        def LT(self):
            return self.getToken(MalloyParser.LT, 0)

        def GT(self):
            return self.getToken(MalloyParser.GT, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_legalParamType

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

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

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




    def legalParamType(self):

        localctx = MalloyParser.LegalParamTypeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 60, self.RULE_legalParamType)
        try:
            self.state = 511
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [43, 50, 82, 91, 98, 99]:
                self.enterOuterAlt(localctx, 1)
                self.state = 505
                self.malloyType()
                pass
            elif token in [59]:
                self.enterOuterAlt(localctx, 2)
                self.state = 506
                self.match(MalloyParser.FILTER)
                self.state = 507
                self.match(MalloyParser.LT)
                self.state = 508
                self.malloyType()
                self.state = 509
                self.match(MalloyParser.GT)
                pass
            else:
                raise NoViableAltException(self)

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


    class SourceParameterContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def parameterNameDef(self):
            return self.getTypedRuleContext(MalloyParser.ParameterNameDefContext,0)


        def DOUBLECOLON(self):
            return self.getToken(MalloyParser.DOUBLECOLON, 0)

        def legalParamType(self):
            return self.getTypedRuleContext(MalloyParser.LegalParamTypeContext,0)


        def IS(self):
            return self.getToken(MalloyParser.IS, 0)

        def fieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.FieldExprContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_sourceParameter

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

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

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




    def sourceParameter(self):

        localctx = MalloyParser.SourceParameterContext(self, self._ctx, self.state)
        self.enterRule(localctx, 62, self.RULE_sourceParameter)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 513
            self.parameterNameDef()
            self.state = 516
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==131:
                self.state = 514
                self.match(MalloyParser.DOUBLECOLON)
                self.state = 515
                self.legalParamType()


            self.state = 520
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==68:
                self.state = 518
                self.match(MalloyParser.IS)
                self.state = 519
                self.fieldExpr(0)


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


    class ParameterNameDefContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def id_(self):
            return self.getTypedRuleContext(MalloyParser.IdContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_parameterNameDef

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

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

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




    def parameterNameDef(self):

        localctx = MalloyParser.ParameterNameDefContext(self, self._ctx, self.state)
        self.enterRule(localctx, 64, self.RULE_parameterNameDef)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 522
            self.id_()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class SourceNameDefContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def id_(self):
            return self.getTypedRuleContext(MalloyParser.IdContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_sourceNameDef

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

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

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




    def sourceNameDef(self):

        localctx = MalloyParser.SourceNameDefContext(self, self._ctx, self.state)
        self.enterRule(localctx, 66, self.RULE_sourceNameDef)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 524
            self.id_()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class ExplorePropertiesContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def OCURLY(self):
            return self.getToken(MalloyParser.OCURLY, 0)

        def CCURLY(self):
            return self.getToken(MalloyParser.CCURLY, 0)

        def exploreStatement(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.ExploreStatementContext)
            else:
                return self.getTypedRuleContext(MalloyParser.ExploreStatementContext,i)


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

        def getRuleIndex(self):
            return MalloyParser.RULE_exploreProperties

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

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

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




    def exploreProperties(self):

        localctx = MalloyParser.ExplorePropertiesContext(self, self._ctx, self.state)
        self.enterRule(localctx, 68, self.RULE_exploreProperties)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 526
            self.match(MalloyParser.OCURLY)
            self.state = 531
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while (((_la) & ~0x3f) == 0 and ((1 << _la) & 241073324674) != 0) or ((((_la - 70)) & ~0x3f) == 0 and ((1 << (_la - 70)) & 3377699720724481) != 0) or _la==149:
                self.state = 529
                self._errHandler.sync(self)
                token = self._input.LA(1)
                if token in [1, 7, 9, 16, 17, 18, 20, 24, 29, 35, 36, 37, 70, 86, 87, 120, 121]:
                    self.state = 527
                    self.exploreStatement()
                    pass
                elif token in [149]:
                    self.state = 528
                    self.match(MalloyParser.SEMI)
                    pass
                else:
                    raise NoViableAltException(self)

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

            self.state = 534
            self.match(MalloyParser.CCURLY)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class ExploreStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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


        def getRuleIndex(self):
            return MalloyParser.RULE_exploreStatement

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



    class DefExploreDimension_stubContext(ExploreStatementContext):

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

        def defDimensions(self):
            return self.getTypedRuleContext(MalloyParser.DefDimensionsContext,0)


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

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

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


    class DefExploreTimezoneContext(ExploreStatementContext):

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

        def timezoneStatement(self):
            return self.getTypedRuleContext(MalloyParser.TimezoneStatementContext,0)


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

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

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


    class DefExploreQueryContext(ExploreStatementContext):

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

        def tags(self):
            return self.getTypedRuleContext(MalloyParser.TagsContext,0)

        def VIEW(self):
            return self.getToken(MalloyParser.VIEW, 0)
        def subQueryDefList(self):
            return self.getTypedRuleContext(MalloyParser.SubQueryDefListContext,0)

        def accessLabel(self):
            return self.getTypedRuleContext(MalloyParser.AccessLabelContext,0)


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

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

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


    class DefExplorePrimaryKeyContext(ExploreStatementContext):

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

        def PRIMARY_KEY(self):
            return self.getToken(MalloyParser.PRIMARY_KEY, 0)
        def fieldName(self):
            return self.getTypedRuleContext(MalloyParser.FieldNameContext,0)


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

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

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


    class DefExploreMeasure_stubContext(ExploreStatementContext):

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

        def defMeasures(self):
            return self.getTypedRuleContext(MalloyParser.DefMeasuresContext,0)


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

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

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


    class DefExploreWhere_stubContext(ExploreStatementContext):

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

        def whereStatement(self):
            return self.getTypedRuleContext(MalloyParser.WhereStatementContext,0)


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

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

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


    class DefIgnoreModel_stubContext(ExploreStatementContext):

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

        def ignoredModelAnnotations(self):
            return self.getTypedRuleContext(MalloyParser.IgnoredModelAnnotationsContext,0)


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

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

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


    class DefExploreRenameContext(ExploreStatementContext):

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

        def tags(self):
            return self.getTypedRuleContext(MalloyParser.TagsContext,0)

        def RENAME(self):
            return self.getToken(MalloyParser.RENAME, 0)
        def renameList(self):
            return self.getTypedRuleContext(MalloyParser.RenameListContext,0)

        def accessLabel(self):
            return self.getTypedRuleContext(MalloyParser.AccessLabelContext,0)


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

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

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


    class DefExploreEditFieldContext(ExploreStatementContext):

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

        def fieldNameList(self):
            return self.getTypedRuleContext(MalloyParser.FieldNameListContext,0)

        def ACCEPT(self):
            return self.getToken(MalloyParser.ACCEPT, 0)
        def EXCEPT(self):
            return self.getToken(MalloyParser.EXCEPT, 0)

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

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

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


    class DefExploreAnnotationContext(ExploreStatementContext):

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

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

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

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

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


    class DefJoin_stubContext(ExploreStatementContext):

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

        def joinStatement(self):
            return self.getTypedRuleContext(MalloyParser.JoinStatementContext,0)


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

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

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



    def exploreStatement(self):

        localctx = MalloyParser.ExploreStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 70, self.RULE_exploreStatement)
        self._la = 0 # Token type
        try:
            self.state = 565
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,31,self._ctx)
            if la_ == 1:
                localctx = MalloyParser.DefExploreDimension_stubContext(self, localctx)
                self.enterOuterAlt(localctx, 1)
                self.state = 536
                self.defDimensions()
                pass

            elif la_ == 2:
                localctx = MalloyParser.DefExploreMeasure_stubContext(self, localctx)
                self.enterOuterAlt(localctx, 2)
                self.state = 537
                self.defMeasures()
                pass

            elif la_ == 3:
                localctx = MalloyParser.DefJoin_stubContext(self, localctx)
                self.enterOuterAlt(localctx, 3)
                self.state = 538
                self.joinStatement()
                pass

            elif la_ == 4:
                localctx = MalloyParser.DefExploreWhere_stubContext(self, localctx)
                self.enterOuterAlt(localctx, 4)
                self.state = 539
                self.whereStatement()
                pass

            elif la_ == 5:
                localctx = MalloyParser.DefExplorePrimaryKeyContext(self, localctx)
                self.enterOuterAlt(localctx, 5)
                self.state = 540
                self.match(MalloyParser.PRIMARY_KEY)
                self.state = 541
                self.fieldName()
                pass

            elif la_ == 6:
                localctx = MalloyParser.DefExploreRenameContext(self, localctx)
                self.enterOuterAlt(localctx, 6)
                self.state = 542
                self.tags()
                self.state = 544
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if ((((_la - 70)) & ~0x3f) == 0 and ((1 << (_la - 70)) & 196609) != 0):
                    self.state = 543
                    self.accessLabel()


                self.state = 546
                self.match(MalloyParser.RENAME)
                self.state = 547
                self.renameList()
                pass

            elif la_ == 7:
                localctx = MalloyParser.DefExploreEditFieldContext(self, localctx)
                self.enterOuterAlt(localctx, 7)
                self.state = 549
                _la = self._input.LA(1)
                if not(_la==1 or _la==9):
                    self._errHandler.recoverInline(self)
                else:
                    self._errHandler.reportMatch(self)
                    self.consume()
                self.state = 550
                self.fieldNameList()
                pass

            elif la_ == 8:
                localctx = MalloyParser.DefExploreQueryContext(self, localctx)
                self.enterOuterAlt(localctx, 8)
                self.state = 551
                self.tags()
                self.state = 553
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if ((((_la - 70)) & ~0x3f) == 0 and ((1 << (_la - 70)) & 196609) != 0):
                    self.state = 552
                    self.accessLabel()


                self.state = 555
                self.match(MalloyParser.VIEW)
                self.state = 556
                self.subQueryDefList()
                pass

            elif la_ == 9:
                localctx = MalloyParser.DefExploreTimezoneContext(self, localctx)
                self.enterOuterAlt(localctx, 9)
                self.state = 558
                self.timezoneStatement()
                pass

            elif la_ == 10:
                localctx = MalloyParser.DefExploreAnnotationContext(self, localctx)
                self.enterOuterAlt(localctx, 10)
                self.state = 560 
                self._errHandler.sync(self)
                _alt = 1
                while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                    if _alt == 1:
                        self.state = 559
                        self.match(MalloyParser.ANNOTATION)

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

                pass

            elif la_ == 11:
                localctx = MalloyParser.DefIgnoreModel_stubContext(self, localctx)
                self.enterOuterAlt(localctx, 11)
                self.state = 564
                self.ignoredModelAnnotations()
                pass


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


    class AccessLabelContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def PUBLIC_KW(self):
            return self.getToken(MalloyParser.PUBLIC_KW, 0)

        def PRIVATE_KW(self):
            return self.getToken(MalloyParser.PRIVATE_KW, 0)

        def INTERNAL_KW(self):
            return self.getToken(MalloyParser.INTERNAL_KW, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_accessLabel

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

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

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




    def accessLabel(self):

        localctx = MalloyParser.AccessLabelContext(self, self._ctx, self.state)
        self.enterRule(localctx, 72, self.RULE_accessLabel)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 567
            _la = self._input.LA(1)
            if not(((((_la - 70)) & ~0x3f) == 0 and ((1 << (_la - 70)) & 196609) != 0)):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class AccessModifierListContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def fieldNameList(self):
            return self.getTypedRuleContext(MalloyParser.FieldNameListContext,0)


        def STAR(self):
            return self.getToken(MalloyParser.STAR, 0)

        def starQualified(self):
            return self.getTypedRuleContext(MalloyParser.StarQualifiedContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_accessModifierList

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

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

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




    def accessModifierList(self):

        localctx = MalloyParser.AccessModifierListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 74, self.RULE_accessModifierList)
        self._la = 0 # Token type
        try:
            self.state = 574
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [119, 162]:
                self.enterOuterAlt(localctx, 1)
                self.state = 569
                self.fieldNameList()
                pass
            elif token in [145]:
                self.enterOuterAlt(localctx, 2)
                self.state = 570
                self.match(MalloyParser.STAR)
                self.state = 572
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==129:
                    self.state = 571
                    self.starQualified()


                pass
            else:
                raise NoViableAltException(self)

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


    class DefMeasuresContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def tags(self):
            return self.getTypedRuleContext(MalloyParser.TagsContext,0)


        def MEASURE(self):
            return self.getToken(MalloyParser.MEASURE, 0)

        def defList(self):
            return self.getTypedRuleContext(MalloyParser.DefListContext,0)


        def accessLabel(self):
            return self.getTypedRuleContext(MalloyParser.AccessLabelContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_defMeasures

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

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

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




    def defMeasures(self):

        localctx = MalloyParser.DefMeasuresContext(self, self._ctx, self.state)
        self.enterRule(localctx, 76, self.RULE_defMeasures)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 576
            self.tags()
            self.state = 578
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if ((((_la - 70)) & ~0x3f) == 0 and ((1 << (_la - 70)) & 196609) != 0):
                self.state = 577
                self.accessLabel()


            self.state = 580
            self.match(MalloyParser.MEASURE)
            self.state = 581
            self.defList()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class DefDimensionsContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def tags(self):
            return self.getTypedRuleContext(MalloyParser.TagsContext,0)


        def DIMENSION(self):
            return self.getToken(MalloyParser.DIMENSION, 0)

        def defList(self):
            return self.getTypedRuleContext(MalloyParser.DefListContext,0)


        def accessLabel(self):
            return self.getTypedRuleContext(MalloyParser.AccessLabelContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_defDimensions

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

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

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




    def defDimensions(self):

        localctx = MalloyParser.DefDimensionsContext(self, self._ctx, self.state)
        self.enterRule(localctx, 78, self.RULE_defDimensions)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 583
            self.tags()
            self.state = 585
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if ((((_la - 70)) & ~0x3f) == 0 and ((1 << (_la - 70)) & 196609) != 0):
                self.state = 584
                self.accessLabel()


            self.state = 587
            self.match(MalloyParser.DIMENSION)
            self.state = 588
            self.defList()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class RenameListContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def renameEntry(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.RenameEntryContext)
            else:
                return self.getTypedRuleContext(MalloyParser.RenameEntryContext,i)


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

        def getRuleIndex(self):
            return MalloyParser.RULE_renameList

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

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

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




    def renameList(self):

        localctx = MalloyParser.RenameListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 80, self.RULE_renameList)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 590
            self.renameEntry()
            self.state = 597
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,37,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 592
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)
                    if _la==135:
                        self.state = 591
                        self.match(MalloyParser.COMMA)


                    self.state = 594
                    self.renameEntry() 
                self.state = 599
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,37,self._ctx)

            self.state = 601
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==135:
                self.state = 600
                self.match(MalloyParser.COMMA)


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


    class RenameEntryContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def tags(self):
            return self.getTypedRuleContext(MalloyParser.TagsContext,0)


        def fieldName(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.FieldNameContext)
            else:
                return self.getTypedRuleContext(MalloyParser.FieldNameContext,i)


        def isDefine(self):
            return self.getTypedRuleContext(MalloyParser.IsDefineContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_renameEntry

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

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

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




    def renameEntry(self):

        localctx = MalloyParser.RenameEntryContext(self, self._ctx, self.state)
        self.enterRule(localctx, 82, self.RULE_renameEntry)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 603
            self.tags()
            self.state = 604
            self.fieldName()
            self.state = 605
            self.isDefine()
            self.state = 606
            self.fieldName()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class DefListContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def fieldDef(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.FieldDefContext)
            else:
                return self.getTypedRuleContext(MalloyParser.FieldDefContext,i)


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

        def getRuleIndex(self):
            return MalloyParser.RULE_defList

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

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

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




    def defList(self):

        localctx = MalloyParser.DefListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 84, self.RULE_defList)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 608
            self.fieldDef()
            self.state = 615
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,40,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 610
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)
                    if _la==135:
                        self.state = 609
                        self.match(MalloyParser.COMMA)


                    self.state = 612
                    self.fieldDef() 
                self.state = 617
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,40,self._ctx)

            self.state = 619
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==135:
                self.state = 618
                self.match(MalloyParser.COMMA)


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


    class FieldDefContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def tags(self):
            return self.getTypedRuleContext(MalloyParser.TagsContext,0)


        def fieldNameDef(self):
            return self.getTypedRuleContext(MalloyParser.FieldNameDefContext,0)


        def isDefine(self):
            return self.getTypedRuleContext(MalloyParser.IsDefineContext,0)


        def fieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.FieldExprContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_fieldDef

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

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

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




    def fieldDef(self):

        localctx = MalloyParser.FieldDefContext(self, self._ctx, self.state)
        self.enterRule(localctx, 86, self.RULE_fieldDef)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 621
            self.tags()
            self.state = 622
            self.fieldNameDef()
            self.state = 623
            self.isDefine()
            self.state = 624
            self.fieldExpr(0)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class FieldNameDefContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def id_(self):
            return self.getTypedRuleContext(MalloyParser.IdContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_fieldNameDef

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

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

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




    def fieldNameDef(self):

        localctx = MalloyParser.FieldNameDefContext(self, self._ctx, self.state)
        self.enterRule(localctx, 88, self.RULE_fieldNameDef)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 626
            self.id_()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class JoinNameDefContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def id_(self):
            return self.getTypedRuleContext(MalloyParser.IdContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_joinNameDef

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

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

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




    def joinNameDef(self):

        localctx = MalloyParser.JoinNameDefContext(self, self._ctx, self.state)
        self.enterRule(localctx, 90, self.RULE_joinNameDef)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 628
            self.id_()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class DeclareStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def DECLARE(self):
            return self.getToken(MalloyParser.DECLARE, 0)

        def defList(self):
            return self.getTypedRuleContext(MalloyParser.DefListContext,0)


        def accessLabel(self):
            return self.getTypedRuleContext(MalloyParser.AccessLabelContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_declareStatement

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

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

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




    def declareStatement(self):

        localctx = MalloyParser.DeclareStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 92, self.RULE_declareStatement)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 630
            self.match(MalloyParser.DECLARE)
            self.state = 632
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if ((((_la - 70)) & ~0x3f) == 0 and ((1 << (_la - 70)) & 196609) != 0):
                self.state = 631
                self.accessLabel()


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


    class JoinStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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


        def getRuleIndex(self):
            return MalloyParser.RULE_joinStatement

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



    class DefJoinManyContext(JoinStatementContext):

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

        def tags(self):
            return self.getTypedRuleContext(MalloyParser.TagsContext,0)

        def JOIN_MANY(self):
            return self.getToken(MalloyParser.JOIN_MANY, 0)
        def joinList(self):
            return self.getTypedRuleContext(MalloyParser.JoinListContext,0)

        def accessLabel(self):
            return self.getTypedRuleContext(MalloyParser.AccessLabelContext,0)


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

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

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


    class DefJoinCrossContext(JoinStatementContext):

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

        def tags(self):
            return self.getTypedRuleContext(MalloyParser.TagsContext,0)

        def JOIN_CROSS(self):
            return self.getToken(MalloyParser.JOIN_CROSS, 0)
        def joinList(self):
            return self.getTypedRuleContext(MalloyParser.JoinListContext,0)

        def accessLabel(self):
            return self.getTypedRuleContext(MalloyParser.AccessLabelContext,0)


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

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

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


    class DefJoinOneContext(JoinStatementContext):

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

        def tags(self):
            return self.getTypedRuleContext(MalloyParser.TagsContext,0)

        def JOIN_ONE(self):
            return self.getToken(MalloyParser.JOIN_ONE, 0)
        def joinList(self):
            return self.getTypedRuleContext(MalloyParser.JoinListContext,0)

        def accessLabel(self):
            return self.getTypedRuleContext(MalloyParser.AccessLabelContext,0)


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

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

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



    def joinStatement(self):

        localctx = MalloyParser.JoinStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 94, self.RULE_joinStatement)
        self._la = 0 # Token type
        try:
            self.state = 657
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,46,self._ctx)
            if la_ == 1:
                localctx = MalloyParser.DefJoinOneContext(self, localctx)
                self.enterOuterAlt(localctx, 1)
                self.state = 636
                self.tags()
                self.state = 638
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if ((((_la - 70)) & ~0x3f) == 0 and ((1 << (_la - 70)) & 196609) != 0):
                    self.state = 637
                    self.accessLabel()


                self.state = 640
                self.match(MalloyParser.JOIN_ONE)
                self.state = 641
                self.joinList()
                pass

            elif la_ == 2:
                localctx = MalloyParser.DefJoinManyContext(self, localctx)
                self.enterOuterAlt(localctx, 2)
                self.state = 643
                self.tags()
                self.state = 645
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if ((((_la - 70)) & ~0x3f) == 0 and ((1 << (_la - 70)) & 196609) != 0):
                    self.state = 644
                    self.accessLabel()


                self.state = 647
                self.match(MalloyParser.JOIN_MANY)
                self.state = 648
                self.joinList()
                pass

            elif la_ == 3:
                localctx = MalloyParser.DefJoinCrossContext(self, localctx)
                self.enterOuterAlt(localctx, 3)
                self.state = 650
                self.tags()
                self.state = 652
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if ((((_la - 70)) & ~0x3f) == 0 and ((1 << (_la - 70)) & 196609) != 0):
                    self.state = 651
                    self.accessLabel()


                self.state = 654
                self.match(MalloyParser.JOIN_CROSS)
                self.state = 655
                self.joinList()
                pass


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


    class QueryExtendContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def EXTENDQ(self):
            return self.getToken(MalloyParser.EXTENDQ, 0)

        def queryExtendStatementList(self):
            return self.getTypedRuleContext(MalloyParser.QueryExtendStatementListContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_queryExtend

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

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

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




    def queryExtend(self):

        localctx = MalloyParser.QueryExtendContext(self, self._ctx, self.state)
        self.enterRule(localctx, 96, self.RULE_queryExtend)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 659
            self.match(MalloyParser.EXTENDQ)
            self.state = 660
            self.queryExtendStatementList()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class ModEitherContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def joinStatement(self):
            return self.getTypedRuleContext(MalloyParser.JoinStatementContext,0)


        def whereStatement(self):
            return self.getTypedRuleContext(MalloyParser.WhereStatementContext,0)


        def declareStatement(self):
            return self.getTypedRuleContext(MalloyParser.DeclareStatementContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_modEither

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

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

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




    def modEither(self):

        localctx = MalloyParser.ModEitherContext(self, self._ctx, self.state)
        self.enterRule(localctx, 98, self.RULE_modEither)
        try:
            self.state = 665
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [16, 17, 18, 70, 86, 87, 121]:
                self.enterOuterAlt(localctx, 1)
                self.state = 662
                self.joinStatement()
                pass
            elif token in [35]:
                self.enterOuterAlt(localctx, 2)
                self.state = 663
                self.whereStatement()
                pass
            elif token in [6]:
                self.enterOuterAlt(localctx, 3)
                self.state = 664
                self.declareStatement()
                pass
            else:
                raise NoViableAltException(self)

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


    class SourceArgumentsContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def OPAREN(self):
            return self.getToken(MalloyParser.OPAREN, 0)

        def CPAREN(self):
            return self.getToken(MalloyParser.CPAREN, 0)

        def sourceArgument(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.SourceArgumentContext)
            else:
                return self.getTypedRuleContext(MalloyParser.SourceArgumentContext,i)


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

        def getRuleIndex(self):
            return MalloyParser.RULE_sourceArguments

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

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

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




    def sourceArguments(self):

        localctx = MalloyParser.SourceArgumentsContext(self, self._ctx, self.state)
        self.enterRule(localctx, 100, self.RULE_sourceArguments)
        self._la = 0 # Token type
        try:
            self.state = 680
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,49,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 667
                self.match(MalloyParser.OPAREN)
                self.state = 668
                self.match(MalloyParser.CPAREN)
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 669
                self.match(MalloyParser.OPAREN)
                self.state = 670
                self.sourceArgument()
                self.state = 675
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while _la==135:
                    self.state = 671
                    self.match(MalloyParser.COMMA)
                    self.state = 672
                    self.sourceArgument()
                    self.state = 677
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)

                self.state = 678
                self.match(MalloyParser.CPAREN)
                pass


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


    class ArgumentIdContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def id_(self):
            return self.getTypedRuleContext(MalloyParser.IdContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_argumentId

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

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

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




    def argumentId(self):

        localctx = MalloyParser.ArgumentIdContext(self, self._ctx, self.state)
        self.enterRule(localctx, 102, self.RULE_argumentId)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 682
            self.id_()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class SourceArgumentContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def fieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.FieldExprContext,0)


        def argumentId(self):
            return self.getTypedRuleContext(MalloyParser.ArgumentIdContext,0)


        def IS(self):
            return self.getToken(MalloyParser.IS, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_sourceArgument

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

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

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




    def sourceArgument(self):

        localctx = MalloyParser.SourceArgumentContext(self, self._ctx, self.state)
        self.enterRule(localctx, 104, self.RULE_sourceArgument)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 687
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,50,self._ctx)
            if la_ == 1:
                self.state = 684
                self.argumentId()
                self.state = 685
                self.match(MalloyParser.IS)


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


    class SqExprContext(ParserRuleContext):
        __slots__ = 'parser'

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


        def getRuleIndex(self):
            return MalloyParser.RULE_sqExpr

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


    class SQRefinedQueryContext(SqExprContext):

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

        def sqExpr(self):
            return self.getTypedRuleContext(MalloyParser.SqExprContext,0)

        def PLUS(self):
            return self.getToken(MalloyParser.PLUS, 0)
        def segExpr(self):
            return self.getTypedRuleContext(MalloyParser.SegExprContext,0)


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

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

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


    class SQSQLContext(SqExprContext):

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

        def sqlSource(self):
            return self.getTypedRuleContext(MalloyParser.SqlSourceContext,0)


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

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

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


    class SQExtendedSourceContext(SqExprContext):

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

        def sqExpr(self):
            return self.getTypedRuleContext(MalloyParser.SqExprContext,0)

        def EXTEND(self):
            return self.getToken(MalloyParser.EXTEND, 0)
        def exploreProperties(self):
            return self.getTypedRuleContext(MalloyParser.ExplorePropertiesContext,0)

        def INCLUDE(self):
            return self.getToken(MalloyParser.INCLUDE, 0)
        def includeBlock(self):
            return self.getTypedRuleContext(MalloyParser.IncludeBlockContext,0)


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

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

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


    class SQComposeContext(SqExprContext):

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

        def COMPOSE(self):
            return self.getToken(MalloyParser.COMPOSE, 0)
        def OPAREN(self):
            return self.getToken(MalloyParser.OPAREN, 0)
        def CPAREN(self):
            return self.getToken(MalloyParser.CPAREN, 0)
        def sqExpr(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.SqExprContext)
            else:
                return self.getTypedRuleContext(MalloyParser.SqExprContext,i)

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

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

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

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


    class SQTableContext(SqExprContext):

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

        def exploreTable(self):
            return self.getTypedRuleContext(MalloyParser.ExploreTableContext,0)


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

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

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


    class SQIncludeContext(SqExprContext):

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

        def sqExpr(self):
            return self.getTypedRuleContext(MalloyParser.SqExprContext,0)

        def INCLUDE(self):
            return self.getToken(MalloyParser.INCLUDE, 0)
        def includeBlock(self):
            return self.getTypedRuleContext(MalloyParser.IncludeBlockContext,0)


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

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

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


    class SQArrowContext(SqExprContext):

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

        def sqExpr(self):
            return self.getTypedRuleContext(MalloyParser.SqExprContext,0)

        def ARROW(self):
            return self.getToken(MalloyParser.ARROW, 0)
        def segExpr(self):
            return self.getTypedRuleContext(MalloyParser.SegExprContext,0)


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

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

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


    class SQParensContext(SqExprContext):

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

        def OPAREN(self):
            return self.getToken(MalloyParser.OPAREN, 0)
        def sqExpr(self):
            return self.getTypedRuleContext(MalloyParser.SqExprContext,0)

        def CPAREN(self):
            return self.getToken(MalloyParser.CPAREN, 0)

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

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

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


    class SQIDContext(SqExprContext):

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

        def id_(self):
            return self.getTypedRuleContext(MalloyParser.IdContext,0)

        def sourceArguments(self):
            return self.getTypedRuleContext(MalloyParser.SourceArgumentsContext,0)


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

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

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



    def sqExpr(self, _p:int=0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = MalloyParser.SqExprContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 106
        self.enterRecursionRule(localctx, 106, self.RULE_sqExpr, _p)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 715
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,54,self._ctx)
            if la_ == 1:
                localctx = MalloyParser.SQIDContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx

                self.state = 692
                self.id_()
                self.state = 694
                self._errHandler.sync(self)
                la_ = self._interp.adaptivePredict(self._input,51,self._ctx)
                if la_ == 1:
                    self.state = 693
                    self.sourceArguments()


                pass

            elif la_ == 2:
                localctx = MalloyParser.SQParensContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 696
                self.match(MalloyParser.OPAREN)
                self.state = 697
                self.sqExpr(0)
                self.state = 698
                self.match(MalloyParser.CPAREN)
                pass

            elif la_ == 3:
                localctx = MalloyParser.SQComposeContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 700
                self.match(MalloyParser.COMPOSE)
                self.state = 701
                self.match(MalloyParser.OPAREN)
                self.state = 710
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==49 or ((((_la - 119)) & ~0x3f) == 0 and ((1 << (_la - 119)) & 8796093022273) != 0):
                    self.state = 702
                    self.sqExpr(0)
                    self.state = 707
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)
                    while _la==135:
                        self.state = 703
                        self.match(MalloyParser.COMMA)
                        self.state = 704
                        self.sqExpr(0)
                        self.state = 709
                        self._errHandler.sync(self)
                        _la = self._input.LA(1)



                self.state = 712
                self.match(MalloyParser.CPAREN)
                pass

            elif la_ == 4:
                localctx = MalloyParser.SQTableContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 713
                self.exploreTable()
                pass

            elif la_ == 5:
                localctx = MalloyParser.SQSQLContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 714
                self.sqlSource()
                pass


            self._ctx.stop = self._input.LT(-1)
            self.state = 735
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,57,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 = 733
                    self._errHandler.sync(self)
                    la_ = self._interp.adaptivePredict(self._input,56,self._ctx)
                    if la_ == 1:
                        localctx = MalloyParser.SQRefinedQueryContext(self, MalloyParser.SqExprContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_sqExpr)
                        self.state = 717
                        if not self.precpred(self._ctx, 6):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 6)")
                        self.state = 718
                        self.match(MalloyParser.PLUS)
                        self.state = 719
                        self.segExpr(0)
                        pass

                    elif la_ == 2:
                        localctx = MalloyParser.SQArrowContext(self, MalloyParser.SqExprContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_sqExpr)
                        self.state = 720
                        if not self.precpred(self._ctx, 5):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 5)")
                        self.state = 721
                        self.match(MalloyParser.ARROW)
                        self.state = 722
                        self.segExpr(0)
                        pass

                    elif la_ == 3:
                        localctx = MalloyParser.SQExtendedSourceContext(self, MalloyParser.SqExprContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_sqExpr)
                        self.state = 723
                        if not self.precpred(self._ctx, 4):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 4)")
                        self.state = 726
                        self._errHandler.sync(self)
                        _la = self._input.LA(1)
                        if _la==66:
                            self.state = 724
                            self.match(MalloyParser.INCLUDE)
                            self.state = 725
                            self.includeBlock()


                        self.state = 728
                        self.match(MalloyParser.EXTEND)
                        self.state = 729
                        self.exploreProperties()
                        pass

                    elif la_ == 4:
                        localctx = MalloyParser.SQIncludeContext(self, MalloyParser.SqExprContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_sqExpr)
                        self.state = 730
                        if not self.precpred(self._ctx, 3):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 3)")
                        self.state = 731
                        self.match(MalloyParser.INCLUDE)
                        self.state = 732
                        self.includeBlock()
                        pass

             
                self.state = 737
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,57,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 IncludeBlockContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def OCURLY(self):
            return self.getToken(MalloyParser.OCURLY, 0)

        def CCURLY(self):
            return self.getToken(MalloyParser.CCURLY, 0)

        def includeItem(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.IncludeItemContext)
            else:
                return self.getTypedRuleContext(MalloyParser.IncludeItemContext,i)


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

        def getRuleIndex(self):
            return MalloyParser.RULE_includeBlock

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

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

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




    def includeBlock(self):

        localctx = MalloyParser.IncludeBlockContext(self, self._ctx, self.state)
        self.enterRule(localctx, 108, self.RULE_includeBlock)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 738
            self.match(MalloyParser.OCURLY)
            self.state = 743
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while (((_la) & ~0x3f) == 0 and ((1 << _la) & 167805440) != 0) or ((((_la - 119)) & ~0x3f) == 0 and ((1 << (_la - 119)) & 8797233872901) != 0):
                self.state = 741
                self._errHandler.sync(self)
                token = self._input.LA(1)
                if token in [9, 15, 25, 27, 119, 121, 145, 162]:
                    self.state = 739
                    self.includeItem()
                    pass
                elif token in [149]:
                    self.state = 740
                    self.match(MalloyParser.SEMI)
                    pass
                else:
                    raise NoViableAltException(self)

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

            self.state = 746
            self.match(MalloyParser.CCURLY)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class IncludeItemContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def tags(self):
            return self.getTypedRuleContext(MalloyParser.TagsContext,0)


        def accessLabelProp(self):
            return self.getTypedRuleContext(MalloyParser.AccessLabelPropContext,0)


        def includeList(self):
            return self.getTypedRuleContext(MalloyParser.IncludeListContext,0)


        def EXCEPT(self):
            return self.getToken(MalloyParser.EXCEPT, 0)

        def includeExceptList(self):
            return self.getTypedRuleContext(MalloyParser.IncludeExceptListContext,0)


        def orphanedAnnotation(self):
            return self.getTypedRuleContext(MalloyParser.OrphanedAnnotationContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_includeItem

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

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

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




    def includeItem(self):

        localctx = MalloyParser.IncludeItemContext(self, self._ctx, self.state)
        self.enterRule(localctx, 110, self.RULE_includeItem)
        try:
            self.state = 758
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,60,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 748
                self.tags()
                self.state = 749
                self.accessLabelProp()
                self.state = 750
                self.includeList()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 752
                self.includeList()
                pass

            elif la_ == 3:
                self.enterOuterAlt(localctx, 3)
                self.state = 753
                self.tags()
                self.state = 754
                self.match(MalloyParser.EXCEPT)
                self.state = 755
                self.includeExceptList()
                pass

            elif la_ == 4:
                self.enterOuterAlt(localctx, 4)
                self.state = 757
                self.orphanedAnnotation()
                pass


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


    class OrphanedAnnotationContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def ANNOTATION(self):
            return self.getToken(MalloyParser.ANNOTATION, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_orphanedAnnotation

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

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

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




    def orphanedAnnotation(self):

        localctx = MalloyParser.OrphanedAnnotationContext(self, self._ctx, self.state)
        self.enterRule(localctx, 112, self.RULE_orphanedAnnotation)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 760
            self.match(MalloyParser.ANNOTATION)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class AccessLabelPropContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def PUBLIC(self):
            return self.getToken(MalloyParser.PUBLIC, 0)

        def PRIVATE(self):
            return self.getToken(MalloyParser.PRIVATE, 0)

        def INTERNAL(self):
            return self.getToken(MalloyParser.INTERNAL, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_accessLabelProp

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

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

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




    def accessLabelProp(self):

        localctx = MalloyParser.AccessLabelPropContext(self, self._ctx, self.state)
        self.enterRule(localctx, 114, self.RULE_accessLabelProp)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 762
            _la = self._input.LA(1)
            if not((((_la) & ~0x3f) == 0 and ((1 << _la) & 167804928) != 0)):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class IncludeExceptListContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def includeExceptListItem(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.IncludeExceptListItemContext)
            else:
                return self.getTypedRuleContext(MalloyParser.IncludeExceptListItemContext,i)


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

        def getRuleIndex(self):
            return MalloyParser.RULE_includeExceptList

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

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

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




    def includeExceptList(self):

        localctx = MalloyParser.IncludeExceptListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 116, self.RULE_includeExceptList)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 764
            self.includeExceptListItem()
            self.state = 771
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,62,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 766
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)
                    if _la==135:
                        self.state = 765
                        self.match(MalloyParser.COMMA)


                    self.state = 768
                    self.includeExceptListItem() 
                self.state = 773
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,62,self._ctx)

            self.state = 775
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==135:
                self.state = 774
                self.match(MalloyParser.COMMA)


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


    class IncludeExceptListItemContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def tags(self):
            return self.getTypedRuleContext(MalloyParser.TagsContext,0)


        def fieldPath(self):
            return self.getTypedRuleContext(MalloyParser.FieldPathContext,0)


        def collectionWildCard(self):
            return self.getTypedRuleContext(MalloyParser.CollectionWildCardContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_includeExceptListItem

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

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

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




    def includeExceptListItem(self):

        localctx = MalloyParser.IncludeExceptListItemContext(self, self._ctx, self.state)
        self.enterRule(localctx, 118, self.RULE_includeExceptListItem)
        try:
            self.state = 783
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,64,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 777
                self.tags()
                self.state = 778
                self.fieldPath()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 780
                self.tags()
                self.state = 781
                self.collectionWildCard()
                pass


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


    class IncludeListContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def includeField(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.IncludeFieldContext)
            else:
                return self.getTypedRuleContext(MalloyParser.IncludeFieldContext,i)


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

        def getRuleIndex(self):
            return MalloyParser.RULE_includeList

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

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

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




    def includeList(self):

        localctx = MalloyParser.IncludeListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 120, self.RULE_includeList)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 785
            self.includeField()
            self.state = 792
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,66,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 787
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)
                    if _la==135:
                        self.state = 786
                        self.match(MalloyParser.COMMA)


                    self.state = 789
                    self.includeField() 
                self.state = 794
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,66,self._ctx)

            self.state = 796
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==135:
                self.state = 795
                self.match(MalloyParser.COMMA)


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


    class IncludeFieldContext(ParserRuleContext):
        __slots__ = 'parser'

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser
            self.as_ = None # FieldNameContext
            self.name = None # FieldPathContext

        def tags(self):
            return self.getTypedRuleContext(MalloyParser.TagsContext,0)


        def fieldPath(self):
            return self.getTypedRuleContext(MalloyParser.FieldPathContext,0)


        def isDefine(self):
            return self.getTypedRuleContext(MalloyParser.IsDefineContext,0)


        def fieldName(self):
            return self.getTypedRuleContext(MalloyParser.FieldNameContext,0)


        def collectionWildCard(self):
            return self.getTypedRuleContext(MalloyParser.CollectionWildCardContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_includeField

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

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

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




    def includeField(self):

        localctx = MalloyParser.IncludeFieldContext(self, self._ctx, self.state)
        self.enterRule(localctx, 122, self.RULE_includeField)
        try:
            self.state = 812
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,69,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 798
                self.tags()
                self.state = 802
                self._errHandler.sync(self)
                la_ = self._interp.adaptivePredict(self._input,68,self._ctx)
                if la_ == 1:
                    self.state = 799
                    localctx.as_ = self.fieldName()
                    self.state = 800
                    self.isDefine()


                self.state = 804
                localctx.name = self.fieldPath()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 806
                self.tags()
                self.state = 807
                localctx.name = self.fieldPath()
                pass

            elif la_ == 3:
                self.enterOuterAlt(localctx, 3)
                self.state = 809
                self.tags()
                self.state = 810
                self.collectionWildCard()
                pass


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


    class SegExprContext(ParserRuleContext):
        __slots__ = 'parser'

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


        def getRuleIndex(self):
            return MalloyParser.RULE_segExpr

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


    class SegFieldContext(SegExprContext):

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

        def fieldPath(self):
            return self.getTypedRuleContext(MalloyParser.FieldPathContext,0)


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

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

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


    class SegRefineContext(SegExprContext):

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

        def PLUS(self):
            return self.getToken(MalloyParser.PLUS, 0)
        def segExpr(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.SegExprContext)
            else:
                return self.getTypedRuleContext(MalloyParser.SegExprContext,i)


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

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

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


    class SegParenContext(SegExprContext):

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

        def OPAREN(self):
            return self.getToken(MalloyParser.OPAREN, 0)
        def vExpr(self):
            return self.getTypedRuleContext(MalloyParser.VExprContext,0)

        def CPAREN(self):
            return self.getToken(MalloyParser.CPAREN, 0)

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

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

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


    class SegOpsContext(SegExprContext):

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

        def queryProperties(self):
            return self.getTypedRuleContext(MalloyParser.QueryPropertiesContext,0)


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

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

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



    def segExpr(self, _p:int=0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = MalloyParser.SegExprContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 124
        self.enterRecursionRule(localctx, 124, self.RULE_segExpr, _p)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 821
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [119, 162]:
                localctx = MalloyParser.SegFieldContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx

                self.state = 815
                self.fieldPath()
                pass
            elif token in [129]:
                localctx = MalloyParser.SegOpsContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 816
                self.queryProperties()
                pass
            elif token in [125]:
                localctx = MalloyParser.SegParenContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 817
                self.match(MalloyParser.OPAREN)
                self.state = 818
                self.vExpr()
                self.state = 819
                self.match(MalloyParser.CPAREN)
                pass
            else:
                raise NoViableAltException(self)

            self._ctx.stop = self._input.LT(-1)
            self.state = 828
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,71,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    if self._parseListeners is not None:
                        self.triggerExitRuleEvent()
                    _prevctx = localctx
                    localctx = MalloyParser.SegRefineContext(self, MalloyParser.SegExprContext(self, _parentctx, _parentState))
                    localctx.lhs = _prevctx
                    self.pushNewRecursionContext(localctx, _startState, self.RULE_segExpr)
                    self.state = 823
                    if not self.precpred(self._ctx, 1):
                        from antlr4.error.Errors import FailedPredicateException
                        raise FailedPredicateException(self, "self.precpred(self._ctx, 1)")
                    self.state = 824
                    self.match(MalloyParser.PLUS)
                    self.state = 825
                    localctx.rhs = self.segExpr(2) 
                self.state = 830
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,71,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 VExprContext(ParserRuleContext):
        __slots__ = 'parser'

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


        def getRuleIndex(self):
            return MalloyParser.RULE_vExpr

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



    class VSegContext(VExprContext):

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

        def segExpr(self):
            return self.getTypedRuleContext(MalloyParser.SegExprContext,0)


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

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

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


    class VArrowContext(VExprContext):

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

        def ARROW(self):
            return self.getToken(MalloyParser.ARROW, 0)
        def segExpr(self):
            return self.getTypedRuleContext(MalloyParser.SegExprContext,0)

        def vExpr(self):
            return self.getTypedRuleContext(MalloyParser.VExprContext,0)


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

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

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



    def vExpr(self):

        localctx = MalloyParser.VExprContext(self, self._ctx, self.state)
        self.enterRule(localctx, 126, self.RULE_vExpr)
        try:
            self.state = 836
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,72,self._ctx)
            if la_ == 1:
                localctx = MalloyParser.VSegContext(self, localctx)
                self.enterOuterAlt(localctx, 1)
                self.state = 831
                self.segExpr(0)
                pass

            elif la_ == 2:
                localctx = MalloyParser.VArrowContext(self, localctx)
                self.enterOuterAlt(localctx, 2)
                self.state = 832
                localctx.lhs = self.segExpr(0)
                self.state = 833
                self.match(MalloyParser.ARROW)
                self.state = 834
                localctx.rhs = self.vExpr()
                pass


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


    class QueryExtendStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def defDimensions(self):
            return self.getTypedRuleContext(MalloyParser.DefDimensionsContext,0)


        def defMeasures(self):
            return self.getTypedRuleContext(MalloyParser.DefMeasuresContext,0)


        def joinStatement(self):
            return self.getTypedRuleContext(MalloyParser.JoinStatementContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_queryExtendStatement

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

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

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




    def queryExtendStatement(self):

        localctx = MalloyParser.QueryExtendStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 128, self.RULE_queryExtendStatement)
        try:
            self.state = 841
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,73,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 838
                self.defDimensions()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 839
                self.defMeasures()
                pass

            elif la_ == 3:
                self.enterOuterAlt(localctx, 3)
                self.state = 840
                self.joinStatement()
                pass


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


    class QueryExtendStatementListContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def OCURLY(self):
            return self.getToken(MalloyParser.OCURLY, 0)

        def CCURLY(self):
            return self.getToken(MalloyParser.CCURLY, 0)

        def queryExtendStatement(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.QueryExtendStatementContext)
            else:
                return self.getTypedRuleContext(MalloyParser.QueryExtendStatementContext,i)


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

        def getRuleIndex(self):
            return MalloyParser.RULE_queryExtendStatementList

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

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

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




    def queryExtendStatementList(self):

        localctx = MalloyParser.QueryExtendStatementListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 130, self.RULE_queryExtendStatementList)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 843
            self.match(MalloyParser.OCURLY)
            self.state = 848
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while ((((_la - 7)) & ~0x3f) == 0 and ((1 << (_la - 7)) & -9223372036854764031) != 0) or ((((_la - 86)) & ~0x3f) == 0 and ((1 << (_la - 86)) & -9223372002495037437) != 0):
                self.state = 846
                self._errHandler.sync(self)
                token = self._input.LA(1)
                if token in [7, 16, 17, 18, 20, 70, 86, 87, 121]:
                    self.state = 844
                    self.queryExtendStatement()
                    pass
                elif token in [149]:
                    self.state = 845
                    self.match(MalloyParser.SEMI)
                    pass
                else:
                    raise NoViableAltException(self)

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

            self.state = 851
            self.match(MalloyParser.CCURLY)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class JoinListContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def joinDef(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.JoinDefContext)
            else:
                return self.getTypedRuleContext(MalloyParser.JoinDefContext,i)


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

        def getRuleIndex(self):
            return MalloyParser.RULE_joinList

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

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

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




    def joinList(self):

        localctx = MalloyParser.JoinListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 132, self.RULE_joinList)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 853
            self.joinDef()
            self.state = 860
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,77,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 855
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)
                    if _la==135:
                        self.state = 854
                        self.match(MalloyParser.COMMA)


                    self.state = 857
                    self.joinDef() 
                self.state = 862
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,77,self._ctx)

            self.state = 864
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==135:
                self.state = 863
                self.match(MalloyParser.COMMA)


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


    class IsExploreContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def IS(self):
            return self.getToken(MalloyParser.IS, 0)

        def sqExpr(self):
            return self.getTypedRuleContext(MalloyParser.SqExprContext,0)


        def tags(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.TagsContext)
            else:
                return self.getTypedRuleContext(MalloyParser.TagsContext,i)


        def getRuleIndex(self):
            return MalloyParser.RULE_isExplore

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

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

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




    def isExplore(self):

        localctx = MalloyParser.IsExploreContext(self, self._ctx, self.state)
        self.enterRule(localctx, 134, self.RULE_isExplore)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 866
            localctx.before_is = self.tags()
            self.state = 867
            self.match(MalloyParser.IS)
            self.state = 868
            localctx.after_is = self.tags()
            self.state = 869
            self.sqExpr(0)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class MatrixOperationContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def LEFT(self):
            return self.getToken(MalloyParser.LEFT, 0)

        def RIGHT(self):
            return self.getToken(MalloyParser.RIGHT, 0)

        def FULL(self):
            return self.getToken(MalloyParser.FULL, 0)

        def INNER(self):
            return self.getToken(MalloyParser.INNER, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_matrixOperation

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

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

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




    def matrixOperation(self):

        localctx = MalloyParser.MatrixOperationContext(self, self._ctx, self.state)
        self.enterRule(localctx, 136, self.RULE_matrixOperation)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 871
            _la = self._input.LA(1)
            if not(((((_la - 60)) & ~0x3f) == 0 and ((1 << (_la - 60)) & 536879233) != 0)):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class JoinFromContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def joinNameDef(self):
            return self.getTypedRuleContext(MalloyParser.JoinNameDefContext,0)


        def sourceArguments(self):
            return self.getTypedRuleContext(MalloyParser.SourceArgumentsContext,0)


        def isExplore(self):
            return self.getTypedRuleContext(MalloyParser.IsExploreContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_joinFrom

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

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

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




    def joinFrom(self):

        localctx = MalloyParser.JoinFromContext(self, self._ctx, self.state)
        self.enterRule(localctx, 138, self.RULE_joinFrom)
        try:
            self.state = 880
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,79,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 873
                self.joinNameDef()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 874
                self.joinNameDef()
                self.state = 875
                self.sourceArguments()
                pass

            elif la_ == 3:
                self.enterOuterAlt(localctx, 3)
                self.state = 877
                self.joinNameDef()
                self.state = 878
                self.isExplore()
                pass


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


    class JoinDefContext(ParserRuleContext):
        __slots__ = 'parser'

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


        def getRuleIndex(self):
            return MalloyParser.RULE_joinDef

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



    class JoinWithContext(JoinDefContext):

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

        def joinFrom(self):
            return self.getTypedRuleContext(MalloyParser.JoinFromContext,0)

        def WITH(self):
            return self.getToken(MalloyParser.WITH, 0)
        def fieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.FieldExprContext,0)

        def ANNOTATION(self, i:int=None):
            if i is None:
                return self.getTokens(MalloyParser.ANNOTATION)
            else:
                return self.getToken(MalloyParser.ANNOTATION, i)
        def matrixOperation(self):
            return self.getTypedRuleContext(MalloyParser.MatrixOperationContext,0)


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

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

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


    class JoinOnContext(JoinDefContext):

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

        def joinFrom(self):
            return self.getTypedRuleContext(MalloyParser.JoinFromContext,0)

        def ANNOTATION(self, i:int=None):
            if i is None:
                return self.getTokens(MalloyParser.ANNOTATION)
            else:
                return self.getToken(MalloyParser.ANNOTATION, i)
        def ON(self):
            return self.getToken(MalloyParser.ON, 0)
        def joinExpression(self):
            return self.getTypedRuleContext(MalloyParser.JoinExpressionContext,0)

        def matrixOperation(self):
            return self.getTypedRuleContext(MalloyParser.MatrixOperationContext,0)


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

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

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



    def joinDef(self):

        localctx = MalloyParser.JoinDefContext(self, self._ctx, self.state)
        self.enterRule(localctx, 140, self.RULE_joinDef)
        self._la = 0 # Token type
        try:
            self.state = 909
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,85,self._ctx)
            if la_ == 1:
                localctx = MalloyParser.JoinWithContext(self, localctx)
                self.enterOuterAlt(localctx, 1)
                self.state = 885
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while _la==121:
                    self.state = 882
                    self.match(MalloyParser.ANNOTATION)
                    self.state = 887
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)

                self.state = 888
                self.joinFrom()
                self.state = 890
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if ((((_la - 60)) & ~0x3f) == 0 and ((1 << (_la - 60)) & 536879233) != 0):
                    self.state = 889
                    self.matrixOperation()


                self.state = 892
                self.match(MalloyParser.WITH)
                self.state = 893
                self.fieldExpr(0)
                pass

            elif la_ == 2:
                localctx = MalloyParser.JoinOnContext(self, localctx)
                self.enterOuterAlt(localctx, 2)
                self.state = 898
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while _la==121:
                    self.state = 895
                    self.match(MalloyParser.ANNOTATION)
                    self.state = 900
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)

                self.state = 901
                self.joinFrom()
                self.state = 907
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if ((((_la - 60)) & ~0x3f) == 0 and ((1 << (_la - 60)) & 545267841) != 0):
                    self.state = 903
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)
                    if ((((_la - 60)) & ~0x3f) == 0 and ((1 << (_la - 60)) & 536879233) != 0):
                        self.state = 902
                        self.matrixOperation()


                    self.state = 905
                    self.match(MalloyParser.ON)
                    self.state = 906
                    self.joinExpression()


                pass


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


    class JoinExpressionContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def fieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.FieldExprContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_joinExpression

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

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

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




    def joinExpression(self):

        localctx = MalloyParser.JoinExpressionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 142, self.RULE_joinExpression)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 911
            self.fieldExpr(0)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class FilterStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def whereStatement(self):
            return self.getTypedRuleContext(MalloyParser.WhereStatementContext,0)


        def havingStatement(self):
            return self.getTypedRuleContext(MalloyParser.HavingStatementContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_filterStatement

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

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

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




    def filterStatement(self):

        localctx = MalloyParser.FilterStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 144, self.RULE_filterStatement)
        try:
            self.state = 915
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [35]:
                self.enterOuterAlt(localctx, 1)
                self.state = 913
                self.whereStatement()
                pass
            elif token in [13]:
                self.enterOuterAlt(localctx, 2)
                self.state = 914
                self.havingStatement()
                pass
            else:
                raise NoViableAltException(self)

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


    class FieldPropertiesContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def OCURLY(self):
            return self.getToken(MalloyParser.OCURLY, 0)

        def CCURLY(self):
            return self.getToken(MalloyParser.CCURLY, 0)

        def fieldPropertyStatement(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.FieldPropertyStatementContext)
            else:
                return self.getTypedRuleContext(MalloyParser.FieldPropertyStatementContext,i)


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

        def getRuleIndex(self):
            return MalloyParser.RULE_fieldProperties

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

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

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




    def fieldProperties(self):

        localctx = MalloyParser.FieldPropertiesContext(self, self._ctx, self.state)
        self.enterRule(localctx, 146, self.RULE_fieldProperties)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 917
            self.match(MalloyParser.OCURLY)
            self.state = 922
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while (((_la) & ~0x3f) == 0 and ((1 << _la) & 34372849664) != 0) or _la==149:
                self.state = 920
                self._errHandler.sync(self)
                token = self._input.LA(1)
                if token in [12, 19, 22, 23, 35]:
                    self.state = 918
                    self.fieldPropertyStatement()
                    pass
                elif token in [149]:
                    self.state = 919
                    self.match(MalloyParser.SEMI)
                    pass
                else:
                    raise NoViableAltException(self)

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

            self.state = 925
            self.match(MalloyParser.CCURLY)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class AggregateOrderingContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def aggregateOrderBySpec(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.AggregateOrderBySpecContext)
            else:
                return self.getTypedRuleContext(MalloyParser.AggregateOrderBySpecContext,i)


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

        def getRuleIndex(self):
            return MalloyParser.RULE_aggregateOrdering

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

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

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




    def aggregateOrdering(self):

        localctx = MalloyParser.AggregateOrderingContext(self, self._ctx, self.state)
        self.enterRule(localctx, 148, self.RULE_aggregateOrdering)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 927
            self.aggregateOrderBySpec()
            self.state = 932
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,89,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 928
                    self.match(MalloyParser.COMMA)
                    self.state = 929
                    self.aggregateOrderBySpec() 
                self.state = 934
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,89,self._ctx)

            self.state = 936
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==135:
                self.state = 935
                self.match(MalloyParser.COMMA)


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


    class AggregateOrderBySpecContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def fieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.FieldExprContext,0)


        def ASC(self):
            return self.getToken(MalloyParser.ASC, 0)

        def DESC(self):
            return self.getToken(MalloyParser.DESC, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_aggregateOrderBySpec

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

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

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




    def aggregateOrderBySpec(self):

        localctx = MalloyParser.AggregateOrderBySpecContext(self, self._ctx, self.state)
        self.enterRule(localctx, 150, self.RULE_aggregateOrderBySpec)
        self._la = 0 # Token type
        try:
            self.state = 944
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [38, 42, 45, 46, 48, 51, 56, 58, 64, 75, 76, 77, 78, 79, 80, 81, 85, 88, 90, 92, 93, 101, 103, 106, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 125, 127, 129, 144, 155, 156, 157, 158, 159, 160, 161, 162, 164, 165, 169]:
                self.enterOuterAlt(localctx, 1)
                self.state = 938
                self.fieldExpr(0)
                self.state = 940
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==41 or _la==52:
                    self.state = 939
                    _la = self._input.LA(1)
                    if not(_la==41 or _la==52):
                        self._errHandler.recoverInline(self)
                    else:
                        self._errHandler.reportMatch(self)
                        self.consume()


                pass
            elif token in [41]:
                self.enterOuterAlt(localctx, 2)
                self.state = 942
                self.match(MalloyParser.ASC)
                pass
            elif token in [52]:
                self.enterOuterAlt(localctx, 3)
                self.state = 943
                self.match(MalloyParser.DESC)
                pass
            else:
                raise NoViableAltException(self)

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


    class AggregateOrderByStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def ORDER_BY(self):
            return self.getToken(MalloyParser.ORDER_BY, 0)

        def aggregateOrdering(self):
            return self.getTypedRuleContext(MalloyParser.AggregateOrderingContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_aggregateOrderByStatement

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

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

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




    def aggregateOrderByStatement(self):

        localctx = MalloyParser.AggregateOrderByStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 152, self.RULE_aggregateOrderByStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 946
            self.match(MalloyParser.ORDER_BY)
            self.state = 947
            self.aggregateOrdering()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class FieldPropertyLimitStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def limitStatement(self):
            return self.getTypedRuleContext(MalloyParser.LimitStatementContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_fieldPropertyLimitStatement

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

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

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




    def fieldPropertyLimitStatement(self):

        localctx = MalloyParser.FieldPropertyLimitStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 154, self.RULE_fieldPropertyLimitStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 949
            self.limitStatement()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class FieldPropertyStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def whereStatement(self):
            return self.getTypedRuleContext(MalloyParser.WhereStatementContext,0)


        def partitionByStatement(self):
            return self.getTypedRuleContext(MalloyParser.PartitionByStatementContext,0)


        def aggregateOrderByStatement(self):
            return self.getTypedRuleContext(MalloyParser.AggregateOrderByStatementContext,0)


        def fieldPropertyLimitStatement(self):
            return self.getTypedRuleContext(MalloyParser.FieldPropertyLimitStatementContext,0)


        def groupedByStatement(self):
            return self.getTypedRuleContext(MalloyParser.GroupedByStatementContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_fieldPropertyStatement

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

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

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




    def fieldPropertyStatement(self):

        localctx = MalloyParser.FieldPropertyStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 156, self.RULE_fieldPropertyStatement)
        try:
            self.state = 956
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [35]:
                self.enterOuterAlt(localctx, 1)
                self.state = 951
                self.whereStatement()
                pass
            elif token in [23]:
                self.enterOuterAlt(localctx, 2)
                self.state = 952
                self.partitionByStatement()
                pass
            elif token in [22]:
                self.enterOuterAlt(localctx, 3)
                self.state = 953
                self.aggregateOrderByStatement()
                pass
            elif token in [19]:
                self.enterOuterAlt(localctx, 4)
                self.state = 954
                self.fieldPropertyLimitStatement()
                pass
            elif token in [12]:
                self.enterOuterAlt(localctx, 5)
                self.state = 955
                self.groupedByStatement()
                pass
            else:
                raise NoViableAltException(self)

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


    class FilterClauseListContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def fieldExpr(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.FieldExprContext)
            else:
                return self.getTypedRuleContext(MalloyParser.FieldExprContext,i)


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

        def getRuleIndex(self):
            return MalloyParser.RULE_filterClauseList

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

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

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




    def filterClauseList(self):

        localctx = MalloyParser.FilterClauseListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 158, self.RULE_filterClauseList)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 958
            self.fieldExpr(0)
            self.state = 963
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,94,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 959
                    self.match(MalloyParser.COMMA)
                    self.state = 960
                    self.fieldExpr(0) 
                self.state = 965
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,94,self._ctx)

            self.state = 967
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==135:
                self.state = 966
                self.match(MalloyParser.COMMA)


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


    class WhereStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def WHERE(self):
            return self.getToken(MalloyParser.WHERE, 0)

        def filterClauseList(self):
            return self.getTypedRuleContext(MalloyParser.FilterClauseListContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_whereStatement

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

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

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




    def whereStatement(self):

        localctx = MalloyParser.WhereStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 160, self.RULE_whereStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 969
            self.match(MalloyParser.WHERE)
            self.state = 970
            self.filterClauseList()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class HavingStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def HAVING(self):
            return self.getToken(MalloyParser.HAVING, 0)

        def filterClauseList(self):
            return self.getTypedRuleContext(MalloyParser.FilterClauseListContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_havingStatement

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

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

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




    def havingStatement(self):

        localctx = MalloyParser.HavingStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 162, self.RULE_havingStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 972
            self.match(MalloyParser.HAVING)
            self.state = 973
            self.filterClauseList()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class SubQueryDefListContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def exploreQueryDef(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.ExploreQueryDefContext)
            else:
                return self.getTypedRuleContext(MalloyParser.ExploreQueryDefContext,i)


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

        def getRuleIndex(self):
            return MalloyParser.RULE_subQueryDefList

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

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

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




    def subQueryDefList(self):

        localctx = MalloyParser.SubQueryDefListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 164, self.RULE_subQueryDefList)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 975
            self.exploreQueryDef()
            self.state = 982
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,97,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 977
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)
                    if _la==135:
                        self.state = 976
                        self.match(MalloyParser.COMMA)


                    self.state = 979
                    self.exploreQueryDef() 
                self.state = 984
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,97,self._ctx)

            self.state = 986
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==135:
                self.state = 985
                self.match(MalloyParser.COMMA)


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


    class ExploreQueryNameDefContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def id_(self):
            return self.getTypedRuleContext(MalloyParser.IdContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_exploreQueryNameDef

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

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

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




    def exploreQueryNameDef(self):

        localctx = MalloyParser.ExploreQueryNameDefContext(self, self._ctx, self.state)
        self.enterRule(localctx, 166, self.RULE_exploreQueryNameDef)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 988
            self.id_()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class ExploreQueryDefContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def exploreQueryNameDef(self):
            return self.getTypedRuleContext(MalloyParser.ExploreQueryNameDefContext,0)


        def isDefine(self):
            return self.getTypedRuleContext(MalloyParser.IsDefineContext,0)


        def vExpr(self):
            return self.getTypedRuleContext(MalloyParser.VExprContext,0)


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

        def getRuleIndex(self):
            return MalloyParser.RULE_exploreQueryDef

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

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

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




    def exploreQueryDef(self):

        localctx = MalloyParser.ExploreQueryDefContext(self, self._ctx, self.state)
        self.enterRule(localctx, 168, self.RULE_exploreQueryDef)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 993
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==121:
                self.state = 990
                self.match(MalloyParser.ANNOTATION)
                self.state = 995
                self._errHandler.sync(self)
                _la = self._input.LA(1)

            self.state = 996
            self.exploreQueryNameDef()
            self.state = 997
            self.isDefine()
            self.state = 998
            self.vExpr()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class DrillStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def DRILL(self):
            return self.getToken(MalloyParser.DRILL, 0)

        def drillClauseList(self):
            return self.getTypedRuleContext(MalloyParser.DrillClauseListContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_drillStatement

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

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

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




    def drillStatement(self):

        localctx = MalloyParser.DrillStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 170, self.RULE_drillStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1000
            self.match(MalloyParser.DRILL)
            self.state = 1001
            self.drillClauseList()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class DrillClauseListContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def fieldExpr(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.FieldExprContext)
            else:
                return self.getTypedRuleContext(MalloyParser.FieldExprContext,i)


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

        def getRuleIndex(self):
            return MalloyParser.RULE_drillClauseList

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

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

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




    def drillClauseList(self):

        localctx = MalloyParser.DrillClauseListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 172, self.RULE_drillClauseList)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1003
            self.fieldExpr(0)
            self.state = 1008
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,100,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 1004
                    self.match(MalloyParser.COMMA)
                    self.state = 1005
                    self.fieldExpr(0) 
                self.state = 1010
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,100,self._ctx)

            self.state = 1012
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==135:
                self.state = 1011
                self.match(MalloyParser.COMMA)


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


    class QueryStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def groupByStatement(self):
            return self.getTypedRuleContext(MalloyParser.GroupByStatementContext,0)


        def declareStatement(self):
            return self.getTypedRuleContext(MalloyParser.DeclareStatementContext,0)


        def queryJoinStatement(self):
            return self.getTypedRuleContext(MalloyParser.QueryJoinStatementContext,0)


        def queryExtend(self):
            return self.getTypedRuleContext(MalloyParser.QueryExtendContext,0)


        def projectStatement(self):
            return self.getTypedRuleContext(MalloyParser.ProjectStatementContext,0)


        def indexStatement(self):
            return self.getTypedRuleContext(MalloyParser.IndexStatementContext,0)


        def aggregateStatement(self):
            return self.getTypedRuleContext(MalloyParser.AggregateStatementContext,0)


        def calculateStatement(self):
            return self.getTypedRuleContext(MalloyParser.CalculateStatementContext,0)


        def topStatement(self):
            return self.getTypedRuleContext(MalloyParser.TopStatementContext,0)


        def limitStatement(self):
            return self.getTypedRuleContext(MalloyParser.LimitStatementContext,0)


        def orderByStatement(self):
            return self.getTypedRuleContext(MalloyParser.OrderByStatementContext,0)


        def whereStatement(self):
            return self.getTypedRuleContext(MalloyParser.WhereStatementContext,0)


        def havingStatement(self):
            return self.getTypedRuleContext(MalloyParser.HavingStatementContext,0)


        def nestStatement(self):
            return self.getTypedRuleContext(MalloyParser.NestStatementContext,0)


        def sampleStatement(self):
            return self.getTypedRuleContext(MalloyParser.SampleStatementContext,0)


        def timezoneStatement(self):
            return self.getTypedRuleContext(MalloyParser.TimezoneStatementContext,0)


        def drillStatement(self):
            return self.getTypedRuleContext(MalloyParser.DrillStatementContext,0)


        def queryAnnotation(self):
            return self.getTypedRuleContext(MalloyParser.QueryAnnotationContext,0)


        def ignoredModelAnnotations(self):
            return self.getTypedRuleContext(MalloyParser.IgnoredModelAnnotationsContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_queryStatement

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

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

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




    def queryStatement(self):

        localctx = MalloyParser.QueryStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 174, self.RULE_queryStatement)
        try:
            self.state = 1033
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,102,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 1014
                self.groupByStatement()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 1015
                self.declareStatement()
                pass

            elif la_ == 3:
                self.enterOuterAlt(localctx, 3)
                self.state = 1016
                self.queryJoinStatement()
                pass

            elif la_ == 4:
                self.enterOuterAlt(localctx, 4)
                self.state = 1017
                self.queryExtend()
                pass

            elif la_ == 5:
                self.enterOuterAlt(localctx, 5)
                self.state = 1018
                self.projectStatement()
                pass

            elif la_ == 6:
                self.enterOuterAlt(localctx, 6)
                self.state = 1019
                self.indexStatement()
                pass

            elif la_ == 7:
                self.enterOuterAlt(localctx, 7)
                self.state = 1020
                self.aggregateStatement()
                pass

            elif la_ == 8:
                self.enterOuterAlt(localctx, 8)
                self.state = 1021
                self.calculateStatement()
                pass

            elif la_ == 9:
                self.enterOuterAlt(localctx, 9)
                self.state = 1022
                self.topStatement()
                pass

            elif la_ == 10:
                self.enterOuterAlt(localctx, 10)
                self.state = 1023
                self.limitStatement()
                pass

            elif la_ == 11:
                self.enterOuterAlt(localctx, 11)
                self.state = 1024
                self.orderByStatement()
                pass

            elif la_ == 12:
                self.enterOuterAlt(localctx, 12)
                self.state = 1025
                self.whereStatement()
                pass

            elif la_ == 13:
                self.enterOuterAlt(localctx, 13)
                self.state = 1026
                self.havingStatement()
                pass

            elif la_ == 14:
                self.enterOuterAlt(localctx, 14)
                self.state = 1027
                self.nestStatement()
                pass

            elif la_ == 15:
                self.enterOuterAlt(localctx, 15)
                self.state = 1028
                self.sampleStatement()
                pass

            elif la_ == 16:
                self.enterOuterAlt(localctx, 16)
                self.state = 1029
                self.timezoneStatement()
                pass

            elif la_ == 17:
                self.enterOuterAlt(localctx, 17)
                self.state = 1030
                self.drillStatement()
                pass

            elif la_ == 18:
                self.enterOuterAlt(localctx, 18)
                self.state = 1031
                self.queryAnnotation()
                pass

            elif la_ == 19:
                self.enterOuterAlt(localctx, 19)
                self.state = 1032
                self.ignoredModelAnnotations()
                pass


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


    class QueryJoinStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def joinStatement(self):
            return self.getTypedRuleContext(MalloyParser.JoinStatementContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_queryJoinStatement

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

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

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




    def queryJoinStatement(self):

        localctx = MalloyParser.QueryJoinStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 176, self.RULE_queryJoinStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1035
            self.joinStatement()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class GroupByStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def tags(self):
            return self.getTypedRuleContext(MalloyParser.TagsContext,0)


        def GROUP_BY(self):
            return self.getToken(MalloyParser.GROUP_BY, 0)

        def queryFieldList(self):
            return self.getTypedRuleContext(MalloyParser.QueryFieldListContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_groupByStatement

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

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

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




    def groupByStatement(self):

        localctx = MalloyParser.GroupByStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 178, self.RULE_groupByStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1037
            self.tags()
            self.state = 1038
            self.match(MalloyParser.GROUP_BY)
            self.state = 1039
            self.queryFieldList()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class QueryFieldListContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def queryFieldEntry(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.QueryFieldEntryContext)
            else:
                return self.getTypedRuleContext(MalloyParser.QueryFieldEntryContext,i)


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

        def getRuleIndex(self):
            return MalloyParser.RULE_queryFieldList

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

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

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




    def queryFieldList(self):

        localctx = MalloyParser.QueryFieldListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 180, self.RULE_queryFieldList)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1041
            self.queryFieldEntry()
            self.state = 1048
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,104,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 1043
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)
                    if _la==135:
                        self.state = 1042
                        self.match(MalloyParser.COMMA)


                    self.state = 1045
                    self.queryFieldEntry() 
                self.state = 1050
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,104,self._ctx)

            self.state = 1052
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==135:
                self.state = 1051
                self.match(MalloyParser.COMMA)


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


    class QueryFieldEntryContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def taggedRef(self):
            return self.getTypedRuleContext(MalloyParser.TaggedRefContext,0)


        def fieldDef(self):
            return self.getTypedRuleContext(MalloyParser.FieldDefContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_queryFieldEntry

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

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

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




    def queryFieldEntry(self):

        localctx = MalloyParser.QueryFieldEntryContext(self, self._ctx, self.state)
        self.enterRule(localctx, 182, self.RULE_queryFieldEntry)
        try:
            self.state = 1056
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,106,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 1054
                self.taggedRef()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 1055
                self.fieldDef()
                pass


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


    class NestStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def tags(self):
            return self.getTypedRuleContext(MalloyParser.TagsContext,0)


        def NEST(self):
            return self.getToken(MalloyParser.NEST, 0)

        def nestedQueryList(self):
            return self.getTypedRuleContext(MalloyParser.NestedQueryListContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_nestStatement

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

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

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




    def nestStatement(self):

        localctx = MalloyParser.NestStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 184, self.RULE_nestStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1058
            self.tags()
            self.state = 1059
            self.match(MalloyParser.NEST)
            self.state = 1060
            self.nestedQueryList()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class NestedQueryListContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def nestEntry(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.NestEntryContext)
            else:
                return self.getTypedRuleContext(MalloyParser.NestEntryContext,i)


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

        def getRuleIndex(self):
            return MalloyParser.RULE_nestedQueryList

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

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

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




    def nestedQueryList(self):

        localctx = MalloyParser.NestedQueryListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 186, self.RULE_nestedQueryList)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1062
            self.nestEntry()
            self.state = 1069
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,108,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 1064
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)
                    if _la==135:
                        self.state = 1063
                        self.match(MalloyParser.COMMA)


                    self.state = 1066
                    self.nestEntry() 
                self.state = 1071
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,108,self._ctx)

            self.state = 1073
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==135:
                self.state = 1072
                self.match(MalloyParser.COMMA)


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


    class NestEntryContext(ParserRuleContext):
        __slots__ = 'parser'

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


        def getRuleIndex(self):
            return MalloyParser.RULE_nestEntry

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



    class NestDefContext(NestEntryContext):

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

        def tags(self):
            return self.getTypedRuleContext(MalloyParser.TagsContext,0)

        def vExpr(self):
            return self.getTypedRuleContext(MalloyParser.VExprContext,0)

        def queryName(self):
            return self.getTypedRuleContext(MalloyParser.QueryNameContext,0)

        def isDefine(self):
            return self.getTypedRuleContext(MalloyParser.IsDefineContext,0)


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

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

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



    def nestEntry(self):

        localctx = MalloyParser.NestEntryContext(self, self._ctx, self.state)
        self.enterRule(localctx, 188, self.RULE_nestEntry)
        try:
            localctx = MalloyParser.NestDefContext(self, localctx)
            self.enterOuterAlt(localctx, 1)
            self.state = 1075
            self.tags()
            self.state = 1079
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,110,self._ctx)
            if la_ == 1:
                self.state = 1076
                self.queryName()
                self.state = 1077
                self.isDefine()


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


    class AggregateStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def tags(self):
            return self.getTypedRuleContext(MalloyParser.TagsContext,0)


        def AGGREGATE(self):
            return self.getToken(MalloyParser.AGGREGATE, 0)

        def queryFieldList(self):
            return self.getTypedRuleContext(MalloyParser.QueryFieldListContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_aggregateStatement

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

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

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




    def aggregateStatement(self):

        localctx = MalloyParser.AggregateStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 190, self.RULE_aggregateStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1083
            self.tags()
            self.state = 1084
            self.match(MalloyParser.AGGREGATE)
            self.state = 1085
            self.queryFieldList()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class CalculateStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def tags(self):
            return self.getTypedRuleContext(MalloyParser.TagsContext,0)


        def CALCULATE(self):
            return self.getToken(MalloyParser.CALCULATE, 0)

        def queryFieldList(self):
            return self.getTypedRuleContext(MalloyParser.QueryFieldListContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_calculateStatement

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

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

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




    def calculateStatement(self):

        localctx = MalloyParser.CalculateStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 192, self.RULE_calculateStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1087
            self.tags()
            self.state = 1088
            self.match(MalloyParser.CALCULATE)
            self.state = 1089
            self.queryFieldList()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class ProjectStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def tags(self):
            return self.getTypedRuleContext(MalloyParser.TagsContext,0)


        def SELECT(self):
            return self.getToken(MalloyParser.SELECT, 0)

        def fieldCollection(self):
            return self.getTypedRuleContext(MalloyParser.FieldCollectionContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_projectStatement

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

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

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




    def projectStatement(self):

        localctx = MalloyParser.ProjectStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 194, self.RULE_projectStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1091
            self.tags()
            self.state = 1092
            self.match(MalloyParser.SELECT)
            self.state = 1093
            self.fieldCollection()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class PartitionByStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def PARTITION_BY(self):
            return self.getToken(MalloyParser.PARTITION_BY, 0)

        def id_(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.IdContext)
            else:
                return self.getTypedRuleContext(MalloyParser.IdContext,i)


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

        def getRuleIndex(self):
            return MalloyParser.RULE_partitionByStatement

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

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

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




    def partitionByStatement(self):

        localctx = MalloyParser.PartitionByStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 196, self.RULE_partitionByStatement)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1095
            self.match(MalloyParser.PARTITION_BY)
            self.state = 1096
            self.id_()
            self.state = 1101
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,111,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 1097
                    self.match(MalloyParser.COMMA)
                    self.state = 1098
                    self.id_() 
                self.state = 1103
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,111,self._ctx)

            self.state = 1105
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==135:
                self.state = 1104
                self.match(MalloyParser.COMMA)


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


    class GroupedByStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def GROUPED_BY(self):
            return self.getToken(MalloyParser.GROUPED_BY, 0)

        def id_(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.IdContext)
            else:
                return self.getTypedRuleContext(MalloyParser.IdContext,i)


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

        def getRuleIndex(self):
            return MalloyParser.RULE_groupedByStatement

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

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

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




    def groupedByStatement(self):

        localctx = MalloyParser.GroupedByStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 198, self.RULE_groupedByStatement)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1107
            self.match(MalloyParser.GROUPED_BY)
            self.state = 1108
            self.id_()
            self.state = 1113
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,113,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 1109
                    self.match(MalloyParser.COMMA)
                    self.state = 1110
                    self.id_() 
                self.state = 1115
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,113,self._ctx)

            self.state = 1117
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==135:
                self.state = 1116
                self.match(MalloyParser.COMMA)


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


    class OrderByStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def ORDER_BY(self):
            return self.getToken(MalloyParser.ORDER_BY, 0)

        def ordering(self):
            return self.getTypedRuleContext(MalloyParser.OrderingContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_orderByStatement

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

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

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




    def orderByStatement(self):

        localctx = MalloyParser.OrderByStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 200, self.RULE_orderByStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1119
            self.match(MalloyParser.ORDER_BY)
            self.state = 1120
            self.ordering()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class OrderingContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def orderBySpec(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.OrderBySpecContext)
            else:
                return self.getTypedRuleContext(MalloyParser.OrderBySpecContext,i)


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

        def getRuleIndex(self):
            return MalloyParser.RULE_ordering

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

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

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




    def ordering(self):

        localctx = MalloyParser.OrderingContext(self, self._ctx, self.state)
        self.enterRule(localctx, 202, self.RULE_ordering)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1122
            self.orderBySpec()
            self.state = 1129
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,116,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 1124
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)
                    if _la==135:
                        self.state = 1123
                        self.match(MalloyParser.COMMA)


                    self.state = 1126
                    self.orderBySpec() 
                self.state = 1131
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,116,self._ctx)

            self.state = 1133
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==135:
                self.state = 1132
                self.match(MalloyParser.COMMA)


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


    class OrderBySpecContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def INTEGER_LITERAL(self):
            return self.getToken(MalloyParser.INTEGER_LITERAL, 0)

        def fieldName(self):
            return self.getTypedRuleContext(MalloyParser.FieldNameContext,0)


        def ASC(self):
            return self.getToken(MalloyParser.ASC, 0)

        def DESC(self):
            return self.getToken(MalloyParser.DESC, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_orderBySpec

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

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

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




    def orderBySpec(self):

        localctx = MalloyParser.OrderBySpecContext(self, self._ctx, self.state)
        self.enterRule(localctx, 204, self.RULE_orderBySpec)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1137
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [165]:
                self.state = 1135
                self.match(MalloyParser.INTEGER_LITERAL)
                pass
            elif token in [119, 162]:
                self.state = 1136
                self.fieldName()
                pass
            else:
                raise NoViableAltException(self)

            self.state = 1140
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==41 or _la==52:
                self.state = 1139
                _la = self._input.LA(1)
                if not(_la==41 or _la==52):
                    self._errHandler.recoverInline(self)
                else:
                    self._errHandler.reportMatch(self)
                    self.consume()


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


    class LimitStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def LIMIT(self):
            return self.getToken(MalloyParser.LIMIT, 0)

        def INTEGER_LITERAL(self):
            return self.getToken(MalloyParser.INTEGER_LITERAL, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_limitStatement

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

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

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




    def limitStatement(self):

        localctx = MalloyParser.LimitStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 206, self.RULE_limitStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1142
            self.match(MalloyParser.LIMIT)
            self.state = 1143
            self.match(MalloyParser.INTEGER_LITERAL)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class BySpecContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def BY(self):
            return self.getToken(MalloyParser.BY, 0)

        def fieldName(self):
            return self.getTypedRuleContext(MalloyParser.FieldNameContext,0)


        def fieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.FieldExprContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_bySpec

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

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

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




    def bySpec(self):

        localctx = MalloyParser.BySpecContext(self, self._ctx, self.state)
        self.enterRule(localctx, 208, self.RULE_bySpec)
        try:
            self.state = 1149
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,120,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 1145
                self.match(MalloyParser.BY)
                self.state = 1146
                self.fieldName()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 1147
                self.match(MalloyParser.BY)
                self.state = 1148
                self.fieldExpr(0)
                pass


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


    class TopStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def TOP(self):
            return self.getToken(MalloyParser.TOP, 0)

        def INTEGER_LITERAL(self):
            return self.getToken(MalloyParser.INTEGER_LITERAL, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_topStatement

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

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

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




    def topStatement(self):

        localctx = MalloyParser.TopStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 210, self.RULE_topStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1151
            self.match(MalloyParser.TOP)
            self.state = 1152
            self.match(MalloyParser.INTEGER_LITERAL)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class IndexElementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def fieldPath(self):
            return self.getTypedRuleContext(MalloyParser.FieldPathContext,0)


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

        def STAR(self):
            return self.getToken(MalloyParser.STAR, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_indexElement

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

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

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




    def indexElement(self):

        localctx = MalloyParser.IndexElementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 212, self.RULE_indexElement)
        self._la = 0 # Token type
        try:
            self.state = 1160
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [119, 162]:
                self.enterOuterAlt(localctx, 1)
                self.state = 1154
                self.fieldPath()
                self.state = 1157
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==136:
                    self.state = 1155
                    self.match(MalloyParser.DOT)
                    self.state = 1156
                    self.match(MalloyParser.STAR)


                pass
            elif token in [145]:
                self.enterOuterAlt(localctx, 2)
                self.state = 1159
                self.match(MalloyParser.STAR)
                pass
            else:
                raise NoViableAltException(self)

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


    class IndexFieldsContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def indexElement(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.IndexElementContext)
            else:
                return self.getTypedRuleContext(MalloyParser.IndexElementContext,i)


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

        def getRuleIndex(self):
            return MalloyParser.RULE_indexFields

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

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

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




    def indexFields(self):

        localctx = MalloyParser.IndexFieldsContext(self, self._ctx, self.state)
        self.enterRule(localctx, 214, self.RULE_indexFields)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1162
            self.indexElement()
            self.state = 1169
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while ((((_la - 119)) & ~0x3f) == 0 and ((1 << (_la - 119)) & 8796160196609) != 0):
                self.state = 1164
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==135:
                    self.state = 1163
                    self.match(MalloyParser.COMMA)


                self.state = 1166
                self.indexElement()
                self.state = 1171
                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 IndexStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def INDEX(self):
            return self.getToken(MalloyParser.INDEX, 0)

        def indexFields(self):
            return self.getTypedRuleContext(MalloyParser.IndexFieldsContext,0)


        def BY(self):
            return self.getToken(MalloyParser.BY, 0)

        def fieldName(self):
            return self.getTypedRuleContext(MalloyParser.FieldNameContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_indexStatement

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

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

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




    def indexStatement(self):

        localctx = MalloyParser.IndexStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 216, self.RULE_indexStatement)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1172
            self.match(MalloyParser.INDEX)
            self.state = 1173
            self.indexFields()
            self.state = 1176
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==44:
                self.state = 1174
                self.match(MalloyParser.BY)
                self.state = 1175
                self.fieldName()


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


    class SampleStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def SAMPLE(self):
            return self.getToken(MalloyParser.SAMPLE, 0)

        def sampleSpec(self):
            return self.getTypedRuleContext(MalloyParser.SampleSpecContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_sampleStatement

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

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

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




    def sampleStatement(self):

        localctx = MalloyParser.SampleStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 218, self.RULE_sampleStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1178
            self.match(MalloyParser.SAMPLE)
            self.state = 1179
            self.sampleSpec()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class TimezoneStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def TIMEZONE(self):
            return self.getToken(MalloyParser.TIMEZONE, 0)

        def string(self):
            return self.getTypedRuleContext(MalloyParser.StringContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_timezoneStatement

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

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

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




    def timezoneStatement(self):

        localctx = MalloyParser.TimezoneStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 220, self.RULE_timezoneStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1181
            self.match(MalloyParser.TIMEZONE)
            self.state = 1182
            self.string()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class QueryAnnotationContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def ANNOTATION(self):
            return self.getToken(MalloyParser.ANNOTATION, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_queryAnnotation

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

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

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




    def queryAnnotation(self):

        localctx = MalloyParser.QueryAnnotationContext(self, self._ctx, self.state)
        self.enterRule(localctx, 222, self.RULE_queryAnnotation)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1184
            self.match(MalloyParser.ANNOTATION)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class SampleSpecContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def PERCENT_LITERAL(self):
            return self.getToken(MalloyParser.PERCENT_LITERAL, 0)

        def INTEGER_LITERAL(self):
            return self.getToken(MalloyParser.INTEGER_LITERAL, 0)

        def TRUE(self):
            return self.getToken(MalloyParser.TRUE, 0)

        def FALSE(self):
            return self.getToken(MalloyParser.FALSE, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_sampleSpec

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

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

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




    def sampleSpec(self):

        localctx = MalloyParser.SampleSpecContext(self, self._ctx, self.state)
        self.enterRule(localctx, 224, self.RULE_sampleSpec)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1186
            _la = self._input.LA(1)
            if not(_la==58 or _la==101 or _la==163 or _la==165):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class AggregateContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def SUM(self):
            return self.getToken(MalloyParser.SUM, 0)

        def COUNT(self):
            return self.getToken(MalloyParser.COUNT, 0)

        def AVG(self):
            return self.getToken(MalloyParser.AVG, 0)

        def MIN(self):
            return self.getToken(MalloyParser.MIN, 0)

        def MAX(self):
            return self.getToken(MalloyParser.MAX, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_aggregate

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

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

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




    def aggregate(self):

        localctx = MalloyParser.AggregateContext(self, self._ctx, self.state)
        self.enterRule(localctx, 226, self.RULE_aggregate)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1188
            _la = self._input.LA(1)
            if not(((((_la - 42)) & ~0x3f) == 0 and ((1 << (_la - 42)) & 2251825583489089) != 0)):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class MalloyTypeContext(ParserRuleContext):
        __slots__ = 'parser'

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

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

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

        def BOOLEAN(self):
            return self.getToken(MalloyParser.BOOLEAN, 0)

        def DATE(self):
            return self.getToken(MalloyParser.DATE, 0)

        def TIMESTAMP(self):
            return self.getToken(MalloyParser.TIMESTAMP, 0)

        def TIMESTAMPTZ(self):
            return self.getToken(MalloyParser.TIMESTAMPTZ, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_malloyType

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

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

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




    def malloyType(self):

        localctx = MalloyParser.MalloyTypeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 228, self.RULE_malloyType)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1190
            _la = self._input.LA(1)
            if not(((((_la - 43)) & ~0x3f) == 0 and ((1 << (_la - 43)) & 108368415789416577) != 0)):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class CompareOpContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def MATCH(self):
            return self.getToken(MalloyParser.MATCH, 0)

        def NOT_MATCH(self):
            return self.getToken(MalloyParser.NOT_MATCH, 0)

        def GT(self):
            return self.getToken(MalloyParser.GT, 0)

        def LT(self):
            return self.getToken(MalloyParser.LT, 0)

        def GTE(self):
            return self.getToken(MalloyParser.GTE, 0)

        def LTE(self):
            return self.getToken(MalloyParser.LTE, 0)

        def EQ(self):
            return self.getToken(MalloyParser.EQ, 0)

        def NE(self):
            return self.getToken(MalloyParser.NE, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_compareOp

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

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

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




    def compareOp(self):

        localctx = MalloyParser.CompareOpContext(self, self._ctx, self.state)
        self.enterRule(localctx, 230, self.RULE_compareOp)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1192
            _la = self._input.LA(1)
            if not(((((_la - 137)) & ~0x3f) == 0 and ((1 << (_la - 137)) & 24639) != 0)):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class StringContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def shortString(self):
            return self.getTypedRuleContext(MalloyParser.ShortStringContext,0)


        def sqlString(self):
            return self.getTypedRuleContext(MalloyParser.SqlStringContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_string

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

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

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




    def string(self):

        localctx = MalloyParser.StringContext(self, self._ctx, self.state)
        self.enterRule(localctx, 232, self.RULE_string)
        try:
            self.state = 1196
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [117, 118]:
                self.enterOuterAlt(localctx, 1)
                self.state = 1194
                self.shortString()
                pass
            elif token in [169]:
                self.enterOuterAlt(localctx, 2)
                self.state = 1195
                self.sqlString()
                pass
            else:
                raise NoViableAltException(self)

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


    class ShortStringContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def SQ_STRING(self):
            return self.getToken(MalloyParser.SQ_STRING, 0)

        def DQ_STRING(self):
            return self.getToken(MalloyParser.DQ_STRING, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_shortString

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

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

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




    def shortString(self):

        localctx = MalloyParser.ShortStringContext(self, self._ctx, self.state)
        self.enterRule(localctx, 234, self.RULE_shortString)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1198
            _la = self._input.LA(1)
            if not(_la==117 or _la==118):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class RawStringContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def RAW_SQ(self):
            return self.getToken(MalloyParser.RAW_SQ, 0)

        def RAW_DQ(self):
            return self.getToken(MalloyParser.RAW_DQ, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_rawString

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

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

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




    def rawString(self):

        localctx = MalloyParser.RawStringContext(self, self._ctx, self.state)
        self.enterRule(localctx, 236, self.RULE_rawString)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1200
            _la = self._input.LA(1)
            if not(_la==109 or _la==110):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class NumericLiteralContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def NUMERIC_LITERAL(self):
            return self.getToken(MalloyParser.NUMERIC_LITERAL, 0)

        def INTEGER_LITERAL(self):
            return self.getToken(MalloyParser.INTEGER_LITERAL, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_numericLiteral

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

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

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




    def numericLiteral(self):

        localctx = MalloyParser.NumericLiteralContext(self, self._ctx, self.state)
        self.enterRule(localctx, 238, self.RULE_numericLiteral)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1202
            _la = self._input.LA(1)
            if not(_la==164 or _la==165):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class LiteralContext(ParserRuleContext):
        __slots__ = 'parser'

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


        def getRuleIndex(self):
            return MalloyParser.RULE_literal

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



    class ExprNULLContext(LiteralContext):

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

        def NULL(self):
            return self.getToken(MalloyParser.NULL, 0)

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

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

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


    class ExprRegexContext(LiteralContext):

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

        def HACKY_REGEX(self):
            return self.getToken(MalloyParser.HACKY_REGEX, 0)

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

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

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


    class Stub_rawStringContext(LiteralContext):

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

        def rawString(self):
            return self.getTypedRuleContext(MalloyParser.RawStringContext,0)


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

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

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


    class ExprStringContext(LiteralContext):

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

        def string(self):
            return self.getTypedRuleContext(MalloyParser.StringContext,0)


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

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

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


    class FilterString_stubContext(LiteralContext):

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

        def filterString(self):
            return self.getTypedRuleContext(MalloyParser.FilterStringContext,0)


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

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

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


    class ExprBoolContext(LiteralContext):

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

        def TRUE(self):
            return self.getToken(MalloyParser.TRUE, 0)
        def FALSE(self):
            return self.getToken(MalloyParser.FALSE, 0)

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

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

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


    class ExprNumberContext(LiteralContext):

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

        def numericLiteral(self):
            return self.getTypedRuleContext(MalloyParser.NumericLiteralContext,0)


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

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

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


    class ExprNowContext(LiteralContext):

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

        def NOW(self):
            return self.getToken(MalloyParser.NOW, 0)

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

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

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


    class ExprTimeContext(LiteralContext):

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

        def dateLiteral(self):
            return self.getTypedRuleContext(MalloyParser.DateLiteralContext,0)


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

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

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



    def literal(self):

        localctx = MalloyParser.LiteralContext(self, self._ctx, self.state)
        self.enterRule(localctx, 240, self.RULE_literal)
        self._la = 0 # Token type
        try:
            self.state = 1213
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [117, 118, 169]:
                localctx = MalloyParser.ExprStringContext(self, localctx)
                self.enterOuterAlt(localctx, 1)
                self.state = 1204
                self.string()
                pass
            elif token in [109, 110]:
                localctx = MalloyParser.Stub_rawStringContext(self, localctx)
                self.enterOuterAlt(localctx, 2)
                self.state = 1205
                self.rawString()
                pass
            elif token in [164, 165]:
                localctx = MalloyParser.ExprNumberContext(self, localctx)
                self.enterOuterAlt(localctx, 3)
                self.state = 1206
                self.numericLiteral()
                pass
            elif token in [155, 156, 157, 158, 159, 160, 161]:
                localctx = MalloyParser.ExprTimeContext(self, localctx)
                self.enterOuterAlt(localctx, 4)
                self.state = 1207
                self.dateLiteral()
                pass
            elif token in [81]:
                localctx = MalloyParser.ExprNULLContext(self, localctx)
                self.enterOuterAlt(localctx, 5)
                self.state = 1208
                self.match(MalloyParser.NULL)
                pass
            elif token in [58, 101]:
                localctx = MalloyParser.ExprBoolContext(self, localctx)
                self.enterOuterAlt(localctx, 6)
                self.state = 1209
                _la = self._input.LA(1)
                if not(_la==58 or _la==101):
                    self._errHandler.recoverInline(self)
                else:
                    self._errHandler.reportMatch(self)
                    self.consume()
                pass
            elif token in [108]:
                localctx = MalloyParser.ExprRegexContext(self, localctx)
                self.enterOuterAlt(localctx, 7)
                self.state = 1210
                self.match(MalloyParser.HACKY_REGEX)
                pass
            elif token in [111, 112, 113, 114, 115, 116]:
                localctx = MalloyParser.FilterString_stubContext(self, localctx)
                self.enterOuterAlt(localctx, 8)
                self.state = 1211
                self.filterString()
                pass
            elif token in [80]:
                localctx = MalloyParser.ExprNowContext(self, localctx)
                self.enterOuterAlt(localctx, 9)
                self.state = 1212
                self.match(MalloyParser.NOW)
                pass
            else:
                raise NoViableAltException(self)

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


    class DateLiteralContext(ParserRuleContext):
        __slots__ = 'parser'

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


        def getRuleIndex(self):
            return MalloyParser.RULE_dateLiteral

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



    class LiteralYearContext(DateLiteralContext):

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

        def LITERAL_YEAR(self):
            return self.getToken(MalloyParser.LITERAL_YEAR, 0)

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

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

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


    class LiteralDayContext(DateLiteralContext):

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

        def LITERAL_DAY(self):
            return self.getToken(MalloyParser.LITERAL_DAY, 0)

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

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

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


    class LiteralTimestampContext(DateLiteralContext):

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

        def LITERAL_TIMESTAMP(self):
            return self.getToken(MalloyParser.LITERAL_TIMESTAMP, 0)

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

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

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


    class LiteralMonthContext(DateLiteralContext):

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

        def LITERAL_MONTH(self):
            return self.getToken(MalloyParser.LITERAL_MONTH, 0)

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

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

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


    class LiteralHourContext(DateLiteralContext):

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

        def LITERAL_HOUR(self):
            return self.getToken(MalloyParser.LITERAL_HOUR, 0)

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

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

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


    class LiteralWeekContext(DateLiteralContext):

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

        def LITERAL_WEEK(self):
            return self.getToken(MalloyParser.LITERAL_WEEK, 0)

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

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

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


    class LiteralQuarterContext(DateLiteralContext):

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

        def LITERAL_QUARTER(self):
            return self.getToken(MalloyParser.LITERAL_QUARTER, 0)

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

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

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



    def dateLiteral(self):

        localctx = MalloyParser.DateLiteralContext(self, self._ctx, self.state)
        self.enterRule(localctx, 242, self.RULE_dateLiteral)
        try:
            self.state = 1222
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [155]:
                localctx = MalloyParser.LiteralTimestampContext(self, localctx)
                self.enterOuterAlt(localctx, 1)
                self.state = 1215
                self.match(MalloyParser.LITERAL_TIMESTAMP)
                pass
            elif token in [156]:
                localctx = MalloyParser.LiteralHourContext(self, localctx)
                self.enterOuterAlt(localctx, 2)
                self.state = 1216
                self.match(MalloyParser.LITERAL_HOUR)
                pass
            elif token in [157]:
                localctx = MalloyParser.LiteralDayContext(self, localctx)
                self.enterOuterAlt(localctx, 3)
                self.state = 1217
                self.match(MalloyParser.LITERAL_DAY)
                pass
            elif token in [160]:
                localctx = MalloyParser.LiteralWeekContext(self, localctx)
                self.enterOuterAlt(localctx, 4)
                self.state = 1218
                self.match(MalloyParser.LITERAL_WEEK)
                pass
            elif token in [159]:
                localctx = MalloyParser.LiteralMonthContext(self, localctx)
                self.enterOuterAlt(localctx, 5)
                self.state = 1219
                self.match(MalloyParser.LITERAL_MONTH)
                pass
            elif token in [158]:
                localctx = MalloyParser.LiteralQuarterContext(self, localctx)
                self.enterOuterAlt(localctx, 6)
                self.state = 1220
                self.match(MalloyParser.LITERAL_QUARTER)
                pass
            elif token in [161]:
                localctx = MalloyParser.LiteralYearContext(self, localctx)
                self.enterOuterAlt(localctx, 7)
                self.state = 1221
                self.match(MalloyParser.LITERAL_YEAR)
                pass
            else:
                raise NoViableAltException(self)

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


    class TablePathContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def string(self):
            return self.getTypedRuleContext(MalloyParser.StringContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_tablePath

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

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

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




    def tablePath(self):

        localctx = MalloyParser.TablePathContext(self, self._ctx, self.state)
        self.enterRule(localctx, 244, self.RULE_tablePath)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1224
            self.string()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class TableURIContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def string(self):
            return self.getTypedRuleContext(MalloyParser.StringContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_tableURI

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

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

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




    def tableURI(self):

        localctx = MalloyParser.TableURIContext(self, self._ctx, self.state)
        self.enterRule(localctx, 246, self.RULE_tableURI)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1226
            self.string()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class IdContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def IDENTIFIER(self):
            return self.getToken(MalloyParser.IDENTIFIER, 0)

        def BQ_STRING(self):
            return self.getToken(MalloyParser.BQ_STRING, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_id

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

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

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




    def id_(self):

        localctx = MalloyParser.IdContext(self, self._ctx, self.state)
        self.enterRule(localctx, 248, self.RULE_id)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1228
            _la = self._input.LA(1)
            if not(_la==119 or _la==162):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class TimeframeContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def SECOND(self):
            return self.getToken(MalloyParser.SECOND, 0)

        def MINUTE(self):
            return self.getToken(MalloyParser.MINUTE, 0)

        def HOUR(self):
            return self.getToken(MalloyParser.HOUR, 0)

        def DAY(self):
            return self.getToken(MalloyParser.DAY, 0)

        def WEEK(self):
            return self.getToken(MalloyParser.WEEK, 0)

        def MONTH(self):
            return self.getToken(MalloyParser.MONTH, 0)

        def QUARTER(self):
            return self.getToken(MalloyParser.QUARTER, 0)

        def YEAR(self):
            return self.getToken(MalloyParser.YEAR, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_timeframe

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

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

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




    def timeframe(self):

        localctx = MalloyParser.TimeframeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 250, self.RULE_timeframe)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1230
            _la = self._input.LA(1)
            if not(((((_la - 51)) & ~0x3f) == 0 and ((1 << (_la - 51)) & 40533084042436609) != 0)):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class UngroupContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def ALL(self):
            return self.getToken(MalloyParser.ALL, 0)

        def EXCLUDE(self):
            return self.getToken(MalloyParser.EXCLUDE, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_ungroup

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

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

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




    def ungroup(self):

        localctx = MalloyParser.UngroupContext(self, self._ctx, self.state)
        self.enterRule(localctx, 252, self.RULE_ungroup)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1232
            _la = self._input.LA(1)
            if not(_la==38 or _la==56):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class MalloyOrSQLTypeContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def malloyType(self):
            return self.getTypedRuleContext(MalloyParser.MalloyTypeContext,0)


        def string(self):
            return self.getTypedRuleContext(MalloyParser.StringContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_malloyOrSQLType

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

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

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




    def malloyOrSQLType(self):

        localctx = MalloyParser.MalloyOrSQLTypeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 254, self.RULE_malloyOrSQLType)
        try:
            self.state = 1236
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [43, 50, 82, 91, 98, 99]:
                self.enterOuterAlt(localctx, 1)
                self.state = 1234
                self.malloyType()
                pass
            elif token in [117, 118, 169]:
                self.enterOuterAlt(localctx, 2)
                self.state = 1235
                self.string()
                pass
            else:
                raise NoViableAltException(self)

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


    class FieldExprContext(ParserRuleContext):
        __slots__ = 'parser'

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


        def getRuleIndex(self):
            return MalloyParser.RULE_fieldExpr

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


    class ExprExprContext(FieldExprContext):

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

        def OPAREN(self):
            return self.getToken(MalloyParser.OPAREN, 0)
        def fieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.FieldExprContext,0)

        def CPAREN(self):
            return self.getToken(MalloyParser.CPAREN, 0)

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

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

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


    class ExprCaseContext(FieldExprContext):

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

        def caseStatement(self):
            return self.getTypedRuleContext(MalloyParser.CaseStatementContext,0)


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

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

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


    class ExprMinusContext(FieldExprContext):

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

        def MINUS(self):
            return self.getToken(MalloyParser.MINUS, 0)
        def fieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.FieldExprContext,0)


        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExprMinus" ):
                listener.enterExprMinus(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExprMinus" ):
                listener.exitExprMinus(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprMinus" ):
                return visitor.visitExprMinus(self)
            else:
                return visitor.visitChildren(self)


    class ExprAddSubContext(FieldExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.FieldExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def fieldExpr(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.FieldExprContext)
            else:
                return self.getTypedRuleContext(MalloyParser.FieldExprContext,i)

        def PLUS(self):
            return self.getToken(MalloyParser.PLUS, 0)
        def MINUS(self):
            return self.getToken(MalloyParser.MINUS, 0)

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExprAddSub" ):
                listener.enterExprAddSub(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExprAddSub" ):
                listener.exitExprAddSub(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprAddSub" ):
                return visitor.visitExprAddSub(self)
            else:
                return visitor.visitChildren(self)


    class ExprNullCheckContext(FieldExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.FieldExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def fieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.FieldExprContext,0)

        def IS(self):
            return self.getToken(MalloyParser.IS, 0)
        def NULL(self):
            return self.getToken(MalloyParser.NULL, 0)
        def NOT(self):
            return self.getToken(MalloyParser.NOT, 0)

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExprNullCheck" ):
                listener.enterExprNullCheck(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExprNullCheck" ):
                listener.exitExprNullCheck(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprNullCheck" ):
                return visitor.visitExprNullCheck(self)
            else:
                return visitor.visitChildren(self)


    class ExprArrayLiteralContext(FieldExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.FieldExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def OBRACK(self):
            return self.getToken(MalloyParser.OBRACK, 0)
        def fieldExpr(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.FieldExprContext)
            else:
                return self.getTypedRuleContext(MalloyParser.FieldExprContext,i)

        def CBRACK(self):
            return self.getToken(MalloyParser.CBRACK, 0)
        def COMMA(self, i:int=None):
            if i is None:
                return self.getTokens(MalloyParser.COMMA)
            else:
                return self.getToken(MalloyParser.COMMA, i)

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExprArrayLiteral" ):
                listener.enterExprArrayLiteral(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExprArrayLiteral" ):
                listener.exitExprArrayLiteral(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprArrayLiteral" ):
                return visitor.visitExprArrayLiteral(self)
            else:
                return visitor.visitChildren(self)


    class ExprRangeContext(FieldExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.FieldExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def fieldExpr(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.FieldExprContext)
            else:
                return self.getTypedRuleContext(MalloyParser.FieldExprContext,i)

        def TO(self):
            return self.getToken(MalloyParser.TO, 0)

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExprRange" ):
                listener.enterExprRange(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExprRange" ):
                listener.exitExprRange(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprRange" ):
                return visitor.visitExprRange(self)
            else:
                return visitor.visitChildren(self)


    class ExprLogicalOrContext(FieldExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.FieldExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def fieldExpr(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.FieldExprContext)
            else:
                return self.getTypedRuleContext(MalloyParser.FieldExprContext,i)

        def OR(self):
            return self.getToken(MalloyParser.OR, 0)

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExprLogicalOr" ):
                listener.enterExprLogicalOr(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExprLogicalOr" ):
                listener.exitExprLogicalOr(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprLogicalOr" ):
                return visitor.visitExprLogicalOr(self)
            else:
                return visitor.visitChildren(self)


    class ExprLiteralContext(FieldExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.FieldExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def literal(self):
            return self.getTypedRuleContext(MalloyParser.LiteralContext,0)


        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExprLiteral" ):
                listener.enterExprLiteral(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExprLiteral" ):
                listener.exitExprLiteral(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprLiteral" ):
                return visitor.visitExprLiteral(self)
            else:
                return visitor.visitChildren(self)


    class ExprCompareContext(FieldExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.FieldExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def fieldExpr(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.FieldExprContext)
            else:
                return self.getTypedRuleContext(MalloyParser.FieldExprContext,i)

        def compareOp(self):
            return self.getTypedRuleContext(MalloyParser.CompareOpContext,0)


        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExprCompare" ):
                listener.enterExprCompare(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExprCompare" ):
                listener.exitExprCompare(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprCompare" ):
                return visitor.visitExprCompare(self)
            else:
                return visitor.visitChildren(self)


    class ExprForRangeContext(FieldExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.FieldExprContext
            super().__init__(parser)
            self.startAt = None # FieldExprContext
            self.duration = None # FieldExprContext
            self.copyFrom(ctx)

        def FOR(self):
            return self.getToken(MalloyParser.FOR, 0)
        def timeframe(self):
            return self.getTypedRuleContext(MalloyParser.TimeframeContext,0)

        def fieldExpr(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.FieldExprContext)
            else:
                return self.getTypedRuleContext(MalloyParser.FieldExprContext,i)


        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExprForRange" ):
                listener.enterExprForRange(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExprForRange" ):
                listener.exitExprForRange(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprForRange" ):
                return visitor.visitExprForRange(self)
            else:
                return visitor.visitChildren(self)


    class ExprFuncContext(FieldExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.FieldExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def OPAREN(self):
            return self.getToken(MalloyParser.OPAREN, 0)
        def CPAREN(self):
            return self.getToken(MalloyParser.CPAREN, 0)
        def timeframe(self):
            return self.getTypedRuleContext(MalloyParser.TimeframeContext,0)

        def id_(self):
            return self.getTypedRuleContext(MalloyParser.IdContext,0)

        def argumentList(self):
            return self.getTypedRuleContext(MalloyParser.ArgumentListContext,0)

        def EXCLAM(self):
            return self.getToken(MalloyParser.EXCLAM, 0)
        def malloyType(self):
            return self.getTypedRuleContext(MalloyParser.MalloyTypeContext,0)


        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExprFunc" ):
                listener.enterExprFunc(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExprFunc" ):
                listener.exitExprFunc(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprFunc" ):
                return visitor.visitExprFunc(self)
            else:
                return visitor.visitChildren(self)


    class ExprAndTreeContext(FieldExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.FieldExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def fieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.FieldExprContext,0)

        def AMPER(self):
            return self.getToken(MalloyParser.AMPER, 0)
        def partialAllowedFieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.PartialAllowedFieldExprContext,0)


        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExprAndTree" ):
                listener.enterExprAndTree(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExprAndTree" ):
                listener.exitExprAndTree(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprAndTree" ):
                return visitor.visitExprAndTree(self)
            else:
                return visitor.visitChildren(self)


    class ExprCastContext(FieldExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.FieldExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def CAST(self):
            return self.getToken(MalloyParser.CAST, 0)
        def OPAREN(self):
            return self.getToken(MalloyParser.OPAREN, 0)
        def fieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.FieldExprContext,0)

        def AS(self):
            return self.getToken(MalloyParser.AS, 0)
        def malloyOrSQLType(self):
            return self.getTypedRuleContext(MalloyParser.MalloyOrSQLTypeContext,0)

        def CPAREN(self):
            return self.getToken(MalloyParser.CPAREN, 0)
        def DOUBLECOLON(self):
            return self.getToken(MalloyParser.DOUBLECOLON, 0)

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExprCast" ):
                listener.enterExprCast(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExprCast" ):
                listener.exitExprCast(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprCast" ):
                return visitor.visitExprCast(self)
            else:
                return visitor.visitChildren(self)


    class ExprAggFuncContext(FieldExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.FieldExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def fieldPath(self):
            return self.getTypedRuleContext(MalloyParser.FieldPathContext,0)

        def DOT(self):
            return self.getToken(MalloyParser.DOT, 0)
        def id_(self):
            return self.getTypedRuleContext(MalloyParser.IdContext,0)

        def OPAREN(self):
            return self.getToken(MalloyParser.OPAREN, 0)
        def CPAREN(self):
            return self.getToken(MalloyParser.CPAREN, 0)
        def argumentList(self):
            return self.getTypedRuleContext(MalloyParser.ArgumentListContext,0)


        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExprAggFunc" ):
                listener.enterExprAggFunc(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExprAggFunc" ):
                listener.exitExprAggFunc(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprAggFunc" ):
                return visitor.visitExprAggFunc(self)
            else:
                return visitor.visitChildren(self)


    class ExprTimeTruncContext(FieldExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.FieldExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def fieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.FieldExprContext,0)

        def DOT(self):
            return self.getToken(MalloyParser.DOT, 0)
        def timeframe(self):
            return self.getTypedRuleContext(MalloyParser.TimeframeContext,0)


        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExprTimeTrunc" ):
                listener.enterExprTimeTrunc(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExprTimeTrunc" ):
                listener.exitExprTimeTrunc(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprTimeTrunc" ):
                return visitor.visitExprTimeTrunc(self)
            else:
                return visitor.visitChildren(self)


    class ExprAggregateContext(FieldExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.FieldExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def fieldPath(self):
            return self.getTypedRuleContext(MalloyParser.FieldPathContext,0)

        def DOT(self):
            return self.getToken(MalloyParser.DOT, 0)
        def aggregate(self):
            return self.getTypedRuleContext(MalloyParser.AggregateContext,0)

        def OPAREN(self):
            return self.getToken(MalloyParser.OPAREN, 0)
        def CPAREN(self):
            return self.getToken(MalloyParser.CPAREN, 0)
        def fieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.FieldExprContext,0)


        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExprAggregate" ):
                listener.enterExprAggregate(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExprAggregate" ):
                listener.exitExprAggregate(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprAggregate" ):
                return visitor.visitExprAggregate(self)
            else:
                return visitor.visitChildren(self)


    class ExprLogicalAndContext(FieldExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.FieldExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def fieldExpr(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.FieldExprContext)
            else:
                return self.getTypedRuleContext(MalloyParser.FieldExprContext,i)

        def AND(self):
            return self.getToken(MalloyParser.AND, 0)

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExprLogicalAnd" ):
                listener.enterExprLogicalAnd(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExprLogicalAnd" ):
                listener.exitExprLogicalAnd(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprLogicalAnd" ):
                return visitor.visitExprLogicalAnd(self)
            else:
                return visitor.visitChildren(self)


    class ExprFieldPathContext(FieldExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.FieldExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def fieldPath(self):
            return self.getTypedRuleContext(MalloyParser.FieldPathContext,0)


        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExprFieldPath" ):
                listener.enterExprFieldPath(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExprFieldPath" ):
                listener.exitExprFieldPath(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprFieldPath" ):
                return visitor.visitExprFieldPath(self)
            else:
                return visitor.visitChildren(self)


    class ExprMulDivContext(FieldExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.FieldExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def fieldExpr(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.FieldExprContext)
            else:
                return self.getTypedRuleContext(MalloyParser.FieldExprContext,i)

        def STAR(self):
            return self.getToken(MalloyParser.STAR, 0)
        def SLASH(self):
            return self.getToken(MalloyParser.SLASH, 0)
        def PERCENT(self):
            return self.getToken(MalloyParser.PERCENT, 0)

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExprMulDiv" ):
                listener.enterExprMulDiv(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExprMulDiv" ):
                listener.exitExprMulDiv(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprMulDiv" ):
                return visitor.visitExprMulDiv(self)
            else:
                return visitor.visitChildren(self)


    class ExprSafeCastContext(FieldExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.FieldExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def fieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.FieldExprContext,0)

        def TRIPLECOLON(self):
            return self.getToken(MalloyParser.TRIPLECOLON, 0)
        def malloyOrSQLType(self):
            return self.getTypedRuleContext(MalloyParser.MalloyOrSQLTypeContext,0)


        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExprSafeCast" ):
                listener.enterExprSafeCast(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExprSafeCast" ):
                listener.exitExprSafeCast(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprSafeCast" ):
                return visitor.visitExprSafeCast(self)
            else:
                return visitor.visitChildren(self)


    class ExprOrTreeContext(FieldExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.FieldExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def fieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.FieldExprContext,0)

        def BAR(self):
            return self.getToken(MalloyParser.BAR, 0)
        def partialAllowedFieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.PartialAllowedFieldExprContext,0)


        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExprOrTree" ):
                listener.enterExprOrTree(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExprOrTree" ):
                listener.exitExprOrTree(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprOrTree" ):
                return visitor.visitExprOrTree(self)
            else:
                return visitor.visitChildren(self)


    class ExprNotContext(FieldExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.FieldExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def NOT(self):
            return self.getToken(MalloyParser.NOT, 0)
        def fieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.FieldExprContext,0)


        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExprNot" ):
                listener.enterExprNot(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExprNot" ):
                listener.exitExprNot(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprNot" ):
                return visitor.visitExprNot(self)
            else:
                return visitor.visitChildren(self)


    class ExprDurationContext(FieldExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.FieldExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def fieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.FieldExprContext,0)

        def timeframe(self):
            return self.getTypedRuleContext(MalloyParser.TimeframeContext,0)


        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExprDuration" ):
                listener.enterExprDuration(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExprDuration" ):
                listener.exitExprDuration(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprDuration" ):
                return visitor.visitExprDuration(self)
            else:
                return visitor.visitChildren(self)


    class ExprApplyContext(FieldExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.FieldExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def fieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.FieldExprContext,0)

        def QMARK(self):
            return self.getToken(MalloyParser.QMARK, 0)
        def partialAllowedFieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.PartialAllowedFieldExprContext,0)


        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExprApply" ):
                listener.enterExprApply(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExprApply" ):
                listener.exitExprApply(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprApply" ):
                return visitor.visitExprApply(self)
            else:
                return visitor.visitChildren(self)


    class ExprWarnLikeContext(FieldExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.FieldExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def fieldExpr(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.FieldExprContext)
            else:
                return self.getTypedRuleContext(MalloyParser.FieldExprContext,i)

        def LIKE(self):
            return self.getToken(MalloyParser.LIKE, 0)
        def NOT(self):
            return self.getToken(MalloyParser.NOT, 0)

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExprWarnLike" ):
                listener.enterExprWarnLike(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExprWarnLike" ):
                listener.exitExprWarnLike(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprWarnLike" ):
                return visitor.visitExprWarnLike(self)
            else:
                return visitor.visitChildren(self)


    class ExprFieldPropsContext(FieldExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.FieldExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def fieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.FieldExprContext,0)

        def fieldProperties(self):
            return self.getTypedRuleContext(MalloyParser.FieldPropertiesContext,0)


        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExprFieldProps" ):
                listener.enterExprFieldProps(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExprFieldProps" ):
                listener.exitExprFieldProps(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprFieldProps" ):
                return visitor.visitExprFieldProps(self)
            else:
                return visitor.visitChildren(self)


    class ExprCoalesceContext(FieldExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.FieldExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def fieldExpr(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.FieldExprContext)
            else:
                return self.getTypedRuleContext(MalloyParser.FieldExprContext,i)

        def DOUBLE_QMARK(self):
            return self.getToken(MalloyParser.DOUBLE_QMARK, 0)

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExprCoalesce" ):
                listener.enterExprCoalesce(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExprCoalesce" ):
                listener.exitExprCoalesce(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprCoalesce" ):
                return visitor.visitExprCoalesce(self)
            else:
                return visitor.visitChildren(self)


    class ExprUngroupContext(FieldExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.FieldExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def ungroup(self):
            return self.getTypedRuleContext(MalloyParser.UngroupContext,0)

        def OPAREN(self):
            return self.getToken(MalloyParser.OPAREN, 0)
        def fieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.FieldExprContext,0)

        def CPAREN(self):
            return self.getToken(MalloyParser.CPAREN, 0)
        def COMMA(self, i:int=None):
            if i is None:
                return self.getTokens(MalloyParser.COMMA)
            else:
                return self.getToken(MalloyParser.COMMA, i)
        def fieldName(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.FieldNameContext)
            else:
                return self.getTypedRuleContext(MalloyParser.FieldNameContext,i)


        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExprUngroup" ):
                listener.enterExprUngroup(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExprUngroup" ):
                listener.exitExprUngroup(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprUngroup" ):
                return visitor.visitExprUngroup(self)
            else:
                return visitor.visitChildren(self)


    class ExprLiteralRecordContext(FieldExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.FieldExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def OCURLY(self):
            return self.getToken(MalloyParser.OCURLY, 0)
        def recordElement(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.RecordElementContext)
            else:
                return self.getTypedRuleContext(MalloyParser.RecordElementContext,i)

        def CCURLY(self):
            return self.getToken(MalloyParser.CCURLY, 0)
        def COMMA(self, i:int=None):
            if i is None:
                return self.getTokens(MalloyParser.COMMA)
            else:
                return self.getToken(MalloyParser.COMMA, i)

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExprLiteralRecord" ):
                listener.enterExprLiteralRecord(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExprLiteralRecord" ):
                listener.exitExprLiteralRecord(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprLiteralRecord" ):
                return visitor.visitExprLiteralRecord(self)
            else:
                return visitor.visitChildren(self)


    class ExprWarnInContext(FieldExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.FieldExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def fieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.FieldExprContext,0)

        def IN(self):
            return self.getToken(MalloyParser.IN, 0)
        def OPAREN(self):
            return self.getToken(MalloyParser.OPAREN, 0)
        def fieldExprList(self):
            return self.getTypedRuleContext(MalloyParser.FieldExprListContext,0)

        def CPAREN(self):
            return self.getToken(MalloyParser.CPAREN, 0)
        def NOT(self):
            return self.getToken(MalloyParser.NOT, 0)

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExprWarnIn" ):
                listener.enterExprWarnIn(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExprWarnIn" ):
                listener.exitExprWarnIn(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprWarnIn" ):
                return visitor.visitExprWarnIn(self)
            else:
                return visitor.visitChildren(self)


    class ExprPickContext(FieldExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.FieldExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def pickStatement(self):
            return self.getTypedRuleContext(MalloyParser.PickStatementContext,0)


        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExprPick" ):
                listener.enterExprPick(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExprPick" ):
                listener.exitExprPick(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprPick" ):
                return visitor.visitExprPick(self)
            else:
                return visitor.visitChildren(self)


    class ExprPathlessAggregateContext(FieldExprContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.FieldExprContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def aggregate(self):
            return self.getTypedRuleContext(MalloyParser.AggregateContext,0)

        def OPAREN(self):
            return self.getToken(MalloyParser.OPAREN, 0)
        def CPAREN(self):
            return self.getToken(MalloyParser.CPAREN, 0)
        def SOURCE_KW(self):
            return self.getToken(MalloyParser.SOURCE_KW, 0)
        def DOT(self):
            return self.getToken(MalloyParser.DOT, 0)
        def fieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.FieldExprContext,0)


        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExprPathlessAggregate" ):
                listener.enterExprPathlessAggregate(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExprPathlessAggregate" ):
                listener.exitExprPathlessAggregate(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExprPathlessAggregate" ):
                return visitor.visitExprPathlessAggregate(self)
            else:
                return visitor.visitChildren(self)



    def fieldExpr(self, _p:int=0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = MalloyParser.FieldExprContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 256
        self.enterRecursionRule(localctx, 256, self.RULE_fieldExpr, _p)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1340
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,142,self._ctx)
            if la_ == 1:
                localctx = MalloyParser.ExprFieldPathContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx

                self.state = 1239
                self.fieldPath()
                pass

            elif la_ == 2:
                localctx = MalloyParser.ExprLiteralContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 1240
                self.literal()
                pass

            elif la_ == 3:
                localctx = MalloyParser.ExprArrayLiteralContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 1241
                self.match(MalloyParser.OBRACK)
                self.state = 1242
                self.fieldExpr(0)
                self.state = 1247
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,130,self._ctx)
                while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                    if _alt==1:
                        self.state = 1243
                        self.match(MalloyParser.COMMA)
                        self.state = 1244
                        self.fieldExpr(0) 
                    self.state = 1249
                    self._errHandler.sync(self)
                    _alt = self._interp.adaptivePredict(self._input,130,self._ctx)

                self.state = 1251
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==135:
                    self.state = 1250
                    self.match(MalloyParser.COMMA)


                self.state = 1253
                self.match(MalloyParser.CBRACK)
                pass

            elif la_ == 4:
                localctx = MalloyParser.ExprLiteralRecordContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 1255
                self.match(MalloyParser.OCURLY)
                self.state = 1256
                self.recordElement()
                self.state = 1261
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while _la==135:
                    self.state = 1257
                    self.match(MalloyParser.COMMA)
                    self.state = 1258
                    self.recordElement()
                    self.state = 1263
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)

                self.state = 1264
                self.match(MalloyParser.CCURLY)
                pass

            elif la_ == 5:
                localctx = MalloyParser.ExprMinusContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 1266
                self.match(MalloyParser.MINUS)
                self.state = 1267
                self.fieldExpr(25)
                pass

            elif la_ == 6:
                localctx = MalloyParser.ExprNotContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 1268
                self.match(MalloyParser.NOT)
                self.state = 1269
                self.fieldExpr(13)
                pass

            elif la_ == 7:
                localctx = MalloyParser.ExprCastContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 1270
                self.match(MalloyParser.CAST)
                self.state = 1271
                self.match(MalloyParser.OPAREN)
                self.state = 1272
                self.fieldExpr(0)
                self.state = 1273
                self.match(MalloyParser.AS)
                self.state = 1274
                self.malloyOrSQLType()
                self.state = 1275
                self.match(MalloyParser.CPAREN)
                pass

            elif la_ == 8:
                localctx = MalloyParser.ExprPathlessAggregateContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 1279
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==92:
                    self.state = 1277
                    self.match(MalloyParser.SOURCE_KW)
                    self.state = 1278
                    self.match(MalloyParser.DOT)


                self.state = 1281
                self.aggregate()
                self.state = 1282
                self.match(MalloyParser.OPAREN)
                self.state = 1284
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if (((_la) & ~0x3f) == 0 and ((1 << _la) & 362931471020720128) != 0) or ((((_la - 64)) & ~0x3f) == 0 and ((1 << (_la - 64)) & -6845483939656370175) != 0) or ((((_la - 129)) & ~0x3f) == 0 and ((1 << (_la - 129)) & 1219703635969) != 0):
                    self.state = 1283
                    self.fieldExpr(0)


                self.state = 1286
                self.match(MalloyParser.CPAREN)
                pass

            elif la_ == 9:
                localctx = MalloyParser.ExprAggregateContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 1288
                self.fieldPath()
                self.state = 1289
                self.match(MalloyParser.DOT)
                self.state = 1290
                self.aggregate()
                self.state = 1291
                self.match(MalloyParser.OPAREN)
                self.state = 1293
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if (((_la) & ~0x3f) == 0 and ((1 << _la) & 362931471020720128) != 0) or ((((_la - 64)) & ~0x3f) == 0 and ((1 << (_la - 64)) & -6845483939656370175) != 0) or ((((_la - 129)) & ~0x3f) == 0 and ((1 << (_la - 129)) & 1219703635969) != 0):
                    self.state = 1292
                    self.fieldExpr(0)


                self.state = 1295
                self.match(MalloyParser.CPAREN)
                pass

            elif la_ == 10:
                localctx = MalloyParser.ExprExprContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 1297
                self.match(MalloyParser.OPAREN)
                self.state = 1298
                self.fieldExpr(0)
                self.state = 1299
                self.match(MalloyParser.CPAREN)
                pass

            elif la_ == 11:
                localctx = MalloyParser.ExprAggFuncContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 1301
                self.fieldPath()
                self.state = 1302
                self.match(MalloyParser.DOT)
                self.state = 1303
                self.id_()
                self.state = 1304
                self.match(MalloyParser.OPAREN)

                self.state = 1306
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if (((_la) & ~0x3f) == 0 and ((1 << _la) & 362931471020720128) != 0) or ((((_la - 64)) & ~0x3f) == 0 and ((1 << (_la - 64)) & -6845483939656370175) != 0) or ((((_la - 129)) & ~0x3f) == 0 and ((1 << (_la - 129)) & 1219703635969) != 0):
                    self.state = 1305
                    self.argumentList()


                self.state = 1308
                self.match(MalloyParser.CPAREN)
                pass

            elif la_ == 12:
                localctx = MalloyParser.ExprFuncContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 1318
                self._errHandler.sync(self)
                token = self._input.LA(1)
                if token in [119, 162]:
                    self.state = 1310
                    self.id_()
                    self.state = 1315
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)
                    if _la==133:
                        self.state = 1311
                        self.match(MalloyParser.EXCLAM)
                        self.state = 1313
                        self._errHandler.sync(self)
                        _la = self._input.LA(1)
                        if ((((_la - 43)) & ~0x3f) == 0 and ((1 << (_la - 43)) & 108368415789416577) != 0):
                            self.state = 1312
                            self.malloyType()




                    pass
                elif token in [51, 64, 77, 78, 88, 90, 103, 106]:
                    self.state = 1317
                    self.timeframe()
                    pass
                else:
                    raise NoViableAltException(self)

                self.state = 1320
                self.match(MalloyParser.OPAREN)

                self.state = 1322
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if (((_la) & ~0x3f) == 0 and ((1 << _la) & 362931471020720128) != 0) or ((((_la - 64)) & ~0x3f) == 0 and ((1 << (_la - 64)) & -6845483939656370175) != 0) or ((((_la - 129)) & ~0x3f) == 0 and ((1 << (_la - 129)) & 1219703635969) != 0):
                    self.state = 1321
                    self.argumentList()


                self.state = 1324
                self.match(MalloyParser.CPAREN)
                pass

            elif la_ == 13:
                localctx = MalloyParser.ExprPickContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 1326
                self.pickStatement()
                pass

            elif la_ == 14:
                localctx = MalloyParser.ExprCaseContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 1327
                self.caseStatement()
                pass

            elif la_ == 15:
                localctx = MalloyParser.ExprUngroupContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 1328
                self.ungroup()
                self.state = 1329
                self.match(MalloyParser.OPAREN)
                self.state = 1330
                self.fieldExpr(0)
                self.state = 1335
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while _la==135:
                    self.state = 1331
                    self.match(MalloyParser.COMMA)
                    self.state = 1332
                    self.fieldName()
                    self.state = 1337
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)

                self.state = 1338
                self.match(MalloyParser.CPAREN)
                pass


            self._ctx.stop = self._input.LT(-1)
            self.state = 1414
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,147,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 = 1412
                    self._errHandler.sync(self)
                    la_ = self._interp.adaptivePredict(self._input,146,self._ctx)
                    if la_ == 1:
                        localctx = MalloyParser.ExprMulDivContext(self, MalloyParser.FieldExprContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_fieldExpr)
                        self.state = 1342
                        if not self.precpred(self._ctx, 24):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 24)")
                        self.state = 1343
                        _la = self._input.LA(1)
                        if not(((((_la - 145)) & ~0x3f) == 0 and ((1 << (_la - 145)) & 133) != 0)):
                            self._errHandler.recoverInline(self)
                        else:
                            self._errHandler.reportMatch(self)
                            self.consume()
                        self.state = 1344
                        self.fieldExpr(25)
                        pass

                    elif la_ == 2:
                        localctx = MalloyParser.ExprAddSubContext(self, MalloyParser.FieldExprContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_fieldExpr)
                        self.state = 1345
                        if not self.precpred(self._ctx, 23):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 23)")
                        self.state = 1346
                        _la = self._input.LA(1)
                        if not(_la==143 or _la==144):
                            self._errHandler.recoverInline(self)
                        else:
                            self._errHandler.reportMatch(self)
                            self.consume()
                        self.state = 1347
                        self.fieldExpr(24)
                        pass

                    elif la_ == 3:
                        localctx = MalloyParser.ExprRangeContext(self, MalloyParser.FieldExprContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_fieldExpr)
                        self.state = 1348
                        if not self.precpred(self._ctx, 22):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 22)")
                        self.state = 1349
                        self.match(MalloyParser.TO)
                        self.state = 1350
                        self.fieldExpr(23)
                        pass

                    elif la_ == 4:
                        localctx = MalloyParser.ExprCompareContext(self, MalloyParser.FieldExprContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_fieldExpr)
                        self.state = 1351
                        if not self.precpred(self._ctx, 18):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 18)")
                        self.state = 1352
                        self.compareOp()
                        self.state = 1353
                        self.fieldExpr(19)
                        pass

                    elif la_ == 5:
                        localctx = MalloyParser.ExprWarnLikeContext(self, MalloyParser.FieldExprContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_fieldExpr)
                        self.state = 1355
                        if not self.precpred(self._ctx, 17):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 17)")
                        self.state = 1357
                        self._errHandler.sync(self)
                        _la = self._input.LA(1)
                        if _la==79:
                            self.state = 1356
                            self.match(MalloyParser.NOT)


                        self.state = 1359
                        self.match(MalloyParser.LIKE)
                        self.state = 1360
                        self.fieldExpr(18)
                        pass

                    elif la_ == 6:
                        localctx = MalloyParser.ExprLogicalAndContext(self, MalloyParser.FieldExprContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_fieldExpr)
                        self.state = 1361
                        if not self.precpred(self._ctx, 12):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 12)")
                        self.state = 1362
                        self.match(MalloyParser.AND)
                        self.state = 1363
                        self.fieldExpr(13)
                        pass

                    elif la_ == 7:
                        localctx = MalloyParser.ExprLogicalOrContext(self, MalloyParser.FieldExprContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_fieldExpr)
                        self.state = 1364
                        if not self.precpred(self._ctx, 11):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 11)")
                        self.state = 1365
                        self.match(MalloyParser.OR)
                        self.state = 1366
                        self.fieldExpr(12)
                        pass

                    elif la_ == 8:
                        localctx = MalloyParser.ExprCoalesceContext(self, MalloyParser.FieldExprContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_fieldExpr)
                        self.state = 1367
                        if not self.precpred(self._ctx, 10):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 10)")
                        self.state = 1368
                        self.match(MalloyParser.DOUBLE_QMARK)
                        self.state = 1369
                        self.fieldExpr(11)
                        pass

                    elif la_ == 9:
                        localctx = MalloyParser.ExprFieldPropsContext(self, MalloyParser.FieldExprContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_fieldExpr)
                        self.state = 1370
                        if not self.precpred(self._ctx, 30):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 30)")
                        self.state = 1371
                        self.fieldProperties()
                        pass

                    elif la_ == 10:
                        localctx = MalloyParser.ExprDurationContext(self, MalloyParser.FieldExprContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_fieldExpr)
                        self.state = 1372
                        if not self.precpred(self._ctx, 29):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 29)")
                        self.state = 1373
                        self.timeframe()
                        pass

                    elif la_ == 11:
                        localctx = MalloyParser.ExprTimeTruncContext(self, MalloyParser.FieldExprContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_fieldExpr)
                        self.state = 1374
                        if not self.precpred(self._ctx, 28):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 28)")
                        self.state = 1375
                        self.match(MalloyParser.DOT)
                        self.state = 1376
                        self.timeframe()
                        pass

                    elif la_ == 12:
                        localctx = MalloyParser.ExprCastContext(self, MalloyParser.FieldExprContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_fieldExpr)
                        self.state = 1377
                        if not self.precpred(self._ctx, 27):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 27)")
                        self.state = 1378
                        self.match(MalloyParser.DOUBLECOLON)
                        self.state = 1379
                        self.malloyOrSQLType()
                        pass

                    elif la_ == 13:
                        localctx = MalloyParser.ExprSafeCastContext(self, MalloyParser.FieldExprContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_fieldExpr)
                        self.state = 1380
                        if not self.precpred(self._ctx, 26):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 26)")
                        self.state = 1381
                        self.match(MalloyParser.TRIPLECOLON)
                        self.state = 1382
                        self.malloyOrSQLType()
                        pass

                    elif la_ == 14:
                        localctx = MalloyParser.ExprForRangeContext(self, MalloyParser.FieldExprContext(self, _parentctx, _parentState))
                        localctx.startAt = _prevctx
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_fieldExpr)
                        self.state = 1383
                        if not self.precpred(self._ctx, 21):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 21)")
                        self.state = 1384
                        self.match(MalloyParser.FOR)
                        self.state = 1385
                        localctx.duration = self.fieldExpr(0)
                        self.state = 1386
                        self.timeframe()
                        pass

                    elif la_ == 15:
                        localctx = MalloyParser.ExprAndTreeContext(self, MalloyParser.FieldExprContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_fieldExpr)
                        self.state = 1388
                        if not self.precpred(self._ctx, 20):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 20)")
                        self.state = 1389
                        self.match(MalloyParser.AMPER)
                        self.state = 1390
                        self.partialAllowedFieldExpr()
                        pass

                    elif la_ == 16:
                        localctx = MalloyParser.ExprOrTreeContext(self, MalloyParser.FieldExprContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_fieldExpr)
                        self.state = 1391
                        if not self.precpred(self._ctx, 19):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 19)")
                        self.state = 1392
                        self.match(MalloyParser.BAR)
                        self.state = 1393
                        self.partialAllowedFieldExpr()
                        pass

                    elif la_ == 17:
                        localctx = MalloyParser.ExprNullCheckContext(self, MalloyParser.FieldExprContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_fieldExpr)
                        self.state = 1394
                        if not self.precpred(self._ctx, 16):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 16)")
                        self.state = 1395
                        self.match(MalloyParser.IS)
                        self.state = 1397
                        self._errHandler.sync(self)
                        _la = self._input.LA(1)
                        if _la==79:
                            self.state = 1396
                            self.match(MalloyParser.NOT)


                        self.state = 1399
                        self.match(MalloyParser.NULL)
                        pass

                    elif la_ == 18:
                        localctx = MalloyParser.ExprWarnInContext(self, MalloyParser.FieldExprContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_fieldExpr)
                        self.state = 1400
                        if not self.precpred(self._ctx, 15):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 15)")
                        self.state = 1402
                        self._errHandler.sync(self)
                        _la = self._input.LA(1)
                        if _la==79:
                            self.state = 1401
                            self.match(MalloyParser.NOT)


                        self.state = 1404
                        self.match(MalloyParser.IN)
                        self.state = 1405
                        self.match(MalloyParser.OPAREN)
                        self.state = 1406
                        self.fieldExprList()
                        self.state = 1407
                        self.match(MalloyParser.CPAREN)
                        pass

                    elif la_ == 19:
                        localctx = MalloyParser.ExprApplyContext(self, MalloyParser.FieldExprContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_fieldExpr)
                        self.state = 1409
                        if not self.precpred(self._ctx, 14):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 14)")
                        self.state = 1410
                        self.match(MalloyParser.QMARK)
                        self.state = 1411
                        self.partialAllowedFieldExpr()
                        pass

             
                self.state = 1416
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,147,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 PartialCompareContext(ParserRuleContext):
        __slots__ = 'parser'

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def compareOp(self):
            return self.getTypedRuleContext(MalloyParser.CompareOpContext,0)


        def fieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.FieldExprContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_partialCompare

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterPartialCompare" ):
                listener.enterPartialCompare(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitPartialCompare" ):
                listener.exitPartialCompare(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitPartialCompare" ):
                return visitor.visitPartialCompare(self)
            else:
                return visitor.visitChildren(self)




    def partialCompare(self):

        localctx = MalloyParser.PartialCompareContext(self, self._ctx, self.state)
        self.enterRule(localctx, 258, self.RULE_partialCompare)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1417
            self.compareOp()
            self.state = 1418
            self.fieldExpr(0)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class PartialTestContext(ParserRuleContext):
        __slots__ = 'parser'

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def partialCompare(self):
            return self.getTypedRuleContext(MalloyParser.PartialCompareContext,0)


        def IS(self):
            return self.getToken(MalloyParser.IS, 0)

        def NULL(self):
            return self.getToken(MalloyParser.NULL, 0)

        def NOT(self):
            return self.getToken(MalloyParser.NOT, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_partialTest

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterPartialTest" ):
                listener.enterPartialTest(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitPartialTest" ):
                listener.exitPartialTest(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitPartialTest" ):
                return visitor.visitPartialTest(self)
            else:
                return visitor.visitChildren(self)




    def partialTest(self):

        localctx = MalloyParser.PartialTestContext(self, self._ctx, self.state)
        self.enterRule(localctx, 260, self.RULE_partialTest)
        self._la = 0 # Token type
        try:
            self.state = 1426
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [137, 138, 139, 140, 141, 142, 150, 151]:
                self.enterOuterAlt(localctx, 1)
                self.state = 1420
                self.partialCompare()
                pass
            elif token in [68]:
                self.enterOuterAlt(localctx, 2)
                self.state = 1421
                self.match(MalloyParser.IS)
                self.state = 1423
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==79:
                    self.state = 1422
                    self.match(MalloyParser.NOT)


                self.state = 1425
                self.match(MalloyParser.NULL)
                pass
            else:
                raise NoViableAltException(self)

        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class PartialAllowedFieldExprContext(ParserRuleContext):
        __slots__ = 'parser'

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def partialTest(self):
            return self.getTypedRuleContext(MalloyParser.PartialTestContext,0)


        def OPAREN(self):
            return self.getToken(MalloyParser.OPAREN, 0)

        def CPAREN(self):
            return self.getToken(MalloyParser.CPAREN, 0)

        def fieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.FieldExprContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_partialAllowedFieldExpr

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterPartialAllowedFieldExpr" ):
                listener.enterPartialAllowedFieldExpr(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitPartialAllowedFieldExpr" ):
                listener.exitPartialAllowedFieldExpr(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitPartialAllowedFieldExpr" ):
                return visitor.visitPartialAllowedFieldExpr(self)
            else:
                return visitor.visitChildren(self)




    def partialAllowedFieldExpr(self):

        localctx = MalloyParser.PartialAllowedFieldExprContext(self, self._ctx, self.state)
        self.enterRule(localctx, 262, self.RULE_partialAllowedFieldExpr)
        try:
            self.state = 1434
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,150,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 1428
                self.partialTest()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 1429
                self.match(MalloyParser.OPAREN)
                self.state = 1430
                self.partialTest()
                self.state = 1431
                self.match(MalloyParser.CPAREN)
                pass

            elif la_ == 3:
                self.enterOuterAlt(localctx, 3)
                self.state = 1433
                self.fieldExpr(0)
                pass


        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class FieldExprListContext(ParserRuleContext):
        __slots__ = 'parser'

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def fieldExpr(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.FieldExprContext)
            else:
                return self.getTypedRuleContext(MalloyParser.FieldExprContext,i)


        def COMMA(self, i:int=None):
            if i is None:
                return self.getTokens(MalloyParser.COMMA)
            else:
                return self.getToken(MalloyParser.COMMA, i)

        def getRuleIndex(self):
            return MalloyParser.RULE_fieldExprList

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterFieldExprList" ):
                listener.enterFieldExprList(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitFieldExprList" ):
                listener.exitFieldExprList(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitFieldExprList" ):
                return visitor.visitFieldExprList(self)
            else:
                return visitor.visitChildren(self)




    def fieldExprList(self):

        localctx = MalloyParser.FieldExprListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 264, self.RULE_fieldExprList)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1436
            self.fieldExpr(0)
            self.state = 1441
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==135:
                self.state = 1437
                self.match(MalloyParser.COMMA)
                self.state = 1438
                self.fieldExpr(0)
                self.state = 1443
                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 PickStatementContext(ParserRuleContext):
        __slots__ = 'parser'

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser
            self.pickElse = None # FieldExprContext

        def pick(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.PickContext)
            else:
                return self.getTypedRuleContext(MalloyParser.PickContext,i)


        def ELSE(self):
            return self.getToken(MalloyParser.ELSE, 0)

        def fieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.FieldExprContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_pickStatement

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterPickStatement" ):
                listener.enterPickStatement(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitPickStatement" ):
                listener.exitPickStatement(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitPickStatement" ):
                return visitor.visitPickStatement(self)
            else:
                return visitor.visitChildren(self)




    def pickStatement(self):

        localctx = MalloyParser.PickStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 266, self.RULE_pickStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1445 
            self._errHandler.sync(self)
            _alt = 1
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt == 1:
                    self.state = 1444
                    self.pick()

                else:
                    raise NoViableAltException(self)
                self.state = 1447 
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,152,self._ctx)

            self.state = 1451
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,153,self._ctx)
            if la_ == 1:
                self.state = 1449
                self.match(MalloyParser.ELSE)
                self.state = 1450
                localctx.pickElse = self.fieldExpr(0)


        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class PickContext(ParserRuleContext):
        __slots__ = 'parser'

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser
            self.pickValue = None # FieldExprContext
            self.pickWhen = None # PartialAllowedFieldExprContext

        def PICK(self):
            return self.getToken(MalloyParser.PICK, 0)

        def WHEN(self):
            return self.getToken(MalloyParser.WHEN, 0)

        def partialAllowedFieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.PartialAllowedFieldExprContext,0)


        def fieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.FieldExprContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_pick

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterPick" ):
                listener.enterPick(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitPick" ):
                listener.exitPick(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitPick" ):
                return visitor.visitPick(self)
            else:
                return visitor.visitChildren(self)




    def pick(self):

        localctx = MalloyParser.PickContext(self, self._ctx, self.state)
        self.enterRule(localctx, 268, self.RULE_pick)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1453
            self.match(MalloyParser.PICK)
            self.state = 1455
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if (((_la) & ~0x3f) == 0 and ((1 << _la) & 362931471020720128) != 0) or ((((_la - 64)) & ~0x3f) == 0 and ((1 << (_la - 64)) & -6845483939656370175) != 0) or ((((_la - 129)) & ~0x3f) == 0 and ((1 << (_la - 129)) & 1219703635969) != 0):
                self.state = 1454
                localctx.pickValue = self.fieldExpr(0)


            self.state = 1457
            self.match(MalloyParser.WHEN)
            self.state = 1458
            localctx.pickWhen = self.partialAllowedFieldExpr()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class CaseStatementContext(ParserRuleContext):
        __slots__ = 'parser'

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser
            self.valueExpr = None # FieldExprContext
            self.caseElse = None # FieldExprContext

        def CASE(self):
            return self.getToken(MalloyParser.CASE, 0)

        def END(self):
            return self.getToken(MalloyParser.END, 0)

        def caseWhen(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.CaseWhenContext)
            else:
                return self.getTypedRuleContext(MalloyParser.CaseWhenContext,i)


        def ELSE(self):
            return self.getToken(MalloyParser.ELSE, 0)

        def fieldExpr(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.FieldExprContext)
            else:
                return self.getTypedRuleContext(MalloyParser.FieldExprContext,i)


        def getRuleIndex(self):
            return MalloyParser.RULE_caseStatement

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterCaseStatement" ):
                listener.enterCaseStatement(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitCaseStatement" ):
                listener.exitCaseStatement(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitCaseStatement" ):
                return visitor.visitCaseStatement(self)
            else:
                return visitor.visitChildren(self)




    def caseStatement(self):

        localctx = MalloyParser.CaseStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 270, self.RULE_caseStatement)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1460
            self.match(MalloyParser.CASE)
            self.state = 1462
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if (((_la) & ~0x3f) == 0 and ((1 << _la) & 362931471020720128) != 0) or ((((_la - 64)) & ~0x3f) == 0 and ((1 << (_la - 64)) & -6845483939656370175) != 0) or ((((_la - 129)) & ~0x3f) == 0 and ((1 << (_la - 129)) & 1219703635969) != 0):
                self.state = 1461
                localctx.valueExpr = self.fieldExpr(0)


            self.state = 1465 
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 1464
                self.caseWhen()
                self.state = 1467 
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not (_la==104):
                    break

            self.state = 1471
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==54:
                self.state = 1469
                self.match(MalloyParser.ELSE)
                self.state = 1470
                localctx.caseElse = self.fieldExpr(0)


            self.state = 1473
            self.match(MalloyParser.END)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class CaseWhenContext(ParserRuleContext):
        __slots__ = 'parser'

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser
            self.condition = None # FieldExprContext
            self.result = None # FieldExprContext

        def WHEN(self):
            return self.getToken(MalloyParser.WHEN, 0)

        def THEN(self):
            return self.getToken(MalloyParser.THEN, 0)

        def fieldExpr(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.FieldExprContext)
            else:
                return self.getTypedRuleContext(MalloyParser.FieldExprContext,i)


        def getRuleIndex(self):
            return MalloyParser.RULE_caseWhen

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterCaseWhen" ):
                listener.enterCaseWhen(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitCaseWhen" ):
                listener.exitCaseWhen(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitCaseWhen" ):
                return visitor.visitCaseWhen(self)
            else:
                return visitor.visitChildren(self)




    def caseWhen(self):

        localctx = MalloyParser.CaseWhenContext(self, self._ctx, self.state)
        self.enterRule(localctx, 272, self.RULE_caseWhen)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1475
            self.match(MalloyParser.WHEN)
            self.state = 1476
            localctx.condition = self.fieldExpr(0)
            self.state = 1477
            self.match(MalloyParser.THEN)
            self.state = 1478
            localctx.result = self.fieldExpr(0)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class RecordKeyContext(ParserRuleContext):
        __slots__ = 'parser'

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def id_(self):
            return self.getTypedRuleContext(MalloyParser.IdContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_recordKey

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterRecordKey" ):
                listener.enterRecordKey(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitRecordKey" ):
                listener.exitRecordKey(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitRecordKey" ):
                return visitor.visitRecordKey(self)
            else:
                return visitor.visitChildren(self)




    def recordKey(self):

        localctx = MalloyParser.RecordKeyContext(self, self._ctx, self.state)
        self.enterRule(localctx, 274, self.RULE_recordKey)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1480
            self.id_()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class RecordElementContext(ParserRuleContext):
        __slots__ = 'parser'

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser


        def getRuleIndex(self):
            return MalloyParser.RULE_recordElement

     
        def copyFrom(self, ctx:ParserRuleContext):
            super().copyFrom(ctx)



    class RecordExprContext(RecordElementContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.RecordElementContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def fieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.FieldExprContext,0)

        def recordKey(self):
            return self.getTypedRuleContext(MalloyParser.RecordKeyContext,0)

        def IS(self):
            return self.getToken(MalloyParser.IS, 0)

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterRecordExpr" ):
                listener.enterRecordExpr(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitRecordExpr" ):
                listener.exitRecordExpr(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitRecordExpr" ):
                return visitor.visitRecordExpr(self)
            else:
                return visitor.visitChildren(self)


    class RecordRefContext(RecordElementContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a MalloyParser.RecordElementContext
            super().__init__(parser)
            self.copyFrom(ctx)

        def fieldPath(self):
            return self.getTypedRuleContext(MalloyParser.FieldPathContext,0)


        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterRecordRef" ):
                listener.enterRecordRef(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitRecordRef" ):
                listener.exitRecordRef(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitRecordRef" ):
                return visitor.visitRecordRef(self)
            else:
                return visitor.visitChildren(self)



    def recordElement(self):

        localctx = MalloyParser.RecordElementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 276, self.RULE_recordElement)
        try:
            self.state = 1489
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,159,self._ctx)
            if la_ == 1:
                localctx = MalloyParser.RecordRefContext(self, localctx)
                self.enterOuterAlt(localctx, 1)
                self.state = 1482
                self.fieldPath()
                pass

            elif la_ == 2:
                localctx = MalloyParser.RecordExprContext(self, localctx)
                self.enterOuterAlt(localctx, 2)
                self.state = 1486
                self._errHandler.sync(self)
                la_ = self._interp.adaptivePredict(self._input,158,self._ctx)
                if la_ == 1:
                    self.state = 1483
                    self.recordKey()
                    self.state = 1484
                    self.match(MalloyParser.IS)


                self.state = 1488
                self.fieldExpr(0)
                pass


        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class ArgumentListContext(ParserRuleContext):
        __slots__ = 'parser'

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def fieldExpr(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.FieldExprContext)
            else:
                return self.getTypedRuleContext(MalloyParser.FieldExprContext,i)


        def COMMA(self, i:int=None):
            if i is None:
                return self.getTokens(MalloyParser.COMMA)
            else:
                return self.getToken(MalloyParser.COMMA, i)

        def getRuleIndex(self):
            return MalloyParser.RULE_argumentList

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterArgumentList" ):
                listener.enterArgumentList(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitArgumentList" ):
                listener.exitArgumentList(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitArgumentList" ):
                return visitor.visitArgumentList(self)
            else:
                return visitor.visitChildren(self)




    def argumentList(self):

        localctx = MalloyParser.ArgumentListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 278, self.RULE_argumentList)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1491
            self.fieldExpr(0)
            self.state = 1496
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,160,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 1492
                    self.match(MalloyParser.COMMA)
                    self.state = 1493
                    self.fieldExpr(0) 
                self.state = 1498
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,160,self._ctx)

            self.state = 1500
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==135:
                self.state = 1499
                self.match(MalloyParser.COMMA)


        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class FieldNameListContext(ParserRuleContext):
        __slots__ = 'parser'

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def fieldName(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.FieldNameContext)
            else:
                return self.getTypedRuleContext(MalloyParser.FieldNameContext,i)


        def COMMA(self, i:int=None):
            if i is None:
                return self.getTokens(MalloyParser.COMMA)
            else:
                return self.getToken(MalloyParser.COMMA, i)

        def getRuleIndex(self):
            return MalloyParser.RULE_fieldNameList

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterFieldNameList" ):
                listener.enterFieldNameList(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitFieldNameList" ):
                listener.exitFieldNameList(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitFieldNameList" ):
                return visitor.visitFieldNameList(self)
            else:
                return visitor.visitChildren(self)




    def fieldNameList(self):

        localctx = MalloyParser.FieldNameListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 280, self.RULE_fieldNameList)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1502
            self.fieldName()
            self.state = 1509
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,163,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 1504
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)
                    if _la==135:
                        self.state = 1503
                        self.match(MalloyParser.COMMA)


                    self.state = 1506
                    self.fieldName() 
                self.state = 1511
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,163,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 FieldCollectionContext(ParserRuleContext):
        __slots__ = 'parser'

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def collectionMember(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.CollectionMemberContext)
            else:
                return self.getTypedRuleContext(MalloyParser.CollectionMemberContext,i)


        def COMMA(self, i:int=None):
            if i is None:
                return self.getTokens(MalloyParser.COMMA)
            else:
                return self.getToken(MalloyParser.COMMA, i)

        def getRuleIndex(self):
            return MalloyParser.RULE_fieldCollection

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterFieldCollection" ):
                listener.enterFieldCollection(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitFieldCollection" ):
                listener.exitFieldCollection(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitFieldCollection" ):
                return visitor.visitFieldCollection(self)
            else:
                return visitor.visitChildren(self)




    def fieldCollection(self):

        localctx = MalloyParser.FieldCollectionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 282, self.RULE_fieldCollection)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1512
            self.collectionMember()
            self.state = 1519
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,165,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 1514
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)
                    if _la==135:
                        self.state = 1513
                        self.match(MalloyParser.COMMA)


                    self.state = 1516
                    self.collectionMember() 
                self.state = 1521
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,165,self._ctx)

            self.state = 1523
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==135:
                self.state = 1522
                self.match(MalloyParser.COMMA)


        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class CollectionWildCardContext(ParserRuleContext):
        __slots__ = 'parser'

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def STAR(self):
            return self.getToken(MalloyParser.STAR, 0)

        def fieldPath(self):
            return self.getTypedRuleContext(MalloyParser.FieldPathContext,0)


        def DOT(self):
            return self.getToken(MalloyParser.DOT, 0)

        def starQualified(self):
            return self.getTypedRuleContext(MalloyParser.StarQualifiedContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_collectionWildCard

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterCollectionWildCard" ):
                listener.enterCollectionWildCard(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitCollectionWildCard" ):
                listener.exitCollectionWildCard(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitCollectionWildCard" ):
                return visitor.visitCollectionWildCard(self)
            else:
                return visitor.visitChildren(self)




    def collectionWildCard(self):

        localctx = MalloyParser.CollectionWildCardContext(self, self._ctx, self.state)
        self.enterRule(localctx, 284, self.RULE_collectionWildCard)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1528
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==119 or _la==162:
                self.state = 1525
                self.fieldPath()
                self.state = 1526
                self.match(MalloyParser.DOT)


            self.state = 1530
            self.match(MalloyParser.STAR)
            self.state = 1532
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==129:
                self.state = 1531
                self.starQualified()


        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class StarQualifiedContext(ParserRuleContext):
        __slots__ = 'parser'

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def OCURLY(self):
            return self.getToken(MalloyParser.OCURLY, 0)

        def CCURLY(self):
            return self.getToken(MalloyParser.CCURLY, 0)

        def COMMA(self, i:int=None):
            if i is None:
                return self.getTokens(MalloyParser.COMMA)
            else:
                return self.getToken(MalloyParser.COMMA, i)

        def EXCEPT(self, i:int=None):
            if i is None:
                return self.getTokens(MalloyParser.EXCEPT)
            else:
                return self.getToken(MalloyParser.EXCEPT, i)

        def fieldNameList(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.FieldNameListContext)
            else:
                return self.getTypedRuleContext(MalloyParser.FieldNameListContext,i)


        def getRuleIndex(self):
            return MalloyParser.RULE_starQualified

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterStarQualified" ):
                listener.enterStarQualified(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitStarQualified" ):
                listener.exitStarQualified(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitStarQualified" ):
                return visitor.visitStarQualified(self)
            else:
                return visitor.visitChildren(self)




    def starQualified(self):

        localctx = MalloyParser.StarQualifiedContext(self, self._ctx, self.state)
        self.enterRule(localctx, 286, self.RULE_starQualified)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1534
            self.match(MalloyParser.OCURLY)
            self.state = 1538 
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 1538
                self._errHandler.sync(self)
                token = self._input.LA(1)
                if token in [9]:
                    self.state = 1535
                    self.match(MalloyParser.EXCEPT)
                    self.state = 1536
                    self.fieldNameList()
                    pass
                elif token in [135]:
                    self.state = 1537
                    self.match(MalloyParser.COMMA)
                    pass
                else:
                    raise NoViableAltException(self)

                self.state = 1540 
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not (_la==9 or _la==135):
                    break

            self.state = 1542
            self.match(MalloyParser.CCURLY)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class TaggedRefContext(ParserRuleContext):
        __slots__ = 'parser'

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def tags(self):
            return self.getTypedRuleContext(MalloyParser.TagsContext,0)


        def fieldPath(self):
            return self.getTypedRuleContext(MalloyParser.FieldPathContext,0)


        def refExpr(self):
            return self.getTypedRuleContext(MalloyParser.RefExprContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_taggedRef

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterTaggedRef" ):
                listener.enterTaggedRef(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitTaggedRef" ):
                listener.exitTaggedRef(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitTaggedRef" ):
                return visitor.visitTaggedRef(self)
            else:
                return visitor.visitChildren(self)




    def taggedRef(self):

        localctx = MalloyParser.TaggedRefContext(self, self._ctx, self.state)
        self.enterRule(localctx, 288, self.RULE_taggedRef)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1544
            self.tags()
            self.state = 1545
            self.fieldPath()
            self.state = 1547
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==136:
                self.state = 1546
                self.refExpr()


        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class RefExprContext(ParserRuleContext):
        __slots__ = 'parser'

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def DOT(self):
            return self.getToken(MalloyParser.DOT, 0)

        def timeframe(self):
            return self.getTypedRuleContext(MalloyParser.TimeframeContext,0)


        def aggregate(self):
            return self.getTypedRuleContext(MalloyParser.AggregateContext,0)


        def OPAREN(self):
            return self.getToken(MalloyParser.OPAREN, 0)

        def CPAREN(self):
            return self.getToken(MalloyParser.CPAREN, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_refExpr

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterRefExpr" ):
                listener.enterRefExpr(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitRefExpr" ):
                listener.exitRefExpr(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitRefExpr" ):
                return visitor.visitRefExpr(self)
            else:
                return visitor.visitChildren(self)




    def refExpr(self):

        localctx = MalloyParser.RefExprContext(self, self._ctx, self.state)
        self.enterRule(localctx, 290, self.RULE_refExpr)
        try:
            self.state = 1556
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,172,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 1549
                self.match(MalloyParser.DOT)
                self.state = 1550
                self.timeframe()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 1551
                self.match(MalloyParser.DOT)
                self.state = 1552
                self.aggregate()
                self.state = 1553
                self.match(MalloyParser.OPAREN)
                self.state = 1554
                self.match(MalloyParser.CPAREN)
                pass


        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class CollectionMemberContext(ParserRuleContext):
        __slots__ = 'parser'

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def taggedRef(self):
            return self.getTypedRuleContext(MalloyParser.TaggedRefContext,0)


        def collectionWildCard(self):
            return self.getTypedRuleContext(MalloyParser.CollectionWildCardContext,0)


        def fieldDef(self):
            return self.getTypedRuleContext(MalloyParser.FieldDefContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_collectionMember

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterCollectionMember" ):
                listener.enterCollectionMember(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitCollectionMember" ):
                listener.exitCollectionMember(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitCollectionMember" ):
                return visitor.visitCollectionMember(self)
            else:
                return visitor.visitChildren(self)




    def collectionMember(self):

        localctx = MalloyParser.CollectionMemberContext(self, self._ctx, self.state)
        self.enterRule(localctx, 292, self.RULE_collectionMember)
        try:
            self.state = 1561
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,173,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 1558
                self.taggedRef()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 1559
                self.collectionWildCard()
                pass

            elif la_ == 3:
                self.enterOuterAlt(localctx, 3)
                self.state = 1560
                self.fieldDef()
                pass


        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class FieldPathContext(ParserRuleContext):
        __slots__ = 'parser'

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def fieldName(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(MalloyParser.FieldNameContext)
            else:
                return self.getTypedRuleContext(MalloyParser.FieldNameContext,i)


        def DOT(self, i:int=None):
            if i is None:
                return self.getTokens(MalloyParser.DOT)
            else:
                return self.getToken(MalloyParser.DOT, i)

        def getRuleIndex(self):
            return MalloyParser.RULE_fieldPath

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterFieldPath" ):
                listener.enterFieldPath(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitFieldPath" ):
                listener.exitFieldPath(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitFieldPath" ):
                return visitor.visitFieldPath(self)
            else:
                return visitor.visitChildren(self)




    def fieldPath(self):

        localctx = MalloyParser.FieldPathContext(self, self._ctx, self.state)
        self.enterRule(localctx, 294, self.RULE_fieldPath)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1563
            self.fieldName()
            self.state = 1568
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,174,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 1564
                    self.match(MalloyParser.DOT)
                    self.state = 1565
                    self.fieldName() 
                self.state = 1570
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,174,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 JoinNameContext(ParserRuleContext):
        __slots__ = 'parser'

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def id_(self):
            return self.getTypedRuleContext(MalloyParser.IdContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_joinName

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterJoinName" ):
                listener.enterJoinName(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitJoinName" ):
                listener.exitJoinName(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitJoinName" ):
                return visitor.visitJoinName(self)
            else:
                return visitor.visitChildren(self)




    def joinName(self):

        localctx = MalloyParser.JoinNameContext(self, self._ctx, self.state)
        self.enterRule(localctx, 296, self.RULE_joinName)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1571
            self.id_()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class FieldNameContext(ParserRuleContext):
        __slots__ = 'parser'

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def id_(self):
            return self.getTypedRuleContext(MalloyParser.IdContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_fieldName

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterFieldName" ):
                listener.enterFieldName(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitFieldName" ):
                listener.exitFieldName(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitFieldName" ):
                return visitor.visitFieldName(self)
            else:
                return visitor.visitChildren(self)




    def fieldName(self):

        localctx = MalloyParser.FieldNameContext(self, self._ctx, self.state)
        self.enterRule(localctx, 298, self.RULE_fieldName)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1573
            self.id_()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class SqlExploreNameRefContext(ParserRuleContext):
        __slots__ = 'parser'

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def id_(self):
            return self.getTypedRuleContext(MalloyParser.IdContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_sqlExploreNameRef

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterSqlExploreNameRef" ):
                listener.enterSqlExploreNameRef(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitSqlExploreNameRef" ):
                listener.exitSqlExploreNameRef(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitSqlExploreNameRef" ):
                return visitor.visitSqlExploreNameRef(self)
            else:
                return visitor.visitChildren(self)




    def sqlExploreNameRef(self):

        localctx = MalloyParser.SqlExploreNameRefContext(self, self._ctx, self.state)
        self.enterRule(localctx, 300, self.RULE_sqlExploreNameRef)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1575
            self.id_()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class NameSQLBlockContext(ParserRuleContext):
        __slots__ = 'parser'

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def id_(self):
            return self.getTypedRuleContext(MalloyParser.IdContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_nameSQLBlock

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterNameSQLBlock" ):
                listener.enterNameSQLBlock(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitNameSQLBlock" ):
                listener.exitNameSQLBlock(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitNameSQLBlock" ):
                return visitor.visitNameSQLBlock(self)
            else:
                return visitor.visitChildren(self)




    def nameSQLBlock(self):

        localctx = MalloyParser.NameSQLBlockContext(self, self._ctx, self.state)
        self.enterRule(localctx, 302, self.RULE_nameSQLBlock)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1577
            self.id_()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class ConnectionNameContext(ParserRuleContext):
        __slots__ = 'parser'

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def string(self):
            return self.getTypedRuleContext(MalloyParser.StringContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_connectionName

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterConnectionName" ):
                listener.enterConnectionName(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitConnectionName" ):
                listener.exitConnectionName(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitConnectionName" ):
                return visitor.visitConnectionName(self)
            else:
                return visitor.visitChildren(self)




    def connectionName(self):

        localctx = MalloyParser.ConnectionNameContext(self, self._ctx, self.state)
        self.enterRule(localctx, 304, self.RULE_connectionName)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1579
            self.string()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class TripFilterStringContext(ParserRuleContext):
        __slots__ = 'parser'

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def SQ3_FILTER(self):
            return self.getToken(MalloyParser.SQ3_FILTER, 0)

        def BQ3_FILTER(self):
            return self.getToken(MalloyParser.BQ3_FILTER, 0)

        def DQ3_FILTER(self):
            return self.getToken(MalloyParser.DQ3_FILTER, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_tripFilterString

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterTripFilterString" ):
                listener.enterTripFilterString(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitTripFilterString" ):
                listener.exitTripFilterString(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitTripFilterString" ):
                return visitor.visitTripFilterString(self)
            else:
                return visitor.visitChildren(self)




    def tripFilterString(self):

        localctx = MalloyParser.TripFilterStringContext(self, self._ctx, self.state)
        self.enterRule(localctx, 306, self.RULE_tripFilterString)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1581
            _la = self._input.LA(1)
            if not(((((_la - 111)) & ~0x3f) == 0 and ((1 << (_la - 111)) & 21) != 0)):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class TickFilterStringContext(ParserRuleContext):
        __slots__ = 'parser'

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def SQ_FILTER(self):
            return self.getToken(MalloyParser.SQ_FILTER, 0)

        def BQ_FILTER(self):
            return self.getToken(MalloyParser.BQ_FILTER, 0)

        def DQ_FILTER(self):
            return self.getToken(MalloyParser.DQ_FILTER, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_tickFilterString

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterTickFilterString" ):
                listener.enterTickFilterString(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitTickFilterString" ):
                listener.exitTickFilterString(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitTickFilterString" ):
                return visitor.visitTickFilterString(self)
            else:
                return visitor.visitChildren(self)




    def tickFilterString(self):

        localctx = MalloyParser.TickFilterStringContext(self, self._ctx, self.state)
        self.enterRule(localctx, 308, self.RULE_tickFilterString)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1583
            _la = self._input.LA(1)
            if not(((((_la - 112)) & ~0x3f) == 0 and ((1 << (_la - 112)) & 21) != 0)):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class FilterStringContext(ParserRuleContext):
        __slots__ = 'parser'

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def tripFilterString(self):
            return self.getTypedRuleContext(MalloyParser.TripFilterStringContext,0)


        def tickFilterString(self):
            return self.getTypedRuleContext(MalloyParser.TickFilterStringContext,0)


        def getRuleIndex(self):
            return MalloyParser.RULE_filterString

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterFilterString" ):
                listener.enterFilterString(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitFilterString" ):
                listener.exitFilterString(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitFilterString" ):
                return visitor.visitFilterString(self)
            else:
                return visitor.visitChildren(self)




    def filterString(self):

        localctx = MalloyParser.FilterStringContext(self, self._ctx, self.state)
        self.enterRule(localctx, 310, self.RULE_filterString)
        try:
            self.state = 1587
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [111, 113, 115]:
                self.enterOuterAlt(localctx, 1)
                self.state = 1585
                self.tripFilterString()
                pass
            elif token in [112, 114, 116]:
                self.enterOuterAlt(localctx, 2)
                self.state = 1586
                self.tickFilterString()
                pass
            else:
                raise NoViableAltException(self)

        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class DebugExprContext(ParserRuleContext):
        __slots__ = 'parser'

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def fieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.FieldExprContext,0)


        def EOF(self):
            return self.getToken(MalloyParser.EOF, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_debugExpr

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterDebugExpr" ):
                listener.enterDebugExpr(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitDebugExpr" ):
                listener.exitDebugExpr(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitDebugExpr" ):
                return visitor.visitDebugExpr(self)
            else:
                return visitor.visitChildren(self)




    def debugExpr(self):

        localctx = MalloyParser.DebugExprContext(self, self._ctx, self.state)
        self.enterRule(localctx, 312, self.RULE_debugExpr)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1589
            self.fieldExpr(0)
            self.state = 1590
            self.match(MalloyParser.EOF)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class DebugPartialContext(ParserRuleContext):
        __slots__ = 'parser'

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def partialAllowedFieldExpr(self):
            return self.getTypedRuleContext(MalloyParser.PartialAllowedFieldExprContext,0)


        def EOF(self):
            return self.getToken(MalloyParser.EOF, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_debugPartial

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterDebugPartial" ):
                listener.enterDebugPartial(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitDebugPartial" ):
                listener.exitDebugPartial(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitDebugPartial" ):
                return visitor.visitDebugPartial(self)
            else:
                return visitor.visitChildren(self)




    def debugPartial(self):

        localctx = MalloyParser.DebugPartialContext(self, self._ctx, self.state)
        self.enterRule(localctx, 314, self.RULE_debugPartial)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1592
            self.partialAllowedFieldExpr()
            self.state = 1593
            self.match(MalloyParser.EOF)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class ExperimentalStatementForTestingContext(ParserRuleContext):
        __slots__ = 'parser'

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser

        def SEMI(self, i:int=None):
            if i is None:
                return self.getTokens(MalloyParser.SEMI)
            else:
                return self.getToken(MalloyParser.SEMI, i)

        def OBRACK(self):
            return self.getToken(MalloyParser.OBRACK, 0)

        def string(self):
            return self.getTypedRuleContext(MalloyParser.StringContext,0)


        def CBRACK(self):
            return self.getToken(MalloyParser.CBRACK, 0)

        def getRuleIndex(self):
            return MalloyParser.RULE_experimentalStatementForTesting

        def enterRule(self, listener:ParseTreeListener):
            if hasattr( listener, "enterExperimentalStatementForTesting" ):
                listener.enterExperimentalStatementForTesting(self)

        def exitRule(self, listener:ParseTreeListener):
            if hasattr( listener, "exitExperimentalStatementForTesting" ):
                listener.exitExperimentalStatementForTesting(self)

        def accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExperimentalStatementForTesting" ):
                return visitor.visitExperimentalStatementForTesting(self)
            else:
                return visitor.visitChildren(self)




    def experimentalStatementForTesting(self):

        localctx = MalloyParser.ExperimentalStatementForTestingContext(self, self._ctx, self.state)
        self.enterRule(localctx, 316, self.RULE_experimentalStatementForTesting)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 1595
            self.match(MalloyParser.SEMI)
            self.state = 1596
            self.match(MalloyParser.SEMI)
            self.state = 1597
            self.match(MalloyParser.OBRACK)
            self.state = 1598
            self.string()
            self.state = 1599
            self.match(MalloyParser.CBRACK)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx



    def sempred(self, localctx:RuleContext, ruleIndex:int, predIndex:int):
        if self._predicates == None:
            self._predicates = dict()
        self._predicates[53] = self.sqExpr_sempred
        self._predicates[62] = self.segExpr_sempred
        self._predicates[128] = self.fieldExpr_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 sqExpr_sempred(self, localctx:SqExprContext, predIndex:int):
            if predIndex == 0:
                return self.precpred(self._ctx, 6)
         

            if predIndex == 1:
                return self.precpred(self._ctx, 5)
         

            if predIndex == 2:
                return self.precpred(self._ctx, 4)
         

            if predIndex == 3:
                return self.precpred(self._ctx, 3)
         

    def segExpr_sempred(self, localctx:SegExprContext, predIndex:int):
            if predIndex == 4:
                return self.precpred(self._ctx, 1)
         

    def fieldExpr_sempred(self, localctx:FieldExprContext, predIndex:int):
            if predIndex == 5:
                return self.precpred(self._ctx, 24)
         

            if predIndex == 6:
                return self.precpred(self._ctx, 23)
         

            if predIndex == 7:
                return self.precpred(self._ctx, 22)
         

            if predIndex == 8:
                return self.precpred(self._ctx, 18)
         

            if predIndex == 9:
                return self.precpred(self._ctx, 17)
         

            if predIndex == 10:
                return self.precpred(self._ctx, 12)
         

            if predIndex == 11:
                return self.precpred(self._ctx, 11)
         

            if predIndex == 12:
                return self.precpred(self._ctx, 10)
         

            if predIndex == 13:
                return self.precpred(self._ctx, 30)
         

            if predIndex == 14:
                return self.precpred(self._ctx, 29)
         

            if predIndex == 15:
                return self.precpred(self._ctx, 28)
         

            if predIndex == 16:
                return self.precpred(self._ctx, 27)
         

            if predIndex == 17:
                return self.precpred(self._ctx, 26)
         

            if predIndex == 18:
                return self.precpred(self._ctx, 21)
         

            if predIndex == 19:
                return self.precpred(self._ctx, 20)
         

            if predIndex == 20:
                return self.precpred(self._ctx, 19)
         

            if predIndex == 21:
                return self.precpred(self._ctx, 16)
         

            if predIndex == 22:
                return self.precpred(self._ctx, 15)
         

            if predIndex == 23:
                return self.precpred(self._ctx, 14)
         




