No description
Find a file
2011-04-20 18:45:50 -07:00
.gitignore first commit 2011-04-17 21:24:23 -07:00
bool.c added eval and apply, lambdas, other goodies 2011-04-20 01:38:53 -07:00
bool.h added eval and apply, lambdas, other goodies 2011-04-20 01:38:53 -07:00
comment.c parse comments as values 2011-04-20 18:45:50 -07:00
comment.h parse comments as values 2011-04-20 18:45:50 -07:00
dlist.c added eval and apply, lambdas, other goodies 2011-04-20 01:38:53 -07:00
dlist.h parse comments as values 2011-04-20 18:45:50 -07:00
env.c replace terrible err/die/oom functions with nice ERR/DIE/OOM macros 2011-04-20 13:43:29 -07:00
env.h added eval and apply, lambdas, other goodies 2011-04-20 01:38:53 -07:00
eval.c parse comments as values 2011-04-20 18:45:50 -07:00
eval.h added eval and apply, lambdas, other goodies 2011-04-20 01:38:53 -07:00
fn.c added eval and apply, lambdas, other goodies 2011-04-20 01:38:53 -07:00
fn.h added eval and apply, lambdas, other goodies 2011-04-20 01:38:53 -07:00
int.c define math primitives + - * and / 2011-04-20 13:43:29 -07:00
int.h define math primitives + - * and / 2011-04-20 13:43:29 -07:00
lake.c parse comments as values 2011-04-20 18:45:50 -07:00
lake.h parse comments as values 2011-04-20 18:45:50 -07:00
LICENSE add license, copyright 2011-04-17 22:45:16 -07:00
list.c improve parser, add numeric = primitive 2011-04-20 16:09:01 -07:00
list.h define a few primitives, fix bugs 2011-04-20 11:43:04 -07:00
Makefile parse comments as values 2011-04-20 18:45:50 -07:00
parse.c parse comments as values 2011-04-20 18:45:50 -07:00
parse.h added eval and apply, lambdas, other goodies 2011-04-20 01:38:53 -07:00
primitive.c improve parser, add numeric = primitive 2011-04-20 16:09:01 -07:00
primitive.h improve parser, add numeric = primitive 2011-04-20 16:09:01 -07:00
Readme.md added eval and apply, lambdas, other goodies 2011-04-20 01:38:53 -07:00
stdlib.scm add stdlib with little schemer stuff 2011-04-20 16:11:37 -07:00
string.c added eval and apply, lambdas, other goodies 2011-04-20 01:38:53 -07:00
string.h added eval and apply, lambdas, other goodies 2011-04-20 01:38:53 -07:00
sym.c added eval and apply, lambdas, other goodies 2011-04-20 01:38:53 -07:00
sym.h added eval and apply, lambdas, other goodies 2011-04-20 01:38:53 -07:00
symtable.c added eval and apply, lambdas, other goodies 2011-04-20 01:38:53 -07:00
symtable.h added eval and apply, lambdas, other goodies 2011-04-20 01:38:53 -07:00

Lake Scheme

A quick and dirty scheme written in C, for fun and to use while reading The Little Schemer. Very quick and dirty, a weekend hack gone awry.

Compiling & Running

Portable C99, only dep is glib, nothing to configure, no documentation!

Install glib 2.x using your package manager, for me it's either brew install glib or sudo aptitude install glib. Once you have glib just run:

$ make && ./lake

That will drop you at a repl. There are booleans, symbols, integers, strings, lists, dotted lists (pairs), lambdas, and a few special forms.

> #t
#t
> (quote symbol)
symbol
> 101
101
> "hello"
"hello"
> (quote (1 2 3 4))
(1 2 3 4)
> (quote (1 . 2))
(1 . 2)
> (lambda () "hello")
(lambda () "hello")
> (define inc (lambda (x) (+ x 1)))

Hooray! It parses (reads), evaluates, and then prints things back. However there aren't any primitives yet, so no +, and if you try to use inc defined above it will not work. The special forms present so far are: quote, define, set!, and, or, and lambda.

> (define answer 7)
> answer
7
> (set! answer 42)
> answer
42
> (define list (lambda rest rest))
> (list 1 2 3 4)
(1 2 3 4)

Woah, we even managed to define a useful function without any primitives!

Lake still needs:

  • primitives:
    • display values
    • compare values
    • basic control flow (if, cond, when)
    • native type operations:
      • symbol
      • integer (math)
      • boolean (logic)
      • string
      • function
      • list (cons, car, cdr, ...)
      • dotted list (head, tail)
  • a minimal stdlib
  • sugar such as '... -> (quote ...)

I don't think I'll need any other numeric types. Similarly I don't intend to add features expected from real languages, such as exception handling, I/O, GC, etc.

Contributors

None of them want any credit.

License

Copyright 2011 Sami Samhuri

MIT License, see included LICENSE file