I wrote
> [Make your syntax look as much like LISP as possible.]
> Then your parser is simply the lisp reader,
·······@asia.cs.rice.edu (Shriram Krishnamurthi) replied:
No:
(let ((foo)) bar)
is not legitimate LISP syntax. A reader is just that; it is not a
parser.
That depends. Is a parser a string -> parse-tree transformer with
syntax checking as a side effect or is it a syntax checker which
produces the parse tree as a side effect? Either answer makes sense
depending on your perspective, but to me a parser is a primarily a
string -> parse-tree transformer, and I don't really care if some
errors that have a syntactic flavor get caught by other parts of the
compiler instead of by the parser.
So, I claim that list (let foo bar) *is* the internal parse tree
produced from the string "(let foo bar)" by a parser that just happens
not to catch this particular syntax error. In fact, if I want I can
simply define the "syntax" to allow (let foo bar) but say that
semantic rules forbid it.