Indentation { public Parser<List<Token>> lexer(Parser<?> tokenizer, Parser<?> delim) { Parser<?> lf = Scanners.isChar('\n').retn(Punctuation.LF); return Parsers.or(tokenizer, lf).lexer(delim) .map(tokens -> analyzeIndentations(tokens, Punctuation.LF)); } Indentation(Object indent, Object outdent);  Indentation(); Parser<Token> indent(); Parser<Token> outdent(); Parser<List<Token>> lexer(Parser<?> tokenizer, Parser<?> delim); static final Parser<Void> WHITESPACES; }
@Test public void testLexer() { Parser<List<Token>> parser = new Indentation().lexer(Scanners.IDENTIFIER, Indentation.WHITESPACES.optional(null)); assertEquals( tokenList("foo", 7, "bar", 4, Indentation.Punctuation.INDENT, "baz", 4, Indentation.Punctuation.INDENT, "bah", 1, "bah", Indentation.Punctuation.OUTDENT, Indentation.Punctuation.OUTDENT), parser.parse("foo \\ \n\\\n bar \n baz\n bah bah ", mode)); }