public void TestCanRecogniseIntegers(string sample, string expectedType) { var lexer = new FifthLexer(new AntlrInputStream(sample)); lexer.RemoveErrorListeners(); lexer.AddErrorListener(new ThrowingErrorListener <int>()); var token = lexer.NextToken(); Assert.That(token.Type, Is.EqualTo(lexer.TokenTypeMap[expectedType])); Assert.That(token.Text, Is.EqualTo(sample)); }
protected static FifthParser GetParserFor(string fragment) { var lexer = new FifthLexer(new AntlrInputStream(fragment)); lexer.RemoveErrorListeners(); lexer.AddErrorListener(new ThrowingErrorListener <int>()); var parser = new FifthParser(new CommonTokenStream(lexer)); parser.RemoveErrorListeners(); parser.AddErrorListener(new ThrowingErrorListener <IToken>()); return(parser); }
private static FifthParser GetParserFor(ICharStream source) { var lexer = new FifthLexer(source); lexer.RemoveErrorListeners(); lexer.AddErrorListener(new ThrowingErrorListener <int>()); var parser = new FifthParser(new CommonTokenStream(lexer)); parser.RemoveErrorListeners(); parser.AddErrorListener(new ThrowingErrorListener <IToken>()); return(parser); }