Read Clojure source code one token at a time

In Clojure, you can read an integer s-expression with (read). Is there a way to read only one token at a time? So the call (read-token "(read)")will return something like ["(", "read", ")"].

+3
source share
1 answer

"tokens" are not something the clojure reader works with: it does not have separate lex / parse phases, such as languages ​​with more complex grammars. Of course, you can write your own grammar for clojure forms, call the token (a OPEN_PAREN, etc., but there is no built-in support.

+2
source

All Articles