private void construct(TextReader stream, FunctionDefinition[] functionDefinitions, VariableDefinition[] variableDefinitions) { Debug.Assert(stream != null); Debug.Assert(functionDefinitions != null); m_compileTimeErrorHandler = new ErrorHandler(); m_runtimeErrorHandler = new ErrorHandler(); m_tokens = Tokenize(stream); m_ast = Parse(m_tokens); if (m_compileTimeErrorHandler.getErrors().Count > 0) { m_compileTimeErrorHandler.printErrorsToConsole(); return; } AddLocalVariables(m_ast, variableDefinitions); ExternalFunctionCreator externalFunctionCreator = AddExternalFunctions(functionDefinitions, m_ast); Scope globalScope = CreateScopeTree(m_ast); if (m_compileTimeErrorHandler.getErrors().Count > 0) { m_compileTimeErrorHandler.printErrorsToConsole(); return; } m_interpreter = new InterpreterTwo(m_ast, globalScope, m_runtimeErrorHandler, externalFunctionCreator); m_started = false; //PaintAST(m_ast); }
public void TooManyTokensInStatements() { ErrorHandler errorHandler = new ErrorHandler(); Tokenizer tokenizer = new Tokenizer(errorHandler, true); List <Token> tokens = tokenizer.process(File.OpenText("code18.txt")); Parser parser = new Parser(tokens, errorHandler); parser.process(); errorHandler.printErrorsToConsole(); Assert.AreEqual(3, errorHandler.getErrors().Count); }
private void construct(TextReader stream, FunctionDefinition[] functionDefinitions, VariableDefinition[] variableDefinitions) { Debug.Assert(stream != null); Debug.Assert(functionDefinitions != null); m_compileTimeErrorHandler = new ErrorHandler(); m_runtimeErrorHandler = new ErrorHandler(); m_tokens = Tokenize(stream); m_ast = Parse(m_tokens); if(m_compileTimeErrorHandler.getErrors().Count > 0) { m_compileTimeErrorHandler.printErrorsToConsole(); return; } AddLocalVariables(m_ast, variableDefinitions); ExternalFunctionCreator externalFunctionCreator = AddExternalFunctions(functionDefinitions, m_ast); Scope globalScope = CreateScopeTree(m_ast); if(m_compileTimeErrorHandler.getErrors().Count > 0) { m_compileTimeErrorHandler.printErrorsToConsole(); return; } m_interpreter = new InterpreterTwo(m_ast, globalScope, m_runtimeErrorHandler, externalFunctionCreator); m_started = false; //PaintAST(m_ast); }
public void TooManyTokensInStatements() { ErrorHandler errorHandler = new ErrorHandler(); Tokenizer tokenizer = new Tokenizer(errorHandler, true); List<Token> tokens = tokenizer.process(File.OpenText("code18.txt")); Parser parser = new Parser(tokens, errorHandler); parser.process(); errorHandler.printErrorsToConsole(); Assert.AreEqual(3, errorHandler.getErrors().Count); }