TerminalParser { static <T> T parse(Parser<T> parser, String source) { return parser.from(TOKENIZER, Scanners.JAVA_DELIMITER).parse(source); }  static Parser<Token> adjacent(Parser<List<Token>> parser, final Parser<?> otherwise); static Parser<Token> adjacent(String operator); static Parser<?> term(String name); static Parser<?> phrase(String phrase);  }
@Test public void testParse() { assertParser(TerminalParser.term("."), " . \n new Token(2, 1, Tokens.reserved("."))); }
@Test public void testLexer() { Parser<?> parser = TerminalParser.TOKENIZER; assertEquals(new ScientificNumberLiteral("1e2", NumberType.DOUBLE), parser.parse("1e2")); assertEquals(new ScientificNumberLiteral("1e2", NumberType.FLOAT), parser.parse("1e2f")); assertEquals("foo", parser.parse("\"foo\"")); assertEquals('a', parser.parse("'a'")); assertEquals(Tokens.reserved("import"), parser.parse("import")); Assert.assertEquals(new DecimalPointNumberLiteral("1.2", NumberType.DOUBLE), parser.parse("1.2")); assertEquals(new IntegerLiteral(Radix.DEC, "1", NumberType.INT), parser.parse("1")); assertEquals(new IntegerLiteral(Radix.HEX, "1", NumberType.LONG), parser.parse("0X1L")); assertEquals(new IntegerLiteral(Radix.OCT, "1", NumberType.DOUBLE), parser.parse("01D")); }