开发者

How to write a LISP interpreter for actionscript 3?

I know t开发者_JAVA技巧here is one, but it's not easy to implement the way I want.

I would like to know the steps to interpret the lisp language and what functions are essential to be implemented.


First, you learn Lisp, then read LiSP and (given you know ActionScript well enough) you just start. PAIP also has sections about implementing Lisp interpreters and compilers.

To get an idea how it generally can be approached, you can have a look at Write Yourself a Scheme in 48 hours. It uses Haskell as an implementation language, but it would give you an idea.

It surely wouldn't be trivial, but it has been done quite often, and there is much to learn from doing it.


danlei's recommendations are excellent. If you want to learn Lisp, PAIP is a better choice to start with, because it will teach you a lot about Common Lisp and a smallish chunk of Scheme.

However, my recommendation would be to start with The Structure and Interpretation of Computer Programs, which will teach you at least as much about Lisp as PAIP (you won't learn as much about AI, though), has a longer and more complete section on how to write Lisp interpreters, and is an awesome book all around. In addition, it's available in its entirety online. I had to order both PAIP and LiSP by mail.


Check out the 'Essentials of Programming Languages' book (also known as EoPL).


If you want to implement a basic lisp in a higher level language, you might get some mileage out of the later chapters of The Little Schemer (where you're shown how to write a meta-circular evaluator in Scheme), the entirety of WYAS48 (where you're shown how to implement an R5RS Scheme in Haskell) and these two Norvig articles (wherein he implements a basic lisp-like in Python).


You can check out sporklisp (which is a lisp variant written in vba) and works in excel.

https://github.com/spoonix/sporklisp

PS I have been able to port this to MS Access also with no problem.

------ note from the author of sporklisp -------

A lot of the concepts came from lisp wizards, particulalry the Structure and Interpretation of Computer Programs (SICP), Peter Norvig's excellent tutorials for LisPy and JScheme, and Christian Queinnec's Lisp in Small Pieces.


I would recommend reading one of the famous dragon books. It pretty much explains the entire process of parsing, compiling, code generation, optimization etc


If you have to ask - you can't do it.

Implementing a programming language is a terribly complicated thing, even if you don't have to do it from scratch. And I don't think there will be many supporting tools/libraries for Actionscript. On top of that, LISP is a functional programming language which will require quite an amount of extra trickery in addition to the usual language implementation in order to get a decent performance.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜