# Generated from Quil.g4 by ANTLR 4.7.2
# encoding: utf-8
from antlr4 import *
from io import StringIO
from typing.io import TextIO
import sys


def serializedATN():
    with StringIO() as buf:
        buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3O")
        buf.write("\u0224\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7")
        buf.write("\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r\t\r\4\16")
        buf.write("\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22\4\23\t\23")
        buf.write("\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31")
        buf.write("\t\31\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36")
        buf.write("\4\37\t\37\4 \t \4!\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t")
        buf.write("&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4,\t,\4-\t-\4.\t.\4")
        buf.write("/\t/\4\60\t\60\4\61\t\61\4\62\t\62\4\63\t\63\4\64\t\64")
        buf.write("\4\65\t\65\4\66\t\66\4\67\t\67\48\t8\49\t9\3\2\5\2t\n")
        buf.write("\2\3\2\6\2w\n\2\r\2\16\2x\3\2\7\2|\n\2\f\2\16\2\177\13")
        buf.write("\2\3\2\7\2\u0082\n\2\f\2\16\2\u0085\13\2\3\2\3\2\3\3\3")
        buf.write("\3\3\3\3\3\5\3\u008d\n\3\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3")
        buf.write("\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\5\4\u00a1\n")
        buf.write("\4\3\5\7\5\u00a4\n\5\f\5\16\5\u00a7\13\5\3\5\3\5\3\5\3")
        buf.write("\5\3\5\7\5\u00ae\n\5\f\5\16\5\u00b1\13\5\3\5\3\5\5\5\u00b5")
        buf.write("\n\5\3\5\6\5\u00b8\n\5\r\5\16\5\u00b9\3\6\3\6\3\7\3\7")
        buf.write("\3\b\3\b\3\t\3\t\3\n\3\n\3\n\3\n\3\n\3\n\7\n\u00ca\n\n")
        buf.write("\f\n\16\n\u00cd\13\n\3\n\3\n\3\n\3\n\5\n\u00d3\n\n\3\n")
        buf.write("\3\n\3\n\3\n\3\13\3\13\3\13\3\13\3\13\3\13\7\13\u00df")
        buf.write("\n\13\f\13\16\13\u00e2\13\13\3\13\3\13\5\13\u00e6\n\13")
        buf.write("\3\13\6\13\u00e9\n\13\r\13\16\13\u00ea\3\13\3\13\3\13")
        buf.write("\3\13\3\13\3\13\3\f\3\f\3\f\3\r\3\r\3\16\3\16\3\16\7\16")
        buf.write("\u00fb\n\16\f\16\16\16\u00fe\13\16\3\16\3\16\3\17\3\17")
        buf.write("\3\17\3\17\7\17\u0106\n\17\f\17\16\17\u0109\13\17\3\20")
        buf.write("\3\20\3\20\7\20\u010e\n\20\f\20\16\20\u0111\13\20\3\20")
        buf.write("\3\20\3\21\3\21\3\21\3\21\3\21\3\21\6\21\u011b\n\21\r")
        buf.write("\21\16\21\u011c\3\22\3\22\3\22\3\22\3\22\3\22\7\22\u0125")
        buf.write("\n\22\f\22\16\22\u0128\13\22\3\22\3\22\5\22\u012c\n\22")
        buf.write("\3\22\7\22\u012f\n\22\f\22\16\22\u0132\13\22\3\22\3\22")
        buf.write("\3\22\3\22\3\23\3\23\3\24\3\24\5\24\u013c\n\24\3\25\3")
        buf.write("\25\3\25\3\25\3\25\7\25\u0143\n\25\f\25\16\25\u0146\13")
        buf.write("\25\3\25\3\25\5\25\u014a\n\25\3\25\6\25\u014d\n\25\r\25")
        buf.write("\16\25\u014e\3\26\3\26\3\26\5\26\u0154\n\26\3\27\3\27")
        buf.write("\5\27\u0158\n\27\3\30\3\30\3\30\3\30\5\30\u015e\n\30\3")
        buf.write("\31\3\31\3\31\3\31\7\31\u0164\n\31\f\31\16\31\u0167\13")
        buf.write("\31\3\31\3\31\3\31\3\32\3\32\3\32\5\32\u016f\n\32\3\33")
        buf.write("\3\33\5\33\u0173\n\33\3\33\3\33\3\33\5\33\u0178\n\33\3")
        buf.write("\34\3\34\3\34\3\35\3\35\3\35\3\36\3\36\3\37\3\37\3\37")
        buf.write("\3 \3 \3 \3 \3!\3!\3!\3!\3\"\3\"\5\"\u018f\n\"\3#\3#\3")
        buf.write("$\3$\3$\3$\3$\3$\5$\u0199\n$\3$\3$\3$\7$\u019e\n$\f$\16")
        buf.write("$\u01a1\13$\5$\u01a3\n$\3%\3%\3%\3%\3&\3&\3&\3\'\3\'\3")
        buf.write("\'\3\'\3\'\5\'\u01b1\n\'\3(\3(\3(\3(\5(\u01b7\n(\3)\3")
        buf.write(")\3)\3)\5)\u01bd\n)\3*\3*\3*\3*\5*\u01c3\n*\3+\3+\3+\3")
        buf.write("+\3,\3,\3,\3,\3-\3-\3-\3-\3-\3.\3.\3.\3.\3.\5.\u01d7\n")
        buf.write(".\3/\3/\3/\3/\3/\5/\u01de\n/\3\60\3\60\3\61\3\61\3\61")
        buf.write("\3\62\3\62\3\62\7\62\u01e8\n\62\f\62\16\62\u01eb\13\62")
        buf.write("\3\62\5\62\u01ee\n\62\3\63\3\63\3\64\3\64\3\64\3\64\3")
        buf.write("\64\3\64\3\64\3\64\3\64\3\64\3\64\3\64\3\64\3\64\3\64")
        buf.write("\3\64\5\64\u0202\n\64\3\64\3\64\3\64\3\64\3\64\3\64\3")
        buf.write("\64\3\64\3\64\7\64\u020d\n\64\f\64\16\64\u0210\13\64\3")
        buf.write("\65\3\65\3\66\3\66\3\67\5\67\u0217\n\67\3\67\3\67\3\67")
        buf.write("\3\67\5\67\u021d\n\67\38\38\38\39\39\39\2\3f:\2\4\6\b")
        buf.write("\n\f\16\20\22\24\26\30\32\34\36 \"$&(*,.\60\62\64\668")
        buf.write(":<>@BDFHJLNPRTVXZ\\^`bdfhjlnp\2\r\3\29;\3\2\24\25\3\2")
        buf.write("\27\32\3\2\33\36\3\2\37\"\3\2&*\3\2<=\3\2\66\67\3\2\64")
        buf.write("\65\3\2/\63\3\2=>\2\u023c\2s\3\2\2\2\4\u008c\3\2\2\2\6")
        buf.write("\u00a0\3\2\2\2\b\u00a5\3\2\2\2\n\u00bb\3\2\2\2\f\u00bd")
        buf.write("\3\2\2\2\16\u00bf\3\2\2\2\20\u00c1\3\2\2\2\22\u00c3\3")
        buf.write("\2\2\2\24\u00d8\3\2\2\2\26\u00f2\3\2\2\2\30\u00f5\3\2")
        buf.write("\2\2\32\u00fc\3\2\2\2\34\u0101\3\2\2\2\36\u010f\3\2\2")
        buf.write("\2 \u0114\3\2\2\2\"\u011e\3\2\2\2$\u0137\3\2\2\2&\u013b")
        buf.write("\3\2\2\2(\u013d\3\2\2\2*\u0150\3\2\2\2,\u0155\3\2\2\2")
        buf.write(".\u015d\3\2\2\2\60\u0165\3\2\2\2\62\u016b\3\2\2\2\64\u0177")
        buf.write("\3\2\2\2\66\u0179\3\2\2\28\u017c\3\2\2\2:\u017f\3\2\2")
        buf.write("\2<\u0181\3\2\2\2>\u0184\3\2\2\2@\u0188\3\2\2\2B\u018c")
        buf.write("\3\2\2\2D\u0190\3\2\2\2F\u0192\3\2\2\2H\u01a4\3\2\2\2")
        buf.write("J\u01a8\3\2\2\2L\u01b0\3\2\2\2N\u01b2\3\2\2\2P\u01b8\3")
        buf.write("\2\2\2R\u01be\3\2\2\2T\u01c4\3\2\2\2V\u01c8\3\2\2\2X\u01cc")
        buf.write("\3\2\2\2Z\u01d1\3\2\2\2\\\u01d8\3\2\2\2^\u01df\3\2\2\2")
        buf.write("`\u01e1\3\2\2\2b\u01e4\3\2\2\2d\u01ef\3\2\2\2f\u0201\3")
        buf.write("\2\2\2h\u0211\3\2\2\2j\u0213\3\2\2\2l\u0216\3\2\2\2n\u021e")
        buf.write("\3\2\2\2p\u0221\3\2\2\2rt\5\4\3\2sr\3\2\2\2st\3\2\2\2")
        buf.write("t}\3\2\2\2uw\7L\2\2vu\3\2\2\2wx\3\2\2\2xv\3\2\2\2xy\3")
        buf.write("\2\2\2yz\3\2\2\2z|\5\4\3\2{v\3\2\2\2|\177\3\2\2\2}{\3")
        buf.write("\2\2\2}~\3\2\2\2~\u0083\3\2\2\2\177}\3\2\2\2\u0080\u0082")
        buf.write("\7L\2\2\u0081\u0080\3\2\2\2\u0082\u0085\3\2\2\2\u0083")
        buf.write("\u0081\3\2\2\2\u0083\u0084\3\2\2\2\u0084\u0086\3\2\2\2")
        buf.write("\u0085\u0083\3\2\2\2\u0086\u0087\7\2\2\3\u0087\3\3\2\2")
        buf.write("\2\u0088\u008d\5\22\n\2\u0089\u008d\5\24\13\2\u008a\u008d")
        buf.write("\5\"\22\2\u008b\u008d\5\6\4\2\u008c\u0088\3\2\2\2\u008c")
        buf.write("\u0089\3\2\2\2\u008c\u008a\3\2\2\2\u008c\u008b\3\2\2\2")
        buf.write("\u008d\5\3\2\2\2\u008e\u00a1\5\b\5\2\u008f\u00a1\5\62")
        buf.write("\32\2\u0090\u00a1\5\66\34\2\u0091\u00a1\5:\36\2\u0092")
        buf.write("\u00a1\5<\37\2\u0093\u00a1\5> \2\u0094\u00a1\5@!\2\u0095")
        buf.write("\u00a1\5B\"\2\u0096\u00a1\5D#\2\u0097\u00a1\5J&\2\u0098")
        buf.write("\u00a1\5L\'\2\u0099\u00a1\5\\/\2\u009a\u00a1\5X-\2\u009b")
        buf.write("\u00a1\5Z.\2\u009c\u00a1\5^\60\2\u009d\u00a1\5`\61\2\u009e")
        buf.write("\u00a1\5b\62\2\u009f\u00a1\5F$\2\u00a0\u008e\3\2\2\2\u00a0")
        buf.write("\u008f\3\2\2\2\u00a0\u0090\3\2\2\2\u00a0\u0091\3\2\2\2")
        buf.write("\u00a0\u0092\3\2\2\2\u00a0\u0093\3\2\2\2\u00a0\u0094\3")
        buf.write("\2\2\2\u00a0\u0095\3\2\2\2\u00a0\u0096\3\2\2\2\u00a0\u0097")
        buf.write("\3\2\2\2\u00a0\u0098\3\2\2\2\u00a0\u0099\3\2\2\2\u00a0")
        buf.write("\u009a\3\2\2\2\u00a0\u009b\3\2\2\2\u00a0\u009c\3\2\2\2")
        buf.write("\u00a0\u009d\3\2\2\2\u00a0\u009e\3\2\2\2\u00a0\u009f\3")
        buf.write("\2\2\2\u00a1\7\3\2\2\2\u00a2\u00a4\5\20\t\2\u00a3\u00a2")
        buf.write("\3\2\2\2\u00a4\u00a7\3\2\2\2\u00a5\u00a3\3\2\2\2\u00a5")
        buf.write("\u00a6\3\2\2\2\u00a6\u00a8\3\2\2\2\u00a7\u00a5\3\2\2\2")
        buf.write("\u00a8\u00b4\5\n\6\2\u00a9\u00aa\7B\2\2\u00aa\u00af\5")
        buf.write("\16\b\2\u00ab\u00ac\7A\2\2\u00ac\u00ae\5\16\b\2\u00ad")
        buf.write("\u00ab\3\2\2\2\u00ae\u00b1\3\2\2\2\u00af\u00ad\3\2\2\2")
        buf.write("\u00af\u00b0\3\2\2\2\u00b0\u00b2\3\2\2\2\u00b1\u00af\3")
        buf.write("\2\2\2\u00b2\u00b3\7C\2\2\u00b3\u00b5\3\2\2\2\u00b4\u00a9")
        buf.write("\3\2\2\2\u00b4\u00b5\3\2\2\2\u00b5\u00b7\3\2\2\2\u00b6")
        buf.write("\u00b8\5\f\7\2\u00b7\u00b6\3\2\2\2\u00b8\u00b9\3\2\2\2")
        buf.write("\u00b9\u00b7\3\2\2\2\u00b9\u00ba\3\2\2\2\u00ba\t\3\2\2")
        buf.write("\2\u00bb\u00bc\7<\2\2\u00bc\13\3\2\2\2\u00bd\u00be\7=")
        buf.write("\2\2\u00be\r\3\2\2\2\u00bf\u00c0\5f\64\2\u00c0\17\3\2")
        buf.write("\2\2\u00c1\u00c2\t\2\2\2\u00c2\21\3\2\2\2\u00c3\u00c4")
        buf.write("\7\3\2\2\u00c4\u00d2\5\n\6\2\u00c5\u00c6\7B\2\2\u00c6")
        buf.write("\u00cb\5\26\f\2\u00c7\u00c8\7A\2\2\u00c8\u00ca\5\26\f")
        buf.write("\2\u00c9\u00c7\3\2\2\2\u00ca\u00cd\3\2\2\2\u00cb\u00c9")
        buf.write("\3\2\2\2\u00cb\u00cc\3\2\2\2\u00cc\u00ce\3\2\2\2\u00cd")
        buf.write("\u00cb\3\2\2\2\u00ce\u00cf\7C\2\2\u00cf\u00d3\3\2\2\2")
        buf.write("\u00d0\u00d1\7\23\2\2\u00d1\u00d3\5\30\r\2\u00d2\u00c5")
        buf.write("\3\2\2\2\u00d2\u00d0\3\2\2\2\u00d2\u00d3\3\2\2\2\u00d3")
        buf.write("\u00d4\3\2\2\2\u00d4\u00d5\7F\2\2\u00d5\u00d6\7L\2\2\u00d6")
        buf.write("\u00d7\5\32\16\2\u00d7\23\3\2\2\2\u00d8\u00d9\7\3\2\2")
        buf.write("\u00d9\u00e5\5\n\6\2\u00da\u00db\7B\2\2\u00db\u00e0\5")
        buf.write("\26\f\2\u00dc\u00dd\7A\2\2\u00dd\u00df\5\26\f\2\u00de")
        buf.write("\u00dc\3\2\2\2\u00df\u00e2\3\2\2\2\u00e0\u00de\3\2\2\2")
        buf.write("\u00e0\u00e1\3\2\2\2\u00e1\u00e3\3\2\2\2\u00e2\u00e0\3")
        buf.write("\2\2\2\u00e3\u00e4\7C\2\2\u00e4\u00e6\3\2\2\2\u00e5\u00da")
        buf.write("\3\2\2\2\u00e5\u00e6\3\2\2\2\u00e6\u00e8\3\2\2\2\u00e7")
        buf.write("\u00e9\5$\23\2\u00e8\u00e7\3\2\2\2\u00e9\u00ea\3\2\2\2")
        buf.write("\u00ea\u00e8\3\2\2\2\u00ea\u00eb\3\2\2\2\u00eb\u00ec\3")
        buf.write("\2\2\2\u00ec\u00ed\7\23\2\2\u00ed\u00ee\7\26\2\2\u00ee")
        buf.write("\u00ef\7F\2\2\u00ef\u00f0\7L\2\2\u00f0\u00f1\5\36\20\2")
        buf.write("\u00f1\25\3\2\2\2\u00f2\u00f3\7G\2\2\u00f3\u00f4\7<\2")
        buf.write("\2\u00f4\27\3\2\2\2\u00f5\u00f6\t\3\2\2\u00f6\31\3\2\2")
        buf.write("\2\u00f7\u00f8\5\34\17\2\u00f8\u00f9\7L\2\2\u00f9\u00fb")
        buf.write("\3\2\2\2\u00fa\u00f7\3\2\2\2\u00fb\u00fe\3\2\2\2\u00fc")
        buf.write("\u00fa\3\2\2\2\u00fc\u00fd\3\2\2\2\u00fd\u00ff\3\2\2\2")
        buf.write("\u00fe\u00fc\3\2\2\2\u00ff\u0100\5\34\17\2\u0100\33\3")
        buf.write("\2\2\2\u0101\u0102\7K\2\2\u0102\u0107\5f\64\2\u0103\u0104")
        buf.write("\7A\2\2\u0104\u0106\5f\64\2\u0105\u0103\3\2\2\2\u0106")
        buf.write("\u0109\3\2\2\2\u0107\u0105\3\2\2\2\u0107\u0108\3\2\2\2")
        buf.write("\u0108\35\3\2\2\2\u0109\u0107\3\2\2\2\u010a\u010b\5 \21")
        buf.write("\2\u010b\u010c\7L\2\2\u010c\u010e\3\2\2\2\u010d\u010a")
        buf.write("\3\2\2\2\u010e\u0111\3\2\2\2\u010f\u010d\3\2\2\2\u010f")
        buf.write("\u0110\3\2\2\2\u0110\u0112\3\2\2\2\u0111\u010f\3\2\2\2")
        buf.write("\u0112\u0113\5 \21\2\u0113\37\3\2\2\2\u0114\u0115\7K\2")
        buf.write("\2\u0115\u0116\7<\2\2\u0116\u0117\7B\2\2\u0117\u0118\5")
        buf.write("f\64\2\u0118\u011a\7C\2\2\u0119\u011b\5$\23\2\u011a\u0119")
        buf.write("\3\2\2\2\u011b\u011c\3\2\2\2\u011c\u011a\3\2\2\2\u011c")
        buf.write("\u011d\3\2\2\2\u011d!\3\2\2\2\u011e\u011f\7\4\2\2\u011f")
        buf.write("\u012b\5\n\6\2\u0120\u0121\7B\2\2\u0121\u0126\5\26\f\2")
        buf.write("\u0122\u0123\7A\2\2\u0123\u0125\5\26\f\2\u0124\u0122\3")
        buf.write("\2\2\2\u0125\u0128\3\2\2\2\u0126\u0124\3\2\2\2\u0126\u0127")
        buf.write("\3\2\2\2\u0127\u0129\3\2\2\2\u0128\u0126\3\2\2\2\u0129")
        buf.write("\u012a\7C\2\2\u012a\u012c\3\2\2\2\u012b\u0120\3\2\2\2")
        buf.write("\u012b\u012c\3\2\2\2\u012c\u0130\3\2\2\2\u012d\u012f\5")
        buf.write("$\23\2\u012e\u012d\3\2\2\2\u012f\u0132\3\2\2\2\u0130\u012e")
        buf.write("\3\2\2\2\u0130\u0131\3\2\2\2\u0131\u0133\3\2\2\2\u0132")
        buf.write("\u0130\3\2\2\2\u0133\u0134\7F\2\2\u0134\u0135\7L\2\2\u0135")
        buf.write("\u0136\5\60\31\2\u0136#\3\2\2\2\u0137\u0138\7<\2\2\u0138")
        buf.write("%\3\2\2\2\u0139\u013c\5\f\7\2\u013a\u013c\5$\23\2\u013b")
        buf.write("\u0139\3\2\2\2\u013b\u013a\3\2\2\2\u013c\'\3\2\2\2\u013d")
        buf.write("\u0149\5\n\6\2\u013e\u013f\7B\2\2\u013f\u0144\5\16\b\2")
        buf.write("\u0140\u0141\7A\2\2\u0141\u0143\5\16\b\2\u0142\u0140\3")
        buf.write("\2\2\2\u0143\u0146\3\2\2\2\u0144\u0142\3\2\2\2\u0144\u0145")
        buf.write("\3\2\2\2\u0145\u0147\3\2\2\2\u0146\u0144\3\2\2\2\u0147")
        buf.write("\u0148\7C\2\2\u0148\u014a\3\2\2\2\u0149\u013e\3\2\2\2")
        buf.write("\u0149\u014a\3\2\2\2\u014a\u014c\3\2\2\2\u014b\u014d\5")
        buf.write("&\24\2\u014c\u014b\3\2\2\2\u014d\u014e\3\2\2\2\u014e\u014c")
        buf.write("\3\2\2\2\u014e\u014f\3\2\2\2\u014f)\3\2\2\2\u0150\u0151")
        buf.write("\7\5\2\2\u0151\u0153\5&\24\2\u0152\u0154\5\64\33\2\u0153")
        buf.write("\u0152\3\2\2\2\u0153\u0154\3\2\2\2\u0154+\3\2\2\2\u0155")
        buf.write("\u0157\7\13\2\2\u0156\u0158\5&\24\2\u0157\u0156\3\2\2")
        buf.write("\2\u0157\u0158\3\2\2\2\u0158-\3\2\2\2\u0159\u015e\5(\25")
        buf.write("\2\u015a\u015e\5*\26\2\u015b\u015e\5,\27\2\u015c\u015e")
        buf.write("\5\6\4\2\u015d\u0159\3\2\2\2\u015d\u015a\3\2\2\2\u015d")
        buf.write("\u015b\3\2\2\2\u015d\u015c\3\2\2\2\u015e/\3\2\2\2\u015f")
        buf.write("\u0160\7K\2\2\u0160\u0161\5.\30\2\u0161\u0162\7L\2\2\u0162")
        buf.write("\u0164\3\2\2\2\u0163\u015f\3\2\2\2\u0164\u0167\3\2\2\2")
        buf.write("\u0165\u0163\3\2\2\2\u0165\u0166\3\2\2\2\u0166\u0168\3")
        buf.write("\2\2\2\u0167\u0165\3\2\2\2\u0168\u0169\7K\2\2\u0169\u016a")
        buf.write("\5.\30\2\u016a\61\3\2\2\2\u016b\u016c\7\5\2\2\u016c\u016e")
        buf.write("\5\f\7\2\u016d\u016f\5\64\33\2\u016e\u016d\3\2\2\2\u016e")
        buf.write("\u016f\3\2\2\2\u016f\63\3\2\2\2\u0170\u0178\7<\2\2\u0171")
        buf.write("\u0173\7<\2\2\u0172\u0171\3\2\2\2\u0172\u0173\3\2\2\2")
        buf.write("\u0173\u0174\3\2\2\2\u0174\u0175\7D\2\2\u0175\u0176\7")
        buf.write("=\2\2\u0176\u0178\7E\2\2\u0177\u0170\3\2\2\2\u0177\u0172")
        buf.write("\3\2\2\2\u0178\65\3\2\2\2\u0179\u017a\7\6\2\2\u017a\u017b")
        buf.write("\58\35\2\u017b\67\3\2\2\2\u017c\u017d\7H\2\2\u017d\u017e")
        buf.write("\7<\2\2\u017e9\3\2\2\2\u017f\u0180\7\7\2\2\u0180;\3\2")
        buf.write("\2\2\u0181\u0182\7\b\2\2\u0182\u0183\58\35\2\u0183=\3")
        buf.write("\2\2\2\u0184\u0185\7\t\2\2\u0185\u0186\58\35\2\u0186\u0187")
        buf.write("\5\64\33\2\u0187?\3\2\2\2\u0188\u0189\7\n\2\2\u0189\u018a")
        buf.write("\58\35\2\u018a\u018b\5\64\33\2\u018bA\3\2\2\2\u018c\u018e")
        buf.write("\7\13\2\2\u018d\u018f\5\f\7\2\u018e\u018d\3\2\2\2\u018e")
        buf.write("\u018f\3\2\2\2\u018fC\3\2\2\2\u0190\u0191\7\f\2\2\u0191")
        buf.write("E\3\2\2\2\u0192\u0193\7\20\2\2\u0193\u0194\7<\2\2\u0194")
        buf.write("\u0198\7<\2\2\u0195\u0196\7D\2\2\u0196\u0197\7=\2\2\u0197")
        buf.write("\u0199\7E\2\2\u0198\u0195\3\2\2\2\u0198\u0199\3\2\2\2")
        buf.write("\u0199\u01a2\3\2\2\2\u019a\u019b\7\21\2\2\u019b\u019f")
        buf.write("\7<\2\2\u019c\u019e\5H%\2\u019d\u019c\3\2\2\2\u019e\u01a1")
        buf.write("\3\2\2\2\u019f\u019d\3\2\2\2\u019f\u01a0\3\2\2\2\u01a0")
        buf.write("\u01a3\3\2\2\2\u01a1\u019f\3\2\2\2\u01a2\u019a\3\2\2\2")
        buf.write("\u01a2\u01a3\3\2\2\2\u01a3G\3\2\2\2\u01a4\u01a5\7\22\2")
        buf.write("\2\u01a5\u01a6\7=\2\2\u01a6\u01a7\7<\2\2\u01a7I\3\2\2")
        buf.write("\2\u01a8\u01a9\t\4\2\2\u01a9\u01aa\5\64\33\2\u01aaK\3")
        buf.write("\2\2\2\u01ab\u01b1\5N(\2\u01ac\u01b1\5P)\2\u01ad\u01b1")
        buf.write("\5R*\2\u01ae\u01b1\5T+\2\u01af\u01b1\5V,\2\u01b0\u01ab")
        buf.write("\3\2\2\2\u01b0\u01ac\3\2\2\2\u01b0\u01ad\3\2\2\2\u01b0")
        buf.write("\u01ae\3\2\2\2\u01b0\u01af\3\2\2\2\u01b1M\3\2\2\2\u01b2")
        buf.write("\u01b3\t\5\2\2\u01b3\u01b6\5\64\33\2\u01b4\u01b7\5\64")
        buf.write("\33\2\u01b5\u01b7\7=\2\2\u01b6\u01b4\3\2\2\2\u01b6\u01b5")
        buf.write("\3\2\2\2\u01b7O\3\2\2\2\u01b8\u01b9\t\6\2\2\u01b9\u01bc")
        buf.write("\5\64\33\2\u01ba\u01bd\5\64\33\2\u01bb\u01bd\5l\67\2\u01bc")
        buf.write("\u01ba\3\2\2\2\u01bc\u01bb\3\2\2\2\u01bdQ\3\2\2\2\u01be")
        buf.write("\u01bf\7#\2\2\u01bf\u01c2\5\64\33\2\u01c0\u01c3\5\64\33")
        buf.write("\2\u01c1\u01c3\5l\67\2\u01c2\u01c0\3\2\2\2\u01c2\u01c1")
        buf.write("\3\2\2\2\u01c3S\3\2\2\2\u01c4\u01c5\7$\2\2\u01c5\u01c6")
        buf.write("\5\64\33\2\u01c6\u01c7\5\64\33\2\u01c7U\3\2\2\2\u01c8")
        buf.write("\u01c9\7%\2\2\u01c9\u01ca\5\64\33\2\u01ca\u01cb\5\64\33")
        buf.write("\2\u01cbW\3\2\2\2\u01cc\u01cd\7+\2\2\u01cd\u01ce\5\64")
        buf.write("\33\2\u01ce\u01cf\7<\2\2\u01cf\u01d0\5\64\33\2\u01d0Y")
        buf.write("\3\2\2\2\u01d1\u01d2\7,\2\2\u01d2\u01d3\7<\2\2\u01d3\u01d6")
        buf.write("\5\64\33\2\u01d4\u01d7\5\64\33\2\u01d5\u01d7\5l\67\2\u01d6")
        buf.write("\u01d4\3\2\2\2\u01d6\u01d5\3\2\2\2\u01d7[\3\2\2\2\u01d8")
        buf.write("\u01d9\t\7\2\2\u01d9\u01da\5\64\33\2\u01da\u01dd\5\64")
        buf.write("\33\2\u01db\u01de\5\64\33\2\u01dc\u01de\5l\67\2\u01dd")
        buf.write("\u01db\3\2\2\2\u01dd\u01dc\3\2\2\2\u01de]\3\2\2\2\u01df")
        buf.write("\u01e0\7\r\2\2\u01e0_\3\2\2\2\u01e1\u01e2\7\16\2\2\u01e2")
        buf.write("\u01e3\7?\2\2\u01e3a\3\2\2\2\u01e4\u01e5\7\17\2\2\u01e5")
        buf.write("\u01e9\7<\2\2\u01e6\u01e8\5d\63\2\u01e7\u01e6\3\2\2\2")
        buf.write("\u01e8\u01eb\3\2\2\2\u01e9\u01e7\3\2\2\2\u01e9\u01ea\3")
        buf.write("\2\2\2\u01ea\u01ed\3\2\2\2\u01eb\u01e9\3\2\2\2\u01ec\u01ee")
        buf.write("\7?\2\2\u01ed\u01ec\3\2\2\2\u01ed\u01ee\3\2\2\2\u01ee")
        buf.write("c\3\2\2\2\u01ef\u01f0\t\b\2\2\u01f0e\3\2\2\2\u01f1\u01f2")
        buf.write("\b\64\1\2\u01f2\u01f3\7B\2\2\u01f3\u01f4\5f\64\2\u01f4")
        buf.write("\u01f5\7C\2\2\u01f5\u0202\3\2\2\2\u01f6\u01f7\5j\66\2")
        buf.write("\u01f7\u01f8\5f\64\n\u01f8\u0202\3\2\2\2\u01f9\u01fa\5")
        buf.write("h\65\2\u01fa\u01fb\7B\2\2\u01fb\u01fc\5f\64\2\u01fc\u01fd")
        buf.write("\7C\2\2\u01fd\u0202\3\2\2\2\u01fe\u0202\5l\67\2\u01ff")
        buf.write("\u0202\5\26\f\2\u0200\u0202\5\64\33\2\u0201\u01f1\3\2")
        buf.write("\2\2\u0201\u01f6\3\2\2\2\u0201\u01f9\3\2\2\2\u0201\u01fe")
        buf.write("\3\2\2\2\u0201\u01ff\3\2\2\2\u0201\u0200\3\2\2\2\u0202")
        buf.write("\u020e\3\2\2\2\u0203\u0204\f\t\2\2\u0204\u0205\78\2\2")
        buf.write("\u0205\u020d\5f\64\t\u0206\u0207\f\b\2\2\u0207\u0208\t")
        buf.write("\t\2\2\u0208\u020d\5f\64\t\u0209\u020a\f\7\2\2\u020a\u020b")
        buf.write("\t\n\2\2\u020b\u020d\5f\64\b\u020c\u0203\3\2\2\2\u020c")
        buf.write("\u0206\3\2\2\2\u020c\u0209\3\2\2\2\u020d\u0210\3\2\2\2")
        buf.write("\u020e\u020c\3\2\2\2\u020e\u020f\3\2\2\2\u020fg\3\2\2")
        buf.write("\2\u0210\u020e\3\2\2\2\u0211\u0212\t\13\2\2\u0212i\3\2")
        buf.write("\2\2\u0213\u0214\t\n\2\2\u0214k\3\2\2\2\u0215\u0217\7")
        buf.write("\65\2\2\u0216\u0215\3\2\2\2\u0216\u0217\3\2\2\2\u0217")
        buf.write("\u021c\3\2\2\2\u0218\u021d\5p9\2\u0219\u021d\5n8\2\u021a")
        buf.write("\u021d\7.\2\2\u021b\u021d\7-\2\2\u021c\u0218\3\2\2\2\u021c")
        buf.write("\u0219\3\2\2\2\u021c\u021a\3\2\2\2\u021c\u021b\3\2\2\2")
        buf.write("\u021dm\3\2\2\2\u021e\u021f\5p9\2\u021f\u0220\7.\2\2\u0220")
        buf.write("o\3\2\2\2\u0221\u0222\t\f\2\2\u0222q\3\2\2\2\64sx}\u0083")
        buf.write("\u008c\u00a0\u00a5\u00af\u00b4\u00b9\u00cb\u00d2\u00e0")
        buf.write("\u00e5\u00ea\u00fc\u0107\u010f\u011c\u0126\u012b\u0130")
        buf.write("\u013b\u0144\u0149\u014e\u0153\u0157\u015d\u0165\u016e")
        buf.write("\u0172\u0177\u018e\u0198\u019f\u01a2\u01b0\u01b6\u01bc")
        buf.write("\u01c2\u01d6\u01dd\u01e9\u01ed\u0201\u020c\u020e\u0216")
        buf.write("\u021c")
        return buf.getvalue()


class QuilParser ( Parser ):

    grammarFileName = "Quil.g4"

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

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

    sharedContextCache = PredictionContextCache()

    literalNames = [ "<INVALID>", "'DEFGATE'", "'DEFCIRCUIT'", "'MEASURE'", 
                     "'LABEL'", "'HALT'", "'JUMP'", "'JUMP-WHEN'", "'JUMP-UNLESS'", 
                     "'RESET'", "'WAIT'", "'NOP'", "'INCLUDE'", "'PRAGMA'", 
                     "'DECLARE'", "'SHARING'", "'OFFSET'", "'AS'", "'MATRIX'", 
                     "'PERMUTATION'", "'PAULI-SUM'", "'NEG'", "'NOT'", "'TRUE'", 
                     "'FALSE'", "'AND'", "'IOR'", "'XOR'", "'OR'", "'ADD'", 
                     "'SUB'", "'MUL'", "'DIV'", "'MOVE'", "'EXCHANGE'", 
                     "'CONVERT'", "'EQ'", "'GT'", "'GE'", "'LT'", "'LE'", 
                     "'LOAD'", "'STORE'", "'pi'", "'i'", "'SIN'", "'COS'", 
                     "'SQRT'", "'EXP'", "'CIS'", "'+'", "'-'", "'*'", "'/'", 
                     "'^'", "'CONTROLLED'", "'DAGGER'", "'FORKED'", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "'.'", "','", 
                     "'('", "')'", "'['", "']'", "':'", "'%'", "'@'", "'\"'", 
                     "'_'", "'    '", "<INVALID>", "<INVALID>", "' '" ]

    symbolicNames = [ "<INVALID>", "DEFGATE", "DEFCIRCUIT", "MEASURE", "LABEL", 
                      "HALT", "JUMP", "JUMPWHEN", "JUMPUNLESS", "RESET", 
                      "WAIT", "NOP", "INCLUDE", "PRAGMA", "DECLARE", "SHARING", 
                      "OFFSET", "AS", "MATRIX", "PERMUTATION", "PAULISUM", 
                      "NEG", "NOT", "TRUE", "FALSE", "AND", "IOR", "XOR", 
                      "OR", "ADD", "SUB", "MUL", "DIV", "MOVE", "EXCHANGE", 
                      "CONVERT", "EQ", "GT", "GE", "LT", "LE", "LOAD", "STORE", 
                      "PI", "I", "SIN", "COS", "SQRT", "EXP", "CIS", "PLUS", 
                      "MINUS", "TIMES", "DIVIDE", "POWER", "CONTROLLED", 
                      "DAGGER", "FORKED", "IDENTIFIER", "INT", "FLOAT", 
                      "STRING", "PERIOD", "COMMA", "LPAREN", "RPAREN", "LBRACKET", 
                      "RBRACKET", "COLON", "PERCENTAGE", "AT", "QUOTE", 
                      "UNDERSCORE", "TAB", "NEWLINE", "COMMENT", "SPACE", 
                      "INVALID" ]

    RULE_quil = 0
    RULE_allInstr = 1
    RULE_instr = 2
    RULE_gate = 3
    RULE_name = 4
    RULE_qubit = 5
    RULE_param = 6
    RULE_modifier = 7
    RULE_defGate = 8
    RULE_defGateAsPauli = 9
    RULE_variable = 10
    RULE_gatetype = 11
    RULE_matrix = 12
    RULE_matrixRow = 13
    RULE_pauliTerms = 14
    RULE_pauliTerm = 15
    RULE_defCircuit = 16
    RULE_qubitVariable = 17
    RULE_circuitQubit = 18
    RULE_circuitGate = 19
    RULE_circuitMeasure = 20
    RULE_circuitResetState = 21
    RULE_circuitInstr = 22
    RULE_circuit = 23
    RULE_measure = 24
    RULE_addr = 25
    RULE_defLabel = 26
    RULE_label = 27
    RULE_halt = 28
    RULE_jump = 29
    RULE_jumpWhen = 30
    RULE_jumpUnless = 31
    RULE_resetState = 32
    RULE_wait = 33
    RULE_memoryDescriptor = 34
    RULE_offsetDescriptor = 35
    RULE_classicalUnary = 36
    RULE_classicalBinary = 37
    RULE_logicalBinaryOp = 38
    RULE_arithmeticBinaryOp = 39
    RULE_move = 40
    RULE_exchange = 41
    RULE_convert = 42
    RULE_load = 43
    RULE_store = 44
    RULE_classicalComparison = 45
    RULE_nop = 46
    RULE_include = 47
    RULE_pragma = 48
    RULE_pragma_name = 49
    RULE_expression = 50
    RULE_function = 51
    RULE_sign = 52
    RULE_number = 53
    RULE_imaginaryN = 54
    RULE_realN = 55

    ruleNames =  [ "quil", "allInstr", "instr", "gate", "name", "qubit", 
                   "param", "modifier", "defGate", "defGateAsPauli", "variable", 
                   "gatetype", "matrix", "matrixRow", "pauliTerms", "pauliTerm", 
                   "defCircuit", "qubitVariable", "circuitQubit", "circuitGate", 
                   "circuitMeasure", "circuitResetState", "circuitInstr", 
                   "circuit", "measure", "addr", "defLabel", "label", "halt", 
                   "jump", "jumpWhen", "jumpUnless", "resetState", "wait", 
                   "memoryDescriptor", "offsetDescriptor", "classicalUnary", 
                   "classicalBinary", "logicalBinaryOp", "arithmeticBinaryOp", 
                   "move", "exchange", "convert", "load", "store", "classicalComparison", 
                   "nop", "include", "pragma", "pragma_name", "expression", 
                   "function", "sign", "number", "imaginaryN", "realN" ]

    EOF = Token.EOF
    DEFGATE=1
    DEFCIRCUIT=2
    MEASURE=3
    LABEL=4
    HALT=5
    JUMP=6
    JUMPWHEN=7
    JUMPUNLESS=8
    RESET=9
    WAIT=10
    NOP=11
    INCLUDE=12
    PRAGMA=13
    DECLARE=14
    SHARING=15
    OFFSET=16
    AS=17
    MATRIX=18
    PERMUTATION=19
    PAULISUM=20
    NEG=21
    NOT=22
    TRUE=23
    FALSE=24
    AND=25
    IOR=26
    XOR=27
    OR=28
    ADD=29
    SUB=30
    MUL=31
    DIV=32
    MOVE=33
    EXCHANGE=34
    CONVERT=35
    EQ=36
    GT=37
    GE=38
    LT=39
    LE=40
    LOAD=41
    STORE=42
    PI=43
    I=44
    SIN=45
    COS=46
    SQRT=47
    EXP=48
    CIS=49
    PLUS=50
    MINUS=51
    TIMES=52
    DIVIDE=53
    POWER=54
    CONTROLLED=55
    DAGGER=56
    FORKED=57
    IDENTIFIER=58
    INT=59
    FLOAT=60
    STRING=61
    PERIOD=62
    COMMA=63
    LPAREN=64
    RPAREN=65
    LBRACKET=66
    RBRACKET=67
    COLON=68
    PERCENTAGE=69
    AT=70
    QUOTE=71
    UNDERSCORE=72
    TAB=73
    NEWLINE=74
    COMMENT=75
    SPACE=76
    INVALID=77

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




    class QuilContext(ParserRuleContext):

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

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

        def allInstr(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(QuilParser.AllInstrContext)
            else:
                return self.getTypedRuleContext(QuilParser.AllInstrContext,i)


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

        def getRuleIndex(self):
            return QuilParser.RULE_quil

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

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




    def quil(self):

        localctx = QuilParser.QuilContext(self, self._ctx, self.state)
        self.enterRule(localctx, 0, self.RULE_quil)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 113
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << QuilParser.DEFGATE) | (1 << QuilParser.DEFCIRCUIT) | (1 << QuilParser.MEASURE) | (1 << QuilParser.LABEL) | (1 << QuilParser.HALT) | (1 << QuilParser.JUMP) | (1 << QuilParser.JUMPWHEN) | (1 << QuilParser.JUMPUNLESS) | (1 << QuilParser.RESET) | (1 << QuilParser.WAIT) | (1 << QuilParser.NOP) | (1 << QuilParser.INCLUDE) | (1 << QuilParser.PRAGMA) | (1 << QuilParser.DECLARE) | (1 << QuilParser.NEG) | (1 << QuilParser.NOT) | (1 << QuilParser.TRUE) | (1 << QuilParser.FALSE) | (1 << QuilParser.AND) | (1 << QuilParser.IOR) | (1 << QuilParser.XOR) | (1 << QuilParser.OR) | (1 << QuilParser.ADD) | (1 << QuilParser.SUB) | (1 << QuilParser.MUL) | (1 << QuilParser.DIV) | (1 << QuilParser.MOVE) | (1 << QuilParser.EXCHANGE) | (1 << QuilParser.CONVERT) | (1 << QuilParser.EQ) | (1 << QuilParser.GT) | (1 << QuilParser.GE) | (1 << QuilParser.LT) | (1 << QuilParser.LE) | (1 << QuilParser.LOAD) | (1 << QuilParser.STORE) | (1 << QuilParser.CONTROLLED) | (1 << QuilParser.DAGGER) | (1 << QuilParser.FORKED) | (1 << QuilParser.IDENTIFIER))) != 0):
                self.state = 112
                self.allInstr()


            self.state = 123
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,2,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 116 
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)
                    while True:
                        self.state = 115
                        self.match(QuilParser.NEWLINE)
                        self.state = 118 
                        self._errHandler.sync(self)
                        _la = self._input.LA(1)
                        if not (_la==QuilParser.NEWLINE):
                            break

                    self.state = 120
                    self.allInstr() 
                self.state = 125
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,2,self._ctx)

            self.state = 129
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==QuilParser.NEWLINE:
                self.state = 126
                self.match(QuilParser.NEWLINE)
                self.state = 131
                self._errHandler.sync(self)
                _la = self._input.LA(1)

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


    class AllInstrContext(ParserRuleContext):

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

        def defGate(self):
            return self.getTypedRuleContext(QuilParser.DefGateContext,0)


        def defGateAsPauli(self):
            return self.getTypedRuleContext(QuilParser.DefGateAsPauliContext,0)


        def defCircuit(self):
            return self.getTypedRuleContext(QuilParser.DefCircuitContext,0)


        def instr(self):
            return self.getTypedRuleContext(QuilParser.InstrContext,0)


        def getRuleIndex(self):
            return QuilParser.RULE_allInstr

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

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




    def allInstr(self):

        localctx = QuilParser.AllInstrContext(self, self._ctx, self.state)
        self.enterRule(localctx, 2, self.RULE_allInstr)
        try:
            self.state = 138
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,4,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 134
                self.defGate()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 135
                self.defGateAsPauli()
                pass

            elif la_ == 3:
                self.enterOuterAlt(localctx, 3)
                self.state = 136
                self.defCircuit()
                pass

            elif la_ == 4:
                self.enterOuterAlt(localctx, 4)
                self.state = 137
                self.instr()
                pass


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


    class InstrContext(ParserRuleContext):

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

        def gate(self):
            return self.getTypedRuleContext(QuilParser.GateContext,0)


        def measure(self):
            return self.getTypedRuleContext(QuilParser.MeasureContext,0)


        def defLabel(self):
            return self.getTypedRuleContext(QuilParser.DefLabelContext,0)


        def halt(self):
            return self.getTypedRuleContext(QuilParser.HaltContext,0)


        def jump(self):
            return self.getTypedRuleContext(QuilParser.JumpContext,0)


        def jumpWhen(self):
            return self.getTypedRuleContext(QuilParser.JumpWhenContext,0)


        def jumpUnless(self):
            return self.getTypedRuleContext(QuilParser.JumpUnlessContext,0)


        def resetState(self):
            return self.getTypedRuleContext(QuilParser.ResetStateContext,0)


        def wait(self):
            return self.getTypedRuleContext(QuilParser.WaitContext,0)


        def classicalUnary(self):
            return self.getTypedRuleContext(QuilParser.ClassicalUnaryContext,0)


        def classicalBinary(self):
            return self.getTypedRuleContext(QuilParser.ClassicalBinaryContext,0)


        def classicalComparison(self):
            return self.getTypedRuleContext(QuilParser.ClassicalComparisonContext,0)


        def load(self):
            return self.getTypedRuleContext(QuilParser.LoadContext,0)


        def store(self):
            return self.getTypedRuleContext(QuilParser.StoreContext,0)


        def nop(self):
            return self.getTypedRuleContext(QuilParser.NopContext,0)


        def include(self):
            return self.getTypedRuleContext(QuilParser.IncludeContext,0)


        def pragma(self):
            return self.getTypedRuleContext(QuilParser.PragmaContext,0)


        def memoryDescriptor(self):
            return self.getTypedRuleContext(QuilParser.MemoryDescriptorContext,0)


        def getRuleIndex(self):
            return QuilParser.RULE_instr

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

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




    def instr(self):

        localctx = QuilParser.InstrContext(self, self._ctx, self.state)
        self.enterRule(localctx, 4, self.RULE_instr)
        try:
            self.state = 158
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [QuilParser.CONTROLLED, QuilParser.DAGGER, QuilParser.FORKED, QuilParser.IDENTIFIER]:
                self.enterOuterAlt(localctx, 1)
                self.state = 140
                self.gate()
                pass
            elif token in [QuilParser.MEASURE]:
                self.enterOuterAlt(localctx, 2)
                self.state = 141
                self.measure()
                pass
            elif token in [QuilParser.LABEL]:
                self.enterOuterAlt(localctx, 3)
                self.state = 142
                self.defLabel()
                pass
            elif token in [QuilParser.HALT]:
                self.enterOuterAlt(localctx, 4)
                self.state = 143
                self.halt()
                pass
            elif token in [QuilParser.JUMP]:
                self.enterOuterAlt(localctx, 5)
                self.state = 144
                self.jump()
                pass
            elif token in [QuilParser.JUMPWHEN]:
                self.enterOuterAlt(localctx, 6)
                self.state = 145
                self.jumpWhen()
                pass
            elif token in [QuilParser.JUMPUNLESS]:
                self.enterOuterAlt(localctx, 7)
                self.state = 146
                self.jumpUnless()
                pass
            elif token in [QuilParser.RESET]:
                self.enterOuterAlt(localctx, 8)
                self.state = 147
                self.resetState()
                pass
            elif token in [QuilParser.WAIT]:
                self.enterOuterAlt(localctx, 9)
                self.state = 148
                self.wait()
                pass
            elif token in [QuilParser.NEG, QuilParser.NOT, QuilParser.TRUE, QuilParser.FALSE]:
                self.enterOuterAlt(localctx, 10)
                self.state = 149
                self.classicalUnary()
                pass
            elif token in [QuilParser.AND, QuilParser.IOR, QuilParser.XOR, QuilParser.OR, QuilParser.ADD, QuilParser.SUB, QuilParser.MUL, QuilParser.DIV, QuilParser.MOVE, QuilParser.EXCHANGE, QuilParser.CONVERT]:
                self.enterOuterAlt(localctx, 11)
                self.state = 150
                self.classicalBinary()
                pass
            elif token in [QuilParser.EQ, QuilParser.GT, QuilParser.GE, QuilParser.LT, QuilParser.LE]:
                self.enterOuterAlt(localctx, 12)
                self.state = 151
                self.classicalComparison()
                pass
            elif token in [QuilParser.LOAD]:
                self.enterOuterAlt(localctx, 13)
                self.state = 152
                self.load()
                pass
            elif token in [QuilParser.STORE]:
                self.enterOuterAlt(localctx, 14)
                self.state = 153
                self.store()
                pass
            elif token in [QuilParser.NOP]:
                self.enterOuterAlt(localctx, 15)
                self.state = 154
                self.nop()
                pass
            elif token in [QuilParser.INCLUDE]:
                self.enterOuterAlt(localctx, 16)
                self.state = 155
                self.include()
                pass
            elif token in [QuilParser.PRAGMA]:
                self.enterOuterAlt(localctx, 17)
                self.state = 156
                self.pragma()
                pass
            elif token in [QuilParser.DECLARE]:
                self.enterOuterAlt(localctx, 18)
                self.state = 157
                self.memoryDescriptor()
                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 GateContext(ParserRuleContext):

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

        def name(self):
            return self.getTypedRuleContext(QuilParser.NameContext,0)


        def modifier(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(QuilParser.ModifierContext)
            else:
                return self.getTypedRuleContext(QuilParser.ModifierContext,i)


        def LPAREN(self):
            return self.getToken(QuilParser.LPAREN, 0)

        def param(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(QuilParser.ParamContext)
            else:
                return self.getTypedRuleContext(QuilParser.ParamContext,i)


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

        def qubit(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(QuilParser.QubitContext)
            else:
                return self.getTypedRuleContext(QuilParser.QubitContext,i)


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

        def getRuleIndex(self):
            return QuilParser.RULE_gate

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

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




    def gate(self):

        localctx = QuilParser.GateContext(self, self._ctx, self.state)
        self.enterRule(localctx, 6, self.RULE_gate)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 163
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << QuilParser.CONTROLLED) | (1 << QuilParser.DAGGER) | (1 << QuilParser.FORKED))) != 0):
                self.state = 160
                self.modifier()
                self.state = 165
                self._errHandler.sync(self)
                _la = self._input.LA(1)

            self.state = 166
            self.name()
            self.state = 178
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==QuilParser.LPAREN:
                self.state = 167
                self.match(QuilParser.LPAREN)
                self.state = 168
                self.param()
                self.state = 173
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while _la==QuilParser.COMMA:
                    self.state = 169
                    self.match(QuilParser.COMMA)
                    self.state = 170
                    self.param()
                    self.state = 175
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)

                self.state = 176
                self.match(QuilParser.RPAREN)


            self.state = 181 
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 180
                self.qubit()
                self.state = 183 
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not (_la==QuilParser.INT):
                    break

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


    class NameContext(ParserRuleContext):

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

        def IDENTIFIER(self):
            return self.getToken(QuilParser.IDENTIFIER, 0)

        def getRuleIndex(self):
            return QuilParser.RULE_name

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

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




    def name(self):

        localctx = QuilParser.NameContext(self, self._ctx, self.state)
        self.enterRule(localctx, 8, self.RULE_name)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 185
            self.match(QuilParser.IDENTIFIER)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class QubitContext(ParserRuleContext):

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

        def INT(self):
            return self.getToken(QuilParser.INT, 0)

        def getRuleIndex(self):
            return QuilParser.RULE_qubit

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

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




    def qubit(self):

        localctx = QuilParser.QubitContext(self, self._ctx, self.state)
        self.enterRule(localctx, 10, self.RULE_qubit)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 187
            self.match(QuilParser.INT)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class ParamContext(ParserRuleContext):

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

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


        def getRuleIndex(self):
            return QuilParser.RULE_param

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

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




    def param(self):

        localctx = QuilParser.ParamContext(self, self._ctx, self.state)
        self.enterRule(localctx, 12, self.RULE_param)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 189
            self.expression(0)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class ModifierContext(ParserRuleContext):

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

        def CONTROLLED(self):
            return self.getToken(QuilParser.CONTROLLED, 0)

        def DAGGER(self):
            return self.getToken(QuilParser.DAGGER, 0)

        def FORKED(self):
            return self.getToken(QuilParser.FORKED, 0)

        def getRuleIndex(self):
            return QuilParser.RULE_modifier

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

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




    def modifier(self):

        localctx = QuilParser.ModifierContext(self, self._ctx, self.state)
        self.enterRule(localctx, 14, self.RULE_modifier)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 191
            _la = self._input.LA(1)
            if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << QuilParser.CONTROLLED) | (1 << QuilParser.DAGGER) | (1 << QuilParser.FORKED))) != 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 DefGateContext(ParserRuleContext):

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

        def DEFGATE(self):
            return self.getToken(QuilParser.DEFGATE, 0)

        def name(self):
            return self.getTypedRuleContext(QuilParser.NameContext,0)


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

        def NEWLINE(self):
            return self.getToken(QuilParser.NEWLINE, 0)

        def matrix(self):
            return self.getTypedRuleContext(QuilParser.MatrixContext,0)


        def LPAREN(self):
            return self.getToken(QuilParser.LPAREN, 0)

        def variable(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(QuilParser.VariableContext)
            else:
                return self.getTypedRuleContext(QuilParser.VariableContext,i)


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

        def AS(self):
            return self.getToken(QuilParser.AS, 0)

        def gatetype(self):
            return self.getTypedRuleContext(QuilParser.GatetypeContext,0)


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

        def getRuleIndex(self):
            return QuilParser.RULE_defGate

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

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




    def defGate(self):

        localctx = QuilParser.DefGateContext(self, self._ctx, self.state)
        self.enterRule(localctx, 16, self.RULE_defGate)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 193
            self.match(QuilParser.DEFGATE)
            self.state = 194
            self.name()
            self.state = 208
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [QuilParser.LPAREN]:
                self.state = 195
                self.match(QuilParser.LPAREN)
                self.state = 196
                self.variable()
                self.state = 201
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while _la==QuilParser.COMMA:
                    self.state = 197
                    self.match(QuilParser.COMMA)
                    self.state = 198
                    self.variable()
                    self.state = 203
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)

                self.state = 204
                self.match(QuilParser.RPAREN)
                pass
            elif token in [QuilParser.AS]:
                self.state = 206
                self.match(QuilParser.AS)
                self.state = 207
                self.gatetype()
                pass
            elif token in [QuilParser.COLON]:
                pass
            else:
                pass
            self.state = 210
            self.match(QuilParser.COLON)
            self.state = 211
            self.match(QuilParser.NEWLINE)
            self.state = 212
            self.matrix()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class DefGateAsPauliContext(ParserRuleContext):

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

        def DEFGATE(self):
            return self.getToken(QuilParser.DEFGATE, 0)

        def name(self):
            return self.getTypedRuleContext(QuilParser.NameContext,0)


        def AS(self):
            return self.getToken(QuilParser.AS, 0)

        def PAULISUM(self):
            return self.getToken(QuilParser.PAULISUM, 0)

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

        def NEWLINE(self):
            return self.getToken(QuilParser.NEWLINE, 0)

        def pauliTerms(self):
            return self.getTypedRuleContext(QuilParser.PauliTermsContext,0)


        def LPAREN(self):
            return self.getToken(QuilParser.LPAREN, 0)

        def variable(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(QuilParser.VariableContext)
            else:
                return self.getTypedRuleContext(QuilParser.VariableContext,i)


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

        def qubitVariable(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(QuilParser.QubitVariableContext)
            else:
                return self.getTypedRuleContext(QuilParser.QubitVariableContext,i)


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

        def getRuleIndex(self):
            return QuilParser.RULE_defGateAsPauli

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

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




    def defGateAsPauli(self):

        localctx = QuilParser.DefGateAsPauliContext(self, self._ctx, self.state)
        self.enterRule(localctx, 18, self.RULE_defGateAsPauli)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 214
            self.match(QuilParser.DEFGATE)
            self.state = 215
            self.name()
            self.state = 227
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==QuilParser.LPAREN:
                self.state = 216
                self.match(QuilParser.LPAREN)
                self.state = 217
                self.variable()
                self.state = 222
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while _la==QuilParser.COMMA:
                    self.state = 218
                    self.match(QuilParser.COMMA)
                    self.state = 219
                    self.variable()
                    self.state = 224
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)

                self.state = 225
                self.match(QuilParser.RPAREN)


            self.state = 230 
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 229
                self.qubitVariable()
                self.state = 232 
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not (_la==QuilParser.IDENTIFIER):
                    break

            self.state = 234
            self.match(QuilParser.AS)
            self.state = 235
            self.match(QuilParser.PAULISUM)
            self.state = 236
            self.match(QuilParser.COLON)
            self.state = 237
            self.match(QuilParser.NEWLINE)
            self.state = 238
            self.pauliTerms()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class VariableContext(ParserRuleContext):

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

        def PERCENTAGE(self):
            return self.getToken(QuilParser.PERCENTAGE, 0)

        def IDENTIFIER(self):
            return self.getToken(QuilParser.IDENTIFIER, 0)

        def getRuleIndex(self):
            return QuilParser.RULE_variable

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

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




    def variable(self):

        localctx = QuilParser.VariableContext(self, self._ctx, self.state)
        self.enterRule(localctx, 20, self.RULE_variable)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 240
            self.match(QuilParser.PERCENTAGE)
            self.state = 241
            self.match(QuilParser.IDENTIFIER)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class GatetypeContext(ParserRuleContext):

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

        def MATRIX(self):
            return self.getToken(QuilParser.MATRIX, 0)

        def PERMUTATION(self):
            return self.getToken(QuilParser.PERMUTATION, 0)

        def getRuleIndex(self):
            return QuilParser.RULE_gatetype

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

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




    def gatetype(self):

        localctx = QuilParser.GatetypeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 22, self.RULE_gatetype)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 243
            _la = self._input.LA(1)
            if not(_la==QuilParser.MATRIX or _la==QuilParser.PERMUTATION):
                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 MatrixContext(ParserRuleContext):

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

        def matrixRow(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(QuilParser.MatrixRowContext)
            else:
                return self.getTypedRuleContext(QuilParser.MatrixRowContext,i)


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

        def getRuleIndex(self):
            return QuilParser.RULE_matrix

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

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




    def matrix(self):

        localctx = QuilParser.MatrixContext(self, self._ctx, self.state)
        self.enterRule(localctx, 24, self.RULE_matrix)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 250
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,15,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 245
                    self.matrixRow()
                    self.state = 246
                    self.match(QuilParser.NEWLINE) 
                self.state = 252
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,15,self._ctx)

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


    class MatrixRowContext(ParserRuleContext):

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

        def TAB(self):
            return self.getToken(QuilParser.TAB, 0)

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


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

        def getRuleIndex(self):
            return QuilParser.RULE_matrixRow

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

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




    def matrixRow(self):

        localctx = QuilParser.MatrixRowContext(self, self._ctx, self.state)
        self.enterRule(localctx, 26, self.RULE_matrixRow)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 255
            self.match(QuilParser.TAB)
            self.state = 256
            self.expression(0)
            self.state = 261
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==QuilParser.COMMA:
                self.state = 257
                self.match(QuilParser.COMMA)
                self.state = 258
                self.expression(0)
                self.state = 263
                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 PauliTermsContext(ParserRuleContext):

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

        def pauliTerm(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(QuilParser.PauliTermContext)
            else:
                return self.getTypedRuleContext(QuilParser.PauliTermContext,i)


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

        def getRuleIndex(self):
            return QuilParser.RULE_pauliTerms

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

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




    def pauliTerms(self):

        localctx = QuilParser.PauliTermsContext(self, self._ctx, self.state)
        self.enterRule(localctx, 28, self.RULE_pauliTerms)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 269
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,17,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 264
                    self.pauliTerm()
                    self.state = 265
                    self.match(QuilParser.NEWLINE) 
                self.state = 271
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,17,self._ctx)

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


    class PauliTermContext(ParserRuleContext):

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

        def TAB(self):
            return self.getToken(QuilParser.TAB, 0)

        def IDENTIFIER(self):
            return self.getToken(QuilParser.IDENTIFIER, 0)

        def LPAREN(self):
            return self.getToken(QuilParser.LPAREN, 0)

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


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

        def qubitVariable(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(QuilParser.QubitVariableContext)
            else:
                return self.getTypedRuleContext(QuilParser.QubitVariableContext,i)


        def getRuleIndex(self):
            return QuilParser.RULE_pauliTerm

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

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




    def pauliTerm(self):

        localctx = QuilParser.PauliTermContext(self, self._ctx, self.state)
        self.enterRule(localctx, 30, self.RULE_pauliTerm)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 274
            self.match(QuilParser.TAB)
            self.state = 275
            self.match(QuilParser.IDENTIFIER)
            self.state = 276
            self.match(QuilParser.LPAREN)
            self.state = 277
            self.expression(0)
            self.state = 278
            self.match(QuilParser.RPAREN)
            self.state = 280 
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 279
                self.qubitVariable()
                self.state = 282 
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not (_la==QuilParser.IDENTIFIER):
                    break

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


    class DefCircuitContext(ParserRuleContext):

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

        def DEFCIRCUIT(self):
            return self.getToken(QuilParser.DEFCIRCUIT, 0)

        def name(self):
            return self.getTypedRuleContext(QuilParser.NameContext,0)


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

        def NEWLINE(self):
            return self.getToken(QuilParser.NEWLINE, 0)

        def circuit(self):
            return self.getTypedRuleContext(QuilParser.CircuitContext,0)


        def LPAREN(self):
            return self.getToken(QuilParser.LPAREN, 0)

        def variable(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(QuilParser.VariableContext)
            else:
                return self.getTypedRuleContext(QuilParser.VariableContext,i)


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

        def qubitVariable(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(QuilParser.QubitVariableContext)
            else:
                return self.getTypedRuleContext(QuilParser.QubitVariableContext,i)


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

        def getRuleIndex(self):
            return QuilParser.RULE_defCircuit

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

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




    def defCircuit(self):

        localctx = QuilParser.DefCircuitContext(self, self._ctx, self.state)
        self.enterRule(localctx, 32, self.RULE_defCircuit)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 284
            self.match(QuilParser.DEFCIRCUIT)
            self.state = 285
            self.name()
            self.state = 297
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==QuilParser.LPAREN:
                self.state = 286
                self.match(QuilParser.LPAREN)
                self.state = 287
                self.variable()
                self.state = 292
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while _la==QuilParser.COMMA:
                    self.state = 288
                    self.match(QuilParser.COMMA)
                    self.state = 289
                    self.variable()
                    self.state = 294
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)

                self.state = 295
                self.match(QuilParser.RPAREN)


            self.state = 302
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==QuilParser.IDENTIFIER:
                self.state = 299
                self.qubitVariable()
                self.state = 304
                self._errHandler.sync(self)
                _la = self._input.LA(1)

            self.state = 305
            self.match(QuilParser.COLON)
            self.state = 306
            self.match(QuilParser.NEWLINE)
            self.state = 307
            self.circuit()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class QubitVariableContext(ParserRuleContext):

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

        def IDENTIFIER(self):
            return self.getToken(QuilParser.IDENTIFIER, 0)

        def getRuleIndex(self):
            return QuilParser.RULE_qubitVariable

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

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




    def qubitVariable(self):

        localctx = QuilParser.QubitVariableContext(self, self._ctx, self.state)
        self.enterRule(localctx, 34, self.RULE_qubitVariable)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 309
            self.match(QuilParser.IDENTIFIER)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class CircuitQubitContext(ParserRuleContext):

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

        def qubit(self):
            return self.getTypedRuleContext(QuilParser.QubitContext,0)


        def qubitVariable(self):
            return self.getTypedRuleContext(QuilParser.QubitVariableContext,0)


        def getRuleIndex(self):
            return QuilParser.RULE_circuitQubit

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

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




    def circuitQubit(self):

        localctx = QuilParser.CircuitQubitContext(self, self._ctx, self.state)
        self.enterRule(localctx, 36, self.RULE_circuitQubit)
        try:
            self.state = 313
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [QuilParser.INT]:
                self.enterOuterAlt(localctx, 1)
                self.state = 311
                self.qubit()
                pass
            elif token in [QuilParser.IDENTIFIER]:
                self.enterOuterAlt(localctx, 2)
                self.state = 312
                self.qubitVariable()
                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 CircuitGateContext(ParserRuleContext):

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

        def name(self):
            return self.getTypedRuleContext(QuilParser.NameContext,0)


        def LPAREN(self):
            return self.getToken(QuilParser.LPAREN, 0)

        def param(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(QuilParser.ParamContext)
            else:
                return self.getTypedRuleContext(QuilParser.ParamContext,i)


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

        def circuitQubit(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(QuilParser.CircuitQubitContext)
            else:
                return self.getTypedRuleContext(QuilParser.CircuitQubitContext,i)


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

        def getRuleIndex(self):
            return QuilParser.RULE_circuitGate

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

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




    def circuitGate(self):

        localctx = QuilParser.CircuitGateContext(self, self._ctx, self.state)
        self.enterRule(localctx, 38, self.RULE_circuitGate)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 315
            self.name()
            self.state = 327
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==QuilParser.LPAREN:
                self.state = 316
                self.match(QuilParser.LPAREN)
                self.state = 317
                self.param()
                self.state = 322
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while _la==QuilParser.COMMA:
                    self.state = 318
                    self.match(QuilParser.COMMA)
                    self.state = 319
                    self.param()
                    self.state = 324
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)

                self.state = 325
                self.match(QuilParser.RPAREN)


            self.state = 330 
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 329
                self.circuitQubit()
                self.state = 332 
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not (_la==QuilParser.IDENTIFIER or _la==QuilParser.INT):
                    break

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


    class CircuitMeasureContext(ParserRuleContext):

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

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

        def circuitQubit(self):
            return self.getTypedRuleContext(QuilParser.CircuitQubitContext,0)


        def addr(self):
            return self.getTypedRuleContext(QuilParser.AddrContext,0)


        def getRuleIndex(self):
            return QuilParser.RULE_circuitMeasure

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

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




    def circuitMeasure(self):

        localctx = QuilParser.CircuitMeasureContext(self, self._ctx, self.state)
        self.enterRule(localctx, 40, self.RULE_circuitMeasure)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 334
            self.match(QuilParser.MEASURE)
            self.state = 335
            self.circuitQubit()
            self.state = 337
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==QuilParser.IDENTIFIER or _la==QuilParser.LBRACKET:
                self.state = 336
                self.addr()


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


    class CircuitResetStateContext(ParserRuleContext):

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

        def RESET(self):
            return self.getToken(QuilParser.RESET, 0)

        def circuitQubit(self):
            return self.getTypedRuleContext(QuilParser.CircuitQubitContext,0)


        def getRuleIndex(self):
            return QuilParser.RULE_circuitResetState

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

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




    def circuitResetState(self):

        localctx = QuilParser.CircuitResetStateContext(self, self._ctx, self.state)
        self.enterRule(localctx, 42, self.RULE_circuitResetState)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 339
            self.match(QuilParser.RESET)
            self.state = 341
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==QuilParser.IDENTIFIER or _la==QuilParser.INT:
                self.state = 340
                self.circuitQubit()


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


    class CircuitInstrContext(ParserRuleContext):

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

        def circuitGate(self):
            return self.getTypedRuleContext(QuilParser.CircuitGateContext,0)


        def circuitMeasure(self):
            return self.getTypedRuleContext(QuilParser.CircuitMeasureContext,0)


        def circuitResetState(self):
            return self.getTypedRuleContext(QuilParser.CircuitResetStateContext,0)


        def instr(self):
            return self.getTypedRuleContext(QuilParser.InstrContext,0)


        def getRuleIndex(self):
            return QuilParser.RULE_circuitInstr

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

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




    def circuitInstr(self):

        localctx = QuilParser.CircuitInstrContext(self, self._ctx, self.state)
        self.enterRule(localctx, 44, self.RULE_circuitInstr)
        try:
            self.state = 347
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,28,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 343
                self.circuitGate()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 344
                self.circuitMeasure()
                pass

            elif la_ == 3:
                self.enterOuterAlt(localctx, 3)
                self.state = 345
                self.circuitResetState()
                pass

            elif la_ == 4:
                self.enterOuterAlt(localctx, 4)
                self.state = 346
                self.instr()
                pass


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


    class CircuitContext(ParserRuleContext):

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

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

        def circuitInstr(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(QuilParser.CircuitInstrContext)
            else:
                return self.getTypedRuleContext(QuilParser.CircuitInstrContext,i)


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

        def getRuleIndex(self):
            return QuilParser.RULE_circuit

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

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




    def circuit(self):

        localctx = QuilParser.CircuitContext(self, self._ctx, self.state)
        self.enterRule(localctx, 46, self.RULE_circuit)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 355
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,29,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 349
                    self.match(QuilParser.TAB)
                    self.state = 350
                    self.circuitInstr()
                    self.state = 351
                    self.match(QuilParser.NEWLINE) 
                self.state = 357
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,29,self._ctx)

            self.state = 358
            self.match(QuilParser.TAB)
            self.state = 359
            self.circuitInstr()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class MeasureContext(ParserRuleContext):

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

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

        def qubit(self):
            return self.getTypedRuleContext(QuilParser.QubitContext,0)


        def addr(self):
            return self.getTypedRuleContext(QuilParser.AddrContext,0)


        def getRuleIndex(self):
            return QuilParser.RULE_measure

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

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




    def measure(self):

        localctx = QuilParser.MeasureContext(self, self._ctx, self.state)
        self.enterRule(localctx, 48, self.RULE_measure)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 361
            self.match(QuilParser.MEASURE)
            self.state = 362
            self.qubit()
            self.state = 364
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==QuilParser.IDENTIFIER or _la==QuilParser.LBRACKET:
                self.state = 363
                self.addr()


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


    class AddrContext(ParserRuleContext):

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

        def IDENTIFIER(self):
            return self.getToken(QuilParser.IDENTIFIER, 0)

        def LBRACKET(self):
            return self.getToken(QuilParser.LBRACKET, 0)

        def INT(self):
            return self.getToken(QuilParser.INT, 0)

        def RBRACKET(self):
            return self.getToken(QuilParser.RBRACKET, 0)

        def getRuleIndex(self):
            return QuilParser.RULE_addr

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

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




    def addr(self):

        localctx = QuilParser.AddrContext(self, self._ctx, self.state)
        self.enterRule(localctx, 50, self.RULE_addr)
        self._la = 0 # Token type
        try:
            self.state = 373
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,32,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 366
                self.match(QuilParser.IDENTIFIER)
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 368
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==QuilParser.IDENTIFIER:
                    self.state = 367
                    self.match(QuilParser.IDENTIFIER)


                self.state = 370
                self.match(QuilParser.LBRACKET)
                self.state = 371
                self.match(QuilParser.INT)
                self.state = 372
                self.match(QuilParser.RBRACKET)
                pass


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


    class DefLabelContext(ParserRuleContext):

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

        def LABEL(self):
            return self.getToken(QuilParser.LABEL, 0)

        def label(self):
            return self.getTypedRuleContext(QuilParser.LabelContext,0)


        def getRuleIndex(self):
            return QuilParser.RULE_defLabel

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

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




    def defLabel(self):

        localctx = QuilParser.DefLabelContext(self, self._ctx, self.state)
        self.enterRule(localctx, 52, self.RULE_defLabel)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 375
            self.match(QuilParser.LABEL)
            self.state = 376
            self.label()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class LabelContext(ParserRuleContext):

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

        def AT(self):
            return self.getToken(QuilParser.AT, 0)

        def IDENTIFIER(self):
            return self.getToken(QuilParser.IDENTIFIER, 0)

        def getRuleIndex(self):
            return QuilParser.RULE_label

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

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




    def label(self):

        localctx = QuilParser.LabelContext(self, self._ctx, self.state)
        self.enterRule(localctx, 54, self.RULE_label)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 378
            self.match(QuilParser.AT)
            self.state = 379
            self.match(QuilParser.IDENTIFIER)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class HaltContext(ParserRuleContext):

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

        def HALT(self):
            return self.getToken(QuilParser.HALT, 0)

        def getRuleIndex(self):
            return QuilParser.RULE_halt

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

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




    def halt(self):

        localctx = QuilParser.HaltContext(self, self._ctx, self.state)
        self.enterRule(localctx, 56, self.RULE_halt)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 381
            self.match(QuilParser.HALT)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class JumpContext(ParserRuleContext):

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

        def JUMP(self):
            return self.getToken(QuilParser.JUMP, 0)

        def label(self):
            return self.getTypedRuleContext(QuilParser.LabelContext,0)


        def getRuleIndex(self):
            return QuilParser.RULE_jump

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

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




    def jump(self):

        localctx = QuilParser.JumpContext(self, self._ctx, self.state)
        self.enterRule(localctx, 58, self.RULE_jump)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 383
            self.match(QuilParser.JUMP)
            self.state = 384
            self.label()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class JumpWhenContext(ParserRuleContext):

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

        def JUMPWHEN(self):
            return self.getToken(QuilParser.JUMPWHEN, 0)

        def label(self):
            return self.getTypedRuleContext(QuilParser.LabelContext,0)


        def addr(self):
            return self.getTypedRuleContext(QuilParser.AddrContext,0)


        def getRuleIndex(self):
            return QuilParser.RULE_jumpWhen

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

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




    def jumpWhen(self):

        localctx = QuilParser.JumpWhenContext(self, self._ctx, self.state)
        self.enterRule(localctx, 60, self.RULE_jumpWhen)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 386
            self.match(QuilParser.JUMPWHEN)
            self.state = 387
            self.label()
            self.state = 388
            self.addr()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class JumpUnlessContext(ParserRuleContext):

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

        def JUMPUNLESS(self):
            return self.getToken(QuilParser.JUMPUNLESS, 0)

        def label(self):
            return self.getTypedRuleContext(QuilParser.LabelContext,0)


        def addr(self):
            return self.getTypedRuleContext(QuilParser.AddrContext,0)


        def getRuleIndex(self):
            return QuilParser.RULE_jumpUnless

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

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




    def jumpUnless(self):

        localctx = QuilParser.JumpUnlessContext(self, self._ctx, self.state)
        self.enterRule(localctx, 62, self.RULE_jumpUnless)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 390
            self.match(QuilParser.JUMPUNLESS)
            self.state = 391
            self.label()
            self.state = 392
            self.addr()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class ResetStateContext(ParserRuleContext):

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

        def RESET(self):
            return self.getToken(QuilParser.RESET, 0)

        def qubit(self):
            return self.getTypedRuleContext(QuilParser.QubitContext,0)


        def getRuleIndex(self):
            return QuilParser.RULE_resetState

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

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




    def resetState(self):

        localctx = QuilParser.ResetStateContext(self, self._ctx, self.state)
        self.enterRule(localctx, 64, self.RULE_resetState)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 394
            self.match(QuilParser.RESET)
            self.state = 396
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==QuilParser.INT:
                self.state = 395
                self.qubit()


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


    class WaitContext(ParserRuleContext):

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

        def WAIT(self):
            return self.getToken(QuilParser.WAIT, 0)

        def getRuleIndex(self):
            return QuilParser.RULE_wait

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

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




    def wait(self):

        localctx = QuilParser.WaitContext(self, self._ctx, self.state)
        self.enterRule(localctx, 66, self.RULE_wait)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 398
            self.match(QuilParser.WAIT)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class MemoryDescriptorContext(ParserRuleContext):

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

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

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

        def LBRACKET(self):
            return self.getToken(QuilParser.LBRACKET, 0)

        def INT(self):
            return self.getToken(QuilParser.INT, 0)

        def RBRACKET(self):
            return self.getToken(QuilParser.RBRACKET, 0)

        def SHARING(self):
            return self.getToken(QuilParser.SHARING, 0)

        def offsetDescriptor(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(QuilParser.OffsetDescriptorContext)
            else:
                return self.getTypedRuleContext(QuilParser.OffsetDescriptorContext,i)


        def getRuleIndex(self):
            return QuilParser.RULE_memoryDescriptor

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

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




    def memoryDescriptor(self):

        localctx = QuilParser.MemoryDescriptorContext(self, self._ctx, self.state)
        self.enterRule(localctx, 68, self.RULE_memoryDescriptor)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 400
            self.match(QuilParser.DECLARE)
            self.state = 401
            self.match(QuilParser.IDENTIFIER)
            self.state = 402
            self.match(QuilParser.IDENTIFIER)
            self.state = 406
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==QuilParser.LBRACKET:
                self.state = 403
                self.match(QuilParser.LBRACKET)
                self.state = 404
                self.match(QuilParser.INT)
                self.state = 405
                self.match(QuilParser.RBRACKET)


            self.state = 416
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==QuilParser.SHARING:
                self.state = 408
                self.match(QuilParser.SHARING)
                self.state = 409
                self.match(QuilParser.IDENTIFIER)
                self.state = 413
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while _la==QuilParser.OFFSET:
                    self.state = 410
                    self.offsetDescriptor()
                    self.state = 415
                    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 OffsetDescriptorContext(ParserRuleContext):

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

        def OFFSET(self):
            return self.getToken(QuilParser.OFFSET, 0)

        def INT(self):
            return self.getToken(QuilParser.INT, 0)

        def IDENTIFIER(self):
            return self.getToken(QuilParser.IDENTIFIER, 0)

        def getRuleIndex(self):
            return QuilParser.RULE_offsetDescriptor

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

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




    def offsetDescriptor(self):

        localctx = QuilParser.OffsetDescriptorContext(self, self._ctx, self.state)
        self.enterRule(localctx, 70, self.RULE_offsetDescriptor)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 418
            self.match(QuilParser.OFFSET)
            self.state = 419
            self.match(QuilParser.INT)
            self.state = 420
            self.match(QuilParser.IDENTIFIER)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class ClassicalUnaryContext(ParserRuleContext):

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

        def addr(self):
            return self.getTypedRuleContext(QuilParser.AddrContext,0)


        def NEG(self):
            return self.getToken(QuilParser.NEG, 0)

        def NOT(self):
            return self.getToken(QuilParser.NOT, 0)

        def TRUE(self):
            return self.getToken(QuilParser.TRUE, 0)

        def FALSE(self):
            return self.getToken(QuilParser.FALSE, 0)

        def getRuleIndex(self):
            return QuilParser.RULE_classicalUnary

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

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




    def classicalUnary(self):

        localctx = QuilParser.ClassicalUnaryContext(self, self._ctx, self.state)
        self.enterRule(localctx, 72, self.RULE_classicalUnary)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 422
            _la = self._input.LA(1)
            if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << QuilParser.NEG) | (1 << QuilParser.NOT) | (1 << QuilParser.TRUE) | (1 << QuilParser.FALSE))) != 0)):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
            self.state = 423
            self.addr()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class ClassicalBinaryContext(ParserRuleContext):

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

        def logicalBinaryOp(self):
            return self.getTypedRuleContext(QuilParser.LogicalBinaryOpContext,0)


        def arithmeticBinaryOp(self):
            return self.getTypedRuleContext(QuilParser.ArithmeticBinaryOpContext,0)


        def move(self):
            return self.getTypedRuleContext(QuilParser.MoveContext,0)


        def exchange(self):
            return self.getTypedRuleContext(QuilParser.ExchangeContext,0)


        def convert(self):
            return self.getTypedRuleContext(QuilParser.ConvertContext,0)


        def getRuleIndex(self):
            return QuilParser.RULE_classicalBinary

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

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




    def classicalBinary(self):

        localctx = QuilParser.ClassicalBinaryContext(self, self._ctx, self.state)
        self.enterRule(localctx, 74, self.RULE_classicalBinary)
        try:
            self.state = 430
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [QuilParser.AND, QuilParser.IOR, QuilParser.XOR, QuilParser.OR]:
                self.enterOuterAlt(localctx, 1)
                self.state = 425
                self.logicalBinaryOp()
                pass
            elif token in [QuilParser.ADD, QuilParser.SUB, QuilParser.MUL, QuilParser.DIV]:
                self.enterOuterAlt(localctx, 2)
                self.state = 426
                self.arithmeticBinaryOp()
                pass
            elif token in [QuilParser.MOVE]:
                self.enterOuterAlt(localctx, 3)
                self.state = 427
                self.move()
                pass
            elif token in [QuilParser.EXCHANGE]:
                self.enterOuterAlt(localctx, 4)
                self.state = 428
                self.exchange()
                pass
            elif token in [QuilParser.CONVERT]:
                self.enterOuterAlt(localctx, 5)
                self.state = 429
                self.convert()
                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 LogicalBinaryOpContext(ParserRuleContext):

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

        def addr(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(QuilParser.AddrContext)
            else:
                return self.getTypedRuleContext(QuilParser.AddrContext,i)


        def AND(self):
            return self.getToken(QuilParser.AND, 0)

        def OR(self):
            return self.getToken(QuilParser.OR, 0)

        def IOR(self):
            return self.getToken(QuilParser.IOR, 0)

        def XOR(self):
            return self.getToken(QuilParser.XOR, 0)

        def INT(self):
            return self.getToken(QuilParser.INT, 0)

        def getRuleIndex(self):
            return QuilParser.RULE_logicalBinaryOp

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

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




    def logicalBinaryOp(self):

        localctx = QuilParser.LogicalBinaryOpContext(self, self._ctx, self.state)
        self.enterRule(localctx, 76, self.RULE_logicalBinaryOp)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 432
            _la = self._input.LA(1)
            if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << QuilParser.AND) | (1 << QuilParser.IOR) | (1 << QuilParser.XOR) | (1 << QuilParser.OR))) != 0)):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
            self.state = 433
            self.addr()
            self.state = 436
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [QuilParser.IDENTIFIER, QuilParser.LBRACKET]:
                self.state = 434
                self.addr()
                pass
            elif token in [QuilParser.INT]:
                self.state = 435
                self.match(QuilParser.INT)
                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 ArithmeticBinaryOpContext(ParserRuleContext):

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

        def addr(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(QuilParser.AddrContext)
            else:
                return self.getTypedRuleContext(QuilParser.AddrContext,i)


        def ADD(self):
            return self.getToken(QuilParser.ADD, 0)

        def SUB(self):
            return self.getToken(QuilParser.SUB, 0)

        def MUL(self):
            return self.getToken(QuilParser.MUL, 0)

        def DIV(self):
            return self.getToken(QuilParser.DIV, 0)

        def number(self):
            return self.getTypedRuleContext(QuilParser.NumberContext,0)


        def getRuleIndex(self):
            return QuilParser.RULE_arithmeticBinaryOp

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

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




    def arithmeticBinaryOp(self):

        localctx = QuilParser.ArithmeticBinaryOpContext(self, self._ctx, self.state)
        self.enterRule(localctx, 78, self.RULE_arithmeticBinaryOp)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 438
            _la = self._input.LA(1)
            if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << QuilParser.ADD) | (1 << QuilParser.SUB) | (1 << QuilParser.MUL) | (1 << QuilParser.DIV))) != 0)):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
            self.state = 439
            self.addr()
            self.state = 442
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [QuilParser.IDENTIFIER, QuilParser.LBRACKET]:
                self.state = 440
                self.addr()
                pass
            elif token in [QuilParser.PI, QuilParser.I, QuilParser.MINUS, QuilParser.INT, QuilParser.FLOAT]:
                self.state = 441
                self.number()
                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 MoveContext(ParserRuleContext):

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

        def MOVE(self):
            return self.getToken(QuilParser.MOVE, 0)

        def addr(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(QuilParser.AddrContext)
            else:
                return self.getTypedRuleContext(QuilParser.AddrContext,i)


        def number(self):
            return self.getTypedRuleContext(QuilParser.NumberContext,0)


        def getRuleIndex(self):
            return QuilParser.RULE_move

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

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




    def move(self):

        localctx = QuilParser.MoveContext(self, self._ctx, self.state)
        self.enterRule(localctx, 80, self.RULE_move)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 444
            self.match(QuilParser.MOVE)
            self.state = 445
            self.addr()
            self.state = 448
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [QuilParser.IDENTIFIER, QuilParser.LBRACKET]:
                self.state = 446
                self.addr()
                pass
            elif token in [QuilParser.PI, QuilParser.I, QuilParser.MINUS, QuilParser.INT, QuilParser.FLOAT]:
                self.state = 447
                self.number()
                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 ExchangeContext(ParserRuleContext):

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

        def EXCHANGE(self):
            return self.getToken(QuilParser.EXCHANGE, 0)

        def addr(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(QuilParser.AddrContext)
            else:
                return self.getTypedRuleContext(QuilParser.AddrContext,i)


        def getRuleIndex(self):
            return QuilParser.RULE_exchange

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

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




    def exchange(self):

        localctx = QuilParser.ExchangeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 82, self.RULE_exchange)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 450
            self.match(QuilParser.EXCHANGE)
            self.state = 451
            self.addr()
            self.state = 452
            self.addr()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class ConvertContext(ParserRuleContext):

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

        def CONVERT(self):
            return self.getToken(QuilParser.CONVERT, 0)

        def addr(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(QuilParser.AddrContext)
            else:
                return self.getTypedRuleContext(QuilParser.AddrContext,i)


        def getRuleIndex(self):
            return QuilParser.RULE_convert

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

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




    def convert(self):

        localctx = QuilParser.ConvertContext(self, self._ctx, self.state)
        self.enterRule(localctx, 84, self.RULE_convert)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 454
            self.match(QuilParser.CONVERT)
            self.state = 455
            self.addr()
            self.state = 456
            self.addr()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class LoadContext(ParserRuleContext):

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

        def LOAD(self):
            return self.getToken(QuilParser.LOAD, 0)

        def addr(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(QuilParser.AddrContext)
            else:
                return self.getTypedRuleContext(QuilParser.AddrContext,i)


        def IDENTIFIER(self):
            return self.getToken(QuilParser.IDENTIFIER, 0)

        def getRuleIndex(self):
            return QuilParser.RULE_load

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

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




    def load(self):

        localctx = QuilParser.LoadContext(self, self._ctx, self.state)
        self.enterRule(localctx, 86, self.RULE_load)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 458
            self.match(QuilParser.LOAD)
            self.state = 459
            self.addr()
            self.state = 460
            self.match(QuilParser.IDENTIFIER)
            self.state = 461
            self.addr()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class StoreContext(ParserRuleContext):

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

        def STORE(self):
            return self.getToken(QuilParser.STORE, 0)

        def IDENTIFIER(self):
            return self.getToken(QuilParser.IDENTIFIER, 0)

        def addr(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(QuilParser.AddrContext)
            else:
                return self.getTypedRuleContext(QuilParser.AddrContext,i)


        def number(self):
            return self.getTypedRuleContext(QuilParser.NumberContext,0)


        def getRuleIndex(self):
            return QuilParser.RULE_store

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

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




    def store(self):

        localctx = QuilParser.StoreContext(self, self._ctx, self.state)
        self.enterRule(localctx, 88, self.RULE_store)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 463
            self.match(QuilParser.STORE)
            self.state = 464
            self.match(QuilParser.IDENTIFIER)
            self.state = 465
            self.addr()
            self.state = 468
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [QuilParser.IDENTIFIER, QuilParser.LBRACKET]:
                self.state = 466
                self.addr()
                pass
            elif token in [QuilParser.PI, QuilParser.I, QuilParser.MINUS, QuilParser.INT, QuilParser.FLOAT]:
                self.state = 467
                self.number()
                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 ClassicalComparisonContext(ParserRuleContext):

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

        def addr(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(QuilParser.AddrContext)
            else:
                return self.getTypedRuleContext(QuilParser.AddrContext,i)


        def EQ(self):
            return self.getToken(QuilParser.EQ, 0)

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

        def GE(self):
            return self.getToken(QuilParser.GE, 0)

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

        def LE(self):
            return self.getToken(QuilParser.LE, 0)

        def number(self):
            return self.getTypedRuleContext(QuilParser.NumberContext,0)


        def getRuleIndex(self):
            return QuilParser.RULE_classicalComparison

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

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




    def classicalComparison(self):

        localctx = QuilParser.ClassicalComparisonContext(self, self._ctx, self.state)
        self.enterRule(localctx, 90, self.RULE_classicalComparison)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 470
            _la = self._input.LA(1)
            if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << QuilParser.EQ) | (1 << QuilParser.GT) | (1 << QuilParser.GE) | (1 << QuilParser.LT) | (1 << QuilParser.LE))) != 0)):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
            self.state = 471
            self.addr()
            self.state = 472
            self.addr()
            self.state = 475
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [QuilParser.IDENTIFIER, QuilParser.LBRACKET]:
                self.state = 473
                self.addr()
                pass
            elif token in [QuilParser.PI, QuilParser.I, QuilParser.MINUS, QuilParser.INT, QuilParser.FLOAT]:
                self.state = 474
                self.number()
                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 NopContext(ParserRuleContext):

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

        def NOP(self):
            return self.getToken(QuilParser.NOP, 0)

        def getRuleIndex(self):
            return QuilParser.RULE_nop

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

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




    def nop(self):

        localctx = QuilParser.NopContext(self, self._ctx, self.state)
        self.enterRule(localctx, 92, self.RULE_nop)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 477
            self.match(QuilParser.NOP)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class IncludeContext(ParserRuleContext):

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

        def INCLUDE(self):
            return self.getToken(QuilParser.INCLUDE, 0)

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

        def getRuleIndex(self):
            return QuilParser.RULE_include

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

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




    def include(self):

        localctx = QuilParser.IncludeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 94, self.RULE_include)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 479
            self.match(QuilParser.INCLUDE)
            self.state = 480
            self.match(QuilParser.STRING)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class PragmaContext(ParserRuleContext):

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

        def PRAGMA(self):
            return self.getToken(QuilParser.PRAGMA, 0)

        def IDENTIFIER(self):
            return self.getToken(QuilParser.IDENTIFIER, 0)

        def pragma_name(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(QuilParser.Pragma_nameContext)
            else:
                return self.getTypedRuleContext(QuilParser.Pragma_nameContext,i)


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

        def getRuleIndex(self):
            return QuilParser.RULE_pragma

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

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




    def pragma(self):

        localctx = QuilParser.PragmaContext(self, self._ctx, self.state)
        self.enterRule(localctx, 96, self.RULE_pragma)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 482
            self.match(QuilParser.PRAGMA)
            self.state = 483
            self.match(QuilParser.IDENTIFIER)
            self.state = 487
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==QuilParser.IDENTIFIER or _la==QuilParser.INT:
                self.state = 484
                self.pragma_name()
                self.state = 489
                self._errHandler.sync(self)
                _la = self._input.LA(1)

            self.state = 491
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==QuilParser.STRING:
                self.state = 490
                self.match(QuilParser.STRING)


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


    class Pragma_nameContext(ParserRuleContext):

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

        def IDENTIFIER(self):
            return self.getToken(QuilParser.IDENTIFIER, 0)

        def INT(self):
            return self.getToken(QuilParser.INT, 0)

        def getRuleIndex(self):
            return QuilParser.RULE_pragma_name

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

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




    def pragma_name(self):

        localctx = QuilParser.Pragma_nameContext(self, self._ctx, self.state)
        self.enterRule(localctx, 98, self.RULE_pragma_name)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 493
            _la = self._input.LA(1)
            if not(_la==QuilParser.IDENTIFIER or _la==QuilParser.INT):
                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 ExpressionContext(ParserRuleContext):

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


        def getRuleIndex(self):
            return QuilParser.RULE_expression

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


    class NumberExpContext(ExpressionContext):

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

        def number(self):
            return self.getTypedRuleContext(QuilParser.NumberContext,0)


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

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


    class PowerExpContext(ExpressionContext):

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

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

        def POWER(self):
            return self.getToken(QuilParser.POWER, 0)

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

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


    class MulDivExpContext(ExpressionContext):

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

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

        def TIMES(self):
            return self.getToken(QuilParser.TIMES, 0)
        def DIVIDE(self):
            return self.getToken(QuilParser.DIVIDE, 0)

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

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


    class ParenthesisExpContext(ExpressionContext):

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

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

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

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

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


    class VariableExpContext(ExpressionContext):

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

        def variable(self):
            return self.getTypedRuleContext(QuilParser.VariableContext,0)


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

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


    class AddrExpContext(ExpressionContext):

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

        def addr(self):
            return self.getTypedRuleContext(QuilParser.AddrContext,0)


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

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


    class SignedExpContext(ExpressionContext):

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

        def sign(self):
            return self.getTypedRuleContext(QuilParser.SignContext,0)

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


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

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


    class AddSubExpContext(ExpressionContext):

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

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

        def PLUS(self):
            return self.getToken(QuilParser.PLUS, 0)
        def MINUS(self):
            return self.getToken(QuilParser.MINUS, 0)

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

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


    class FunctionExpContext(ExpressionContext):

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

        def function(self):
            return self.getTypedRuleContext(QuilParser.FunctionContext,0)

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

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

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

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



    def expression(self, _p:int=0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = QuilParser.ExpressionContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 100
        self.enterRecursionRule(localctx, 100, self.RULE_expression, _p)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 511
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,45,self._ctx)
            if la_ == 1:
                localctx = QuilParser.ParenthesisExpContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx

                self.state = 496
                self.match(QuilParser.LPAREN)
                self.state = 497
                self.expression(0)
                self.state = 498
                self.match(QuilParser.RPAREN)
                pass

            elif la_ == 2:
                localctx = QuilParser.SignedExpContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 500
                self.sign()
                self.state = 501
                self.expression(8)
                pass

            elif la_ == 3:
                localctx = QuilParser.FunctionExpContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 503
                self.function()
                self.state = 504
                self.match(QuilParser.LPAREN)
                self.state = 505
                self.expression(0)
                self.state = 506
                self.match(QuilParser.RPAREN)
                pass

            elif la_ == 4:
                localctx = QuilParser.NumberExpContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 508
                self.number()
                pass

            elif la_ == 5:
                localctx = QuilParser.VariableExpContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 509
                self.variable()
                pass

            elif la_ == 6:
                localctx = QuilParser.AddrExpContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 510
                self.addr()
                pass


            self._ctx.stop = self._input.LT(-1)
            self.state = 524
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,47,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 = 522
                    self._errHandler.sync(self)
                    la_ = self._interp.adaptivePredict(self._input,46,self._ctx)
                    if la_ == 1:
                        localctx = QuilParser.PowerExpContext(self, QuilParser.ExpressionContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expression)
                        self.state = 513
                        if not self.precpred(self._ctx, 7):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 7)")
                        self.state = 514
                        self.match(QuilParser.POWER)
                        self.state = 515
                        self.expression(7)
                        pass

                    elif la_ == 2:
                        localctx = QuilParser.MulDivExpContext(self, QuilParser.ExpressionContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expression)
                        self.state = 516
                        if not self.precpred(self._ctx, 6):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 6)")
                        self.state = 517
                        _la = self._input.LA(1)
                        if not(_la==QuilParser.TIMES or _la==QuilParser.DIVIDE):
                            self._errHandler.recoverInline(self)
                        else:
                            self._errHandler.reportMatch(self)
                            self.consume()
                        self.state = 518
                        self.expression(7)
                        pass

                    elif la_ == 3:
                        localctx = QuilParser.AddSubExpContext(self, QuilParser.ExpressionContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expression)
                        self.state = 519
                        if not self.precpred(self._ctx, 5):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 5)")
                        self.state = 520
                        _la = self._input.LA(1)
                        if not(_la==QuilParser.PLUS or _la==QuilParser.MINUS):
                            self._errHandler.recoverInline(self)
                        else:
                            self._errHandler.reportMatch(self)
                            self.consume()
                        self.state = 521
                        self.expression(6)
                        pass

             
                self.state = 526
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,47,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 FunctionContext(ParserRuleContext):

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

        def SIN(self):
            return self.getToken(QuilParser.SIN, 0)

        def COS(self):
            return self.getToken(QuilParser.COS, 0)

        def SQRT(self):
            return self.getToken(QuilParser.SQRT, 0)

        def EXP(self):
            return self.getToken(QuilParser.EXP, 0)

        def CIS(self):
            return self.getToken(QuilParser.CIS, 0)

        def getRuleIndex(self):
            return QuilParser.RULE_function

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

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




    def function(self):

        localctx = QuilParser.FunctionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 102, self.RULE_function)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 527
            _la = self._input.LA(1)
            if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << QuilParser.SIN) | (1 << QuilParser.COS) | (1 << QuilParser.SQRT) | (1 << QuilParser.EXP) | (1 << QuilParser.CIS))) != 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 SignContext(ParserRuleContext):

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

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

        def MINUS(self):
            return self.getToken(QuilParser.MINUS, 0)

        def getRuleIndex(self):
            return QuilParser.RULE_sign

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

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




    def sign(self):

        localctx = QuilParser.SignContext(self, self._ctx, self.state)
        self.enterRule(localctx, 104, self.RULE_sign)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 529
            _la = self._input.LA(1)
            if not(_la==QuilParser.PLUS or _la==QuilParser.MINUS):
                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 NumberContext(ParserRuleContext):

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

        def realN(self):
            return self.getTypedRuleContext(QuilParser.RealNContext,0)


        def imaginaryN(self):
            return self.getTypedRuleContext(QuilParser.ImaginaryNContext,0)


        def I(self):
            return self.getToken(QuilParser.I, 0)

        def PI(self):
            return self.getToken(QuilParser.PI, 0)

        def MINUS(self):
            return self.getToken(QuilParser.MINUS, 0)

        def getRuleIndex(self):
            return QuilParser.RULE_number

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

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




    def number(self):

        localctx = QuilParser.NumberContext(self, self._ctx, self.state)
        self.enterRule(localctx, 106, self.RULE_number)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 532
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==QuilParser.MINUS:
                self.state = 531
                self.match(QuilParser.MINUS)


            self.state = 538
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,49,self._ctx)
            if la_ == 1:
                self.state = 534
                self.realN()
                pass

            elif la_ == 2:
                self.state = 535
                self.imaginaryN()
                pass

            elif la_ == 3:
                self.state = 536
                self.match(QuilParser.I)
                pass

            elif la_ == 4:
                self.state = 537
                self.match(QuilParser.PI)
                pass


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


    class ImaginaryNContext(ParserRuleContext):

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

        def realN(self):
            return self.getTypedRuleContext(QuilParser.RealNContext,0)


        def I(self):
            return self.getToken(QuilParser.I, 0)

        def getRuleIndex(self):
            return QuilParser.RULE_imaginaryN

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

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




    def imaginaryN(self):

        localctx = QuilParser.ImaginaryNContext(self, self._ctx, self.state)
        self.enterRule(localctx, 108, self.RULE_imaginaryN)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 540
            self.realN()
            self.state = 541
            self.match(QuilParser.I)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class RealNContext(ParserRuleContext):

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

        def FLOAT(self):
            return self.getToken(QuilParser.FLOAT, 0)

        def INT(self):
            return self.getToken(QuilParser.INT, 0)

        def getRuleIndex(self):
            return QuilParser.RULE_realN

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

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




    def realN(self):

        localctx = QuilParser.RealNContext(self, self._ctx, self.state)
        self.enterRule(localctx, 110, self.RULE_realN)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 543
            _la = self._input.LA(1)
            if not(_la==QuilParser.INT or _la==QuilParser.FLOAT):
                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



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

    def expression_sempred(self, localctx:ExpressionContext, predIndex:int):
            if predIndex == 0:
                return self.precpred(self._ctx, 7)
         

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

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




