public void LoadAllLinesAndExecute() { using (StreamReader sr = new StreamReader(fileName)) { string temp = sr.ReadLine(); LinePointer.SetFirstLine(beginFileTokenLineNumber); while (!FoundBeginFile(temp)) { fileLineTokens.Add(new TokenLine(temp.Trim())); LinePointer.Increment(); temp = sr.ReadLine(); beginFileTokenLineNumber++; } while (temp != null) { fileLineTokens.Add(new TokenLine(temp.Trim())); LinePointer.Increment(); temp = sr.ReadLine(); } LinePointer.SetFirstLine(beginFileTokenLineNumber); } LoadLineMarkers(); ParseAndExecute(); }
private static void ReturnPointer(Token[] functionArguments) { if (functionArguments.Length > 0) { throw new ILSException("Return does not take arguments"); } LinePointer.ReturnMostRecent(); }
private void ParseAndExecute() { while (LinePointer.GetCurrentLine() < fileLineTokens.Count) { int line = LinePointer.GetCurrentLine(); fileLineTokens[line - 1].ParseAndExecute(); LinePointer.Increment(); } }
public static void RunFunction(string function, Token[] functionArguments) { string output = GetOutput(functionArguments); FunctionName result; Enum.TryParse(function, out result); if (result == FunctionName.PRINT) { Console.Write(output); } else if (result == FunctionName.PRINTN) { Console.WriteLine(output); } else if (result == FunctionName.UPDATE) { UpdateVariable(functionArguments); } else if (result == FunctionName.JUMPTO) { LinePointer.InsertJump(GetLineJumpNumber(functionArguments)); } else if (result == FunctionName.JUMPONCE) { LinePointer.InsertJumpOnce(GetLineJumpNumber(functionArguments)); } else if (result == FunctionName.RETURN) { ReturnPointer(functionArguments); } }
public ILSException(string m) : base("Exception thrown on line " + LinePointer.GetCurrentLine() + ": " + m) { }
public static void LogErrorAndQuit(string errorMessage) { Console.WriteLine("Exception thrown on line " + LinePointer.GetCurrentLine() + ": " + errorMessage); Console.ReadKey(); Environment.Exit(0); }
public void Return(Token[] args) { LinePointer.ReturnMostRecent(); }
public void Jumponce(Token[] args) { int linenumber = GetLineJumpNumber(args); LinePointer.InsertJumpOnce(linenumber); }