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); }
public Interpreter(AST ast, Scope globalScope, ErrorHandler errorHandler, ExternalFunctionCreator externalFunctionCreator) { m_ast = ast; m_errorHandler = errorHandler; m_globalScope = globalScope; m_currentScope = m_globalScope; m_externalFunctionCreator = externalFunctionCreator; }
public ScopeBuilder(AST ast, ErrorHandler errorHandler) { Debug.Assert(ast != null); Debug.Assert(errorHandler != null); m_errorHandler = errorHandler; m_ast = ast; }
public Parser(List<Token> tokens, ErrorHandler errorHandler) { m_tokens = tokens; m_errorHandler = errorHandler; m_nextTokenIndex = 0; m_lookahead = new Token[k]; m_lookaheadIndex = 0; //Fill lookahead buffer: for (int i = 0; i < k; i++) { consumeCurrentToken(); } m_programAST = new AST(new Token(Token.TokenType.PROGRAM_ROOT, "<PROGRAM_ROOT>")); m_isInsideFunctionDefinition = false; m_processed = false; }
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 Tokenizer(ErrorHandler errorHandler, bool stripOutComments) { m_errorHandler = errorHandler; m_stripOutComments = stripOutComments; }
public void UnrecognizedChar() { TextReader reader = File.OpenText("code17.txt"); ErrorHandler errorHandler = new ErrorHandler(); Tokenizer tokenizer = new Tokenizer(errorHandler, true); tokenizer.process(File.OpenText("code17.txt")); List<Error> errors = errorHandler.getErrors(); Assert.AreEqual(3, errors.Count); }
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); }