aboutsummaryrefslogtreecommitdiff
path: root/README.rst
blob: 531c9fac5fbdda6b39fe75b1a036af4434fc7f8d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
lisp16
======

Simple cross platform 16bit Lisp interpreter.

* documentation - `<https://lisp16.kopic.xyz>`_
* git repository - `<https://github.com/bozokopic/lisp16.git>`_


About
-----

This project is intended as case study of Lisp implementation with following
features:

    * cross platform compatibility
        * support for 8bit/16bit architectures (microcontrollers)
        * possibility of running on POSIX systems
        * small platform compatibility layer
    * reduced Lisp dialect mostly based on Scheme
        * LISP-1 namespace
        * tail call optimization
        * macros
    * tree walking interpreter
        * possibility of multiple independent interpreter instances as part of
          single process
        * simple mark and sweep garbage collection
        * API design taking into account possibility of usage with foreign
          function interface
    * intended for educational/testing purposes
        * emphasis on source code functionality organization over binary size
          or lines of code (or other kinds of optimization)
        * accompanied documentation with implementation explanation

Following features are considered out of scope for this project:

    * real-life production usage
    * execution speed optimization
    * virtual machine or machine code compilation
    * rich standard library


Building and usage
------------------

8bit AVR microcontrollers
'''''''''''''''''''''''''

Build targeting 8bit AVR microcontrollers (tested with ATmega328P) depends
on `avr-gcc` and associated `binutils`.

Shell script::

    $ ./build-avr8.sh

produces ``build/avr8/lisp16.bin`` binary that can be written to
microcontroller's flash.

After writing binary to flash, microcontroller will execute `lisp16` repl with
UART used as input/output port.


POSIX system
''''''''''''

Build targeting POSIX systems depends on C compiler (gcc with musl C library is
used by default) and implementation of `getchar`/`putchar` and `malloc`/`free`
functions (`malloc` can be replaced with static allocation in case multiple
interpreter instances are not needed).

Shell script::

    $ ./build-posix.sh

produces ``build/posix/lisp16`` static binary.

Execution of ``build/posix/lisp16`` starts `lisp16` repl `stdin`/`stdout` used
as input/output port.


Documentation
'''''''''''''

Building of documentation depends on python with sphinx and furo modules
available.

Shell script::

    $ ./build-docs.sh

produces ``build/docs`` folder containing documentation.


License
-------

lisp16 - simple cross platform 16bit Lisp interpreter

Copyright (C) 2022 Bozo Kopic

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.