public void BasicErrorHandlerUsage() { ErrorHandler errorHandler = new ErrorHandler(); errorHandler.errorOccured("Test error 1.", Error.ErrorType.UNDEFINED); errorHandler.errorOccured("Test error 2.", Error.ErrorType.SYNTAX, 10, 20); Assert.AreEqual(2, errorHandler.getErrors().Count); }
private void construct(TextReader stream, FunctionDefinition[] functionDefinitions, VariableDefinition[] variableDefinitions) { nrOfSprakRunnersInMemory++; Debug.Assert(stream != null); Debug.Assert(functionDefinitions != null); m_compileTimeErrorHandler = new ErrorHandler(); m_runtimeErrorHandler = new ErrorHandler(); m_tokens = Tokenize(stream); try { //PrintTokens (); m_ast = Parse(m_tokens); if (m_compileTimeErrorHandler.getErrors().Count > 0) { m_compileTimeErrorHandler.printErrorsToConsole(); return; } //PaintAST(m_ast); 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; } catch (Error e) { m_compileTimeErrorHandler.errorOccured(e); return; } }
private void construct(TextReader stream, FunctionDefinition[] functionDefinitions, VariableDefinition[] variableDefinitions) { nrOfSprakRunnersInMemory++; Debug.Assert(stream != null); Debug.Assert(functionDefinitions != null); m_compileTimeErrorHandler = new ErrorHandler(); m_runtimeErrorHandler = new ErrorHandler(); m_tokens = Tokenize(stream); try { //PrintTokens (); m_ast = Parse(m_tokens); if(m_compileTimeErrorHandler.getErrors().Count > 0) { m_compileTimeErrorHandler.printErrorsToConsole(); return; } //PaintAST(m_ast); 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; } catch(Error e) { m_compileTimeErrorHandler.errorOccured (e); return; } }