@Test public void test() { final Reader reader = new StringReader(string); final LispLexer lexer = new LispLexer(reader); final List<Token> actTokens = new ArrayList<>(); Token token = lexer.nextToken(); while (token.getType() != TokenType.EOF) { actTokens.add(token); token = lexer.nextToken(); } assertEquals(tokens, actTokens); }
public Token nextToken() { while (c != EOF) { switch (c) { case ' ': case '\t': case '\n': case '\r': WS(); continue; case ';': COMMENT(); continue; case '(': return LPAREN(); case ')': return RPAREN(); default: return ATOM(); } } return Token.of("<EOF>", TokenType.EOF); }
LispLexer { public Token nextToken() { while (c != EOF) { switch (c) { case ' ': case '\t': case '\n': case '\r': WS(); continue; case ';': COMMENT(); continue; case '(': return LPAREN(); case ')': return RPAREN(); default: return ATOM(); } } return Token.of("<EOF>", TokenType.EOF); } }
LispLexer { public Token nextToken() { while (c != EOF) { switch (c) { case ' ': case '\t': case '\n': case '\r': WS(); continue; case ';': COMMENT(); continue; case '(': return LPAREN(); case ')': return RPAREN(); default: return ATOM(); } } return Token.of("<EOF>", TokenType.EOF); } LispLexer(final Reader reader); }
LispLexer { public Token nextToken() { while (c != EOF) { switch (c) { case ' ': case '\t': case '\n': case '\r': WS(); continue; case ';': COMMENT(); continue; case '(': return LPAREN(); case ')': return RPAREN(); default: return ATOM(); } } return Token.of("<EOF>", TokenType.EOF); } LispLexer(final Reader reader); Token nextToken(); }
LispLexer { public Token nextToken() { while (c != EOF) { switch (c) { case ' ': case '\t': case '\n': case '\r': WS(); continue; case ';': COMMENT(); continue; case '(': return LPAREN(); case ')': return RPAREN(); default: return ATOM(); } } return Token.of("<EOF>", TokenType.EOF); } LispLexer(final Reader reader); Token nextToken();  }