Terminals extends Lexicon { public static Terminals operators(String... ops) { return operators(asList(ops)); } private  Terminals(Lexicon lexicon); @Deprecated static Terminals caseInsensitive(String[] ops, String[] keywords); @Deprecated static Terminals caseSensitive(String[] ops, String[] keywords); @Deprecated static Terminals caseInsensitive(
      Parser<String> wordScanner, String[] ops, String[] keywords); @Deprecated static Terminals caseSensitive(
      Parser<String> wordScanner, String[] ops, String[] keywords); @Deprecated static Terminals caseInsensitive(
      Parser<String> wordScanner, String[] ops, String[] keywords, Function<String, ?> wordMap); @Deprecated static Terminals caseSensitive(
      Parser<String> wordScanner, String[] ops, String[] keywords, Function<String, ?> wordMap); static Terminals operators(String... ops); static Terminals operators(Collection<String> ops); Builder words(Parser<String> wordScanner); static Parser<String> identifier(); static Parser<String> fragment(final Object... tags); static final Parser<String> RESERVED; }
@Test public void testToken_noTokenName() { Terminals terminals = Terminals.operators("+", "-"); Parser<Token> parser = terminals.token().from(terminals.tokenizer(), WHITESPACES); assertFailure(mode, parser, "+", 1, 1); }
@Test public void testToken_oneTokenNameOnly() { Terminals terminals = Terminals.operators("+", "-"); Parser<Token> parser = terminals.token("+").from(terminals.tokenizer(), WHITESPACES); assertEquals(new Token(0, 1, Tokens.reserved("+")), parser.parse("+")); assertFailure(mode, parser, "-", 1, 1, "+ expected, - encountered."); }
@Test public void testToken_tokenNamesListed() { Terminals terminals = Terminals.operators("+", "-"); Parser<Token> parser = terminals.token("+", "-").from(terminals.tokenizer(), WHITESPACES); assertEquals(new Token(0, 1, Tokens.reserved("+")), parser.parse("+")); assertEquals(new Token(0, 1, Tokens.reserved("-")), parser.parse("-")); assertFailure(mode, parser, "*", 1, 1, "+ or - expected, * encountered."); }