static void InterpretFile(string filename) { Interpreter i = new Interpreter(); string contents = File.ReadAllText(filename); Console.WriteLine(i.Interpret(contents)); }
static void ReplPrompt() { Interpreter i = new Interpreter(); for (; ;) { bool completeInput = false; int openParens = 0; int closeParens = 0; List<Token> partialInput = new List<Token>(); while (completeInput != true) { if (openParens != closeParens) { Console.Write("schemin* "); } else { Console.Write("schemin> "); } string line = Console.ReadLine(); // bust out right here if the user wants to exit if (line == ",exit") { return; } var lineTokens = i.tokenizer.Tokenize(line); foreach (Token token in lineTokens) { partialInput.Add(token); if (token.Type == TokenType.OpenParen) { openParens++; } else if (token.Type == TokenType.CloseParen) { closeParens++; } } if (openParens == closeParens) { completeInput = true; break; } } if (partialInput.Count < 1) { continue; } Console.WriteLine(i.Interpret(partialInput)); } }