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


def serializedATN():
    with StringIO() as buf:
        buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3?")
        buf.write("\u0170\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7")
        buf.write("\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r\t\r\4\16")
        buf.write("\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22\4\23\t\23")
        buf.write("\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31")
        buf.write("\t\31\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36")
        buf.write("\4\37\t\37\4 \t \4!\t!\4\"\t\"\4#\t#\4$\t$\3\2\7\2J\n")
        buf.write("\2\f\2\16\2M\13\2\3\2\3\2\7\2Q\n\2\f\2\16\2T\13\2\3\2")
        buf.write("\3\2\7\2X\n\2\f\2\16\2[\13\2\3\2\3\2\3\3\3\3\6\3a\n\3")
        buf.write("\r\3\16\3b\3\3\3\3\6\3g\n\3\r\3\16\3h\3\3\5\3l\n\3\3\3")
        buf.write("\6\3o\n\3\r\3\16\3p\3\3\5\3t\n\3\3\3\3\3\7\3x\n\3\f\3")
        buf.write("\16\3{\13\3\3\4\3\4\3\4\3\5\3\5\3\6\3\6\3\6\3\7\3\7\3")
        buf.write("\b\3\b\3\b\5\b\u008a\n\b\3\t\3\t\3\n\3\n\3\n\5\n\u0091")
        buf.write("\n\n\3\13\3\13\3\f\3\f\3\f\3\r\3\r\3\r\3\r\3\r\7\r\u009d")
        buf.write("\n\r\f\r\16\r\u00a0\13\r\3\16\3\16\3\16\3\16\3\16\5\16")
        buf.write("\u00a7\n\16\3\17\3\17\3\17\3\17\3\17\3\17\3\17\5\17\u00b0")
        buf.write("\n\17\3\17\3\17\3\17\3\17\5\17\u00b6\n\17\3\20\3\20\5")
        buf.write("\20\u00ba\n\20\3\21\3\21\5\21\u00be\n\21\3\22\3\22\3\23")
        buf.write("\3\23\3\24\3\24\3\25\3\25\3\25\7\25\u00c9\n\25\f\25\16")
        buf.write("\25\u00cc\13\25\3\26\3\26\3\26\3\26\7\26\u00d2\n\26\f")
        buf.write("\26\16\26\u00d5\13\26\3\27\3\27\3\27\7\27\u00da\n\27\f")
        buf.write("\27\16\27\u00dd\13\27\3\30\3\30\5\30\u00e1\n\30\3\30\5")
        buf.write("\30\u00e4\n\30\3\30\3\30\5\30\u00e8\n\30\3\30\3\30\5\30")
        buf.write("\u00ec\n\30\3\30\7\30\u00ef\n\30\f\30\16\30\u00f2\13\30")
        buf.write("\3\31\3\31\3\32\3\32\3\33\3\33\3\33\3\33\3\33\3\33\5\33")
        buf.write("\u00fe\n\33\3\33\3\33\5\33\u0102\n\33\5\33\u0104\n\33")
        buf.write("\3\33\3\33\3\33\6\33\u0109\n\33\r\33\16\33\u010a\3\34")
        buf.write("\3\34\3\34\3\34\7\34\u0111\n\34\f\34\16\34\u0114\13\34")
        buf.write("\5\34\u0116\n\34\3\34\5\34\u0119\n\34\3\34\3\34\3\34\7")
        buf.write("\34\u011e\n\34\f\34\16\34\u0121\13\34\5\34\u0123\n\34")
        buf.write("\3\34\3\34\3\35\3\35\3\35\3\35\3\35\5\35\u012c\n\35\3")
        buf.write("\35\5\35\u012f\n\35\3\36\3\36\5\36\u0133\n\36\3\37\3\37")
        buf.write("\3\37\7\37\u0138\n\37\f\37\16\37\u013b\13\37\3 \3 \3 ")
        buf.write("\3 \3 \5 \u0142\n \3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3")
        buf.write("!\3!\3!\3!\3!\3!\3!\3!\3!\5!\u0158\n!\3!\3!\3!\3!\3!\3")
        buf.write("!\3!\3!\3!\7!\u0163\n!\f!\16!\u0166\13!\3\"\3\"\3\"\3")
        buf.write("\"\3#\3#\3$\3$\3$\2\3@%\2\4\6\b\n\f\16\20\22\24\26\30")
        buf.write("\32\34\36 \"$&(*,.\60\62\64\668:<>@BDF\2\r\3\2<=\3\2\25")
        buf.write("\30\3\2\649\3\2\16\17\4\2--//\4\2..\60\60\3\2\3\4\4\2")
        buf.write("::<<\3\2\5\6\4\2\13\r\21\21\3\2\32(\2\u0181\2K\3\2\2\2")
        buf.write("\4^\3\2\2\2\6|\3\2\2\2\b\177\3\2\2\2\n\u0081\3\2\2\2\f")
        buf.write("\u0084\3\2\2\2\16\u0086\3\2\2\2\20\u008b\3\2\2\2\22\u008d")
        buf.write("\3\2\2\2\24\u0092\3\2\2\2\26\u0094\3\2\2\2\30\u009e\3")
        buf.write("\2\2\2\32\u00a1\3\2\2\2\34\u00a8\3\2\2\2\36\u00b9\3\2")
        buf.write("\2\2 \u00bd\3\2\2\2\"\u00bf\3\2\2\2$\u00c1\3\2\2\2&\u00c3")
        buf.write("\3\2\2\2(\u00c5\3\2\2\2*\u00d3\3\2\2\2,\u00d6\3\2\2\2")
        buf.write(".\u00e0\3\2\2\2\60\u00f3\3\2\2\2\62\u00f5\3\2\2\2\64\u00f7")
        buf.write("\3\2\2\2\66\u010c\3\2\2\28\u0126\3\2\2\2:\u0132\3\2\2")
        buf.write("\2<\u0134\3\2\2\2>\u013c\3\2\2\2@\u0157\3\2\2\2B\u0167")
        buf.write("\3\2\2\2D\u016b\3\2\2\2F\u016d\3\2\2\2HJ\7\22\2\2IH\3")
        buf.write("\2\2\2JM\3\2\2\2KI\3\2\2\2KL\3\2\2\2LN\3\2\2\2MK\3\2\2")
        buf.write("\2NR\5\4\3\2OQ\7\22\2\2PO\3\2\2\2QT\3\2\2\2RP\3\2\2\2")
        buf.write("RS\3\2\2\2SU\3\2\2\2TR\3\2\2\2UY\5\30\r\2VX\7\22\2\2W")
        buf.write("V\3\2\2\2X[\3\2\2\2YW\3\2\2\2YZ\3\2\2\2Z\\\3\2\2\2[Y\3")
        buf.write("\2\2\2\\]\7\2\2\3]\3\3\2\2\2^`\5\6\4\2_a\7\22\2\2`_\3")
        buf.write("\2\2\2ab\3\2\2\2b`\3\2\2\2bc\3\2\2\2cd\3\2\2\2dk\5\n\6")
        buf.write("\2eg\7\22\2\2fe\3\2\2\2gh\3\2\2\2hf\3\2\2\2hi\3\2\2\2")
        buf.write("ij\3\2\2\2jl\5\16\b\2kf\3\2\2\2kl\3\2\2\2ls\3\2\2\2mo")
        buf.write("\7\22\2\2nm\3\2\2\2op\3\2\2\2pn\3\2\2\2pq\3\2\2\2qr\3")
        buf.write("\2\2\2rt\5\22\n\2sn\3\2\2\2st\3\2\2\2ty\3\2\2\2ux\7\22")
        buf.write("\2\2vx\5\26\f\2wu\3\2\2\2wv\3\2\2\2x{\3\2\2\2yw\3\2\2")
        buf.write("\2yz\3\2\2\2z\5\3\2\2\2{y\3\2\2\2|}\7\25\2\2}~\5\b\5\2")
        buf.write("~\7\3\2\2\2\177\u0080\7<\2\2\u0080\t\3\2\2\2\u0081\u0082")
        buf.write("\7\26\2\2\u0082\u0083\5\f\7\2\u0083\13\3\2\2\2\u0084\u0085")
        buf.write("\7\f\2\2\u0085\r\3\2\2\2\u0086\u0087\7\27\2\2\u0087\u0089")
        buf.write("\5\20\t\2\u0088\u008a\5\66\34\2\u0089\u0088\3\2\2\2\u0089")
        buf.write("\u008a\3\2\2\2\u008a\17\3\2\2\2\u008b\u008c\t\2\2\2\u008c")
        buf.write("\21\3\2\2\2\u008d\u008e\7\30\2\2\u008e\u0090\5\24\13\2")
        buf.write("\u008f\u0091\5\66\34\2\u0090\u008f\3\2\2\2\u0090\u0091")
        buf.write("\3\2\2\2\u0091\23\3\2\2\2\u0092\u0093\7<\2\2\u0093\25")
        buf.write("\3\2\2\2\u0094\u0095\7\31\2\2\u0095\u0096\7\16\2\2\u0096")
        buf.write("\27\3\2\2\2\u0097\u009d\7\22\2\2\u0098\u009d\5\64\33\2")
        buf.write("\u0099\u009d\5\32\16\2\u009a\u009d\5\34\17\2\u009b\u009d")
        buf.write("\5.\30\2\u009c\u0097\3\2\2\2\u009c\u0098\3\2\2\2\u009c")
        buf.write("\u0099\3\2\2\2\u009c\u009a\3\2\2\2\u009c\u009b\3\2\2\2")
        buf.write("\u009d\u00a0\3\2\2\2\u009e\u009c\3\2\2\2\u009e\u009f\3")
        buf.write("\2\2\2\u009f\31\3\2\2\2\u00a0\u009e\3\2\2\2\u00a1\u00a2")
        buf.write("\5$\23\2\u00a2\u00a3\5\36\20\2\u00a3\u00a6\7\b\2\2\u00a4")
        buf.write("\u00a7\5@!\2\u00a5\u00a7\5&\24\2\u00a6\u00a4\3\2\2\2\u00a6")
        buf.write("\u00a5\3\2\2\2\u00a7\33\3\2\2\2\u00a8\u00a9\5$\23\2\u00a9")
        buf.write("\u00aa\7\64\2\2\u00aa\u00af\5\36\20\2\u00ab\u00ac\7/\2")
        buf.write("\2\u00ac\u00ad\5(\25\2\u00ad\u00ae\7\60\2\2\u00ae\u00b0")
        buf.write("\3\2\2\2\u00af\u00ab\3\2\2\2\u00af\u00b0\3\2\2\2\u00b0")
        buf.write("\u00b1\3\2\2\2\u00b1\u00b2\7\b\2\2\u00b2\u00b5\7\22\2")
        buf.write("\2\u00b3\u00b6\5*\26\2\u00b4\u00b6\5B\"\2\u00b5\u00b3")
        buf.write("\3\2\2\2\u00b5\u00b4\3\2\2\2\u00b6\35\3\2\2\2\u00b7\u00ba")
        buf.write("\5 \21\2\u00b8\u00ba\7<\2\2\u00b9\u00b7\3\2\2\2\u00b9")
        buf.write("\u00b8\3\2\2\2\u00ba\37\3\2\2\2\u00bb\u00be\7:\2\2\u00bc")
        buf.write("\u00be\5\"\22\2\u00bd\u00bb\3\2\2\2\u00bd\u00bc\3\2\2")
        buf.write("\2\u00be!\3\2\2\2\u00bf\u00c0\t\3\2\2\u00c0#\3\2\2\2\u00c1")
        buf.write("\u00c2\t\4\2\2\u00c2%\3\2\2\2\u00c3\u00c4\t\5\2\2\u00c4")
        buf.write("\'\3\2\2\2\u00c5\u00ca\7\13\2\2\u00c6\u00c7\7*\2\2\u00c7")
        buf.write("\u00c9\7\13\2\2\u00c8\u00c6\3\2\2\2\u00c9\u00cc\3\2\2")
        buf.write("\2\u00ca\u00c8\3\2\2\2\u00ca\u00cb\3\2\2\2\u00cb)\3\2")
        buf.write("\2\2\u00cc\u00ca\3\2\2\2\u00cd\u00ce\7\23\2\2\u00ce\u00cf")
        buf.write("\5,\27\2\u00cf\u00d0\7\22\2\2\u00d0\u00d2\3\2\2\2\u00d1")
        buf.write("\u00cd\3\2\2\2\u00d2\u00d5\3\2\2\2\u00d3\u00d1\3\2\2\2")
        buf.write("\u00d3\u00d4\3\2\2\2\u00d4+\3\2\2\2\u00d5\u00d3\3\2\2")
        buf.write("\2\u00d6\u00db\5@!\2\u00d7\u00d8\7*\2\2\u00d8\u00da\5")
        buf.write("@!\2\u00d9\u00d7\3\2\2\2\u00da\u00dd\3\2\2\2\u00db\u00d9")
        buf.write("\3\2\2\2\u00db\u00dc\3\2\2\2\u00dc-\3\2\2\2\u00dd\u00db")
        buf.write("\3\2\2\2\u00de\u00e1\5\60\31\2\u00df\u00e1\5\62\32\2\u00e0")
        buf.write("\u00de\3\2\2\2\u00e0\u00df\3\2\2\2\u00e1\u00e3\3\2\2\2")
        buf.write("\u00e2\u00e4\5\66\34\2\u00e3\u00e2\3\2\2\2\u00e3\u00e4")
        buf.write("\3\2\2\2\u00e4\u00e5\3\2\2\2\u00e5\u00e7\7\63\2\2\u00e6")
        buf.write("\u00e8\t\6\2\2\u00e7\u00e6\3\2\2\2\u00e7\u00e8\3\2\2\2")
        buf.write("\u00e8\u00e9\3\2\2\2\u00e9\u00eb\5,\27\2\u00ea\u00ec\t")
        buf.write("\7\2\2\u00eb\u00ea\3\2\2\2\u00eb\u00ec\3\2\2\2\u00ec\u00f0")
        buf.write("\3\2\2\2\u00ed\u00ef\7\22\2\2\u00ee\u00ed\3\2\2\2\u00ef")
        buf.write("\u00f2\3\2\2\2\u00f0\u00ee\3\2\2\2\u00f0\u00f1\3\2\2\2")
        buf.write("\u00f1/\3\2\2\2\u00f2\u00f0\3\2\2\2\u00f3\u00f4\7<\2\2")
        buf.write("\u00f4\61\3\2\2\2\u00f5\u00f6\7;\2\2\u00f6\63\3\2\2\2")
        buf.write("\u00f7\u00f8\7\t\2\2\u00f8\u00f9\5$\23\2\u00f9\u00fa\7")
        buf.write("<\2\2\u00fa\u0103\7\n\2\2\u00fb\u0104\5> \2\u00fc\u00fe")
        buf.write("\t\6\2\2\u00fd\u00fc\3\2\2\2\u00fd\u00fe\3\2\2\2\u00fe")
        buf.write("\u00ff\3\2\2\2\u00ff\u0101\5<\37\2\u0100\u0102\t\7\2\2")
        buf.write("\u0101\u0100\3\2\2\2\u0101\u0102\3\2\2\2\u0102\u0104\3")
        buf.write("\2\2\2\u0103\u00fb\3\2\2\2\u0103\u00fd\3\2\2\2\u0104\u0108")
        buf.write("\3\2\2\2\u0105\u0106\7\22\2\2\u0106\u0107\7\23\2\2\u0107")
        buf.write("\u0109\5.\30\2\u0108\u0105\3\2\2\2\u0109\u010a\3\2\2\2")
        buf.write("\u010a\u0108\3\2\2\2\u010a\u010b\3\2\2\2\u010b\65\3\2")
        buf.write("\2\2\u010c\u0115\7-\2\2\u010d\u0112\5:\36\2\u010e\u010f")
        buf.write("\7*\2\2\u010f\u0111\5:\36\2\u0110\u010e\3\2\2\2\u0111")
        buf.write("\u0114\3\2\2\2\u0112\u0110\3\2\2\2\u0112\u0113\3\2\2\2")
        buf.write("\u0113\u0116\3\2\2\2\u0114\u0112\3\2\2\2\u0115\u010d\3")
        buf.write("\2\2\2\u0115\u0116\3\2\2\2\u0116\u0118\3\2\2\2\u0117\u0119")
        buf.write("\7*\2\2\u0118\u0117\3\2\2\2\u0118\u0119\3\2\2\2\u0119")
        buf.write("\u0122\3\2\2\2\u011a\u011f\58\35\2\u011b\u011c\7*\2\2")
        buf.write("\u011c\u011e\58\35\2\u011d\u011b\3\2\2\2\u011e\u0121\3")
        buf.write("\2\2\2\u011f\u011d\3\2\2\2\u011f\u0120\3\2\2\2\u0120\u0123")
        buf.write("\3\2\2\2\u0121\u011f\3\2\2\2\u0122\u011a\3\2\2\2\u0122")
        buf.write("\u0123\3\2\2\2\u0123\u0124\3\2\2\2\u0124\u0125\7.\2\2")
        buf.write("\u0125\67\3\2\2\2\u0126\u0127\7<\2\2\u0127\u012e\7\b\2")
        buf.write("\2\u0128\u012f\5:\36\2\u0129\u012b\7/\2\2\u012a\u012c")
        buf.write("\5<\37\2\u012b\u012a\3\2\2\2\u012b\u012c\3\2\2\2\u012c")
        buf.write("\u012d\3\2\2\2\u012d\u012f\7\60\2\2\u012e\u0128\3\2\2")
        buf.write("\2\u012e\u0129\3\2\2\2\u012f9\3\2\2\2\u0130\u0133\5&\24")
        buf.write("\2\u0131\u0133\5@!\2\u0132\u0130\3\2\2\2\u0132\u0131\3")
        buf.write("\2\2\2\u0133;\3\2\2\2\u0134\u0139\5:\36\2\u0135\u0136")
        buf.write("\7*\2\2\u0136\u0138\5:\36\2\u0137\u0135\3\2\2\2\u0138")
        buf.write("\u013b\3\2\2\2\u0139\u0137\3\2\2\2\u0139\u013a\3\2\2\2")
        buf.write("\u013a=\3\2\2\2\u013b\u0139\3\2\2\2\u013c\u013d\7\13\2")
        buf.write("\2\u013d\u013e\7+\2\2\u013e\u0141\7\13\2\2\u013f\u0140")
        buf.write("\7+\2\2\u0140\u0142\7\13\2\2\u0141\u013f\3\2\2\2\u0141")
        buf.write("\u0142\3\2\2\2\u0142?\3\2\2\2\u0143\u0144\b!\1\2\u0144")
        buf.write("\u0145\7-\2\2\u0145\u0146\5@!\2\u0146\u0147\7.\2\2\u0147")
        buf.write("\u0158\3\2\2\2\u0148\u0149\t\b\2\2\u0149\u0158\5@!\13")
        buf.write("\u014a\u014b\5F$\2\u014b\u014c\7-\2\2\u014c\u014d\5@!")
        buf.write("\2\u014d\u014e\7.\2\2\u014e\u0158\3\2\2\2\u014f\u0158")
        buf.write("\5D#\2\u0150\u0158\t\t\2\2\u0151\u0152\7<\2\2\u0152\u0153")
        buf.write("\7/\2\2\u0153\u0154\5@!\2\u0154\u0155\7\60\2\2\u0155\u0158")
        buf.write("\3\2\2\2\u0156\u0158\5B\"\2\u0157\u0143\3\2\2\2\u0157")
        buf.write("\u0148\3\2\2\2\u0157\u014a\3\2\2\2\u0157\u014f\3\2\2\2")
        buf.write("\u0157\u0150\3\2\2\2\u0157\u0151\3\2\2\2\u0157\u0156\3")
        buf.write("\2\2\2\u0158\u0164\3\2\2\2\u0159\u015a\f\n\2\2\u015a\u015b")
        buf.write("\7\7\2\2\u015b\u0163\5@!\n\u015c\u015d\f\t\2\2\u015d\u015e")
        buf.write("\t\n\2\2\u015e\u0163\5@!\n\u015f\u0160\f\b\2\2\u0160\u0161")
        buf.write("\t\b\2\2\u0161\u0163\5@!\t\u0162\u0159\3\2\2\2\u0162\u015c")
        buf.write("\3\2\2\2\u0162\u015f\3\2\2\2\u0163\u0166\3\2\2\2\u0164")
        buf.write("\u0162\3\2\2\2\u0164\u0165\3\2\2\2\u0165A\3\2\2\2\u0166")
        buf.write("\u0164\3\2\2\2\u0167\u0168\7\61\2\2\u0168\u0169\7<\2\2")
        buf.write("\u0169\u016a\7\62\2\2\u016aC\3\2\2\2\u016b\u016c\t\13")
        buf.write("\2\2\u016cE\3\2\2\2\u016d\u016e\t\f\2\2\u016eG\3\2\2\2")
        buf.write(".KRYbhkpswy\u0089\u0090\u009c\u009e\u00a6\u00af\u00b5")
        buf.write("\u00b9\u00bd\u00ca\u00d3\u00db\u00e0\u00e3\u00e7\u00eb")
        buf.write("\u00f0\u00fd\u0101\u0103\u010a\u0112\u0115\u0118\u011f")
        buf.write("\u0122\u012b\u012e\u0132\u0139\u0141\u0157\u0162\u0164")
        return buf.getvalue()


class blackbirdParser ( Parser ):

    grammarFileName = "blackbird.g4"

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

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

    sharedContextCache = PredictionContextCache()

    literalNames = [ "<INVALID>", "'+'", "'-'", "'*'", "'/'", "'**'", "'='", 
                     "'for'", "'in'", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "'pi'", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "'name'", "'version'", "'target'", 
                     "'type'", "'include'", "'sqrt'", "'sin'", "'cos'", 
                     "'tan'", "'arcsin'", "'arccos'", "'arctan'", "'sinh'", 
                     "'cosh'", "'tanh'", "'arcsinh'", "'arccosh'", "'arctanh'", 
                     "'exp'", "'log'", "'.'", "','", "':'", "'\"'", "'('", 
                     "')'", "'['", "']'", "'{'", "'}'", "'|'", "'array'", 
                     "'float'", "'complex'", "'int'", "'str'", "'bool'" ]

    symbolicNames = [ "<INVALID>", "PLUS", "MINUS", "TIMES", "DIVIDE", "PWR", 
                      "ASSIGN", "FOR", "IN", "INT", "FLOAT", "COMPLEX", 
                      "STR", "BOOL", "SEQUENCE", "PI", "NEWLINE", "TAB", 
                      "SPACE", "PROGNAME", "VERSION", "TARGET", "PROGTYPE", 
                      "INCLUDE", "SQRT", "SIN", "COS", "TAN", "ARCSIN", 
                      "ARCCOS", "ARCTAN", "SINH", "COSH", "TANH", "ARCSINH", 
                      "ARCCOSH", "ARCTANH", "EXP", "LOG", "PERIOD", "COMMA", 
                      "COLON", "QUOTE", "LBRAC", "RBRAC", "LSQBRAC", "RSQBRAC", 
                      "LBRACE", "RBRACE", "APPLY", "TYPE_ARRAY", "TYPE_FLOAT", 
                      "TYPE_COMPLEX", "TYPE_INT", "TYPE_STR", "TYPE_BOOL", 
                      "REGREF", "MEASURE", "NAME", "DEVICE", "COMMENT", 
                      "ANY" ]

    RULE_start = 0
    RULE_metadatablock = 1
    RULE_declarename = 2
    RULE_programname = 3
    RULE_version = 4
    RULE_versionnumber = 5
    RULE_target = 6
    RULE_device = 7
    RULE_declaretype = 8
    RULE_programtype = 9
    RULE_include = 10
    RULE_program = 11
    RULE_expressionvar = 12
    RULE_arrayvar = 13
    RULE_name = 14
    RULE_invalid = 15
    RULE_reserved = 16
    RULE_vartype = 17
    RULE_nonnumeric = 18
    RULE_shape = 19
    RULE_arrayval = 20
    RULE_arrayrow = 21
    RULE_statement = 22
    RULE_operation = 23
    RULE_measure = 24
    RULE_forloop = 25
    RULE_arguments = 26
    RULE_kwarg = 27
    RULE_val = 28
    RULE_vallist = 29
    RULE_rangeval = 30
    RULE_expression = 31
    RULE_parameter = 32
    RULE_number = 33
    RULE_function = 34

    ruleNames =  [ "start", "metadatablock", "declarename", "programname", 
                   "version", "versionnumber", "target", "device", "declaretype", 
                   "programtype", "include", "program", "expressionvar", 
                   "arrayvar", "name", "invalid", "reserved", "vartype", 
                   "nonnumeric", "shape", "arrayval", "arrayrow", "statement", 
                   "operation", "measure", "forloop", "arguments", "kwarg", 
                   "val", "vallist", "rangeval", "expression", "parameter", 
                   "number", "function" ]

    EOF = Token.EOF
    PLUS=1
    MINUS=2
    TIMES=3
    DIVIDE=4
    PWR=5
    ASSIGN=6
    FOR=7
    IN=8
    INT=9
    FLOAT=10
    COMPLEX=11
    STR=12
    BOOL=13
    SEQUENCE=14
    PI=15
    NEWLINE=16
    TAB=17
    SPACE=18
    PROGNAME=19
    VERSION=20
    TARGET=21
    PROGTYPE=22
    INCLUDE=23
    SQRT=24
    SIN=25
    COS=26
    TAN=27
    ARCSIN=28
    ARCCOS=29
    ARCTAN=30
    SINH=31
    COSH=32
    TANH=33
    ARCSINH=34
    ARCCOSH=35
    ARCTANH=36
    EXP=37
    LOG=38
    PERIOD=39
    COMMA=40
    COLON=41
    QUOTE=42
    LBRAC=43
    RBRAC=44
    LSQBRAC=45
    RSQBRAC=46
    LBRACE=47
    RBRACE=48
    APPLY=49
    TYPE_ARRAY=50
    TYPE_FLOAT=51
    TYPE_COMPLEX=52
    TYPE_INT=53
    TYPE_STR=54
    TYPE_BOOL=55
    REGREF=56
    MEASURE=57
    NAME=58
    DEVICE=59
    COMMENT=60
    ANY=61

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




    class StartContext(ParserRuleContext):

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

        def metadatablock(self):
            return self.getTypedRuleContext(blackbirdParser.MetadatablockContext,0)


        def program(self):
            return self.getTypedRuleContext(blackbirdParser.ProgramContext,0)


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

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

        def getRuleIndex(self):
            return blackbirdParser.RULE_start

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

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




    def start(self):

        localctx = blackbirdParser.StartContext(self, self._ctx, self.state)
        self.enterRule(localctx, 0, self.RULE_start)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 73
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==blackbirdParser.NEWLINE:
                self.state = 70
                self.match(blackbirdParser.NEWLINE)
                self.state = 75
                self._errHandler.sync(self)
                _la = self._input.LA(1)

            self.state = 76
            self.metadatablock()
            self.state = 80
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,1,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 77
                    self.match(blackbirdParser.NEWLINE) 
                self.state = 82
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,1,self._ctx)

            self.state = 83
            self.program()
            self.state = 87
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==blackbirdParser.NEWLINE:
                self.state = 84
                self.match(blackbirdParser.NEWLINE)
                self.state = 89
                self._errHandler.sync(self)
                _la = self._input.LA(1)

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


    class MetadatablockContext(ParserRuleContext):

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser
            self._include = None # IncludeContext
            self.include_list = list() # of IncludeContexts

        def declarename(self):
            return self.getTypedRuleContext(blackbirdParser.DeclarenameContext,0)


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


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

        def target(self):
            return self.getTypedRuleContext(blackbirdParser.TargetContext,0)


        def declaretype(self):
            return self.getTypedRuleContext(blackbirdParser.DeclaretypeContext,0)


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


        def getRuleIndex(self):
            return blackbirdParser.RULE_metadatablock

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

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




    def metadatablock(self):

        localctx = blackbirdParser.MetadatablockContext(self, self._ctx, self.state)
        self.enterRule(localctx, 2, self.RULE_metadatablock)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 92
            self.declarename()
            self.state = 94 
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 93
                self.match(blackbirdParser.NEWLINE)
                self.state = 96 
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not (_la==blackbirdParser.NEWLINE):
                    break

            self.state = 98
            self.version()
            self.state = 105
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,5,self._ctx)
            if la_ == 1:
                self.state = 100 
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while True:
                    self.state = 99
                    self.match(blackbirdParser.NEWLINE)
                    self.state = 102 
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)
                    if not (_la==blackbirdParser.NEWLINE):
                        break

                self.state = 104
                self.target()


            self.state = 113
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,7,self._ctx)
            if la_ == 1:
                self.state = 108 
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while True:
                    self.state = 107
                    self.match(blackbirdParser.NEWLINE)
                    self.state = 110 
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)
                    if not (_la==blackbirdParser.NEWLINE):
                        break

                self.state = 112
                self.declaretype()


            self.state = 119
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,9,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 117
                    self._errHandler.sync(self)
                    token = self._input.LA(1)
                    if token in [blackbirdParser.NEWLINE]:
                        self.state = 115
                        self.match(blackbirdParser.NEWLINE)
                        pass
                    elif token in [blackbirdParser.INCLUDE]:
                        self.state = 116
                        localctx._include = self.include()
                        localctx.include_list.append(localctx._include)
                        pass
                    else:
                        raise NoViableAltException(self)
             
                self.state = 121
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,9,self._ctx)

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


    class DeclarenameContext(ParserRuleContext):

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

        def PROGNAME(self):
            return self.getToken(blackbirdParser.PROGNAME, 0)

        def programname(self):
            return self.getTypedRuleContext(blackbirdParser.ProgramnameContext,0)


        def getRuleIndex(self):
            return blackbirdParser.RULE_declarename

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

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




    def declarename(self):

        localctx = blackbirdParser.DeclarenameContext(self, self._ctx, self.state)
        self.enterRule(localctx, 4, self.RULE_declarename)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 122
            self.match(blackbirdParser.PROGNAME)
            self.state = 123
            self.programname()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class ProgramnameContext(ParserRuleContext):

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

        def NAME(self):
            return self.getToken(blackbirdParser.NAME, 0)

        def getRuleIndex(self):
            return blackbirdParser.RULE_programname

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

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




    def programname(self):

        localctx = blackbirdParser.ProgramnameContext(self, self._ctx, self.state)
        self.enterRule(localctx, 6, self.RULE_programname)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 125
            self.match(blackbirdParser.NAME)
        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):

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

        def VERSION(self):
            return self.getToken(blackbirdParser.VERSION, 0)

        def versionnumber(self):
            return self.getTypedRuleContext(blackbirdParser.VersionnumberContext,0)


        def getRuleIndex(self):
            return blackbirdParser.RULE_version

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

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




    def version(self):

        localctx = blackbirdParser.VersionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 8, self.RULE_version)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 127
            self.match(blackbirdParser.VERSION)
            self.state = 128
            self.versionnumber()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class VersionnumberContext(ParserRuleContext):

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

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

        def getRuleIndex(self):
            return blackbirdParser.RULE_versionnumber

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

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




    def versionnumber(self):

        localctx = blackbirdParser.VersionnumberContext(self, self._ctx, self.state)
        self.enterRule(localctx, 10, self.RULE_versionnumber)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 130
            self.match(blackbirdParser.FLOAT)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class TargetContext(ParserRuleContext):

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

        def TARGET(self):
            return self.getToken(blackbirdParser.TARGET, 0)

        def device(self):
            return self.getTypedRuleContext(blackbirdParser.DeviceContext,0)


        def arguments(self):
            return self.getTypedRuleContext(blackbirdParser.ArgumentsContext,0)


        def getRuleIndex(self):
            return blackbirdParser.RULE_target

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

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




    def target(self):

        localctx = blackbirdParser.TargetContext(self, self._ctx, self.state)
        self.enterRule(localctx, 12, self.RULE_target)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 132
            self.match(blackbirdParser.TARGET)
            self.state = 133
            self.device()
            self.state = 135
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==blackbirdParser.LBRAC:
                self.state = 134
                self.arguments()


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


    class DeviceContext(ParserRuleContext):

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

        def NAME(self):
            return self.getToken(blackbirdParser.NAME, 0)

        def DEVICE(self):
            return self.getToken(blackbirdParser.DEVICE, 0)

        def getRuleIndex(self):
            return blackbirdParser.RULE_device

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

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




    def device(self):

        localctx = blackbirdParser.DeviceContext(self, self._ctx, self.state)
        self.enterRule(localctx, 14, self.RULE_device)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 137
            _la = self._input.LA(1)
            if not(_la==blackbirdParser.NAME or _la==blackbirdParser.DEVICE):
                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 DeclaretypeContext(ParserRuleContext):

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

        def PROGTYPE(self):
            return self.getToken(blackbirdParser.PROGTYPE, 0)

        def programtype(self):
            return self.getTypedRuleContext(blackbirdParser.ProgramtypeContext,0)


        def arguments(self):
            return self.getTypedRuleContext(blackbirdParser.ArgumentsContext,0)


        def getRuleIndex(self):
            return blackbirdParser.RULE_declaretype

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

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




    def declaretype(self):

        localctx = blackbirdParser.DeclaretypeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 16, self.RULE_declaretype)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 139
            self.match(blackbirdParser.PROGTYPE)
            self.state = 140
            self.programtype()
            self.state = 142
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==blackbirdParser.LBRAC:
                self.state = 141
                self.arguments()


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


    class ProgramtypeContext(ParserRuleContext):

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

        def NAME(self):
            return self.getToken(blackbirdParser.NAME, 0)

        def getRuleIndex(self):
            return blackbirdParser.RULE_programtype

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

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




    def programtype(self):

        localctx = blackbirdParser.ProgramtypeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 18, self.RULE_programtype)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 144
            self.match(blackbirdParser.NAME)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class IncludeContext(ParserRuleContext):

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

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

        def STR(self):
            return self.getToken(blackbirdParser.STR, 0)

        def getRuleIndex(self):
            return blackbirdParser.RULE_include

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

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




    def include(self):

        localctx = blackbirdParser.IncludeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 20, self.RULE_include)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 146
            self.match(blackbirdParser.INCLUDE)
            self.state = 147
            self.match(blackbirdParser.STR)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class ProgramContext(ParserRuleContext):

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser
            self._forloop = None # ForloopContext
            self.for_list = list() # of ForloopContexts
            self._expressionvar = None # ExpressionvarContext
            self.var_list = list() # of ExpressionvarContexts
            self._arrayvar = None # ArrayvarContext
            self.array_list = list() # of ArrayvarContexts
            self._statement = None # StatementContext
            self.statement_list = list() # of StatementContexts

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

        def forloop(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(blackbirdParser.ForloopContext)
            else:
                return self.getTypedRuleContext(blackbirdParser.ForloopContext,i)


        def expressionvar(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(blackbirdParser.ExpressionvarContext)
            else:
                return self.getTypedRuleContext(blackbirdParser.ExpressionvarContext,i)


        def arrayvar(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(blackbirdParser.ArrayvarContext)
            else:
                return self.getTypedRuleContext(blackbirdParser.ArrayvarContext,i)


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


        def getRuleIndex(self):
            return blackbirdParser.RULE_program

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

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




    def program(self):

        localctx = blackbirdParser.ProgramContext(self, self._ctx, self.state)
        self.enterRule(localctx, 22, self.RULE_program)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 156
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,13,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 154
                    self._errHandler.sync(self)
                    la_ = self._interp.adaptivePredict(self._input,12,self._ctx)
                    if la_ == 1:
                        self.state = 149
                        self.match(blackbirdParser.NEWLINE)
                        pass

                    elif la_ == 2:
                        self.state = 150
                        localctx._forloop = self.forloop()
                        localctx.for_list.append(localctx._forloop)
                        pass

                    elif la_ == 3:
                        self.state = 151
                        localctx._expressionvar = self.expressionvar()
                        localctx.var_list.append(localctx._expressionvar)
                        pass

                    elif la_ == 4:
                        self.state = 152
                        localctx._arrayvar = self.arrayvar()
                        localctx.array_list.append(localctx._arrayvar)
                        pass

                    elif la_ == 5:
                        self.state = 153
                        localctx._statement = self.statement()
                        localctx.statement_list.append(localctx._statement)
                        pass

             
                self.state = 158
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,13,self._ctx)

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


    class ExpressionvarContext(ParserRuleContext):

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

        def vartype(self):
            return self.getTypedRuleContext(blackbirdParser.VartypeContext,0)


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


        def ASSIGN(self):
            return self.getToken(blackbirdParser.ASSIGN, 0)

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


        def nonnumeric(self):
            return self.getTypedRuleContext(blackbirdParser.NonnumericContext,0)


        def getRuleIndex(self):
            return blackbirdParser.RULE_expressionvar

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

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




    def expressionvar(self):

        localctx = blackbirdParser.ExpressionvarContext(self, self._ctx, self.state)
        self.enterRule(localctx, 24, self.RULE_expressionvar)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 159
            self.vartype()
            self.state = 160
            self.name()
            self.state = 161
            self.match(blackbirdParser.ASSIGN)
            self.state = 164
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [blackbirdParser.PLUS, blackbirdParser.MINUS, blackbirdParser.INT, blackbirdParser.FLOAT, blackbirdParser.COMPLEX, blackbirdParser.PI, blackbirdParser.SQRT, blackbirdParser.SIN, blackbirdParser.COS, blackbirdParser.TAN, blackbirdParser.ARCSIN, blackbirdParser.ARCCOS, blackbirdParser.ARCTAN, blackbirdParser.SINH, blackbirdParser.COSH, blackbirdParser.TANH, blackbirdParser.ARCSINH, blackbirdParser.ARCCOSH, blackbirdParser.ARCTANH, blackbirdParser.EXP, blackbirdParser.LOG, blackbirdParser.LBRAC, blackbirdParser.LBRACE, blackbirdParser.REGREF, blackbirdParser.NAME]:
                self.state = 162
                self.expression(0)
                pass
            elif token in [blackbirdParser.STR, blackbirdParser.BOOL]:
                self.state = 163
                self.nonnumeric()
                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 ArrayvarContext(ParserRuleContext):

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

        def vartype(self):
            return self.getTypedRuleContext(blackbirdParser.VartypeContext,0)


        def TYPE_ARRAY(self):
            return self.getToken(blackbirdParser.TYPE_ARRAY, 0)

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


        def ASSIGN(self):
            return self.getToken(blackbirdParser.ASSIGN, 0)

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

        def arrayval(self):
            return self.getTypedRuleContext(blackbirdParser.ArrayvalContext,0)


        def parameter(self):
            return self.getTypedRuleContext(blackbirdParser.ParameterContext,0)


        def LSQBRAC(self):
            return self.getToken(blackbirdParser.LSQBRAC, 0)

        def shape(self):
            return self.getTypedRuleContext(blackbirdParser.ShapeContext,0)


        def RSQBRAC(self):
            return self.getToken(blackbirdParser.RSQBRAC, 0)

        def getRuleIndex(self):
            return blackbirdParser.RULE_arrayvar

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

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




    def arrayvar(self):

        localctx = blackbirdParser.ArrayvarContext(self, self._ctx, self.state)
        self.enterRule(localctx, 26, self.RULE_arrayvar)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 166
            self.vartype()
            self.state = 167
            self.match(blackbirdParser.TYPE_ARRAY)
            self.state = 168
            self.name()
            self.state = 173
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==blackbirdParser.LSQBRAC:
                self.state = 169
                self.match(blackbirdParser.LSQBRAC)
                self.state = 170
                self.shape()
                self.state = 171
                self.match(blackbirdParser.RSQBRAC)


            self.state = 175
            self.match(blackbirdParser.ASSIGN)
            self.state = 176
            self.match(blackbirdParser.NEWLINE)
            self.state = 179
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [blackbirdParser.EOF, blackbirdParser.FOR, blackbirdParser.NEWLINE, blackbirdParser.TAB, blackbirdParser.TYPE_ARRAY, blackbirdParser.TYPE_FLOAT, blackbirdParser.TYPE_COMPLEX, blackbirdParser.TYPE_INT, blackbirdParser.TYPE_STR, blackbirdParser.TYPE_BOOL, blackbirdParser.MEASURE, blackbirdParser.NAME]:
                self.state = 177
                self.arrayval()
                pass
            elif token in [blackbirdParser.LBRACE]:
                self.state = 178
                self.parameter()
                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 NameContext(ParserRuleContext):

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

        def invalid(self):
            return self.getTypedRuleContext(blackbirdParser.InvalidContext,0)


        def NAME(self):
            return self.getToken(blackbirdParser.NAME, 0)

        def getRuleIndex(self):
            return blackbirdParser.RULE_name

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

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




    def name(self):

        localctx = blackbirdParser.NameContext(self, self._ctx, self.state)
        self.enterRule(localctx, 28, self.RULE_name)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 183
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [blackbirdParser.PROGNAME, blackbirdParser.VERSION, blackbirdParser.TARGET, blackbirdParser.PROGTYPE, blackbirdParser.REGREF]:
                self.state = 181
                self.invalid()
                pass
            elif token in [blackbirdParser.NAME]:
                self.state = 182
                self.match(blackbirdParser.NAME)
                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 InvalidContext(ParserRuleContext):

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

        def REGREF(self):
            return self.getToken(blackbirdParser.REGREF, 0)

        def reserved(self):
            return self.getTypedRuleContext(blackbirdParser.ReservedContext,0)


        def getRuleIndex(self):
            return blackbirdParser.RULE_invalid

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

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




    def invalid(self):

        localctx = blackbirdParser.InvalidContext(self, self._ctx, self.state)
        self.enterRule(localctx, 30, self.RULE_invalid)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 187
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [blackbirdParser.REGREF]:
                self.state = 185
                self.match(blackbirdParser.REGREF)
                pass
            elif token in [blackbirdParser.PROGNAME, blackbirdParser.VERSION, blackbirdParser.TARGET, blackbirdParser.PROGTYPE]:
                self.state = 186
                self.reserved()
                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 ReservedContext(ParserRuleContext):

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

        def PROGNAME(self):
            return self.getToken(blackbirdParser.PROGNAME, 0)

        def VERSION(self):
            return self.getToken(blackbirdParser.VERSION, 0)

        def TARGET(self):
            return self.getToken(blackbirdParser.TARGET, 0)

        def PROGTYPE(self):
            return self.getToken(blackbirdParser.PROGTYPE, 0)

        def getRuleIndex(self):
            return blackbirdParser.RULE_reserved

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

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




    def reserved(self):

        localctx = blackbirdParser.ReservedContext(self, self._ctx, self.state)
        self.enterRule(localctx, 32, self.RULE_reserved)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 189
            _la = self._input.LA(1)
            if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << blackbirdParser.PROGNAME) | (1 << blackbirdParser.VERSION) | (1 << blackbirdParser.TARGET) | (1 << blackbirdParser.PROGTYPE))) != 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 VartypeContext(ParserRuleContext):

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

        def TYPE_ARRAY(self):
            return self.getToken(blackbirdParser.TYPE_ARRAY, 0)

        def TYPE_FLOAT(self):
            return self.getToken(blackbirdParser.TYPE_FLOAT, 0)

        def TYPE_COMPLEX(self):
            return self.getToken(blackbirdParser.TYPE_COMPLEX, 0)

        def TYPE_INT(self):
            return self.getToken(blackbirdParser.TYPE_INT, 0)

        def TYPE_STR(self):
            return self.getToken(blackbirdParser.TYPE_STR, 0)

        def TYPE_BOOL(self):
            return self.getToken(blackbirdParser.TYPE_BOOL, 0)

        def getRuleIndex(self):
            return blackbirdParser.RULE_vartype

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

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




    def vartype(self):

        localctx = blackbirdParser.VartypeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 34, self.RULE_vartype)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 191
            _la = self._input.LA(1)
            if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << blackbirdParser.TYPE_ARRAY) | (1 << blackbirdParser.TYPE_FLOAT) | (1 << blackbirdParser.TYPE_COMPLEX) | (1 << blackbirdParser.TYPE_INT) | (1 << blackbirdParser.TYPE_STR) | (1 << blackbirdParser.TYPE_BOOL))) != 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 NonnumericContext(ParserRuleContext):

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

        def STR(self):
            return self.getToken(blackbirdParser.STR, 0)

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

        def getRuleIndex(self):
            return blackbirdParser.RULE_nonnumeric

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

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




    def nonnumeric(self):

        localctx = blackbirdParser.NonnumericContext(self, self._ctx, self.state)
        self.enterRule(localctx, 36, self.RULE_nonnumeric)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 193
            _la = self._input.LA(1)
            if not(_la==blackbirdParser.STR or _la==blackbirdParser.BOOL):
                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 ShapeContext(ParserRuleContext):

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

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

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

        def getRuleIndex(self):
            return blackbirdParser.RULE_shape

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

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




    def shape(self):

        localctx = blackbirdParser.ShapeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 38, self.RULE_shape)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 195
            self.match(blackbirdParser.INT)
            self.state = 200
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==blackbirdParser.COMMA:
                self.state = 196
                self.match(blackbirdParser.COMMA)
                self.state = 197
                self.match(blackbirdParser.INT)
                self.state = 202
                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 ArrayvalContext(ParserRuleContext):

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser
            self._arrayrow = None # ArrayrowContext
            self.row_list = list() # of ArrayrowContexts

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

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

        def arrayrow(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(blackbirdParser.ArrayrowContext)
            else:
                return self.getTypedRuleContext(blackbirdParser.ArrayrowContext,i)


        def getRuleIndex(self):
            return blackbirdParser.RULE_arrayval

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

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




    def arrayval(self):

        localctx = blackbirdParser.ArrayvalContext(self, self._ctx, self.state)
        self.enterRule(localctx, 40, self.RULE_arrayval)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 209
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==blackbirdParser.TAB:
                self.state = 203
                self.match(blackbirdParser.TAB)
                self.state = 204
                localctx._arrayrow = self.arrayrow()
                localctx.row_list.append(localctx._arrayrow)
                self.state = 205
                self.match(blackbirdParser.NEWLINE)
                self.state = 211
                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 ArrayrowContext(ParserRuleContext):

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


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

        def getRuleIndex(self):
            return blackbirdParser.RULE_arrayrow

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

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




    def arrayrow(self):

        localctx = blackbirdParser.ArrayrowContext(self, self._ctx, self.state)
        self.enterRule(localctx, 42, self.RULE_arrayrow)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 212
            self.expression(0)
            self.state = 217
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==blackbirdParser.COMMA:
                self.state = 213
                self.match(blackbirdParser.COMMA)
                self.state = 214
                self.expression(0)
                self.state = 219
                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 StatementContext(ParserRuleContext):

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

        def APPLY(self):
            return self.getToken(blackbirdParser.APPLY, 0)

        def arrayrow(self):
            return self.getTypedRuleContext(blackbirdParser.ArrayrowContext,0)


        def operation(self):
            return self.getTypedRuleContext(blackbirdParser.OperationContext,0)


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


        def arguments(self):
            return self.getTypedRuleContext(blackbirdParser.ArgumentsContext,0)


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

        def LBRAC(self):
            return self.getToken(blackbirdParser.LBRAC, 0)

        def LSQBRAC(self):
            return self.getToken(blackbirdParser.LSQBRAC, 0)

        def RBRAC(self):
            return self.getToken(blackbirdParser.RBRAC, 0)

        def RSQBRAC(self):
            return self.getToken(blackbirdParser.RSQBRAC, 0)

        def getRuleIndex(self):
            return blackbirdParser.RULE_statement

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

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




    def statement(self):

        localctx = blackbirdParser.StatementContext(self, self._ctx, self.state)
        self.enterRule(localctx, 44, self.RULE_statement)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 222
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [blackbirdParser.NAME]:
                self.state = 220
                self.operation()
                pass
            elif token in [blackbirdParser.MEASURE]:
                self.state = 221
                self.measure()
                pass
            else:
                raise NoViableAltException(self)

            self.state = 225
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==blackbirdParser.LBRAC:
                self.state = 224
                self.arguments()


            self.state = 227
            self.match(blackbirdParser.APPLY)
            self.state = 229
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,24,self._ctx)
            if la_ == 1:
                self.state = 228
                _la = self._input.LA(1)
                if not(_la==blackbirdParser.LBRAC or _la==blackbirdParser.LSQBRAC):
                    self._errHandler.recoverInline(self)
                else:
                    self._errHandler.reportMatch(self)
                    self.consume()


            self.state = 231
            self.arrayrow()
            self.state = 233
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==blackbirdParser.RBRAC or _la==blackbirdParser.RSQBRAC:
                self.state = 232
                _la = self._input.LA(1)
                if not(_la==blackbirdParser.RBRAC or _la==blackbirdParser.RSQBRAC):
                    self._errHandler.recoverInline(self)
                else:
                    self._errHandler.reportMatch(self)
                    self.consume()


            self.state = 238
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,26,self._ctx)
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt==1:
                    self.state = 235
                    self.match(blackbirdParser.NEWLINE) 
                self.state = 240
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,26,self._ctx)

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


    class OperationContext(ParserRuleContext):

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

        def NAME(self):
            return self.getToken(blackbirdParser.NAME, 0)

        def getRuleIndex(self):
            return blackbirdParser.RULE_operation

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

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




    def operation(self):

        localctx = blackbirdParser.OperationContext(self, self._ctx, self.state)
        self.enterRule(localctx, 46, self.RULE_operation)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 241
            self.match(blackbirdParser.NAME)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class MeasureContext(ParserRuleContext):

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

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

        def getRuleIndex(self):
            return blackbirdParser.RULE_measure

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

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




    def measure(self):

        localctx = blackbirdParser.MeasureContext(self, self._ctx, self.state)
        self.enterRule(localctx, 48, self.RULE_measure)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 243
            self.match(blackbirdParser.MEASURE)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class ForloopContext(ParserRuleContext):

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser
            self._statement = None # StatementContext
            self.statement_list = list() # of StatementContexts

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

        def vartype(self):
            return self.getTypedRuleContext(blackbirdParser.VartypeContext,0)


        def NAME(self):
            return self.getToken(blackbirdParser.NAME, 0)

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

        def rangeval(self):
            return self.getTypedRuleContext(blackbirdParser.RangevalContext,0)


        def vallist(self):
            return self.getTypedRuleContext(blackbirdParser.VallistContext,0)


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

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

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


        def LBRAC(self):
            return self.getToken(blackbirdParser.LBRAC, 0)

        def LSQBRAC(self):
            return self.getToken(blackbirdParser.LSQBRAC, 0)

        def RBRAC(self):
            return self.getToken(blackbirdParser.RBRAC, 0)

        def RSQBRAC(self):
            return self.getToken(blackbirdParser.RSQBRAC, 0)

        def getRuleIndex(self):
            return blackbirdParser.RULE_forloop

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

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




    def forloop(self):

        localctx = blackbirdParser.ForloopContext(self, self._ctx, self.state)
        self.enterRule(localctx, 50, self.RULE_forloop)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 245
            self.match(blackbirdParser.FOR)
            self.state = 246
            self.vartype()
            self.state = 247
            self.match(blackbirdParser.NAME)
            self.state = 248
            self.match(blackbirdParser.IN)
            self.state = 257
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,29,self._ctx)
            if la_ == 1:
                self.state = 249
                self.rangeval()
                pass

            elif la_ == 2:
                self.state = 251
                self._errHandler.sync(self)
                la_ = self._interp.adaptivePredict(self._input,27,self._ctx)
                if la_ == 1:
                    self.state = 250
                    _la = self._input.LA(1)
                    if not(_la==blackbirdParser.LBRAC or _la==blackbirdParser.LSQBRAC):
                        self._errHandler.recoverInline(self)
                    else:
                        self._errHandler.reportMatch(self)
                        self.consume()


                self.state = 253
                self.vallist()
                self.state = 255
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if _la==blackbirdParser.RBRAC or _la==blackbirdParser.RSQBRAC:
                    self.state = 254
                    _la = self._input.LA(1)
                    if not(_la==blackbirdParser.RBRAC or _la==blackbirdParser.RSQBRAC):
                        self._errHandler.recoverInline(self)
                    else:
                        self._errHandler.reportMatch(self)
                        self.consume()


                pass


            self.state = 262 
            self._errHandler.sync(self)
            _alt = 1
            while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                if _alt == 1:
                    self.state = 259
                    self.match(blackbirdParser.NEWLINE)
                    self.state = 260
                    self.match(blackbirdParser.TAB)
                    self.state = 261
                    localctx._statement = self.statement()
                    localctx.statement_list.append(localctx._statement)

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

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


    class ArgumentsContext(ParserRuleContext):

        def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
            super().__init__(parent, invokingState)
            self.parser = parser
            self._val = None # ValContext
            self.val_list = list() # of ValContexts
            self._kwarg = None # KwargContext
            self.kwarg_list = list() # of KwargContexts

        def LBRAC(self):
            return self.getToken(blackbirdParser.LBRAC, 0)

        def RBRAC(self):
            return self.getToken(blackbirdParser.RBRAC, 0)

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

        def val(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(blackbirdParser.ValContext)
            else:
                return self.getTypedRuleContext(blackbirdParser.ValContext,i)


        def kwarg(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(blackbirdParser.KwargContext)
            else:
                return self.getTypedRuleContext(blackbirdParser.KwargContext,i)


        def getRuleIndex(self):
            return blackbirdParser.RULE_arguments

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

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




    def arguments(self):

        localctx = blackbirdParser.ArgumentsContext(self, self._ctx, self.state)
        self.enterRule(localctx, 52, self.RULE_arguments)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 266
            self.match(blackbirdParser.LBRAC)
            self.state = 275
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,32,self._ctx)
            if la_ == 1:
                self.state = 267
                localctx._val = self.val()
                localctx.val_list.append(localctx._val)
                self.state = 272
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,31,self._ctx)
                while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
                    if _alt==1:
                        self.state = 268
                        self.match(blackbirdParser.COMMA)
                        self.state = 269
                        localctx._val = self.val()
                        localctx.val_list.append(localctx._val) 
                    self.state = 274
                    self._errHandler.sync(self)
                    _alt = self._interp.adaptivePredict(self._input,31,self._ctx)



            self.state = 278
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==blackbirdParser.COMMA:
                self.state = 277
                self.match(blackbirdParser.COMMA)


            self.state = 288
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==blackbirdParser.NAME:
                self.state = 280
                localctx._kwarg = self.kwarg()
                localctx.kwarg_list.append(localctx._kwarg)
                self.state = 285
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while _la==blackbirdParser.COMMA:
                    self.state = 281
                    self.match(blackbirdParser.COMMA)
                    self.state = 282
                    localctx._kwarg = self.kwarg()
                    localctx.kwarg_list.append(localctx._kwarg)
                    self.state = 287
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)



            self.state = 290
            self.match(blackbirdParser.RBRAC)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class KwargContext(ParserRuleContext):

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

        def NAME(self):
            return self.getToken(blackbirdParser.NAME, 0)

        def ASSIGN(self):
            return self.getToken(blackbirdParser.ASSIGN, 0)

        def val(self):
            return self.getTypedRuleContext(blackbirdParser.ValContext,0)


        def LSQBRAC(self):
            return self.getToken(blackbirdParser.LSQBRAC, 0)

        def RSQBRAC(self):
            return self.getToken(blackbirdParser.RSQBRAC, 0)

        def vallist(self):
            return self.getTypedRuleContext(blackbirdParser.VallistContext,0)


        def getRuleIndex(self):
            return blackbirdParser.RULE_kwarg

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

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




    def kwarg(self):

        localctx = blackbirdParser.KwargContext(self, self._ctx, self.state)
        self.enterRule(localctx, 54, self.RULE_kwarg)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 292
            self.match(blackbirdParser.NAME)
            self.state = 293
            self.match(blackbirdParser.ASSIGN)
            self.state = 300
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [blackbirdParser.PLUS, blackbirdParser.MINUS, blackbirdParser.INT, blackbirdParser.FLOAT, blackbirdParser.COMPLEX, blackbirdParser.STR, blackbirdParser.BOOL, blackbirdParser.PI, blackbirdParser.SQRT, blackbirdParser.SIN, blackbirdParser.COS, blackbirdParser.TAN, blackbirdParser.ARCSIN, blackbirdParser.ARCCOS, blackbirdParser.ARCTAN, blackbirdParser.SINH, blackbirdParser.COSH, blackbirdParser.TANH, blackbirdParser.ARCSINH, blackbirdParser.ARCCOSH, blackbirdParser.ARCTANH, blackbirdParser.EXP, blackbirdParser.LOG, blackbirdParser.LBRAC, blackbirdParser.LBRACE, blackbirdParser.REGREF, blackbirdParser.NAME]:
                self.state = 294
                self.val()
                pass
            elif token in [blackbirdParser.LSQBRAC]:
                self.state = 295
                self.match(blackbirdParser.LSQBRAC)
                self.state = 297
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << blackbirdParser.PLUS) | (1 << blackbirdParser.MINUS) | (1 << blackbirdParser.INT) | (1 << blackbirdParser.FLOAT) | (1 << blackbirdParser.COMPLEX) | (1 << blackbirdParser.STR) | (1 << blackbirdParser.BOOL) | (1 << blackbirdParser.PI) | (1 << blackbirdParser.SQRT) | (1 << blackbirdParser.SIN) | (1 << blackbirdParser.COS) | (1 << blackbirdParser.TAN) | (1 << blackbirdParser.ARCSIN) | (1 << blackbirdParser.ARCCOS) | (1 << blackbirdParser.ARCTAN) | (1 << blackbirdParser.SINH) | (1 << blackbirdParser.COSH) | (1 << blackbirdParser.TANH) | (1 << blackbirdParser.ARCSINH) | (1 << blackbirdParser.ARCCOSH) | (1 << blackbirdParser.ARCTANH) | (1 << blackbirdParser.EXP) | (1 << blackbirdParser.LOG) | (1 << blackbirdParser.LBRAC) | (1 << blackbirdParser.LBRACE) | (1 << blackbirdParser.REGREF) | (1 << blackbirdParser.NAME))) != 0):
                    self.state = 296
                    self.vallist()


                self.state = 299
                self.match(blackbirdParser.RSQBRAC)
                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 ValContext(ParserRuleContext):

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

        def nonnumeric(self):
            return self.getTypedRuleContext(blackbirdParser.NonnumericContext,0)


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


        def getRuleIndex(self):
            return blackbirdParser.RULE_val

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

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




    def val(self):

        localctx = blackbirdParser.ValContext(self, self._ctx, self.state)
        self.enterRule(localctx, 56, self.RULE_val)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 304
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [blackbirdParser.STR, blackbirdParser.BOOL]:
                self.state = 302
                self.nonnumeric()
                pass
            elif token in [blackbirdParser.PLUS, blackbirdParser.MINUS, blackbirdParser.INT, blackbirdParser.FLOAT, blackbirdParser.COMPLEX, blackbirdParser.PI, blackbirdParser.SQRT, blackbirdParser.SIN, blackbirdParser.COS, blackbirdParser.TAN, blackbirdParser.ARCSIN, blackbirdParser.ARCCOS, blackbirdParser.ARCTAN, blackbirdParser.SINH, blackbirdParser.COSH, blackbirdParser.TANH, blackbirdParser.ARCSINH, blackbirdParser.ARCCOSH, blackbirdParser.ARCTANH, blackbirdParser.EXP, blackbirdParser.LOG, blackbirdParser.LBRAC, blackbirdParser.LBRACE, blackbirdParser.REGREF, blackbirdParser.NAME]:
                self.state = 303
                self.expression(0)
                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 VallistContext(ParserRuleContext):

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

        def val(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(blackbirdParser.ValContext)
            else:
                return self.getTypedRuleContext(blackbirdParser.ValContext,i)


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

        def getRuleIndex(self):
            return blackbirdParser.RULE_vallist

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

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




    def vallist(self):

        localctx = blackbirdParser.VallistContext(self, self._ctx, self.state)
        self.enterRule(localctx, 58, self.RULE_vallist)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 306
            self.val()
            self.state = 311
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==blackbirdParser.COMMA:
                self.state = 307
                self.match(blackbirdParser.COMMA)
                self.state = 308
                self.val()
                self.state = 313
                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 RangevalContext(ParserRuleContext):

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

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

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

        def getRuleIndex(self):
            return blackbirdParser.RULE_rangeval

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

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




    def rangeval(self):

        localctx = blackbirdParser.RangevalContext(self, self._ctx, self.state)
        self.enterRule(localctx, 60, self.RULE_rangeval)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 314
            self.match(blackbirdParser.INT)
            self.state = 315
            self.match(blackbirdParser.COLON)
            self.state = 316
            self.match(blackbirdParser.INT)
            self.state = 319
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==blackbirdParser.COLON:
                self.state = 317
                self.match(blackbirdParser.COLON)
                self.state = 318
                self.match(blackbirdParser.INT)


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


    class ExpressionContext(ParserRuleContext):

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


        def getRuleIndex(self):
            return blackbirdParser.RULE_expression

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


    class ParameterLabelContext(ExpressionContext):

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

        def parameter(self):
            return self.getTypedRuleContext(blackbirdParser.ParameterContext,0)


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

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


    class BracketsLabelContext(ExpressionContext):

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

        def LBRAC(self):
            return self.getToken(blackbirdParser.LBRAC, 0)
        def expression(self):
            return self.getTypedRuleContext(blackbirdParser.ExpressionContext,0)

        def RBRAC(self):
            return self.getToken(blackbirdParser.RBRAC, 0)

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

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


    class SignLabelContext(ExpressionContext):

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

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

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

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

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


    class PowerLabelContext(ExpressionContext):

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

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

        def PWR(self):
            return self.getToken(blackbirdParser.PWR, 0)

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

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


    class NumberLabelContext(ExpressionContext):

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

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


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

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


    class VariableLabelContext(ExpressionContext):

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

        def REGREF(self):
            return self.getToken(blackbirdParser.REGREF, 0)
        def NAME(self):
            return self.getToken(blackbirdParser.NAME, 0)

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

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


    class ArrayIdxLabelContext(ExpressionContext):

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

        def NAME(self):
            return self.getToken(blackbirdParser.NAME, 0)
        def LSQBRAC(self):
            return self.getToken(blackbirdParser.LSQBRAC, 0)
        def expression(self):
            return self.getTypedRuleContext(blackbirdParser.ExpressionContext,0)

        def RSQBRAC(self):
            return self.getToken(blackbirdParser.RSQBRAC, 0)

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

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


    class MulLabelContext(ExpressionContext):

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

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

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

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

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


    class FunctionLabelContext(ExpressionContext):

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

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

        def LBRAC(self):
            return self.getToken(blackbirdParser.LBRAC, 0)
        def expression(self):
            return self.getTypedRuleContext(blackbirdParser.ExpressionContext,0)

        def RBRAC(self):
            return self.getToken(blackbirdParser.RBRAC, 0)

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

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


    class AddLabelContext(ExpressionContext):

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

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

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

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

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



    def expression(self, _p:int=0):
        _parentctx = self._ctx
        _parentState = self.state
        localctx = blackbirdParser.ExpressionContext(self, self._ctx, _parentState)
        _prevctx = localctx
        _startState = 62
        self.enterRecursionRule(localctx, 62, self.RULE_expression, _p)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 341
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,41,self._ctx)
            if la_ == 1:
                localctx = blackbirdParser.BracketsLabelContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx

                self.state = 322
                self.match(blackbirdParser.LBRAC)
                self.state = 323
                self.expression(0)
                self.state = 324
                self.match(blackbirdParser.RBRAC)
                pass

            elif la_ == 2:
                localctx = blackbirdParser.SignLabelContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 326
                _la = self._input.LA(1)
                if not(_la==blackbirdParser.PLUS or _la==blackbirdParser.MINUS):
                    self._errHandler.recoverInline(self)
                else:
                    self._errHandler.reportMatch(self)
                    self.consume()
                self.state = 327
                self.expression(9)
                pass

            elif la_ == 3:
                localctx = blackbirdParser.FunctionLabelContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 328
                self.function()
                self.state = 329
                self.match(blackbirdParser.LBRAC)
                self.state = 330
                self.expression(0)
                self.state = 331
                self.match(blackbirdParser.RBRAC)
                pass

            elif la_ == 4:
                localctx = blackbirdParser.NumberLabelContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 333
                self.number()
                pass

            elif la_ == 5:
                localctx = blackbirdParser.VariableLabelContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 334
                _la = self._input.LA(1)
                if not(_la==blackbirdParser.REGREF or _la==blackbirdParser.NAME):
                    self._errHandler.recoverInline(self)
                else:
                    self._errHandler.reportMatch(self)
                    self.consume()
                pass

            elif la_ == 6:
                localctx = blackbirdParser.ArrayIdxLabelContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 335
                self.match(blackbirdParser.NAME)
                self.state = 336
                self.match(blackbirdParser.LSQBRAC)
                self.state = 337
                self.expression(0)
                self.state = 338
                self.match(blackbirdParser.RSQBRAC)
                pass

            elif la_ == 7:
                localctx = blackbirdParser.ParameterLabelContext(self, localctx)
                self._ctx = localctx
                _prevctx = localctx
                self.state = 340
                self.parameter()
                pass


            self._ctx.stop = self._input.LT(-1)
            self.state = 354
            self._errHandler.sync(self)
            _alt = self._interp.adaptivePredict(self._input,43,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 = 352
                    self._errHandler.sync(self)
                    la_ = self._interp.adaptivePredict(self._input,42,self._ctx)
                    if la_ == 1:
                        localctx = blackbirdParser.PowerLabelContext(self, blackbirdParser.ExpressionContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expression)
                        self.state = 343
                        if not self.precpred(self._ctx, 8):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 8)")
                        self.state = 344
                        self.match(blackbirdParser.PWR)
                        self.state = 345
                        self.expression(8)
                        pass

                    elif la_ == 2:
                        localctx = blackbirdParser.MulLabelContext(self, blackbirdParser.ExpressionContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expression)
                        self.state = 346
                        if not self.precpred(self._ctx, 7):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 7)")
                        self.state = 347
                        _la = self._input.LA(1)
                        if not(_la==blackbirdParser.TIMES or _la==blackbirdParser.DIVIDE):
                            self._errHandler.recoverInline(self)
                        else:
                            self._errHandler.reportMatch(self)
                            self.consume()
                        self.state = 348
                        self.expression(8)
                        pass

                    elif la_ == 3:
                        localctx = blackbirdParser.AddLabelContext(self, blackbirdParser.ExpressionContext(self, _parentctx, _parentState))
                        self.pushNewRecursionContext(localctx, _startState, self.RULE_expression)
                        self.state = 349
                        if not self.precpred(self._ctx, 6):
                            from antlr4.error.Errors import FailedPredicateException
                            raise FailedPredicateException(self, "self.precpred(self._ctx, 6)")
                        self.state = 350
                        _la = self._input.LA(1)
                        if not(_la==blackbirdParser.PLUS or _la==blackbirdParser.MINUS):
                            self._errHandler.recoverInline(self)
                        else:
                            self._errHandler.reportMatch(self)
                            self.consume()
                        self.state = 351
                        self.expression(7)
                        pass

             
                self.state = 356
                self._errHandler.sync(self)
                _alt = self._interp.adaptivePredict(self._input,43,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 ParameterContext(ParserRuleContext):

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

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

        def NAME(self):
            return self.getToken(blackbirdParser.NAME, 0)

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

        def getRuleIndex(self):
            return blackbirdParser.RULE_parameter

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

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




    def parameter(self):

        localctx = blackbirdParser.ParameterContext(self, self._ctx, self.state)
        self.enterRule(localctx, 64, self.RULE_parameter)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 357
            self.match(blackbirdParser.LBRACE)
            self.state = 358
            self.match(blackbirdParser.NAME)
            self.state = 359
            self.match(blackbirdParser.RBRACE)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx


    class NumberContext(ParserRuleContext):

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

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

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

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

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

        def getRuleIndex(self):
            return blackbirdParser.RULE_number

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

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




    def number(self):

        localctx = blackbirdParser.NumberContext(self, self._ctx, self.state)
        self.enterRule(localctx, 66, self.RULE_number)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 361
            _la = self._input.LA(1)
            if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << blackbirdParser.INT) | (1 << blackbirdParser.FLOAT) | (1 << blackbirdParser.COMPLEX) | (1 << blackbirdParser.PI))) != 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 FunctionContext(ParserRuleContext):

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

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

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

        def TAN(self):
            return self.getToken(blackbirdParser.TAN, 0)

        def ARCSIN(self):
            return self.getToken(blackbirdParser.ARCSIN, 0)

        def ARCCOS(self):
            return self.getToken(blackbirdParser.ARCCOS, 0)

        def ARCTAN(self):
            return self.getToken(blackbirdParser.ARCTAN, 0)

        def SINH(self):
            return self.getToken(blackbirdParser.SINH, 0)

        def COSH(self):
            return self.getToken(blackbirdParser.COSH, 0)

        def TANH(self):
            return self.getToken(blackbirdParser.TANH, 0)

        def ARCSINH(self):
            return self.getToken(blackbirdParser.ARCSINH, 0)

        def ARCCOSH(self):
            return self.getToken(blackbirdParser.ARCCOSH, 0)

        def ARCTANH(self):
            return self.getToken(blackbirdParser.ARCTANH, 0)

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

        def LOG(self):
            return self.getToken(blackbirdParser.LOG, 0)

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

        def getRuleIndex(self):
            return blackbirdParser.RULE_function

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

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




    def function(self):

        localctx = blackbirdParser.FunctionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 68, self.RULE_function)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 363
            _la = self._input.LA(1)
            if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << blackbirdParser.SQRT) | (1 << blackbirdParser.SIN) | (1 << blackbirdParser.COS) | (1 << blackbirdParser.TAN) | (1 << blackbirdParser.ARCSIN) | (1 << blackbirdParser.ARCCOS) | (1 << blackbirdParser.ARCTAN) | (1 << blackbirdParser.SINH) | (1 << blackbirdParser.COSH) | (1 << blackbirdParser.TANH) | (1 << blackbirdParser.ARCSINH) | (1 << blackbirdParser.ARCCOSH) | (1 << blackbirdParser.ARCTANH) | (1 << blackbirdParser.EXP) | (1 << blackbirdParser.LOG))) != 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



    def sempred(self, localctx:RuleContext, ruleIndex:int, predIndex:int):
        if self._predicates == None:
            self._predicates = dict()
        self._predicates[31] = 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, 8)
         

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

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




