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

def serializedATN():
    return [
        4,1,113,826,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,
        7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,
        13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2,
        20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,26,7,
        26,2,27,7,27,2,28,7,28,2,29,7,29,2,30,7,30,2,31,7,31,2,32,7,32,2,
        33,7,33,2,34,7,34,2,35,7,35,2,36,7,36,2,37,7,37,2,38,7,38,2,39,7,
        39,2,40,7,40,2,41,7,41,2,42,7,42,2,43,7,43,2,44,7,44,2,45,7,45,2,
        46,7,46,2,47,7,47,2,48,7,48,2,49,7,49,2,50,7,50,2,51,7,51,2,52,7,
        52,2,53,7,53,2,54,7,54,2,55,7,55,2,56,7,56,2,57,7,57,2,58,7,58,2,
        59,7,59,2,60,7,60,2,61,7,61,2,62,7,62,2,63,7,63,2,64,7,64,2,65,7,
        65,1,0,3,0,134,8,0,1,0,5,0,137,8,0,10,0,12,0,140,9,0,1,0,1,0,1,1,
        1,1,1,1,1,1,1,2,1,2,5,2,150,8,2,10,2,12,2,153,9,2,1,2,1,2,1,2,1,
        2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,
        2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,3,2,184,8,2,3,2,186,8,2,1,
        3,1,3,3,3,190,8,3,1,4,1,4,5,4,194,8,4,10,4,12,4,197,9,4,1,4,1,4,
        1,5,1,5,1,5,1,6,1,6,3,6,206,8,6,1,7,1,7,1,7,1,7,1,8,1,8,1,8,1,8,
        1,9,1,9,1,9,1,10,1,10,1,10,1,11,1,11,1,11,1,12,1,12,1,12,1,12,1,
        12,1,12,1,12,1,12,1,12,1,12,3,12,235,8,12,1,12,1,12,1,13,1,13,1,
        13,1,13,1,13,1,13,1,13,3,13,246,8,13,1,14,1,14,1,14,3,14,251,8,14,
        1,14,1,14,1,15,1,15,1,15,1,15,1,15,1,15,1,16,1,16,1,16,1,16,1,16,
        1,16,5,16,267,8,16,10,16,12,16,270,9,16,1,16,1,16,1,17,1,17,1,17,
        1,17,1,17,1,17,3,17,280,8,17,1,18,1,18,3,18,284,8,18,1,18,1,18,1,
        19,1,19,3,19,290,8,19,1,19,1,19,1,20,1,20,1,20,3,20,297,8,20,1,20,
        1,20,1,21,5,21,302,8,21,10,21,12,21,305,9,21,1,21,1,21,1,21,3,21,
        310,8,21,1,21,3,21,313,8,21,1,21,3,21,316,8,21,1,21,1,21,1,21,1,
        21,5,21,322,8,21,10,21,12,21,325,9,21,1,21,1,21,1,21,3,21,330,8,
        21,1,21,3,21,333,8,21,1,21,3,21,336,8,21,1,21,3,21,339,8,21,1,21,
        3,21,342,8,21,1,22,1,22,1,22,3,22,347,8,22,1,22,1,22,1,23,1,23,1,
        23,1,23,1,24,1,24,1,24,1,24,1,24,1,24,1,25,1,25,3,25,363,8,25,1,
        25,1,25,1,25,3,25,368,8,25,1,25,1,25,1,26,1,26,1,26,1,26,1,26,1,
        26,1,26,1,27,1,27,1,27,3,27,382,8,27,1,27,1,27,1,27,1,28,1,28,1,
        28,3,28,390,8,28,1,28,1,28,1,29,1,29,1,29,1,29,1,30,1,30,1,30,1,
        30,3,30,402,8,30,1,30,1,30,3,30,406,8,30,1,30,1,30,1,31,1,31,1,31,
        1,31,3,31,414,8,31,1,31,1,31,3,31,418,8,31,1,31,1,31,1,32,1,32,1,
        32,1,32,3,32,426,8,32,1,32,3,32,429,8,32,1,32,1,32,1,32,1,33,1,33,
        1,33,1,33,3,33,438,8,33,1,33,1,33,1,34,1,34,1,34,1,35,1,35,1,35,
        3,35,448,8,35,1,35,1,35,1,36,1,36,1,36,1,36,3,36,456,8,36,1,36,3,
        36,459,8,36,1,36,1,36,3,36,463,8,36,1,36,1,36,3,36,467,8,36,1,36,
        1,36,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,3,37,480,8,37,
        1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,3,37,
        494,8,37,1,37,1,37,3,37,498,8,37,1,37,1,37,1,37,1,37,1,37,1,37,1,
        37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,
        37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,
        37,1,37,1,37,5,37,535,8,37,10,37,12,37,538,9,37,1,38,1,38,1,38,5,
        38,543,8,38,10,38,12,38,546,9,38,1,39,1,39,1,39,3,39,551,8,39,1,
        40,1,40,1,40,1,41,3,41,557,8,41,1,41,1,41,3,41,561,8,41,1,41,1,41,
        3,41,565,8,41,1,42,1,42,1,42,1,42,5,42,571,8,42,10,42,12,42,574,
        9,42,1,42,3,42,577,8,42,1,42,1,42,1,43,1,43,1,43,3,43,584,8,43,1,
        43,1,43,1,43,3,43,589,8,43,5,43,591,8,43,10,43,12,43,594,9,43,1,
        43,3,43,597,8,43,3,43,599,8,43,1,43,1,43,1,44,1,44,1,44,1,44,3,44,
        607,8,44,1,44,1,44,1,44,3,44,612,8,44,5,44,614,8,44,10,44,12,44,
        617,9,44,1,44,3,44,620,8,44,3,44,622,8,44,1,44,1,44,1,45,1,45,5,
        45,628,8,45,10,45,12,45,631,9,45,1,46,1,46,1,46,1,47,1,47,1,47,1,
        47,1,47,1,47,1,47,1,47,1,47,1,47,1,47,3,47,647,8,47,3,47,649,8,47,
        1,47,1,47,1,48,1,48,3,48,655,8,48,1,48,1,48,3,48,659,8,48,1,48,1,
        48,3,48,663,8,48,1,48,1,48,3,48,667,8,48,1,48,1,48,3,48,671,8,48,
        1,48,1,48,1,48,1,48,1,48,1,48,1,48,1,48,3,48,681,8,48,3,48,683,8,
        48,1,49,1,49,3,49,687,8,49,1,50,1,50,1,50,1,50,1,50,1,50,1,50,1,
        51,1,51,1,51,1,51,1,51,1,51,1,51,1,51,1,51,3,51,705,8,51,1,51,1,
        51,1,52,1,52,1,52,1,52,1,53,1,53,1,54,1,54,3,54,717,8,54,1,55,1,
        55,1,56,1,56,3,56,723,8,56,1,57,1,57,1,57,1,57,3,57,729,8,57,3,57,
        731,8,57,1,58,1,58,1,58,1,58,1,58,1,58,1,58,1,58,1,58,3,58,742,8,
        58,1,58,1,58,1,58,3,58,747,8,58,1,59,1,59,1,59,5,59,752,8,59,10,
        59,12,59,755,9,59,1,59,3,59,758,8,59,1,60,1,60,1,60,5,60,763,8,60,
        10,60,12,60,766,9,60,1,60,3,60,769,8,60,1,61,1,61,1,61,5,61,774,
        8,61,10,61,12,61,777,9,61,1,61,3,61,780,8,61,1,62,1,62,1,62,5,62,
        785,8,62,10,62,12,62,788,9,62,1,62,3,62,791,8,62,1,63,1,63,1,63,
        5,63,796,8,63,10,63,12,63,799,9,63,1,63,3,63,802,8,63,1,64,1,64,
        1,64,5,64,807,8,64,10,64,12,64,810,9,64,1,64,3,64,813,8,64,1,65,
        1,65,1,65,5,65,818,8,65,10,65,12,65,821,9,65,1,65,3,65,824,8,65,
        1,65,0,1,74,66,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,
        36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,
        80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,
        118,120,122,124,126,128,130,0,11,1,0,25,26,2,0,30,30,32,32,2,0,66,
        66,84,84,2,0,70,70,81,82,2,0,55,55,88,97,2,0,71,71,73,74,2,0,68,
        68,70,70,1,0,47,48,1,0,28,29,2,0,51,53,93,93,1,0,93,94,911,0,133,
        1,0,0,0,2,143,1,0,0,0,4,185,1,0,0,0,6,187,1,0,0,0,8,191,1,0,0,0,
        10,200,1,0,0,0,12,205,1,0,0,0,14,207,1,0,0,0,16,211,1,0,0,0,18,215,
        1,0,0,0,20,218,1,0,0,0,22,221,1,0,0,0,24,224,1,0,0,0,26,238,1,0,
        0,0,28,247,1,0,0,0,30,254,1,0,0,0,32,260,1,0,0,0,34,279,1,0,0,0,
        36,281,1,0,0,0,38,287,1,0,0,0,40,293,1,0,0,0,42,341,1,0,0,0,44,343,
        1,0,0,0,46,350,1,0,0,0,48,354,1,0,0,0,50,362,1,0,0,0,52,371,1,0,
        0,0,54,378,1,0,0,0,56,386,1,0,0,0,58,393,1,0,0,0,60,397,1,0,0,0,
        62,409,1,0,0,0,64,421,1,0,0,0,66,433,1,0,0,0,68,441,1,0,0,0,70,444,
        1,0,0,0,72,451,1,0,0,0,74,497,1,0,0,0,76,539,1,0,0,0,78,550,1,0,
        0,0,80,552,1,0,0,0,82,556,1,0,0,0,84,566,1,0,0,0,86,580,1,0,0,0,
        88,602,1,0,0,0,90,625,1,0,0,0,92,632,1,0,0,0,94,648,1,0,0,0,96,682,
        1,0,0,0,98,684,1,0,0,0,100,688,1,0,0,0,102,695,1,0,0,0,104,708,1,
        0,0,0,106,712,1,0,0,0,108,716,1,0,0,0,110,718,1,0,0,0,112,722,1,
        0,0,0,114,730,1,0,0,0,116,746,1,0,0,0,118,748,1,0,0,0,120,759,1,
        0,0,0,122,770,1,0,0,0,124,781,1,0,0,0,126,792,1,0,0,0,128,803,1,
        0,0,0,130,814,1,0,0,0,132,134,3,2,1,0,133,132,1,0,0,0,133,134,1,
        0,0,0,134,138,1,0,0,0,135,137,3,12,6,0,136,135,1,0,0,0,137,140,1,
        0,0,0,138,136,1,0,0,0,138,139,1,0,0,0,139,141,1,0,0,0,140,138,1,
        0,0,0,141,142,5,0,0,1,142,1,1,0,0,0,143,144,5,1,0,0,144,145,5,103,
        0,0,145,146,5,63,0,0,146,3,1,0,0,0,147,186,3,10,5,0,148,150,3,6,
        3,0,149,148,1,0,0,0,150,153,1,0,0,0,151,149,1,0,0,0,151,152,1,0,
        0,0,152,183,1,0,0,0,153,151,1,0,0,0,154,184,3,48,24,0,155,184,3,
        66,33,0,156,184,3,36,18,0,157,184,3,38,19,0,158,184,3,18,9,0,159,
        184,3,70,35,0,160,184,3,14,7,0,161,184,3,50,25,0,162,184,3,52,26,
        0,163,184,3,20,10,0,164,184,3,60,30,0,165,184,3,72,36,0,166,184,
        3,40,20,0,167,184,3,22,11,0,168,184,3,68,34,0,169,184,3,62,31,0,
        170,184,3,24,12,0,171,184,3,42,21,0,172,184,3,64,32,0,173,184,3,
        26,13,0,174,184,3,16,8,0,175,184,3,54,27,0,176,184,3,44,22,0,177,
        184,3,56,28,0,178,184,3,58,29,0,179,184,3,46,23,0,180,184,3,28,14,
        0,181,184,3,32,16,0,182,184,3,30,15,0,183,154,1,0,0,0,183,155,1,
        0,0,0,183,156,1,0,0,0,183,157,1,0,0,0,183,158,1,0,0,0,183,159,1,
        0,0,0,183,160,1,0,0,0,183,161,1,0,0,0,183,162,1,0,0,0,183,163,1,
        0,0,0,183,164,1,0,0,0,183,165,1,0,0,0,183,166,1,0,0,0,183,167,1,
        0,0,0,183,168,1,0,0,0,183,169,1,0,0,0,183,170,1,0,0,0,183,171,1,
        0,0,0,183,172,1,0,0,0,183,173,1,0,0,0,183,174,1,0,0,0,183,175,1,
        0,0,0,183,176,1,0,0,0,183,177,1,0,0,0,183,178,1,0,0,0,183,179,1,
        0,0,0,183,180,1,0,0,0,183,181,1,0,0,0,183,182,1,0,0,0,184,186,1,
        0,0,0,185,147,1,0,0,0,185,151,1,0,0,0,186,5,1,0,0,0,187,189,5,24,
        0,0,188,190,5,108,0,0,189,188,1,0,0,0,189,190,1,0,0,0,190,7,1,0,
        0,0,191,195,5,58,0,0,192,194,3,12,6,0,193,192,1,0,0,0,194,197,1,
        0,0,0,195,193,1,0,0,0,195,196,1,0,0,0,196,198,1,0,0,0,197,195,1,
        0,0,0,198,199,5,59,0,0,199,9,1,0,0,0,200,201,5,23,0,0,201,202,5,
        108,0,0,202,11,1,0,0,0,203,206,3,4,2,0,204,206,3,8,4,0,205,203,1,
        0,0,0,205,204,1,0,0,0,206,13,1,0,0,0,207,208,5,3,0,0,208,209,5,105,
        0,0,209,210,5,63,0,0,210,15,1,0,0,0,211,212,5,2,0,0,212,213,5,105,
        0,0,213,214,5,63,0,0,214,17,1,0,0,0,215,216,5,11,0,0,216,217,5,63,
        0,0,217,19,1,0,0,0,218,219,5,12,0,0,219,220,5,63,0,0,220,21,1,0,
        0,0,221,222,5,15,0,0,222,223,5,63,0,0,223,23,1,0,0,0,224,225,5,17,
        0,0,225,226,3,96,48,0,226,227,5,93,0,0,227,234,5,19,0,0,228,235,
        3,84,42,0,229,230,5,56,0,0,230,231,3,82,41,0,231,232,5,57,0,0,232,
        235,1,0,0,0,233,235,3,74,37,0,234,228,1,0,0,0,234,229,1,0,0,0,234,
        233,1,0,0,0,235,236,1,0,0,0,236,237,3,12,6,0,237,25,1,0,0,0,238,
        239,5,13,0,0,239,240,5,60,0,0,240,241,3,74,37,0,241,242,5,61,0,0,
        242,245,3,12,6,0,243,244,5,14,0,0,244,246,3,12,6,0,245,243,1,0,0,
        0,245,246,1,0,0,0,246,27,1,0,0,0,247,250,5,16,0,0,248,251,3,74,37,
        0,249,251,3,80,40,0,250,248,1,0,0,0,250,249,1,0,0,0,250,251,1,0,
        0,0,251,252,1,0,0,0,252,253,5,63,0,0,253,29,1,0,0,0,254,255,5,18,
        0,0,255,256,5,60,0,0,256,257,3,74,37,0,257,258,5,61,0,0,258,259,
        3,12,6,0,259,31,1,0,0,0,260,261,5,20,0,0,261,262,5,60,0,0,262,263,
        3,74,37,0,263,264,5,61,0,0,264,268,5,58,0,0,265,267,3,34,17,0,266,
        265,1,0,0,0,267,270,1,0,0,0,268,266,1,0,0,0,268,269,1,0,0,0,269,
        271,1,0,0,0,270,268,1,0,0,0,271,272,5,59,0,0,272,33,1,0,0,0,273,
        274,5,21,0,0,274,275,3,124,62,0,275,276,3,8,4,0,276,280,1,0,0,0,
        277,278,5,22,0,0,278,280,3,8,4,0,279,273,1,0,0,0,279,277,1,0,0,0,
        280,35,1,0,0,0,281,283,5,54,0,0,282,284,3,128,64,0,283,282,1,0,0,
        0,283,284,1,0,0,0,284,285,1,0,0,0,285,286,5,63,0,0,286,37,1,0,0,
        0,287,289,5,9,0,0,288,290,3,104,52,0,289,288,1,0,0,0,289,290,1,0,
        0,0,290,291,1,0,0,0,291,292,3,8,4,0,292,39,1,0,0,0,293,294,5,51,
        0,0,294,296,3,104,52,0,295,297,3,128,64,0,296,295,1,0,0,0,296,297,
        1,0,0,0,297,298,1,0,0,0,298,299,5,63,0,0,299,41,1,0,0,0,300,302,
        3,94,47,0,301,300,1,0,0,0,302,305,1,0,0,0,303,301,1,0,0,0,303,304,
        1,0,0,0,304,306,1,0,0,0,305,303,1,0,0,0,306,312,5,93,0,0,307,309,
        5,60,0,0,308,310,3,124,62,0,309,308,1,0,0,0,309,310,1,0,0,0,310,
        311,1,0,0,0,311,313,5,61,0,0,312,307,1,0,0,0,312,313,1,0,0,0,313,
        315,1,0,0,0,314,316,3,104,52,0,315,314,1,0,0,0,315,316,1,0,0,0,316,
        317,1,0,0,0,317,318,3,128,64,0,318,319,5,63,0,0,319,342,1,0,0,0,
        320,322,3,94,47,0,321,320,1,0,0,0,322,325,1,0,0,0,323,321,1,0,0,
        0,323,324,1,0,0,0,324,326,1,0,0,0,325,323,1,0,0,0,326,332,5,44,0,
        0,327,329,5,60,0,0,328,330,3,124,62,0,329,328,1,0,0,0,329,330,1,
        0,0,0,330,331,1,0,0,0,331,333,5,61,0,0,332,327,1,0,0,0,332,333,1,
        0,0,0,333,335,1,0,0,0,334,336,3,104,52,0,335,334,1,0,0,0,335,336,
        1,0,0,0,336,338,1,0,0,0,337,339,3,128,64,0,338,337,1,0,0,0,338,339,
        1,0,0,0,339,340,1,0,0,0,340,342,5,63,0,0,341,303,1,0,0,0,341,323,
        1,0,0,0,342,43,1,0,0,0,343,346,3,80,40,0,344,345,5,67,0,0,345,347,
        3,90,45,0,346,344,1,0,0,0,346,347,1,0,0,0,347,348,1,0,0,0,348,349,
        5,63,0,0,349,45,1,0,0,0,350,351,5,52,0,0,351,352,3,112,56,0,352,
        353,5,63,0,0,353,47,1,0,0,0,354,355,5,10,0,0,355,356,5,93,0,0,356,
        357,5,66,0,0,357,358,3,76,38,0,358,359,5,63,0,0,359,49,1,0,0,0,360,
        363,3,96,48,0,361,363,3,100,50,0,362,360,1,0,0,0,362,361,1,0,0,0,
        363,364,1,0,0,0,364,367,5,93,0,0,365,366,5,66,0,0,366,368,3,78,39,
        0,367,365,1,0,0,0,367,368,1,0,0,0,368,369,1,0,0,0,369,370,5,63,0,
        0,370,51,1,0,0,0,371,372,5,27,0,0,372,373,3,96,48,0,373,374,5,93,
        0,0,374,375,5,66,0,0,375,376,3,78,39,0,376,377,5,63,0,0,377,53,1,
        0,0,0,378,381,7,0,0,0,379,382,3,96,48,0,380,382,3,100,50,0,381,379,
        1,0,0,0,381,380,1,0,0,0,382,383,1,0,0,0,383,384,5,93,0,0,384,385,
        5,63,0,0,385,55,1,0,0,0,386,387,7,1,0,0,387,389,5,93,0,0,388,390,
        3,104,52,0,389,388,1,0,0,0,389,390,1,0,0,0,390,391,1,0,0,0,391,392,
        5,63,0,0,392,57,1,0,0,0,393,394,3,98,49,0,394,395,5,93,0,0,395,396,
        5,63,0,0,396,59,1,0,0,0,397,398,5,4,0,0,398,399,5,93,0,0,399,401,
        5,60,0,0,400,402,3,118,59,0,401,400,1,0,0,0,401,402,1,0,0,0,402,
        403,1,0,0,0,403,405,5,61,0,0,404,406,3,92,46,0,405,404,1,0,0,0,405,
        406,1,0,0,0,406,407,1,0,0,0,407,408,3,8,4,0,408,61,1,0,0,0,409,410,
        5,8,0,0,410,411,5,93,0,0,411,413,5,60,0,0,412,414,3,130,65,0,413,
        412,1,0,0,0,413,414,1,0,0,0,414,415,1,0,0,0,415,417,5,61,0,0,416,
        418,3,92,46,0,417,416,1,0,0,0,417,418,1,0,0,0,418,419,1,0,0,0,419,
        420,5,63,0,0,420,63,1,0,0,0,421,422,5,7,0,0,422,428,5,93,0,0,423,
        425,5,60,0,0,424,426,3,126,63,0,425,424,1,0,0,0,425,426,1,0,0,0,
        426,427,1,0,0,0,427,429,5,61,0,0,428,423,1,0,0,0,428,429,1,0,0,0,
        429,430,1,0,0,0,430,431,3,126,63,0,431,432,3,8,4,0,432,65,1,0,0,
        0,433,434,3,90,45,0,434,437,7,2,0,0,435,438,3,74,37,0,436,438,3,
        80,40,0,437,435,1,0,0,0,437,436,1,0,0,0,438,439,1,0,0,0,439,440,
        5,63,0,0,440,67,1,0,0,0,441,442,3,74,37,0,442,443,5,63,0,0,443,69,
        1,0,0,0,444,445,5,5,0,0,445,447,5,58,0,0,446,448,5,113,0,0,447,446,
        1,0,0,0,447,448,1,0,0,0,448,449,1,0,0,0,449,450,5,59,0,0,450,71,
        1,0,0,0,451,452,5,6,0,0,452,458,3,106,53,0,453,455,5,60,0,0,454,
        456,3,120,60,0,455,454,1,0,0,0,455,456,1,0,0,0,456,457,1,0,0,0,457,
        459,5,61,0,0,458,453,1,0,0,0,458,459,1,0,0,0,459,460,1,0,0,0,460,
        462,3,122,61,0,461,463,3,92,46,0,462,461,1,0,0,0,462,463,1,0,0,0,
        463,464,1,0,0,0,464,466,5,58,0,0,465,467,5,113,0,0,466,465,1,0,0,
        0,466,467,1,0,0,0,467,468,1,0,0,0,468,469,5,59,0,0,469,73,1,0,0,
        0,470,471,6,37,-1,0,471,472,5,60,0,0,472,473,3,74,37,0,473,474,5,
        61,0,0,474,498,1,0,0,0,475,476,7,3,0,0,476,498,3,74,37,15,477,480,
        3,96,48,0,478,480,3,100,50,0,479,477,1,0,0,0,479,478,1,0,0,0,480,
        481,1,0,0,0,481,482,5,60,0,0,482,483,3,74,37,0,483,484,5,61,0,0,
        484,498,1,0,0,0,485,486,5,50,0,0,486,487,5,60,0,0,487,488,3,8,4,
        0,488,489,5,61,0,0,489,498,1,0,0,0,490,491,5,93,0,0,491,493,5,60,
        0,0,492,494,3,124,62,0,493,492,1,0,0,0,493,494,1,0,0,0,494,495,1,
        0,0,0,495,498,5,61,0,0,496,498,7,4,0,0,497,470,1,0,0,0,497,475,1,
        0,0,0,497,479,1,0,0,0,497,485,1,0,0,0,497,490,1,0,0,0,497,496,1,
        0,0,0,498,536,1,0,0,0,499,500,10,16,0,0,500,501,5,72,0,0,501,535,
        3,74,37,16,502,503,10,14,0,0,503,504,7,5,0,0,504,535,3,74,37,15,
        505,506,10,13,0,0,506,507,7,6,0,0,507,535,3,74,37,14,508,509,10,
        12,0,0,509,510,5,86,0,0,510,535,3,74,37,13,511,512,10,11,0,0,512,
        513,5,85,0,0,513,535,3,74,37,12,514,515,10,10,0,0,515,516,5,83,0,
        0,516,535,3,74,37,11,517,518,10,9,0,0,518,519,5,77,0,0,519,535,3,
        74,37,10,520,521,10,8,0,0,521,522,5,79,0,0,522,535,3,74,37,9,523,
        524,10,7,0,0,524,525,5,75,0,0,525,535,3,74,37,8,526,527,10,6,0,0,
        527,528,5,78,0,0,528,535,3,74,37,7,529,530,10,5,0,0,530,531,5,76,
        0,0,531,535,3,74,37,6,532,533,10,17,0,0,533,535,3,88,44,0,534,499,
        1,0,0,0,534,502,1,0,0,0,534,505,1,0,0,0,534,508,1,0,0,0,534,511,
        1,0,0,0,534,514,1,0,0,0,534,517,1,0,0,0,534,520,1,0,0,0,534,523,
        1,0,0,0,534,526,1,0,0,0,534,529,1,0,0,0,534,532,1,0,0,0,535,538,
        1,0,0,0,536,534,1,0,0,0,536,537,1,0,0,0,537,75,1,0,0,0,538,536,1,
        0,0,0,539,544,3,74,37,0,540,541,5,69,0,0,541,543,3,74,37,0,542,540,
        1,0,0,0,543,546,1,0,0,0,544,542,1,0,0,0,544,545,1,0,0,0,545,77,1,
        0,0,0,546,544,1,0,0,0,547,551,3,86,43,0,548,551,3,74,37,0,549,551,
        3,80,40,0,550,547,1,0,0,0,550,548,1,0,0,0,550,549,1,0,0,0,551,79,
        1,0,0,0,552,553,5,53,0,0,553,554,3,112,56,0,554,81,1,0,0,0,555,557,
        3,74,37,0,556,555,1,0,0,0,556,557,1,0,0,0,557,558,1,0,0,0,558,560,
        5,62,0,0,559,561,3,74,37,0,560,559,1,0,0,0,560,561,1,0,0,0,561,564,
        1,0,0,0,562,563,5,62,0,0,563,565,3,74,37,0,564,562,1,0,0,0,564,565,
        1,0,0,0,565,83,1,0,0,0,566,567,5,58,0,0,567,572,3,74,37,0,568,569,
        5,65,0,0,569,571,3,74,37,0,570,568,1,0,0,0,571,574,1,0,0,0,572,570,
        1,0,0,0,572,573,1,0,0,0,573,576,1,0,0,0,574,572,1,0,0,0,575,577,
        5,65,0,0,576,575,1,0,0,0,576,577,1,0,0,0,577,578,1,0,0,0,578,579,
        5,59,0,0,579,85,1,0,0,0,580,598,5,58,0,0,581,584,3,74,37,0,582,584,
        3,86,43,0,583,581,1,0,0,0,583,582,1,0,0,0,584,592,1,0,0,0,585,588,
        5,65,0,0,586,589,3,74,37,0,587,589,3,86,43,0,588,586,1,0,0,0,588,
        587,1,0,0,0,589,591,1,0,0,0,590,585,1,0,0,0,591,594,1,0,0,0,592,
        590,1,0,0,0,592,593,1,0,0,0,593,596,1,0,0,0,594,592,1,0,0,0,595,
        597,5,65,0,0,596,595,1,0,0,0,596,597,1,0,0,0,597,599,1,0,0,0,598,
        583,1,0,0,0,598,599,1,0,0,0,599,600,1,0,0,0,600,601,5,59,0,0,601,
        87,1,0,0,0,602,621,5,56,0,0,603,622,3,84,42,0,604,607,3,74,37,0,
        605,607,3,82,41,0,606,604,1,0,0,0,606,605,1,0,0,0,607,615,1,0,0,
        0,608,611,5,65,0,0,609,612,3,74,37,0,610,612,3,82,41,0,611,609,1,
        0,0,0,611,610,1,0,0,0,612,614,1,0,0,0,613,608,1,0,0,0,614,617,1,
        0,0,0,615,613,1,0,0,0,615,616,1,0,0,0,616,619,1,0,0,0,617,615,1,
        0,0,0,618,620,5,65,0,0,619,618,1,0,0,0,619,620,1,0,0,0,620,622,1,
        0,0,0,621,603,1,0,0,0,621,606,1,0,0,0,622,623,1,0,0,0,623,624,5,
        57,0,0,624,89,1,0,0,0,625,629,5,93,0,0,626,628,3,88,44,0,627,626,
        1,0,0,0,628,631,1,0,0,0,629,627,1,0,0,0,629,630,1,0,0,0,630,91,1,
        0,0,0,631,629,1,0,0,0,632,633,5,67,0,0,633,634,3,96,48,0,634,93,
        1,0,0,0,635,649,5,45,0,0,636,637,5,46,0,0,637,638,5,60,0,0,638,639,
        3,74,37,0,639,640,5,61,0,0,640,649,1,0,0,0,641,646,7,7,0,0,642,643,
        5,60,0,0,643,644,3,74,37,0,644,645,5,61,0,0,645,647,1,0,0,0,646,
        642,1,0,0,0,646,647,1,0,0,0,647,649,1,0,0,0,648,635,1,0,0,0,648,
        636,1,0,0,0,648,641,1,0,0,0,649,650,1,0,0,0,650,651,5,80,0,0,651,
        95,1,0,0,0,652,654,5,34,0,0,653,655,3,104,52,0,654,653,1,0,0,0,654,
        655,1,0,0,0,655,683,1,0,0,0,656,658,5,35,0,0,657,659,3,104,52,0,
        658,657,1,0,0,0,658,659,1,0,0,0,659,683,1,0,0,0,660,662,5,36,0,0,
        661,663,3,104,52,0,662,661,1,0,0,0,662,663,1,0,0,0,663,683,1,0,0,
        0,664,666,5,37,0,0,665,667,3,104,52,0,666,665,1,0,0,0,666,667,1,
        0,0,0,667,683,1,0,0,0,668,670,5,38,0,0,669,671,3,104,52,0,670,669,
        1,0,0,0,670,671,1,0,0,0,671,683,1,0,0,0,672,683,5,33,0,0,673,683,
        5,42,0,0,674,683,5,43,0,0,675,680,5,39,0,0,676,677,5,56,0,0,677,
        678,3,96,48,0,678,679,5,57,0,0,679,681,1,0,0,0,680,676,1,0,0,0,680,
        681,1,0,0,0,681,683,1,0,0,0,682,652,1,0,0,0,682,656,1,0,0,0,682,
        660,1,0,0,0,682,664,1,0,0,0,682,668,1,0,0,0,682,672,1,0,0,0,682,
        673,1,0,0,0,682,674,1,0,0,0,682,675,1,0,0,0,683,97,1,0,0,0,684,686,
        5,31,0,0,685,687,3,104,52,0,686,685,1,0,0,0,686,687,1,0,0,0,687,
        99,1,0,0,0,688,689,5,40,0,0,689,690,5,56,0,0,690,691,3,96,48,0,691,
        692,5,65,0,0,692,693,3,124,62,0,693,694,5,57,0,0,694,101,1,0,0,0,
        695,696,7,8,0,0,696,697,5,40,0,0,697,698,5,56,0,0,698,699,3,96,48,
        0,699,704,5,65,0,0,700,705,3,124,62,0,701,702,5,49,0,0,702,703,5,
        66,0,0,703,705,3,74,37,0,704,700,1,0,0,0,704,701,1,0,0,0,705,706,
        1,0,0,0,706,707,5,57,0,0,707,103,1,0,0,0,708,709,5,56,0,0,709,710,
        3,74,37,0,710,711,5,57,0,0,711,105,1,0,0,0,712,713,7,9,0,0,713,107,
        1,0,0,0,714,717,3,74,37,0,715,717,3,116,58,0,716,714,1,0,0,0,716,
        715,1,0,0,0,717,109,1,0,0,0,718,719,7,10,0,0,719,111,1,0,0,0,720,
        723,3,90,45,0,721,723,5,94,0,0,722,720,1,0,0,0,722,721,1,0,0,0,723,
        113,1,0,0,0,724,731,3,96,48,0,725,731,3,102,51,0,726,728,5,32,0,
        0,727,729,3,104,52,0,728,727,1,0,0,0,728,729,1,0,0,0,729,731,1,0,
        0,0,730,724,1,0,0,0,730,725,1,0,0,0,730,726,1,0,0,0,731,115,1,0,
        0,0,732,733,3,96,48,0,733,734,5,93,0,0,734,747,1,0,0,0,735,736,3,
        98,49,0,736,737,5,93,0,0,737,747,1,0,0,0,738,739,7,1,0,0,739,741,
        5,93,0,0,740,742,3,104,52,0,741,740,1,0,0,0,741,742,1,0,0,0,742,
        747,1,0,0,0,743,744,3,102,51,0,744,745,5,93,0,0,745,747,1,0,0,0,
        746,732,1,0,0,0,746,735,1,0,0,0,746,738,1,0,0,0,746,743,1,0,0,0,
        747,117,1,0,0,0,748,753,3,116,58,0,749,750,5,65,0,0,750,752,3,116,
        58,0,751,749,1,0,0,0,752,755,1,0,0,0,753,751,1,0,0,0,753,754,1,0,
        0,0,754,757,1,0,0,0,755,753,1,0,0,0,756,758,5,65,0,0,757,756,1,0,
        0,0,757,758,1,0,0,0,758,119,1,0,0,0,759,764,3,108,54,0,760,761,5,
        65,0,0,761,763,3,108,54,0,762,760,1,0,0,0,763,766,1,0,0,0,764,762,
        1,0,0,0,764,765,1,0,0,0,765,768,1,0,0,0,766,764,1,0,0,0,767,769,
        5,65,0,0,768,767,1,0,0,0,768,769,1,0,0,0,769,121,1,0,0,0,770,775,
        3,110,55,0,771,772,5,65,0,0,772,774,3,110,55,0,773,771,1,0,0,0,774,
        777,1,0,0,0,775,773,1,0,0,0,775,776,1,0,0,0,776,779,1,0,0,0,777,
        775,1,0,0,0,778,780,5,65,0,0,779,778,1,0,0,0,779,780,1,0,0,0,780,
        123,1,0,0,0,781,786,3,74,37,0,782,783,5,65,0,0,783,785,3,74,37,0,
        784,782,1,0,0,0,785,788,1,0,0,0,786,784,1,0,0,0,786,787,1,0,0,0,
        787,790,1,0,0,0,788,786,1,0,0,0,789,791,5,65,0,0,790,789,1,0,0,0,
        790,791,1,0,0,0,791,125,1,0,0,0,792,797,5,93,0,0,793,794,5,65,0,
        0,794,796,5,93,0,0,795,793,1,0,0,0,796,799,1,0,0,0,797,795,1,0,0,
        0,797,798,1,0,0,0,798,801,1,0,0,0,799,797,1,0,0,0,800,802,5,65,0,
        0,801,800,1,0,0,0,801,802,1,0,0,0,802,127,1,0,0,0,803,808,3,112,
        56,0,804,805,5,65,0,0,805,807,3,112,56,0,806,804,1,0,0,0,807,810,
        1,0,0,0,808,806,1,0,0,0,808,809,1,0,0,0,809,812,1,0,0,0,810,808,
        1,0,0,0,811,813,5,65,0,0,812,811,1,0,0,0,812,813,1,0,0,0,813,129,
        1,0,0,0,814,819,3,114,57,0,815,816,5,65,0,0,816,818,3,114,57,0,817,
        815,1,0,0,0,818,821,1,0,0,0,819,817,1,0,0,0,819,820,1,0,0,0,820,
        823,1,0,0,0,821,819,1,0,0,0,822,824,5,65,0,0,823,822,1,0,0,0,823,
        824,1,0,0,0,824,131,1,0,0,0,97,133,138,151,183,185,189,195,205,234,
        245,250,268,279,283,289,296,303,309,312,315,323,329,332,335,338,
        341,346,362,367,381,389,401,405,413,417,425,428,437,447,455,458,
        462,466,479,493,497,534,536,544,550,556,560,564,572,576,583,588,
        592,596,598,606,611,615,619,621,629,646,648,654,658,662,666,670,
        680,682,686,704,716,722,728,730,741,746,753,757,764,768,775,779,
        786,790,797,801,808,812,819,823
    ]

class qasm3Parser ( Parser ):

    grammarFileName = "qasm3Parser.g4"

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

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

    sharedContextCache = PredictionContextCache()

    literalNames = [ "<INVALID>", "'OPENQASM'", "'include'", "'defcalgrammar'", 
                     "'def'", "'cal'", "'defcal'", "'gate'", "'extern'", 
                     "'box'", "'let'", "'break'", "'continue'", "'if'", 
                     "'else'", "'end'", "'return'", "'for'", "'while'", 
                     "'in'", "'switch'", "'case'", "'default'", "<INVALID>", 
                     "<INVALID>", "'input'", "'output'", "'const'", "'readonly'", 
                     "'mutable'", "'qreg'", "'qubit'", "'creg'", "'bool'", 
                     "'bit'", "'int'", "'uint'", "'float'", "'angle'", "'complex'", 
                     "'array'", "'void'", "'duration'", "'stretch'", "'gphase'", 
                     "'inv'", "'pow'", "'ctrl'", "'negctrl'", "'#dim'", 
                     "'durationof'", "'delay'", "'reset'", "'measure'", 
                     "'barrier'", "<INVALID>", "'['", "']'", "'{'", "'}'", 
                     "'('", "')'", "':'", "';'", "'.'", "','", "'='", "'->'", 
                     "'+'", "'++'", "'-'", "'*'", "'**'", "'/'", "'%'", 
                     "'|'", "'||'", "'&'", "'&&'", "'^'", "'@'", "'~'", 
                     "'!'", "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "'im'" ]

    symbolicNames = [ "<INVALID>", "OPENQASM", "INCLUDE", "DEFCALGRAMMAR", 
                      "DEF", "CAL", "DEFCAL", "GATE", "EXTERN", "BOX", "LET", 
                      "BREAK", "CONTINUE", "IF", "ELSE", "END", "RETURN", 
                      "FOR", "WHILE", "IN", "SWITCH", "CASE", "DEFAULT", 
                      "PRAGMA", "AnnotationKeyword", "INPUT", "OUTPUT", 
                      "CONST", "READONLY", "MUTABLE", "QREG", "QUBIT", "CREG", 
                      "BOOL", "BIT", "INT", "UINT", "FLOAT", "ANGLE", "COMPLEX", 
                      "ARRAY", "VOID", "DURATION", "STRETCH", "GPHASE", 
                      "INV", "POW", "CTRL", "NEGCTRL", "DIM", "DURATIONOF", 
                      "DELAY", "RESET", "MEASURE", "BARRIER", "BooleanLiteral", 
                      "LBRACKET", "RBRACKET", "LBRACE", "RBRACE", "LPAREN", 
                      "RPAREN", "COLON", "SEMICOLON", "DOT", "COMMA", "EQUALS", 
                      "ARROW", "PLUS", "DOUBLE_PLUS", "MINUS", "ASTERISK", 
                      "DOUBLE_ASTERISK", "SLASH", "PERCENT", "PIPE", "DOUBLE_PIPE", 
                      "AMPERSAND", "DOUBLE_AMPERSAND", "CARET", "AT", "TILDE", 
                      "EXCLAMATION_POINT", "EqualityOperator", "CompoundAssignmentOperator", 
                      "ComparisonOperator", "BitshiftOperator", "IMAG", 
                      "ImaginaryLiteral", "BinaryIntegerLiteral", "OctalIntegerLiteral", 
                      "DecimalIntegerLiteral", "HexIntegerLiteral", "Identifier", 
                      "HardwareQubit", "FloatLiteral", "TimingLiteral", 
                      "BitstringLiteral", "Whitespace", "Newline", "LineComment", 
                      "BlockComment", "VERSION_IDENTIFER_WHITESPACE", "VersionSpecifier", 
                      "ARBITRARY_STRING_WHITESPACE", "StringLiteral", "EAT_INITIAL_SPACE", 
                      "EAT_LINE_END", "RemainingLineContent", "CAL_PRELUDE_WHITESPACE", 
                      "CAL_PRELUDE_COMMENT", "DEFCAL_PRELUDE_WHITESPACE", 
                      "DEFCAL_PRELUDE_COMMENT", "CalibrationBlock" ]

    RULE_program = 0
    RULE_version = 1
    RULE_statement = 2
    RULE_annotation = 3
    RULE_scope = 4
    RULE_pragma = 5
    RULE_statementOrScope = 6
    RULE_calibrationGrammarStatement = 7
    RULE_includeStatement = 8
    RULE_breakStatement = 9
    RULE_continueStatement = 10
    RULE_endStatement = 11
    RULE_forStatement = 12
    RULE_ifStatement = 13
    RULE_returnStatement = 14
    RULE_whileStatement = 15
    RULE_switchStatement = 16
    RULE_switchCaseItem = 17
    RULE_barrierStatement = 18
    RULE_boxStatement = 19
    RULE_delayStatement = 20
    RULE_gateCallStatement = 21
    RULE_measureArrowAssignmentStatement = 22
    RULE_resetStatement = 23
    RULE_aliasDeclarationStatement = 24
    RULE_classicalDeclarationStatement = 25
    RULE_constDeclarationStatement = 26
    RULE_ioDeclarationStatement = 27
    RULE_oldStyleDeclarationStatement = 28
    RULE_quantumDeclarationStatement = 29
    RULE_defStatement = 30
    RULE_externStatement = 31
    RULE_gateStatement = 32
    RULE_assignmentStatement = 33
    RULE_expressionStatement = 34
    RULE_calStatement = 35
    RULE_defcalStatement = 36
    RULE_expression = 37
    RULE_aliasExpression = 38
    RULE_declarationExpression = 39
    RULE_measureExpression = 40
    RULE_rangeExpression = 41
    RULE_setExpression = 42
    RULE_arrayLiteral = 43
    RULE_indexOperator = 44
    RULE_indexedIdentifier = 45
    RULE_returnSignature = 46
    RULE_gateModifier = 47
    RULE_scalarType = 48
    RULE_qubitType = 49
    RULE_arrayType = 50
    RULE_arrayReferenceType = 51
    RULE_designator = 52
    RULE_defcalTarget = 53
    RULE_defcalArgumentDefinition = 54
    RULE_defcalOperand = 55
    RULE_gateOperand = 56
    RULE_externArgument = 57
    RULE_argumentDefinition = 58
    RULE_argumentDefinitionList = 59
    RULE_defcalArgumentDefinitionList = 60
    RULE_defcalOperandList = 61
    RULE_expressionList = 62
    RULE_identifierList = 63
    RULE_gateOperandList = 64
    RULE_externArgumentList = 65

    ruleNames =  [ "program", "version", "statement", "annotation", "scope", 
                   "pragma", "statementOrScope", "calibrationGrammarStatement", 
                   "includeStatement", "breakStatement", "continueStatement", 
                   "endStatement", "forStatement", "ifStatement", "returnStatement", 
                   "whileStatement", "switchStatement", "switchCaseItem", 
                   "barrierStatement", "boxStatement", "delayStatement", 
                   "gateCallStatement", "measureArrowAssignmentStatement", 
                   "resetStatement", "aliasDeclarationStatement", "classicalDeclarationStatement", 
                   "constDeclarationStatement", "ioDeclarationStatement", 
                   "oldStyleDeclarationStatement", "quantumDeclarationStatement", 
                   "defStatement", "externStatement", "gateStatement", "assignmentStatement", 
                   "expressionStatement", "calStatement", "defcalStatement", 
                   "expression", "aliasExpression", "declarationExpression", 
                   "measureExpression", "rangeExpression", "setExpression", 
                   "arrayLiteral", "indexOperator", "indexedIdentifier", 
                   "returnSignature", "gateModifier", "scalarType", "qubitType", 
                   "arrayType", "arrayReferenceType", "designator", "defcalTarget", 
                   "defcalArgumentDefinition", "defcalOperand", "gateOperand", 
                   "externArgument", "argumentDefinition", "argumentDefinitionList", 
                   "defcalArgumentDefinitionList", "defcalOperandList", 
                   "expressionList", "identifierList", "gateOperandList", 
                   "externArgumentList" ]

    EOF = Token.EOF
    OPENQASM=1
    INCLUDE=2
    DEFCALGRAMMAR=3
    DEF=4
    CAL=5
    DEFCAL=6
    GATE=7
    EXTERN=8
    BOX=9
    LET=10
    BREAK=11
    CONTINUE=12
    IF=13
    ELSE=14
    END=15
    RETURN=16
    FOR=17
    WHILE=18
    IN=19
    SWITCH=20
    CASE=21
    DEFAULT=22
    PRAGMA=23
    AnnotationKeyword=24
    INPUT=25
    OUTPUT=26
    CONST=27
    READONLY=28
    MUTABLE=29
    QREG=30
    QUBIT=31
    CREG=32
    BOOL=33
    BIT=34
    INT=35
    UINT=36
    FLOAT=37
    ANGLE=38
    COMPLEX=39
    ARRAY=40
    VOID=41
    DURATION=42
    STRETCH=43
    GPHASE=44
    INV=45
    POW=46
    CTRL=47
    NEGCTRL=48
    DIM=49
    DURATIONOF=50
    DELAY=51
    RESET=52
    MEASURE=53
    BARRIER=54
    BooleanLiteral=55
    LBRACKET=56
    RBRACKET=57
    LBRACE=58
    RBRACE=59
    LPAREN=60
    RPAREN=61
    COLON=62
    SEMICOLON=63
    DOT=64
    COMMA=65
    EQUALS=66
    ARROW=67
    PLUS=68
    DOUBLE_PLUS=69
    MINUS=70
    ASTERISK=71
    DOUBLE_ASTERISK=72
    SLASH=73
    PERCENT=74
    PIPE=75
    DOUBLE_PIPE=76
    AMPERSAND=77
    DOUBLE_AMPERSAND=78
    CARET=79
    AT=80
    TILDE=81
    EXCLAMATION_POINT=82
    EqualityOperator=83
    CompoundAssignmentOperator=84
    ComparisonOperator=85
    BitshiftOperator=86
    IMAG=87
    ImaginaryLiteral=88
    BinaryIntegerLiteral=89
    OctalIntegerLiteral=90
    DecimalIntegerLiteral=91
    HexIntegerLiteral=92
    Identifier=93
    HardwareQubit=94
    FloatLiteral=95
    TimingLiteral=96
    BitstringLiteral=97
    Whitespace=98
    Newline=99
    LineComment=100
    BlockComment=101
    VERSION_IDENTIFER_WHITESPACE=102
    VersionSpecifier=103
    ARBITRARY_STRING_WHITESPACE=104
    StringLiteral=105
    EAT_INITIAL_SPACE=106
    EAT_LINE_END=107
    RemainingLineContent=108
    CAL_PRELUDE_WHITESPACE=109
    CAL_PRELUDE_COMMENT=110
    DEFCAL_PRELUDE_WHITESPACE=111
    DEFCAL_PRELUDE_COMMENT=112
    CalibrationBlock=113

    def __init__(self, input:TokenStream, output:TextIO = sys.stdout):
        super().__init__(input, output)
        self.checkVersion("4.13.0")
        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 EOF(self):
            return self.getToken(qasm3Parser.EOF, 0)

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


        def statementOrScope(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(qasm3Parser.StatementOrScopeContext)
            else:
                return self.getTypedRuleContext(qasm3Parser.StatementOrScopeContext,i)


        def getRuleIndex(self):
            return qasm3Parser.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 accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitProgram" ):
                return visitor.visitProgram(self)
            else:
                return visitor.visitChildren(self)




    def program(self):

        localctx = qasm3Parser.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 = 133
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==1:
                self.state = 132
                self.version()


            self.state = 138
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while (((_la) & ~0x3f) == 0 and ((1 << _la) & 1512644325007671292) != 0) or ((((_la - 70)) & ~0x3f) == 0 and ((1 << (_la - 70)) & 268179457) != 0):
                self.state = 135
                self.statementOrScope()
                self.state = 140
                self._errHandler.sync(self)
                _la = self._input.LA(1)

            self.state = 141
            self.match(qasm3Parser.EOF)
        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 OPENQASM(self):
            return self.getToken(qasm3Parser.OPENQASM, 0)

        def VersionSpecifier(self):
            return self.getToken(qasm3Parser.VersionSpecifier, 0)

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

        def getRuleIndex(self):
            return qasm3Parser.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 accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitVersion" ):
                return visitor.visitVersion(self)
            else:
                return visitor.visitChildren(self)




    def version(self):

        localctx = qasm3Parser.VersionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 2, self.RULE_version)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 143
            self.match(qasm3Parser.OPENQASM)
            self.state = 144
            self.match(qasm3Parser.VersionSpecifier)
            self.state = 145
            self.match(qasm3Parser.SEMICOLON)
        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 pragma(self):
            return self.getTypedRuleContext(qasm3Parser.PragmaContext,0)


        def aliasDeclarationStatement(self):
            return self.getTypedRuleContext(qasm3Parser.AliasDeclarationStatementContext,0)


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


        def barrierStatement(self):
            return self.getTypedRuleContext(qasm3Parser.BarrierStatementContext,0)


        def boxStatement(self):
            return self.getTypedRuleContext(qasm3Parser.BoxStatementContext,0)


        def breakStatement(self):
            return self.getTypedRuleContext(qasm3Parser.BreakStatementContext,0)


        def calStatement(self):
            return self.getTypedRuleContext(qasm3Parser.CalStatementContext,0)


        def calibrationGrammarStatement(self):
            return self.getTypedRuleContext(qasm3Parser.CalibrationGrammarStatementContext,0)


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


        def constDeclarationStatement(self):
            return self.getTypedRuleContext(qasm3Parser.ConstDeclarationStatementContext,0)


        def continueStatement(self):
            return self.getTypedRuleContext(qasm3Parser.ContinueStatementContext,0)


        def defStatement(self):
            return self.getTypedRuleContext(qasm3Parser.DefStatementContext,0)


        def defcalStatement(self):
            return self.getTypedRuleContext(qasm3Parser.DefcalStatementContext,0)


        def delayStatement(self):
            return self.getTypedRuleContext(qasm3Parser.DelayStatementContext,0)


        def endStatement(self):
            return self.getTypedRuleContext(qasm3Parser.EndStatementContext,0)


        def expressionStatement(self):
            return self.getTypedRuleContext(qasm3Parser.ExpressionStatementContext,0)


        def externStatement(self):
            return self.getTypedRuleContext(qasm3Parser.ExternStatementContext,0)


        def forStatement(self):
            return self.getTypedRuleContext(qasm3Parser.ForStatementContext,0)


        def gateCallStatement(self):
            return self.getTypedRuleContext(qasm3Parser.GateCallStatementContext,0)


        def gateStatement(self):
            return self.getTypedRuleContext(qasm3Parser.GateStatementContext,0)


        def ifStatement(self):
            return self.getTypedRuleContext(qasm3Parser.IfStatementContext,0)


        def includeStatement(self):
            return self.getTypedRuleContext(qasm3Parser.IncludeStatementContext,0)


        def ioDeclarationStatement(self):
            return self.getTypedRuleContext(qasm3Parser.IoDeclarationStatementContext,0)


        def measureArrowAssignmentStatement(self):
            return self.getTypedRuleContext(qasm3Parser.MeasureArrowAssignmentStatementContext,0)


        def oldStyleDeclarationStatement(self):
            return self.getTypedRuleContext(qasm3Parser.OldStyleDeclarationStatementContext,0)


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


        def resetStatement(self):
            return self.getTypedRuleContext(qasm3Parser.ResetStatementContext,0)


        def returnStatement(self):
            return self.getTypedRuleContext(qasm3Parser.ReturnStatementContext,0)


        def switchStatement(self):
            return self.getTypedRuleContext(qasm3Parser.SwitchStatementContext,0)


        def whileStatement(self):
            return self.getTypedRuleContext(qasm3Parser.WhileStatementContext,0)


        def annotation(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(qasm3Parser.AnnotationContext)
            else:
                return self.getTypedRuleContext(qasm3Parser.AnnotationContext,i)


        def getRuleIndex(self):
            return qasm3Parser.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 accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitStatement" ):
                return visitor.visitStatement(self)
            else:
                return visitor.visitChildren(self)




    def statement(self):

        localctx = qasm3Parser.StatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 4, self.RULE_statement)
        self._la = 0 # Token type
        try:
            self.state = 185
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [23]:
                self.enterOuterAlt(localctx, 1)
                self.state = 147
                self.pragma()
                pass
            elif token in [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 20, 24, 25, 26, 27, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 44, 45, 46, 47, 48, 50, 51, 52, 53, 54, 55, 60, 70, 81, 82, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97]:
                self.enterOuterAlt(localctx, 2)
                self.state = 151
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while _la==24:
                    self.state = 148
                    self.annotation()
                    self.state = 153
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)

                self.state = 183
                self._errHandler.sync(self)
                la_ = self._interp.adaptivePredict(self._input,3,self._ctx)
                if la_ == 1:
                    self.state = 154
                    self.aliasDeclarationStatement()
                    pass

                elif la_ == 2:
                    self.state = 155
                    self.assignmentStatement()
                    pass

                elif la_ == 3:
                    self.state = 156
                    self.barrierStatement()
                    pass

                elif la_ == 4:
                    self.state = 157
                    self.boxStatement()
                    pass

                elif la_ == 5:
                    self.state = 158
                    self.breakStatement()
                    pass

                elif la_ == 6:
                    self.state = 159
                    self.calStatement()
                    pass

                elif la_ == 7:
                    self.state = 160
                    self.calibrationGrammarStatement()
                    pass

                elif la_ == 8:
                    self.state = 161
                    self.classicalDeclarationStatement()
                    pass

                elif la_ == 9:
                    self.state = 162
                    self.constDeclarationStatement()
                    pass

                elif la_ == 10:
                    self.state = 163
                    self.continueStatement()
                    pass

                elif la_ == 11:
                    self.state = 164
                    self.defStatement()
                    pass

                elif la_ == 12:
                    self.state = 165
                    self.defcalStatement()
                    pass

                elif la_ == 13:
                    self.state = 166
                    self.delayStatement()
                    pass

                elif la_ == 14:
                    self.state = 167
                    self.endStatement()
                    pass

                elif la_ == 15:
                    self.state = 168
                    self.expressionStatement()
                    pass

                elif la_ == 16:
                    self.state = 169
                    self.externStatement()
                    pass

                elif la_ == 17:
                    self.state = 170
                    self.forStatement()
                    pass

                elif la_ == 18:
                    self.state = 171
                    self.gateCallStatement()
                    pass

                elif la_ == 19:
                    self.state = 172
                    self.gateStatement()
                    pass

                elif la_ == 20:
                    self.state = 173
                    self.ifStatement()
                    pass

                elif la_ == 21:
                    self.state = 174
                    self.includeStatement()
                    pass

                elif la_ == 22:
                    self.state = 175
                    self.ioDeclarationStatement()
                    pass

                elif la_ == 23:
                    self.state = 176
                    self.measureArrowAssignmentStatement()
                    pass

                elif la_ == 24:
                    self.state = 177
                    self.oldStyleDeclarationStatement()
                    pass

                elif la_ == 25:
                    self.state = 178
                    self.quantumDeclarationStatement()
                    pass

                elif la_ == 26:
                    self.state = 179
                    self.resetStatement()
                    pass

                elif la_ == 27:
                    self.state = 180
                    self.returnStatement()
                    pass

                elif la_ == 28:
                    self.state = 181
                    self.switchStatement()
                    pass

                elif la_ == 29:
                    self.state = 182
                    self.whileStatement()
                    pass


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

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

        def AnnotationKeyword(self):
            return self.getToken(qasm3Parser.AnnotationKeyword, 0)

        def RemainingLineContent(self):
            return self.getToken(qasm3Parser.RemainingLineContent, 0)

        def getRuleIndex(self):
            return qasm3Parser.RULE_annotation

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

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

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




    def annotation(self):

        localctx = qasm3Parser.AnnotationContext(self, self._ctx, self.state)
        self.enterRule(localctx, 6, self.RULE_annotation)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 187
            self.match(qasm3Parser.AnnotationKeyword)
            self.state = 189
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==108:
                self.state = 188
                self.match(qasm3Parser.RemainingLineContent)


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


    class ScopeContext(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(qasm3Parser.LBRACE, 0)

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

        def statementOrScope(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(qasm3Parser.StatementOrScopeContext)
            else:
                return self.getTypedRuleContext(qasm3Parser.StatementOrScopeContext,i)


        def getRuleIndex(self):
            return qasm3Parser.RULE_scope

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

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

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




    def scope(self):

        localctx = qasm3Parser.ScopeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 8, self.RULE_scope)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 191
            self.match(qasm3Parser.LBRACE)
            self.state = 195
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while (((_la) & ~0x3f) == 0 and ((1 << _la) & 1512644325007671292) != 0) or ((((_la - 70)) & ~0x3f) == 0 and ((1 << (_la - 70)) & 268179457) != 0):
                self.state = 192
                self.statementOrScope()
                self.state = 197
                self._errHandler.sync(self)
                _la = self._input.LA(1)

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


    class PragmaContext(ParserRuleContext):
        __slots__ = 'parser'

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

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

        def RemainingLineContent(self):
            return self.getToken(qasm3Parser.RemainingLineContent, 0)

        def getRuleIndex(self):
            return qasm3Parser.RULE_pragma

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

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

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




    def pragma(self):

        localctx = qasm3Parser.PragmaContext(self, self._ctx, self.state)
        self.enterRule(localctx, 10, self.RULE_pragma)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 200
            self.match(qasm3Parser.PRAGMA)
            self.state = 201
            self.match(qasm3Parser.RemainingLineContent)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class StatementOrScopeContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def statement(self):
            return self.getTypedRuleContext(qasm3Parser.StatementContext,0)


        def scope(self):
            return self.getTypedRuleContext(qasm3Parser.ScopeContext,0)


        def getRuleIndex(self):
            return qasm3Parser.RULE_statementOrScope

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

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

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




    def statementOrScope(self):

        localctx = qasm3Parser.StatementOrScopeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 12, self.RULE_statementOrScope)
        try:
            self.state = 205
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 20, 23, 24, 25, 26, 27, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 44, 45, 46, 47, 48, 50, 51, 52, 53, 54, 55, 60, 70, 81, 82, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97]:
                self.enterOuterAlt(localctx, 1)
                self.state = 203
                self.statement()
                pass
            elif token in [58]:
                self.enterOuterAlt(localctx, 2)
                self.state = 204
                self.scope()
                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 CalibrationGrammarStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def DEFCALGRAMMAR(self):
            return self.getToken(qasm3Parser.DEFCALGRAMMAR, 0)

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

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

        def getRuleIndex(self):
            return qasm3Parser.RULE_calibrationGrammarStatement

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

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

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




    def calibrationGrammarStatement(self):

        localctx = qasm3Parser.CalibrationGrammarStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 14, self.RULE_calibrationGrammarStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 207
            self.match(qasm3Parser.DEFCALGRAMMAR)
            self.state = 208
            self.match(qasm3Parser.StringLiteral)
            self.state = 209
            self.match(qasm3Parser.SEMICOLON)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class IncludeStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

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

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

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

        def getRuleIndex(self):
            return qasm3Parser.RULE_includeStatement

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

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

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




    def includeStatement(self):

        localctx = qasm3Parser.IncludeStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 16, self.RULE_includeStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 211
            self.match(qasm3Parser.INCLUDE)
            self.state = 212
            self.match(qasm3Parser.StringLiteral)
            self.state = 213
            self.match(qasm3Parser.SEMICOLON)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class BreakStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def BREAK(self):
            return self.getToken(qasm3Parser.BREAK, 0)

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

        def getRuleIndex(self):
            return qasm3Parser.RULE_breakStatement

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

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

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




    def breakStatement(self):

        localctx = qasm3Parser.BreakStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 18, self.RULE_breakStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 215
            self.match(qasm3Parser.BREAK)
            self.state = 216
            self.match(qasm3Parser.SEMICOLON)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class ContinueStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def CONTINUE(self):
            return self.getToken(qasm3Parser.CONTINUE, 0)

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

        def getRuleIndex(self):
            return qasm3Parser.RULE_continueStatement

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

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

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




    def continueStatement(self):

        localctx = qasm3Parser.ContinueStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 20, self.RULE_continueStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 218
            self.match(qasm3Parser.CONTINUE)
            self.state = 219
            self.match(qasm3Parser.SEMICOLON)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class EndStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

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

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

        def getRuleIndex(self):
            return qasm3Parser.RULE_endStatement

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

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

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




    def endStatement(self):

        localctx = qasm3Parser.EndStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 22, self.RULE_endStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 221
            self.match(qasm3Parser.END)
            self.state = 222
            self.match(qasm3Parser.SEMICOLON)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class ForStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def FOR(self):
            return self.getToken(qasm3Parser.FOR, 0)

        def scalarType(self):
            return self.getTypedRuleContext(qasm3Parser.ScalarTypeContext,0)


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

        def IN(self):
            return self.getToken(qasm3Parser.IN, 0)

        def statementOrScope(self):
            return self.getTypedRuleContext(qasm3Parser.StatementOrScopeContext,0)


        def setExpression(self):
            return self.getTypedRuleContext(qasm3Parser.SetExpressionContext,0)


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

        def rangeExpression(self):
            return self.getTypedRuleContext(qasm3Parser.RangeExpressionContext,0)


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

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


        def getRuleIndex(self):
            return qasm3Parser.RULE_forStatement

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

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

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




    def forStatement(self):

        localctx = qasm3Parser.ForStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 24, self.RULE_forStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 224
            self.match(qasm3Parser.FOR)
            self.state = 225
            self.scalarType()
            self.state = 226
            self.match(qasm3Parser.Identifier)
            self.state = 227
            self.match(qasm3Parser.IN)
            self.state = 234
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [58]:
                self.state = 228
                self.setExpression()
                pass
            elif token in [56]:
                self.state = 229
                self.match(qasm3Parser.LBRACKET)
                self.state = 230
                self.rangeExpression()
                self.state = 231
                self.match(qasm3Parser.RBRACKET)
                pass
            elif token in [33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 50, 55, 60, 70, 81, 82, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97]:
                self.state = 233
                self.expression(0)
                pass
            else:
                raise NoViableAltException(self)

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


    class IfStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

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

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

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


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

        def statementOrScope(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(qasm3Parser.StatementOrScopeContext)
            else:
                return self.getTypedRuleContext(qasm3Parser.StatementOrScopeContext,i)


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

        def getRuleIndex(self):
            return qasm3Parser.RULE_ifStatement

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

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

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




    def ifStatement(self):

        localctx = qasm3Parser.IfStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 26, self.RULE_ifStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 238
            self.match(qasm3Parser.IF)
            self.state = 239
            self.match(qasm3Parser.LPAREN)
            self.state = 240
            self.expression(0)
            self.state = 241
            self.match(qasm3Parser.RPAREN)
            self.state = 242
            localctx.if_body = self.statementOrScope()
            self.state = 245
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,9,self._ctx)
            if la_ == 1:
                self.state = 243
                self.match(qasm3Parser.ELSE)
                self.state = 244
                localctx.else_body = self.statementOrScope()


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


    class ReturnStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def RETURN(self):
            return self.getToken(qasm3Parser.RETURN, 0)

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

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


        def measureExpression(self):
            return self.getTypedRuleContext(qasm3Parser.MeasureExpressionContext,0)


        def getRuleIndex(self):
            return qasm3Parser.RULE_returnStatement

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

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

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




    def returnStatement(self):

        localctx = qasm3Parser.ReturnStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 28, self.RULE_returnStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 247
            self.match(qasm3Parser.RETURN)
            self.state = 250
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 50, 55, 60, 70, 81, 82, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97]:
                self.state = 248
                self.expression(0)
                pass
            elif token in [53]:
                self.state = 249
                self.measureExpression()
                pass
            elif token in [63]:
                pass
            else:
                pass
            self.state = 252
            self.match(qasm3Parser.SEMICOLON)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class WhileStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def WHILE(self):
            return self.getToken(qasm3Parser.WHILE, 0)

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

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


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

        def statementOrScope(self):
            return self.getTypedRuleContext(qasm3Parser.StatementOrScopeContext,0)


        def getRuleIndex(self):
            return qasm3Parser.RULE_whileStatement

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

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

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




    def whileStatement(self):

        localctx = qasm3Parser.WhileStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 30, self.RULE_whileStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 254
            self.match(qasm3Parser.WHILE)
            self.state = 255
            self.match(qasm3Parser.LPAREN)
            self.state = 256
            self.expression(0)
            self.state = 257
            self.match(qasm3Parser.RPAREN)
            self.state = 258
            localctx.body = self.statementOrScope()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class SwitchStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def SWITCH(self):
            return self.getToken(qasm3Parser.SWITCH, 0)

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

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


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

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

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

        def switchCaseItem(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(qasm3Parser.SwitchCaseItemContext)
            else:
                return self.getTypedRuleContext(qasm3Parser.SwitchCaseItemContext,i)


        def getRuleIndex(self):
            return qasm3Parser.RULE_switchStatement

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

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

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




    def switchStatement(self):

        localctx = qasm3Parser.SwitchStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 32, self.RULE_switchStatement)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 260
            self.match(qasm3Parser.SWITCH)
            self.state = 261
            self.match(qasm3Parser.LPAREN)
            self.state = 262
            self.expression(0)
            self.state = 263
            self.match(qasm3Parser.RPAREN)
            self.state = 264
            self.match(qasm3Parser.LBRACE)
            self.state = 268
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==21 or _la==22:
                self.state = 265
                self.switchCaseItem()
                self.state = 270
                self._errHandler.sync(self)
                _la = self._input.LA(1)

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


    class SwitchCaseItemContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def CASE(self):
            return self.getToken(qasm3Parser.CASE, 0)

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


        def scope(self):
            return self.getTypedRuleContext(qasm3Parser.ScopeContext,0)


        def DEFAULT(self):
            return self.getToken(qasm3Parser.DEFAULT, 0)

        def getRuleIndex(self):
            return qasm3Parser.RULE_switchCaseItem

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

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

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




    def switchCaseItem(self):

        localctx = qasm3Parser.SwitchCaseItemContext(self, self._ctx, self.state)
        self.enterRule(localctx, 34, self.RULE_switchCaseItem)
        try:
            self.state = 279
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [21]:
                self.enterOuterAlt(localctx, 1)
                self.state = 273
                self.match(qasm3Parser.CASE)
                self.state = 274
                self.expressionList()
                self.state = 275
                self.scope()
                pass
            elif token in [22]:
                self.enterOuterAlt(localctx, 2)
                self.state = 277
                self.match(qasm3Parser.DEFAULT)
                self.state = 278
                self.scope()
                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 BarrierStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def BARRIER(self):
            return self.getToken(qasm3Parser.BARRIER, 0)

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

        def gateOperandList(self):
            return self.getTypedRuleContext(qasm3Parser.GateOperandListContext,0)


        def getRuleIndex(self):
            return qasm3Parser.RULE_barrierStatement

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

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

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




    def barrierStatement(self):

        localctx = qasm3Parser.BarrierStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 36, self.RULE_barrierStatement)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 281
            self.match(qasm3Parser.BARRIER)
            self.state = 283
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==93 or _la==94:
                self.state = 282
                self.gateOperandList()


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


    class BoxStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def BOX(self):
            return self.getToken(qasm3Parser.BOX, 0)

        def scope(self):
            return self.getTypedRuleContext(qasm3Parser.ScopeContext,0)


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


        def getRuleIndex(self):
            return qasm3Parser.RULE_boxStatement

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

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

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




    def boxStatement(self):

        localctx = qasm3Parser.BoxStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 38, self.RULE_boxStatement)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 287
            self.match(qasm3Parser.BOX)
            self.state = 289
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==56:
                self.state = 288
                self.designator()


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


    class DelayStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def DELAY(self):
            return self.getToken(qasm3Parser.DELAY, 0)

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


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

        def gateOperandList(self):
            return self.getTypedRuleContext(qasm3Parser.GateOperandListContext,0)


        def getRuleIndex(self):
            return qasm3Parser.RULE_delayStatement

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

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

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




    def delayStatement(self):

        localctx = qasm3Parser.DelayStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 40, self.RULE_delayStatement)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 293
            self.match(qasm3Parser.DELAY)
            self.state = 294
            self.designator()
            self.state = 296
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==93 or _la==94:
                self.state = 295
                self.gateOperandList()


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


    class GateCallStatementContext(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(qasm3Parser.Identifier, 0)

        def gateOperandList(self):
            return self.getTypedRuleContext(qasm3Parser.GateOperandListContext,0)


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

        def gateModifier(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(qasm3Parser.GateModifierContext)
            else:
                return self.getTypedRuleContext(qasm3Parser.GateModifierContext,i)


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

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

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


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


        def GPHASE(self):
            return self.getToken(qasm3Parser.GPHASE, 0)

        def getRuleIndex(self):
            return qasm3Parser.RULE_gateCallStatement

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

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

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




    def gateCallStatement(self):

        localctx = qasm3Parser.GateCallStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 42, self.RULE_gateCallStatement)
        self._la = 0 # Token type
        try:
            self.state = 341
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,25,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 303
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while (((_la) & ~0x3f) == 0 and ((1 << _la) & 527765581332480) != 0):
                    self.state = 300
                    self.gateModifier()
                    self.state = 305
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)

                self.state = 306
                self.match(qasm3Parser.Identifier)
                self.state = 312
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==60:
                    self.state = 307
                    self.match(qasm3Parser.LPAREN)
                    self.state = 309
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)
                    if (((_la) & ~0x3f) == 0 and ((1 << _la) & 1190091586105507840) != 0) or ((((_la - 70)) & ~0x3f) == 0 and ((1 << (_la - 70)) & 268179457) != 0):
                        self.state = 308
                        self.expressionList()


                    self.state = 311
                    self.match(qasm3Parser.RPAREN)


                self.state = 315
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==56:
                    self.state = 314
                    self.designator()


                self.state = 317
                self.gateOperandList()
                self.state = 318
                self.match(qasm3Parser.SEMICOLON)
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 323
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while (((_la) & ~0x3f) == 0 and ((1 << _la) & 527765581332480) != 0):
                    self.state = 320
                    self.gateModifier()
                    self.state = 325
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)

                self.state = 326
                self.match(qasm3Parser.GPHASE)
                self.state = 332
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==60:
                    self.state = 327
                    self.match(qasm3Parser.LPAREN)
                    self.state = 329
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)
                    if (((_la) & ~0x3f) == 0 and ((1 << _la) & 1190091586105507840) != 0) or ((((_la - 70)) & ~0x3f) == 0 and ((1 << (_la - 70)) & 268179457) != 0):
                        self.state = 328
                        self.expressionList()


                    self.state = 331
                    self.match(qasm3Parser.RPAREN)


                self.state = 335
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==56:
                    self.state = 334
                    self.designator()


                self.state = 338
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==93 or _la==94:
                    self.state = 337
                    self.gateOperandList()


                self.state = 340
                self.match(qasm3Parser.SEMICOLON)
                pass


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


    class MeasureArrowAssignmentStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def measureExpression(self):
            return self.getTypedRuleContext(qasm3Parser.MeasureExpressionContext,0)


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

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

        def indexedIdentifier(self):
            return self.getTypedRuleContext(qasm3Parser.IndexedIdentifierContext,0)


        def getRuleIndex(self):
            return qasm3Parser.RULE_measureArrowAssignmentStatement

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

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

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




    def measureArrowAssignmentStatement(self):

        localctx = qasm3Parser.MeasureArrowAssignmentStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 44, self.RULE_measureArrowAssignmentStatement)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 343
            self.measureExpression()
            self.state = 346
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==67:
                self.state = 344
                self.match(qasm3Parser.ARROW)
                self.state = 345
                self.indexedIdentifier()


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


    class ResetStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

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

        def gateOperand(self):
            return self.getTypedRuleContext(qasm3Parser.GateOperandContext,0)


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

        def getRuleIndex(self):
            return qasm3Parser.RULE_resetStatement

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

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

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




    def resetStatement(self):

        localctx = qasm3Parser.ResetStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 46, self.RULE_resetStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 350
            self.match(qasm3Parser.RESET)
            self.state = 351
            self.gateOperand()
            self.state = 352
            self.match(qasm3Parser.SEMICOLON)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class AliasDeclarationStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def LET(self):
            return self.getToken(qasm3Parser.LET, 0)

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

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

        def aliasExpression(self):
            return self.getTypedRuleContext(qasm3Parser.AliasExpressionContext,0)


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

        def getRuleIndex(self):
            return qasm3Parser.RULE_aliasDeclarationStatement

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

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

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




    def aliasDeclarationStatement(self):

        localctx = qasm3Parser.AliasDeclarationStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 48, self.RULE_aliasDeclarationStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 354
            self.match(qasm3Parser.LET)
            self.state = 355
            self.match(qasm3Parser.Identifier)
            self.state = 356
            self.match(qasm3Parser.EQUALS)
            self.state = 357
            self.aliasExpression()
            self.state = 358
            self.match(qasm3Parser.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 Identifier(self):
            return self.getToken(qasm3Parser.Identifier, 0)

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

        def scalarType(self):
            return self.getTypedRuleContext(qasm3Parser.ScalarTypeContext,0)


        def arrayType(self):
            return self.getTypedRuleContext(qasm3Parser.ArrayTypeContext,0)


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

        def declarationExpression(self):
            return self.getTypedRuleContext(qasm3Parser.DeclarationExpressionContext,0)


        def getRuleIndex(self):
            return qasm3Parser.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 accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitClassicalDeclarationStatement" ):
                return visitor.visitClassicalDeclarationStatement(self)
            else:
                return visitor.visitChildren(self)




    def classicalDeclarationStatement(self):

        localctx = qasm3Parser.ClassicalDeclarationStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 50, self.RULE_classicalDeclarationStatement)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 362
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [33, 34, 35, 36, 37, 38, 39, 42, 43]:
                self.state = 360
                self.scalarType()
                pass
            elif token in [40]:
                self.state = 361
                self.arrayType()
                pass
            else:
                raise NoViableAltException(self)

            self.state = 364
            self.match(qasm3Parser.Identifier)
            self.state = 367
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==66:
                self.state = 365
                self.match(qasm3Parser.EQUALS)
                self.state = 366
                self.declarationExpression()


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


    class ConstDeclarationStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def CONST(self):
            return self.getToken(qasm3Parser.CONST, 0)

        def scalarType(self):
            return self.getTypedRuleContext(qasm3Parser.ScalarTypeContext,0)


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

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

        def declarationExpression(self):
            return self.getTypedRuleContext(qasm3Parser.DeclarationExpressionContext,0)


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

        def getRuleIndex(self):
            return qasm3Parser.RULE_constDeclarationStatement

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

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

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




    def constDeclarationStatement(self):

        localctx = qasm3Parser.ConstDeclarationStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 52, self.RULE_constDeclarationStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 371
            self.match(qasm3Parser.CONST)
            self.state = 372
            self.scalarType()
            self.state = 373
            self.match(qasm3Parser.Identifier)
            self.state = 374
            self.match(qasm3Parser.EQUALS)
            self.state = 375
            self.declarationExpression()
            self.state = 376
            self.match(qasm3Parser.SEMICOLON)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class IoDeclarationStatementContext(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(qasm3Parser.Identifier, 0)

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

        def INPUT(self):
            return self.getToken(qasm3Parser.INPUT, 0)

        def OUTPUT(self):
            return self.getToken(qasm3Parser.OUTPUT, 0)

        def scalarType(self):
            return self.getTypedRuleContext(qasm3Parser.ScalarTypeContext,0)


        def arrayType(self):
            return self.getTypedRuleContext(qasm3Parser.ArrayTypeContext,0)


        def getRuleIndex(self):
            return qasm3Parser.RULE_ioDeclarationStatement

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

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

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




    def ioDeclarationStatement(self):

        localctx = qasm3Parser.IoDeclarationStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 54, self.RULE_ioDeclarationStatement)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 378
            _la = self._input.LA(1)
            if not(_la==25 or _la==26):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
            self.state = 381
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [33, 34, 35, 36, 37, 38, 39, 42, 43]:
                self.state = 379
                self.scalarType()
                pass
            elif token in [40]:
                self.state = 380
                self.arrayType()
                pass
            else:
                raise NoViableAltException(self)

            self.state = 383
            self.match(qasm3Parser.Identifier)
            self.state = 384
            self.match(qasm3Parser.SEMICOLON)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class OldStyleDeclarationStatementContext(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(qasm3Parser.Identifier, 0)

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

        def CREG(self):
            return self.getToken(qasm3Parser.CREG, 0)

        def QREG(self):
            return self.getToken(qasm3Parser.QREG, 0)

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


        def getRuleIndex(self):
            return qasm3Parser.RULE_oldStyleDeclarationStatement

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

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

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




    def oldStyleDeclarationStatement(self):

        localctx = qasm3Parser.OldStyleDeclarationStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 56, self.RULE_oldStyleDeclarationStatement)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 386
            _la = self._input.LA(1)
            if not(_la==30 or _la==32):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
            self.state = 387
            self.match(qasm3Parser.Identifier)
            self.state = 389
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==56:
                self.state = 388
                self.designator()


            self.state = 391
            self.match(qasm3Parser.SEMICOLON)
        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 qubitType(self):
            return self.getTypedRuleContext(qasm3Parser.QubitTypeContext,0)


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

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

        def getRuleIndex(self):
            return qasm3Parser.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 accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitQuantumDeclarationStatement" ):
                return visitor.visitQuantumDeclarationStatement(self)
            else:
                return visitor.visitChildren(self)




    def quantumDeclarationStatement(self):

        localctx = qasm3Parser.QuantumDeclarationStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 58, self.RULE_quantumDeclarationStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 393
            self.qubitType()
            self.state = 394
            self.match(qasm3Parser.Identifier)
            self.state = 395
            self.match(qasm3Parser.SEMICOLON)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class DefStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def DEF(self):
            return self.getToken(qasm3Parser.DEF, 0)

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

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

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

        def scope(self):
            return self.getTypedRuleContext(qasm3Parser.ScopeContext,0)


        def argumentDefinitionList(self):
            return self.getTypedRuleContext(qasm3Parser.ArgumentDefinitionListContext,0)


        def returnSignature(self):
            return self.getTypedRuleContext(qasm3Parser.ReturnSignatureContext,0)


        def getRuleIndex(self):
            return qasm3Parser.RULE_defStatement

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

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

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




    def defStatement(self):

        localctx = qasm3Parser.DefStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 60, self.RULE_defStatement)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 397
            self.match(qasm3Parser.DEF)
            self.state = 398
            self.match(qasm3Parser.Identifier)
            self.state = 399
            self.match(qasm3Parser.LPAREN)
            self.state = 401
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if (((_la) & ~0x3f) == 0 and ((1 << _la) & 14293382725632) != 0):
                self.state = 400
                self.argumentDefinitionList()


            self.state = 403
            self.match(qasm3Parser.RPAREN)
            self.state = 405
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==67:
                self.state = 404
                self.returnSignature()


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


    class ExternStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def EXTERN(self):
            return self.getToken(qasm3Parser.EXTERN, 0)

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

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

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

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

        def externArgumentList(self):
            return self.getTypedRuleContext(qasm3Parser.ExternArgumentListContext,0)


        def returnSignature(self):
            return self.getTypedRuleContext(qasm3Parser.ReturnSignatureContext,0)


        def getRuleIndex(self):
            return qasm3Parser.RULE_externStatement

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

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

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




    def externStatement(self):

        localctx = qasm3Parser.ExternStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 62, self.RULE_externStatement)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 409
            self.match(qasm3Parser.EXTERN)
            self.state = 410
            self.match(qasm3Parser.Identifier)
            self.state = 411
            self.match(qasm3Parser.LPAREN)
            self.state = 413
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if (((_la) & ~0x3f) == 0 and ((1 << _la) & 14290161500160) != 0):
                self.state = 412
                self.externArgumentList()


            self.state = 415
            self.match(qasm3Parser.RPAREN)
            self.state = 417
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==67:
                self.state = 416
                self.returnSignature()


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


    class GateStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def GATE(self):
            return self.getToken(qasm3Parser.GATE, 0)

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

        def scope(self):
            return self.getTypedRuleContext(qasm3Parser.ScopeContext,0)


        def identifierList(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(qasm3Parser.IdentifierListContext)
            else:
                return self.getTypedRuleContext(qasm3Parser.IdentifierListContext,i)


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

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

        def getRuleIndex(self):
            return qasm3Parser.RULE_gateStatement

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

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

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




    def gateStatement(self):

        localctx = qasm3Parser.GateStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 64, self.RULE_gateStatement)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 421
            self.match(qasm3Parser.GATE)
            self.state = 422
            self.match(qasm3Parser.Identifier)
            self.state = 428
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==60:
                self.state = 423
                self.match(qasm3Parser.LPAREN)
                self.state = 425
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==93:
                    self.state = 424
                    localctx.params = self.identifierList()


                self.state = 427
                self.match(qasm3Parser.RPAREN)


            self.state = 430
            localctx.qubits = self.identifierList()
            self.state = 431
            self.scope()
        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
            self.op = None # Token

        def indexedIdentifier(self):
            return self.getTypedRuleContext(qasm3Parser.IndexedIdentifierContext,0)


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

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

        def CompoundAssignmentOperator(self):
            return self.getToken(qasm3Parser.CompoundAssignmentOperator, 0)

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


        def measureExpression(self):
            return self.getTypedRuleContext(qasm3Parser.MeasureExpressionContext,0)


        def getRuleIndex(self):
            return qasm3Parser.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 accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitAssignmentStatement" ):
                return visitor.visitAssignmentStatement(self)
            else:
                return visitor.visitChildren(self)




    def assignmentStatement(self):

        localctx = qasm3Parser.AssignmentStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 66, self.RULE_assignmentStatement)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 433
            self.indexedIdentifier()
            self.state = 434
            localctx.op = self._input.LT(1)
            _la = self._input.LA(1)
            if not(_la==66 or _la==84):
                localctx.op = self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
            self.state = 437
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 50, 55, 60, 70, 81, 82, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97]:
                self.state = 435
                self.expression(0)
                pass
            elif token in [53]:
                self.state = 436
                self.measureExpression()
                pass
            else:
                raise NoViableAltException(self)

            self.state = 439
            self.match(qasm3Parser.SEMICOLON)
        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(qasm3Parser.ExpressionContext,0)


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

        def getRuleIndex(self):
            return qasm3Parser.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 accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExpressionStatement" ):
                return visitor.visitExpressionStatement(self)
            else:
                return visitor.visitChildren(self)




    def expressionStatement(self):

        localctx = qasm3Parser.ExpressionStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 68, self.RULE_expressionStatement)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 441
            self.expression(0)
            self.state = 442
            self.match(qasm3Parser.SEMICOLON)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class CalStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def CAL(self):
            return self.getToken(qasm3Parser.CAL, 0)

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

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

        def CalibrationBlock(self):
            return self.getToken(qasm3Parser.CalibrationBlock, 0)

        def getRuleIndex(self):
            return qasm3Parser.RULE_calStatement

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

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

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




    def calStatement(self):

        localctx = qasm3Parser.CalStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 70, self.RULE_calStatement)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 444
            self.match(qasm3Parser.CAL)
            self.state = 445
            self.match(qasm3Parser.LBRACE)
            self.state = 447
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==113:
                self.state = 446
                self.match(qasm3Parser.CalibrationBlock)


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


    class DefcalStatementContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def DEFCAL(self):
            return self.getToken(qasm3Parser.DEFCAL, 0)

        def defcalTarget(self):
            return self.getTypedRuleContext(qasm3Parser.DefcalTargetContext,0)


        def defcalOperandList(self):
            return self.getTypedRuleContext(qasm3Parser.DefcalOperandListContext,0)


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

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

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

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

        def returnSignature(self):
            return self.getTypedRuleContext(qasm3Parser.ReturnSignatureContext,0)


        def CalibrationBlock(self):
            return self.getToken(qasm3Parser.CalibrationBlock, 0)

        def defcalArgumentDefinitionList(self):
            return self.getTypedRuleContext(qasm3Parser.DefcalArgumentDefinitionListContext,0)


        def getRuleIndex(self):
            return qasm3Parser.RULE_defcalStatement

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

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

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




    def defcalStatement(self):

        localctx = qasm3Parser.DefcalStatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 72, self.RULE_defcalStatement)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 451
            self.match(qasm3Parser.DEFCAL)
            self.state = 452
            self.defcalTarget()
            self.state = 458
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==60:
                self.state = 453
                self.match(qasm3Parser.LPAREN)
                self.state = 455
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if (((_la) & ~0x3f) == 0 and ((1 << _la) & 1190091594427006976) != 0) or ((((_la - 70)) & ~0x3f) == 0 and ((1 << (_la - 70)) & 268179457) != 0):
                    self.state = 454
                    self.defcalArgumentDefinitionList()


                self.state = 457
                self.match(qasm3Parser.RPAREN)


            self.state = 460
            self.defcalOperandList()
            self.state = 462
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==67:
                self.state = 461
                self.returnSignature()


            self.state = 464
            self.match(qasm3Parser.LBRACE)
            self.state = 466
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==113:
                self.state = 465
                self.match(qasm3Parser.CalibrationBlock)


            self.state = 468
            self.match(qasm3Parser.RBRACE)
        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 getRuleIndex(self):
            return qasm3Parser.RULE_expression

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


    class BitwiseXorExpressionContext(ExpressionContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a qasm3Parser.ExpressionContext
            super().__init__(parser)
            self.op = None # Token
            self.copyFrom(ctx)

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

        def CARET(self):
            return self.getToken(qasm3Parser.CARET, 0)

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

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

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


    class AdditiveExpressionContext(ExpressionContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a qasm3Parser.ExpressionContext
            super().__init__(parser)
            self.op = None # Token
            self.copyFrom(ctx)

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

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

        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 accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitAdditiveExpression" ):
                return visitor.visitAdditiveExpression(self)
            else:
                return visitor.visitChildren(self)


    class DurationofExpressionContext(ExpressionContext):

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

        def DURATIONOF(self):
            return self.getToken(qasm3Parser.DURATIONOF, 0)
        def LPAREN(self):
            return self.getToken(qasm3Parser.LPAREN, 0)
        def scope(self):
            return self.getTypedRuleContext(qasm3Parser.ScopeContext,0)

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

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

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

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


    class ParenthesisExpressionContext(ExpressionContext):

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

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

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

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

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

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


    class ComparisonExpressionContext(ExpressionContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a qasm3Parser.ExpressionContext
            super().__init__(parser)
            self.op = None # Token
            self.copyFrom(ctx)

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

        def ComparisonOperator(self):
            return self.getToken(qasm3Parser.ComparisonOperator, 0)

        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 accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitComparisonExpression" ):
                return visitor.visitComparisonExpression(self)
            else:
                return visitor.visitChildren(self)


    class MultiplicativeExpressionContext(ExpressionContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a qasm3Parser.ExpressionContext
            super().__init__(parser)
            self.op = None # Token
            self.copyFrom(ctx)

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

        def ASTERISK(self):
            return self.getToken(qasm3Parser.ASTERISK, 0)
        def SLASH(self):
            return self.getToken(qasm3Parser.SLASH, 0)
        def PERCENT(self):
            return self.getToken(qasm3Parser.PERCENT, 0)

        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 accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitMultiplicativeExpression" ):
                return visitor.visitMultiplicativeExpression(self)
            else:
                return visitor.visitChildren(self)


    class LogicalOrExpressionContext(ExpressionContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a qasm3Parser.ExpressionContext
            super().__init__(parser)
            self.op = None # Token
            self.copyFrom(ctx)

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

        def DOUBLE_PIPE(self):
            return self.getToken(qasm3Parser.DOUBLE_PIPE, 0)

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

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

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


    class CastExpressionContext(ExpressionContext):

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

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

        def RPAREN(self):
            return self.getToken(qasm3Parser.RPAREN, 0)
        def scalarType(self):
            return self.getTypedRuleContext(qasm3Parser.ScalarTypeContext,0)

        def arrayType(self):
            return self.getTypedRuleContext(qasm3Parser.ArrayTypeContext,0)


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

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

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


    class PowerExpressionContext(ExpressionContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a qasm3Parser.ExpressionContext
            super().__init__(parser)
            self.op = None # Token
            self.copyFrom(ctx)

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

        def DOUBLE_ASTERISK(self):
            return self.getToken(qasm3Parser.DOUBLE_ASTERISK, 0)

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

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

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


    class BitwiseOrExpressionContext(ExpressionContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a qasm3Parser.ExpressionContext
            super().__init__(parser)
            self.op = None # Token
            self.copyFrom(ctx)

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

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

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

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

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


    class CallExpressionContext(ExpressionContext):

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

        def Identifier(self):
            return self.getToken(qasm3Parser.Identifier, 0)
        def LPAREN(self):
            return self.getToken(qasm3Parser.LPAREN, 0)
        def RPAREN(self):
            return self.getToken(qasm3Parser.RPAREN, 0)
        def expressionList(self):
            return self.getTypedRuleContext(qasm3Parser.ExpressionListContext,0)


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

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

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


    class BitshiftExpressionContext(ExpressionContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a qasm3Parser.ExpressionContext
            super().__init__(parser)
            self.op = None # Token
            self.copyFrom(ctx)

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

        def BitshiftOperator(self):
            return self.getToken(qasm3Parser.BitshiftOperator, 0)

        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 accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitBitshiftExpression" ):
                return visitor.visitBitshiftExpression(self)
            else:
                return visitor.visitChildren(self)


    class BitwiseAndExpressionContext(ExpressionContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a qasm3Parser.ExpressionContext
            super().__init__(parser)
            self.op = None # Token
            self.copyFrom(ctx)

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

        def AMPERSAND(self):
            return self.getToken(qasm3Parser.AMPERSAND, 0)

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

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

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


    class EqualityExpressionContext(ExpressionContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a qasm3Parser.ExpressionContext
            super().__init__(parser)
            self.op = None # Token
            self.copyFrom(ctx)

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

        def EqualityOperator(self):
            return self.getToken(qasm3Parser.EqualityOperator, 0)

        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 accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitEqualityExpression" ):
                return visitor.visitEqualityExpression(self)
            else:
                return visitor.visitChildren(self)


    class LogicalAndExpressionContext(ExpressionContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a qasm3Parser.ExpressionContext
            super().__init__(parser)
            self.op = None # Token
            self.copyFrom(ctx)

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

        def DOUBLE_AMPERSAND(self):
            return self.getToken(qasm3Parser.DOUBLE_AMPERSAND, 0)

        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 accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitLogicalAndExpression" ):
                return visitor.visitLogicalAndExpression(self)
            else:
                return visitor.visitChildren(self)


    class IndexExpressionContext(ExpressionContext):

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

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

        def indexOperator(self):
            return self.getTypedRuleContext(qasm3Parser.IndexOperatorContext,0)


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

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

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


    class UnaryExpressionContext(ExpressionContext):

        def __init__(self, parser, ctx:ParserRuleContext): # actually a qasm3Parser.ExpressionContext
            super().__init__(parser)
            self.op = None # Token
            self.copyFrom(ctx)

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

        def TILDE(self):
            return self.getToken(qasm3Parser.TILDE, 0)
        def EXCLAMATION_POINT(self):
            return self.getToken(qasm3Parser.EXCLAMATION_POINT, 0)
        def MINUS(self):
            return self.getToken(qasm3Parser.MINUS, 0)

        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 accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitUnaryExpression" ):
                return visitor.visitUnaryExpression(self)
            else:
                return visitor.visitChildren(self)


    class LiteralExpressionContext(ExpressionContext):

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

        def Identifier(self):
            return self.getToken(qasm3Parser.Identifier, 0)
        def BinaryIntegerLiteral(self):
            return self.getToken(qasm3Parser.BinaryIntegerLiteral, 0)
        def OctalIntegerLiteral(self):
            return self.getToken(qasm3Parser.OctalIntegerLiteral, 0)
        def DecimalIntegerLiteral(self):
            return self.getToken(qasm3Parser.DecimalIntegerLiteral, 0)
        def HexIntegerLiteral(self):
            return self.getToken(qasm3Parser.HexIntegerLiteral, 0)
        def FloatLiteral(self):
            return self.getToken(qasm3Parser.FloatLiteral, 0)
        def ImaginaryLiteral(self):
            return self.getToken(qasm3Parser.ImaginaryLiteral, 0)
        def BooleanLiteral(self):
            return self.getToken(qasm3Parser.BooleanLiteral, 0)
        def BitstringLiteral(self):
            return self.getToken(qasm3Parser.BitstringLiteral, 0)
        def TimingLiteral(self):
            return self.getToken(qasm3Parser.TimingLiteral, 0)
        def HardwareQubit(self):
            return self.getToken(qasm3Parser.HardwareQubit, 0)

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

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

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



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

                self.state = 471
                self.match(qasm3Parser.LPAREN)
                self.state = 472
                self.expression(0)
                self.state = 473
                self.match(qasm3Parser.RPAREN)
                pass

            elif la_ == 2:
                localctx = qasm3Parser.UnaryExpressionContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 475
                localctx.op = self._input.LT(1)
                _la = self._input.LA(1)
                if not(((((_la - 70)) & ~0x3f) == 0 and ((1 << (_la - 70)) & 6145) != 0)):
                    localctx.op = self._errHandler.recoverInline(self)
                else:
                    self._errHandler.reportMatch(self)
                    self.consume()
                self.state = 476
                self.expression(15)
                pass

            elif la_ == 3:
                localctx = qasm3Parser.CastExpressionContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 479
                self._errHandler.sync(self)
                token = self._input.LA(1)
                if token in [33, 34, 35, 36, 37, 38, 39, 42, 43]:
                    self.state = 477
                    self.scalarType()
                    pass
                elif token in [40]:
                    self.state = 478
                    self.arrayType()
                    pass
                else:
                    raise NoViableAltException(self)

                self.state = 481
                self.match(qasm3Parser.LPAREN)
                self.state = 482
                self.expression(0)
                self.state = 483
                self.match(qasm3Parser.RPAREN)
                pass

            elif la_ == 4:
                localctx = qasm3Parser.DurationofExpressionContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 485
                self.match(qasm3Parser.DURATIONOF)
                self.state = 486
                self.match(qasm3Parser.LPAREN)
                self.state = 487
                self.scope()
                self.state = 488
                self.match(qasm3Parser.RPAREN)
                pass

            elif la_ == 5:
                localctx = qasm3Parser.CallExpressionContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 490
                self.match(qasm3Parser.Identifier)
                self.state = 491
                self.match(qasm3Parser.LPAREN)
                self.state = 493
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if (((_la) & ~0x3f) == 0 and ((1 << _la) & 1190091586105507840) != 0) or ((((_la - 70)) & ~0x3f) == 0 and ((1 << (_la - 70)) & 268179457) != 0):
                    self.state = 492
                    self.expressionList()


                self.state = 495
                self.match(qasm3Parser.RPAREN)
                pass

            elif la_ == 6:
                localctx = qasm3Parser.LiteralExpressionContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 496
                _la = self._input.LA(1)
                if not(((((_la - 55)) & ~0x3f) == 0 and ((1 << (_la - 55)) & 8787503087617) != 0)):
                    self._errHandler.recoverInline(self)
                else:
                    self._errHandler.reportMatch(self)
                    self.consume()
                pass


            self._ctx.stop = self._input.LT(-1)
            self.state = 536
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,47,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    if self._parseListeners is not None:
                        self.triggerExitRuleEvent()
                    _prevctx = localctx
                    self.state = 534
                    self._errHandler.sync(self)
                    la_ = self._interp.adaptivePredict(self._input,46,self._ctx)
                    if la_ == 1:
                        localctx = qasm3Parser.PowerExpressionContext(self, qasm3Parser.ExpressionContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expression)
                        self.state = 499
                        if not self.precpred(self._ctx, 16):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 16)")
                        self.state = 500
                        localctx.op = self.match(qasm3Parser.DOUBLE_ASTERISK)
                        self.state = 501
                        self.expression(16)
                        pass

                    elif la_ == 2:
                        localctx = qasm3Parser.MultiplicativeExpressionContext(self, qasm3Parser.ExpressionContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expression)
                        self.state = 502
                        if not self.precpred(self._ctx, 14):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 14)")
                        self.state = 503
                        localctx.op = self._input.LT(1)
                        _la = self._input.LA(1)
                        if not(((((_la - 71)) & ~0x3f) == 0 and ((1 << (_la - 71)) & 13) != 0)):
                            localctx.op = self._errHandler.recoverInline(self)
                        else:
                            self._errHandler.reportMatch(self)
                            self.consume()
                        self.state = 504
                        self.expression(15)
                        pass

                    elif la_ == 3:
                        localctx = qasm3Parser.AdditiveExpressionContext(self, qasm3Parser.ExpressionContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expression)
                        self.state = 505
                        if not self.precpred(self._ctx, 13):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 13)")
                        self.state = 506
                        localctx.op = self._input.LT(1)
                        _la = self._input.LA(1)
                        if not(_la==68 or _la==70):
                            localctx.op = self._errHandler.recoverInline(self)
                        else:
                            self._errHandler.reportMatch(self)
                            self.consume()
                        self.state = 507
                        self.expression(14)
                        pass

                    elif la_ == 4:
                        localctx = qasm3Parser.BitshiftExpressionContext(self, qasm3Parser.ExpressionContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expression)
                        self.state = 508
                        if not self.precpred(self._ctx, 12):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 12)")
                        self.state = 509
                        localctx.op = self.match(qasm3Parser.BitshiftOperator)
                        self.state = 510
                        self.expression(13)
                        pass

                    elif la_ == 5:
                        localctx = qasm3Parser.ComparisonExpressionContext(self, qasm3Parser.ExpressionContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expression)
                        self.state = 511
                        if not self.precpred(self._ctx, 11):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 11)")
                        self.state = 512
                        localctx.op = self.match(qasm3Parser.ComparisonOperator)
                        self.state = 513
                        self.expression(12)
                        pass

                    elif la_ == 6:
                        localctx = qasm3Parser.EqualityExpressionContext(self, qasm3Parser.ExpressionContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expression)
                        self.state = 514
                        if not self.precpred(self._ctx, 10):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 10)")
                        self.state = 515
                        localctx.op = self.match(qasm3Parser.EqualityOperator)
                        self.state = 516
                        self.expression(11)
                        pass

                    elif la_ == 7:
                        localctx = qasm3Parser.BitwiseAndExpressionContext(self, qasm3Parser.ExpressionContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expression)
                        self.state = 517
                        if not self.precpred(self._ctx, 9):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 9)")
                        self.state = 518
                        localctx.op = self.match(qasm3Parser.AMPERSAND)
                        self.state = 519
                        self.expression(10)
                        pass

                    elif la_ == 8:
                        localctx = qasm3Parser.BitwiseXorExpressionContext(self, qasm3Parser.ExpressionContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expression)
                        self.state = 520
                        if not self.precpred(self._ctx, 8):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 8)")
                        self.state = 521
                        localctx.op = self.match(qasm3Parser.CARET)
                        self.state = 522
                        self.expression(9)
                        pass

                    elif la_ == 9:
                        localctx = qasm3Parser.BitwiseOrExpressionContext(self, qasm3Parser.ExpressionContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expression)
                        self.state = 523
                        if not self.precpred(self._ctx, 7):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 7)")
                        self.state = 524
                        localctx.op = self.match(qasm3Parser.PIPE)
                        self.state = 525
                        self.expression(8)
                        pass

                    elif la_ == 10:
                        localctx = qasm3Parser.LogicalAndExpressionContext(self, qasm3Parser.ExpressionContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expression)
                        self.state = 526
                        if not self.precpred(self._ctx, 6):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 6)")
                        self.state = 527
                        localctx.op = self.match(qasm3Parser.DOUBLE_AMPERSAND)
                        self.state = 528
                        self.expression(7)
                        pass

                    elif la_ == 11:
                        localctx = qasm3Parser.LogicalOrExpressionContext(self, qasm3Parser.ExpressionContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expression)
                        self.state = 529
                        if not self.precpred(self._ctx, 5):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 5)")
                        self.state = 530
                        localctx.op = self.match(qasm3Parser.DOUBLE_PIPE)
                        self.state = 531
                        self.expression(6)
                        pass

                    elif la_ == 12:
                        localctx = qasm3Parser.IndexExpressionContext(self, qasm3Parser.ExpressionContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expression)
                        self.state = 532
                        if not self.precpred(self._ctx, 17):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 17)")
                        self.state = 533
                        self.indexOperator()
                        pass

             
                self.state = 538
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,47,self._ctx)

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


    class AliasExpressionContext(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(qasm3Parser.ExpressionContext)
            else:
                return self.getTypedRuleContext(qasm3Parser.ExpressionContext,i)


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

        def getRuleIndex(self):
            return qasm3Parser.RULE_aliasExpression

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

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

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




    def aliasExpression(self):

        localctx = qasm3Parser.AliasExpressionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 76, self.RULE_aliasExpression)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 539
            self.expression(0)
            self.state = 544
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==69:
                self.state = 540
                self.match(qasm3Parser.DOUBLE_PLUS)
                self.state = 541
                self.expression(0)
                self.state = 546
                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 DeclarationExpressionContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def arrayLiteral(self):
            return self.getTypedRuleContext(qasm3Parser.ArrayLiteralContext,0)


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


        def measureExpression(self):
            return self.getTypedRuleContext(qasm3Parser.MeasureExpressionContext,0)


        def getRuleIndex(self):
            return qasm3Parser.RULE_declarationExpression

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

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

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




    def declarationExpression(self):

        localctx = qasm3Parser.DeclarationExpressionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 78, self.RULE_declarationExpression)
        try:
            self.state = 550
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [58]:
                self.enterOuterAlt(localctx, 1)
                self.state = 547
                self.arrayLiteral()
                pass
            elif token in [33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 50, 55, 60, 70, 81, 82, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97]:
                self.enterOuterAlt(localctx, 2)
                self.state = 548
                self.expression(0)
                pass
            elif token in [53]:
                self.enterOuterAlt(localctx, 3)
                self.state = 549
                self.measureExpression()
                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 MeasureExpressionContext(ParserRuleContext):
        __slots__ = 'parser'

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

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

        def gateOperand(self):
            return self.getTypedRuleContext(qasm3Parser.GateOperandContext,0)


        def getRuleIndex(self):
            return qasm3Parser.RULE_measureExpression

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

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

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




    def measureExpression(self):

        localctx = qasm3Parser.MeasureExpressionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 80, self.RULE_measureExpression)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 552
            self.match(qasm3Parser.MEASURE)
            self.state = 553
            self.gateOperand()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class RangeExpressionContext(ParserRuleContext):
        __slots__ = 'parser'

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

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

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


        def getRuleIndex(self):
            return qasm3Parser.RULE_rangeExpression

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

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

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




    def rangeExpression(self):

        localctx = qasm3Parser.RangeExpressionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 82, self.RULE_rangeExpression)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 556
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if (((_la) & ~0x3f) == 0 and ((1 << _la) & 1190091586105507840) != 0) or ((((_la - 70)) & ~0x3f) == 0 and ((1 << (_la - 70)) & 268179457) != 0):
                self.state = 555
                self.expression(0)


            self.state = 558
            self.match(qasm3Parser.COLON)
            self.state = 560
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if (((_la) & ~0x3f) == 0 and ((1 << _la) & 1190091586105507840) != 0) or ((((_la - 70)) & ~0x3f) == 0 and ((1 << (_la - 70)) & 268179457) != 0):
                self.state = 559
                self.expression(0)


            self.state = 564
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==62:
                self.state = 562
                self.match(qasm3Parser.COLON)
                self.state = 563
                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 SetExpressionContext(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(qasm3Parser.LBRACE, 0)

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


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

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

        def getRuleIndex(self):
            return qasm3Parser.RULE_setExpression

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

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

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




    def setExpression(self):

        localctx = qasm3Parser.SetExpressionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 84, self.RULE_setExpression)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 566
            self.match(qasm3Parser.LBRACE)
            self.state = 567
            self.expression(0)
            self.state = 572
            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:
                    self.state = 568
                    self.match(qasm3Parser.COMMA)
                    self.state = 569
                    self.expression(0) 
                self.state = 574
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,53,self._ctx)

            self.state = 576
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==65:
                self.state = 575
                self.match(qasm3Parser.COMMA)


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


    class ArrayLiteralContext(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(qasm3Parser.LBRACE, 0)

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

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


        def arrayLiteral(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(qasm3Parser.ArrayLiteralContext)
            else:
                return self.getTypedRuleContext(qasm3Parser.ArrayLiteralContext,i)


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

        def getRuleIndex(self):
            return qasm3Parser.RULE_arrayLiteral

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

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

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




    def arrayLiteral(self):

        localctx = qasm3Parser.ArrayLiteralContext(self, self._ctx, self.state)
        self.enterRule(localctx, 86, self.RULE_arrayLiteral)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 580
            self.match(qasm3Parser.LBRACE)
            self.state = 598
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if (((_la) & ~0x3f) == 0 and ((1 << _la) & 1478321962257219584) != 0) or ((((_la - 70)) & ~0x3f) == 0 and ((1 << (_la - 70)) & 268179457) != 0):
                self.state = 583
                self._errHandler.sync(self)
                token = self._input.LA(1)
                if token in [33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 50, 55, 60, 70, 81, 82, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97]:
                    self.state = 581
                    self.expression(0)
                    pass
                elif token in [58]:
                    self.state = 582
                    self.arrayLiteral()
                    pass
                else:
                    raise NoViableAltException(self)

                self.state = 592
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,57,self._ctx)
                while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                    if _alt==1:
                        self.state = 585
                        self.match(qasm3Parser.COMMA)
                        self.state = 588
                        self._errHandler.sync(self)
                        token = self._input.LA(1)
                        if token in [33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 50, 55, 60, 70, 81, 82, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97]:
                            self.state = 586
                            self.expression(0)
                            pass
                        elif token in [58]:
                            self.state = 587
                            self.arrayLiteral()
                            pass
                        else:
                            raise NoViableAltException(self)
                 
                    self.state = 594
                    self._errHandler.sync(self)
                    _alt = self._interp.adaptivePredict(self._input,57,self._ctx)

                self.state = 596
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==65:
                    self.state = 595
                    self.match(qasm3Parser.COMMA)




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


    class IndexOperatorContext(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(qasm3Parser.LBRACKET, 0)

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

        def setExpression(self):
            return self.getTypedRuleContext(qasm3Parser.SetExpressionContext,0)


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


        def rangeExpression(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(qasm3Parser.RangeExpressionContext)
            else:
                return self.getTypedRuleContext(qasm3Parser.RangeExpressionContext,i)


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

        def getRuleIndex(self):
            return qasm3Parser.RULE_indexOperator

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

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

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




    def indexOperator(self):

        localctx = qasm3Parser.IndexOperatorContext(self, self._ctx, self.state)
        self.enterRule(localctx, 88, self.RULE_indexOperator)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 602
            self.match(qasm3Parser.LBRACKET)
            self.state = 621
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [58]:
                self.state = 603
                self.setExpression()
                pass
            elif token in [33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 50, 55, 60, 62, 70, 81, 82, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97]:
                self.state = 606
                self._errHandler.sync(self)
                la_ = self._interp.adaptivePredict(self._input,60,self._ctx)
                if la_ == 1:
                    self.state = 604
                    self.expression(0)
                    pass

                elif la_ == 2:
                    self.state = 605
                    self.rangeExpression()
                    pass


                self.state = 615
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,62,self._ctx)
                while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                    if _alt==1:
                        self.state = 608
                        self.match(qasm3Parser.COMMA)
                        self.state = 611
                        self._errHandler.sync(self)
                        la_ = self._interp.adaptivePredict(self._input,61,self._ctx)
                        if la_ == 1:
                            self.state = 609
                            self.expression(0)
                            pass

                        elif la_ == 2:
                            self.state = 610
                            self.rangeExpression()
                            pass

                 
                    self.state = 617
                    self._errHandler.sync(self)
                    _alt = self._interp.adaptivePredict(self._input,62,self._ctx)

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


                pass
            else:
                raise NoViableAltException(self)

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


    class IndexedIdentifierContext(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(qasm3Parser.Identifier, 0)

        def indexOperator(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(qasm3Parser.IndexOperatorContext)
            else:
                return self.getTypedRuleContext(qasm3Parser.IndexOperatorContext,i)


        def getRuleIndex(self):
            return qasm3Parser.RULE_indexedIdentifier

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

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

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




    def indexedIdentifier(self):

        localctx = qasm3Parser.IndexedIdentifierContext(self, self._ctx, self.state)
        self.enterRule(localctx, 90, self.RULE_indexedIdentifier)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 625
            self.match(qasm3Parser.Identifier)
            self.state = 629
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==56:
                self.state = 626
                self.indexOperator()
                self.state = 631
                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 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(qasm3Parser.ARROW, 0)

        def scalarType(self):
            return self.getTypedRuleContext(qasm3Parser.ScalarTypeContext,0)


        def getRuleIndex(self):
            return qasm3Parser.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 accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitReturnSignature" ):
                return visitor.visitReturnSignature(self)
            else:
                return visitor.visitChildren(self)




    def returnSignature(self):

        localctx = qasm3Parser.ReturnSignatureContext(self, self._ctx, self.state)
        self.enterRule(localctx, 92, self.RULE_returnSignature)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 632
            self.match(qasm3Parser.ARROW)
            self.state = 633
            self.scalarType()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class GateModifierContext(ParserRuleContext):
        __slots__ = 'parser'

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

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

        def INV(self):
            return self.getToken(qasm3Parser.INV, 0)

        def POW(self):
            return self.getToken(qasm3Parser.POW, 0)

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

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


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

        def CTRL(self):
            return self.getToken(qasm3Parser.CTRL, 0)

        def NEGCTRL(self):
            return self.getToken(qasm3Parser.NEGCTRL, 0)

        def getRuleIndex(self):
            return qasm3Parser.RULE_gateModifier

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

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

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




    def gateModifier(self):

        localctx = qasm3Parser.GateModifierContext(self, self._ctx, self.state)
        self.enterRule(localctx, 94, self.RULE_gateModifier)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 648
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [45]:
                self.state = 635
                self.match(qasm3Parser.INV)
                pass
            elif token in [46]:
                self.state = 636
                self.match(qasm3Parser.POW)
                self.state = 637
                self.match(qasm3Parser.LPAREN)
                self.state = 638
                self.expression(0)
                self.state = 639
                self.match(qasm3Parser.RPAREN)
                pass
            elif token in [47, 48]:
                self.state = 641
                _la = self._input.LA(1)
                if not(_la==47 or _la==48):
                    self._errHandler.recoverInline(self)
                else:
                    self._errHandler.reportMatch(self)
                    self.consume()
                self.state = 646
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==60:
                    self.state = 642
                    self.match(qasm3Parser.LPAREN)
                    self.state = 643
                    self.expression(0)
                    self.state = 644
                    self.match(qasm3Parser.RPAREN)


                pass
            else:
                raise NoViableAltException(self)

            self.state = 650
            self.match(qasm3Parser.AT)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class ScalarTypeContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def BIT(self):
            return self.getToken(qasm3Parser.BIT, 0)

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


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

        def UINT(self):
            return self.getToken(qasm3Parser.UINT, 0)

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

        def ANGLE(self):
            return self.getToken(qasm3Parser.ANGLE, 0)

        def BOOL(self):
            return self.getToken(qasm3Parser.BOOL, 0)

        def DURATION(self):
            return self.getToken(qasm3Parser.DURATION, 0)

        def STRETCH(self):
            return self.getToken(qasm3Parser.STRETCH, 0)

        def COMPLEX(self):
            return self.getToken(qasm3Parser.COMPLEX, 0)

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

        def scalarType(self):
            return self.getTypedRuleContext(qasm3Parser.ScalarTypeContext,0)


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

        def getRuleIndex(self):
            return qasm3Parser.RULE_scalarType

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

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

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




    def scalarType(self):

        localctx = qasm3Parser.ScalarTypeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 96, self.RULE_scalarType)
        self._la = 0 # Token type
        try:
            self.state = 682
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [34]:
                self.enterOuterAlt(localctx, 1)
                self.state = 652
                self.match(qasm3Parser.BIT)
                self.state = 654
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==56:
                    self.state = 653
                    self.designator()


                pass
            elif token in [35]:
                self.enterOuterAlt(localctx, 2)
                self.state = 656
                self.match(qasm3Parser.INT)
                self.state = 658
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==56:
                    self.state = 657
                    self.designator()


                pass
            elif token in [36]:
                self.enterOuterAlt(localctx, 3)
                self.state = 660
                self.match(qasm3Parser.UINT)
                self.state = 662
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==56:
                    self.state = 661
                    self.designator()


                pass
            elif token in [37]:
                self.enterOuterAlt(localctx, 4)
                self.state = 664
                self.match(qasm3Parser.FLOAT)
                self.state = 666
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==56:
                    self.state = 665
                    self.designator()


                pass
            elif token in [38]:
                self.enterOuterAlt(localctx, 5)
                self.state = 668
                self.match(qasm3Parser.ANGLE)
                self.state = 670
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==56:
                    self.state = 669
                    self.designator()


                pass
            elif token in [33]:
                self.enterOuterAlt(localctx, 6)
                self.state = 672
                self.match(qasm3Parser.BOOL)
                pass
            elif token in [42]:
                self.enterOuterAlt(localctx, 7)
                self.state = 673
                self.match(qasm3Parser.DURATION)
                pass
            elif token in [43]:
                self.enterOuterAlt(localctx, 8)
                self.state = 674
                self.match(qasm3Parser.STRETCH)
                pass
            elif token in [39]:
                self.enterOuterAlt(localctx, 9)
                self.state = 675
                self.match(qasm3Parser.COMPLEX)
                self.state = 680
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==56:
                    self.state = 676
                    self.match(qasm3Parser.LBRACKET)
                    self.state = 677
                    self.scalarType()
                    self.state = 678
                    self.match(qasm3Parser.RBRACKET)


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

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

        def QUBIT(self):
            return self.getToken(qasm3Parser.QUBIT, 0)

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


        def getRuleIndex(self):
            return qasm3Parser.RULE_qubitType

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

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

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




    def qubitType(self):

        localctx = qasm3Parser.QubitTypeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 98, self.RULE_qubitType)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 684
            self.match(qasm3Parser.QUBIT)
            self.state = 686
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==56:
                self.state = 685
                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 ArrayTypeContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def ARRAY(self):
            return self.getToken(qasm3Parser.ARRAY, 0)

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

        def scalarType(self):
            return self.getTypedRuleContext(qasm3Parser.ScalarTypeContext,0)


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

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


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

        def getRuleIndex(self):
            return qasm3Parser.RULE_arrayType

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

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

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




    def arrayType(self):

        localctx = qasm3Parser.ArrayTypeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 100, self.RULE_arrayType)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 688
            self.match(qasm3Parser.ARRAY)
            self.state = 689
            self.match(qasm3Parser.LBRACKET)
            self.state = 690
            self.scalarType()
            self.state = 691
            self.match(qasm3Parser.COMMA)
            self.state = 692
            self.expressionList()
            self.state = 693
            self.match(qasm3Parser.RBRACKET)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class ArrayReferenceTypeContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def ARRAY(self):
            return self.getToken(qasm3Parser.ARRAY, 0)

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

        def scalarType(self):
            return self.getTypedRuleContext(qasm3Parser.ScalarTypeContext,0)


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

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

        def READONLY(self):
            return self.getToken(qasm3Parser.READONLY, 0)

        def MUTABLE(self):
            return self.getToken(qasm3Parser.MUTABLE, 0)

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


        def DIM(self):
            return self.getToken(qasm3Parser.DIM, 0)

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

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


        def getRuleIndex(self):
            return qasm3Parser.RULE_arrayReferenceType

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

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

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




    def arrayReferenceType(self):

        localctx = qasm3Parser.ArrayReferenceTypeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 102, self.RULE_arrayReferenceType)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 695
            _la = self._input.LA(1)
            if not(_la==28 or _la==29):
                self._errHandler.recoverInline(self)
            else:
                self._errHandler.reportMatch(self)
                self.consume()
            self.state = 696
            self.match(qasm3Parser.ARRAY)
            self.state = 697
            self.match(qasm3Parser.LBRACKET)
            self.state = 698
            self.scalarType()
            self.state = 699
            self.match(qasm3Parser.COMMA)
            self.state = 704
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 50, 55, 60, 70, 81, 82, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97]:
                self.state = 700
                self.expressionList()
                pass
            elif token in [49]:
                self.state = 701
                self.match(qasm3Parser.DIM)
                self.state = 702
                self.match(qasm3Parser.EQUALS)
                self.state = 703
                self.expression(0)
                pass
            else:
                raise NoViableAltException(self)

            self.state = 706
            self.match(qasm3Parser.RBRACKET)
        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(qasm3Parser.LBRACKET, 0)

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


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

        def getRuleIndex(self):
            return qasm3Parser.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 accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitDesignator" ):
                return visitor.visitDesignator(self)
            else:
                return visitor.visitChildren(self)




    def designator(self):

        localctx = qasm3Parser.DesignatorContext(self, self._ctx, self.state)
        self.enterRule(localctx, 104, self.RULE_designator)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 708
            self.match(qasm3Parser.LBRACKET)
            self.state = 709
            self.expression(0)
            self.state = 710
            self.match(qasm3Parser.RBRACKET)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class DefcalTargetContext(ParserRuleContext):
        __slots__ = 'parser'

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

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

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

        def DELAY(self):
            return self.getToken(qasm3Parser.DELAY, 0)

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

        def getRuleIndex(self):
            return qasm3Parser.RULE_defcalTarget

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

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

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




    def defcalTarget(self):

        localctx = qasm3Parser.DefcalTargetContext(self, self._ctx, self.state)
        self.enterRule(localctx, 106, self.RULE_defcalTarget)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 712
            _la = self._input.LA(1)
            if not(((((_la - 51)) & ~0x3f) == 0 and ((1 << (_la - 51)) & 4398046511111) != 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 DefcalArgumentDefinitionContext(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(qasm3Parser.ExpressionContext,0)


        def argumentDefinition(self):
            return self.getTypedRuleContext(qasm3Parser.ArgumentDefinitionContext,0)


        def getRuleIndex(self):
            return qasm3Parser.RULE_defcalArgumentDefinition

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

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

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




    def defcalArgumentDefinition(self):

        localctx = qasm3Parser.DefcalArgumentDefinitionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 108, self.RULE_defcalArgumentDefinition)
        try:
            self.state = 716
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,77,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 714
                self.expression(0)
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 715
                self.argumentDefinition()
                pass


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


    class DefcalOperandContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def HardwareQubit(self):
            return self.getToken(qasm3Parser.HardwareQubit, 0)

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

        def getRuleIndex(self):
            return qasm3Parser.RULE_defcalOperand

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

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

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




    def defcalOperand(self):

        localctx = qasm3Parser.DefcalOperandContext(self, self._ctx, self.state)
        self.enterRule(localctx, 110, self.RULE_defcalOperand)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 718
            _la = self._input.LA(1)
            if not(_la==93 or _la==94):
                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 GateOperandContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def indexedIdentifier(self):
            return self.getTypedRuleContext(qasm3Parser.IndexedIdentifierContext,0)


        def HardwareQubit(self):
            return self.getToken(qasm3Parser.HardwareQubit, 0)

        def getRuleIndex(self):
            return qasm3Parser.RULE_gateOperand

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

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

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




    def gateOperand(self):

        localctx = qasm3Parser.GateOperandContext(self, self._ctx, self.state)
        self.enterRule(localctx, 112, self.RULE_gateOperand)
        try:
            self.state = 722
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [93]:
                self.enterOuterAlt(localctx, 1)
                self.state = 720
                self.indexedIdentifier()
                pass
            elif token in [94]:
                self.enterOuterAlt(localctx, 2)
                self.state = 721
                self.match(qasm3Parser.HardwareQubit)
                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 ExternArgumentContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def scalarType(self):
            return self.getTypedRuleContext(qasm3Parser.ScalarTypeContext,0)


        def arrayReferenceType(self):
            return self.getTypedRuleContext(qasm3Parser.ArrayReferenceTypeContext,0)


        def CREG(self):
            return self.getToken(qasm3Parser.CREG, 0)

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


        def getRuleIndex(self):
            return qasm3Parser.RULE_externArgument

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

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

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




    def externArgument(self):

        localctx = qasm3Parser.ExternArgumentContext(self, self._ctx, self.state)
        self.enterRule(localctx, 114, self.RULE_externArgument)
        self._la = 0 # Token type
        try:
            self.state = 730
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [33, 34, 35, 36, 37, 38, 39, 42, 43]:
                self.enterOuterAlt(localctx, 1)
                self.state = 724
                self.scalarType()
                pass
            elif token in [28, 29]:
                self.enterOuterAlt(localctx, 2)
                self.state = 725
                self.arrayReferenceType()
                pass
            elif token in [32]:
                self.enterOuterAlt(localctx, 3)
                self.state = 726
                self.match(qasm3Parser.CREG)
                self.state = 728
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==56:
                    self.state = 727
                    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 ArgumentDefinitionContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def scalarType(self):
            return self.getTypedRuleContext(qasm3Parser.ScalarTypeContext,0)


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

        def qubitType(self):
            return self.getTypedRuleContext(qasm3Parser.QubitTypeContext,0)


        def CREG(self):
            return self.getToken(qasm3Parser.CREG, 0)

        def QREG(self):
            return self.getToken(qasm3Parser.QREG, 0)

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


        def arrayReferenceType(self):
            return self.getTypedRuleContext(qasm3Parser.ArrayReferenceTypeContext,0)


        def getRuleIndex(self):
            return qasm3Parser.RULE_argumentDefinition

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

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

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




    def argumentDefinition(self):

        localctx = qasm3Parser.ArgumentDefinitionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 116, self.RULE_argumentDefinition)
        self._la = 0 # Token type
        try:
            self.state = 746
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [33, 34, 35, 36, 37, 38, 39, 42, 43]:
                self.enterOuterAlt(localctx, 1)
                self.state = 732
                self.scalarType()
                self.state = 733
                self.match(qasm3Parser.Identifier)
                pass
            elif token in [31]:
                self.enterOuterAlt(localctx, 2)
                self.state = 735
                self.qubitType()
                self.state = 736
                self.match(qasm3Parser.Identifier)
                pass
            elif token in [30, 32]:
                self.enterOuterAlt(localctx, 3)
                self.state = 738
                _la = self._input.LA(1)
                if not(_la==30 or _la==32):
                    self._errHandler.recoverInline(self)
                else:
                    self._errHandler.reportMatch(self)
                    self.consume()
                self.state = 739
                self.match(qasm3Parser.Identifier)
                self.state = 741
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==56:
                    self.state = 740
                    self.designator()


                pass
            elif token in [28, 29]:
                self.enterOuterAlt(localctx, 4)
                self.state = 743
                self.arrayReferenceType()
                self.state = 744
                self.match(qasm3Parser.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 ArgumentDefinitionListContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def argumentDefinition(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(qasm3Parser.ArgumentDefinitionContext)
            else:
                return self.getTypedRuleContext(qasm3Parser.ArgumentDefinitionContext,i)


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

        def getRuleIndex(self):
            return qasm3Parser.RULE_argumentDefinitionList

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

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

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




    def argumentDefinitionList(self):

        localctx = qasm3Parser.ArgumentDefinitionListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 118, self.RULE_argumentDefinitionList)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 748
            self.argumentDefinition()
            self.state = 753
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,83,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 749
                    self.match(qasm3Parser.COMMA)
                    self.state = 750
                    self.argumentDefinition() 
                self.state = 755
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,83,self._ctx)

            self.state = 757
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==65:
                self.state = 756
                self.match(qasm3Parser.COMMA)


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


    class DefcalArgumentDefinitionListContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def defcalArgumentDefinition(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(qasm3Parser.DefcalArgumentDefinitionContext)
            else:
                return self.getTypedRuleContext(qasm3Parser.DefcalArgumentDefinitionContext,i)


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

        def getRuleIndex(self):
            return qasm3Parser.RULE_defcalArgumentDefinitionList

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

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

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




    def defcalArgumentDefinitionList(self):

        localctx = qasm3Parser.DefcalArgumentDefinitionListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 120, self.RULE_defcalArgumentDefinitionList)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 759
            self.defcalArgumentDefinition()
            self.state = 764
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,85,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 760
                    self.match(qasm3Parser.COMMA)
                    self.state = 761
                    self.defcalArgumentDefinition() 
                self.state = 766
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,85,self._ctx)

            self.state = 768
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==65:
                self.state = 767
                self.match(qasm3Parser.COMMA)


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


    class DefcalOperandListContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def defcalOperand(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(qasm3Parser.DefcalOperandContext)
            else:
                return self.getTypedRuleContext(qasm3Parser.DefcalOperandContext,i)


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

        def getRuleIndex(self):
            return qasm3Parser.RULE_defcalOperandList

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

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

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




    def defcalOperandList(self):

        localctx = qasm3Parser.DefcalOperandListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 122, self.RULE_defcalOperandList)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 770
            self.defcalOperand()
            self.state = 775
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,87,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 771
                    self.match(qasm3Parser.COMMA)
                    self.state = 772
                    self.defcalOperand() 
                self.state = 777
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,87,self._ctx)

            self.state = 779
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==65:
                self.state = 778
                self.match(qasm3Parser.COMMA)


        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(qasm3Parser.ExpressionContext)
            else:
                return self.getTypedRuleContext(qasm3Parser.ExpressionContext,i)


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

        def getRuleIndex(self):
            return qasm3Parser.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 accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitExpressionList" ):
                return visitor.visitExpressionList(self)
            else:
                return visitor.visitChildren(self)




    def expressionList(self):

        localctx = qasm3Parser.ExpressionListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 124, self.RULE_expressionList)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 781
            self.expression(0)
            self.state = 786
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,89,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 782
                    self.match(qasm3Parser.COMMA)
                    self.state = 783
                    self.expression(0) 
                self.state = 788
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,89,self._ctx)

            self.state = 790
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==65:
                self.state = 789
                self.match(qasm3Parser.COMMA)


        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(qasm3Parser.Identifier)
            else:
                return self.getToken(qasm3Parser.Identifier, i)

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

        def getRuleIndex(self):
            return qasm3Parser.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 accept(self, visitor:ParseTreeVisitor):
            if hasattr( visitor, "visitIdentifierList" ):
                return visitor.visitIdentifierList(self)
            else:
                return visitor.visitChildren(self)




    def identifierList(self):

        localctx = qasm3Parser.IdentifierListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 126, self.RULE_identifierList)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 792
            self.match(qasm3Parser.Identifier)
            self.state = 797
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,91,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 793
                    self.match(qasm3Parser.COMMA)
                    self.state = 794
                    self.match(qasm3Parser.Identifier) 
                self.state = 799
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,91,self._ctx)

            self.state = 801
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==65:
                self.state = 800
                self.match(qasm3Parser.COMMA)


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


    class GateOperandListContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def gateOperand(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(qasm3Parser.GateOperandContext)
            else:
                return self.getTypedRuleContext(qasm3Parser.GateOperandContext,i)


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

        def getRuleIndex(self):
            return qasm3Parser.RULE_gateOperandList

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

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

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




    def gateOperandList(self):

        localctx = qasm3Parser.GateOperandListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 128, self.RULE_gateOperandList)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 803
            self.gateOperand()
            self.state = 808
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,93,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 804
                    self.match(qasm3Parser.COMMA)
                    self.state = 805
                    self.gateOperand() 
                self.state = 810
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,93,self._ctx)

            self.state = 812
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==65:
                self.state = 811
                self.match(qasm3Parser.COMMA)


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


    class ExternArgumentListContext(ParserRuleContext):
        __slots__ = 'parser'

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

        def externArgument(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(qasm3Parser.ExternArgumentContext)
            else:
                return self.getTypedRuleContext(qasm3Parser.ExternArgumentContext,i)


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

        def getRuleIndex(self):
            return qasm3Parser.RULE_externArgumentList

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

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

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




    def externArgumentList(self):

        localctx = qasm3Parser.ExternArgumentListContext(self, self._ctx, self.state)
        self.enterRule(localctx, 130, self.RULE_externArgumentList)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 814
            self.externArgument()
            self.state = 819
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,95,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 815
                    self.match(qasm3Parser.COMMA)
                    self.state = 816
                    self.externArgument() 
                self.state = 821
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,95,self._ctx)

            self.state = 823
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==65:
                self.state = 822
                self.match(qasm3Parser.COMMA)


        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[37] = self.expression_sempred
        pred = self._predicates.get(ruleIndex, None)
        if pred is None:
            raise Exception("No predicate with index:" + str(ruleIndex))
        else:
            return pred(localctx, predIndex)

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

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

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

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

            if predIndex == 4:
                return self.precpred(self._ctx, 11)
         

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

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

            if predIndex == 7:
                return self.precpred(self._ctx, 8)
         

            if predIndex == 8:
                return self.precpred(self._ctx, 7)
         

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

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

            if predIndex == 11:
                return self.precpred(self._ctx, 17)
         




