Example #1
0
        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));
        }
Example #2
0
        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);
        }