<reponame>michaelgundlach/7billionhumans
# Generated from SBHasm.g4 by ANTLR 4.7.1
# encoding: utf-8
import sys
from io import StringIO

from antlr4 import *
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("\u0102\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!\3\2\6\2D\n\2\r\2\16\2E\3\3\3\3")
        buf.write("\3\3\3\3\3\3\5\3M\n\3\3\3\3\3\3\4\3\4\3\4\3\4\3\4\3\4")
        buf.write("\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\5\4a\n\4\3\5")
        buf.write("\3\5\3\5\5\5f\n\5\3\6\3\6\3\6\5\6k\n\6\3\7\3\7\3\7\5\7")
        buf.write("p\n\7\3\b\3\b\3\t\3\t\3\t\3\t\3\t\6\ty\n\t\r\t\16\tz\3")
        buf.write("\t\3\t\3\t\6\t\u0080\n\t\r\t\16\t\u0081\5\t\u0084\n\t")
        buf.write("\3\t\3\t\3\n\3\n\3\n\3\n\7\n\u008c\n\n\f\n\16\n\u008f")
        buf.write("\13\n\3\13\3\13\3\13\5\13\u0094\n\13\3\13\3\13\3\13\3")
        buf.write("\13\5\13\u009a\n\13\3\f\3\f\3\r\3\r\3\r\3\r\5\r\u00a2")
        buf.write("\n\r\3\16\3\16\3\17\3\17\3\17\3\17\5\17\u00aa\n\17\3\20")
        buf.write("\3\20\3\20\3\20\3\20\3\20\3\20\5\20\u00b3\n\20\3\20\3")
        buf.write("\20\3\20\3\20\3\20\5\20\u00ba\n\20\3\21\3\21\3\21\3\21")
        buf.write("\3\21\3\21\3\21\3\21\5\21\u00c4\n\21\3\22\3\22\3\22\5")
        buf.write("\22\u00c9\n\22\3\23\3\23\3\23\5\23\u00ce\n\23\3\24\3\24")
        buf.write("\3\24\3\24\3\24\3\25\3\25\3\26\3\26\3\27\3\27\3\27\3\30")
        buf.write("\3\30\3\30\3\31\3\31\3\31\3\32\3\32\3\32\5\32\u00e5\n")
        buf.write("\32\3\32\3\32\3\33\3\33\3\34\3\34\3\35\3\35\3\36\3\36")
        buf.write("\3\37\3\37\3 \3 \3!\3!\3!\3!\3!\3!\3!\6!\u00fc\n!\r!\16")
        buf.write("!\u00fd\3!\3!\3!\2\2\"\2\4\6\b\n\f\16\20\22\24\26\30\32")
        buf.write("\34\36 \"$&(*,.\60\62\64\668:<>@\2\3\3\2 !\2\u0115\2C")
        buf.write("\3\2\2\2\4L\3\2\2\2\6`\3\2\2\2\bb\3\2\2\2\ng\3\2\2\2\f")
        buf.write("l\3\2\2\2\16q\3\2\2\2\20s\3\2\2\2\22\u0087\3\2\2\2\24")
        buf.write("\u0093\3\2\2\2\26\u009b\3\2\2\2\30\u00a1\3\2\2\2\32\u00a3")
        buf.write("\3\2\2\2\34\u00a5\3\2\2\2\36\u00ab\3\2\2\2 \u00bb\3\2")
        buf.write("\2\2\"\u00c5\3\2\2\2$\u00ca\3\2\2\2&\u00cf\3\2\2\2(\u00d4")
        buf.write("\3\2\2\2*\u00d6\3\2\2\2,\u00d8\3\2\2\2.\u00db\3\2\2\2")
        buf.write("\60\u00de\3\2\2\2\62\u00e1\3\2\2\2\64\u00e8\3\2\2\2\66")
        buf.write("\u00ea\3\2\2\28\u00ec\3\2\2\2:\u00ee\3\2\2\2<\u00f0\3")
        buf.write("\2\2\2>\u00f2\3\2\2\2@\u00f4\3\2\2\2BD\5\4\3\2CB\3\2\2")
        buf.write("\2DE\3\2\2\2EC\3\2\2\2EF\3\2\2\2F\3\3\2\2\2GM\5\6\4\2")
        buf.write("HM\5\26\f\2IM\5\16\b\2JM\5,\27\2KM\5.\30\2LG\3\2\2\2L")
        buf.write("H\3\2\2\2LI\3\2\2\2LJ\3\2\2\2LK\3\2\2\2LM\3\2\2\2MN\3")
        buf.write("\2\2\2NO\7\34\2\2O\5\3\2\2\2Pa\7\5\2\2Qa\5\n\6\2Ra\5\b")
        buf.write("\5\2Sa\5\20\t\2Ta\5\34\17\2Ua\5(\25\2Va\5\36\20\2Wa\5")
        buf.write(" \21\2Xa\5\"\22\2Ya\5$\23\2Za\5&\24\2[a\7\23\2\2\\a\5")
        buf.write("\b\5\2]a\5\60\31\2^a\5\62\32\2_a\5@!\2`P\3\2\2\2`Q\3\2")
        buf.write("\2\2`R\3\2\2\2`S\3\2\2\2`T\3\2\2\2`U\3\2\2\2`V\3\2\2\2")
        buf.write("`W\3\2\2\2`X\3\2\2\2`Y\3\2\2\2`Z\3\2\2\2`[\3\2\2\2`\\")
        buf.write("\3\2\2\2`]\3\2\2\2`^\3\2\2\2`_\3\2\2\2a\7\3\2\2\2be\7")
        buf.write("\7\2\2cf\5\64\33\2df\5\66\34\2ec\3\2\2\2ed\3\2\2\2ef\3")
        buf.write("\2\2\2f\t\3\2\2\2gj\7\6\2\2hk\5\f\7\2ik\5\66\34\2jh\3")
        buf.write("\2\2\2ji\3\2\2\2k\13\3\2\2\2lo\5\64\33\2mn\7\36\2\2np")
        buf.write("\5\f\7\2om\3\2\2\2op\3\2\2\2p\r\3\2\2\2qr\7\33\2\2r\17")
        buf.write("\3\2\2\2st\7\b\2\2tu\5\22\n\2uv\7\35\2\2vx\7\34\2\2wy")
        buf.write("\5\4\3\2xw\3\2\2\2yz\3\2\2\2zx\3\2\2\2z{\3\2\2\2{\u0083")
        buf.write("\3\2\2\2|}\5*\26\2}\177\7\34\2\2~\u0080\5\4\3\2\177~\3")
        buf.write("\2\2\2\u0080\u0081\3\2\2\2\u0081\177\3\2\2\2\u0081\u0082")
        buf.write("\3\2\2\2\u0082\u0084\3\2\2\2\u0083|\3\2\2\2\u0083\u0084")
        buf.write("\3\2\2\2\u0084\u0085\3\2\2\2\u0085\u0086\7\n\2\2\u0086")
        buf.write("\21\3\2\2\2\u0087\u008d\5\24\13\2\u0088\u0089\t\2\2\2")
        buf.write("\u0089\u008a\7\34\2\2\u008a\u008c\5\24\13\2\u008b\u0088")
        buf.write("\3\2\2\2\u008c\u008f\3\2\2\2\u008d\u008b\3\2\2\2\u008d")
        buf.write("\u008e\3\2\2\2\u008e\23\3\2\2\2\u008f\u008d\3\2\2\2\u0090")
        buf.write("\u0094\5\64\33\2\u0091\u0094\5\30\r\2\u0092\u0094\58\35")
        buf.write("\2\u0093\u0090\3\2\2\2\u0093\u0091\3\2\2\2\u0093\u0092")
        buf.write("\3\2\2\2\u0094\u0095\3\2\2\2\u0095\u0099\7\27\2\2\u0096")
        buf.write("\u009a\5\64\33\2\u0097\u009a\5\30\r\2\u0098\u009a\58\35")
        buf.write("\2\u0099\u0096\3\2\2\2\u0099\u0097\3\2\2\2\u0099\u0098")
        buf.write("\3\2\2\2\u009a\25\3\2\2\2\u009b\u009c\7\3\2\2\u009c\27")
        buf.write("\3\2\2\2\u009d\u00a2\5\32\16\2\u009e\u00a2\5\66\34\2\u009f")
        buf.write("\u00a2\7\22\2\2\u00a0\u00a2\7\24\2\2\u00a1\u009d\3\2\2")
        buf.write("\2\u00a1\u009e\3\2\2\2\u00a1\u009f\3\2\2\2\u00a1\u00a0")
        buf.write("\3\2\2\2\u00a2\31\3\2\2\2\u00a3\u00a4\7\25\2\2\u00a4\33")
        buf.write("\3\2\2\2\u00a5\u00a9\7\f\2\2\u00a6\u00aa\58\35\2\u00a7")
        buf.write("\u00aa\5\64\33\2\u00a8\u00aa\5\66\34\2\u00a9\u00a6\3\2")
        buf.write("\2\2\u00a9\u00a7\3\2\2\2\u00a9\u00a8\3\2\2\2\u00aa\35")
        buf.write("\3\2\2\2\u00ab\u00ac\5\66\34\2\u00ac\u00ad\7\37\2\2\u00ad")
        buf.write("\u00b2\7\r\2\2\u00ae\u00b3\5\64\33\2\u00af\u00b3\5\66")
        buf.write("\34\2\u00b0\u00b3\7\22\2\2\u00b1\u00b3\58\35\2\u00b2\u00ae")
        buf.write("\3\2\2\2\u00b2\u00af\3\2\2\2\u00b2\u00b0\3\2\2\2\u00b2")
        buf.write("\u00b1\3\2\2\2\u00b3\u00b4\3\2\2\2\u00b4\u00b9\5:\36\2")
        buf.write("\u00b5\u00ba\5\64\33\2\u00b6\u00ba\5\66\34\2\u00b7\u00ba")
        buf.write("\7\22\2\2\u00b8\u00ba\58\35\2\u00b9\u00b5\3\2\2\2\u00b9")
        buf.write("\u00b6\3\2\2\2\u00b9\u00b7\3\2\2\2\u00b9\u00b8\3\2\2\2")
        buf.write("\u00ba\37\3\2\2\2\u00bb\u00bc\5\66\34\2\u00bc\u00bd\7")
        buf.write("\37\2\2\u00bd\u00c3\7\16\2\2\u00be\u00c4\5\64\33\2\u00bf")
        buf.write("\u00c4\5\66\34\2\u00c0\u00c4\7\22\2\2\u00c1\u00c4\58\35")
        buf.write("\2\u00c2\u00c4\7\24\2\2\u00c3\u00be\3\2\2\2\u00c3\u00bf")
        buf.write("\3\2\2\2\u00c3\u00c0\3\2\2\2\u00c3\u00c1\3\2\2\2\u00c3")
        buf.write("\u00c2\3\2\2\2\u00c4!\3\2\2\2\u00c5\u00c8\7\17\2\2\u00c6")
        buf.write("\u00c9\5\64\33\2\u00c7\u00c9\5\66\34\2\u00c8\u00c6\3\2")
        buf.write("\2\2\u00c8\u00c7\3\2\2\2\u00c9#\3\2\2\2\u00ca\u00cd\7")
        buf.write("\20\2\2\u00cb\u00ce\5\64\33\2\u00cc\u00ce\5\66\34\2\u00cd")
        buf.write("\u00cb\3\2\2\2\u00cd\u00cc\3\2\2\2\u00ce%\3\2\2\2\u00cf")
        buf.write("\u00d0\5\66\34\2\u00d0\u00d1\7\37\2\2\u00d1\u00d2\7\21")
        buf.write("\2\2\u00d2\u00d3\5\32\16\2\u00d3\'\3\2\2\2\u00d4\u00d5")
        buf.write("\7\13\2\2\u00d5)\3\2\2\2\u00d6\u00d7\7\t\2\2\u00d7+\3")
        buf.write("\2\2\2\u00d8\u00d9\7(\2\2\u00d9\u00da\58\35\2\u00da-\3")
        buf.write("\2\2\2\u00db\u00dc\7)\2\2\u00dc\u00dd\58\35\2\u00dd/\3")
        buf.write("\2\2\2\u00de\u00df\7\"\2\2\u00df\u00e0\5<\37\2\u00e0\61")
        buf.write("\3\2\2\2\u00e1\u00e4\7#\2\2\u00e2\u00e5\5> \2\u00e3\u00e5")
        buf.write("\5\64\33\2\u00e4\u00e2\3\2\2\2\u00e4\u00e3\3\2\2\2\u00e5")
        buf.write("\u00e6\3\2\2\2\u00e6\u00e7\5<\37\2\u00e7\63\3\2\2\2\u00e8")
        buf.write("\u00e9\7\32\2\2\u00e9\65\3\2\2\2\u00ea\u00eb\7\26\2\2")
        buf.write("\u00eb\67\3\2\2\2\u00ec\u00ed\7\31\2\2\u00ed9\3\2\2\2")
        buf.write("\u00ee\u00ef\7\30\2\2\u00ef;\3\2\2\2\u00f0\u00f1\7%\2")
        buf.write("\2\u00f1=\3\2\2\2\u00f2\u00f3\7$\2\2\u00f3?\3\2\2\2\u00f4")
        buf.write("\u00f5\5\66\34\2\u00f5\u00f6\7\37\2\2\u00f6\u00f7\7&\2")
        buf.write("\2\u00f7\u00f8\5\f\7\2\u00f8\u00f9\7\35\2\2\u00f9\u00fb")
        buf.write("\7\34\2\2\u00fa\u00fc\5\4\3\2\u00fb\u00fa\3\2\2\2\u00fc")
        buf.write("\u00fd\3\2\2\2\u00fd\u00fb\3\2\2\2\u00fd\u00fe\3\2\2\2")
        buf.write("\u00fe\u00ff\3\2\2\2\u00ff\u0100\7\'\2\2\u0100A\3\2\2")
        buf.write("\2\27EL`ejoz\u0081\u0083\u008d\u0093\u0099\u00a1\u00a9")
        buf.write("\u00b2\u00b9\u00c3\u00c8\u00cd\u00e4\u00fd")
        return buf.getvalue()


class SBHasmParser ( Parser ):

    grammarFileName = "SBHasm.g4"

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

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

    sharedContextCache = PredictionContextCache()

    literalNames = [ "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "'step'", "'pickup'", "'if'", "'else:'", "'endif'", 
                     "'drop'", "'write'", "'calc'", "'set'", "'takefrom'", 
                     "'giveto'", "'nearest'", "'myitem'", "'end'", "'nothing'", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "':'", "','", "'='", "'and'", "'or'", "'listenfor'", 
                     "'tell'", "'everyone'", "<INVALID>", "'foreachdir'", 
                     "'endfor'", "'comment'", "'DEFINE COMMENT'" ]

    symbolicNames = [ "<INVALID>", "COMMENT", "WHITESPACE", "JUMP", "STEP", 
                      "PICKUP", "IF", "ELSE", "ENDIF", "DROP", "WRITE", 
                      "CALC", "SET", "TAKE", "GIVE", "NEAREST", "MYITEM", 
                      "END", "NOTHING", "ITEM", "MEM", "COMPARE", "CALC_OP", 
                      "NUMBER", "DIRECTION", "LABEL", "EOL", "COLON", "COMMA", 
                      "EQUAL", "AND", "OR", "LISTEN", "TELL", "EVERYONE", 
                      "MESSAGE", "FOREACHDIR", "ENDFOR", "GAMECOMMENT", 
                      "GAMECOMMENTDEF" ]

    RULE_asm = 0
    RULE_line = 1
    RULE_cmd = 2
    RULE_pickup = 3
    RULE_step = 4
    RULE_directions = 5
    RULE_label = 6
    RULE_cond = 7
    RULE_expressions = 8
    RULE_expression = 9
    RULE_comment = 10
    RULE_items = 11
    RULE_item = 12
    RULE_write = 13
    RULE_calc = 14
    RULE_setval = 15
    RULE_take = 16
    RULE_give = 17
    RULE_nearest = 18
    RULE_drop = 19
    RULE_sonst = 20
    RULE_sbhcomment = 21
    RULE_sbhcommentd = 22
    RULE_listen = 23
    RULE_tell = 24
    RULE_direction = 25
    RULE_mem = 26
    RULE_number = 27
    RULE_calcop = 28
    RULE_message = 29
    RULE_everyone = 30
    RULE_foreachdir = 31

    ruleNames =  [ "asm", "line", "cmd", "pickup", "step", "directions", 
                   "label", "cond", "expressions", "expression", "comment", 
                   "items", "item", "write", "calc", "setval", "take", "give", 
                   "nearest", "drop", "sonst", "sbhcomment", "sbhcommentd", 
                   "listen", "tell", "direction", "mem", "number", "calcop", 
                   "message", "everyone", "foreachdir" ]

    EOF = Token.EOF
    COMMENT=1
    WHITESPACE=2
    JUMP=3
    STEP=4
    PICKUP=5
    IF=6
    ELSE=7
    ENDIF=8
    DROP=9
    WRITE=10
    CALC=11
    SET=12
    TAKE=13
    GIVE=14
    NEAREST=15
    MYITEM=16
    END=17
    NOTHING=18
    ITEM=19
    MEM=20
    COMPARE=21
    CALC_OP=22
    NUMBER=23
    DIRECTION=24
    LABEL=25
    EOL=26
    COLON=27
    COMMA=28
    EQUAL=29
    AND=30
    OR=31
    LISTEN=32
    TELL=33
    EVERYONE=34
    MESSAGE=35
    FOREACHDIR=36
    ENDFOR=37
    GAMECOMMENT=38
    GAMECOMMENTDEF=39

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



    class AsmContext(ParserRuleContext):

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

        def line(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(SBHasmParser.LineContext)
            else:
                return self.getTypedRuleContext(SBHasmParser.LineContext,i)


        def getRuleIndex(self):
            return SBHasmParser.RULE_asm

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

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




    def asm(self):

        localctx = SBHasmParser.AsmContext(self, self._ctx, self.state)
        self.enterRule(localctx, 0, self.RULE_asm)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 65 
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 64
                self.line()
                self.state = 67 
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << SBHasmParser.COMMENT) | (1 << SBHasmParser.JUMP) | (1 << SBHasmParser.STEP) | (1 << SBHasmParser.PICKUP) | (1 << SBHasmParser.IF) | (1 << SBHasmParser.DROP) | (1 << SBHasmParser.WRITE) | (1 << SBHasmParser.TAKE) | (1 << SBHasmParser.GIVE) | (1 << SBHasmParser.END) | (1 << SBHasmParser.MEM) | (1 << SBHasmParser.LABEL) | (1 << SBHasmParser.EOL) | (1 << SBHasmParser.LISTEN) | (1 << SBHasmParser.TELL) | (1 << SBHasmParser.GAMECOMMENT) | (1 << SBHasmParser.GAMECOMMENTDEF))) != 0)):
                    break

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

    class LineContext(ParserRuleContext):

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

        def EOL(self):
            return self.getToken(SBHasmParser.EOL, 0)

        def cmd(self):
            return self.getTypedRuleContext(SBHasmParser.CmdContext,0)


        def comment(self):
            return self.getTypedRuleContext(SBHasmParser.CommentContext,0)


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


        def sbhcomment(self):
            return self.getTypedRuleContext(SBHasmParser.SbhcommentContext,0)


        def sbhcommentd(self):
            return self.getTypedRuleContext(SBHasmParser.SbhcommentdContext,0)


        def getRuleIndex(self):
            return SBHasmParser.RULE_line

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

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




    def line(self):

        localctx = SBHasmParser.LineContext(self, self._ctx, self.state)
        self.enterRule(localctx, 2, self.RULE_line)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 74
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [SBHasmParser.JUMP, SBHasmParser.STEP, SBHasmParser.PICKUP, SBHasmParser.IF, SBHasmParser.DROP, SBHasmParser.WRITE, SBHasmParser.TAKE, SBHasmParser.GIVE, SBHasmParser.END, SBHasmParser.MEM, SBHasmParser.LISTEN, SBHasmParser.TELL]:
                self.state = 69
                self.cmd()
                pass
            elif token in [SBHasmParser.COMMENT]:
                self.state = 70
                self.comment()
                pass
            elif token in [SBHasmParser.LABEL]:
                self.state = 71
                self.label()
                pass
            elif token in [SBHasmParser.GAMECOMMENT]:
                self.state = 72
                self.sbhcomment()
                pass
            elif token in [SBHasmParser.GAMECOMMENTDEF]:
                self.state = 73
                self.sbhcommentd()
                pass
            elif token in [SBHasmParser.EOL]:
                pass
            else:
                pass

            self.state = 76
            self.match(SBHasmParser.EOL)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class CmdContext(ParserRuleContext):

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

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

        def step(self):
            return self.getTypedRuleContext(SBHasmParser.StepContext,0)


        def pickup(self):
            return self.getTypedRuleContext(SBHasmParser.PickupContext,0)


        def cond(self):
            return self.getTypedRuleContext(SBHasmParser.CondContext,0)


        def write(self):
            return self.getTypedRuleContext(SBHasmParser.WriteContext,0)


        def drop(self):
            return self.getTypedRuleContext(SBHasmParser.DropContext,0)


        def calc(self):
            return self.getTypedRuleContext(SBHasmParser.CalcContext,0)


        def setval(self):
            return self.getTypedRuleContext(SBHasmParser.SetvalContext,0)


        def take(self):
            return self.getTypedRuleContext(SBHasmParser.TakeContext,0)


        def give(self):
            return self.getTypedRuleContext(SBHasmParser.GiveContext,0)


        def nearest(self):
            return self.getTypedRuleContext(SBHasmParser.NearestContext,0)


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

        def listen(self):
            return self.getTypedRuleContext(SBHasmParser.ListenContext,0)


        def tell(self):
            return self.getTypedRuleContext(SBHasmParser.TellContext,0)


        def foreachdir(self):
            return self.getTypedRuleContext(SBHasmParser.ForeachdirContext,0)


        def getRuleIndex(self):
            return SBHasmParser.RULE_cmd

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

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




    def cmd(self):

        localctx = SBHasmParser.CmdContext(self, self._ctx, self.state)
        self.enterRule(localctx, 4, self.RULE_cmd)
        try:
            self.state = 94
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,2,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 78
                self.match(SBHasmParser.JUMP)
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 79
                self.step()
                pass

            elif la_ == 3:
                self.enterOuterAlt(localctx, 3)
                self.state = 80
                self.pickup()
                pass

            elif la_ == 4:
                self.enterOuterAlt(localctx, 4)
                self.state = 81
                self.cond()
                pass

            elif la_ == 5:
                self.enterOuterAlt(localctx, 5)
                self.state = 82
                self.write()
                pass

            elif la_ == 6:
                self.enterOuterAlt(localctx, 6)
                self.state = 83
                self.drop()
                pass

            elif la_ == 7:
                self.enterOuterAlt(localctx, 7)
                self.state = 84
                self.calc()
                pass

            elif la_ == 8:
                self.enterOuterAlt(localctx, 8)
                self.state = 85
                self.setval()
                pass

            elif la_ == 9:
                self.enterOuterAlt(localctx, 9)
                self.state = 86
                self.take()
                pass

            elif la_ == 10:
                self.enterOuterAlt(localctx, 10)
                self.state = 87
                self.give()
                pass

            elif la_ == 11:
                self.enterOuterAlt(localctx, 11)
                self.state = 88
                self.nearest()
                pass

            elif la_ == 12:
                self.enterOuterAlt(localctx, 12)
                self.state = 89
                self.match(SBHasmParser.END)
                pass

            elif la_ == 13:
                self.enterOuterAlt(localctx, 13)
                self.state = 90
                self.pickup()
                pass

            elif la_ == 14:
                self.enterOuterAlt(localctx, 14)
                self.state = 91
                self.listen()
                pass

            elif la_ == 15:
                self.enterOuterAlt(localctx, 15)
                self.state = 92
                self.tell()
                pass

            elif la_ == 16:
                self.enterOuterAlt(localctx, 16)
                self.state = 93
                self.foreachdir()
                pass


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

    class PickupContext(ParserRuleContext):

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

        def PICKUP(self):
            return self.getToken(SBHasmParser.PICKUP, 0)

        def direction(self):
            return self.getTypedRuleContext(SBHasmParser.DirectionContext,0)


        def mem(self):
            return self.getTypedRuleContext(SBHasmParser.MemContext,0)


        def getRuleIndex(self):
            return SBHasmParser.RULE_pickup

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

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




    def pickup(self):

        localctx = SBHasmParser.PickupContext(self, self._ctx, self.state)
        self.enterRule(localctx, 6, self.RULE_pickup)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 96
            self.match(SBHasmParser.PICKUP)
            self.state = 99
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [SBHasmParser.DIRECTION]:
                self.state = 97
                self.direction()
                pass
            elif token in [SBHasmParser.MEM]:
                self.state = 98
                self.mem()
                pass
            elif token in [SBHasmParser.EOL]:
                pass
            else:
                pass
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class StepContext(ParserRuleContext):

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

        def STEP(self):
            return self.getToken(SBHasmParser.STEP, 0)

        def directions(self):
            return self.getTypedRuleContext(SBHasmParser.DirectionsContext,0)


        def mem(self):
            return self.getTypedRuleContext(SBHasmParser.MemContext,0)


        def getRuleIndex(self):
            return SBHasmParser.RULE_step

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

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




    def step(self):

        localctx = SBHasmParser.StepContext(self, self._ctx, self.state)
        self.enterRule(localctx, 8, self.RULE_step)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 101
            self.match(SBHasmParser.STEP)
            self.state = 104
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [SBHasmParser.DIRECTION]:
                self.state = 102
                self.directions()
                pass
            elif token in [SBHasmParser.MEM]:
                self.state = 103
                self.mem()
                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 DirectionsContext(ParserRuleContext):

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

        def direction(self):
            return self.getTypedRuleContext(SBHasmParser.DirectionContext,0)


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

        def directions(self):
            return self.getTypedRuleContext(SBHasmParser.DirectionsContext,0)


        def getRuleIndex(self):
            return SBHasmParser.RULE_directions

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

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




    def directions(self):

        localctx = SBHasmParser.DirectionsContext(self, self._ctx, self.state)
        self.enterRule(localctx, 10, self.RULE_directions)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 106
            self.direction()
            self.state = 109
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==SBHasmParser.COMMA:
                self.state = 107
                self.match(SBHasmParser.COMMA)
                self.state = 108
                self.directions()


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

    class LabelContext(ParserRuleContext):

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

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

        def getRuleIndex(self):
            return SBHasmParser.RULE_label

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

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




    def label(self):

        localctx = SBHasmParser.LabelContext(self, self._ctx, self.state)
        self.enterRule(localctx, 12, self.RULE_label)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 111
            self.match(SBHasmParser.LABEL)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class CondContext(ParserRuleContext):

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

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

        def expressions(self):
            return self.getTypedRuleContext(SBHasmParser.ExpressionsContext,0)


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

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

        def ENDIF(self):
            return self.getToken(SBHasmParser.ENDIF, 0)

        def line(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(SBHasmParser.LineContext)
            else:
                return self.getTypedRuleContext(SBHasmParser.LineContext,i)


        def sonst(self):
            return self.getTypedRuleContext(SBHasmParser.SonstContext,0)


        def getRuleIndex(self):
            return SBHasmParser.RULE_cond

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

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




    def cond(self):

        localctx = SBHasmParser.CondContext(self, self._ctx, self.state)
        self.enterRule(localctx, 14, self.RULE_cond)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 113
            self.match(SBHasmParser.IF)
            self.state = 114
            self.expressions()
            self.state = 115
            self.match(SBHasmParser.COLON)
            self.state = 116
            self.match(SBHasmParser.EOL)
            self.state = 118 
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 117
                self.line()
                self.state = 120 
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << SBHasmParser.COMMENT) | (1 << SBHasmParser.JUMP) | (1 << SBHasmParser.STEP) | (1 << SBHasmParser.PICKUP) | (1 << SBHasmParser.IF) | (1 << SBHasmParser.DROP) | (1 << SBHasmParser.WRITE) | (1 << SBHasmParser.TAKE) | (1 << SBHasmParser.GIVE) | (1 << SBHasmParser.END) | (1 << SBHasmParser.MEM) | (1 << SBHasmParser.LABEL) | (1 << SBHasmParser.EOL) | (1 << SBHasmParser.LISTEN) | (1 << SBHasmParser.TELL) | (1 << SBHasmParser.GAMECOMMENT) | (1 << SBHasmParser.GAMECOMMENTDEF))) != 0)):
                    break

            self.state = 129
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==SBHasmParser.ELSE:
                self.state = 122
                self.sonst()
                self.state = 123
                self.match(SBHasmParser.EOL)
                self.state = 125 
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while True:
                    self.state = 124
                    self.line()
                    self.state = 127 
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)
                    if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << SBHasmParser.COMMENT) | (1 << SBHasmParser.JUMP) | (1 << SBHasmParser.STEP) | (1 << SBHasmParser.PICKUP) | (1 << SBHasmParser.IF) | (1 << SBHasmParser.DROP) | (1 << SBHasmParser.WRITE) | (1 << SBHasmParser.TAKE) | (1 << SBHasmParser.GIVE) | (1 << SBHasmParser.END) | (1 << SBHasmParser.MEM) | (1 << SBHasmParser.LABEL) | (1 << SBHasmParser.EOL) | (1 << SBHasmParser.LISTEN) | (1 << SBHasmParser.TELL) | (1 << SBHasmParser.GAMECOMMENT) | (1 << SBHasmParser.GAMECOMMENTDEF))) != 0)):
                        break



            self.state = 131
            self.match(SBHasmParser.ENDIF)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

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


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

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

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

        def getRuleIndex(self):
            return SBHasmParser.RULE_expressions

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

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




    def expressions(self):

        localctx = SBHasmParser.ExpressionsContext(self, self._ctx, self.state)
        self.enterRule(localctx, 16, self.RULE_expressions)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 133
            self.expression()
            self.state = 139
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==SBHasmParser.AND or _la==SBHasmParser.OR:
                self.state = 134
                _la = self._input.LA(1)
                if not(_la==SBHasmParser.AND or _la==SBHasmParser.OR):
                    self._errHandler.recoverInline(self)
                else:
                    self._errHandler.reportMatch(self)
                    self.consume()
                self.state = 135
                self.match(SBHasmParser.EOL)
                self.state = 136
                self.expression()
                self.state = 141
                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 ExpressionContext(ParserRuleContext):

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

        def COMPARE(self):
            return self.getToken(SBHasmParser.COMPARE, 0)

        def direction(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(SBHasmParser.DirectionContext)
            else:
                return self.getTypedRuleContext(SBHasmParser.DirectionContext,i)


        def items(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(SBHasmParser.ItemsContext)
            else:
                return self.getTypedRuleContext(SBHasmParser.ItemsContext,i)


        def number(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(SBHasmParser.NumberContext)
            else:
                return self.getTypedRuleContext(SBHasmParser.NumberContext,i)


        def getRuleIndex(self):
            return SBHasmParser.RULE_expression

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

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




    def expression(self):

        localctx = SBHasmParser.ExpressionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 18, self.RULE_expression)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 145
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [SBHasmParser.DIRECTION]:
                self.state = 142
                self.direction()
                pass
            elif token in [SBHasmParser.MYITEM, SBHasmParser.NOTHING, SBHasmParser.ITEM, SBHasmParser.MEM]:
                self.state = 143
                self.items()
                pass
            elif token in [SBHasmParser.NUMBER]:
                self.state = 144
                self.number()
                pass
            else:
                raise NoViableAltException(self)

            self.state = 147
            self.match(SBHasmParser.COMPARE)
            self.state = 151
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [SBHasmParser.DIRECTION]:
                self.state = 148
                self.direction()
                pass
            elif token in [SBHasmParser.MYITEM, SBHasmParser.NOTHING, SBHasmParser.ITEM, SBHasmParser.MEM]:
                self.state = 149
                self.items()
                pass
            elif token in [SBHasmParser.NUMBER]:
                self.state = 150
                self.number()
                pass
            else:
                raise NoViableAltException(self)

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

    class CommentContext(ParserRuleContext):

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

        def COMMENT(self):
            return self.getToken(SBHasmParser.COMMENT, 0)

        def getRuleIndex(self):
            return SBHasmParser.RULE_comment

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

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




    def comment(self):

        localctx = SBHasmParser.CommentContext(self, self._ctx, self.state)
        self.enterRule(localctx, 20, self.RULE_comment)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 153
            self.match(SBHasmParser.COMMENT)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ItemsContext(ParserRuleContext):

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

        def item(self):
            return self.getTypedRuleContext(SBHasmParser.ItemContext,0)


        def mem(self):
            return self.getTypedRuleContext(SBHasmParser.MemContext,0)


        def MYITEM(self):
            return self.getToken(SBHasmParser.MYITEM, 0)

        def NOTHING(self):
            return self.getToken(SBHasmParser.NOTHING, 0)

        def getRuleIndex(self):
            return SBHasmParser.RULE_items

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

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




    def items(self):

        localctx = SBHasmParser.ItemsContext(self, self._ctx, self.state)
        self.enterRule(localctx, 22, self.RULE_items)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 159
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [SBHasmParser.ITEM]:
                self.state = 155
                self.item()
                pass
            elif token in [SBHasmParser.MEM]:
                self.state = 156
                self.mem()
                pass
            elif token in [SBHasmParser.MYITEM]:
                self.state = 157
                self.match(SBHasmParser.MYITEM)
                pass
            elif token in [SBHasmParser.NOTHING]:
                self.state = 158
                self.match(SBHasmParser.NOTHING)
                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 ItemContext(ParserRuleContext):

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

        def ITEM(self):
            return self.getToken(SBHasmParser.ITEM, 0)

        def getRuleIndex(self):
            return SBHasmParser.RULE_item

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

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




    def item(self):

        localctx = SBHasmParser.ItemContext(self, self._ctx, self.state)
        self.enterRule(localctx, 24, self.RULE_item)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 161
            self.match(SBHasmParser.ITEM)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class WriteContext(ParserRuleContext):

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

        def WRITE(self):
            return self.getToken(SBHasmParser.WRITE, 0)

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


        def direction(self):
            return self.getTypedRuleContext(SBHasmParser.DirectionContext,0)


        def mem(self):
            return self.getTypedRuleContext(SBHasmParser.MemContext,0)


        def getRuleIndex(self):
            return SBHasmParser.RULE_write

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

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




    def write(self):

        localctx = SBHasmParser.WriteContext(self, self._ctx, self.state)
        self.enterRule(localctx, 26, self.RULE_write)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 163
            self.match(SBHasmParser.WRITE)
            self.state = 167
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [SBHasmParser.NUMBER]:
                self.state = 164
                self.number()
                pass
            elif token in [SBHasmParser.DIRECTION]:
                self.state = 165
                self.direction()
                pass
            elif token in [SBHasmParser.MEM]:
                self.state = 166
                self.mem()
                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 CalcContext(ParserRuleContext):

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

        def mem(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(SBHasmParser.MemContext)
            else:
                return self.getTypedRuleContext(SBHasmParser.MemContext,i)


        def EQUAL(self):
            return self.getToken(SBHasmParser.EQUAL, 0)

        def CALC(self):
            return self.getToken(SBHasmParser.CALC, 0)

        def calcop(self):
            return self.getTypedRuleContext(SBHasmParser.CalcopContext,0)


        def direction(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(SBHasmParser.DirectionContext)
            else:
                return self.getTypedRuleContext(SBHasmParser.DirectionContext,i)


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

        def number(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(SBHasmParser.NumberContext)
            else:
                return self.getTypedRuleContext(SBHasmParser.NumberContext,i)


        def getRuleIndex(self):
            return SBHasmParser.RULE_calc

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

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




    def calc(self):

        localctx = SBHasmParser.CalcContext(self, self._ctx, self.state)
        self.enterRule(localctx, 28, self.RULE_calc)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 169
            self.mem()
            self.state = 170
            self.match(SBHasmParser.EQUAL)
            self.state = 171
            self.match(SBHasmParser.CALC)
            self.state = 176
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [SBHasmParser.DIRECTION]:
                self.state = 172
                self.direction()
                pass
            elif token in [SBHasmParser.MEM]:
                self.state = 173
                self.mem()
                pass
            elif token in [SBHasmParser.MYITEM]:
                self.state = 174
                self.match(SBHasmParser.MYITEM)
                pass
            elif token in [SBHasmParser.NUMBER]:
                self.state = 175
                self.number()
                pass
            else:
                raise NoViableAltException(self)

            self.state = 178
            self.calcop()
            self.state = 183
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [SBHasmParser.DIRECTION]:
                self.state = 179
                self.direction()
                pass
            elif token in [SBHasmParser.MEM]:
                self.state = 180
                self.mem()
                pass
            elif token in [SBHasmParser.MYITEM]:
                self.state = 181
                self.match(SBHasmParser.MYITEM)
                pass
            elif token in [SBHasmParser.NUMBER]:
                self.state = 182
                self.number()
                pass
            else:
                raise NoViableAltException(self)

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

    class SetvalContext(ParserRuleContext):

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

        def mem(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(SBHasmParser.MemContext)
            else:
                return self.getTypedRuleContext(SBHasmParser.MemContext,i)


        def EQUAL(self):
            return self.getToken(SBHasmParser.EQUAL, 0)

        def SET(self):
            return self.getToken(SBHasmParser.SET, 0)

        def direction(self):
            return self.getTypedRuleContext(SBHasmParser.DirectionContext,0)


        def MYITEM(self):
            return self.getToken(SBHasmParser.MYITEM, 0)

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


        def NOTHING(self):
            return self.getToken(SBHasmParser.NOTHING, 0)

        def getRuleIndex(self):
            return SBHasmParser.RULE_setval

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

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




    def setval(self):

        localctx = SBHasmParser.SetvalContext(self, self._ctx, self.state)
        self.enterRule(localctx, 30, self.RULE_setval)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 185
            self.mem()
            self.state = 186
            self.match(SBHasmParser.EQUAL)
            self.state = 187
            self.match(SBHasmParser.SET)
            self.state = 193
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [SBHasmParser.DIRECTION]:
                self.state = 188
                self.direction()
                pass
            elif token in [SBHasmParser.MEM]:
                self.state = 189
                self.mem()
                pass
            elif token in [SBHasmParser.MYITEM]:
                self.state = 190
                self.match(SBHasmParser.MYITEM)
                pass
            elif token in [SBHasmParser.NUMBER]:
                self.state = 191
                self.number()
                pass
            elif token in [SBHasmParser.NOTHING]:
                self.state = 192
                self.match(SBHasmParser.NOTHING)
                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 TakeContext(ParserRuleContext):

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

        def TAKE(self):
            return self.getToken(SBHasmParser.TAKE, 0)

        def direction(self):
            return self.getTypedRuleContext(SBHasmParser.DirectionContext,0)


        def mem(self):
            return self.getTypedRuleContext(SBHasmParser.MemContext,0)


        def getRuleIndex(self):
            return SBHasmParser.RULE_take

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

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




    def take(self):

        localctx = SBHasmParser.TakeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 32, self.RULE_take)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 195
            self.match(SBHasmParser.TAKE)
            self.state = 198
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [SBHasmParser.DIRECTION]:
                self.state = 196
                self.direction()
                pass
            elif token in [SBHasmParser.MEM]:
                self.state = 197
                self.mem()
                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 GiveContext(ParserRuleContext):

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

        def GIVE(self):
            return self.getToken(SBHasmParser.GIVE, 0)

        def direction(self):
            return self.getTypedRuleContext(SBHasmParser.DirectionContext,0)


        def mem(self):
            return self.getTypedRuleContext(SBHasmParser.MemContext,0)


        def getRuleIndex(self):
            return SBHasmParser.RULE_give

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

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




    def give(self):

        localctx = SBHasmParser.GiveContext(self, self._ctx, self.state)
        self.enterRule(localctx, 34, self.RULE_give)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 200
            self.match(SBHasmParser.GIVE)
            self.state = 203
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [SBHasmParser.DIRECTION]:
                self.state = 201
                self.direction()
                pass
            elif token in [SBHasmParser.MEM]:
                self.state = 202
                self.mem()
                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 NearestContext(ParserRuleContext):

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

        def mem(self):
            return self.getTypedRuleContext(SBHasmParser.MemContext,0)


        def EQUAL(self):
            return self.getToken(SBHasmParser.EQUAL, 0)

        def NEAREST(self):
            return self.getToken(SBHasmParser.NEAREST, 0)

        def item(self):
            return self.getTypedRuleContext(SBHasmParser.ItemContext,0)


        def getRuleIndex(self):
            return SBHasmParser.RULE_nearest

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

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




    def nearest(self):

        localctx = SBHasmParser.NearestContext(self, self._ctx, self.state)
        self.enterRule(localctx, 36, self.RULE_nearest)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 205
            self.mem()
            self.state = 206
            self.match(SBHasmParser.EQUAL)
            self.state = 207
            self.match(SBHasmParser.NEAREST)
            self.state = 208
            self.item()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class DropContext(ParserRuleContext):

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

        def DROP(self):
            return self.getToken(SBHasmParser.DROP, 0)

        def getRuleIndex(self):
            return SBHasmParser.RULE_drop

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

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




    def drop(self):

        localctx = SBHasmParser.DropContext(self, self._ctx, self.state)
        self.enterRule(localctx, 38, self.RULE_drop)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 210
            self.match(SBHasmParser.DROP)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class SonstContext(ParserRuleContext):

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

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

        def getRuleIndex(self):
            return SBHasmParser.RULE_sonst

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

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




    def sonst(self):

        localctx = SBHasmParser.SonstContext(self, self._ctx, self.state)
        self.enterRule(localctx, 40, self.RULE_sonst)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 212
            self.match(SBHasmParser.ELSE)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class SbhcommentContext(ParserRuleContext):

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

        def GAMECOMMENT(self):
            return self.getToken(SBHasmParser.GAMECOMMENT, 0)

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


        def getRuleIndex(self):
            return SBHasmParser.RULE_sbhcomment

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

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




    def sbhcomment(self):

        localctx = SBHasmParser.SbhcommentContext(self, self._ctx, self.state)
        self.enterRule(localctx, 42, self.RULE_sbhcomment)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 214
            self.match(SBHasmParser.GAMECOMMENT)
            self.state = 215
            self.number()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class SbhcommentdContext(ParserRuleContext):

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

        def GAMECOMMENTDEF(self):
            return self.getToken(SBHasmParser.GAMECOMMENTDEF, 0)

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


        def getRuleIndex(self):
            return SBHasmParser.RULE_sbhcommentd

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

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




    def sbhcommentd(self):

        localctx = SBHasmParser.SbhcommentdContext(self, self._ctx, self.state)
        self.enterRule(localctx, 44, self.RULE_sbhcommentd)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 217
            self.match(SBHasmParser.GAMECOMMENTDEF)
            self.state = 218
            self.number()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ListenContext(ParserRuleContext):

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

        def LISTEN(self):
            return self.getToken(SBHasmParser.LISTEN, 0)

        def message(self):
            return self.getTypedRuleContext(SBHasmParser.MessageContext,0)


        def getRuleIndex(self):
            return SBHasmParser.RULE_listen

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

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




    def listen(self):

        localctx = SBHasmParser.ListenContext(self, self._ctx, self.state)
        self.enterRule(localctx, 46, self.RULE_listen)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 220
            self.match(SBHasmParser.LISTEN)
            self.state = 221
            self.message()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class TellContext(ParserRuleContext):

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

        def TELL(self):
            return self.getToken(SBHasmParser.TELL, 0)

        def message(self):
            return self.getTypedRuleContext(SBHasmParser.MessageContext,0)


        def everyone(self):
            return self.getTypedRuleContext(SBHasmParser.EveryoneContext,0)


        def direction(self):
            return self.getTypedRuleContext(SBHasmParser.DirectionContext,0)


        def getRuleIndex(self):
            return SBHasmParser.RULE_tell

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

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




    def tell(self):

        localctx = SBHasmParser.TellContext(self, self._ctx, self.state)
        self.enterRule(localctx, 48, self.RULE_tell)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 223
            self.match(SBHasmParser.TELL)
            self.state = 226
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [SBHasmParser.EVERYONE]:
                self.state = 224
                self.everyone()
                pass
            elif token in [SBHasmParser.DIRECTION]:
                self.state = 225
                self.direction()
                pass
            else:
                raise NoViableAltException(self)

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

    class DirectionContext(ParserRuleContext):

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

        def DIRECTION(self):
            return self.getToken(SBHasmParser.DIRECTION, 0)

        def getRuleIndex(self):
            return SBHasmParser.RULE_direction

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

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




    def direction(self):

        localctx = SBHasmParser.DirectionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 50, self.RULE_direction)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 230
            self.match(SBHasmParser.DIRECTION)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class MemContext(ParserRuleContext):

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

        def MEM(self):
            return self.getToken(SBHasmParser.MEM, 0)

        def getRuleIndex(self):
            return SBHasmParser.RULE_mem

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

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




    def mem(self):

        localctx = SBHasmParser.MemContext(self, self._ctx, self.state)
        self.enterRule(localctx, 52, self.RULE_mem)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 232
            self.match(SBHasmParser.MEM)
        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 NUMBER(self):
            return self.getToken(SBHasmParser.NUMBER, 0)

        def getRuleIndex(self):
            return SBHasmParser.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 = SBHasmParser.NumberContext(self, self._ctx, self.state)
        self.enterRule(localctx, 54, self.RULE_number)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 234
            self.match(SBHasmParser.NUMBER)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class CalcopContext(ParserRuleContext):

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

        def CALC_OP(self):
            return self.getToken(SBHasmParser.CALC_OP, 0)

        def getRuleIndex(self):
            return SBHasmParser.RULE_calcop

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

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




    def calcop(self):

        localctx = SBHasmParser.CalcopContext(self, self._ctx, self.state)
        self.enterRule(localctx, 56, self.RULE_calcop)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 236
            self.match(SBHasmParser.CALC_OP)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class MessageContext(ParserRuleContext):

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

        def MESSAGE(self):
            return self.getToken(SBHasmParser.MESSAGE, 0)

        def getRuleIndex(self):
            return SBHasmParser.RULE_message

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

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




    def message(self):

        localctx = SBHasmParser.MessageContext(self, self._ctx, self.state)
        self.enterRule(localctx, 58, self.RULE_message)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 238
            self.match(SBHasmParser.MESSAGE)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class EveryoneContext(ParserRuleContext):

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

        def EVERYONE(self):
            return self.getToken(SBHasmParser.EVERYONE, 0)

        def getRuleIndex(self):
            return SBHasmParser.RULE_everyone

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

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




    def everyone(self):

        localctx = SBHasmParser.EveryoneContext(self, self._ctx, self.state)
        self.enterRule(localctx, 60, self.RULE_everyone)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 240
            self.match(SBHasmParser.EVERYONE)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ForeachdirContext(ParserRuleContext):

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

        def mem(self):
            return self.getTypedRuleContext(SBHasmParser.MemContext,0)


        def EQUAL(self):
            return self.getToken(SBHasmParser.EQUAL, 0)

        def FOREACHDIR(self):
            return self.getToken(SBHasmParser.FOREACHDIR, 0)

        def directions(self):
            return self.getTypedRuleContext(SBHasmParser.DirectionsContext,0)


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

        def EOL(self):
            return self.getToken(SBHasmParser.EOL, 0)

        def ENDFOR(self):
            return self.getToken(SBHasmParser.ENDFOR, 0)

        def line(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(SBHasmParser.LineContext)
            else:
                return self.getTypedRuleContext(SBHasmParser.LineContext,i)


        def getRuleIndex(self):
            return SBHasmParser.RULE_foreachdir

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

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




    def foreachdir(self):

        localctx = SBHasmParser.ForeachdirContext(self, self._ctx, self.state)
        self.enterRule(localctx, 62, self.RULE_foreachdir)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 242
            self.mem()
            self.state = 243
            self.match(SBHasmParser.EQUAL)
            self.state = 244
            self.match(SBHasmParser.FOREACHDIR)
            self.state = 245
            self.directions()
            self.state = 246
            self.match(SBHasmParser.COLON)
            self.state = 247
            self.match(SBHasmParser.EOL)
            self.state = 249 
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 248
                self.line()
                self.state = 251 
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << SBHasmParser.COMMENT) | (1 << SBHasmParser.JUMP) | (1 << SBHasmParser.STEP) | (1 << SBHasmParser.PICKUP) | (1 << SBHasmParser.IF) | (1 << SBHasmParser.DROP) | (1 << SBHasmParser.WRITE) | (1 << SBHasmParser.TAKE) | (1 << SBHasmParser.GIVE) | (1 << SBHasmParser.END) | (1 << SBHasmParser.MEM) | (1 << SBHasmParser.LABEL) | (1 << SBHasmParser.EOL) | (1 << SBHasmParser.LISTEN) | (1 << SBHasmParser.TELL) | (1 << SBHasmParser.GAMECOMMENT) | (1 << SBHasmParser.GAMECOMMENTDEF))) != 0)):
                    break

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






# Generated from SBHasm.g4 by ANTLR 4.7.1
# encoding: utf-8
import sys
from io import StringIO

from antlr4 import *
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("\u0102\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!\3\2\6\2D\n\2\r\2\16\2E\3\3\3\3")
        buf.write("\3\3\3\3\3\3\5\3M\n\3\3\3\3\3\3\4\3\4\3\4\3\4\3\4\3\4")
        buf.write("\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\5\4a\n\4\3\5")
        buf.write("\3\5\3\5\5\5f\n\5\3\6\3\6\3\6\5\6k\n\6\3\7\3\7\3\7\5\7")
        buf.write("p\n\7\3\b\3\b\3\t\3\t\3\t\3\t\3\t\6\ty\n\t\r\t\16\tz\3")
        buf.write("\t\3\t\3\t\6\t\u0080\n\t\r\t\16\t\u0081\5\t\u0084\n\t")
        buf.write("\3\t\3\t\3\n\3\n\3\n\3\n\7\n\u008c\n\n\f\n\16\n\u008f")
        buf.write("\13\n\3\13\3\13\3\13\5\13\u0094\n\13\3\13\3\13\3\13\3")
        buf.write("\13\5\13\u009a\n\13\3\f\3\f\3\r\3\r\3\r\3\r\5\r\u00a2")
        buf.write("\n\r\3\16\3\16\3\17\3\17\3\17\3\17\5\17\u00aa\n\17\3\20")
        buf.write("\3\20\3\20\3\20\3\20\3\20\3\20\5\20\u00b3\n\20\3\20\3")
        buf.write("\20\3\20\3\20\3\20\5\20\u00ba\n\20\3\21\3\21\3\21\3\21")
        buf.write("\3\21\3\21\3\21\3\21\5\21\u00c4\n\21\3\22\3\22\3\22\5")
        buf.write("\22\u00c9\n\22\3\23\3\23\3\23\5\23\u00ce\n\23\3\24\3\24")
        buf.write("\3\24\3\24\3\24\3\25\3\25\3\26\3\26\3\27\3\27\3\27\3\30")
        buf.write("\3\30\3\30\3\31\3\31\3\31\3\32\3\32\3\32\5\32\u00e5\n")
        buf.write("\32\3\32\3\32\3\33\3\33\3\34\3\34\3\35\3\35\3\36\3\36")
        buf.write("\3\37\3\37\3 \3 \3!\3!\3!\3!\3!\3!\3!\6!\u00fc\n!\r!\16")
        buf.write("!\u00fd\3!\3!\3!\2\2\"\2\4\6\b\n\f\16\20\22\24\26\30\32")
        buf.write("\34\36 \"$&(*,.\60\62\64\668:<>@\2\3\3\2 !\2\u0115\2C")
        buf.write("\3\2\2\2\4L\3\2\2\2\6`\3\2\2\2\bb\3\2\2\2\ng\3\2\2\2\f")
        buf.write("l\3\2\2\2\16q\3\2\2\2\20s\3\2\2\2\22\u0087\3\2\2\2\24")
        buf.write("\u0093\3\2\2\2\26\u009b\3\2\2\2\30\u00a1\3\2\2\2\32\u00a3")
        buf.write("\3\2\2\2\34\u00a5\3\2\2\2\36\u00ab\3\2\2\2 \u00bb\3\2")
        buf.write("\2\2\"\u00c5\3\2\2\2$\u00ca\3\2\2\2&\u00cf\3\2\2\2(\u00d4")
        buf.write("\3\2\2\2*\u00d6\3\2\2\2,\u00d8\3\2\2\2.\u00db\3\2\2\2")
        buf.write("\60\u00de\3\2\2\2\62\u00e1\3\2\2\2\64\u00e8\3\2\2\2\66")
        buf.write("\u00ea\3\2\2\28\u00ec\3\2\2\2:\u00ee\3\2\2\2<\u00f0\3")
        buf.write("\2\2\2>\u00f2\3\2\2\2@\u00f4\3\2\2\2BD\5\4\3\2CB\3\2\2")
        buf.write("\2DE\3\2\2\2EC\3\2\2\2EF\3\2\2\2F\3\3\2\2\2GM\5\6\4\2")
        buf.write("HM\5\26\f\2IM\5\16\b\2JM\5,\27\2KM\5.\30\2LG\3\2\2\2L")
        buf.write("H\3\2\2\2LI\3\2\2\2LJ\3\2\2\2LK\3\2\2\2LM\3\2\2\2MN\3")
        buf.write("\2\2\2NO\7\34\2\2O\5\3\2\2\2Pa\7\5\2\2Qa\5\n\6\2Ra\5\b")
        buf.write("\5\2Sa\5\20\t\2Ta\5\34\17\2Ua\5(\25\2Va\5\36\20\2Wa\5")
        buf.write(" \21\2Xa\5\"\22\2Ya\5$\23\2Za\5&\24\2[a\7\23\2\2\\a\5")
        buf.write("\b\5\2]a\5\60\31\2^a\5\62\32\2_a\5@!\2`P\3\2\2\2`Q\3\2")
        buf.write("\2\2`R\3\2\2\2`S\3\2\2\2`T\3\2\2\2`U\3\2\2\2`V\3\2\2\2")
        buf.write("`W\3\2\2\2`X\3\2\2\2`Y\3\2\2\2`Z\3\2\2\2`[\3\2\2\2`\\")
        buf.write("\3\2\2\2`]\3\2\2\2`^\3\2\2\2`_\3\2\2\2a\7\3\2\2\2be\7")
        buf.write("\7\2\2cf\5\64\33\2df\5\66\34\2ec\3\2\2\2ed\3\2\2\2ef\3")
        buf.write("\2\2\2f\t\3\2\2\2gj\7\6\2\2hk\5\f\7\2ik\5\66\34\2jh\3")
        buf.write("\2\2\2ji\3\2\2\2k\13\3\2\2\2lo\5\64\33\2mn\7\36\2\2np")
        buf.write("\5\f\7\2om\3\2\2\2op\3\2\2\2p\r\3\2\2\2qr\7\33\2\2r\17")
        buf.write("\3\2\2\2st\7\b\2\2tu\5\22\n\2uv\7\35\2\2vx\7\34\2\2wy")
        buf.write("\5\4\3\2xw\3\2\2\2yz\3\2\2\2zx\3\2\2\2z{\3\2\2\2{\u0083")
        buf.write("\3\2\2\2|}\5*\26\2}\177\7\34\2\2~\u0080\5\4\3\2\177~\3")
        buf.write("\2\2\2\u0080\u0081\3\2\2\2\u0081\177\3\2\2\2\u0081\u0082")
        buf.write("\3\2\2\2\u0082\u0084\3\2\2\2\u0083|\3\2\2\2\u0083\u0084")
        buf.write("\3\2\2\2\u0084\u0085\3\2\2\2\u0085\u0086\7\n\2\2\u0086")
        buf.write("\21\3\2\2\2\u0087\u008d\5\24\13\2\u0088\u0089\t\2\2\2")
        buf.write("\u0089\u008a\7\34\2\2\u008a\u008c\5\24\13\2\u008b\u0088")
        buf.write("\3\2\2\2\u008c\u008f\3\2\2\2\u008d\u008b\3\2\2\2\u008d")
        buf.write("\u008e\3\2\2\2\u008e\23\3\2\2\2\u008f\u008d\3\2\2\2\u0090")
        buf.write("\u0094\5\64\33\2\u0091\u0094\5\30\r\2\u0092\u0094\58\35")
        buf.write("\2\u0093\u0090\3\2\2\2\u0093\u0091\3\2\2\2\u0093\u0092")
        buf.write("\3\2\2\2\u0094\u0095\3\2\2\2\u0095\u0099\7\27\2\2\u0096")
        buf.write("\u009a\5\64\33\2\u0097\u009a\5\30\r\2\u0098\u009a\58\35")
        buf.write("\2\u0099\u0096\3\2\2\2\u0099\u0097\3\2\2\2\u0099\u0098")
        buf.write("\3\2\2\2\u009a\25\3\2\2\2\u009b\u009c\7\3\2\2\u009c\27")
        buf.write("\3\2\2\2\u009d\u00a2\5\32\16\2\u009e\u00a2\5\66\34\2\u009f")
        buf.write("\u00a2\7\22\2\2\u00a0\u00a2\7\24\2\2\u00a1\u009d\3\2\2")
        buf.write("\2\u00a1\u009e\3\2\2\2\u00a1\u009f\3\2\2\2\u00a1\u00a0")
        buf.write("\3\2\2\2\u00a2\31\3\2\2\2\u00a3\u00a4\7\25\2\2\u00a4\33")
        buf.write("\3\2\2\2\u00a5\u00a9\7\f\2\2\u00a6\u00aa\58\35\2\u00a7")
        buf.write("\u00aa\5\64\33\2\u00a8\u00aa\5\66\34\2\u00a9\u00a6\3\2")
        buf.write("\2\2\u00a9\u00a7\3\2\2\2\u00a9\u00a8\3\2\2\2\u00aa\35")
        buf.write("\3\2\2\2\u00ab\u00ac\5\66\34\2\u00ac\u00ad\7\37\2\2\u00ad")
        buf.write("\u00b2\7\r\2\2\u00ae\u00b3\5\64\33\2\u00af\u00b3\5\66")
        buf.write("\34\2\u00b0\u00b3\7\22\2\2\u00b1\u00b3\58\35\2\u00b2\u00ae")
        buf.write("\3\2\2\2\u00b2\u00af\3\2\2\2\u00b2\u00b0\3\2\2\2\u00b2")
        buf.write("\u00b1\3\2\2\2\u00b3\u00b4\3\2\2\2\u00b4\u00b9\5:\36\2")
        buf.write("\u00b5\u00ba\5\64\33\2\u00b6\u00ba\5\66\34\2\u00b7\u00ba")
        buf.write("\7\22\2\2\u00b8\u00ba\58\35\2\u00b9\u00b5\3\2\2\2\u00b9")
        buf.write("\u00b6\3\2\2\2\u00b9\u00b7\3\2\2\2\u00b9\u00b8\3\2\2\2")
        buf.write("\u00ba\37\3\2\2\2\u00bb\u00bc\5\66\34\2\u00bc\u00bd\7")
        buf.write("\37\2\2\u00bd\u00c3\7\16\2\2\u00be\u00c4\5\64\33\2\u00bf")
        buf.write("\u00c4\5\66\34\2\u00c0\u00c4\7\22\2\2\u00c1\u00c4\58\35")
        buf.write("\2\u00c2\u00c4\7\24\2\2\u00c3\u00be\3\2\2\2\u00c3\u00bf")
        buf.write("\3\2\2\2\u00c3\u00c0\3\2\2\2\u00c3\u00c1\3\2\2\2\u00c3")
        buf.write("\u00c2\3\2\2\2\u00c4!\3\2\2\2\u00c5\u00c8\7\17\2\2\u00c6")
        buf.write("\u00c9\5\64\33\2\u00c7\u00c9\5\66\34\2\u00c8\u00c6\3\2")
        buf.write("\2\2\u00c8\u00c7\3\2\2\2\u00c9#\3\2\2\2\u00ca\u00cd\7")
        buf.write("\20\2\2\u00cb\u00ce\5\64\33\2\u00cc\u00ce\5\66\34\2\u00cd")
        buf.write("\u00cb\3\2\2\2\u00cd\u00cc\3\2\2\2\u00ce%\3\2\2\2\u00cf")
        buf.write("\u00d0\5\66\34\2\u00d0\u00d1\7\37\2\2\u00d1\u00d2\7\21")
        buf.write("\2\2\u00d2\u00d3\5\32\16\2\u00d3\'\3\2\2\2\u00d4\u00d5")
        buf.write("\7\13\2\2\u00d5)\3\2\2\2\u00d6\u00d7\7\t\2\2\u00d7+\3")
        buf.write("\2\2\2\u00d8\u00d9\7(\2\2\u00d9\u00da\58\35\2\u00da-\3")
        buf.write("\2\2\2\u00db\u00dc\7)\2\2\u00dc\u00dd\58\35\2\u00dd/\3")
        buf.write("\2\2\2\u00de\u00df\7\"\2\2\u00df\u00e0\5<\37\2\u00e0\61")
        buf.write("\3\2\2\2\u00e1\u00e4\7#\2\2\u00e2\u00e5\5> \2\u00e3\u00e5")
        buf.write("\5\64\33\2\u00e4\u00e2\3\2\2\2\u00e4\u00e3\3\2\2\2\u00e5")
        buf.write("\u00e6\3\2\2\2\u00e6\u00e7\5<\37\2\u00e7\63\3\2\2\2\u00e8")
        buf.write("\u00e9\7\32\2\2\u00e9\65\3\2\2\2\u00ea\u00eb\7\26\2\2")
        buf.write("\u00eb\67\3\2\2\2\u00ec\u00ed\7\31\2\2\u00ed9\3\2\2\2")
        buf.write("\u00ee\u00ef\7\30\2\2\u00ef;\3\2\2\2\u00f0\u00f1\7%\2")
        buf.write("\2\u00f1=\3\2\2\2\u00f2\u00f3\7$\2\2\u00f3?\3\2\2\2\u00f4")
        buf.write("\u00f5\5\66\34\2\u00f5\u00f6\7\37\2\2\u00f6\u00f7\7&\2")
        buf.write("\2\u00f7\u00f8\5\f\7\2\u00f8\u00f9\7\35\2\2\u00f9\u00fb")
        buf.write("\7\34\2\2\u00fa\u00fc\5\4\3\2\u00fb\u00fa\3\2\2\2\u00fc")
        buf.write("\u00fd\3\2\2\2\u00fd\u00fb\3\2\2\2\u00fd\u00fe\3\2\2\2")
        buf.write("\u00fe\u00ff\3\2\2\2\u00ff\u0100\7\'\2\2\u0100A\3\2\2")
        buf.write("\2\27EL`ejoz\u0081\u0083\u008d\u0093\u0099\u00a1\u00a9")
        buf.write("\u00b2\u00b9\u00c3\u00c8\u00cd\u00e4\u00fd")
        return buf.getvalue()


class SBHasmParser ( Parser ):

    grammarFileName = "SBHasm.g4"

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

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

    sharedContextCache = PredictionContextCache()

    literalNames = [ "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "'step'", "'pickup'", "'if'", "'else:'", "'endif'", 
                     "'drop'", "'write'", "'calc'", "'set'", "'takefrom'", 
                     "'giveto'", "'nearest'", "'myitem'", "'end'", "'nothing'", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>", 
                     "':'", "','", "'='", "'and'", "'or'", "'listenfor'", 
                     "'tell'", "'everyone'", "<INVALID>", "'foreachdir'", 
                     "'endfor'", "'comment'", "'DEFINE COMMENT'" ]

    symbolicNames = [ "<INVALID>", "COMMENT", "WHITESPACE", "JUMP", "STEP", 
                      "PICKUP", "IF", "ELSE", "ENDIF", "DROP", "WRITE", 
                      "CALC", "SET", "TAKE", "GIVE", "NEAREST", "MYITEM", 
                      "END", "NOTHING", "ITEM", "MEM", "COMPARE", "CALC_OP", 
                      "NUMBER", "DIRECTION", "LABEL", "EOL", "COLON", "COMMA", 
                      "EQUAL", "AND", "OR", "LISTEN", "TELL", "EVERYONE", 
                      "MESSAGE", "FOREACHDIR", "ENDFOR", "GAMECOMMENT", 
                      "GAMECOMMENTDEF" ]

    RULE_asm = 0
    RULE_line = 1
    RULE_cmd = 2
    RULE_pickup = 3
    RULE_step = 4
    RULE_directions = 5
    RULE_label = 6
    RULE_cond = 7
    RULE_expressions = 8
    RULE_expression = 9
    RULE_comment = 10
    RULE_items = 11
    RULE_item = 12
    RULE_write = 13
    RULE_calc = 14
    RULE_setval = 15
    RULE_take = 16
    RULE_give = 17
    RULE_nearest = 18
    RULE_drop = 19
    RULE_sonst = 20
    RULE_sbhcomment = 21
    RULE_sbhcommentd = 22
    RULE_listen = 23
    RULE_tell = 24
    RULE_direction = 25
    RULE_mem = 26
    RULE_number = 27
    RULE_calcop = 28
    RULE_message = 29
    RULE_everyone = 30
    RULE_foreachdir = 31

    ruleNames =  [ "asm", "line", "cmd", "pickup", "step", "directions", 
                   "label", "cond", "expressions", "expression", "comment", 
                   "items", "item", "write", "calc", "setval", "take", "give", 
                   "nearest", "drop", "sonst", "sbhcomment", "sbhcommentd", 
                   "listen", "tell", "direction", "mem", "number", "calcop", 
                   "message", "everyone", "foreachdir" ]

    EOF = Token.EOF
    COMMENT=1
    WHITESPACE=2
    JUMP=3
    STEP=4
    PICKUP=5
    IF=6
    ELSE=7
    ENDIF=8
    DROP=9
    WRITE=10
    CALC=11
    SET=12
    TAKE=13
    GIVE=14
    NEAREST=15
    MYITEM=16
    END=17
    NOTHING=18
    ITEM=19
    MEM=20
    COMPARE=21
    CALC_OP=22
    NUMBER=23
    DIRECTION=24
    LABEL=25
    EOL=26
    COLON=27
    COMMA=28
    EQUAL=29
    AND=30
    OR=31
    LISTEN=32
    TELL=33
    EVERYONE=34
    MESSAGE=35
    FOREACHDIR=36
    ENDFOR=37
    GAMECOMMENT=38
    GAMECOMMENTDEF=39

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



    class AsmContext(ParserRuleContext):

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

        def line(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(SBHasmParser.LineContext)
            else:
                return self.getTypedRuleContext(SBHasmParser.LineContext,i)


        def getRuleIndex(self):
            return SBHasmParser.RULE_asm

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

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




    def asm(self):

        localctx = SBHasmParser.AsmContext(self, self._ctx, self.state)
        self.enterRule(localctx, 0, self.RULE_asm)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 65 
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 64
                self.line()
                self.state = 67 
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << SBHasmParser.COMMENT) | (1 << SBHasmParser.JUMP) | (1 << SBHasmParser.STEP) | (1 << SBHasmParser.PICKUP) | (1 << SBHasmParser.IF) | (1 << SBHasmParser.DROP) | (1 << SBHasmParser.WRITE) | (1 << SBHasmParser.TAKE) | (1 << SBHasmParser.GIVE) | (1 << SBHasmParser.END) | (1 << SBHasmParser.MEM) | (1 << SBHasmParser.LABEL) | (1 << SBHasmParser.EOL) | (1 << SBHasmParser.LISTEN) | (1 << SBHasmParser.TELL) | (1 << SBHasmParser.GAMECOMMENT) | (1 << SBHasmParser.GAMECOMMENTDEF))) != 0)):
                    break

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

    class LineContext(ParserRuleContext):

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

        def EOL(self):
            return self.getToken(SBHasmParser.EOL, 0)

        def cmd(self):
            return self.getTypedRuleContext(SBHasmParser.CmdContext,0)


        def comment(self):
            return self.getTypedRuleContext(SBHasmParser.CommentContext,0)


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


        def sbhcomment(self):
            return self.getTypedRuleContext(SBHasmParser.SbhcommentContext,0)


        def sbhcommentd(self):
            return self.getTypedRuleContext(SBHasmParser.SbhcommentdContext,0)


        def getRuleIndex(self):
            return SBHasmParser.RULE_line

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

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




    def line(self):

        localctx = SBHasmParser.LineContext(self, self._ctx, self.state)
        self.enterRule(localctx, 2, self.RULE_line)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 74
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [SBHasmParser.JUMP, SBHasmParser.STEP, SBHasmParser.PICKUP, SBHasmParser.IF, SBHasmParser.DROP, SBHasmParser.WRITE, SBHasmParser.TAKE, SBHasmParser.GIVE, SBHasmParser.END, SBHasmParser.MEM, SBHasmParser.LISTEN, SBHasmParser.TELL]:
                self.state = 69
                self.cmd()
                pass
            elif token in [SBHasmParser.COMMENT]:
                self.state = 70
                self.comment()
                pass
            elif token in [SBHasmParser.LABEL]:
                self.state = 71
                self.label()
                pass
            elif token in [SBHasmParser.GAMECOMMENT]:
                self.state = 72
                self.sbhcomment()
                pass
            elif token in [SBHasmParser.GAMECOMMENTDEF]:
                self.state = 73
                self.sbhcommentd()
                pass
            elif token in [SBHasmParser.EOL]:
                pass
            else:
                pass

            self.state = 76
            self.match(SBHasmParser.EOL)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class CmdContext(ParserRuleContext):

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

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

        def step(self):
            return self.getTypedRuleContext(SBHasmParser.StepContext,0)


        def pickup(self):
            return self.getTypedRuleContext(SBHasmParser.PickupContext,0)


        def cond(self):
            return self.getTypedRuleContext(SBHasmParser.CondContext,0)


        def write(self):
            return self.getTypedRuleContext(SBHasmParser.WriteContext,0)


        def drop(self):
            return self.getTypedRuleContext(SBHasmParser.DropContext,0)


        def calc(self):
            return self.getTypedRuleContext(SBHasmParser.CalcContext,0)


        def setval(self):
            return self.getTypedRuleContext(SBHasmParser.SetvalContext,0)


        def take(self):
            return self.getTypedRuleContext(SBHasmParser.TakeContext,0)


        def give(self):
            return self.getTypedRuleContext(SBHasmParser.GiveContext,0)


        def nearest(self):
            return self.getTypedRuleContext(SBHasmParser.NearestContext,0)


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

        def listen(self):
            return self.getTypedRuleContext(SBHasmParser.ListenContext,0)


        def tell(self):
            return self.getTypedRuleContext(SBHasmParser.TellContext,0)


        def foreachdir(self):
            return self.getTypedRuleContext(SBHasmParser.ForeachdirContext,0)


        def getRuleIndex(self):
            return SBHasmParser.RULE_cmd

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

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




    def cmd(self):

        localctx = SBHasmParser.CmdContext(self, self._ctx, self.state)
        self.enterRule(localctx, 4, self.RULE_cmd)
        try:
            self.state = 94
            self._errHandler.sync(self)
            la_ = self._interp.adaptivePredict(self._input,2,self._ctx)
            if la_ == 1:
                self.enterOuterAlt(localctx, 1)
                self.state = 78
                self.match(SBHasmParser.JUMP)
                pass

            elif la_ == 2:
                self.enterOuterAlt(localctx, 2)
                self.state = 79
                self.step()
                pass

            elif la_ == 3:
                self.enterOuterAlt(localctx, 3)
                self.state = 80
                self.pickup()
                pass

            elif la_ == 4:
                self.enterOuterAlt(localctx, 4)
                self.state = 81
                self.cond()
                pass

            elif la_ == 5:
                self.enterOuterAlt(localctx, 5)
                self.state = 82
                self.write()
                pass

            elif la_ == 6:
                self.enterOuterAlt(localctx, 6)
                self.state = 83
                self.drop()
                pass

            elif la_ == 7:
                self.enterOuterAlt(localctx, 7)
                self.state = 84
                self.calc()
                pass

            elif la_ == 8:
                self.enterOuterAlt(localctx, 8)
                self.state = 85
                self.setval()
                pass

            elif la_ == 9:
                self.enterOuterAlt(localctx, 9)
                self.state = 86
                self.take()
                pass

            elif la_ == 10:
                self.enterOuterAlt(localctx, 10)
                self.state = 87
                self.give()
                pass

            elif la_ == 11:
                self.enterOuterAlt(localctx, 11)
                self.state = 88
                self.nearest()
                pass

            elif la_ == 12:
                self.enterOuterAlt(localctx, 12)
                self.state = 89
                self.match(SBHasmParser.END)
                pass

            elif la_ == 13:
                self.enterOuterAlt(localctx, 13)
                self.state = 90
                self.pickup()
                pass

            elif la_ == 14:
                self.enterOuterAlt(localctx, 14)
                self.state = 91
                self.listen()
                pass

            elif la_ == 15:
                self.enterOuterAlt(localctx, 15)
                self.state = 92
                self.tell()
                pass

            elif la_ == 16:
                self.enterOuterAlt(localctx, 16)
                self.state = 93
                self.foreachdir()
                pass


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

    class PickupContext(ParserRuleContext):

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

        def PICKUP(self):
            return self.getToken(SBHasmParser.PICKUP, 0)

        def direction(self):
            return self.getTypedRuleContext(SBHasmParser.DirectionContext,0)


        def mem(self):
            return self.getTypedRuleContext(SBHasmParser.MemContext,0)


        def getRuleIndex(self):
            return SBHasmParser.RULE_pickup

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

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




    def pickup(self):

        localctx = SBHasmParser.PickupContext(self, self._ctx, self.state)
        self.enterRule(localctx, 6, self.RULE_pickup)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 96
            self.match(SBHasmParser.PICKUP)
            self.state = 99
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [SBHasmParser.DIRECTION]:
                self.state = 97
                self.direction()
                pass
            elif token in [SBHasmParser.MEM]:
                self.state = 98
                self.mem()
                pass
            elif token in [SBHasmParser.EOL]:
                pass
            else:
                pass
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class StepContext(ParserRuleContext):

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

        def STEP(self):
            return self.getToken(SBHasmParser.STEP, 0)

        def directions(self):
            return self.getTypedRuleContext(SBHasmParser.DirectionsContext,0)


        def mem(self):
            return self.getTypedRuleContext(SBHasmParser.MemContext,0)


        def getRuleIndex(self):
            return SBHasmParser.RULE_step

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

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




    def step(self):

        localctx = SBHasmParser.StepContext(self, self._ctx, self.state)
        self.enterRule(localctx, 8, self.RULE_step)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 101
            self.match(SBHasmParser.STEP)
            self.state = 104
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [SBHasmParser.DIRECTION]:
                self.state = 102
                self.directions()
                pass
            elif token in [SBHasmParser.MEM]:
                self.state = 103
                self.mem()
                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 DirectionsContext(ParserRuleContext):

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

        def direction(self):
            return self.getTypedRuleContext(SBHasmParser.DirectionContext,0)


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

        def directions(self):
            return self.getTypedRuleContext(SBHasmParser.DirectionsContext,0)


        def getRuleIndex(self):
            return SBHasmParser.RULE_directions

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

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




    def directions(self):

        localctx = SBHasmParser.DirectionsContext(self, self._ctx, self.state)
        self.enterRule(localctx, 10, self.RULE_directions)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 106
            self.direction()
            self.state = 109
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==SBHasmParser.COMMA:
                self.state = 107
                self.match(SBHasmParser.COMMA)
                self.state = 108
                self.directions()


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

    class LabelContext(ParserRuleContext):

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

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

        def getRuleIndex(self):
            return SBHasmParser.RULE_label

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

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




    def label(self):

        localctx = SBHasmParser.LabelContext(self, self._ctx, self.state)
        self.enterRule(localctx, 12, self.RULE_label)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 111
            self.match(SBHasmParser.LABEL)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class CondContext(ParserRuleContext):

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

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

        def expressions(self):
            return self.getTypedRuleContext(SBHasmParser.ExpressionsContext,0)


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

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

        def ENDIF(self):
            return self.getToken(SBHasmParser.ENDIF, 0)

        def line(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(SBHasmParser.LineContext)
            else:
                return self.getTypedRuleContext(SBHasmParser.LineContext,i)


        def sonst(self):
            return self.getTypedRuleContext(SBHasmParser.SonstContext,0)


        def getRuleIndex(self):
            return SBHasmParser.RULE_cond

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

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




    def cond(self):

        localctx = SBHasmParser.CondContext(self, self._ctx, self.state)
        self.enterRule(localctx, 14, self.RULE_cond)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 113
            self.match(SBHasmParser.IF)
            self.state = 114
            self.expressions()
            self.state = 115
            self.match(SBHasmParser.COLON)
            self.state = 116
            self.match(SBHasmParser.EOL)
            self.state = 118 
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 117
                self.line()
                self.state = 120 
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << SBHasmParser.COMMENT) | (1 << SBHasmParser.JUMP) | (1 << SBHasmParser.STEP) | (1 << SBHasmParser.PICKUP) | (1 << SBHasmParser.IF) | (1 << SBHasmParser.DROP) | (1 << SBHasmParser.WRITE) | (1 << SBHasmParser.TAKE) | (1 << SBHasmParser.GIVE) | (1 << SBHasmParser.END) | (1 << SBHasmParser.MEM) | (1 << SBHasmParser.LABEL) | (1 << SBHasmParser.EOL) | (1 << SBHasmParser.LISTEN) | (1 << SBHasmParser.TELL) | (1 << SBHasmParser.GAMECOMMENT) | (1 << SBHasmParser.GAMECOMMENTDEF))) != 0)):
                    break

            self.state = 129
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            if _la==SBHasmParser.ELSE:
                self.state = 122
                self.sonst()
                self.state = 123
                self.match(SBHasmParser.EOL)
                self.state = 125 
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                while True:
                    self.state = 124
                    self.line()
                    self.state = 127 
                    self._errHandler.sync(self)
                    _la = self._input.LA(1)
                    if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << SBHasmParser.COMMENT) | (1 << SBHasmParser.JUMP) | (1 << SBHasmParser.STEP) | (1 << SBHasmParser.PICKUP) | (1 << SBHasmParser.IF) | (1 << SBHasmParser.DROP) | (1 << SBHasmParser.WRITE) | (1 << SBHasmParser.TAKE) | (1 << SBHasmParser.GIVE) | (1 << SBHasmParser.END) | (1 << SBHasmParser.MEM) | (1 << SBHasmParser.LABEL) | (1 << SBHasmParser.EOL) | (1 << SBHasmParser.LISTEN) | (1 << SBHasmParser.TELL) | (1 << SBHasmParser.GAMECOMMENT) | (1 << SBHasmParser.GAMECOMMENTDEF))) != 0)):
                        break



            self.state = 131
            self.match(SBHasmParser.ENDIF)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

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


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

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

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

        def getRuleIndex(self):
            return SBHasmParser.RULE_expressions

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

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




    def expressions(self):

        localctx = SBHasmParser.ExpressionsContext(self, self._ctx, self.state)
        self.enterRule(localctx, 16, self.RULE_expressions)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 133
            self.expression()
            self.state = 139
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while _la==SBHasmParser.AND or _la==SBHasmParser.OR:
                self.state = 134
                _la = self._input.LA(1)
                if not(_la==SBHasmParser.AND or _la==SBHasmParser.OR):
                    self._errHandler.recoverInline(self)
                else:
                    self._errHandler.reportMatch(self)
                    self.consume()
                self.state = 135
                self.match(SBHasmParser.EOL)
                self.state = 136
                self.expression()
                self.state = 141
                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 ExpressionContext(ParserRuleContext):

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

        def COMPARE(self):
            return self.getToken(SBHasmParser.COMPARE, 0)

        def direction(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(SBHasmParser.DirectionContext)
            else:
                return self.getTypedRuleContext(SBHasmParser.DirectionContext,i)


        def items(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(SBHasmParser.ItemsContext)
            else:
                return self.getTypedRuleContext(SBHasmParser.ItemsContext,i)


        def number(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(SBHasmParser.NumberContext)
            else:
                return self.getTypedRuleContext(SBHasmParser.NumberContext,i)


        def getRuleIndex(self):
            return SBHasmParser.RULE_expression

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

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




    def expression(self):

        localctx = SBHasmParser.ExpressionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 18, self.RULE_expression)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 145
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [SBHasmParser.DIRECTION]:
                self.state = 142
                self.direction()
                pass
            elif token in [SBHasmParser.MYITEM, SBHasmParser.NOTHING, SBHasmParser.ITEM, SBHasmParser.MEM]:
                self.state = 143
                self.items()
                pass
            elif token in [SBHasmParser.NUMBER]:
                self.state = 144
                self.number()
                pass
            else:
                raise NoViableAltException(self)

            self.state = 147
            self.match(SBHasmParser.COMPARE)
            self.state = 151
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [SBHasmParser.DIRECTION]:
                self.state = 148
                self.direction()
                pass
            elif token in [SBHasmParser.MYITEM, SBHasmParser.NOTHING, SBHasmParser.ITEM, SBHasmParser.MEM]:
                self.state = 149
                self.items()
                pass
            elif token in [SBHasmParser.NUMBER]:
                self.state = 150
                self.number()
                pass
            else:
                raise NoViableAltException(self)

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

    class CommentContext(ParserRuleContext):

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

        def COMMENT(self):
            return self.getToken(SBHasmParser.COMMENT, 0)

        def getRuleIndex(self):
            return SBHasmParser.RULE_comment

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

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




    def comment(self):

        localctx = SBHasmParser.CommentContext(self, self._ctx, self.state)
        self.enterRule(localctx, 20, self.RULE_comment)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 153
            self.match(SBHasmParser.COMMENT)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ItemsContext(ParserRuleContext):

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

        def item(self):
            return self.getTypedRuleContext(SBHasmParser.ItemContext,0)


        def mem(self):
            return self.getTypedRuleContext(SBHasmParser.MemContext,0)


        def MYITEM(self):
            return self.getToken(SBHasmParser.MYITEM, 0)

        def NOTHING(self):
            return self.getToken(SBHasmParser.NOTHING, 0)

        def getRuleIndex(self):
            return SBHasmParser.RULE_items

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

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




    def items(self):

        localctx = SBHasmParser.ItemsContext(self, self._ctx, self.state)
        self.enterRule(localctx, 22, self.RULE_items)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 159
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [SBHasmParser.ITEM]:
                self.state = 155
                self.item()
                pass
            elif token in [SBHasmParser.MEM]:
                self.state = 156
                self.mem()
                pass
            elif token in [SBHasmParser.MYITEM]:
                self.state = 157
                self.match(SBHasmParser.MYITEM)
                pass
            elif token in [SBHasmParser.NOTHING]:
                self.state = 158
                self.match(SBHasmParser.NOTHING)
                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 ItemContext(ParserRuleContext):

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

        def ITEM(self):
            return self.getToken(SBHasmParser.ITEM, 0)

        def getRuleIndex(self):
            return SBHasmParser.RULE_item

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

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




    def item(self):

        localctx = SBHasmParser.ItemContext(self, self._ctx, self.state)
        self.enterRule(localctx, 24, self.RULE_item)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 161
            self.match(SBHasmParser.ITEM)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class WriteContext(ParserRuleContext):

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

        def WRITE(self):
            return self.getToken(SBHasmParser.WRITE, 0)

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


        def direction(self):
            return self.getTypedRuleContext(SBHasmParser.DirectionContext,0)


        def mem(self):
            return self.getTypedRuleContext(SBHasmParser.MemContext,0)


        def getRuleIndex(self):
            return SBHasmParser.RULE_write

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

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




    def write(self):

        localctx = SBHasmParser.WriteContext(self, self._ctx, self.state)
        self.enterRule(localctx, 26, self.RULE_write)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 163
            self.match(SBHasmParser.WRITE)
            self.state = 167
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [SBHasmParser.NUMBER]:
                self.state = 164
                self.number()
                pass
            elif token in [SBHasmParser.DIRECTION]:
                self.state = 165
                self.direction()
                pass
            elif token in [SBHasmParser.MEM]:
                self.state = 166
                self.mem()
                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 CalcContext(ParserRuleContext):

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

        def mem(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(SBHasmParser.MemContext)
            else:
                return self.getTypedRuleContext(SBHasmParser.MemContext,i)


        def EQUAL(self):
            return self.getToken(SBHasmParser.EQUAL, 0)

        def CALC(self):
            return self.getToken(SBHasmParser.CALC, 0)

        def calcop(self):
            return self.getTypedRuleContext(SBHasmParser.CalcopContext,0)


        def direction(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(SBHasmParser.DirectionContext)
            else:
                return self.getTypedRuleContext(SBHasmParser.DirectionContext,i)


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

        def number(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(SBHasmParser.NumberContext)
            else:
                return self.getTypedRuleContext(SBHasmParser.NumberContext,i)


        def getRuleIndex(self):
            return SBHasmParser.RULE_calc

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

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




    def calc(self):

        localctx = SBHasmParser.CalcContext(self, self._ctx, self.state)
        self.enterRule(localctx, 28, self.RULE_calc)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 169
            self.mem()
            self.state = 170
            self.match(SBHasmParser.EQUAL)
            self.state = 171
            self.match(SBHasmParser.CALC)
            self.state = 176
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [SBHasmParser.DIRECTION]:
                self.state = 172
                self.direction()
                pass
            elif token in [SBHasmParser.MEM]:
                self.state = 173
                self.mem()
                pass
            elif token in [SBHasmParser.MYITEM]:
                self.state = 174
                self.match(SBHasmParser.MYITEM)
                pass
            elif token in [SBHasmParser.NUMBER]:
                self.state = 175
                self.number()
                pass
            else:
                raise NoViableAltException(self)

            self.state = 178
            self.calcop()
            self.state = 183
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [SBHasmParser.DIRECTION]:
                self.state = 179
                self.direction()
                pass
            elif token in [SBHasmParser.MEM]:
                self.state = 180
                self.mem()
                pass
            elif token in [SBHasmParser.MYITEM]:
                self.state = 181
                self.match(SBHasmParser.MYITEM)
                pass
            elif token in [SBHasmParser.NUMBER]:
                self.state = 182
                self.number()
                pass
            else:
                raise NoViableAltException(self)

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

    class SetvalContext(ParserRuleContext):

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

        def mem(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(SBHasmParser.MemContext)
            else:
                return self.getTypedRuleContext(SBHasmParser.MemContext,i)


        def EQUAL(self):
            return self.getToken(SBHasmParser.EQUAL, 0)

        def SET(self):
            return self.getToken(SBHasmParser.SET, 0)

        def direction(self):
            return self.getTypedRuleContext(SBHasmParser.DirectionContext,0)


        def MYITEM(self):
            return self.getToken(SBHasmParser.MYITEM, 0)

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


        def NOTHING(self):
            return self.getToken(SBHasmParser.NOTHING, 0)

        def getRuleIndex(self):
            return SBHasmParser.RULE_setval

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

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




    def setval(self):

        localctx = SBHasmParser.SetvalContext(self, self._ctx, self.state)
        self.enterRule(localctx, 30, self.RULE_setval)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 185
            self.mem()
            self.state = 186
            self.match(SBHasmParser.EQUAL)
            self.state = 187
            self.match(SBHasmParser.SET)
            self.state = 193
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [SBHasmParser.DIRECTION]:
                self.state = 188
                self.direction()
                pass
            elif token in [SBHasmParser.MEM]:
                self.state = 189
                self.mem()
                pass
            elif token in [SBHasmParser.MYITEM]:
                self.state = 190
                self.match(SBHasmParser.MYITEM)
                pass
            elif token in [SBHasmParser.NUMBER]:
                self.state = 191
                self.number()
                pass
            elif token in [SBHasmParser.NOTHING]:
                self.state = 192
                self.match(SBHasmParser.NOTHING)
                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 TakeContext(ParserRuleContext):

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

        def TAKE(self):
            return self.getToken(SBHasmParser.TAKE, 0)

        def direction(self):
            return self.getTypedRuleContext(SBHasmParser.DirectionContext,0)


        def mem(self):
            return self.getTypedRuleContext(SBHasmParser.MemContext,0)


        def getRuleIndex(self):
            return SBHasmParser.RULE_take

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

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




    def take(self):

        localctx = SBHasmParser.TakeContext(self, self._ctx, self.state)
        self.enterRule(localctx, 32, self.RULE_take)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 195
            self.match(SBHasmParser.TAKE)
            self.state = 198
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [SBHasmParser.DIRECTION]:
                self.state = 196
                self.direction()
                pass
            elif token in [SBHasmParser.MEM]:
                self.state = 197
                self.mem()
                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 GiveContext(ParserRuleContext):

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

        def GIVE(self):
            return self.getToken(SBHasmParser.GIVE, 0)

        def direction(self):
            return self.getTypedRuleContext(SBHasmParser.DirectionContext,0)


        def mem(self):
            return self.getTypedRuleContext(SBHasmParser.MemContext,0)


        def getRuleIndex(self):
            return SBHasmParser.RULE_give

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

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




    def give(self):

        localctx = SBHasmParser.GiveContext(self, self._ctx, self.state)
        self.enterRule(localctx, 34, self.RULE_give)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 200
            self.match(SBHasmParser.GIVE)
            self.state = 203
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [SBHasmParser.DIRECTION]:
                self.state = 201
                self.direction()
                pass
            elif token in [SBHasmParser.MEM]:
                self.state = 202
                self.mem()
                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 NearestContext(ParserRuleContext):

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

        def mem(self):
            return self.getTypedRuleContext(SBHasmParser.MemContext,0)


        def EQUAL(self):
            return self.getToken(SBHasmParser.EQUAL, 0)

        def NEAREST(self):
            return self.getToken(SBHasmParser.NEAREST, 0)

        def item(self):
            return self.getTypedRuleContext(SBHasmParser.ItemContext,0)


        def getRuleIndex(self):
            return SBHasmParser.RULE_nearest

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

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




    def nearest(self):

        localctx = SBHasmParser.NearestContext(self, self._ctx, self.state)
        self.enterRule(localctx, 36, self.RULE_nearest)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 205
            self.mem()
            self.state = 206
            self.match(SBHasmParser.EQUAL)
            self.state = 207
            self.match(SBHasmParser.NEAREST)
            self.state = 208
            self.item()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class DropContext(ParserRuleContext):

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

        def DROP(self):
            return self.getToken(SBHasmParser.DROP, 0)

        def getRuleIndex(self):
            return SBHasmParser.RULE_drop

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

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




    def drop(self):

        localctx = SBHasmParser.DropContext(self, self._ctx, self.state)
        self.enterRule(localctx, 38, self.RULE_drop)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 210
            self.match(SBHasmParser.DROP)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class SonstContext(ParserRuleContext):

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

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

        def getRuleIndex(self):
            return SBHasmParser.RULE_sonst

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

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




    def sonst(self):

        localctx = SBHasmParser.SonstContext(self, self._ctx, self.state)
        self.enterRule(localctx, 40, self.RULE_sonst)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 212
            self.match(SBHasmParser.ELSE)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class SbhcommentContext(ParserRuleContext):

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

        def GAMECOMMENT(self):
            return self.getToken(SBHasmParser.GAMECOMMENT, 0)

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


        def getRuleIndex(self):
            return SBHasmParser.RULE_sbhcomment

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

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




    def sbhcomment(self):

        localctx = SBHasmParser.SbhcommentContext(self, self._ctx, self.state)
        self.enterRule(localctx, 42, self.RULE_sbhcomment)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 214
            self.match(SBHasmParser.GAMECOMMENT)
            self.state = 215
            self.number()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class SbhcommentdContext(ParserRuleContext):

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

        def GAMECOMMENTDEF(self):
            return self.getToken(SBHasmParser.GAMECOMMENTDEF, 0)

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


        def getRuleIndex(self):
            return SBHasmParser.RULE_sbhcommentd

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

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




    def sbhcommentd(self):

        localctx = SBHasmParser.SbhcommentdContext(self, self._ctx, self.state)
        self.enterRule(localctx, 44, self.RULE_sbhcommentd)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 217
            self.match(SBHasmParser.GAMECOMMENTDEF)
            self.state = 218
            self.number()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ListenContext(ParserRuleContext):

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

        def LISTEN(self):
            return self.getToken(SBHasmParser.LISTEN, 0)

        def message(self):
            return self.getTypedRuleContext(SBHasmParser.MessageContext,0)


        def getRuleIndex(self):
            return SBHasmParser.RULE_listen

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

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




    def listen(self):

        localctx = SBHasmParser.ListenContext(self, self._ctx, self.state)
        self.enterRule(localctx, 46, self.RULE_listen)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 220
            self.match(SBHasmParser.LISTEN)
            self.state = 221
            self.message()
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class TellContext(ParserRuleContext):

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

        def TELL(self):
            return self.getToken(SBHasmParser.TELL, 0)

        def message(self):
            return self.getTypedRuleContext(SBHasmParser.MessageContext,0)


        def everyone(self):
            return self.getTypedRuleContext(SBHasmParser.EveryoneContext,0)


        def direction(self):
            return self.getTypedRuleContext(SBHasmParser.DirectionContext,0)


        def getRuleIndex(self):
            return SBHasmParser.RULE_tell

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

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




    def tell(self):

        localctx = SBHasmParser.TellContext(self, self._ctx, self.state)
        self.enterRule(localctx, 48, self.RULE_tell)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 223
            self.match(SBHasmParser.TELL)
            self.state = 226
            self._errHandler.sync(self)
            token = self._input.LA(1)
            if token in [SBHasmParser.EVERYONE]:
                self.state = 224
                self.everyone()
                pass
            elif token in [SBHasmParser.DIRECTION]:
                self.state = 225
                self.direction()
                pass
            else:
                raise NoViableAltException(self)

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

    class DirectionContext(ParserRuleContext):

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

        def DIRECTION(self):
            return self.getToken(SBHasmParser.DIRECTION, 0)

        def getRuleIndex(self):
            return SBHasmParser.RULE_direction

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

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




    def direction(self):

        localctx = SBHasmParser.DirectionContext(self, self._ctx, self.state)
        self.enterRule(localctx, 50, self.RULE_direction)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 230
            self.match(SBHasmParser.DIRECTION)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class MemContext(ParserRuleContext):

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

        def MEM(self):
            return self.getToken(SBHasmParser.MEM, 0)

        def getRuleIndex(self):
            return SBHasmParser.RULE_mem

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

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




    def mem(self):

        localctx = SBHasmParser.MemContext(self, self._ctx, self.state)
        self.enterRule(localctx, 52, self.RULE_mem)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 232
            self.match(SBHasmParser.MEM)
        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 NUMBER(self):
            return self.getToken(SBHasmParser.NUMBER, 0)

        def getRuleIndex(self):
            return SBHasmParser.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 = SBHasmParser.NumberContext(self, self._ctx, self.state)
        self.enterRule(localctx, 54, self.RULE_number)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 234
            self.match(SBHasmParser.NUMBER)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class CalcopContext(ParserRuleContext):

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

        def CALC_OP(self):
            return self.getToken(SBHasmParser.CALC_OP, 0)

        def getRuleIndex(self):
            return SBHasmParser.RULE_calcop

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

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




    def calcop(self):

        localctx = SBHasmParser.CalcopContext(self, self._ctx, self.state)
        self.enterRule(localctx, 56, self.RULE_calcop)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 236
            self.match(SBHasmParser.CALC_OP)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class MessageContext(ParserRuleContext):

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

        def MESSAGE(self):
            return self.getToken(SBHasmParser.MESSAGE, 0)

        def getRuleIndex(self):
            return SBHasmParser.RULE_message

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

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




    def message(self):

        localctx = SBHasmParser.MessageContext(self, self._ctx, self.state)
        self.enterRule(localctx, 58, self.RULE_message)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 238
            self.match(SBHasmParser.MESSAGE)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class EveryoneContext(ParserRuleContext):

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

        def EVERYONE(self):
            return self.getToken(SBHasmParser.EVERYONE, 0)

        def getRuleIndex(self):
            return SBHasmParser.RULE_everyone

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

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




    def everyone(self):

        localctx = SBHasmParser.EveryoneContext(self, self._ctx, self.state)
        self.enterRule(localctx, 60, self.RULE_everyone)
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 240
            self.match(SBHasmParser.EVERYONE)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx

    class ForeachdirContext(ParserRuleContext):

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

        def mem(self):
            return self.getTypedRuleContext(SBHasmParser.MemContext,0)


        def EQUAL(self):
            return self.getToken(SBHasmParser.EQUAL, 0)

        def FOREACHDIR(self):
            return self.getToken(SBHasmParser.FOREACHDIR, 0)

        def directions(self):
            return self.getTypedRuleContext(SBHasmParser.DirectionsContext,0)


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

        def EOL(self):
            return self.getToken(SBHasmParser.EOL, 0)

        def ENDFOR(self):
            return self.getToken(SBHasmParser.ENDFOR, 0)

        def line(self, i:int=None):
            if i is None:
                return self.getTypedRuleContexts(SBHasmParser.LineContext)
            else:
                return self.getTypedRuleContext(SBHasmParser.LineContext,i)


        def getRuleIndex(self):
            return SBHasmParser.RULE_foreachdir

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

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




    def foreachdir(self):

        localctx = SBHasmParser.ForeachdirContext(self, self._ctx, self.state)
        self.enterRule(localctx, 62, self.RULE_foreachdir)
        self._la = 0 # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 242
            self.mem()
            self.state = 243
            self.match(SBHasmParser.EQUAL)
            self.state = 244
            self.match(SBHasmParser.FOREACHDIR)
            self.state = 245
            self.directions()
            self.state = 246
            self.match(SBHasmParser.COLON)
            self.state = 247
            self.match(SBHasmParser.EOL)
            self.state = 249 
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 248
                self.line()
                self.state = 251 
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << SBHasmParser.COMMENT) | (1 << SBHasmParser.JUMP) | (1 << SBHasmParser.STEP) | (1 << SBHasmParser.PICKUP) | (1 << SBHasmParser.IF) | (1 << SBHasmParser.DROP) | (1 << SBHasmParser.WRITE) | (1 << SBHasmParser.TAKE) | (1 << SBHasmParser.GIVE) | (1 << SBHasmParser.END) | (1 << SBHasmParser.MEM) | (1 << SBHasmParser.LABEL) | (1 << SBHasmParser.EOL) | (1 << SBHasmParser.LISTEN) | (1 << SBHasmParser.TELL) | (1 << SBHasmParser.GAMECOMMENT) | (1 << SBHasmParser.GAMECOMMENTDEF))) != 0)):
                    break

            self.state = 253
            self.match(SBHasmParser.ENDFOR)
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx
# Generated from SBHasm.g4 by ANTLR 4.7.1 # encoding: utf-8 #\3\2\2\2\u00ca\u00cd\7") #\2\2\u00e2\u00e5\5> \2\u00e3\u00e5") # Token type # Token type # Token type # Token type # Token type