lbruder/NLisp
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Copyright (c) 2012, Leif Bruder <leifbruder@gmail.com> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. Simple Lisp interpreter for C# 3.5 ================================== This is a pet Lisp interpreter for .NET 3.5 written in C#. The main issue here is to have fun, NOT to make it as fast as possible! However, I strive to make the interpreter small and simple and keep most of the standard functions and macros in a separate "init" script, so another implementation of the base system with speed in mind should yield results pretty quickly. The system is divided into two parts: ------------------------------------- - The base interpreter providing a minimal Lisp-1 system - An init script, written in the Lisp dialect provided by the base interpreter, creating a more fully featured language. The base interpreter provides the following: -------------------------------------------- - Special Forms: define, setq, if, quote, lambda, progn, while - Lexical scoping - Constants: nil, t - Basic functions: cons, car, cdr, eq, nullp, consp, symbolp, numberp, apply, string, stringp, substring, length (for strings, lists, arrays), random, print (raises a c# event on the interpreter), rplaca, rplacd, eval (always uses the global environment), make-array, arrayp, aref - Basic arithmetic: +, -, *, /, mod, =, >, < TODO: Comparison via < and > for strings; better as string>, string<? - Basic macro functionality: defmacro, macroexpand-1, macroexpand, gensym - Helper methods: - (sys:aset array index value) => value - (sys:make-symbol-constant symbol) => t - (sys:get-global-symbols) => list-of-symbol - Basic stream operations: - (sys:print obj stream) => obj - (sys:open-file-for-output filename) => stream - (sys:open-file-for-input filename) => stream - (sys:read stream) => obj or nil on EOF - (sys:read-line stream) => string or nil on EOF - (sys:close stream) => t - Planned stream operations: - (sys:eof-p stream) => bool - (sys:read-char stream) => string* or nil on EOF *until a char data type is implemented - (sys:open-file-for-append filename) => stream - (sys:open-tcp-socket hostname-or-ip port) => stream The base interpreter does NOT provide (yet): -------------------------------------------- - princ, prin1 - Quasiquoting - Tail Call Optimization (thus the while SF) The init script provides the following on top of the base language: ------------------------------------------------------------------- - Macros: defun, cond, incf, decf, push, pop, let, and, or, dolist, dotimes, when, unless - Functions: list, not, <=, >=, cxxr, cxxxr, abs, evenp, oddp, reverse, nreverse, map, filter, reduce, append, every, some, eql, equal, remove-if-not (=filter), remove-if, count-if, count-if-not, all (=every), any (=some), sort, identity, acons, assoc, pairlis, member, member-if, member-if-not, string>=, string<=, vector, for-each - The map function corresponds to mapcar as found in Common Lisp - (range ?start-value below-value ?step) - (range 5) => (0 1 2 3 4) - (range 2 5) => (2 3 4) - (range 2 16 3) => (2 5 8 11 14) - Planned: setf, print, read, read-line, with-open-file... Future plans ------------ - setf, coerce - Generate init-script-part of README from the script itself (SPOT rule) - with-open-file - string manipulation functions - More goodies as found in Common Lisp and/or Scheme - Strings as streams? - Exception handling - Thread functions - A faster version of the base interpreter that compiles all code to a bytecode representation before executing, to be used with the same init script - A Java version of the base interpreter - A CLR FFI: - clr-methods - clr-properties - clr-get - clr-set - clr-new - clr-call (or ".") - Interpreter method AddFunction to use e.g. C# lambdas as Lisp functions
About
Pet Lisp interpreter for .NET 3.5
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published