/// <summary> /// Run Statement /// </summary> /// <param name="BasicIntrepeter">Basic Intrepeter that called the Statement</param> public override void ExcecuteStatement(Basic BasicIntrepeter) { BasicIntrepeter.CodeParser.Expect(typeof(GotoToken)); if (BasicIntrepeter.CodeParser.CurrentToken.GetType().Equals(typeof(NumericToken))) { BasicIntrepeter.JumpToLine(Parser.CurrentToken.asNumber()); } else if (BasicIntrepeter.CodeParser.CurrentToken.GetType().Equals(typeof(TextToken))) { BasicIntrepeter.JumpToLabel(Parser.CurrentToken.Content); } }
/// <summary> /// Run Statement /// </summary> /// <param name="BasicIntrepeter">Basic Intrepeter that called the Statement</param> public override void ExcecuteStatement(Basic BasicIntrepeter) { BasicIntrepeter.CodeParser.Expect(typeof(GosubToken)); if (BasicIntrepeter.CodeParser.CurrentToken.GetType().Equals(typeof(NumericToken))) { double GotoLineNumber = BasicIntrepeter.CodeParser.CurrentToken.asNumber(); BasicIntrepeter.CodeParser.Expect(typeof(NumericToken)); // Find start of next line (Used for if then else loops) while (!BasicIntrepeter.CodeParser.CurrentToken.GetType().Equals(typeof(EndOfLineToken)) && !BasicIntrepeter.CodeParser.CurrentToken.GetType().Equals(typeof(EndOfInputToken))) BasicIntrepeter.CodeParser.Next(); if (BasicIntrepeter.GOSUBStackPosition < (BasicIntrepeter.GOSUBStack.Length - 1)) { BasicIntrepeter.GOSUBStack[BasicIntrepeter.GOSUBStackPosition] = BasicIntrepeter.CodeParser.ProgramPosition - 1; BasicIntrepeter.GOSUBStackPosition++; BasicIntrepeter.JumpToLine(GotoLineNumber); } else { throw new MFBasic.Exceptions.BasicLanguageException(MFBasic.Exceptions.BasicLanguageException.GOSUB_STACK_EXHAUSTED); } } else if (BasicIntrepeter.CodeParser.CurrentToken.GetType().Equals(typeof(TextToken))) { String GotoLabel = BasicIntrepeter.CodeParser.CurrentToken.Content; BasicIntrepeter.CodeParser.Expect(typeof(TextToken)); // Find start of next line (Used for if then else loops) while (!BasicIntrepeter.CodeParser.CurrentToken.GetType().Equals(typeof(EndOfLineToken)) && !BasicIntrepeter.CodeParser.CurrentToken.GetType().Equals(typeof(EndOfInputToken))) BasicIntrepeter.CodeParser.Next(); if (BasicIntrepeter.GOSUBStackPosition < (BasicIntrepeter.GOSUBStack.Length - 1)) { BasicIntrepeter.GOSUBStack[BasicIntrepeter.GOSUBStackPosition] = BasicIntrepeter.CodeParser.ProgramPosition - 1; BasicIntrepeter.GOSUBStackPosition++; BasicIntrepeter.JumpToLabel(GotoLabel); } else { throw new MFBasic.Exceptions.BasicLanguageException(MFBasic.Exceptions.BasicLanguageException.GOSUB_STACK_EXHAUSTED); } } }