Search code examples
lisptokenize

Lisp: atom and string


I am working on a simple Lisp interpreter. And now I am trying to write a parser for it. LISP - Basic Syntax. I've read that in Lisp there are only three types of block: atom, list, string. Also, I've noticed that string block can be nested into the list, like:

(format t "Some string block...~%").

Could string type of building block be considered as atom block?


Solution

  • First, the pages you chose as a "reference" are of a very dubious quality. The most obvious visual red flag if the "unconventional" (to put it mildly) way to format Lisp code.

    Second, block in Lisp has a very specific meaning. When they use that word they, apparently, mean token.

    Third, the string type in Lisp is a subtype of type atom:

    (atom "foo")
    ==> t
    

    Thus, the answer to the question you asked is: yes, every string is an atom.

    And the answer to the question you should have asked is: refer to CLHS, not to some dubious web site.

    PS. There are several FLOSS Common Lisp implementations available (e.g., CLISP, SBCL), you might want to start with looking how they do things.