diff options
author | bryan newbold <bnewbold@leaflabs.com> | 2014-03-12 16:17:01 -0400 |
---|---|---|
committer | bryan newbold <bnewbold@leaflabs.com> | 2014-03-12 16:17:01 -0400 |
commit | cffecb57f88acb02354b68a9ffe22abbabd5931d (patch) | |
tree | 3eb141991df1b7a7619104140f73e693ce75e8a0 | |
parent | 251e18cf769866c24b6c4719f950d589b5eac8b9 (diff) | |
download | spectrum-cffecb57f88acb02354b68a9ffe22abbabd5931d.tar.gz spectrum-cffecb57f88acb02354b68a9ffe22abbabd5931d.zip |
basic docs
-rw-r--r-- | README | 9 | ||||
-rw-r--r-- | howto.txt | 51 |
2 files changed, 60 insertions, 0 deletions
@@ -0,0 +1,9 @@ + _ + ___ _ __ ___ ___| |_ _ __ _ _ _ __ ___ + / __| '_ \ / _ \/ __| __| '__| | | | '_ ` _ \ + \__ \ |_) | __/ (__| |_| | | |_| | | | | | | + |___/ .__/ \___|\___|\__|_| \__,_|_| |_| |_| + |_| + + a set of lambdas + diff --git a/howto.txt b/howto.txt new file mode 100644 index 0000000..1a29af2 --- /dev/null +++ b/howto.txt @@ -0,0 +1,51 @@ + +### How to implement a simple scheme? + +Potentially need an AST-like data structure representing the parsed expression. +This is the s-expression. Well represented as a pair with value types: + + null + pair + boolean (true/false) + number + identifier/symbol + +One way to accomplish the above would be to use a pair datatype in the host +language. Another is to try to use tuples or lists; this will result in faster +execution but is much harder? + +'value' and other high level functions will take an s-expr and return an +s-expr. eval wraps this with an AST parse at the begining and a pretty print at +the end. + +'meaning' takes an s-expr object and a context/environment and computes the +result s-expr. it recursively looks at each node in the s-expr, decides what +action needs to be taken on it, and executes the action. possible actions (aka, +parsed types) are: + + const (atomic values) + lambda + quote (s-expr "one level down") + identifier (a symbol to be looked up in the context) + cond (conditional expression) + +The specific list of "special"/"built-in"/"reserved" identifiers is: + + lambda + quote + cond + else + cons + car + cdr + null? + eq? + atom? + zero? + number? + +Things which an be applied are lambdas and the above built-ins. + +When applying a lambda, need to bind values to local context. This requires +an immutable or copied lookup table. + |