/// <summary> /// Entry point of the program. Processes command-line arguments. /// </summary> /// <param name="args">The command-line arguments.</param> public static void Main(string[] args) { if (args.Length < 1) { PrintHelp(); return; } Parser parser = new Parser(); Interpreter interpreter = new Interpreter(30000, System.Console.In, System.Console.Out); parser.GenerateASTFromString(System.IO.File.ReadAllText(args[0])); List<IInstruction> program = parser.AbstractSyntaxTree; interpreter.Interpret(program); }
/// <summary> /// Handles a loop in the code. /// </summary> /// <returns>A loop filled with many glorious instructions.</returns> private Loop HandleLoop() { //An empty loop. Loop result = new Loop(); //Match the end of the loop. int i = FindMatchingEndOfLoop(); //Divide this into bits within this loop, and bits outside. string firstpart = i == -1 ? this._inputString : this._inputString.Substring(0, i); this._inputString = this._inputString.Substring(i); //A new parsing context. Parser subprogram = new Parser(); //Our loop needs to contains a list of instructions. subprogram.GenerateASTFromString(firstpart); result.Statements = subprogram.AbstractSyntaxTree; return result; }