Is there an existing LISP parser written in C++? I just want the parser, not a full interpreter, but an interpreter to go along with it would be a plus.
-
4do you want a parser for s-expressions or for Lisp? Which Lisp? Scheme? Common Lisp?Rainer Joswig– Rainer Joswig2009-09-01 14:16:04 +00:00Commented Sep 1, 2009 at 14:16
-
I'm looking for a parser for a LISP-like syntax, so I guess a parser for s-expressions is really what I'm looking for.Imagist– Imagist2009-09-02 03:43:33 +00:00Commented Sep 2, 2009 at 3:43
-
Right, s-expressions are the syntax for Lisp data. Lisp programs are written using s-expressions. But not every s-expression is a valid Lisp program. So Lisp has more syntax on top of s-expressions. See the syntax definitions in the Common Lisp and Scheme standards.Rainer Joswig– Rainer Joswig2009-09-02 07:23:01 +00:00Commented Sep 2, 2009 at 7:23
Add a comment
|
4 Answers
Lisp is just a tree structure, any tree parser will parse lisp readily... you can try this one which google gave me.
4 Comments
David Thornley
In fact, the Common Lisp I write looks almost exactly like the parse trees I built in compilers class.
Luís Oliveira
You can parse a subset of it easily. But the real thing involves more data-structures than just symbols and lists.
dsm
He did mention he wanted a parser, not a full interpreter
@DavidThornley Indeed. :) One could say, Lisp is basically an AST processor that has operations to modify itself. Check out the famous 6.001 (SAICP) videos: ocw.mit.edu/courses/electrical-engineering-and-computer-science/…
XCL is an implementation of Common Lisp whose runtime is written in C++. The compiler is written in Lisp but it has an interpreter written in C++ which is used for bootstrapping.