# Copyright 2021 SpinQ Technology Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Generated from Qasm2.g4 by ANTLR 4.9.2
# encoding: utf-8
from antlr4 import *
from io import StringIO
import sys

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


def serializedATN():
    with StringIO() as buf:
        buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3Y")
        buf.write("\u02b9\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\4:\t:\4;\t")
        buf.write(";\4<\t<\4=\t=\4>\t>\4?\t?\4@\t@\4A\tA\4B\tB\4C\tC\4D\t")
        buf.write("D\4E\tE\4F\tF\4G\tG\4H\tH\4I\tI\4J\tJ\3\2\3\2\3\2\7\2")
        buf.write("\u0098\n\2\f\2\16\2\u009b\13\2\3\2\3\2\3\3\5\3\u00a0\n")
        buf.write("\3\3\3\7\3\u00a3\n\3\f\3\16\3\u00a6\13\3\3\4\3\4\3\4\3")
        buf.write("\4\3\5\3\5\3\5\3\5\3\6\3\6\3\6\5\6\u00b3\n\6\3\7\3\7\3")
        buf.write("\7\5\7\u00b8\n\7\3\b\3\b\3\b\3\t\3\t\5\t\u00bf\n\t\3\t")
        buf.write("\3\t\3\n\3\n\3\n\3\13\3\13\3\13\3\f\3\f\3\f\3\f\3\r\3")
        buf.write("\r\3\r\3\r\3\r\3\r\3\16\3\16\7\16\u00d5\n\16\f\16\16\16")
        buf.write("\u00d8\13\16\3\16\3\16\3\17\3\17\3\17\5\17\u00df\n\17")
        buf.write("\3\20\3\20\3\20\5\20\u00e4\n\20\3\20\3\20\5\20\u00e8\n")
        buf.write("\20\3\20\5\20\u00eb\n\20\3\21\3\21\3\21\7\21\u00f0\n\21")
        buf.write("\f\21\16\21\u00f3\13\21\3\21\3\21\3\22\3\22\3\23\3\23")
        buf.write("\3\24\3\24\3\25\3\25\3\26\3\26\3\26\3\26\3\26\3\26\3\26")
        buf.write("\3\26\3\26\5\26\u0108\n\26\5\26\u010a\n\26\3\27\3\27\3")
        buf.write("\27\5\27\u010f\n\27\3\30\3\30\3\30\3\30\5\30\u0115\n\30")
        buf.write("\3\31\3\31\3\31\3\31\5\31\u011b\n\31\3\32\3\32\3\32\5")
        buf.write("\32\u0120\n\32\3\33\3\33\3\33\5\33\u0125\n\33\3\33\3\33")
        buf.write("\5\33\u0129\n\33\3\33\5\33\u012c\n\33\3\33\5\33\u012f")
        buf.write("\n\33\3\34\3\34\3\34\3\34\5\34\u0135\n\34\3\35\3\35\3")
        buf.write("\35\7\35\u013a\n\35\f\35\16\35\u013d\13\35\3\35\3\35\3")
        buf.write("\36\3\36\3\36\3\36\3\36\3\36\3\36\5\36\u0148\n\36\3\36")
        buf.write("\3\36\3\36\3\36\3\36\5\36\u014f\n\36\3\36\3\36\5\36\u0153")
        buf.write("\n\36\3\36\5\36\u0156\n\36\3\37\3\37\3\37\7\37\u015b\n")
        buf.write("\37\f\37\16\37\u015e\13\37\3\37\3\37\3 \3 \3 \3 \3 \3")
        buf.write(" \3 \3 \5 \u016a\n \5 \u016c\n \3 \3 \3 \7 \u0171\n \f")
        buf.write(" \16 \u0174\13 \3!\3!\3!\7!\u0179\n!\f!\16!\u017c\13!")
        buf.write("\3!\3!\3\"\3\"\5\"\u0182\n\"\3\"\3\"\5\"\u0186\n\"\3\"")
        buf.write("\3\"\5\"\u018a\n\"\3\"\3\"\3#\3#\3#\3#\3$\3$\5$\u0194")
        buf.write("\n$\3$\3$\3%\3%\3&\3&\5&\u019c\n&\3&\3&\3\'\3\'\7\'\u01a2")
        buf.write("\n\'\f\'\16\'\u01a5\13\'\3\'\3\'\3(\3(\3(\7(\u01ac\n(")
        buf.write("\f(\16(\u01af\13(\3(\5(\u01b2\n(\3)\3)\3)\3*\3*\3*\5*")
        buf.write("\u01ba\n*\3+\3+\3+\3,\3,\3,\5,\u01c2\n,\3,\3,\3,\3,\5")
        buf.write(",\u01c8\n,\3-\3-\3-\3.\3.\3.\5.\u01d0\n.\3.\5.\u01d3\n")
        buf.write(".\3.\3.\3/\3/\3\60\3\60\3\61\3\61\3\62\3\62\3\63\3\63")
        buf.write("\3\63\3\64\3\64\3\64\3\64\3\64\3\64\3\64\5\64\u01e9\n")
        buf.write("\64\3\64\3\64\3\64\7\64\u01ee\n\64\f\64\16\64\u01f1\13")
        buf.write("\64\3\65\3\65\3\65\3\65\3\65\3\65\7\65\u01f9\n\65\f\65")
        buf.write("\16\65\u01fc\13\65\3\66\3\66\3\66\3\66\3\66\3\66\7\66")
        buf.write("\u0204\n\66\f\66\16\66\u0207\13\66\3\67\3\67\3\67\3\67")
        buf.write("\3\67\3\67\7\67\u020f\n\67\f\67\16\67\u0212\13\67\38\3")
        buf.write("8\38\38\38\38\78\u021a\n8\f8\168\u021d\138\39\39\39\3")
        buf.write("9\39\39\39\79\u0226\n9\f9\169\u0229\139\3:\3:\3:\3:\3")
        buf.write(":\3:\3:\7:\u0232\n:\f:\16:\u0235\13:\3;\3;\3;\3;\3;\3")
        buf.write(";\7;\u023d\n;\f;\16;\u0240\13;\3<\3<\3<\3<\3<\3<\7<\u0248")
        buf.write("\n<\f<\16<\u024b\13<\3=\3=\3=\5=\u0250\n=\3=\3=\3=\3=")
        buf.write("\5=\u0256\n=\7=\u0258\n=\f=\16=\u025b\13=\3>\3>\3>\3?")
        buf.write("\3?\3?\3?\3?\3?\3?\3?\3?\3?\3?\3?\3?\3?\3?\3?\5?\u0270")
        buf.write("\n?\3?\3?\3?\3?\3?\3?\3?\7?\u0279\n?\f?\16?\u027c\13?")
        buf.write("\3@\3@\3A\3A\3B\3B\5B\u0284\nB\3B\3B\3B\3B\3C\3C\3D\3")
        buf.write("D\3E\3E\3E\7E\u0291\nE\fE\16E\u0294\13E\3E\3E\3F\3F\3")
        buf.write("F\3G\3G\3H\3H\3H\3H\3H\3H\5H\u02a3\nH\3I\3I\3I\7I\u02a8")
        buf.write("\nI\fI\16I\u02ab\13I\3I\5I\u02ae\nI\3J\3J\3J\3J\3J\3J")
        buf.write("\3J\5J\u02b7\nJ\3J\2\16>fhjlnprtvx|K\2\4\6\b\n\f\16\20")
        buf.write("\22\24\26\30\32\34\36 \"$&(*,.\60\62\64\668:<>@BDFHJL")
        buf.write("NPRTVXZ\\^`bdfhjlnprtvxz|~\u0080\u0082\u0084\u0086\u0088")
        buf.write("\u008a\u008c\u008e\u0090\u0092\2\21\4\2RRUU\3\2\7\b\3")
        buf.write("\2\t\f\4\2\22\23TT\4\2\26\27KK\3\2\30\33\3\2\34\35\4\2")
        buf.write("\20\20\36\36\3\2\"#\3\2JK\3\2LN\3\2$%\3\2&\'\3\2(\61\4")
        buf.write("\2\62;HH\2\u02c6\2\u0094\3\2\2\2\4\u009f\3\2\2\2\6\u00a7")
        buf.write("\3\2\2\2\b\u00ab\3\2\2\2\n\u00b2\3\2\2\2\f\u00b7\3\2\2")
        buf.write("\2\16\u00b9\3\2\2\2\20\u00be\3\2\2\2\22\u00c2\3\2\2\2")
        buf.write("\24\u00c5\3\2\2\2\26\u00c8\3\2\2\2\30\u00cc\3\2\2\2\32")
        buf.write("\u00d6\3\2\2\2\34\u00db\3\2\2\2\36\u00ea\3\2\2\2 \u00f1")
        buf.write("\3\2\2\2\"\u00f6\3\2\2\2$\u00f8\3\2\2\2&\u00fa\3\2\2\2")
        buf.write("(\u00fc\3\2\2\2*\u0109\3\2\2\2,\u010b\3\2\2\2.\u0110\3")
        buf.write("\2\2\2\60\u0116\3\2\2\2\62\u011c\3\2\2\2\64\u012b\3\2")
        buf.write("\2\2\66\u0134\3\2\2\28\u013b\3\2\2\2:\u0155\3\2\2\2<\u015c")
        buf.write("\3\2\2\2>\u016b\3\2\2\2@\u017a\3\2\2\2B\u017f\3\2\2\2")
        buf.write("D\u018d\3\2\2\2F\u0191\3\2\2\2H\u0197\3\2\2\2J\u0199\3")
        buf.write("\2\2\2L\u019f\3\2\2\2N\u01b1\3\2\2\2P\u01b3\3\2\2\2R\u01b9")
        buf.write("\3\2\2\2T\u01bb\3\2\2\2V\u01c7\3\2\2\2X\u01c9\3\2\2\2")
        buf.write("Z\u01cc\3\2\2\2\\\u01d6\3\2\2\2^\u01d8\3\2\2\2`\u01da")
        buf.write("\3\2\2\2b\u01dc\3\2\2\2d\u01de\3\2\2\2f\u01e8\3\2\2\2")
        buf.write("h\u01f2\3\2\2\2j\u01fd\3\2\2\2l\u0208\3\2\2\2n\u0213\3")
        buf.write("\2\2\2p\u021e\3\2\2\2r\u022a\3\2\2\2t\u0236\3\2\2\2v\u0241")
        buf.write("\3\2\2\2x\u024f\3\2\2\2z\u025c\3\2\2\2|\u026f\3\2\2\2")
        buf.write("~\u027d\3\2\2\2\u0080\u027f\3\2\2\2\u0082\u0283\3\2\2")
        buf.write("\2\u0084\u0289\3\2\2\2\u0086\u028b\3\2\2\2\u0088\u0292")
        buf.write("\3\2\2\2\u008a\u0297\3\2\2\2\u008c\u029a\3\2\2\2\u008e")
        buf.write("\u02a2\3\2\2\2\u0090\u02ad\3\2\2\2\u0092\u02af\3\2\2\2")
        buf.write("\u0094\u0099\5\4\3\2\u0095\u0098\5\n\6\2\u0096\u0098\5")
        buf.write("\f\7\2\u0097\u0095\3\2\2\2\u0097\u0096\3\2\2\2\u0098\u009b")
        buf.write("\3\2\2\2\u0099\u0097\3\2\2\2\u0099\u009a\3\2\2\2\u009a")
        buf.write("\u009c\3\2\2\2\u009b\u0099\3\2\2\2\u009c\u009d\7\2\2\3")
        buf.write("\u009d\3\3\2\2\2\u009e\u00a0\5\6\4\2\u009f\u009e\3\2\2")
        buf.write("\2\u009f\u00a0\3\2\2\2\u00a0\u00a4\3\2\2\2\u00a1\u00a3")
        buf.write("\5\b\5\2\u00a2\u00a1\3\2\2\2\u00a3\u00a6\3\2\2\2\u00a4")
        buf.write("\u00a2\3\2\2\2\u00a4\u00a5\3\2\2\2\u00a5\5\3\2\2\2\u00a6")
        buf.write("\u00a4\3\2\2\2\u00a7\u00a8\7\3\2\2\u00a8\u00a9\t\2\2\2")
        buf.write("\u00a9\u00aa\7E\2\2\u00aa\7\3\2\2\2\u00ab\u00ac\7\4\2")
        buf.write("\2\u00ac\u00ad\7W\2\2\u00ad\u00ae\7E\2\2\u00ae\t\3\2\2")
        buf.write("\2\u00af\u00b3\5\16\b\2\u00b0\u00b3\5D#\2\u00b1\u00b3")
        buf.write("\5\20\t\2\u00b2\u00af\3\2\2\2\u00b2\u00b0\3\2\2\2\u00b2")
        buf.write("\u00b1\3\2\2\2\u00b3\13\3\2\2\2\u00b4\u00b8\5P)\2\u00b5")
        buf.write("\u00b8\5\22\n\2\u00b6\u00b8\5\u0092J\2\u00b7\u00b4\3\2")
        buf.write("\2\2\u00b7\u00b5\3\2\2\2\u00b7\u00b6\3\2\2\2\u00b8\r\3")
        buf.write("\2\2\2\u00b9\u00ba\5\34\17\2\u00ba\u00bb\7E\2\2\u00bb")
        buf.write("\17\3\2\2\2\u00bc\u00bf\5\66\34\2\u00bd\u00bf\5,\27\2")
        buf.write("\u00be\u00bc\3\2\2\2\u00be\u00bd\3\2\2\2\u00bf\u00c0\3")
        buf.write("\2\2\2\u00c0\u00c1\7E\2\2\u00c1\21\3\2\2\2\u00c2\u00c3")
        buf.write("\5V,\2\u00c3\u00c4\7E\2\2\u00c4\23\3\2\2\2\u00c5\u00c6")
        buf.write("\7I\2\2\u00c6\u00c7\5*\26\2\u00c7\25\3\2\2\2\u00c8\u00c9")
        buf.write("\7>\2\2\u00c9\u00ca\5f\64\2\u00ca\u00cb\7?\2\2\u00cb\27")
        buf.write("\3\2\2\2\u00cc\u00cd\7>\2\2\u00cd\u00ce\5f\64\2\u00ce")
        buf.write("\u00cf\7G\2\2\u00cf\u00d0\5f\64\2\u00d0\u00d1\7?\2\2\u00d1")
        buf.write("\31\3\2\2\2\u00d2\u00d3\7T\2\2\u00d3\u00d5\7G\2\2\u00d4")
        buf.write("\u00d2\3\2\2\2\u00d5\u00d8\3\2\2\2\u00d6\u00d4\3\2\2\2")
        buf.write("\u00d6\u00d7\3\2\2\2\u00d7\u00d9\3\2\2\2\u00d8\u00d6\3")
        buf.write("\2\2\2\u00d9\u00da\7T\2\2\u00da\33\3\2\2\2\u00db\u00dc")
        buf.write("\7\5\2\2\u00dc\u00de\7T\2\2\u00dd\u00df\5\26\f\2\u00de")
        buf.write("\u00dd\3\2\2\2\u00de\u00df\3\2\2\2\u00df\35\3\2\2\2\u00e0")
        buf.write("\u00e1\7\5\2\2\u00e1\u00e3\7T\2\2\u00e2\u00e4\5\26\f\2")
        buf.write("\u00e3\u00e2\3\2\2\2\u00e3\u00e4\3\2\2\2\u00e4\u00eb\3")
        buf.write("\2\2\2\u00e5\u00e7\7\6\2\2\u00e6\u00e8\5\26\f\2\u00e7")
        buf.write("\u00e6\3\2\2\2\u00e7\u00e8\3\2\2\2\u00e8\u00e9\3\2\2\2")
        buf.write("\u00e9\u00eb\7T\2\2\u00ea\u00e0\3\2\2\2\u00ea\u00e5\3")
        buf.write("\2\2\2\u00eb\37\3\2\2\2\u00ec\u00ed\5\36\20\2\u00ed\u00ee")
        buf.write("\7G\2\2\u00ee\u00f0\3\2\2\2\u00ef\u00ec\3\2\2\2\u00f0")
        buf.write("\u00f3\3\2\2\2\u00f1\u00ef\3\2\2\2\u00f1\u00f2\3\2\2\2")
        buf.write("\u00f2\u00f4\3\2\2\2\u00f3\u00f1\3\2\2\2\u00f4\u00f5\5")
        buf.write("\36\20\2\u00f5!\3\2\2\2\u00f6\u00f7\t\3\2\2\u00f7#\3\2")
        buf.write("\2\2\u00f8\u00f9\t\4\2\2\u00f9%\3\2\2\2\u00fa\u00fb\7")
        buf.write("\r\2\2\u00fb\'\3\2\2\2\u00fc\u00fd\7\16\2\2\u00fd)\3\2")
        buf.write("\2\2\u00fe\u00ff\5$\23\2\u00ff\u0100\5\26\f\2\u0100\u010a")
        buf.write("\3\2\2\2\u0101\u0102\5&\24\2\u0102\u0103\5\30\r\2\u0103")
        buf.write("\u010a\3\2\2\2\u0104\u010a\5(\25\2\u0105\u0107\5\"\22")
        buf.write("\2\u0106\u0108\5\26\f\2\u0107\u0106\3\2\2\2\u0107\u0108")
        buf.write("\3\2\2\2\u0108\u010a\3\2\2\2\u0109\u00fe\3\2\2\2\u0109")
        buf.write("\u0101\3\2\2\2\u0109\u0104\3\2\2\2\u0109\u0105\3\2\2\2")
        buf.write("\u010a+\3\2\2\2\u010b\u010c\7\17\2\2\u010c\u010e\7T\2")
        buf.write("\2\u010d\u010f\5\u008aF\2\u010e\u010d\3\2\2\2\u010e\u010f")
        buf.write("\3\2\2\2\u010f-\3\2\2\2\u0110\u0111\5$\23\2\u0111\u0112")
        buf.write("\5\26\f\2\u0112\u0114\7T\2\2\u0113\u0115\5\u008aF\2\u0114")
        buf.write("\u0113\3\2\2\2\u0114\u0115\3\2\2\2\u0115/\3\2\2\2\u0116")
        buf.write("\u0117\5&\24\2\u0117\u0118\5\30\r\2\u0118\u011a\7T\2\2")
        buf.write("\u0119\u011b\5\u008aF\2\u011a\u0119\3\2\2\2\u011a\u011b")
        buf.write("\3\2\2\2\u011b\61\3\2\2\2\u011c\u011d\5(\25\2\u011d\u011f")
        buf.write("\7T\2\2\u011e\u0120\5\u008aF\2\u011f\u011e\3\2\2\2\u011f")
        buf.write("\u0120\3\2\2\2\u0120\63\3\2\2\2\u0121\u0122\7\b\2\2\u0122")
        buf.write("\u0124\7T\2\2\u0123\u0125\5\26\f\2\u0124\u0123\3\2\2\2")
        buf.write("\u0124\u0125\3\2\2\2\u0125\u012c\3\2\2\2\u0126\u0128\7")
        buf.write("\7\2\2\u0127\u0129\5\26\f\2\u0128\u0127\3\2\2\2\u0128")
        buf.write("\u0129\3\2\2\2\u0129\u012a\3\2\2\2\u012a\u012c\7T\2\2")
        buf.write("\u012b\u0121\3\2\2\2\u012b\u0126\3\2\2\2\u012c\u012e\3")
        buf.write("\2\2\2\u012d\u012f\5\u008aF\2\u012e\u012d\3\2\2\2\u012e")
        buf.write("\u012f\3\2\2\2\u012f\65\3\2\2\2\u0130\u0135\5.\30\2\u0131")
        buf.write("\u0135\5\60\31\2\u0132\u0135\5\62\32\2\u0133\u0135\5\64")
        buf.write("\33\2\u0134\u0130\3\2\2\2\u0134\u0131\3\2\2\2\u0134\u0132")
        buf.write("\3\2\2\2\u0134\u0133\3\2\2\2\u0135\67\3\2\2\2\u0136\u0137")
        buf.write("\5*\26\2\u0137\u0138\7G\2\2\u0138\u013a\3\2\2\2\u0139")
        buf.write("\u0136\3\2\2\2\u013a\u013d\3\2\2\2\u013b\u0139\3\2\2\2")
        buf.write("\u013b\u013c\3\2\2\2\u013c\u013e\3\2\2\2\u013d\u013b\3")
        buf.write("\2\2\2\u013e\u013f\5*\26\2\u013f9\3\2\2\2\u0140\u0141")
        buf.write("\5$\23\2\u0141\u0142\5\26\f\2\u0142\u0148\3\2\2\2\u0143")
        buf.write("\u0144\5&\24\2\u0144\u0145\5\30\r\2\u0145\u0148\3\2\2")
        buf.write("\2\u0146\u0148\5(\25\2\u0147\u0140\3\2\2\2\u0147\u0143")
        buf.write("\3\2\2\2\u0147\u0146\3\2\2\2\u0148\u0149\3\2\2\2\u0149")
        buf.write("\u014a\7T\2\2\u014a\u0156\3\2\2\2\u014b\u014c\7\b\2\2")
        buf.write("\u014c\u014e\7T\2\2\u014d\u014f\5\26\f\2\u014e\u014d\3")
        buf.write("\2\2\2\u014e\u014f\3\2\2\2\u014f\u0156\3\2\2\2\u0150\u0152")
        buf.write("\7\7\2\2\u0151\u0153\5\26\f\2\u0152\u0151\3\2\2\2\u0152")
        buf.write("\u0153\3\2\2\2\u0153\u0154\3\2\2\2\u0154\u0156\7T\2\2")
        buf.write("\u0155\u0147\3\2\2\2\u0155\u014b\3\2\2\2\u0155\u0150\3")
        buf.write("\2\2\2\u0156;\3\2\2\2\u0157\u0158\5:\36\2\u0158\u0159")
        buf.write("\7G\2\2\u0159\u015b\3\2\2\2\u015a\u0157\3\2\2\2\u015b")
        buf.write("\u015e\3\2\2\2\u015c\u015a\3\2\2\2\u015c\u015d\3\2\2\2")
        buf.write("\u015d\u015f\3\2\2\2\u015e\u015c\3\2\2\2\u015f\u0160\5")
        buf.write(":\36\2\u0160=\3\2\2\2\u0161\u0162\b \1\2\u0162\u0163\7")
        buf.write("T\2\2\u0163\u016c\5B\"\2\u0164\u0169\7T\2\2\u0165\u0166")
        buf.write("\7>\2\2\u0166\u0167\5\u0088E\2\u0167\u0168\7?\2\2\u0168")
        buf.write("\u016a\3\2\2\2\u0169\u0165\3\2\2\2\u0169\u016a\3\2\2\2")
        buf.write("\u016a\u016c\3\2\2\2\u016b\u0161\3\2\2\2\u016b\u0164\3")
        buf.write("\2\2\2\u016c\u0172\3\2\2\2\u016d\u016e\f\3\2\2\u016e\u016f")
        buf.write("\7\20\2\2\u016f\u0171\5> \4\u0170\u016d\3\2\2\2\u0171")
        buf.write("\u0174\3\2\2\2\u0172\u0170\3\2\2\2\u0172\u0173\3\2\2\2")
        buf.write("\u0173?\3\2\2\2\u0174\u0172\3\2\2\2\u0175\u0176\5> \2")
        buf.write("\u0176\u0177\7G\2\2\u0177\u0179\3\2\2\2\u0178\u0175\3")
        buf.write("\2\2\2\u0179\u017c\3\2\2\2\u017a\u0178\3\2\2\2\u017a\u017b")
        buf.write("\3\2\2\2\u017b\u017d\3\2\2\2\u017c\u017a\3\2\2\2\u017d")
        buf.write("\u017e\5> \2\u017eA\3\2\2\2\u017f\u0181\7>\2\2\u0180\u0182")
        buf.write("\5f\64\2\u0181\u0180\3\2\2\2\u0181\u0182\3\2\2\2\u0182")
        buf.write("\u0183\3\2\2\2\u0183\u0185\7D\2\2\u0184\u0186\5f\64\2")
        buf.write("\u0185\u0184\3\2\2\2\u0185\u0186\3\2\2\2\u0186\u0189\3")
        buf.write("\2\2\2\u0187\u0188\7D\2\2\u0188\u018a\5f\64\2\u0189\u0187")
        buf.write("\3\2\2\2\u0189\u018a\3\2\2\2\u018a\u018b\3\2\2\2\u018b")
        buf.write("\u018c\7?\2\2\u018cC\3\2\2\2\u018d\u018e\7\21\2\2\u018e")
        buf.write("\u018f\5J&\2\u018f\u0190\5L\'\2\u0190E\3\2\2\2\u0191\u0193")
        buf.write("\7B\2\2\u0192\u0194\5\32\16\2\u0193\u0192\3\2\2\2\u0193")
        buf.write("\u0194\3\2\2\2\u0194\u0195\3\2\2\2\u0195\u0196\7C\2\2")
        buf.write("\u0196G\3\2\2\2\u0197\u0198\t\5\2\2\u0198I\3\2\2\2\u0199")
        buf.write("\u019b\7T\2\2\u019a\u019c\5F$\2\u019b\u019a\3\2\2\2\u019b")
        buf.write("\u019c\3\2\2\2\u019c\u019d\3\2\2\2\u019d\u019e\5\32\16")
        buf.write("\2\u019eK\3\2\2\2\u019f\u01a3\7@\2\2\u01a0\u01a2\5P)\2")
        buf.write("\u01a1\u01a0\3\2\2\2\u01a2\u01a5\3\2\2\2\u01a3\u01a1\3")
        buf.write("\2\2\2\u01a3\u01a4\3\2\2\2\u01a4\u01a6\3\2\2\2\u01a5\u01a3")
        buf.write("\3\2\2\2\u01a6\u01a7\7A\2\2\u01a7M\3\2\2\2\u01a8\u01b2")
        buf.write("\5P)\2\u01a9\u01ad\7@\2\2\u01aa\u01ac\5P)\2\u01ab\u01aa")
        buf.write("\3\2\2\2\u01ac\u01af\3\2\2\2\u01ad\u01ab\3\2\2\2\u01ad")
        buf.write("\u01ae\3\2\2\2\u01ae\u01b0\3\2\2\2\u01af\u01ad\3\2\2\2")
        buf.write("\u01b0\u01b2\7A\2\2\u01b1\u01a8\3\2\2\2\u01b1\u01a9\3")
        buf.write("\2\2\2\u01b2O\3\2\2\2\u01b3\u01b4\5R*\2\u01b4\u01b5\7")
        buf.write("E\2\2\u01b5Q\3\2\2\2\u01b6\u01ba\5Z.\2\u01b7\u01ba\5T")
        buf.write("+\2\u01b8\u01ba\5X-\2\u01b9\u01b6\3\2\2\2\u01b9\u01b7")
        buf.write("\3\2\2\2\u01b9\u01b8\3\2\2\2\u01baS\3\2\2\2\u01bb\u01bc")
        buf.write("\7\24\2\2\u01bc\u01bd\5@!\2\u01bdU\3\2\2\2\u01be\u01c1")
        buf.write("\5T+\2\u01bf\u01c0\7I\2\2\u01c0\u01c2\5@!\2\u01c1\u01bf")
        buf.write("\3\2\2\2\u01c1\u01c2\3\2\2\2\u01c2\u01c8\3\2\2\2\u01c3")
        buf.write("\u01c4\5@!\2\u01c4\u01c5\7H\2\2\u01c5\u01c6\5T+\2\u01c6")
        buf.write("\u01c8\3\2\2\2\u01c7\u01be\3\2\2\2\u01c7\u01c3\3\2\2\2")
        buf.write("\u01c8W\3\2\2\2\u01c9\u01ca\7\25\2\2\u01ca\u01cb\5@!\2")
        buf.write("\u01cbY\3\2\2\2\u01cc\u01d2\5H%\2\u01cd\u01cf\7B\2\2\u01ce")
        buf.write("\u01d0\5\u0088E\2\u01cf\u01ce\3\2\2\2\u01cf\u01d0\3\2")
        buf.write("\2\2\u01d0\u01d1\3\2\2\2\u01d1\u01d3\7C\2\2\u01d2\u01cd")
        buf.write("\3\2\2\2\u01d2\u01d3\3\2\2\2\u01d3\u01d4\3\2\2\2\u01d4")
        buf.write("\u01d5\5@!\2\u01d5[\3\2\2\2\u01d6\u01d7\t\6\2\2\u01d7")
        buf.write("]\3\2\2\2\u01d8\u01d9\t\7\2\2\u01d9_\3\2\2\2\u01da\u01db")
        buf.write("\t\b\2\2\u01dba\3\2\2\2\u01dc\u01dd\t\t\2\2\u01ddc\3\2")
        buf.write("\2\2\u01de\u01df\5f\64\2\u01df\u01e0\7E\2\2\u01e0e\3\2")
        buf.write("\2\2\u01e1\u01e2\b\64\1\2\u01e2\u01e9\5|?\2\u01e3\u01e9")
        buf.write("\5z>\2\u01e4\u01e9\5h\65\2\u01e5\u01e6\5\u0084C\2\u01e6")
        buf.write("\u01e7\5|?\2\u01e7\u01e9\3\2\2\2\u01e8\u01e1\3\2\2\2\u01e8")
        buf.write("\u01e3\3\2\2\2\u01e8\u01e4\3\2\2\2\u01e8\u01e5\3\2\2\2")
        buf.write("\u01e9\u01ef\3\2\2\2\u01ea\u01eb\f\4\2\2\u01eb\u01ec\7")
        buf.write("\20\2\2\u01ec\u01ee\5h\65\2\u01ed\u01ea\3\2\2\2\u01ee")
        buf.write("\u01f1\3\2\2\2\u01ef\u01ed\3\2\2\2\u01ef\u01f0\3\2\2\2")
        buf.write("\u01f0g\3\2\2\2\u01f1\u01ef\3\2\2\2\u01f2\u01f3\b\65\1")
        buf.write("\2\u01f3\u01f4\5j\66\2\u01f4\u01fa\3\2\2\2\u01f5\u01f6")
        buf.write("\f\3\2\2\u01f6\u01f7\7\36\2\2\u01f7\u01f9\5j\66\2\u01f8")
        buf.write("\u01f5\3\2\2\2\u01f9\u01fc\3\2\2\2\u01fa\u01f8\3\2\2\2")
        buf.write("\u01fa\u01fb\3\2\2\2\u01fbi\3\2\2\2\u01fc\u01fa\3\2\2")
        buf.write("\2\u01fd\u01fe\b\66\1\2\u01fe\u01ff\5l\67\2\u01ff\u0205")
        buf.write("\3\2\2\2\u0200\u0201\f\3\2\2\u0201\u0202\7\37\2\2\u0202")
        buf.write("\u0204\5l\67\2\u0203\u0200\3\2\2\2\u0204\u0207\3\2\2\2")
        buf.write("\u0205\u0203\3\2\2\2\u0205\u0206\3\2\2\2\u0206k\3\2\2")
        buf.write("\2\u0207\u0205\3\2\2\2\u0208\u0209\b\67\1\2\u0209\u020a")
        buf.write("\5n8\2\u020a\u0210\3\2\2\2\u020b\u020c\f\3\2\2\u020c\u020d")
        buf.write("\7 \2\2\u020d\u020f\5n8\2\u020e\u020b\3\2\2\2\u020f\u0212")
        buf.write("\3\2\2\2\u0210\u020e\3\2\2\2\u0210\u0211\3\2\2\2\u0211")
        buf.write("m\3\2\2\2\u0212\u0210\3\2\2\2\u0213\u0214\b8\1\2\u0214")
        buf.write("\u0215\5p9\2\u0215\u021b\3\2\2\2\u0216\u0217\f\3\2\2\u0217")
        buf.write("\u0218\7!\2\2\u0218\u021a\5p9\2\u0219\u0216\3\2\2\2\u021a")
        buf.write("\u021d\3\2\2\2\u021b\u0219\3\2\2\2\u021b\u021c\3\2\2\2")
        buf.write("\u021co\3\2\2\2\u021d\u021b\3\2\2\2\u021e\u021f\b9\1\2")
        buf.write("\u021f\u0220\5r:\2\u0220\u0227\3\2\2\2\u0221\u0222\f\3")
        buf.write("\2\2\u0222\u0223\5`\61\2\u0223\u0224\5r:\2\u0224\u0226")
        buf.write("\3\2\2\2\u0225\u0221\3\2\2\2\u0226\u0229\3\2\2\2\u0227")
        buf.write("\u0225\3\2\2\2\u0227\u0228\3\2\2\2\u0228q\3\2\2\2\u0229")
        buf.write("\u0227\3\2\2\2\u022a\u022b\b:\1\2\u022b\u022c\5t;\2\u022c")
        buf.write("\u0233\3\2\2\2\u022d\u022e\f\3\2\2\u022e\u022f\5^\60\2")
        buf.write("\u022f\u0230\5t;\2\u0230\u0232\3\2\2\2\u0231\u022d\3\2")
        buf.write("\2\2\u0232\u0235\3\2\2\2\u0233\u0231\3\2\2\2\u0233\u0234")
        buf.write("\3\2\2\2\u0234s\3\2\2\2\u0235\u0233\3\2\2\2\u0236\u0237")
        buf.write("\b;\1\2\u0237\u0238\5v<\2\u0238\u023e\3\2\2\2\u0239\u023a")
        buf.write("\f\3\2\2\u023a\u023b\t\n\2\2\u023b\u023d\5v<\2\u023c\u0239")
        buf.write("\3\2\2\2\u023d\u0240\3\2\2\2\u023e\u023c\3\2\2\2\u023e")
        buf.write("\u023f\3\2\2\2\u023fu\3\2\2\2\u0240\u023e\3\2\2\2\u0241")
        buf.write("\u0242\b<\1\2\u0242\u0243\5x=\2\u0243\u0249\3\2\2\2\u0244")
        buf.write("\u0245\f\3\2\2\u0245\u0246\t\13\2\2\u0246\u0248\5x=\2")
        buf.write("\u0247\u0244\3\2\2\2\u0248\u024b\3\2\2\2\u0249\u0247\3")
        buf.write("\2\2\2\u0249\u024a\3\2\2\2\u024aw\3\2\2\2\u024b\u0249")
        buf.write("\3\2\2\2\u024c\u024d\b=\1\2\u024d\u0250\5|?\2\u024e\u0250")
        buf.write("\5z>\2\u024f\u024c\3\2\2\2\u024f\u024e\3\2\2\2\u0250\u0259")
        buf.write("\3\2\2\2\u0251\u0252\f\3\2\2\u0252\u0255\t\f\2\2\u0253")
        buf.write("\u0256\5|?\2\u0254\u0256\5z>\2\u0255\u0253\3\2\2\2\u0255")
        buf.write("\u0254\3\2\2\2\u0256\u0258\3\2\2\2\u0257\u0251\3\2\2\2")
        buf.write("\u0258\u025b\3\2\2\2\u0259\u0257\3\2\2\2\u0259\u025a\3")
        buf.write("\2\2\2\u025ay\3\2\2\2\u025b\u0259\3\2\2\2\u025c\u025d")
        buf.write("\5\\/\2\u025d\u025e\5|?\2\u025e{\3\2\2\2\u025f\u0260\b")
        buf.write("?\1\2\u0260\u0270\7O\2\2\u0261\u0270\7R\2\2\u0262\u0270")
        buf.write("\7U\2\2\u0263\u0270\5~@\2\u0264\u0270\7T\2\2\u0265\u0270")
        buf.write("\7W\2\2\u0266\u0267\7B\2\2\u0267\u0268\5f\64\2\u0268\u0269")
        buf.write("\7C\2\2\u0269\u0270\3\2\2\2\u026a\u026b\5\u0084C\2\u026b")
        buf.write("\u026c\7B\2\2\u026c\u026d\5f\64\2\u026d\u026e\7C\2\2\u026e")
        buf.write("\u0270\3\2\2\2\u026f\u025f\3\2\2\2\u026f\u0261\3\2\2\2")
        buf.write("\u026f\u0262\3\2\2\2\u026f\u0263\3\2\2\2\u026f\u0264\3")
        buf.write("\2\2\2\u026f\u0265\3\2\2\2\u026f\u0266\3\2\2\2\u026f\u026a")
        buf.write("\3\2\2\2\u0270\u027a\3\2\2\2\u0271\u0272\f\5\2\2\u0272")
        buf.write("\u0273\7>\2\2\u0273\u0274\5f\64\2\u0274\u0275\7?\2\2\u0275")
        buf.write("\u0279\3\2\2\2\u0276\u0277\f\4\2\2\u0277\u0279\5\u0080")
        buf.write("A\2\u0278\u0271\3\2\2\2\u0278\u0276\3\2\2\2\u0279\u027c")
        buf.write("\3\2\2\2\u027a\u0278\3\2\2\2\u027a\u027b\3\2\2\2\u027b")
        buf.write("}\3\2\2\2\u027c\u027a\3\2\2\2\u027d\u027e\t\r\2\2\u027e")
        buf.write("\177\3\2\2\2\u027f\u0280\t\16\2\2\u0280\u0081\3\2\2\2")
        buf.write("\u0281\u0284\5\u0084C\2\u0282\u0284\5\u0086D\2\u0283\u0281")
        buf.write("\3\2\2\2\u0283\u0282\3\2\2\2\u0284\u0285\3\2\2\2\u0285")
        buf.write("\u0286\7B\2\2\u0286\u0287\5\u0088E\2\u0287\u0288\7C\2")
        buf.write("\2\u0288\u0083\3\2\2\2\u0289\u028a\t\17\2\2\u028a\u0085")
        buf.write("\3\2\2\2\u028b\u028c\5*\26\2\u028c\u0087\3\2\2\2\u028d")
        buf.write("\u028e\5f\64\2\u028e\u028f\7G\2\2\u028f\u0291\3\2\2\2")
        buf.write("\u0290\u028d\3\2\2\2\u0291\u0294\3\2\2\2\u0292\u0290\3")
        buf.write("\2\2\2\u0292\u0293\3\2\2\2\u0293\u0295\3\2\2\2\u0294\u0292")
        buf.write("\3\2\2\2\u0295\u0296\5f\64\2\u0296\u0089\3\2\2\2\u0297")
        buf.write("\u0298\7H\2\2\u0298\u0299\5f\64\2\u0299\u008b\3\2\2\2")
        buf.write("\u029a\u029b\t\20\2\2\u029b\u008d\3\2\2\2\u029c\u029d")
        buf.write("\7@\2\2\u029d\u029e\5\u0088E\2\u029e\u029f\7A\2\2\u029f")
        buf.write("\u02a3\3\2\2\2\u02a0\u02a3\5B\"\2\u02a1\u02a3\7T\2\2\u02a2")
        buf.write("\u029c\3\2\2\2\u02a2\u02a0\3\2\2\2\u02a2\u02a1\3\2\2\2")
        buf.write("\u02a3\u008f\3\2\2\2\u02a4\u02ae\5\f\7\2\u02a5\u02a9\7")
        buf.write("@\2\2\u02a6\u02a8\5\f\7\2\u02a7\u02a6\3\2\2\2\u02a8\u02ab")
        buf.write("\3\2\2\2\u02a9\u02a7\3\2\2\2\u02a9\u02aa\3\2\2\2\u02aa")
        buf.write("\u02ac\3\2\2\2\u02ab\u02a9\3\2\2\2\u02ac\u02ae\7A\2\2")
        buf.write("\u02ad\u02a4\3\2\2\2\u02ad\u02a5\3\2\2\2\u02ae\u0091\3")
        buf.write("\2\2\2\u02af\u02b0\7<\2\2\u02b0\u02b1\7B\2\2\u02b1\u02b2")
        buf.write("\5f\64\2\u02b2\u02b3\7C\2\2\u02b3\u02b6\5\u0090I\2\u02b4")
        buf.write("\u02b5\7=\2\2\u02b5\u02b7\5\u0090I\2\u02b6\u02b4\3\2\2")
        buf.write("\2\u02b6\u02b7\3\2\2\2\u02b7\u0093\3\2\2\2G\u0097\u0099")
        buf.write("\u009f\u00a4\u00b2\u00b7\u00be\u00d6\u00de\u00e3\u00e7")
        buf.write("\u00ea\u00f1\u0107\u0109\u010e\u0114\u011a\u011f\u0124")
        buf.write("\u0128\u012b\u012e\u0134\u013b\u0147\u014e\u0152\u0155")
        buf.write("\u015c\u0169\u016b\u0172\u017a\u0181\u0185\u0189\u0193")
        buf.write("\u019b\u01a3\u01ad\u01b1\u01b9\u01c1\u01c7\u01cf\u01d2")
        buf.write("\u01e8\u01ef\u01fa\u0205\u0210\u021b\u0227\u0233\u023e")
        buf.write("\u0249\u024f\u0255\u0259\u026f\u0278\u027a\u0283\u0292")
        buf.write("\u02a2\u02a9\u02ad\u02b6")
        return buf.getvalue()


class Qasm2Parser(Parser):
    grammarFileName = "Qasm2.g4"

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

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

    sharedContextCache = PredictionContextCache()

    literalNames = ["<INVALID>", "'OPENQASM'", "'include'", "'qreg'", "'qubit'",
                    "'bit'", "'creg'", "'int'", "'uint'", "'float'", "'angle'",
                    "'fixed'", "'bool'", "'const'", "'||'", "'gate'", "'U'",
                    "'CX'", "'measure'", "'barrier'", "'~'", "'!'", "'>'",
                    "'<'", "'>='", "'<='", "'=='", "'!='", "'&&'", "'|'",
                    "'^'", "'&'", "'<<'", "'>>'", "'true'", "'false'",
                    "'++'", "'--'", "'sin'", "'cos'", "'tan'", "'exp'",
                    "'ln'", "'sqrt'", "'rotl'", "'rotr'", "'popcount'",
                    "'lengthof'", "'+='", "'-='", "'*='", "'/='", "'&='",
                    "'|='", "'~='", "'^='", "'<<='", "'>>='", "'if'", "'else'",
                    "'['", "']'", "'{'", "'}'", "'('", "')'", "':'", "';'",
                    "'.'", "','", "'='", "'->'", "'+'", "'-'", "'*'", "'/'",
                    "'%'"]

    symbolicNames = ["<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
                     "LBRACKET", "RBRACKET", "LBRACE", "RBRACE", "LPAREN",
                     "RPAREN", "COLON", "SEMICOLON", "DOT", "COMMA", "EQUALS",
                     "ARROW", "PLUS", "MINUS", "MUL", "DIV", "MOD", "Constant",
                     "Whitespace", "Newline", "Integer", "StretchN", "Identifier",
                     "RealNumber", "TimingLiteral", "StringLiteral", "LineComment",
                     "BlockComment"]

    RULE_program = 0
    RULE_header = 1
    RULE_version = 2
    RULE_include = 3
    RULE_globalStatement = 4
    RULE_statement = 5
    RULE_quantumDeclarationStatement = 6
    RULE_classicalDeclarationStatement = 7
    RULE_assignmentStatement = 8
    RULE_returnSignature = 9
    RULE_designator = 10
    RULE_doubleDesignator = 11
    RULE_identifierList = 12
    RULE_quantumDeclaration = 13
    RULE_quantumArgument = 14
    RULE_quantumArgumentList = 15
    RULE_bitType = 16
    RULE_singleDesignatorType = 17
    RULE_doubleDesignatorType = 18
    RULE_noDesignatorType = 19
    RULE_classicalType = 20
    RULE_constantDeclaration = 21
    RULE_singleDesignatorDeclaration = 22
    RULE_doubleDesignatorDeclaration = 23
    RULE_noDesignatorDeclaration = 24
    RULE_bitDeclaration = 25
    RULE_classicalDeclaration = 26
    RULE_classicalTypeList = 27
    RULE_classicalArgument = 28
    RULE_classicalArgumentList = 29
    RULE_indexIdentifier = 30
    RULE_indexIdentifierList = 31
    RULE_rangeDefinition = 32
    RULE_quantumGateDefinition = 33
    RULE_quantumGateParameter = 34
    RULE_quantumGateName = 35
    RULE_quantumGateSignature = 36
    RULE_quantumBlock = 37
    RULE_quantumLoopBlock = 38
    RULE_quantumStatement = 39
    RULE_quantumInstruction = 40
    RULE_quantumMeasurement = 41
    RULE_quantumMeasurementAssignment = 42
    RULE_quantumBarrier = 43
    RULE_quantumGateCall = 44
    RULE_unaryOperator = 45
    RULE_comparisonOperator = 46
    RULE_equalityOperator = 47
    RULE_logicalOperator = 48
    RULE_expressionStatement = 49
    RULE_expression = 50
    RULE_logicalAndExpression = 51
    RULE_bitOrExpression = 52
    RULE_xOrExpression = 53
    RULE_bitAndExpression = 54
    RULE_equalityExpression = 55
    RULE_comparisonExpression = 56
    RULE_bitShiftExpression = 57
    RULE_additiveExpression = 58
    RULE_multiplicativeExpression = 59
    RULE_unaryExpression = 60
    RULE_expressionTerminator = 61
    RULE_booleanLiteral = 62
    RULE_incrementor = 63
    RULE_builtInCall = 64
    RULE_builtInMath = 65
    RULE_castOperator = 66
    RULE_expressionList = 67
    RULE_equalsExpression = 68
    RULE_assignmentOperator = 69
    RULE_setDeclaration = 70
    RULE_programBlock = 71
    RULE_branchingStatement = 72

    ruleNames = ["program", "header", "version", "include", "globalStatement",
                 "statement", "quantumDeclarationStatement", "classicalDeclarationStatement",
                 "assignmentStatement", "returnSignature", "designator",
                 "doubleDesignator", "identifierList", "quantumDeclaration",
                 "quantumArgument", "quantumArgumentList", "bitType",
                 "singleDesignatorType", "doubleDesignatorType", "noDesignatorType",
                 "classicalType", "constantDeclaration", "singleDesignatorDeclaration",
                 "doubleDesignatorDeclaration", "noDesignatorDeclaration",
                 "bitDeclaration", "classicalDeclaration", "classicalTypeList",
                 "classicalArgument", "classicalArgumentList", "indexIdentifier",
                 "indexIdentifierList", "rangeDefinition", "quantumGateDefinition",
                 "quantumGateParameter", "quantumGateName", "quantumGateSignature",
                 "quantumBlock", "quantumLoopBlock", "quantumStatement",
                 "quantumInstruction", "quantumMeasurement", "quantumMeasurementAssignment",
                 "quantumBarrier", "quantumGateCall", "unaryOperator",
                 "comparisonOperator", "equalityOperator", "logicalOperator",
                 "expressionStatement", "expression", "logicalAndExpression",
                 "bitOrExpression", "xOrExpression", "bitAndExpression",
                 "equalityExpression", "comparisonExpression", "bitShiftExpression",
                 "additiveExpression", "multiplicativeExpression", "unaryExpression",
                 "expressionTerminator", "booleanLiteral", "incrementor",
                 "builtInCall", "builtInMath", "castOperator", "expressionList",
                 "equalsExpression", "assignmentOperator", "setDeclaration",
                 "programBlock", "branchingStatement"]

    EOF = Token.EOF
    T__0 = 1
    T__1 = 2
    T__2 = 3
    T__3 = 4
    T__4 = 5
    T__5 = 6
    T__6 = 7
    T__7 = 8
    T__8 = 9
    T__9 = 10
    T__10 = 11
    T__11 = 12
    T__12 = 13
    T__13 = 14
    T__14 = 15
    T__15 = 16
    T__16 = 17
    T__17 = 18
    T__18 = 19
    T__19 = 20
    T__20 = 21
    T__21 = 22
    T__22 = 23
    T__23 = 24
    T__24 = 25
    T__25 = 26
    T__26 = 27
    T__27 = 28
    T__28 = 29
    T__29 = 30
    T__30 = 31
    T__31 = 32
    T__32 = 33
    T__33 = 34
    T__34 = 35
    T__35 = 36
    T__36 = 37
    T__37 = 38
    T__38 = 39
    T__39 = 40
    T__40 = 41
    T__41 = 42
    T__42 = 43
    T__43 = 44
    T__44 = 45
    T__45 = 46
    T__46 = 47
    T__47 = 48
    T__48 = 49
    T__49 = 50
    T__50 = 51
    T__51 = 52
    T__52 = 53
    T__53 = 54
    T__54 = 55
    T__55 = 56
    T__56 = 57
    T__57 = 58
    T__58 = 59
    LBRACKET = 60
    RBRACKET = 61
    LBRACE = 62
    RBRACE = 63
    LPAREN = 64
    RPAREN = 65
    COLON = 66
    SEMICOLON = 67
    DOT = 68
    COMMA = 69
    EQUALS = 70
    ARROW = 71
    PLUS = 72
    MINUS = 73
    MUL = 74
    DIV = 75
    MOD = 76
    Constant = 77
    Whitespace = 78
    Newline = 79
    Integer = 80
    StretchN = 81
    Identifier = 82
    RealNumber = 83
    TimingLiteral = 84
    StringLiteral = 85
    LineComment = 86
    BlockComment = 87

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

    class ProgramContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def header(self):
            return self.getTypedRuleContext(Qasm2Parser.HeaderContext, 0)

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

        def globalStatement(self, i: int = None):
            if i is None:
                return self.getTypedRuleContexts(Qasm2Parser.GlobalStatementContext)
            else:
                return self.getTypedRuleContext(Qasm2Parser.GlobalStatementContext, i)

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

        def getRuleIndex(self):
            return Qasm2Parser.RULE_program

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

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

    def program(self):

        localctx = Qasm2Parser.ProgramContext(self, self._ctx, self.state)
        self.enterRule(localctx, 0, self.RULE_program)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 146
            self.header()
            self.state = 151
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while (((_la) & ~0x3f) == 0 and ((1 << _la) & (
                    (1 << Qasm2Parser.T__2) | (1 << Qasm2Parser.T__4) | (1 << Qasm2Parser.T__5) | (
                    1 << Qasm2Parser.T__6) | (1 << Qasm2Parser.T__7) | (1 << Qasm2Parser.T__8) | (
                            1 << Qasm2Parser.T__9) | (1 << Qasm2Parser.T__10) | (1 << Qasm2Parser.T__11) | (
                            1 << Qasm2Parser.T__12) | (1 << Qasm2Parser.T__14) | (1 << Qasm2Parser.T__15) | (
                            1 << Qasm2Parser.T__16) | (1 << Qasm2Parser.T__17) | (1 << Qasm2Parser.T__18) | (
                            1 << Qasm2Parser.T__57))) != 0) or _la == Qasm2Parser.Identifier:
                self.state = 149
                self._errHandler.sync(self)
                token = self._input.LA(1)
                if token in [Qasm2Parser.T__2, Qasm2Parser.T__4, Qasm2Parser.T__5, Qasm2Parser.T__6, Qasm2Parser.T__7,
                             Qasm2Parser.T__8, Qasm2Parser.T__9, Qasm2Parser.T__10, Qasm2Parser.T__11,
                             Qasm2Parser.T__12, Qasm2Parser.T__14]:
                    self.state = 147
                    self.globalStatement()
                    pass
                elif token in [Qasm2Parser.T__15, Qasm2Parser.T__16, Qasm2Parser.T__17, Qasm2Parser.T__18,
                               Qasm2Parser.T__57, Qasm2Parser.Identifier]:
                    self.state = 148
                    self.statement()
                    pass
                else:
                    raise NoViableAltException(self)

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

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

    class HeaderContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def version(self):
            return self.getTypedRuleContext(Qasm2Parser.VersionContext, 0)

        def include(self, i: int = None):
            if i is None:
                return self.getTypedRuleContexts(Qasm2Parser.IncludeContext)
            else:
                return self.getTypedRuleContext(Qasm2Parser.IncludeContext, i)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_header

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

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

    def header(self):

        localctx = Qasm2Parser.HeaderContext(self, self._ctx, self.state)
        self.enterRule(localctx, 2, self.RULE_header)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 157
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la == Qasm2Parser.T__0:
                self.state = 156
                self.version()

            self.state = 162
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la == Qasm2Parser.T__1:
                self.state = 159
                self.include()
                self.state = 164
                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 VersionContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def SEMICOLON(self):
            return self.getToken(Qasm2Parser.SEMICOLON, 0)

        def Integer(self):
            return self.getToken(Qasm2Parser.Integer, 0)

        def RealNumber(self):
            return self.getToken(Qasm2Parser.RealNumber, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_version

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

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

    def version(self):

        localctx = Qasm2Parser.VersionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 4, self.RULE_version)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 165
            self.match(Qasm2Parser.T__0)
            self.state = 166
            _la = self._input.LA(1)
            if not (_la == Qasm2Parser.Integer or _la == Qasm2Parser.RealNumber):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
            self.state = 167
            self.match(Qasm2Parser.SEMICOLON)
        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):
        __slots__ = 'parser'

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

        def StringLiteral(self):
            return self.getToken(Qasm2Parser.StringLiteral, 0)

        def SEMICOLON(self):
            return self.getToken(Qasm2Parser.SEMICOLON, 0)

        def getRuleIndex(self):
            return Qasm2Parser.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 = Qasm2Parser.IncludeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 6, self.RULE_include)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 169
            self.match(Qasm2Parser.T__1)
            self.state = 170
            self.match(Qasm2Parser.StringLiteral)
            self.state = 171
            self.match(Qasm2Parser.SEMICOLON)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class GlobalStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def quantumDeclarationStatement(self):
            return self.getTypedRuleContext(Qasm2Parser.QuantumDeclarationStatementContext, 0)

        def quantumGateDefinition(self):
            return self.getTypedRuleContext(Qasm2Parser.QuantumGateDefinitionContext, 0)

        def classicalDeclarationStatement(self):
            return self.getTypedRuleContext(Qasm2Parser.ClassicalDeclarationStatementContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_globalStatement

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

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

    def globalStatement(self):

        localctx = Qasm2Parser.GlobalStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 8, self.RULE_globalStatement)
        try:
            self.state = 176
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [Qasm2Parser.T__2]:
                self.enterOuterAlt(localctx, 1)
                self.state = 173
                self.quantumDeclarationStatement()
                pass
            elif token in [Qasm2Parser.T__14]:
                self.enterOuterAlt(localctx, 2)
                self.state = 174
                self.quantumGateDefinition()
                pass
            elif token in [Qasm2Parser.T__4, Qasm2Parser.T__5, Qasm2Parser.T__6, Qasm2Parser.T__7, Qasm2Parser.T__8,
                           Qasm2Parser.T__9, Qasm2Parser.T__10, Qasm2Parser.T__11, Qasm2Parser.T__12]:
                self.enterOuterAlt(localctx, 3)
                self.state = 175
                self.classicalDeclarationStatement()
                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 StatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def quantumStatement(self):
            return self.getTypedRuleContext(Qasm2Parser.QuantumStatementContext, 0)

        def assignmentStatement(self):
            return self.getTypedRuleContext(Qasm2Parser.AssignmentStatementContext, 0)

        def branchingStatement(self):
            return self.getTypedRuleContext(Qasm2Parser.BranchingStatementContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_statement

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

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

    def statement(self):

        localctx = Qasm2Parser.StatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 10, self.RULE_statement)
        try:
            self.state = 181
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input, 5, self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 178
                self.quantumStatement()
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 179
                self.assignmentStatement()
                pass

            elif la_ == 3:
                self.enterOuterAlt(localctx, 3)
                self.state = 180
                self.branchingStatement()
                pass


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

    class QuantumDeclarationStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def quantumDeclaration(self):
            return self.getTypedRuleContext(Qasm2Parser.QuantumDeclarationContext, 0)

        def SEMICOLON(self):
            return self.getToken(Qasm2Parser.SEMICOLON, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_quantumDeclarationStatement

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

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

    def quantumDeclarationStatement(self):

        localctx = Qasm2Parser.QuantumDeclarationStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 12, self.RULE_quantumDeclarationStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 183
            self.quantumDeclaration()
            self.state = 184
            self.match(Qasm2Parser.SEMICOLON)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ClassicalDeclarationStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def SEMICOLON(self):
            return self.getToken(Qasm2Parser.SEMICOLON, 0)

        def classicalDeclaration(self):
            return self.getTypedRuleContext(Qasm2Parser.ClassicalDeclarationContext, 0)

        def constantDeclaration(self):
            return self.getTypedRuleContext(Qasm2Parser.ConstantDeclarationContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_classicalDeclarationStatement

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

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

    def classicalDeclarationStatement(self):

        localctx = Qasm2Parser.ClassicalDeclarationStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 14, self.RULE_classicalDeclarationStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 188
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [Qasm2Parser.T__4, Qasm2Parser.T__5, Qasm2Parser.T__6, Qasm2Parser.T__7, Qasm2Parser.T__8,
                         Qasm2Parser.T__9, Qasm2Parser.T__10, Qasm2Parser.T__11]:
                self.state = 186
                self.classicalDeclaration()
                pass
            elif token in [Qasm2Parser.T__12]:
                self.state = 187
                self.constantDeclaration()
                pass
            else:
                raise NoViableAltException(self)

            self.state = 190
            self.match(Qasm2Parser.SEMICOLON)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class AssignmentStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def quantumMeasurementAssignment(self):
            return self.getTypedRuleContext(Qasm2Parser.QuantumMeasurementAssignmentContext, 0)

        def SEMICOLON(self):
            return self.getToken(Qasm2Parser.SEMICOLON, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_assignmentStatement

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

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

    def assignmentStatement(self):

        localctx = Qasm2Parser.AssignmentStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 16, self.RULE_assignmentStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 192
            self.quantumMeasurementAssignment()
            self.state = 193
            self.match(Qasm2Parser.SEMICOLON)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ReturnSignatureContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def ARROW(self):
            return self.getToken(Qasm2Parser.ARROW, 0)

        def classicalType(self):
            return self.getTypedRuleContext(Qasm2Parser.ClassicalTypeContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_returnSignature

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

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

    def returnSignature(self):

        localctx = Qasm2Parser.ReturnSignatureContext(self, self._ctx, self.state)
        self.enterRule(localctx, 18, self.RULE_returnSignature)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 195
            self.match(Qasm2Parser.ARROW)
            self.state = 196
            self.classicalType()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class DesignatorContext(ParserRuleContext):
        __slots__ = 'parser'

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

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

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

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

        def getRuleIndex(self):
            return Qasm2Parser.RULE_designator

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

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

    def designator(self):

        localctx = Qasm2Parser.DesignatorContext(self, self._ctx, self.state)
        self.enterRule(localctx, 20, self.RULE_designator)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 198
            self.match(Qasm2Parser.LBRACKET)
            self.state = 199
            self.expression(0)
            self.state = 200
            self.match(Qasm2Parser.RBRACKET)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class DoubleDesignatorContext(ParserRuleContext):
        __slots__ = 'parser'

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

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

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

        def COMMA(self):
            return self.getToken(Qasm2Parser.COMMA, 0)

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

        def getRuleIndex(self):
            return Qasm2Parser.RULE_doubleDesignator

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

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

    def doubleDesignator(self):

        localctx = Qasm2Parser.DoubleDesignatorContext(self, self._ctx, self.state)
        self.enterRule(localctx, 22, self.RULE_doubleDesignator)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 202
            self.match(Qasm2Parser.LBRACKET)
            self.state = 203
            self.expression(0)
            self.state = 204
            self.match(Qasm2Parser.COMMA)
            self.state = 205
            self.expression(0)
            self.state = 206
            self.match(Qasm2Parser.RBRACKET)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class IdentifierListContext(ParserRuleContext):
        __slots__ = 'parser'

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

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

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

        def getRuleIndex(self):
            return Qasm2Parser.RULE_identifierList

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

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

    def identifierList(self):

        localctx = Qasm2Parser.IdentifierListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 24, self.RULE_identifierList)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 212
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input, 7, self._ctx)
            while _alt != 2 and _alt != ATN.INVALID_ALT_NUMBER:
                if _alt == 1:
                    self.state = 208
                    self.match(Qasm2Parser.Identifier)
                    self.state = 209
                    self.match(Qasm2Parser.COMMA)
                self.state = 214
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input, 7, self._ctx)

            self.state = 215
            self.match(Qasm2Parser.Identifier)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class QuantumDeclarationContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def Identifier(self):
            return self.getToken(Qasm2Parser.Identifier, 0)

        def designator(self):
            return self.getTypedRuleContext(Qasm2Parser.DesignatorContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_quantumDeclaration

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

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

    def quantumDeclaration(self):

        localctx = Qasm2Parser.QuantumDeclarationContext(self, self._ctx, self.state)
        self.enterRule(localctx, 26, self.RULE_quantumDeclaration)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 217
            self.match(Qasm2Parser.T__2)
            self.state = 218
            self.match(Qasm2Parser.Identifier)
            self.state = 220
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la == Qasm2Parser.LBRACKET:
                self.state = 219
                self.designator()


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

    class QuantumArgumentContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def Identifier(self):
            return self.getToken(Qasm2Parser.Identifier, 0)

        def designator(self):
            return self.getTypedRuleContext(Qasm2Parser.DesignatorContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_quantumArgument

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

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

    def quantumArgument(self):

        localctx = Qasm2Parser.QuantumArgumentContext(self, self._ctx, self.state)
        self.enterRule(localctx, 28, self.RULE_quantumArgument)
        self._la = 0  # Token type
        try:
            self.state = 232
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [Qasm2Parser.T__2]:
                self.enterOuterAlt(localctx, 1)
                self.state = 222
                self.match(Qasm2Parser.T__2)
                self.state = 223
                self.match(Qasm2Parser.Identifier)
                self.state = 225
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la == Qasm2Parser.LBRACKET:
                    self.state = 224
                    self.designator()

                pass
            elif token in [Qasm2Parser.T__3]:
                self.enterOuterAlt(localctx, 2)
                self.state = 227
                self.match(Qasm2Parser.T__3)
                self.state = 229
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la == Qasm2Parser.LBRACKET:
                    self.state = 228
                    self.designator()

                self.state = 231
                self.match(Qasm2Parser.Identifier)
                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 QuantumArgumentListContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def quantumArgument(self, i: int = None):
            if i is None:
                return self.getTypedRuleContexts(Qasm2Parser.QuantumArgumentContext)
            else:
                return self.getTypedRuleContext(Qasm2Parser.QuantumArgumentContext, i)

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

        def getRuleIndex(self):
            return Qasm2Parser.RULE_quantumArgumentList

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

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

    def quantumArgumentList(self):

        localctx = Qasm2Parser.QuantumArgumentListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 30, self.RULE_quantumArgumentList)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 239
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input, 12, self._ctx)
            while _alt != 2 and _alt != ATN.INVALID_ALT_NUMBER:
                if _alt == 1:
                    self.state = 234
                    self.quantumArgument()
                    self.state = 235
                    self.match(Qasm2Parser.COMMA)
                self.state = 241
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input, 12, self._ctx)

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

    class BitTypeContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def getRuleIndex(self):
            return Qasm2Parser.RULE_bitType

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

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

    def bitType(self):

        localctx = Qasm2Parser.BitTypeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 32, self.RULE_bitType)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 244
            _la = self._input.LA(1)
            if not (_la == Qasm2Parser.T__4 or _la == Qasm2Parser.T__5):
                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 SingleDesignatorTypeContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def getRuleIndex(self):
            return Qasm2Parser.RULE_singleDesignatorType

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

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

    def singleDesignatorType(self):

        localctx = Qasm2Parser.SingleDesignatorTypeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 34, self.RULE_singleDesignatorType)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 246
            _la = self._input.LA(1)
            if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & (
                    (1 << Qasm2Parser.T__6) | (1 << Qasm2Parser.T__7) | (1 << Qasm2Parser.T__8) | (
                    1 << Qasm2Parser.T__9))) != 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 DoubleDesignatorTypeContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def getRuleIndex(self):
            return Qasm2Parser.RULE_doubleDesignatorType

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

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

    def doubleDesignatorType(self):

        localctx = Qasm2Parser.DoubleDesignatorTypeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 36, self.RULE_doubleDesignatorType)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 248
            self.match(Qasm2Parser.T__10)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class NoDesignatorTypeContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def getRuleIndex(self):
            return Qasm2Parser.RULE_noDesignatorType

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

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

    def noDesignatorType(self):

        localctx = Qasm2Parser.NoDesignatorTypeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 38, self.RULE_noDesignatorType)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 250
            self.match(Qasm2Parser.T__11)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ClassicalTypeContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def singleDesignatorType(self):
            return self.getTypedRuleContext(Qasm2Parser.SingleDesignatorTypeContext, 0)

        def designator(self):
            return self.getTypedRuleContext(Qasm2Parser.DesignatorContext, 0)

        def doubleDesignatorType(self):
            return self.getTypedRuleContext(Qasm2Parser.DoubleDesignatorTypeContext, 0)

        def doubleDesignator(self):
            return self.getTypedRuleContext(Qasm2Parser.DoubleDesignatorContext, 0)

        def noDesignatorType(self):
            return self.getTypedRuleContext(Qasm2Parser.NoDesignatorTypeContext, 0)

        def bitType(self):
            return self.getTypedRuleContext(Qasm2Parser.BitTypeContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_classicalType

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

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

    def classicalType(self):

        localctx = Qasm2Parser.ClassicalTypeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 40, self.RULE_classicalType)
        self._la = 0  # Token type
        try:
            self.state = 263
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [Qasm2Parser.T__6, Qasm2Parser.T__7, Qasm2Parser.T__8, Qasm2Parser.T__9]:
                self.enterOuterAlt(localctx, 1)
                self.state = 252
                self.singleDesignatorType()
                self.state = 253
                self.designator()
                pass
            elif token in [Qasm2Parser.T__10]:
                self.enterOuterAlt(localctx, 2)
                self.state = 255
                self.doubleDesignatorType()
                self.state = 256
                self.doubleDesignator()
                pass
            elif token in [Qasm2Parser.T__11]:
                self.enterOuterAlt(localctx, 3)
                self.state = 258
                self.noDesignatorType()
                pass
            elif token in [Qasm2Parser.T__4, Qasm2Parser.T__5]:
                self.enterOuterAlt(localctx, 4)
                self.state = 259
                self.bitType()
                self.state = 261
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la == Qasm2Parser.LBRACKET:
                    self.state = 260
                    self.designator()

                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 ConstantDeclarationContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def Identifier(self):
            return self.getToken(Qasm2Parser.Identifier, 0)

        def equalsExpression(self):
            return self.getTypedRuleContext(Qasm2Parser.EqualsExpressionContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_constantDeclaration

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

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

    def constantDeclaration(self):

        localctx = Qasm2Parser.ConstantDeclarationContext(self, self._ctx, self.state)
        self.enterRule(localctx, 42, self.RULE_constantDeclaration)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 265
            self.match(Qasm2Parser.T__12)
            self.state = 266
            self.match(Qasm2Parser.Identifier)
            self.state = 268
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la == Qasm2Parser.EQUALS:
                self.state = 267
                self.equalsExpression()


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

    class SingleDesignatorDeclarationContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def singleDesignatorType(self):
            return self.getTypedRuleContext(Qasm2Parser.SingleDesignatorTypeContext, 0)

        def designator(self):
            return self.getTypedRuleContext(Qasm2Parser.DesignatorContext, 0)

        def Identifier(self):
            return self.getToken(Qasm2Parser.Identifier, 0)

        def equalsExpression(self):
            return self.getTypedRuleContext(Qasm2Parser.EqualsExpressionContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_singleDesignatorDeclaration

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

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

    def singleDesignatorDeclaration(self):

        localctx = Qasm2Parser.SingleDesignatorDeclarationContext(self, self._ctx, self.state)
        self.enterRule(localctx, 44, self.RULE_singleDesignatorDeclaration)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 270
            self.singleDesignatorType()
            self.state = 271
            self.designator()
            self.state = 272
            self.match(Qasm2Parser.Identifier)
            self.state = 274
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la == Qasm2Parser.EQUALS:
                self.state = 273
                self.equalsExpression()


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

    class DoubleDesignatorDeclarationContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def doubleDesignatorType(self):
            return self.getTypedRuleContext(Qasm2Parser.DoubleDesignatorTypeContext, 0)

        def doubleDesignator(self):
            return self.getTypedRuleContext(Qasm2Parser.DoubleDesignatorContext, 0)

        def Identifier(self):
            return self.getToken(Qasm2Parser.Identifier, 0)

        def equalsExpression(self):
            return self.getTypedRuleContext(Qasm2Parser.EqualsExpressionContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_doubleDesignatorDeclaration

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

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

    def doubleDesignatorDeclaration(self):

        localctx = Qasm2Parser.DoubleDesignatorDeclarationContext(self, self._ctx, self.state)
        self.enterRule(localctx, 46, self.RULE_doubleDesignatorDeclaration)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 276
            self.doubleDesignatorType()
            self.state = 277
            self.doubleDesignator()
            self.state = 278
            self.match(Qasm2Parser.Identifier)
            self.state = 280
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la == Qasm2Parser.EQUALS:
                self.state = 279
                self.equalsExpression()


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

    class NoDesignatorDeclarationContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def noDesignatorType(self):
            return self.getTypedRuleContext(Qasm2Parser.NoDesignatorTypeContext, 0)

        def Identifier(self):
            return self.getToken(Qasm2Parser.Identifier, 0)

        def equalsExpression(self):
            return self.getTypedRuleContext(Qasm2Parser.EqualsExpressionContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_noDesignatorDeclaration

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

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

    def noDesignatorDeclaration(self):

        localctx = Qasm2Parser.NoDesignatorDeclarationContext(self, self._ctx, self.state)
        self.enterRule(localctx, 48, self.RULE_noDesignatorDeclaration)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 282
            self.noDesignatorType()
            self.state = 283
            self.match(Qasm2Parser.Identifier)
            self.state = 285
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la == Qasm2Parser.EQUALS:
                self.state = 284
                self.equalsExpression()


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

    class BitDeclarationContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def Identifier(self):
            return self.getToken(Qasm2Parser.Identifier, 0)

        def equalsExpression(self):
            return self.getTypedRuleContext(Qasm2Parser.EqualsExpressionContext, 0)

        def designator(self):
            return self.getTypedRuleContext(Qasm2Parser.DesignatorContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_bitDeclaration

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

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

    def bitDeclaration(self):

        localctx = Qasm2Parser.BitDeclarationContext(self, self._ctx, self.state)
        self.enterRule(localctx, 50, self.RULE_bitDeclaration)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 297
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [Qasm2Parser.T__5]:
                self.state = 287
                self.match(Qasm2Parser.T__5)
                self.state = 288
                self.match(Qasm2Parser.Identifier)
                self.state = 290
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la == Qasm2Parser.LBRACKET:
                    self.state = 289
                    self.designator()

                pass
            elif token in [Qasm2Parser.T__4]:
                self.state = 292
                self.match(Qasm2Parser.T__4)
                self.state = 294
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la == Qasm2Parser.LBRACKET:
                    self.state = 293
                    self.designator()

                self.state = 296
                self.match(Qasm2Parser.Identifier)
                pass
            else:
                raise NoViableAltException(self)

            self.state = 300
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la == Qasm2Parser.EQUALS:
                self.state = 299
                self.equalsExpression()


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

    class ClassicalDeclarationContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def singleDesignatorDeclaration(self):
            return self.getTypedRuleContext(Qasm2Parser.SingleDesignatorDeclarationContext, 0)

        def doubleDesignatorDeclaration(self):
            return self.getTypedRuleContext(Qasm2Parser.DoubleDesignatorDeclarationContext, 0)

        def noDesignatorDeclaration(self):
            return self.getTypedRuleContext(Qasm2Parser.NoDesignatorDeclarationContext, 0)

        def bitDeclaration(self):
            return self.getTypedRuleContext(Qasm2Parser.BitDeclarationContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_classicalDeclaration

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

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

    def classicalDeclaration(self):

        localctx = Qasm2Parser.ClassicalDeclarationContext(self, self._ctx, self.state)
        self.enterRule(localctx, 52, self.RULE_classicalDeclaration)
        try:
            self.state = 306
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [Qasm2Parser.T__6, Qasm2Parser.T__7, Qasm2Parser.T__8, Qasm2Parser.T__9]:
                self.enterOuterAlt(localctx, 1)
                self.state = 302
                self.singleDesignatorDeclaration()
                pass
            elif token in [Qasm2Parser.T__10]:
                self.enterOuterAlt(localctx, 2)
                self.state = 303
                self.doubleDesignatorDeclaration()
                pass
            elif token in [Qasm2Parser.T__11]:
                self.enterOuterAlt(localctx, 3)
                self.state = 304
                self.noDesignatorDeclaration()
                pass
            elif token in [Qasm2Parser.T__4, Qasm2Parser.T__5]:
                self.enterOuterAlt(localctx, 4)
                self.state = 305
                self.bitDeclaration()
                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 ClassicalTypeListContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def classicalType(self, i: int = None):
            if i is None:
                return self.getTypedRuleContexts(Qasm2Parser.ClassicalTypeContext)
            else:
                return self.getTypedRuleContext(Qasm2Parser.ClassicalTypeContext, i)

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

        def getRuleIndex(self):
            return Qasm2Parser.RULE_classicalTypeList

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

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

    def classicalTypeList(self):

        localctx = Qasm2Parser.ClassicalTypeListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 54, self.RULE_classicalTypeList)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 313
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input, 24, self._ctx)
            while _alt != 2 and _alt != ATN.INVALID_ALT_NUMBER:
                if _alt == 1:
                    self.state = 308
                    self.classicalType()
                    self.state = 309
                    self.match(Qasm2Parser.COMMA)
                self.state = 315
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input, 24, self._ctx)

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

    class ClassicalArgumentContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def Identifier(self):
            return self.getToken(Qasm2Parser.Identifier, 0)

        def singleDesignatorType(self):
            return self.getTypedRuleContext(Qasm2Parser.SingleDesignatorTypeContext, 0)

        def designator(self):
            return self.getTypedRuleContext(Qasm2Parser.DesignatorContext, 0)

        def doubleDesignatorType(self):
            return self.getTypedRuleContext(Qasm2Parser.DoubleDesignatorTypeContext, 0)

        def doubleDesignator(self):
            return self.getTypedRuleContext(Qasm2Parser.DoubleDesignatorContext, 0)

        def noDesignatorType(self):
            return self.getTypedRuleContext(Qasm2Parser.NoDesignatorTypeContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_classicalArgument

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

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

    def classicalArgument(self):

        localctx = Qasm2Parser.ClassicalArgumentContext(self, self._ctx, self.state)
        self.enterRule(localctx, 56, self.RULE_classicalArgument)
        self._la = 0  # Token type
        try:
            self.state = 339
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [Qasm2Parser.T__6, Qasm2Parser.T__7, Qasm2Parser.T__8, Qasm2Parser.T__9, Qasm2Parser.T__10,
                         Qasm2Parser.T__11]:
                self.enterOuterAlt(localctx, 1)
                self.state = 325
                self._errHandler.sync(self)
                token = self._input.LA(1)
                if token in [Qasm2Parser.T__6, Qasm2Parser.T__7, Qasm2Parser.T__8, Qasm2Parser.T__9]:
                    self.state = 318
                    self.singleDesignatorType()
                    self.state = 319
                    self.designator()
                    pass
                elif token in [Qasm2Parser.T__10]:
                    self.state = 321
                    self.doubleDesignatorType()
                    self.state = 322
                    self.doubleDesignator()
                    pass
                elif token in [Qasm2Parser.T__11]:
                    self.state = 324
                    self.noDesignatorType()
                    pass
                else:
                    raise NoViableAltException(self)

                self.state = 327
                self.match(Qasm2Parser.Identifier)
                pass
            elif token in [Qasm2Parser.T__5]:
                self.enterOuterAlt(localctx, 2)
                self.state = 329
                self.match(Qasm2Parser.T__5)
                self.state = 330
                self.match(Qasm2Parser.Identifier)
                self.state = 332
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la == Qasm2Parser.LBRACKET:
                    self.state = 331
                    self.designator()

                pass
            elif token in [Qasm2Parser.T__4]:
                self.enterOuterAlt(localctx, 3)
                self.state = 334
                self.match(Qasm2Parser.T__4)
                self.state = 336
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la == Qasm2Parser.LBRACKET:
                    self.state = 335
                    self.designator()

                self.state = 338
                self.match(Qasm2Parser.Identifier)
                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 ClassicalArgumentListContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def classicalArgument(self, i: int = None):
            if i is None:
                return self.getTypedRuleContexts(Qasm2Parser.ClassicalArgumentContext)
            else:
                return self.getTypedRuleContext(Qasm2Parser.ClassicalArgumentContext, i)

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

        def getRuleIndex(self):
            return Qasm2Parser.RULE_classicalArgumentList

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

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

    def classicalArgumentList(self):

        localctx = Qasm2Parser.ClassicalArgumentListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 58, self.RULE_classicalArgumentList)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 346
            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 = 341
                    self.classicalArgument()
                    self.state = 342
                    self.match(Qasm2Parser.COMMA)
                self.state = 348
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input, 29, self._ctx)

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

    class IndexIdentifierContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def Identifier(self):
            return self.getToken(Qasm2Parser.Identifier, 0)

        def rangeDefinition(self):
            return self.getTypedRuleContext(Qasm2Parser.RangeDefinitionContext, 0)

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

        def expressionList(self):
            return self.getTypedRuleContext(Qasm2Parser.ExpressionListContext, 0)

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

        def indexIdentifier(self, i: int = None):
            if i is None:
                return self.getTypedRuleContexts(Qasm2Parser.IndexIdentifierContext)
            else:
                return self.getTypedRuleContext(Qasm2Parser.IndexIdentifierContext, i)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_indexIdentifier

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

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

    def indexIdentifier(self, _p: int = 0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = Qasm2Parser.IndexIdentifierContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 60
        self.enterRecursionRule(localctx, 60, self.RULE_indexIdentifier, _p)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 361
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input, 31, self._ctx)
            if la_ == 1:
                self.state = 352
                self.match(Qasm2Parser.Identifier)
                self.state = 353
                self.rangeDefinition()
                pass

            elif la_ == 2:
                self.state = 354
                self.match(Qasm2Parser.Identifier)
                self.state = 359
                self._errHandler.sync(self)
                la_ = self._interp.adaptivePredict(self._input, 30, self._ctx)
                if la_ == 1:
                    self.state = 355
                    self.match(Qasm2Parser.LBRACKET)
                    self.state = 356
                    self.expressionList()
                    self.state = 357
                    self.match(Qasm2Parser.RBRACKET)

                pass

            self._ctx.stop = self._input.LT(-1)
            self.state = 368
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input, 32, self._ctx)
            while _alt != 2 and _alt != ATN.INVALID_ALT_NUMBER:
                if _alt == 1:
                    if self._parseListeners is not None:
                        self.triggerExitRuleEvent()
                    _prevctx = localctx
                    localctx = Qasm2Parser.IndexIdentifierContext(self, _parentctx, _parentState)
                    self.pushNewRecursionContext(localctx, _startState, self.RULE_indexIdentifier)
                    self.state = 363
                    if not self.precpred(self._ctx, 1):
                        from antlr4.error.Errors import FailedPredicateException
                        raise FailedPredicateException(self, "self.precpred(self._ctx, 1)")
                    self.state = 364
                    self.match(Qasm2Parser.T__13)
                    self.state = 365
                    self.indexIdentifier(2)
                self.state = 370
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input, 32, 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 IndexIdentifierListContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def indexIdentifier(self, i: int = None):
            if i is None:
                return self.getTypedRuleContexts(Qasm2Parser.IndexIdentifierContext)
            else:
                return self.getTypedRuleContext(Qasm2Parser.IndexIdentifierContext, i)

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

        def getRuleIndex(self):
            return Qasm2Parser.RULE_indexIdentifierList

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

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

    def indexIdentifierList(self):

        localctx = Qasm2Parser.IndexIdentifierListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 62, self.RULE_indexIdentifierList)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 376
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input, 33, self._ctx)
            while _alt != 2 and _alt != ATN.INVALID_ALT_NUMBER:
                if _alt == 1:
                    self.state = 371
                    self.indexIdentifier(0)
                    self.state = 372
                    self.match(Qasm2Parser.COMMA)
                self.state = 378
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input, 33, self._ctx)

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

    class RangeDefinitionContext(ParserRuleContext):
        __slots__ = 'parser'

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

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

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

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

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

        def getRuleIndex(self):
            return Qasm2Parser.RULE_rangeDefinition

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

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

    def rangeDefinition(self):

        localctx = Qasm2Parser.RangeDefinitionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 64, self.RULE_rangeDefinition)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 381
            self.match(Qasm2Parser.LBRACKET)
            self.state = 383
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if (((_la) & ~0x3f) == 0 and ((1 << _la) & (
                    (1 << Qasm2Parser.T__19) | (1 << Qasm2Parser.T__20) | (1 << Qasm2Parser.T__33) | (
                    1 << Qasm2Parser.T__34) | (1 << Qasm2Parser.T__37) | (1 << Qasm2Parser.T__38) | (
                            1 << Qasm2Parser.T__39) | (1 << Qasm2Parser.T__40) | (1 << Qasm2Parser.T__41) | (
                            1 << Qasm2Parser.T__42) | (1 << Qasm2Parser.T__43) | (1 << Qasm2Parser.T__44) | (
                            1 << Qasm2Parser.T__45) | (1 << Qasm2Parser.T__46))) != 0) or (
                    (((_la - 64)) & ~0x3f) == 0 and ((1 << (_la - 64)) & (
                    (1 << (Qasm2Parser.LPAREN - 64)) | (1 << (Qasm2Parser.MINUS - 64)) | (
                    1 << (Qasm2Parser.Constant - 64)) | (1 << (Qasm2Parser.Integer - 64)) | (
                            1 << (Qasm2Parser.Identifier - 64)) | (1 << (Qasm2Parser.RealNumber - 64)) | (
                            1 << (Qasm2Parser.StringLiteral - 64)))) != 0):
                self.state = 382
                self.expression(0)

            self.state = 385
            self.match(Qasm2Parser.COLON)
            self.state = 387
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if (((_la) & ~0x3f) == 0 and ((1 << _la) & (
                    (1 << Qasm2Parser.T__19) | (1 << Qasm2Parser.T__20) | (1 << Qasm2Parser.T__33) | (
                    1 << Qasm2Parser.T__34) | (1 << Qasm2Parser.T__37) | (1 << Qasm2Parser.T__38) | (
                            1 << Qasm2Parser.T__39) | (1 << Qasm2Parser.T__40) | (1 << Qasm2Parser.T__41) | (
                            1 << Qasm2Parser.T__42) | (1 << Qasm2Parser.T__43) | (1 << Qasm2Parser.T__44) | (
                            1 << Qasm2Parser.T__45) | (1 << Qasm2Parser.T__46))) != 0) or (
                    (((_la - 64)) & ~0x3f) == 0 and ((1 << (_la - 64)) & (
                    (1 << (Qasm2Parser.LPAREN - 64)) | (1 << (Qasm2Parser.MINUS - 64)) | (
                    1 << (Qasm2Parser.Constant - 64)) | (1 << (Qasm2Parser.Integer - 64)) | (
                            1 << (Qasm2Parser.Identifier - 64)) | (1 << (Qasm2Parser.RealNumber - 64)) | (
                            1 << (Qasm2Parser.StringLiteral - 64)))) != 0):
                self.state = 386
                self.expression(0)

            self.state = 391
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la == Qasm2Parser.COLON:
                self.state = 389
                self.match(Qasm2Parser.COLON)
                self.state = 390
                self.expression(0)

            self.state = 393
            self.match(Qasm2Parser.RBRACKET)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class QuantumGateDefinitionContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def quantumGateSignature(self):
            return self.getTypedRuleContext(Qasm2Parser.QuantumGateSignatureContext, 0)

        def quantumBlock(self):
            return self.getTypedRuleContext(Qasm2Parser.QuantumBlockContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_quantumGateDefinition

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

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

    def quantumGateDefinition(self):

        localctx = Qasm2Parser.QuantumGateDefinitionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 66, self.RULE_quantumGateDefinition)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 395
            self.match(Qasm2Parser.T__14)
            self.state = 396
            self.quantumGateSignature()
            self.state = 397
            self.quantumBlock()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class QuantumGateParameterContext(ParserRuleContext):
        __slots__ = 'parser'

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

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

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

        def identifierList(self):
            return self.getTypedRuleContext(Qasm2Parser.IdentifierListContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_quantumGateParameter

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

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

    def quantumGateParameter(self):

        localctx = Qasm2Parser.QuantumGateParameterContext(self, self._ctx, self.state)
        self.enterRule(localctx, 68, self.RULE_quantumGateParameter)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 399
            self.match(Qasm2Parser.LPAREN)
            self.state = 401
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la == Qasm2Parser.Identifier:
                self.state = 400
                self.identifierList()

            self.state = 403
            self.match(Qasm2Parser.RPAREN)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class QuantumGateNameContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def Identifier(self):
            return self.getToken(Qasm2Parser.Identifier, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_quantumGateName

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

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

    def quantumGateName(self):

        localctx = Qasm2Parser.QuantumGateNameContext(self, self._ctx, self.state)
        self.enterRule(localctx, 70, self.RULE_quantumGateName)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 405
            _la = self._input.LA(1)
            if not (_la == Qasm2Parser.T__15 or _la == Qasm2Parser.T__16 or _la == Qasm2Parser.Identifier):
                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 QuantumGateSignatureContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def Identifier(self):
            return self.getToken(Qasm2Parser.Identifier, 0)

        def identifierList(self):
            return self.getTypedRuleContext(Qasm2Parser.IdentifierListContext, 0)

        def quantumGateParameter(self):
            return self.getTypedRuleContext(Qasm2Parser.QuantumGateParameterContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_quantumGateSignature

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

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

    def quantumGateSignature(self):

        localctx = Qasm2Parser.QuantumGateSignatureContext(self, self._ctx, self.state)
        self.enterRule(localctx, 72, self.RULE_quantumGateSignature)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 407
            self.match(Qasm2Parser.Identifier)
            self.state = 409
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la == Qasm2Parser.LPAREN:
                self.state = 408
                self.quantumGateParameter()

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

    class QuantumBlockContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def LBRACE(self):
            return self.getToken(Qasm2Parser.LBRACE, 0)

        def RBRACE(self):
            return self.getToken(Qasm2Parser.RBRACE, 0)

        def quantumStatement(self, i: int = None):
            if i is None:
                return self.getTypedRuleContexts(Qasm2Parser.QuantumStatementContext)
            else:
                return self.getTypedRuleContext(Qasm2Parser.QuantumStatementContext, i)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_quantumBlock

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

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

    def quantumBlock(self):

        localctx = Qasm2Parser.QuantumBlockContext(self, self._ctx, self.state)
        self.enterRule(localctx, 74, self.RULE_quantumBlock)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 413
            self.match(Qasm2Parser.LBRACE)
            self.state = 417
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while (((_la) & ~0x3f) == 0 and ((1 << _la) & (
                    (1 << Qasm2Parser.T__15) | (1 << Qasm2Parser.T__16) | (1 << Qasm2Parser.T__17) | (
                    1 << Qasm2Parser.T__18))) != 0) or _la == Qasm2Parser.Identifier:
                self.state = 414
                self.quantumStatement()
                self.state = 419
                self._errHandler.sync(self)
                _la = self._input.LA(1)

            self.state = 420
            self.match(Qasm2Parser.RBRACE)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class QuantumLoopBlockContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def quantumStatement(self, i: int = None):
            if i is None:
                return self.getTypedRuleContexts(Qasm2Parser.QuantumStatementContext)
            else:
                return self.getTypedRuleContext(Qasm2Parser.QuantumStatementContext, i)

        def LBRACE(self):
            return self.getToken(Qasm2Parser.LBRACE, 0)

        def RBRACE(self):
            return self.getToken(Qasm2Parser.RBRACE, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_quantumLoopBlock

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

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

    def quantumLoopBlock(self):

        localctx = Qasm2Parser.QuantumLoopBlockContext(self, self._ctx, self.state)
        self.enterRule(localctx, 76, self.RULE_quantumLoopBlock)
        self._la = 0  # Token type
        try:
            self.state = 431
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [Qasm2Parser.T__15, Qasm2Parser.T__16, Qasm2Parser.T__17, Qasm2Parser.T__18,
                         Qasm2Parser.Identifier]:
                self.enterOuterAlt(localctx, 1)
                self.state = 422
                self.quantumStatement()
                pass
            elif token in [Qasm2Parser.LBRACE]:
                self.enterOuterAlt(localctx, 2)
                self.state = 423
                self.match(Qasm2Parser.LBRACE)
                self.state = 427
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while (((_la) & ~0x3f) == 0 and ((1 << _la) & (
                        (1 << Qasm2Parser.T__15) | (1 << Qasm2Parser.T__16) | (1 << Qasm2Parser.T__17) | (
                        1 << Qasm2Parser.T__18))) != 0) or _la == Qasm2Parser.Identifier:
                    self.state = 424
                    self.quantumStatement()
                    self.state = 429
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)

                self.state = 430
                self.match(Qasm2Parser.RBRACE)
                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 QuantumStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def quantumInstruction(self):
            return self.getTypedRuleContext(Qasm2Parser.QuantumInstructionContext, 0)

        def SEMICOLON(self):
            return self.getToken(Qasm2Parser.SEMICOLON, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_quantumStatement

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

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

    def quantumStatement(self):

        localctx = Qasm2Parser.QuantumStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 78, self.RULE_quantumStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 433
            self.quantumInstruction()
            self.state = 434
            self.match(Qasm2Parser.SEMICOLON)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class QuantumInstructionContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def quantumGateCall(self):
            return self.getTypedRuleContext(Qasm2Parser.QuantumGateCallContext, 0)

        def quantumMeasurement(self):
            return self.getTypedRuleContext(Qasm2Parser.QuantumMeasurementContext, 0)

        def quantumBarrier(self):
            return self.getTypedRuleContext(Qasm2Parser.QuantumBarrierContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_quantumInstruction

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

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

    def quantumInstruction(self):

        localctx = Qasm2Parser.QuantumInstructionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 80, self.RULE_quantumInstruction)
        try:
            self.state = 439
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [Qasm2Parser.T__15, Qasm2Parser.T__16, Qasm2Parser.Identifier]:
                self.enterOuterAlt(localctx, 1)
                self.state = 436
                self.quantumGateCall()
                pass
            elif token in [Qasm2Parser.T__17]:
                self.enterOuterAlt(localctx, 2)
                self.state = 437
                self.quantumMeasurement()
                pass
            elif token in [Qasm2Parser.T__18]:
                self.enterOuterAlt(localctx, 3)
                self.state = 438
                self.quantumBarrier()
                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 QuantumMeasurementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def indexIdentifierList(self):
            return self.getTypedRuleContext(Qasm2Parser.IndexIdentifierListContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_quantumMeasurement

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

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

    def quantumMeasurement(self):

        localctx = Qasm2Parser.QuantumMeasurementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 82, self.RULE_quantumMeasurement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 441
            self.match(Qasm2Parser.T__17)
            self.state = 442
            self.indexIdentifierList()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class QuantumMeasurementAssignmentContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def quantumMeasurement(self):
            return self.getTypedRuleContext(Qasm2Parser.QuantumMeasurementContext, 0)

        def ARROW(self):
            return self.getToken(Qasm2Parser.ARROW, 0)

        def indexIdentifierList(self):
            return self.getTypedRuleContext(Qasm2Parser.IndexIdentifierListContext, 0)

        def EQUALS(self):
            return self.getToken(Qasm2Parser.EQUALS, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_quantumMeasurementAssignment

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

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

    def quantumMeasurementAssignment(self):

        localctx = Qasm2Parser.QuantumMeasurementAssignmentContext(self, self._ctx, self.state)
        self.enterRule(localctx, 84, self.RULE_quantumMeasurementAssignment)
        self._la = 0  # Token type
        try:
            self.state = 453
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [Qasm2Parser.T__17]:
                self.enterOuterAlt(localctx, 1)
                self.state = 444
                self.quantumMeasurement()
                self.state = 447
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la == Qasm2Parser.ARROW:
                    self.state = 445
                    self.match(Qasm2Parser.ARROW)
                    self.state = 446
                    self.indexIdentifierList()

                pass
            elif token in [Qasm2Parser.Identifier]:
                self.enterOuterAlt(localctx, 2)
                self.state = 449
                self.indexIdentifierList()
                self.state = 450
                self.match(Qasm2Parser.EQUALS)
                self.state = 451
                self.quantumMeasurement()
                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 QuantumBarrierContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def indexIdentifierList(self):
            return self.getTypedRuleContext(Qasm2Parser.IndexIdentifierListContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_quantumBarrier

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

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

    def quantumBarrier(self):

        localctx = Qasm2Parser.QuantumBarrierContext(self, self._ctx, self.state)
        self.enterRule(localctx, 86, self.RULE_quantumBarrier)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 455
            self.match(Qasm2Parser.T__18)
            self.state = 456
            self.indexIdentifierList()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class QuantumGateCallContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def quantumGateName(self):
            return self.getTypedRuleContext(Qasm2Parser.QuantumGateNameContext, 0)

        def indexIdentifierList(self):
            return self.getTypedRuleContext(Qasm2Parser.IndexIdentifierListContext, 0)

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

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

        def expressionList(self):
            return self.getTypedRuleContext(Qasm2Parser.ExpressionListContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_quantumGateCall

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

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

    def quantumGateCall(self):

        localctx = Qasm2Parser.QuantumGateCallContext(self, self._ctx, self.state)
        self.enterRule(localctx, 88, self.RULE_quantumGateCall)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 458
            self.quantumGateName()
            self.state = 464
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la == Qasm2Parser.LPAREN:
                self.state = 459
                self.match(Qasm2Parser.LPAREN)
                self.state = 461
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if (((_la) & ~0x3f) == 0 and ((1 << _la) & (
                        (1 << Qasm2Parser.T__19) | (1 << Qasm2Parser.T__20) | (1 << Qasm2Parser.T__33) | (
                        1 << Qasm2Parser.T__34) | (1 << Qasm2Parser.T__37) | (1 << Qasm2Parser.T__38) | (
                                1 << Qasm2Parser.T__39) | (1 << Qasm2Parser.T__40) | (1 << Qasm2Parser.T__41) | (
                                1 << Qasm2Parser.T__42) | (1 << Qasm2Parser.T__43) | (1 << Qasm2Parser.T__44) | (
                                1 << Qasm2Parser.T__45) | (1 << Qasm2Parser.T__46))) != 0) or (
                        (((_la - 64)) & ~0x3f) == 0 and ((1 << (_la - 64)) & (
                        (1 << (Qasm2Parser.LPAREN - 64)) | (1 << (Qasm2Parser.MINUS - 64)) | (
                        1 << (Qasm2Parser.Constant - 64)) | (1 << (Qasm2Parser.Integer - 64)) | (
                                1 << (Qasm2Parser.Identifier - 64)) | (1 << (Qasm2Parser.RealNumber - 64)) | (
                                1 << (Qasm2Parser.StringLiteral - 64)))) != 0):
                    self.state = 460
                    self.expressionList()

                self.state = 463
                self.match(Qasm2Parser.RPAREN)

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

    class UnaryOperatorContext(ParserRuleContext):
        __slots__ = 'parser'

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

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

        def getRuleIndex(self):
            return Qasm2Parser.RULE_unaryOperator

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

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

    def unaryOperator(self):

        localctx = Qasm2Parser.UnaryOperatorContext(self, self._ctx, self.state)
        self.enterRule(localctx, 90, self.RULE_unaryOperator)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 468
            _la = self._input.LA(1)
            if not (((((_la - 20)) & ~0x3f) == 0 and ((1 << (_la - 20)) & (
                    (1 << (Qasm2Parser.T__19 - 20)) | (1 << (Qasm2Parser.T__20 - 20)) | (
                    1 << (Qasm2Parser.MINUS - 20)))) != 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 ComparisonOperatorContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def getRuleIndex(self):
            return Qasm2Parser.RULE_comparisonOperator

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

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

    def comparisonOperator(self):

        localctx = Qasm2Parser.ComparisonOperatorContext(self, self._ctx, self.state)
        self.enterRule(localctx, 92, self.RULE_comparisonOperator)
        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 << Qasm2Parser.T__21) | (1 << Qasm2Parser.T__22) | (1 << Qasm2Parser.T__23) | (
                    1 << Qasm2Parser.T__24))) != 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 EqualityOperatorContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def getRuleIndex(self):
            return Qasm2Parser.RULE_equalityOperator

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

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

    def equalityOperator(self):

        localctx = Qasm2Parser.EqualityOperatorContext(self, self._ctx, self.state)
        self.enterRule(localctx, 94, self.RULE_equalityOperator)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 472
            _la = self._input.LA(1)
            if not (_la == Qasm2Parser.T__25 or _la == Qasm2Parser.T__26):
                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 LogicalOperatorContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def getRuleIndex(self):
            return Qasm2Parser.RULE_logicalOperator

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

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

    def logicalOperator(self):

        localctx = Qasm2Parser.LogicalOperatorContext(self, self._ctx, self.state)
        self.enterRule(localctx, 96, self.RULE_logicalOperator)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 474
            _la = self._input.LA(1)
            if not (_la == Qasm2Parser.T__13 or _la == Qasm2Parser.T__27):
                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 ExpressionStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

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

        def SEMICOLON(self):
            return self.getToken(Qasm2Parser.SEMICOLON, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_expressionStatement

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

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

    def expressionStatement(self):

        localctx = Qasm2Parser.ExpressionStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 98, self.RULE_expressionStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 476
            self.expression(0)
            self.state = 477
            self.match(Qasm2Parser.SEMICOLON)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ExpressionContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def expressionTerminator(self):
            return self.getTypedRuleContext(Qasm2Parser.ExpressionTerminatorContext, 0)

        def unaryExpression(self):
            return self.getTypedRuleContext(Qasm2Parser.UnaryExpressionContext, 0)

        def logicalAndExpression(self):
            return self.getTypedRuleContext(Qasm2Parser.LogicalAndExpressionContext, 0)

        def builtInMath(self):
            return self.getTypedRuleContext(Qasm2Parser.BuiltInMathContext, 0)

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

        def getRuleIndex(self):
            return Qasm2Parser.RULE_expression

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

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

    def expression(self, _p: int = 0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = Qasm2Parser.ExpressionContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 100
        self.enterRecursionRule(localctx, 100, self.RULE_expression, _p)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 486
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input, 47, self._ctx)
            if la_ == 1:
                self.state = 480
                self.expressionTerminator(0)
                pass

            elif la_ == 2:
                self.state = 481
                self.unaryExpression()
                pass

            elif la_ == 3:
                self.state = 482
                self.logicalAndExpression(0)
                pass

            elif la_ == 4:
                self.state = 483
                self.builtInMath()
                self.state = 484
                self.expressionTerminator(0)
                pass

            self._ctx.stop = self._input.LT(-1)
            self.state = 493
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input, 48, self._ctx)
            while _alt != 2 and _alt != ATN.INVALID_ALT_NUMBER:
                if _alt == 1:
                    if self._parseListeners is not None:
                        self.triggerExitRuleEvent()
                    _prevctx = localctx
                    localctx = Qasm2Parser.ExpressionContext(self, _parentctx, _parentState)
                    self.pushNewRecursionContext(localctx, _startState, self.RULE_expression)
                    self.state = 488
                    if not self.precpred(self._ctx, 2):
                        from antlr4.error.Errors import FailedPredicateException
                        raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
                    self.state = 489
                    self.match(Qasm2Parser.T__13)
                    self.state = 490
                    self.logicalAndExpression(0)
                self.state = 495
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input, 48, 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 LogicalAndExpressionContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def bitOrExpression(self):
            return self.getTypedRuleContext(Qasm2Parser.BitOrExpressionContext, 0)

        def logicalAndExpression(self):
            return self.getTypedRuleContext(Qasm2Parser.LogicalAndExpressionContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_logicalAndExpression

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

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

    def logicalAndExpression(self, _p: int = 0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = Qasm2Parser.LogicalAndExpressionContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 102
        self.enterRecursionRule(localctx, 102, self.RULE_logicalAndExpression, _p)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 497
            self.bitOrExpression(0)
            self._ctx.stop = self._input.LT(-1)
            self.state = 504
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input, 49, self._ctx)
            while _alt != 2 and _alt != ATN.INVALID_ALT_NUMBER:
                if _alt == 1:
                    if self._parseListeners is not None:
                        self.triggerExitRuleEvent()
                    _prevctx = localctx
                    localctx = Qasm2Parser.LogicalAndExpressionContext(self, _parentctx, _parentState)
                    self.pushNewRecursionContext(localctx, _startState, self.RULE_logicalAndExpression)
                    self.state = 499
                    if not self.precpred(self._ctx, 1):
                        from antlr4.error.Errors import FailedPredicateException
                        raise FailedPredicateException(self, "self.precpred(self._ctx, 1)")
                    self.state = 500
                    self.match(Qasm2Parser.T__27)
                    self.state = 501
                    self.bitOrExpression(0)
                self.state = 506
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input, 49, 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 BitOrExpressionContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def xOrExpression(self):
            return self.getTypedRuleContext(Qasm2Parser.XOrExpressionContext, 0)

        def bitOrExpression(self):
            return self.getTypedRuleContext(Qasm2Parser.BitOrExpressionContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_bitOrExpression

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

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

    def bitOrExpression(self, _p: int = 0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = Qasm2Parser.BitOrExpressionContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 104
        self.enterRecursionRule(localctx, 104, self.RULE_bitOrExpression, _p)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 508
            self.xOrExpression(0)
            self._ctx.stop = self._input.LT(-1)
            self.state = 515
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input, 50, self._ctx)
            while _alt != 2 and _alt != ATN.INVALID_ALT_NUMBER:
                if _alt == 1:
                    if self._parseListeners is not None:
                        self.triggerExitRuleEvent()
                    _prevctx = localctx
                    localctx = Qasm2Parser.BitOrExpressionContext(self, _parentctx, _parentState)
                    self.pushNewRecursionContext(localctx, _startState, self.RULE_bitOrExpression)
                    self.state = 510
                    if not self.precpred(self._ctx, 1):
                        from antlr4.error.Errors import FailedPredicateException
                        raise FailedPredicateException(self, "self.precpred(self._ctx, 1)")
                    self.state = 511
                    self.match(Qasm2Parser.T__28)
                    self.state = 512
                    self.xOrExpression(0)
                self.state = 517
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input, 50, 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 XOrExpressionContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def bitAndExpression(self):
            return self.getTypedRuleContext(Qasm2Parser.BitAndExpressionContext, 0)

        def xOrExpression(self):
            return self.getTypedRuleContext(Qasm2Parser.XOrExpressionContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_xOrExpression

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

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

    def xOrExpression(self, _p: int = 0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = Qasm2Parser.XOrExpressionContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 106
        self.enterRecursionRule(localctx, 106, self.RULE_xOrExpression, _p)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 519
            self.bitAndExpression(0)
            self._ctx.stop = self._input.LT(-1)
            self.state = 526
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input, 51, self._ctx)
            while _alt != 2 and _alt != ATN.INVALID_ALT_NUMBER:
                if _alt == 1:
                    if self._parseListeners is not None:
                        self.triggerExitRuleEvent()
                    _prevctx = localctx
                    localctx = Qasm2Parser.XOrExpressionContext(self, _parentctx, _parentState)
                    self.pushNewRecursionContext(localctx, _startState, self.RULE_xOrExpression)
                    self.state = 521
                    if not self.precpred(self._ctx, 1):
                        from antlr4.error.Errors import FailedPredicateException
                        raise FailedPredicateException(self, "self.precpred(self._ctx, 1)")
                    self.state = 522
                    self.match(Qasm2Parser.T__29)
                    self.state = 523
                    self.bitAndExpression(0)
                self.state = 528
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input, 51, 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 BitAndExpressionContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def equalityExpression(self):
            return self.getTypedRuleContext(Qasm2Parser.EqualityExpressionContext, 0)

        def bitAndExpression(self):
            return self.getTypedRuleContext(Qasm2Parser.BitAndExpressionContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_bitAndExpression

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

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

    def bitAndExpression(self, _p: int = 0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = Qasm2Parser.BitAndExpressionContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 108
        self.enterRecursionRule(localctx, 108, self.RULE_bitAndExpression, _p)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 530
            self.equalityExpression(0)
            self._ctx.stop = self._input.LT(-1)
            self.state = 537
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input, 52, self._ctx)
            while _alt != 2 and _alt != ATN.INVALID_ALT_NUMBER:
                if _alt == 1:
                    if self._parseListeners is not None:
                        self.triggerExitRuleEvent()
                    _prevctx = localctx
                    localctx = Qasm2Parser.BitAndExpressionContext(self, _parentctx, _parentState)
                    self.pushNewRecursionContext(localctx, _startState, self.RULE_bitAndExpression)
                    self.state = 532
                    if not self.precpred(self._ctx, 1):
                        from antlr4.error.Errors import FailedPredicateException
                        raise FailedPredicateException(self, "self.precpred(self._ctx, 1)")
                    self.state = 533
                    self.match(Qasm2Parser.T__30)
                    self.state = 534
                    self.equalityExpression(0)
                self.state = 539
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input, 52, 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 EqualityExpressionContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def comparisonExpression(self):
            return self.getTypedRuleContext(Qasm2Parser.ComparisonExpressionContext, 0)

        def equalityExpression(self):
            return self.getTypedRuleContext(Qasm2Parser.EqualityExpressionContext, 0)

        def equalityOperator(self):
            return self.getTypedRuleContext(Qasm2Parser.EqualityOperatorContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_equalityExpression

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

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

    def equalityExpression(self, _p: int = 0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = Qasm2Parser.EqualityExpressionContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 110
        self.enterRecursionRule(localctx, 110, self.RULE_equalityExpression, _p)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 541
            self.comparisonExpression(0)
            self._ctx.stop = self._input.LT(-1)
            self.state = 549
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input, 53, self._ctx)
            while _alt != 2 and _alt != ATN.INVALID_ALT_NUMBER:
                if _alt == 1:
                    if self._parseListeners is not None:
                        self.triggerExitRuleEvent()
                    _prevctx = localctx
                    localctx = Qasm2Parser.EqualityExpressionContext(self, _parentctx, _parentState)
                    self.pushNewRecursionContext(localctx, _startState, self.RULE_equalityExpression)
                    self.state = 543
                    if not self.precpred(self._ctx, 1):
                        from antlr4.error.Errors import FailedPredicateException
                        raise FailedPredicateException(self, "self.precpred(self._ctx, 1)")
                    self.state = 544
                    self.equalityOperator()
                    self.state = 545
                    self.comparisonExpression(0)
                self.state = 551
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input, 53, 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 ComparisonExpressionContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def bitShiftExpression(self):
            return self.getTypedRuleContext(Qasm2Parser.BitShiftExpressionContext, 0)

        def comparisonExpression(self):
            return self.getTypedRuleContext(Qasm2Parser.ComparisonExpressionContext, 0)

        def comparisonOperator(self):
            return self.getTypedRuleContext(Qasm2Parser.ComparisonOperatorContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_comparisonExpression

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

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

    def comparisonExpression(self, _p: int = 0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = Qasm2Parser.ComparisonExpressionContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 112
        self.enterRecursionRule(localctx, 112, self.RULE_comparisonExpression, _p)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 553
            self.bitShiftExpression(0)
            self._ctx.stop = self._input.LT(-1)
            self.state = 561
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input, 54, self._ctx)
            while _alt != 2 and _alt != ATN.INVALID_ALT_NUMBER:
                if _alt == 1:
                    if self._parseListeners is not None:
                        self.triggerExitRuleEvent()
                    _prevctx = localctx
                    localctx = Qasm2Parser.ComparisonExpressionContext(self, _parentctx, _parentState)
                    self.pushNewRecursionContext(localctx, _startState, self.RULE_comparisonExpression)
                    self.state = 555
                    if not self.precpred(self._ctx, 1):
                        from antlr4.error.Errors import FailedPredicateException
                        raise FailedPredicateException(self, "self.precpred(self._ctx, 1)")
                    self.state = 556
                    self.comparisonOperator()
                    self.state = 557
                    self.bitShiftExpression(0)
                self.state = 563
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input, 54, 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 BitShiftExpressionContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def additiveExpression(self):
            return self.getTypedRuleContext(Qasm2Parser.AdditiveExpressionContext, 0)

        def bitShiftExpression(self):
            return self.getTypedRuleContext(Qasm2Parser.BitShiftExpressionContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_bitShiftExpression

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

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

    def bitShiftExpression(self, _p: int = 0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = Qasm2Parser.BitShiftExpressionContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 114
        self.enterRecursionRule(localctx, 114, self.RULE_bitShiftExpression, _p)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 565
            self.additiveExpression(0)
            self._ctx.stop = self._input.LT(-1)
            self.state = 572
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input, 55, self._ctx)
            while _alt != 2 and _alt != ATN.INVALID_ALT_NUMBER:
                if _alt == 1:
                    if self._parseListeners is not None:
                        self.triggerExitRuleEvent()
                    _prevctx = localctx
                    localctx = Qasm2Parser.BitShiftExpressionContext(self, _parentctx, _parentState)
                    self.pushNewRecursionContext(localctx, _startState, self.RULE_bitShiftExpression)
                    self.state = 567
                    if not self.precpred(self._ctx, 1):
                        from antlr4.error.Errors import FailedPredicateException
                        raise FailedPredicateException(self, "self.precpred(self._ctx, 1)")
                    self.state = 568
                    _la = self._input.LA(1)
                    if not (_la == Qasm2Parser.T__31 or _la == Qasm2Parser.T__32):
                        self._errHandler.recoverInline(self)
                    else:
                        self._errHandler.reportMatch(self)
                        self.consume()
                    self.state = 569
                    self.additiveExpression(0)
                self.state = 574
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input, 55, 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 AdditiveExpressionContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def multiplicativeExpression(self):
            return self.getTypedRuleContext(Qasm2Parser.MultiplicativeExpressionContext, 0)

        def additiveExpression(self):
            return self.getTypedRuleContext(Qasm2Parser.AdditiveExpressionContext, 0)

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

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

        def getRuleIndex(self):
            return Qasm2Parser.RULE_additiveExpression

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

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

    def additiveExpression(self, _p: int = 0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = Qasm2Parser.AdditiveExpressionContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 116
        self.enterRecursionRule(localctx, 116, self.RULE_additiveExpression, _p)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 576
            self.multiplicativeExpression(0)
            self._ctx.stop = self._input.LT(-1)
            self.state = 583
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input, 56, self._ctx)
            while _alt != 2 and _alt != ATN.INVALID_ALT_NUMBER:
                if _alt == 1:
                    if self._parseListeners is not None:
                        self.triggerExitRuleEvent()
                    _prevctx = localctx
                    localctx = Qasm2Parser.AdditiveExpressionContext(self, _parentctx, _parentState)
                    self.pushNewRecursionContext(localctx, _startState, self.RULE_additiveExpression)
                    self.state = 578
                    if not self.precpred(self._ctx, 1):
                        from antlr4.error.Errors import FailedPredicateException
                        raise FailedPredicateException(self, "self.precpred(self._ctx, 1)")
                    self.state = 579
                    _la = self._input.LA(1)
                    if not (_la == Qasm2Parser.PLUS or _la == Qasm2Parser.MINUS):
                        self._errHandler.recoverInline(self)
                    else:
                        self._errHandler.reportMatch(self)
                        self.consume()
                    self.state = 580
                    self.multiplicativeExpression(0)
                self.state = 585
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input, 56, 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 MultiplicativeExpressionContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def expressionTerminator(self):
            return self.getTypedRuleContext(Qasm2Parser.ExpressionTerminatorContext, 0)

        def unaryExpression(self):
            return self.getTypedRuleContext(Qasm2Parser.UnaryExpressionContext, 0)

        def multiplicativeExpression(self):
            return self.getTypedRuleContext(Qasm2Parser.MultiplicativeExpressionContext, 0)

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

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

        def MOD(self):
            return self.getToken(Qasm2Parser.MOD, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_multiplicativeExpression

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

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

    def multiplicativeExpression(self, _p: int = 0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = Qasm2Parser.MultiplicativeExpressionContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 118
        self.enterRecursionRule(localctx, 118, self.RULE_multiplicativeExpression, _p)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 589
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [Qasm2Parser.T__33, Qasm2Parser.T__34, Qasm2Parser.T__37, Qasm2Parser.T__38, Qasm2Parser.T__39,
                         Qasm2Parser.T__40, Qasm2Parser.T__41, Qasm2Parser.T__42, Qasm2Parser.T__43, Qasm2Parser.T__44,
                         Qasm2Parser.T__45, Qasm2Parser.T__46, Qasm2Parser.LPAREN, Qasm2Parser.Constant,
                         Qasm2Parser.Integer, Qasm2Parser.Identifier, Qasm2Parser.RealNumber,
                         Qasm2Parser.StringLiteral]:
                self.state = 587
                self.expressionTerminator(0)
                pass
            elif token in [Qasm2Parser.T__19, Qasm2Parser.T__20, Qasm2Parser.MINUS]:
                self.state = 588
                self.unaryExpression()
                pass
            else:
                raise NoViableAltException(self)

            self._ctx.stop = self._input.LT(-1)
            self.state = 599
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input, 59, self._ctx)
            while _alt != 2 and _alt != ATN.INVALID_ALT_NUMBER:
                if _alt == 1:
                    if self._parseListeners is not None:
                        self.triggerExitRuleEvent()
                    _prevctx = localctx
                    localctx = Qasm2Parser.MultiplicativeExpressionContext(self, _parentctx, _parentState)
                    self.pushNewRecursionContext(localctx, _startState, self.RULE_multiplicativeExpression)
                    self.state = 591
                    if not self.precpred(self._ctx, 1):
                        from antlr4.error.Errors import FailedPredicateException
                        raise FailedPredicateException(self, "self.precpred(self._ctx, 1)")
                    self.state = 592
                    _la = self._input.LA(1)
                    if not (((((_la - 74)) & ~0x3f) == 0 and ((1 << (_la - 74)) & (
                            (1 << (Qasm2Parser.MUL - 74)) | (1 << (Qasm2Parser.DIV - 74)) | (
                            1 << (Qasm2Parser.MOD - 74)))) != 0)):
                        self._errHandler.recoverInline(self)
                    else:
                        self._errHandler.reportMatch(self)
                        self.consume()
                    self.state = 595
                    self._errHandler.sync(self)
                    token = self._input.LA(1)
                    if token in [Qasm2Parser.T__33, Qasm2Parser.T__34, Qasm2Parser.T__37, Qasm2Parser.T__38,
                                 Qasm2Parser.T__39, Qasm2Parser.T__40, Qasm2Parser.T__41, Qasm2Parser.T__42,
                                 Qasm2Parser.T__43, Qasm2Parser.T__44, Qasm2Parser.T__45, Qasm2Parser.T__46,
                                 Qasm2Parser.LPAREN, Qasm2Parser.Constant, Qasm2Parser.Integer, Qasm2Parser.Identifier,
                                 Qasm2Parser.RealNumber, Qasm2Parser.StringLiteral]:
                        self.state = 593
                        self.expressionTerminator(0)
                        pass
                    elif token in [Qasm2Parser.T__19, Qasm2Parser.T__20, Qasm2Parser.MINUS]:
                        self.state = 594
                        self.unaryExpression()
                        pass
                    else:
                        raise NoViableAltException(self)

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

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

        def unaryOperator(self):
            return self.getTypedRuleContext(Qasm2Parser.UnaryOperatorContext, 0)

        def expressionTerminator(self):
            return self.getTypedRuleContext(Qasm2Parser.ExpressionTerminatorContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_unaryExpression

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

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

    def unaryExpression(self):

        localctx = Qasm2Parser.UnaryExpressionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 120, self.RULE_unaryExpression)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 602
            self.unaryOperator()
            self.state = 603
            self.expressionTerminator(0)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ExpressionTerminatorContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def Constant(self):
            return self.getToken(Qasm2Parser.Constant, 0)

        def Integer(self):
            return self.getToken(Qasm2Parser.Integer, 0)

        def RealNumber(self):
            return self.getToken(Qasm2Parser.RealNumber, 0)

        def booleanLiteral(self):
            return self.getTypedRuleContext(Qasm2Parser.BooleanLiteralContext, 0)

        def Identifier(self):
            return self.getToken(Qasm2Parser.Identifier, 0)

        def StringLiteral(self):
            return self.getToken(Qasm2Parser.StringLiteral, 0)

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

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

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

        def builtInMath(self):
            return self.getTypedRuleContext(Qasm2Parser.BuiltInMathContext, 0)

        def expressionTerminator(self):
            return self.getTypedRuleContext(Qasm2Parser.ExpressionTerminatorContext, 0)

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

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

        def incrementor(self):
            return self.getTypedRuleContext(Qasm2Parser.IncrementorContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_expressionTerminator

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

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

    def expressionTerminator(self, _p: int = 0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = Qasm2Parser.ExpressionTerminatorContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 122
        self.enterRecursionRule(localctx, 122, self.RULE_expressionTerminator, _p)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 621
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [Qasm2Parser.Constant]:
                self.state = 606
                self.match(Qasm2Parser.Constant)
                pass
            elif token in [Qasm2Parser.Integer]:
                self.state = 607
                self.match(Qasm2Parser.Integer)
                pass
            elif token in [Qasm2Parser.RealNumber]:
                self.state = 608
                self.match(Qasm2Parser.RealNumber)
                pass
            elif token in [Qasm2Parser.T__33, Qasm2Parser.T__34]:
                self.state = 609
                self.booleanLiteral()
                pass
            elif token in [Qasm2Parser.Identifier]:
                self.state = 610
                self.match(Qasm2Parser.Identifier)
                pass
            elif token in [Qasm2Parser.StringLiteral]:
                self.state = 611
                self.match(Qasm2Parser.StringLiteral)
                pass
            elif token in [Qasm2Parser.LPAREN]:
                self.state = 612
                self.match(Qasm2Parser.LPAREN)
                self.state = 613
                self.expression(0)
                self.state = 614
                self.match(Qasm2Parser.RPAREN)
                pass
            elif token in [Qasm2Parser.T__37, Qasm2Parser.T__38, Qasm2Parser.T__39, Qasm2Parser.T__40,
                           Qasm2Parser.T__41, Qasm2Parser.T__42, Qasm2Parser.T__43, Qasm2Parser.T__44,
                           Qasm2Parser.T__45, Qasm2Parser.T__46]:
                self.state = 616
                self.builtInMath()
                self.state = 617
                self.match(Qasm2Parser.LPAREN)
                self.state = 618
                self.expression(0)
                self.state = 619
                self.match(Qasm2Parser.RPAREN)
                pass
            else:
                raise NoViableAltException(self)

            self._ctx.stop = self._input.LT(-1)
            self.state = 632
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input, 62, self._ctx)
            while _alt != 2 and _alt != ATN.INVALID_ALT_NUMBER:
                if _alt == 1:
                    if self._parseListeners is not None:
                        self.triggerExitRuleEvent()
                    _prevctx = localctx
                    self.state = 630
                    self._errHandler.sync(self)
                    la_ = self._interp.adaptivePredict(self._input, 61, self._ctx)
                    if la_ == 1:
                        localctx = Qasm2Parser.ExpressionTerminatorContext(self, _parentctx, _parentState)
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expressionTerminator)
                        self.state = 623
                        if not self.precpred(self._ctx, 3):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 3)")
                        self.state = 624
                        self.match(Qasm2Parser.LBRACKET)
                        self.state = 625
                        self.expression(0)
                        self.state = 626
                        self.match(Qasm2Parser.RBRACKET)
                        pass

                    elif la_ == 2:
                        localctx = Qasm2Parser.ExpressionTerminatorContext(self, _parentctx, _parentState)
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expressionTerminator)
                        self.state = 628
                        if not self.precpred(self._ctx, 2):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
                        self.state = 629
                        self.incrementor()
                        pass

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

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

        def getRuleIndex(self):
            return Qasm2Parser.RULE_booleanLiteral

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

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

    def booleanLiteral(self):

        localctx = Qasm2Parser.BooleanLiteralContext(self, self._ctx, self.state)
        self.enterRule(localctx, 124, self.RULE_booleanLiteral)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 635
            _la = self._input.LA(1)
            if not (_la == Qasm2Parser.T__33 or _la == Qasm2Parser.T__34):
                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 IncrementorContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def getRuleIndex(self):
            return Qasm2Parser.RULE_incrementor

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

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

    def incrementor(self):

        localctx = Qasm2Parser.IncrementorContext(self, self._ctx, self.state)
        self.enterRule(localctx, 126, self.RULE_incrementor)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 637
            _la = self._input.LA(1)
            if not (_la == Qasm2Parser.T__35 or _la == Qasm2Parser.T__36):
                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 BuiltInCallContext(ParserRuleContext):
        __slots__ = 'parser'

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

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

        def expressionList(self):
            return self.getTypedRuleContext(Qasm2Parser.ExpressionListContext, 0)

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

        def builtInMath(self):
            return self.getTypedRuleContext(Qasm2Parser.BuiltInMathContext, 0)

        def castOperator(self):
            return self.getTypedRuleContext(Qasm2Parser.CastOperatorContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_builtInCall

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

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

    def builtInCall(self):

        localctx = Qasm2Parser.BuiltInCallContext(self, self._ctx, self.state)
        self.enterRule(localctx, 128, self.RULE_builtInCall)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 641
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [Qasm2Parser.T__37, Qasm2Parser.T__38, Qasm2Parser.T__39, Qasm2Parser.T__40, Qasm2Parser.T__41,
                         Qasm2Parser.T__42, Qasm2Parser.T__43, Qasm2Parser.T__44, Qasm2Parser.T__45, Qasm2Parser.T__46]:
                self.state = 639
                self.builtInMath()
                pass
            elif token in [Qasm2Parser.T__4, Qasm2Parser.T__5, Qasm2Parser.T__6, Qasm2Parser.T__7, Qasm2Parser.T__8,
                           Qasm2Parser.T__9, Qasm2Parser.T__10, Qasm2Parser.T__11]:
                self.state = 640
                self.castOperator()
                pass
            else:
                raise NoViableAltException(self)

            self.state = 643
            self.match(Qasm2Parser.LPAREN)
            self.state = 644
            self.expressionList()
            self.state = 645
            self.match(Qasm2Parser.RPAREN)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class BuiltInMathContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def getRuleIndex(self):
            return Qasm2Parser.RULE_builtInMath

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

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

    def builtInMath(self):

        localctx = Qasm2Parser.BuiltInMathContext(self, self._ctx, self.state)
        self.enterRule(localctx, 130, self.RULE_builtInMath)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 647
            _la = self._input.LA(1)
            if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & (
                    (1 << Qasm2Parser.T__37) | (1 << Qasm2Parser.T__38) | (1 << Qasm2Parser.T__39) | (
                    1 << Qasm2Parser.T__40) | (1 << Qasm2Parser.T__41) | (1 << Qasm2Parser.T__42) | (
                            1 << Qasm2Parser.T__43) | (1 << Qasm2Parser.T__44) | (1 << Qasm2Parser.T__45) | (
                            1 << Qasm2Parser.T__46))) != 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 CastOperatorContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def classicalType(self):
            return self.getTypedRuleContext(Qasm2Parser.ClassicalTypeContext, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_castOperator

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

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

    def castOperator(self):

        localctx = Qasm2Parser.CastOperatorContext(self, self._ctx, self.state)
        self.enterRule(localctx, 132, self.RULE_castOperator)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 649
            self.classicalType()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ExpressionListContext(ParserRuleContext):
        __slots__ = 'parser'

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

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

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

        def getRuleIndex(self):
            return Qasm2Parser.RULE_expressionList

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

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

    def expressionList(self):

        localctx = Qasm2Parser.ExpressionListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 134, self.RULE_expressionList)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 656
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input, 64, self._ctx)
            while _alt != 2 and _alt != ATN.INVALID_ALT_NUMBER:
                if _alt == 1:
                    self.state = 651
                    self.expression(0)
                    self.state = 652
                    self.match(Qasm2Parser.COMMA)
                self.state = 658
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input, 64, self._ctx)

            self.state = 659
            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 EqualsExpressionContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def EQUALS(self):
            return self.getToken(Qasm2Parser.EQUALS, 0)

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

        def getRuleIndex(self):
            return Qasm2Parser.RULE_equalsExpression

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

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

    def equalsExpression(self):

        localctx = Qasm2Parser.EqualsExpressionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 136, self.RULE_equalsExpression)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 661
            self.match(Qasm2Parser.EQUALS)
            self.state = 662
            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 AssignmentOperatorContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def EQUALS(self):
            return self.getToken(Qasm2Parser.EQUALS, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_assignmentOperator

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

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

    def assignmentOperator(self):

        localctx = Qasm2Parser.AssignmentOperatorContext(self, self._ctx, self.state)
        self.enterRule(localctx, 138, self.RULE_assignmentOperator)
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 664
            _la = self._input.LA(1)
            if not (((((_la - 48)) & ~0x3f) == 0 and ((1 << (_la - 48)) & (
                    (1 << (Qasm2Parser.T__47 - 48)) | (1 << (Qasm2Parser.T__48 - 48)) | (
                    1 << (Qasm2Parser.T__49 - 48)) | (1 << (Qasm2Parser.T__50 - 48)) | (
                            1 << (Qasm2Parser.T__51 - 48)) | (1 << (Qasm2Parser.T__52 - 48)) | (
                            1 << (Qasm2Parser.T__53 - 48)) | (1 << (Qasm2Parser.T__54 - 48)) | (
                            1 << (Qasm2Parser.T__55 - 48)) | (1 << (Qasm2Parser.T__56 - 48)) | (
                            1 << (Qasm2Parser.EQUALS - 48)))) != 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 SetDeclarationContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def LBRACE(self):
            return self.getToken(Qasm2Parser.LBRACE, 0)

        def expressionList(self):
            return self.getTypedRuleContext(Qasm2Parser.ExpressionListContext, 0)

        def RBRACE(self):
            return self.getToken(Qasm2Parser.RBRACE, 0)

        def rangeDefinition(self):
            return self.getTypedRuleContext(Qasm2Parser.RangeDefinitionContext, 0)

        def Identifier(self):
            return self.getToken(Qasm2Parser.Identifier, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_setDeclaration

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

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

    def setDeclaration(self):

        localctx = Qasm2Parser.SetDeclarationContext(self, self._ctx, self.state)
        self.enterRule(localctx, 140, self.RULE_setDeclaration)
        try:
            self.state = 672
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [Qasm2Parser.LBRACE]:
                self.enterOuterAlt(localctx, 1)
                self.state = 666
                self.match(Qasm2Parser.LBRACE)
                self.state = 667
                self.expressionList()
                self.state = 668
                self.match(Qasm2Parser.RBRACE)
                pass
            elif token in [Qasm2Parser.LBRACKET]:
                self.enterOuterAlt(localctx, 2)
                self.state = 670
                self.rangeDefinition()
                pass
            elif token in [Qasm2Parser.Identifier]:
                self.enterOuterAlt(localctx, 3)
                self.state = 671
                self.match(Qasm2Parser.Identifier)
                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 ProgramBlockContext(ParserRuleContext):
        __slots__ = 'parser'

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

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

        def LBRACE(self):
            return self.getToken(Qasm2Parser.LBRACE, 0)

        def RBRACE(self):
            return self.getToken(Qasm2Parser.RBRACE, 0)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_programBlock

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

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

    def programBlock(self):

        localctx = Qasm2Parser.ProgramBlockContext(self, self._ctx, self.state)
        self.enterRule(localctx, 142, self.RULE_programBlock)
        self._la = 0  # Token type
        try:
            self.state = 683
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [Qasm2Parser.T__15, Qasm2Parser.T__16, Qasm2Parser.T__17, Qasm2Parser.T__18, Qasm2Parser.T__57,
                         Qasm2Parser.Identifier]:
                self.enterOuterAlt(localctx, 1)
                self.state = 674
                self.statement()
                pass
            elif token in [Qasm2Parser.LBRACE]:
                self.enterOuterAlt(localctx, 2)
                self.state = 675
                self.match(Qasm2Parser.LBRACE)
                self.state = 679
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while (((_la) & ~0x3f) == 0 and ((1 << _la) & (
                        (1 << Qasm2Parser.T__15) | (1 << Qasm2Parser.T__16) | (1 << Qasm2Parser.T__17) | (
                        1 << Qasm2Parser.T__18) | (1 << Qasm2Parser.T__57))) != 0) or _la == Qasm2Parser.Identifier:
                    self.state = 676
                    self.statement()
                    self.state = 681
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)

                self.state = 682
                self.match(Qasm2Parser.RBRACE)
                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 BranchingStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

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

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

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

        def programBlock(self, i: int = None):
            if i is None:
                return self.getTypedRuleContexts(Qasm2Parser.ProgramBlockContext)
            else:
                return self.getTypedRuleContext(Qasm2Parser.ProgramBlockContext, i)

        def getRuleIndex(self):
            return Qasm2Parser.RULE_branchingStatement

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

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

    def branchingStatement(self):

        localctx = Qasm2Parser.BranchingStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 144, self.RULE_branchingStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 685
            self.match(Qasm2Parser.T__57)
            self.state = 686
            self.match(Qasm2Parser.LPAREN)
            self.state = 687
            self.expression(0)
            self.state = 688
            self.match(Qasm2Parser.RPAREN)
            self.state = 689
            self.programBlock()
            self.state = 692
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input, 68, self._ctx)
            if la_ == 1:
                self.state = 690
                self.match(Qasm2Parser.T__58)
                self.state = 691
                self.programBlock()


        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[30] = self.indexIdentifier_sempred
        self._predicates[50] = self.expression_sempred
        self._predicates[51] = self.logicalAndExpression_sempred
        self._predicates[52] = self.bitOrExpression_sempred
        self._predicates[53] = self.xOrExpression_sempred
        self._predicates[54] = self.bitAndExpression_sempred
        self._predicates[55] = self.equalityExpression_sempred
        self._predicates[56] = self.comparisonExpression_sempred
        self._predicates[57] = self.bitShiftExpression_sempred
        self._predicates[58] = self.additiveExpression_sempred
        self._predicates[59] = self.multiplicativeExpression_sempred
        self._predicates[61] = self.expressionTerminator_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 indexIdentifier_sempred(self, localctx: IndexIdentifierContext, predIndex: int):
        if predIndex == 0:
            return self.precpred(self._ctx, 1)

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

    def logicalAndExpression_sempred(self, localctx: LogicalAndExpressionContext, predIndex: int):
        if predIndex == 2:
            return self.precpred(self._ctx, 1)

    def bitOrExpression_sempred(self, localctx: BitOrExpressionContext, predIndex: int):
        if predIndex == 3:
            return self.precpred(self._ctx, 1)

    def xOrExpression_sempred(self, localctx: XOrExpressionContext, predIndex: int):
        if predIndex == 4:
            return self.precpred(self._ctx, 1)

    def bitAndExpression_sempred(self, localctx: BitAndExpressionContext, predIndex: int):
        if predIndex == 5:
            return self.precpred(self._ctx, 1)

    def equalityExpression_sempred(self, localctx: EqualityExpressionContext, predIndex: int):
        if predIndex == 6:
            return self.precpred(self._ctx, 1)

    def comparisonExpression_sempred(self, localctx: ComparisonExpressionContext, predIndex: int):
        if predIndex == 7:
            return self.precpred(self._ctx, 1)

    def bitShiftExpression_sempred(self, localctx: BitShiftExpressionContext, predIndex: int):
        if predIndex == 8:
            return self.precpred(self._ctx, 1)

    def additiveExpression_sempred(self, localctx: AdditiveExpressionContext, predIndex: int):
        if predIndex == 9:
            return self.precpred(self._ctx, 1)

    def multiplicativeExpression_sempred(self, localctx: MultiplicativeExpressionContext, predIndex: int):
        if predIndex == 10:
            return self.precpred(self._ctx, 1)

    def expressionTerminator_sempred(self, localctx: ExpressionTerminatorContext, predIndex: int):
        if predIndex == 11:
            return self.precpred(self._ctx, 3)

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