Compare commits
No commits in common. "master" and "feature/1" have entirely different histories.
10
CHANGELOG.md
10
CHANGELOG.md
|
@ -1,16 +1,6 @@
|
|||
# Change Log
|
||||
All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/).
|
||||
|
||||
## [0.3.0] - 2023-04-10
|
||||
|
||||
### Changed
|
||||
|
||||
- Added property lists in the exact format used by Lisp 1.5;
|
||||
- Added `ASSOC`, `EFFACE`, `MAPLIST`, `PROG`, and other functions;
|
||||
- Where there are both interpreted (`EXPR`) and Clojure (`SUBR`) implementations of the same function, the `EXPR` is preferred (it is planned to make this configurable if/when there is a working compiler);
|
||||
- More error messages/diagnostics are now printed in Old English (it is planned to implement internationalisation so that you can switch to messages you actually understand);
|
||||
- Documentation improvements.
|
||||
|
||||
## [0.2.1] - 2023-03-30
|
||||
|
||||
### Changed
|
||||
|
|
302
README.md
302
README.md
|
@ -1,80 +1,30 @@
|
|||
# beowulf
|
||||
|
||||
## Þý liste cræfte spræc
|
||||
|
||||
LISP 1.5 is to all Lisp dialects as Beowulf is to English literature.
|
||||
|
||||

|
||||
|
||||
## Contents
|
||||
* [What this is](#what-this-is)
|
||||
+ [Status](#status)
|
||||
+ [BUT WHY?!!?!](#but-why-----)
|
||||
+ [Project Target](#project-target)
|
||||
+ [Invoking](#invoking)
|
||||
+ [Building and Invoking](#building-and-invoking)
|
||||
+ [Reader macros](#reader-macros)
|
||||
+ [Functions and symbols implemented](#functions-and-symbols-implemented)
|
||||
+ [Architectural plan](#architectural-plan)
|
||||
- [resources/lisp1.5.lsp](#resources-lisp15lsp)
|
||||
- [beowulf/boostrap.clj](#beowulf-boostrapclj)
|
||||
- [beowulf/host.clj](#beowulf-hostclj)
|
||||
- [beowulf/read.clj](#beowulf-readclj)
|
||||
+ [Commentary](#commentary)
|
||||
* [Installation](#installation)
|
||||
+ [Input/output](#input-output)
|
||||
- [SYSOUT](#sysout)
|
||||
- [SYSIN](#sysin)
|
||||
* [Learning Lisp 1.5](#learning-lisp-15)
|
||||
* [Other Lisp 1.5 resources](#other-lisp-15-resources)
|
||||
+ [Other implmentations](#other-implementations)
|
||||
+ [History resources](#history-resources)
|
||||
* [License](#license)
|
||||
|
||||
<small><i><a href='http://ecotrust-canada.github.io/markdown-toc/'>Table of contents generated with markdown-toc</a></i></small>
|
||||
|
||||
## What this is
|
||||
|
||||
A work-in-progress towards an implementation of Lisp 1.5 in Clojure. The
|
||||
objective is to build a complete and accurate implementation of Lisp 1.5
|
||||
as described in the manual, with, in so far as is possible, exactly the
|
||||
same behaviour — except as documented below.
|
||||
|
||||
### BUT WHY?!!?!
|
||||
|
||||
Because.
|
||||
|
||||
Because Lisp is the only computer language worth learning, and if a thing
|
||||
is worth learning, it's worth learning properly; which means going back to
|
||||
the beginning and trying to understand that.
|
||||
|
||||
Because there is, so far as I know, no working implementation of Lisp 1.5
|
||||
for modern machines.
|
||||
|
||||
Because I'm barking mad, and this is therapy.
|
||||
same bahaviour - except as documented below.
|
||||
|
||||
### Status
|
||||
|
||||
Working Lisp interpreter, but some key features not yet implemented.
|
||||
Boots to REPL, but few functions yet available.
|
||||
|
||||
* [Project website](https://simon-brooke.github.io/beowulf/).
|
||||
* [Source code documentation](https://simon-brooke.github.io/beowulf/docs/codox/index.html).
|
||||
|
||||
### Project Target
|
||||
### Building and Invoking
|
||||
|
||||
The project target is to be able to run the [Wang algorithm for the propositional calculus](https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=52) given in chapter 8 of the *Lisp 1.5 Programmer's Manual*. When that runs, the project is as far as I am concerned feature complete. I may keep tinkering with it after that and I'll certainly accept pull requests which are in the spirit of the project (i.e. making Beowulf more usable, and/or implementing parts of Lisp 1.5 which I have not implemented), but this isn't intended to be a new language for doing real work; it's an educational and archaeological project, not serious engineering.
|
||||
Build with
|
||||
|
||||
Some `readline`-like functionality would be really useful, but my attempt to integrate [JLine](https://github.com/jline/jline3) has not (yet) been successful.
|
||||
|
||||
An in-core structure editor would be an extremely nice thing, and I may well implement one.
|
||||
|
||||
You are of course welcome to fork the project and do whatever you like with it!
|
||||
|
||||
### Invoking
|
||||
lein uberjar
|
||||
|
||||
Invoke with
|
||||
|
||||
java -jar target/uberjar/beowulf-0.3.0-standalone.jar --help
|
||||
java -jar target/uberjar/beowulf-0.2.1-SNAPSHOT-standalone.jar --help
|
||||
|
||||
(Obviously, check your version number)
|
||||
|
||||
|
@ -83,128 +33,107 @@ Command line arguments as follows:
|
|||
```
|
||||
-h, --help Print this message
|
||||
-p PROMPT, --prompt PROMPT Set the REPL prompt to PROMPT
|
||||
-r INITFILE, --read SYSOUTFILE Read Lisp sysout from the file SYSOUTFILE
|
||||
(defaults to `resources/lisp1.5.lsp`)
|
||||
-s, --strict Strictly interpret the Lisp 1.5 language,
|
||||
without extensions.
|
||||
-r INITFILE, --read INITFILE Read Lisp functions from the file INITFILE
|
||||
-s, --strict Strictly interpret the Lisp 1.5 language, without extensions.
|
||||
```
|
||||
|
||||
To end a session, type `STOP` at the command prompt.
|
||||
|
||||
### Building and Invoking
|
||||
|
||||
Build with
|
||||
|
||||
lein uberjar
|
||||
|
||||
|
||||
### Reader macros
|
||||
|
||||
Currently `SETQ` and `DEFUN` are implemented as reader macros, sort of. It would
|
||||
now be possible to reimplement them as `FEXPRs` and so the reader macro functionality will probably go away.
|
||||
Currently I don't have
|
||||
|
||||
### Functions and symbols implemented
|
||||
|
||||
The following functions and symbols are implemented:
|
||||
|
||||
| Function | Type | Signature | Implementation | Documentation |
|
||||
|--------------|----------------|------------------|----------------|----------------------|
|
||||
| NIL | Lisp variable | ? | | The canonical empty list. See manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=22'>22</a>, <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=69'>69</a>s |
|
||||
| T | Lisp variable | ? | | The canonical true value. See manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=22'>22</a>, <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=69'>69</a> |
|
||||
| F | Lisp variable | ? | | The canonical false value. See manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=22'>22</a>, <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=69'>69</a> |
|
||||
| ADD1 | Host lambda function | x:number | | Add one to the number `x`. |
|
||||
| AND | Host lambda function | expr* | PREDICATE | `T` if and only if none of my `args` evaluate to either `F` or `NIL`, else `F`. <br><br>In `beowulf.host` principally because I don't yet feel confident to define varargs functions in Lisp. |
|
||||
| APPEND | Lisp lambda function | ? | | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=11'>11</a>, <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=61'>61</a> |
|
||||
| APPLY | Host lambda function | ? | | Apply this `function` to these `arguments` in this `environment` and return the result.<br><br>For bootstrapping, at least, a version of APPLY written in Clojure.<br><br>All args are assumed to be symbols or `beowulf.cons-cell/ConsCell` objects.<br><br>See page <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=13'>13</a> of the Lisp 1.5 Programmers Manual. |
|
||||
| ASSOC | Lisp lambda function, Host lambda function | a:list | ? | If a is an association list such as the one formed by PAIRLIS in the above example, then assoc will produce the first pair whose first term is x. Thus it is a table searching function. All args are assumed to be `beowulf.cons-cell/ConsCell` objects. See page <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=12'>12</a> of the Lisp 1.5 Programmers Manual.<br><br>**NOTE THAT** this function is overridden by an implementation in Lisp, but is currently still present for bootstrapping. |
|
||||
| ATOM | Host lambda function | x:expr | PREDICATE | Returns `T` if and only if the argument `x` is bound to an atom; else `F`. It is not clear to me from the documentation whether `(ATOM 7)` should return `T` or `F`. I'm going to assume `T`. |
|
||||
| CAR | Host lambda function | list | | Return the item indicated by the first pointer of a pair. NIL is treated specially: the CAR of NIL is NIL. |
|
||||
| CAAAAR | Lisp lambda function | list | ? | ? |
|
||||
| CAAADR | Lisp lambda function | list | ? | ? |
|
||||
| CAAAR | Lisp lambda function | list | ? | ? |
|
||||
| CAADAR | Lisp lambda function | list | ? | ? |
|
||||
| CAADDR | Lisp lambda function | list | ? | ? |
|
||||
| CAADR | Lisp lambda function | list | ? | ? |
|
||||
| CAAR | Lisp lambda function | list | ? | ? |
|
||||
| CADAAR | Lisp lambda function | list | ? | ? |
|
||||
| CADADR | Lisp lambda function | list | ? | ? |
|
||||
| CADAR | Lisp lambda function | list | ? | ? |
|
||||
| CADDAR | Lisp lambda function | list | ? | ? |
|
||||
| CADDDR | Lisp lambda function | list | ? | ? |
|
||||
| CADDR | Lisp lambda function | list | ? | ? |
|
||||
| CADR | Lisp lambda function | list | ? | ? |
|
||||
| CDAAAR | Lisp lambda function | list | ? | ? |
|
||||
| CDAADR | Lisp lambda function | list | ? | ? |
|
||||
| CDAAR | Lisp lambda function | list | ? | ? |
|
||||
| CDADAR | Lisp lambda function | list | ? | ? |
|
||||
| CDADDR | Lisp lambda function | list | ? | ? |
|
||||
| CDADR | Lisp lambda function | list | ? | ? |
|
||||
| CDAR | Lisp lambda function | list | ? | ? |
|
||||
| CDDAAR | Lisp lambda function | list | ? | ? |
|
||||
| CDDADR | Lisp lambda function | list | ? | ? |
|
||||
| CDDAR | Lisp lambda function | list | ? | ? |
|
||||
| CDDDAR | Lisp lambda function | list | ? | ? |
|
||||
| CDDDDR | Lisp lambda function | list | ? | ? |
|
||||
| CDDDR | Lisp lambda function | list | ? | ? |
|
||||
| CDDR | Lisp lambda function | list | ? | ? |
|
||||
| CDR | Host lambda function | list | | Return the item indicated by the second pointer of a pair. NIL is treated specially: the CDR of NIL is NIL. |
|
||||
| CONS | Host lambda function | expr, expr | | Construct a new instance of cons cell with this `car` and `cdr`. |
|
||||
| CONSP | Host lambda function | o:expr | ? | Return `T` if object `o` is a cons cell, else `F`.<br><br>**NOTE THAT** this is an extension function, not available in strict mode. I believe that Lisp 1.5 did not have any mechanism for testing whether an argument was, or was not, a cons cell. |
|
||||
| COPY | Lisp lambda function | ? | | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=62'>62</a> |
|
||||
| DEFINE | Host lambda function | ? | PSEUDO-FUNCTION | Bootstrap-only version of `DEFINE` which, post boostrap, can be overwritten in LISP. The single argument to `DEFINE` should be an association list of symbols to lambda functions. See page <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=58'>58</a> of the manual. |
|
||||
| DIFFERENCE | Host lambda function | x:number, y:number | | Returns the result of subtracting the number `y` from the number `x` |
|
||||
| DIVIDE | Lisp lambda function | x:number, y:number | | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=26'>26</a>, <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=64'>64</a> |
|
||||
| DOC | Host lambda function | ? | ? | Open the page for this `symbol` in the Lisp 1.5 manual, if known, in the default web browser.<br><br>**NOTE THAT** this is an extension function, not available in strct mode. |
|
||||
| EFFACE | Lisp lambda function | ? | PSEUDO-FUNCTION | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=63'>63</a> |
|
||||
| ERROR | Host lambda function | ? | PSEUDO-FUNCTION | Throw an error |
|
||||
| EQ | Host lambda function | ? | PREDICATE | Returns `T` if and only if both `x` and `y` are bound to the same atom, else `NIL`. |
|
||||
| EQUAL | Host lambda function | ? | PREDICATE | This is a predicate that is true if its two arguments are identical S-expressions, and false if they are different. (The elementary predicate `EQ` is defined only for atomic arguments.) The definition of `EQUAL` is an example of a conditional expression inside a conditional expression. NOTE: returns `F` on failure, not `NIL` |
|
||||
| EVAL | Host lambda function | ? | | Evaluate this `expr` and return the result. If `environment` is not passed, it defaults to the current value of the global object list. The `depth` argument is part of the tracing system and should not be set by user code. All args are assumed to be numbers, symbols or `beowulf.cons-cell/ConsCell` objects. However, if called with just a single arg, `expr`, I'll assume it's being called from the Clojure REPL and will coerce the `expr` to `ConsCell`. |
|
||||
| FACTORIAL | Lisp lambda function | ? | ? | ? |
|
||||
| FIXP | Host lambda function | ? | PREDICATE | ? |
|
||||
| GENSYM | Host lambda function | ? | | Generate a unique symbol. |
|
||||
| GET | Host lambda function | ? | | From the manual: '`get` is somewhat like `prop`; however its value is car of the rest of the list if the `indicator` is found, and NIL otherwise.'<br><br>It's clear that `GET` is expected to be defined in terms of `PROP`, but we can't implement `PROP` here because we lack `EVAL`; and we can't have `EVAL` here because both it and `APPLY` depends on `GET`.<br><br>OK, It's worse than that: the statement of the definition of `GET` (and of) `PROP` on page <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=59'>59</a> says that the first argument to each must be a list; But the in the definition of `ASSOC` on page 70, when `GET` is called its first argument is always an atom. Since it's `ASSOC` and `EVAL` which I need to make work, I'm going to assume that page 59 is wrong. |
|
||||
| GREATERP | Host lambda function | ? | PREDICATE | ? |
|
||||
| INTEROP | Host lambda function | ? | ? | ? |
|
||||
| INTERSECTION | Lisp lambda function | ? | ? | ? |
|
||||
| LENGTH | Lisp lambda function | ? | | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=62'>62</a> |
|
||||
| LESSP | Host lambda function | ? | PREDICATE | ? |
|
||||
| MAPLIST | Lisp lambda function | ? | FUNCTIONAL | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=20'>20</a>, <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=21'>21</a>, <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=63'>63</a> |
|
||||
| MEMBER | Lisp lambda function | ? | PREDICATE | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=11'>11</a>, <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=62'>62</a> |
|
||||
| MINUSP | Lisp lambda function | ? | PREDICATE | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=26'>26</a>, <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=64'>64</a> |
|
||||
| NOT | Lisp lambda function | ? | PREDICATE | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=21'>21</a>, <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=23'>23</a>, <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=58'>58</a> |
|
||||
| NULL | Lisp lambda function | ? | PREDICATE | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=11'>11</a>, <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=57'>57</a> |
|
||||
| NUMBERP | Host lambda function | ? | PREDICATE | ? |
|
||||
| OBLIST | Host lambda function | ? | | Return a list of the symbols currently bound on the object list.<br><br>**NOTE THAT** in the Lisp 1.5 manual, footnote at the bottom of page <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=69'>69</a>, it implies that an argument can be passed but I'm not sure of the semantics of this. |
|
||||
| ONEP | Lisp lambda function | ? | PREDICATE | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=26'>26</a>, <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=64'>64</a> |
|
||||
| OR | Host lambda function | ? | PREDICATE | `T` if and only if at least one of my `args` evaluates to something other than either `F` or `NIL`, else `F`.<br><br>In `beowulf.host` principally because I don't yet feel confident to define varargs functions in Lisp. |
|
||||
| PAIR | Lisp lambda function | ? | | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=60'>60</a> |
|
||||
| PAIRLIS | Lisp lambda function, Host lambda function | ? | ? | This function gives the list of pairs of corresponding elements of the lists `x` and `y`, and APPENDs this to the list `a`. The resultant list of pairs, which is like a table with two columns, is called an association list. Essentially, it builds the environment on the stack, implementing shallow binding.<br><br>All args are assumed to be `beowulf.cons-cell/ConsCell` objects. See page <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=12'>12</a> of the Lisp 1.5 Programmers Manual.<br><br>**NOTE THAT** this function is overridden by an implementation in Lisp, but is currently still present for bootstrapping. |
|
||||
| PLUS | Host lambda function | ? | | ? |
|
||||
| PRETTY | | ? | ? | ? |
|
||||
| PRINT | | ? | PSEUDO-FUNCTION | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=65'>65</a>, <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=84'>84</a> |
|
||||
| PROG | Host nlambda function | ? | | The accursed `PROG` feature. See page <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=71'>71</a> of the manual.<br><br>Lisp 1.5 introduced `PROG`, and most Lisps have been stuck with it ever since. It introduces imperative programming into what should be a pure functional language, and consequently it's going to be a pig to implement. Broadly, `PROG` is a variadic pseudo function called as a `FEXPR` (or possibly an `FSUBR`, although I'm not presently sure that would even work.) The arguments, which are unevaluated, are a list of forms, the first of which is expected to be a list of symbols which will be treated as names of variables within the program, and the rest of which (the 'program body') are either lists or symbols. Lists are treated as Lisp expressions which may be evaulated in turn. Symbols are treated as targets for the `GO` statement. <ul><li>**GO:** A `GO` statement takes the form of `(GO target)`, where `target` should be one of the symbols which occur at top level among that particular invocation of `PROG`s arguments. A `GO` statement may occur at top level in a PROG, or in a clause of a `COND` statement in a `PROG`, but not in a function called from the `PROG` statement. When a `GO` statement is evaluated, execution should transfer immediately to the expression which is the argument list immediately following the symbol which is its target. If the target is not found, an error with the code `A6` should be thrown.</li><li>**RETURN:** A `RETURN` statement takes the form `(RETURN value)`, where `value` is any value. Following the evaluation of a `RETURN` statement, the `PROG` should immediately exit without executing any further expressions, returning the value.</li><li>**SET and SETQ:** In addition to the above, if a `SET` or `SETQ` expression is encountered in any expression within the `PROG` body, it should affect not the global object list but instead only the local variables of the program.</li><li>**COND:** In **strict** mode, when in normal execution, a `COND` statement none of whose clauses match should not return `NIL` but should throw an error with the code `A3`... *except* that inside a `PROG` body, it should not do so. *sigh*.</li></ul>**Flow of control:** Apart from the exceptions specified above, expressions in the program body are evaluated sequentially. If execution reaches the end of the program body, `NIL` is returned.<br><br>Got all that? Good. |
|
||||
| PROP | Lisp lambda function | ? | FUNCTIONAL | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=59'>59</a> |
|
||||
| QUOTE | Lisp lambda function | ? | | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=10'>10</a>, <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=22'>22</a>, <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=71'>71</a> |
|
||||
| QUOTIENT | Host lambda function | ? | | I'm not certain from the documentation whether Lisp 1.5 `QUOTIENT` returned the integer part of the quotient, or a realnum representing the whole quotient. I am for now implementing the latter. |
|
||||
| RANGE | Lisp lambda function | ? | ? | ? |
|
||||
| READ | Host lambda function | ? | PSEUDO-FUNCTION | An implementation of a Lisp reader sufficient for bootstrapping; not necessarily the final Lisp reader. `input` should be either a string representation of a LISP expression, or else an input stream. A single form will be read. |
|
||||
| REMAINDER | Host lambda function | ? | | ? |
|
||||
| REPEAT | Lisp lambda function | ? | ? | ? |
|
||||
| RPLACA | Host lambda function | ? | PSEUDO-FUNCTION | Replace the `CAR` pointer of this `cell` with this `value`. Dangerous, should really not exist, but does in Lisp 1.5 (and was important for some performance hacks in early Lisps) |
|
||||
| RPLACD | Host lambda function | ? | PSEUDO-FUNCTION | Replace the `CDR` pointer of this `cell` with this `value`. Dangerous, should really not exist, but does in Lisp 1.5 (and was important for some performance hacks in early Lisps) |
|
||||
| SEARCH | Lisp lambda function | ? | FUNCTIONAL | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=63'>63</a> |
|
||||
| SET | Host lambda function | ? | PSEUDO-FUNCTION | Implementation of SET in Clojure. Add to the `oblist` a binding of the value of `var` to the value of `val`.<br><br>**NOTE WELL**: this is not SETQ! |
|
||||
| SUB1 | Lisp lambda function, Host lambda function | ? | | ? |
|
||||
| SUB2 | Lisp lambda function | ? | ? | ? |
|
||||
| SUBLIS | Lisp lambda function | ? | | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=12'>12</a>, <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=61'>61</a> |
|
||||
| SUBST | Lisp lambda function | ? | | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=11'>11</a>, <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=61'>61</a> |
|
||||
| SYSIN | Host lambda function | ? | ? | Read the contents of the file at this `filename` into the object list. If the file is not a valid Beowulf sysout file, this will probably corrupt the system, you have been warned. File paths will be considered relative to the filepath set when starting Lisp. It is intended that sysout files can be read both from resources within the jar file, and from the file system. If a named file exists in both the file system and the resources, the file system will be preferred.<br><br>**NOTE THAT** if the provided `filename` does not end with `.lsp` (which, if you're writing it from the Lisp REPL, it won't), the extension `.lsp` will be appended.<br><br>**NOTE THAT** this is an extension function, not available in strct mode. |
|
||||
| SYSOUT | Host lambda function | ? | ? | Dump the current content of the object list to file. If no `filepath` is specified, a file name will be constructed of the symbol `Sysout` and the current date. File paths will be considered relative to the filepath set when starting Lisp.<br><br>**NOTE THAT** this is an extension function, not available in strict mode. |
|
||||
| TERPRI | | ? | PSEUDO-FUNCTION | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=65'>65</a>, <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=84'>84</a> |
|
||||
| TIMES | Host lambda function | ? | | ? |
|
||||
| TRACE | Host lambda function | ? | PSEUDO-FUNCTION | Add this `s` to the set of symbols currently being traced. If `s` is not a symbol or sequence of symbols, does nothing. |
|
||||
| UNION | Lisp lambda function | ? | ? | ? |
|
||||
| UNTRACE | Host lambda function | ? | PSEUDO-FUNCTION | Remove this `s` from the set of symbols currently being traced. If `s` is not a symbol or sequence of symbols, does nothing. |
|
||||
| ZEROP | Lisp lambda function | ? | PREDICATE | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=26'>26</a>, <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=64'>64</a> |
|
||||
| NIL | Lisp variable | | | ? |
|
||||
| T | Lisp variable | | | ? |
|
||||
| F | Lisp variable | | | ? |
|
||||
| ADD1 | Host function | (ADD1 X) | | ? |
|
||||
| AND | Host function | (AND & ARGS) | PREDICATE | `T` if and only if none of my `args` evaluate to either `F` or `NIL`, else `F`. In `beowulf.host` principally because I don't yet feel confident to define varargs functions in Lisp. |
|
||||
| APPEND | Lisp function | (APPEND X Y) | LAMBDA-fn | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=19'>11</a>, <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=69'>61</a> |
|
||||
| APPLY | Host function | (APPLY FUNCTION ARGS ENVIRONMENT DEPTH) | | Apply this `function` to these `arguments` in this `environment` and return the result. For bootstrapping, at least, a version of APPLY written in Clojure. All args are assumed to be symbols or `beowulf.cons-cell/ConsCell` objects. See page 13 of the Lisp 1.5 Programmers Manual. |
|
||||
| ATOM | Host function | (ATOM X) | PREDICATE | Returns `T` if and only if the argument `x` is bound to an atom; else `F`. It is not clear to me from the documentation whether `(ATOM 7)` should return `T` or `F`. I'm going to assume `T`. |
|
||||
| CAR | Host function | (CAR X) | | Return the item indicated by the first pointer of a pair. NIL is treated specially: the CAR of NIL is NIL. |
|
||||
| CAAAAR | Lisp function | (CAAAAR X) | LAMBDA-fn | ? |
|
||||
| CAAADR | Lisp function | (CAAADR X) | LAMBDA-fn | ? |
|
||||
| CAAAR | Lisp function | (CAAAR X) | LAMBDA-fn | ? |
|
||||
| CAADAR | Lisp function | (CAADAR X) | LAMBDA-fn | ? |
|
||||
| CAADDR | Lisp function | (CAADDR X) | LAMBDA-fn | ? |
|
||||
| CAADR | Lisp function | (CAADR X) | LAMBDA-fn | ? |
|
||||
| CAAR | Lisp function | (CAAR X) | LAMBDA-fn | ? |
|
||||
| CADAAR | Lisp function | (CADAAR X) | LAMBDA-fn | ? |
|
||||
| CADADR | Lisp function | (CADADR X) | LAMBDA-fn | ? |
|
||||
| CADAR | Lisp function | (CADAR X) | LAMBDA-fn | ? |
|
||||
| CADDAR | Lisp function | (CADDAR X) | LAMBDA-fn | ? |
|
||||
| CADDDR | Lisp function | (CADDDR X) | LAMBDA-fn | ? |
|
||||
| CADDR | Lisp function | (CADDR X) | LAMBDA-fn | ? |
|
||||
| CADR | Lisp function | (CADR X) | LAMBDA-fn | ? |
|
||||
| CDAAAR | Lisp function | (CDAAAR X) | LAMBDA-fn | ? |
|
||||
| CDAADR | Lisp function | (CDAADR X) | LAMBDA-fn | ? |
|
||||
| CDAAR | Lisp function | (CDAAR X) | LAMBDA-fn | ? |
|
||||
| CDADAR | Lisp function | (CDADAR X) | LAMBDA-fn | ? |
|
||||
| CDADDR | Lisp function | (CDADDR X) | LAMBDA-fn | ? |
|
||||
| CDADR | Lisp function | (CDADR X) | LAMBDA-fn | ? |
|
||||
| CDAR | Lisp function | (CDAR X) | LAMBDA-fn | ? |
|
||||
| CDDAAR | Lisp function | (CDDAAR X) | LAMBDA-fn | ? |
|
||||
| CDDADR | Lisp function | (CDDADR X) | LAMBDA-fn | ? |
|
||||
| CDDAR | Lisp function | (CDDAR X) | LAMBDA-fn | ? |
|
||||
| CDDDAR | Lisp function | (CDDDAR X) | LAMBDA-fn | ? |
|
||||
| CDDDDR | Lisp function | (CDDDDR X) | LAMBDA-fn | ? |
|
||||
| CDDDR | Lisp function | (CDDDR X) | LAMBDA-fn | ? |
|
||||
| CDDR | Lisp function | (CDDR X) | LAMBDA-fn | ? |
|
||||
| CDR | Host function | (CDR X) | | Return the item indicated by the second pointer of a pair. NIL is treated specially: the CDR of NIL is NIL. |
|
||||
| CONS | Host function | (CONS CAR CDR) | | Construct a new instance of cons cell with this `car` and `cdr`. |
|
||||
| COPY | Lisp function | (COPY X) | LAMBDA-fn | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=70'>62</a> |
|
||||
| DEFINE | Host function | (DEFINE ARGS) | PSEUDO-FUNCTION | Bootstrap-only version of `DEFINE` which, post boostrap, can be overwritten in LISP. The single argument to `DEFINE` should be an assoc list which should be nconc'ed onto the front of the oblist. Broadly, (SETQ OBLIST (NCONC ARG1 OBLIST)) |
|
||||
| DIFFERENCE | Host function | (DIFFERENCE X Y) | | ? |
|
||||
| DIVIDE | Lisp function | (DIVIDE X Y) | LAMBDA-fn | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=34'>26</a>, <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=72'>64</a> |
|
||||
| ERROR | Host function | (ERROR & ARGS) | PSEUDO-FUNCTION | Throw an error |
|
||||
| EQ | Host function | (EQ X Y) | PREDICATE | Returns `T` if and only if both `x` and `y` are bound to the same atom, else `NIL`. |
|
||||
| EQUAL | Host function | (EQUAL X Y) | PREDICATE | This is a predicate that is true if its two arguments are identical S-expressions, and false if they are different. (The elementary predicate `EQ` is defined only for atomic arguments.) The definition of `EQUAL` is an example of a conditional expression inside a conditional expression. NOTE: returns `F` on failure, not `NIL` |
|
||||
| EVAL | Host function | (EVAL EXPR); (EVAL EXPR ENV DEPTH) | | Evaluate this `expr` and return the result. If `environment` is not passed, it defaults to the current value of the global object list. The `depth` argument is part of the tracing system and should not be set by user code. All args are assumed to be numbers, symbols or `beowulf.cons-cell/ConsCell` objects. |
|
||||
| FACTORIAL | Lisp function | (FACTORIAL N) | LAMBDA-fn | ? |
|
||||
| FIXP | Host function | (FIXP X) | PREDICATE | ? |
|
||||
| GENSYM | Host function | (GENSYM ) | | Generate a unique symbol. |
|
||||
| GET | Lisp function | (GET X Y) | LAMBDA-fn | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=49'>41</a>, <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=67'>59</a> |
|
||||
| GREATERP | Host function | (GREATERP X Y) | PREDICATE | ? |
|
||||
| INTEROP | Host function | (INTEROP FN-SYMBOL ARGS) | (INTEROP) | Clojure (or other host environment) interoperation API. `fn-symbol` is expected to be either 1. a symbol bound in the host environment to a function; or 2. a sequence (list) of symbols forming a qualified path name bound to a function. Lower case characters cannot normally be represented in Lisp 1.5, so both the upper case and lower case variants of `fn-symbol` will be tried. If the function you're looking for has a mixed case name, that is not currently accessible. `args` is expected to be a Lisp 1.5 list of arguments to be passed to that function. Return value must be something acceptable to Lisp 1.5, so either a symbol, a number, or a Lisp 1.5 list. If `fn-symbol` is not found (even when cast to lower case), or is not a function, or the value returned cannot be represented in Lisp 1.5, an exception is thrown with `:cause` bound to `:interop` and `:detail` set to a value representing the actual problem. |
|
||||
| INTERSECTION | Lisp function | (INTERSECTION X Y) | LAMBDA-fn | ? |
|
||||
| LENGTH | Lisp function | (LENGTH L) | LAMBDA-fn | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=70'>62</a> |
|
||||
| LESSP | Host function | (LESSP X Y) | PREDICATE | ? |
|
||||
| MEMBER | Lisp function | (MEMBER A X) | LAMBDA-fn | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=19'>11</a>, <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=70'>62</a> |
|
||||
| MINUSP | Lisp function | (MINUSP X) | LAMBDA-fn | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=34'>26</a>, <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=72'>64</a> |
|
||||
| NOT | Lisp function | (NOT X) | LAMBDA-fn | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=29'>21</a>, <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=31'>23</a>, <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=66'>58</a> |
|
||||
| NULL | Lisp function | (NULL X) | LAMBDA-fn | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=19'>11</a>, <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=65'>57</a> |
|
||||
| NUMBERP | Host function | (NUMBERP X) | PREDICATE | ? |
|
||||
| OBLIST | Host function | (OBLIST ) | | Return a list of the symbols currently bound on the object list. **NOTE THAT** in the Lisp 1.5 manual, footnote at the bottom of page 69, it implies that an argument can be passed but I'm not sure of the semantics of this. |
|
||||
| ONEP | Lisp function | (ONEP X) | LAMBDA-fn | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=34'>26</a>, <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=72'>64</a> |
|
||||
| PAIR | Lisp function | (PAIR X Y) | LAMBDA-fn | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=68'>60</a> |
|
||||
| PLUS | Host function | (PLUS & ARGS) | | ? |
|
||||
| PRETTY | Lisp variable | | (PRETTY) | ? |
|
||||
| PRINT | Lisp variable | | PSEUDO-FUNCTION | ? |
|
||||
| PROP | Lisp function | (PROP X Y U) | LAMBDA-fn | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=67'>59</a> |
|
||||
| QUOTIENT | Host function | (QUOTIENT X Y) | | I'm not certain from the documentation whether Lisp 1.5 `QUOTIENT` returned the integer part of the quotient, or a realnum representing the whole quotient. I am for now implementing the latter. |
|
||||
| RANGE | Lisp variable | ? | (RANGE (LAMBDA (N M) (COND ((LESSP M N) (QUOTE NIL)) ((QUOTE T) (CONS N (RANGE (ADD1 N) M)))))) | ? |
|
||||
| READ | Host function | (READ ); (READ INPUT) | PSEUDO-FUNCTION | An implementation of a Lisp reader sufficient for bootstrapping; not necessarily the final Lisp reader. `input` should be either a string representation of a LISP expression, or else an input stream. A single form will be read. |
|
||||
| REMAINDER | Host function | (REMAINDER X Y) | | ? |
|
||||
| REPEAT | Lisp function | (REPEAT N X) | LAMBDA-fn | ? |
|
||||
| RPLACA | Host function | (RPLACA CELL VALUE) | PSEUDO-FUNCTION | Replace the CAR pointer of this `cell` with this `value`. Dangerous, should really not exist, but does in Lisp 1.5 (and was important for some performance hacks in early Lisps) |
|
||||
| RPLACD | Host function | (RPLACD CELL VALUE) | PSEUDO-FUNCTION | Replace the CDR pointer of this `cell` with this `value`. Dangerous, should really not exist, but does in Lisp 1.5 (and was important for some performance hacks in early Lisps) |
|
||||
| SET | Host function | (SET SYMBOL VAL) | PSEUDO-FUNCTION | Implementation of SET in Clojure. Add to the `oblist` a binding of the value of `var` to the value of `val`. NOTE WELL: this is not SETQ! |
|
||||
| SUB1 | Lisp function | (SUB1 N) | LAMBDA-fn | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=34'>26</a>, <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=72'>64</a> |
|
||||
| SYSIN | Host function | (SYSIN ); (SYSIN FILENAME) | (SYSIN) | Read the contents of the file at this `filename` into the object list. If the file is not a valid Beowulf sysout file, this will probably corrupt the system, you have been warned. File paths will be considered relative to the filepath set when starting Lisp. It is intended that sysout files can be read both from resources within the jar file, and from the file system. If a named file exists in both the file system and the resources, the file system will be preferred. **NOTE THAT** if the provided `filename` does not end with `.lsp` (which, if you're writing it from the Lisp REPL, it won't), the extension `.lsp` will be appended. |
|
||||
| SYSOUT | Host function | (SYSOUT ); (SYSOUT FILEPATH) | (SYSOUT) | Dump the current content of the object list to file. If no `filepath` is specified, a file name will be constructed of the symbol `Sysout` and the current date. File paths will be considered relative to the filepath set when starting Lisp. |
|
||||
| TERPRI | Lisp variable | | PSEUDO-FUNCTION | ? |
|
||||
| TIMES | Host function | (TIMES & ARGS) | | ? |
|
||||
| TRACE | Host function | (TRACE S) | PSEUDO-FUNCTION | Add this symbol `s` to the set of symbols currently being traced. If `s` is not a symbol, does nothing. |
|
||||
| UNTRACE | Host function | (UNTRACE S) | PSEUDO-FUNCTION | ? |
|
||||
| ZEROP | Lisp function | (ZEROP N) | LAMBDA-fn | see manual pages <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=34'>26</a>, <a href='https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=72'>64</a> |
|
||||
|
||||
|
||||
Functions described as 'Lisp function' above are defined in the default
|
||||
sysout file, `resources/lisp1.5.lsp`, which will be loaded by default unless
|
||||
|
@ -216,7 +145,8 @@ over the Clojure implementations.
|
|||
|
||||
### Architectural plan
|
||||
|
||||
Not everything documented in this section is yet built. It indicates the direction of travel and intended destination, not the current state.
|
||||
Not everything documented in this section is yet built. It indicates the
|
||||
direction of travel and intended destination, not the current state.
|
||||
|
||||
#### resources/lisp1.5.lsp
|
||||
|
||||
|
@ -265,6 +195,19 @@ Intended deviations from the behaviour of the real Lisp reader are as follows:
|
|||
a comment, as most modern Lisps do; but I do not believe Lisp 1.5 had
|
||||
this feature.
|
||||
|
||||
### BUT WHY?!!?!
|
||||
|
||||
Because.
|
||||
|
||||
Because Lisp is the only computer language worth learning, and if a thing
|
||||
is worth learning, it's worth learning properly; which means going back to
|
||||
the beginning and trying to understand that.
|
||||
|
||||
Because there is, so far as I know, no working implementation of Lisp 1.5
|
||||
for modern machines.
|
||||
|
||||
Because I'm barking mad, and this is therapy.
|
||||
|
||||
### Commentary
|
||||
|
||||
What's surprised me in working on this is how much more polished Lisp 1.5 is
|
||||
|
@ -282,19 +225,11 @@ but this is software which is almost sixty years old).
|
|||
|
||||
## Installation
|
||||
|
||||
Download the latest [release 'uberjar'](https://github.com/simon-brooke/beowulf/releases) and run it using:
|
||||
At present, clone the source and build it using
|
||||
|
||||
```bash
|
||||
java -jar <path name of uberjar>
|
||||
```
|
||||
`lein uberjar`.
|
||||
|
||||
Or clone the source and build it using:
|
||||
|
||||
```bash
|
||||
lein uberjar`
|
||||
```
|
||||
|
||||
To build it you will require to have [Leiningen](https://leiningen.org/) installed.
|
||||
You will require to have [Leiningen](https://leiningen.org/) installed.
|
||||
|
||||
### Input/output
|
||||
|
||||
|
@ -327,14 +262,7 @@ processors, but I failed to find the Lisp source of Lisp functions as a text
|
|||
file, which is why `resources/lisp1.5.lsp` is largely copytyped and
|
||||
reconstructed from the manual.
|
||||
|
||||
### Other implementations
|
||||
|
||||
There's an online (browser native) Lisp 1.5 implementation [here](https://pages.zick.run/ichigo/) (source code [here](https://github.com/zick/IchigoLisp)). It
|
||||
even has a working compiler!
|
||||
|
||||
### History resources
|
||||
|
||||
I'm compiling a [list of links to historical documents on Lisp 1.5](https://simon-brooke.github.io/beowulf/docs/further_reading.html).
|
||||
I'm not at this time aware of any other working Lisp 1.5 implementations.
|
||||
|
||||
## License
|
||||
|
||||
|
|
|
@ -1,16 +1,7 @@
|
|||
# Further Reading
|
||||
|
||||
1. [CODING for the MIT-IBM 704 COMPUTER, October 1957](http://bitsavers.org/pdf/mit/computer_center/Coding_for_the_MIT-IBM_704_Computer_Oct57.pdf)
|
||||
This paper is not about Lisp. But it is about the particular individual computer on which Lisp was first implemented, and it is written in part by members of the Lisp team. I have found it useful in understanding the software environment in which, and the constraints under which, Lisp was written.
|
||||
2. [MIT AI Memo 1, John McCarthy, September 1958](https://www.softwarepreservation.org/projects/LISP/MIT/AIM-001.pdf)
|
||||
This is, as far as I can find, the earliest specification document of the Lisp project.
|
||||
3. [Lisp 1 Programmer's Manual, Phyllis Fox, March 1960](https://bitsavers.org/pdf/mit/rle_lisp/LISP_I_Programmers_Manual_Mar60.pdf)
|
||||
4. [Lisp 1.5 Programmer's Manual, Michael I. Levin, August 1962](https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=81)
|
||||
This book is essential reading: it documents in some detail the first fully realised Lisp language system.
|
||||
5. [Early LISP History (1956 - 1959), Herbert Stoyan, August 1984](https://dl.acm.org/doi/pdf/10.1145/800055.802047#page=3)
|
||||
|
||||
|
||||
6. [The Roots of Lisp, Paul Graham, 2001](http://www.paulgraham.com/rootsoflisp.html)
|
||||
6. [The Revenge of the Nerds, Paul Graham, 2002](http://www.paulgraham.com/icad.html)
|
||||
This is mainly about why to use Lisp as a language for modern commercial software, but has useful insights into where it comes from.
|
||||
> So the short explanation of why this 1950s language is not obsolete is that it was not technology but math, and math doesn't get stale.
|
441
doc/lisp1.5.md
441
doc/lisp1.5.md
|
@ -5,10 +5,10 @@
|
|||
|
||||
**Massachusetts Institute of Technology**
|
||||
|
||||
> [John McCarthy](https://en.wikipedia.org/wiki/John_McCarthy_(computer_scientist))
|
||||
> [Paul W. Abrahams](https://mitpress.mit.edu/author/paul-w-abrahams-31449/)
|
||||
> [Daniel J. Edwards](https://www.chessprogramming.org/Daniel_Edwards)
|
||||
> [Timothy P. Hart](https://www.chessprogramming.org/Timothy_Hart)
|
||||
> John McCarthy
|
||||
> Paul W. Abrahams
|
||||
> Daniel J. Edwards
|
||||
> Timothy P. Hart
|
||||
|
||||
> The M. I.T. Press
|
||||
> Massachusetts Institute of Technology
|
||||
|
@ -43,11 +43,11 @@ The over-all design of the LISP Programming System is the work of John McCarthy
|
|||
|
||||
This manual was written by Michael I. Levin.
|
||||
|
||||
The interpreter was programmed by [Stephen B. Russell](https://en.wikipedia.org/wiki/Steve_Russell_(computer_scientist)) and Daniel J. Edwards. The print and read programs were written by John McCarthy, Klim Maling, Daniel J. Edwards, and Paul W. Abrahams.
|
||||
The interpreter was programmed by Stephen B. Russell and Daniel J. Edwards. The print and read programs were written by John McCarthy, Klim Maling, Daniel J. Edwards, and Paul W, Abrahams.
|
||||
|
||||
The garbage collector and arithmetic features Were written by Daniel J. Edwards. The compiler and assembler were written by Timothy P. Hart and Michael I. Levin. An earlier compiler was written by Robert Brayton.
|
||||
|
||||
The "LISP 1 Programmer's Manual" March 1, 1960, was written by [Phyllis A. Fox](https://en.wikipedia.org/wiki/Phyllis_Fox). Additional programs and suggestions were contributed by the following members of the Artificial Intelligence Group of the Research Laboratory of Electronics: Marvin L. Minsky, Bertram Raphael, Louis Hodes, David M. R. Park, David C. Luckham, Daniel G. Bobrow, James R. Slagle, and Nathaniel Rochester.
|
||||
The "LISP 1 Programmer's Manual" March 1, 1960, was written by Phyllis A. Fox. Additional programs and suggestions were contributed by the following members of the Artificial Intelligence Group of the Research Laboratory of Electronics: Marvin L. Minsky, Bertram Raphael, Louis Hodes, David M. R. Park, David C. Luckham, Daniel G. Bobrow, James R. Slagle, and Nathaniel Rochester.
|
||||
|
||||
August 17, 1962
|
||||
|
||||
|
@ -387,7 +387,7 @@ The Euclidean algorithm for finding the greatest common divisor of two positive
|
|||
|
||||
```
|
||||
gcd[x; y]=[x>y -> gcd[y; x];
|
||||
rem[y;x]=0 -> x]
|
||||
rem[y;x]=0 -> x]
|
||||
```
|
||||
|
||||
`rem[u; v]` is the remainder when `u` is divided by `v`.
|
||||
|
@ -575,9 +575,9 @@ This function gives the result of substituting the S-expression x for all occurr
|
|||
|
||||
```
|
||||
subst[x; y; z] = [equal[y; z] -> x;
|
||||
atom[z] - z;
|
||||
T - cons[subst
|
||||
[x; y; car[z]]; subst[x; y; cdr[z]]]]
|
||||
atom[z] - z;
|
||||
T - cons[subst
|
||||
[x; y; car[z]]; subst[x; y; cdr[z]]]]
|
||||
```
|
||||
|
||||
As an example, we have
|
||||
|
@ -607,8 +607,8 @@ append[(A B);(C D E)] = (A B C D E)
|
|||
This predicate is true if the S-expression `x` occurs among the elements of the list `y`. We have
|
||||
```
|
||||
member[x; y] = [null[y] -> F;
|
||||
equal[x; car [y ]] ->T;
|
||||
T -> member[x; cdr [y ]]]
|
||||
equal[x; car [y ]] ->T;
|
||||
T -> member[x; cdr [y ]]]
|
||||
```
|
||||
|
||||
#### 3. pairlis[x; y; a]
|
||||
|
@ -621,8 +621,8 @@ two columns, is called an association list. We have
|
|||
|
||||
```
|
||||
pairlis [x; y; a] = [null[x] -> a;
|
||||
T -> cons[cons[car[x]; car[y]];
|
||||
pairlis[cdr[x]; cdr [y]; a]]]
|
||||
T -> cons[cons[car[x]; car[y]];
|
||||
pairlis[cdr[x]; cdr [y]; a]]]
|
||||
```
|
||||
|
||||
An example is
|
||||
|
@ -658,13 +658,13 @@ from the pair list. In order to define `sublis`, we first define an auxiliary fu
|
|||
|
||||
```
|
||||
sub2[a; z] = [null[a] -> z; eq[caar[a]; z] -> cdar[a];
|
||||
T -> sub2[cdr[a]; z]]
|
||||
T -> sub2[cdr[a]; z]]
|
||||
```
|
||||
and
|
||||
|
||||
```
|
||||
sublis[a; y] = [atom[y] -> sub2[a; y];
|
||||
T -> cons[sublis[a; car[y]]; sublis[a; cdr[y]]]]
|
||||
T -> cons[sublis[a; car[y]]; sublis[a; cdr[y]]]]
|
||||
```
|
||||
|
||||
An example is
|
||||
|
@ -707,35 +707,35 @@ evalquote[fn; x] = apply[fn; x; NIL]
|
|||
where
|
||||
```mexpr
|
||||
apply[fn; x; a] =
|
||||
[atom[fn] -> [eq[fn; CAR] -> caar[x]
|
||||
eq[fn; CDR] -> cdar[x];
|
||||
eq[fn; CONS] -> cons[car[x]; cadr[x]];
|
||||
eq[fn; ATOM] -> atom[car[x]];
|
||||
eq[fn; EQ] -> eq[car[x]; cadr[x]];
|
||||
T -> apply[eval[fn; a]; x; a]]
|
||||
eq[car[fn]; LAMBDA] -> eval[caddr[fn]; pairlis[cadr[fn]; x; a]];
|
||||
eq[car[fn]; LABEL] -> apply[caddr [fn]; x; cons[cons[cadr [fn];
|
||||
caddr[fn]]; a]]]
|
||||
[atom[fn] -> [eq[fn; CAR] -> caar[x]
|
||||
eq[fn; CDR] -> cdar[x];
|
||||
eq[fn; CONS] -> cons[car[x]; cadr[x]];
|
||||
eq[fn; ATOM] -> atom[car[x]];
|
||||
eq[fn; EQ] -> eq[car[x]; cadr[x]];
|
||||
T -> apply[eval[fn; a]; x; a]]
|
||||
eq[car[fn]; LAMBDA] -> eval[caddr[fn]; pairlis[cadr[fn]; x; a]];
|
||||
eq[car[fn]; LABEL] -> apply[caddr [fn]; x; cons[cons[cadr [fn];
|
||||
caddr[fn]]; a]]]
|
||||
|
||||
eval[e;a] = [atom[e] -> cdr[assoc[e;a]];
|
||||
atom[car[e]] -> [eq[car[e]; QUOTE] -> cadr[e];
|
||||
eq[car[e]; COND] -> evcon[cdr[e]; a];
|
||||
T -> apply[car[e]; evlis[cdr[el; a]; a]];
|
||||
T -> apply[car[e]; evlis [cdr[e]; a]; a]]
|
||||
atom[car[e]] -> [eq[car[e]; QUOTE] -> cadr[e];
|
||||
eq[car[e]; COND] -> evcon[cdr[e]; a];
|
||||
T -> apply[car[e]; evlis[cdr[el; a]; a]];
|
||||
T -> apply[car[e]; evlis [cdr[e]; a]; a]]
|
||||
```
|
||||
|
||||
`pairlis` and `assoc` have been previously defined.
|
||||
|
||||
```mexpr
|
||||
evcon[c; a] = [eval[caar[c]; a] -> eval[cadar[c]; a];
|
||||
T -> evcon[cdr [c];a]]
|
||||
T -> evcon[cdr [c];a]]
|
||||
```
|
||||
|
||||
and
|
||||
|
||||
```mexpr
|
||||
evlis[m; a] = [null[m] -> NIL;
|
||||
T -> cons [eval[car [m];a];evlis[cdr [m];a]]]
|
||||
T -> cons [eval[car [m];a];evlis[cdr [m];a]]]
|
||||
```
|
||||
|
||||
<a name="page14">page 14</a>
|
||||
|
@ -780,11 +780,11 @@ The following example is a LISP program that defines three functions `union`, `i
|
|||
|
||||
```
|
||||
member[a; x] = [null[x] -> F; eq[a; car[x]] -> T;
|
||||
T -> member[a; cdr[x]]]
|
||||
T -> member[a; cdr[x]]]
|
||||
|
||||
union[x; y] = [null[x] -> y;
|
||||
member[car[x];y] -> union[cdr[x]; y];
|
||||
T -> cons[car[x]; union[cdr[x]; y]]]
|
||||
member[car[x];y] -> union[cdr[x]; y];
|
||||
T -> cons[car[x]; union[cdr[x]; y]]]
|
||||
|
||||
intersection[x;y] = [null[x] -> NIL;
|
||||
member[car[x]; y] -> cons[car[x]; intersection[cdr[x]; y]];
|
||||
|
@ -2719,8 +2719,8 @@ erty list for FF.
|
|||
The function `prop` searches the list `x` for an item that is `eq` to `y`. If such an element is found, the value of `prop` is the rest of the list beginning immediately after the element. Otherwise the value is `u[]`, where u is a function of no arguments.
|
||||
```
|
||||
prop[x; y; u] = [null[x] -> u[ ];
|
||||
eq[car[x];y] -> cdr[x]
|
||||
T -> prop[cdr[x]; y; u]]
|
||||
eq[car[x];y] -> cdr[x]
|
||||
T -> prop[cdr[x]; y; u]]
|
||||
```
|
||||
SUBR
|
||||
```
|
||||
|
@ -2816,14 +2816,13 @@ Note that the following M-expression is different from that given in Section I,
|
|||
the result is the same.
|
||||
|
||||
```
|
||||
sublis[x;y] = [null[x] -> y;
|
||||
null[y] -> y;
|
||||
T -> search[x;
|
||||
lambda[[j]; equal[y;caar[j]]];
|
||||
lambda[[j]; cdar[j]];
|
||||
lambda[[j]; [atom[y] -> y;
|
||||
T -> cons[sublis[x; car[y]];
|
||||
sublis[x; cdr[y]]]]]]]
|
||||
sublis[x;y] [null[x] -- y;
|
||||
null[y] -- y;
|
||||
T -. search[x;
|
||||
k[[j]; equal[y;caar[j]]];
|
||||
k[[j]; cdar[j]];
|
||||
k[[j];[atom[y] - y;
|
||||
T -c cons [sublis [x;car [y]];sublis [x;cdr [y]]]]]]]
|
||||
```
|
||||
|
||||
### List Handling Functions
|
||||
|
@ -3292,136 +3291,127 @@ NIL
|
|||
by performing
|
||||
EVAL (OBLIST NIL).
|
||||
|
||||
<a name="page70">page 70</a>
|
||||
|
||||
## APPENDIX B : THE LISP INTERPRETER
|
||||
|
||||
This appendix is written in mixed M-expressions and English. Its purpose is to describe as closely as possible the actual working of the interpreter and PROG feature. The functions `evalquote`, `apply`, `eval`, `evlis`, `evcon`, and the `PROG` feature are defined by using a language that follows the M-expression notation as closely as possible and contains some insertions in English.
|
||||
This appendix is written in mixed M-expressions and English. Its purpose is to
|
||||
describe as closely as possible the actual working of the interpreter and PROG feature.
|
||||
The functions evalquote, ---- apply, eval, evlis, evcon, and the PROG feature are defined
|
||||
by using a language that follows the M-expression notation as closely as possible and
|
||||
contains some insertions in English.
|
||||
|
||||
```mexpr
|
||||
evalquote[fn; args]=[get[fn; FEXPR] v get[fn; FSUBR] -> eval[cons [ fn; args]; NIL];
|
||||
T -> apply[fn; args; NIL]
|
||||
```
|
||||
###### evalquote[fn;args]=[get [fn; FEXPR] vget [fn; FSUBR] -
|
||||
|
||||
This definition shows that `evalquote` is capable of handling special forms as a sort of exception. Apply cannot handle special forms and will give error `A2` if given one as its first argument.
|
||||
|
||||
The following definition of `apply` is an enlargement of the one given in Section I. It shows how functional arguments bound by FUNARG are processed, and describes the way in which machine language subroutines are called.
|
||||
|
||||
In this description, `spread` can be regarded as a pseudo-function of one argument. This argument is a list. `spread` puts the individual items of this list into the AC, MQ,
|
||||
$ARG3,... the standard cells *[general purpose registers]* for transmitting arguments to functions.
|
||||
eval[cons [ fn; args]; NIL]
|
||||
|
||||
This definition shows that evalquote is capable of handling special forms as a sort
|
||||
of exception. Apply cannot handle special forms and will give error A2 if given one as
|
||||
its first argument.
|
||||
The following definition'of apply is an enlargement of the one given in Section I. It
|
||||
shows how functional arguments bound by FUNARG are processed, and describes the
|
||||
way in which machine language subroutines are called.
|
||||
In this description, spread can be regarded as a pseudo-function of one argument.
|
||||
This argument is a list. spread puts the individual items of this list into the AC, MQ,
|
||||
$ARG3,... the standard cells for transmitting arguments to functions.
|
||||
These M-expressions should not be taken too literally. In many cases, the actual
|
||||
program is a store and transfer where a recursion is suggested by these definitions.
|
||||
apply[fn;args;a]=[
|
||||
null [fn]-NIL;
|
||||
at ~rn[fn]-[~et [fn; EXPR]-~~~~~ [expr^1 ; args ; a];
|
||||
spread[args];
|
||||
|
||||
```mexpr
|
||||
apply[fn; args; a]=[
|
||||
null[fn] -> NIL;
|
||||
atom[fn] -> [get[fn; EXPR] -> apply[expr ; args ; a];
|
||||
get[fn; subr] -> {spread[args];
|
||||
$ALIST := a;
|
||||
TSX subr, 4};
|
||||
T -> apply[cdr[sassoc[fn; a; lambda[[];error [A2]]]]; args ;a];
|
||||
eq[car[fn]; LABEL] -> apply[caddr[fn];args;
|
||||
cons[cons[cadr[fn];
|
||||
caddr[fn]];a]];
|
||||
eq[car[fn]; FUNARG] -> apply[cadr[fn]; args; caddr[fn]];
|
||||
eq[car [fn]; LAMBDA] -> eval[caddr[fn];
|
||||
nconc [pair[cadr[fn]; args]; a]];
|
||||
T -> apply[eval[fn; a]; args; a]]
|
||||
```
|
||||
*NOTE THAT the formatting of this MEXPR is beyond the capabilities of Markdown to reproduce; this is a rational reconstruction, but to be perfectly certain of the interpretation consult the PDF*
|
||||
T-apply[cdr[sassoc [fn;a;~[[];error [~2]]]];ar~s ;a];
|
||||
eq[car[fn]; ~~~~~]-a~~l~[caddr[fn];ar~s;cons[cons[cadr[fn];caddr[fn]];a]];
|
||||
eq[car[fn]; ~~~~~~]-a~~1~[cadr [fn]; args; caddr [fn]];
|
||||
eq[car [fn]; LAMBDA]-eval[caddr[fn]; nconc [pair[cadr[fn]; args]; a]];
|
||||
~-a~~ly[eval[fn;a];ar~s ;a]]
|
||||
|
||||
1. The value of get is set aside. This is the meaning of the apparent free or unde-
|
||||
fined variable -
|
||||
|
||||
* eval[f orm; a]= [
|
||||
null[f orm]-NIL;
|
||||
numberp[f orm]-f orm;
|
||||
atom[form]-[get[f O~~;APVAL]-car [apval^1 1;
|
||||
~~cdr[sassoc[form;a;~[[ ];error[A8]]]]];
|
||||
eq[car[f O~~];QUOTE]-cadr [form]; 2
|
||||
eq[car [form]; FUNCTION]-~~~~[FUNARG; cadr [form];a];
|
||||
eq[car [form]; COND]-evcon[cdr[form]; a];
|
||||
eq[car [form]; ~~OG]-~ro~[cdr [form]; a];
|
||||
atom[car[form]] -[get[car [form];~~~~]-~a~~l~[ex~r;^1 evlis[cdr lforrn];a];a];
|
||||
get[car[form];~~~~~]-apply[fexpr !list[cdr [form];a];a];
|
||||
spread[evlis [cdr [form]; a]];
|
||||
get[car[form];~~~~]-
|
||||
TSX subr f 4
|
||||
AC: =cdr [ form];
|
||||
get[car[form];F~u~R]-, MQ: = $ALIST: =a; ;
|
||||
|
||||
-----
|
||||
|
||||
1. The value of get is set aside. This is the meaning of the apparent free or undefined variable.
|
||||
|
||||
<a name="page71">page 71</a>
|
||||
|
||||
```mexpr
|
||||
eval[form; a]= [
|
||||
null[form] -> NIL;
|
||||
numberp[form] -> form;
|
||||
atom[form] -> [get[form; APVAL] -> car[apval];
|
||||
T -> cdr[sassoc[form; a; lambda[[ ]; error[A8]]]]];
|
||||
eq[car[form]; QUOTE] -> cadr[form];
|
||||
eq[car[form]; FUNCTION] -> list[FUNARG; cadr[form]; a];
|
||||
eq[car [form]; COND] -> evcon[cdr[form]; a];
|
||||
eq[car [form]; PROG] -> prog[cdr[form]; a];
|
||||
atom[car[form]] -> [get[car [form]; EXPR] ->
|
||||
apply[expr; evlis[cdr[form]; a]; a];
|
||||
get[car[form]; FEXPR] ->
|
||||
apply[fexpr; list[cdr[form]; a]; a];
|
||||
get[car[form]; SUBR] -> {spread[evlis[cdr[form]; a]];
|
||||
$ALIST := a;
|
||||
TSX subr 4};
|
||||
get[car[form]; FSUBR] -> {AC := cdr[form];
|
||||
MQ := $ALIST := a;
|
||||
TSX fsubr 4}
|
||||
T -> eval[cons[cdr[sassoc[car[form]; a;
|
||||
lambda[[];error[A9]]]];
|
||||
cdr[form]]; a]];
|
||||
T-apply [car [form];evlis [cdr [form]; a]; a]]
|
||||
|
||||
evcon[c; a] = [null[c] -> error[A3];
|
||||
eval[caar[c]; a] -> eval[cadar[a]; a];
|
||||
T -> evcon[cdr[ c]; a]]
|
||||
|
||||
evlis[m; a] = maplist[m; lambda[[j]; eval[car[j]; a]]]
|
||||
```
|
||||
### The PROG Feature
|
||||
# (TSx fsubr!4 }
|
||||
|
||||
~-e~al[~0ns[cdr[sas~0~[car[form];a;~[[];error[~9]]]];
|
||||
cdr [form]]; a]];
|
||||
T-apply [car [form];evlis [cdr [form]; a]; a]]
|
||||
evcon[c; a]= [null[c]--error [A3];
|
||||
eval[caar[ c]; a]-eval[cadar [a];a];
|
||||
T-evcon[cdr [ c];a]]
|
||||
evlis[ - m; a] =maplist [m; ~[[j]; eval[car[j]; a]]]
|
||||
The PROG Feature
|
||||
The PROG feature is an FSUBR coded into the system. It can best be explained in
|
||||
English, although it is possible to define it by using M-expressions.
|
||||
|
||||
1. As soon as the PROG feature is entered, the list of program variables is used
|
||||
to make a new list in which each one is paired with NIL. This is then appended to the current a-list. Thus each program variable is set to NIL at the entrance to the program.
|
||||
to make a new list in which each one is paired with NIL. This is then appended to the
|
||||
current a-list. Thus each program variable is set to NIL at the entrance to the program.
|
||||
2. The remainder of the program is searched for atomic symbols that are under-
|
||||
stood to be location symbols. A go-list is formed in which each location symbol is paired with a pointer into the remainder of the program.
|
||||
3. When a set or a setq - is encountered, the name of the variable is located on the a-list. The value of the variable (or cdr of the pair) is actually replaced with the new value.
|
||||
stood to be location symbols. A go-list is formed in which each location symbol is
|
||||
paired with a pointer into the remainder of the program.
|
||||
3. When a set or a setq - is encountered, the name of the variable is located on the
|
||||
a-list. The value of the variable (or cs of the pair) is actually replaced with the new
|
||||
value.
|
||||
1. The value of get is set aside. This is the meaning of the apparent free or unde-
|
||||
fined variable-
|
||||
2. In the actual system this is handled by an FSUBR rather than as the separate special
|
||||
case as shown here.
|
||||
|
||||
-----
|
||||
1. The value of get is set aside. This is the meaning of the apparent free or undefined variable.
|
||||
2. In the actual system this is handled by an FSUBR rather than as the separate special case as shown here.
|
||||
If the variable is bound several times on the a-list, only the first or most recent
|
||||
occurrence is changed. If the current binding of the variable is at a higher level than
|
||||
the entrance to the prog, then the change will remain in effect throughout the scope
|
||||
of that binding, and the old value will be lost.
|
||||
If the variable does not occur on the a-list, then error diagnostic A4 or A5 will
|
||||
occur.
|
||||
|
||||
<a name="page72">page 72</a>
|
||||
|
||||
If the variable is bound several times on the a-list, only the first or most recent occurrence is changed. If the current binding of the variable is at a higher level than the entrance to the prog, then the change will remain in effect throughout the scope of that binding, and the old value will be lost.
|
||||
|
||||
If the variable does not occur on the a-list, then error diagnostic `A4` or `A5` will occur.
|
||||
|
||||
4. When a return is encountered at any point, its argument is evaluated and returned as the value of the most recent prog that has been entered.
|
||||
4. When a return is encountered at any point, its argument is evaluated and returned
|
||||
as the value of the most recent prog that has been entered.
|
||||
5. The form go may be used only in two ways.
|
||||
a. `(GO X)` may occur on the top level of the prog, `x` must be a location symbol of this `prog` and not another one on a higher or lower level.
|
||||
b. This form may also occur as one of the value parts of a conditional expression, if this conditional expression occurs on the top level of the `prog`.
|
||||
If a `go` is used incorrectly or refers to a nonexistent location, error diagnostic `A6` will occur.
|
||||
|
||||
6. When the form cond occurs on the top level of a `prog`, it differs from other
|
||||
`cond`s in the following ways.
|
||||
a. It is the only instance in which a `go` can occur inside a `cond`.
|
||||
b. If the `cond` runs out of clauses, error diagnostic `A3` will not occur. Instead, the `prog` will continue with the next statement.
|
||||
|
||||
a. (GO X) may occur on the top level of the prog, x must be a location symbol
|
||||
of this prog and not another one on a higher or lower level.
|
||||
b. This form may also occur as one of the value parts of a conditional expres-
|
||||
sion, if this conditional expression occurs on the top level of the prog.
|
||||
If a go - is used incorrectly or refers to a nonexistent location, error diagnostic A6
|
||||
will occur.
|
||||
6. When the form cond occurs on the top level of a prog, it differs from other
|
||||
conds in the following ways.
|
||||
a. It is the only instance in which a gocan occur inside a cond.
|
||||
b. If the cond runs out of clauses, error diagnostic A3 will not occur. Instead,
|
||||
the prog will c6ntinue with the next statement.
|
||||
7. When a statement is executed, this has the following meaning, with the exception
|
||||
of the special forms `cond`, `go`, `return`, `setq` and the pseudo-function `set`, all of which are peculiar to `prog`.
|
||||
The statement `s` is executed by performing `eval[s;a]`, where `a` is the current a-list, and then ignoring the value.
|
||||
|
||||
of the special forms cond, go, return, setq and the pseudo-functionset, all of which
|
||||
are peculiar to prog.
|
||||
The statement 5 is executed by performing eval[s;a], where 2 is the current a-list,
|
||||
and then ignoring the value.
|
||||
8. If a prog runs out of statements, its value is NIL.
|
||||
When a prog - is compiled, it will have the same effect as when it is interpreted, although the method of execution is much different; for example, a go is always cornpiled as a transfer. The following points should be noted concerning declared variables.<sup>1</sup>
|
||||
1. Program variables follow the same rules as h variables do.
|
||||
a. If a variable is purely local, it need not be declared.
|
||||
b. Special variables can be used as free variables in compiled functions. They may be set at a lower level than that at which they are bound.
|
||||
c. Common program variables maintain complete communication between compiled programs and the interpreter.
|
||||
|
||||
2. & as distinct from setq can only be used to set common variables.
|
||||
|
||||
|
||||
-----
|
||||
When a prog - is compiled, it will have the same effect as when it is interpreted,
|
||||
although the method of execution is much different; for example, a go is always corn-
|
||||
piled as a transfer. The following points should be noted concerning declared variables.^1
|
||||
1. Program variables follow the same rules as h variables do.
|
||||
a. If a variable is purely local, it need not be declared.
|
||||
b. Special variables can be used as free variables in compiled functions. They
|
||||
may be set at a lower level than that at which they are bound.
|
||||
c. Common program variables maintain complete communication between com-
|
||||
piled programs and the interpreter.
|
||||
2. & as distinct from setq can only be used to set common variables.
|
||||
1. See Appendix D for an explanation of variable declaration.
|
||||
|
||||
<a name="page73">page 73</a>
|
||||
|
||||
## APPENDIX C : THE LISP ASSEMBLY PROGRAM (LAP)
|
||||
APPENDIX C : THE LISP ASSEMBLY PROGRAM (LAP)
|
||||
|
||||
lap is a two-pass assembler. It was specifically designed for use by the new com-
|
||||
piler, but it can also be used for defining functions in machine language, and for making
|
||||
|
@ -3465,9 +3455,6 @@ FSUBR. n is the number of arguments which the subroutine expects.
|
|||
Symbols
|
||||
|
||||
Atomic symbols appearing on the listing (except NIL or the first item on the listing)
|
||||
|
||||
<a name="page74">page 74</a>
|
||||
|
||||
are treated as location symbols. The appearance of the symbol defines it as the location
|
||||
of the next instruction in the listing. During pass one, these symbols and their values
|
||||
are made into a pair list, and appended to the initial symbol table to form the final sym-
|
||||
|
@ -3513,8 +3500,6 @@ literal will not be created if it is equal to one that already exists.
|
|||
4. If the field is of the form (SPECIAL x), then the value is the address of the
|
||||
SPECIAL cell on the property list of x. If one does not already exist, it will be created.
|
||||
|
||||
<a name="page75">page 75</a>
|
||||
|
||||
The SPECIAL cell itself (but not the entire atom) is protected against garbage collection.
|
||||
|
||||
5. In all other cases, the field is assumed to be a list of subfields, and their sum
|
||||
|
@ -3581,10 +3566,8 @@ LAP ( (6217Q (TRA NIL) )NIL)
|
|||
LAP ( (NIL (CLA A) (TSX 6204Q) (TRA B) )
|
||||
( (A 6243Q) (B 6220Q) ) )
|
||||
|
||||
<a name="page76">page 76</a>
|
||||
|
||||
## APPENDIX D : THE LISP COMPILER
|
||||
|
||||
APPENDIX D
|
||||
THE LISP COMPILER
|
||||
The LISP Compiler is a program written in LISP that translates S-expression defi-
|
||||
nitions of functions into machine language subroutines. It is an optional feature that
|
||||
makes programs run many times faster than they would if they were to be interpreted
|
||||
|
@ -3597,13 +3580,12 @@ space. Thus an EXPR, or an FEXPR, has been changed to a SUBR or an FSUBR,
|
|||
respectively.
|
||||
Experience has shown that compiled programs run anywhere from 10 to 100 times
|
||||
as fast as interpreted programs, the time depending upon the nature of the program.
|
||||
Compiled programs are also more economical with memory than their corresponding
|
||||
S-expressions, taking only from 50 per cent to 80 per cent as much space.<sup>1</sup>
|
||||
Compiled programs are also more economical with memory than their corresponding 1
|
||||
S-expressions, taking only from 50 per cent to 80 per cent as much space.'
|
||||
The major part of the compiler is a translator or function from the S-expression
|
||||
function notation into the assembly language, LAP. The only reasons why the compiler
|
||||
is regarded as a pseudo-function are that it calls LAP, and it removes EXPRts and
|
||||
FEXPR1s when it has finished compiling.
|
||||
|
||||
The compiler has an interesting and perhaps unique history. It was developed in
|
||||
the following steps:
|
||||
|
||||
|
@ -3618,20 +3600,18 @@ tape is created, the entire compiler was punched out in assembly language by usi
|
|||
punc hlap.
|
||||
4. When a system tape is to be made, the compiler in assembly language is read
|
||||
in by using readlap.
|
||||
The compiler is called by using the pseudo-function compile. The argument of com-
|
||||
|
||||
The compiler is called by using the pseudo-function compile. The argument of compile is a list of the names of functions to be compiled. Each atomic symbol on this list
|
||||
- pile is a list of the names of functions to be compiled. Each atomic symbol on this list
|
||||
should have either an EXPR or an FEXPR on its property list before being compiled.
|
||||
The processing of each function occurs in three steps. First, the S-expression for
|
||||
the function is translated into assembly language. If no S-expression is found, then the
|
||||
compiler will print this fact and proceed with the next function. Second, the assembly
|
||||
|
||||
-----
|
||||
1. Since the compiled program is binary program space, which is normally
|
||||
not otherwise accessible, one gains as free storage the total space formerly occupied
|
||||
by the S-expression definition.
|
||||
|
||||
<a name="page77">page 77</a>
|
||||
|
||||
language program is assembled by LAP. Finally, if no error has occurred, then the
|
||||
EXPR or FEXPR is removed from the property list. When certain errors caused by
|
||||
undeclared free variables occur, the compiler will print a diagnostic and continue.
|
||||
|
@ -3678,8 +3658,6 @@ When a variable is used free, it must have been bound by a higher level function
|
|||
If a program is being run interpretively, and a free variable is used without having been
|
||||
bound on a higher level, error diagnostic *A^89 will occur.
|
||||
|
||||
<a name="page78">page 78</a>
|
||||
|
||||
If the program is being run compiled, the diagnostic may not occur, and the variable
|
||||
may have value NIL.
|
||||
There are three types of variables in compiled functions: ordinary variables,
|
||||
|
@ -3721,8 +3699,6 @@ Consider the following definition of a function dot by using an S-expression:
|
|||
(YDOT (LAMBDA (X Y) (MAPLIST X (FUNCTION
|
||||
(LAMBDA (J) (CONS (CAR J) Y)) ))))
|
||||
|
||||
<a name="page79">page 79</a>
|
||||
|
||||
Following the word FUNCTION is a functional constant. If we consider it as a sep-
|
||||
arate function, it is evident that it contains a bound variable "Jtt, and a free variable
|
||||
"Yfl. This free variable must be declared SPECIAL or COMMON, even though it is
|
||||
|
@ -3757,8 +3733,6 @@ form the instruction TSX and plant this on top of the STR.
|
|||
2. Once a direct TSX link is made, this particular calling point will not be traced.
|
||||
(Link will not make a TSX as long as the called function is being traced. )
|
||||
|
||||
<a name="page80">page 80</a>
|
||||
|
||||
## APPENDIX E : OVERLORD - THE MONITOR
|
||||
|
||||
Overlord is the monitor of the LISP System. It controls the handling of tapes, the
|
||||
|
@ -3799,8 +3773,6 @@ card columns to use are as follows.
|
|||
|
||||
address data word
|
||||
|
||||
<a name="page81">page 81</a>
|
||||
|
||||
Overlord cards have the Overlord direction beginning in column 8. If the card has
|
||||
no other field, then comments may begin in column 16. Otherwise, the other fields of
|
||||
the card begin in column 16 and are separated by commas. The comments may begin
|
||||
|
@ -3861,8 +3833,6 @@ Causes the computer to halt. An end of file mark is written on SYSPOT. An end
|
|||
of file is written on SYSPPT only if it has been used. If the FIN card was read on-line,
|
||||
the computer halts after doing these things. If the FIN card came from SYSPIT, then
|
||||
|
||||
<a name="page82">page 82</a>
|
||||
|
||||
SYSPIT is advanced past the next end of file mark before the halt occurs.
|
||||
|
||||
Use of Sense Switches
|
||||
|
@ -3886,8 +3856,6 @@ become a system tape containing the basic system plus any changes that have been
|
|||
onto it. It may be mounted on the SYSTAP drive for some future run to use definitions
|
||||
that have been set onto it.
|
||||
|
||||
<a name="page83">page 83</a>
|
||||
|
||||
## APPENDIX F : LISP INPUT AND OUTPUT
|
||||
|
||||
This appendix describes the LISP read and write programs and the character-
|
||||
|
@ -3929,8 +3897,6 @@ b. The first two characters must not be $ $.
|
|||
c. It must be delimited on either side by a character from class C.
|
||||
There is a provision for reading in atomic symbols containing arbitrary characters.
|
||||
|
||||
<a name="page84">page 84</a>
|
||||
|
||||
This is done by punching the form $$dsd, where s is any string of up to 30 characters,
|
||||
and d is any character not contained in the string s. Only the string s is used in
|
||||
forming the print name of the atomic symbol; d and the dollar signs will not appear when
|
||||
|
@ -3974,9 +3940,6 @@ to Z. Each letter is a legitimate atomic symbol, and therefore may be referred t
|
|||
a straightforward way, without ambiguity.
|
||||
The second group of legal characters consists of the digits from 0 to 9. These
|
||||
must be handled with some care because if a digit is considered as an ordinary integer
|
||||
|
||||
<a name="page85">page 85</a>
|
||||
|
||||
rather than a character a new nonunique object will be created corresponding to it, and
|
||||
this object will not be the same as the character object for the same digit, even though
|
||||
it has the same print name. Since the character-handling programs depend on the char-
|
||||
|
@ -4029,8 +3992,6 @@ Examples
|
|||
EVAL (DOLLAR NIL) value is " $
|
||||
EVAL ((PRINT PERIOD) NIL) value is ". and If. is also printed.
|
||||
|
||||
<a name="page86">page 86</a>
|
||||
|
||||
The remaining characters are all illegal as far as the key punch is concerned. The
|
||||
two characters corresponding to 12 and 72 have been reserved for end-of-file and end-
|
||||
of-record, respectively, The end-of-file character has print name $EOF$ and the end-
|
||||
|
@ -4075,8 +4036,6 @@ whose print name is in BOFFO.
|
|||
sented by the sequence of characters in BOFFO. (Positive decimal integers from
|
||||
0 to 9 are converted so as to point to the corresponding character object. )
|
||||
|
||||
<a name="page87">page 87</a>
|
||||
|
||||
5. unpack [x]: SUBR pseudo-function
|
||||
This function has as argument a pointer to a full word. unpack considers
|
||||
the full word to be a set of 6 BCD characters, and has as value a list of these
|
||||
|
@ -4115,10 +4074,9 @@ an object). There is also an object CHARCOUNT whose value is an integer object g
|
|||
the column just read on the card, i. e., the column number of the character given by
|
||||
CURCHAR. There are three functions which affect the value of CURCHAR:
|
||||
|
||||
#### 1. startread [ ] : SUBR ps eudo-function
|
||||
startread is a function of no arguments which causes a new card to be read. The value of startread is the first character on that card, or more precisely,
|
||||
|
||||
<a name="page88">page 88</a>
|
||||
1. startread [ 1: : SUBR ps eudo-function
|
||||
startread is a function of no arguments which causes a new card to be read.
|
||||
The value of startread is the first character on that card, or more precisely,
|
||||
|
||||
the object corresponding to the first character on the card. If an end-of-file
|
||||
condition exists, the value of startread is $EOF$. The value of CURCHAR
|
||||
|
@ -4127,30 +4085,35 @@ becomes 1. Both CURCHAR and CHARCOUNT are undefined until a startread
|
|||
is performed. A startread may be performed before the current card has been
|
||||
completely read.
|
||||
|
||||
#### 2. advance [ ] : SUBR pseudo -function
|
||||
2. advance [ 1: SUBR pseudo -function
|
||||
advance is a function of no arguments which causes the next character to be
|
||||
read. The value of advance is that character. After the 72nd character on the
|
||||
card has been read, the next advance will have value $EOR$. After reading
|
||||
$EOR$, the next advance will act like a startread, i. e., will read the first char-
|
||||
acter of the next card unless an end-of-file condition exists. The new value of
|
||||
CURCHAR is the same as the output of advance; executing advance also increases
|
||||
the value of CHARCOUNT by 1. However, CHARCOUNT is undefined when
|
||||
CURCHAR is either $EOR $ or $EOF $.
|
||||
3. endread [ 1: SUBR pseudo-function
|
||||
endread is a function of no arguments which causes the remainder of the
|
||||
card to be read and ignored. endread sets CURCHAR to $EOR$ and leaves
|
||||
CHARCOUNT undefined; the value of endread is always $EOR $. An advance
|
||||
following endread acts like a startread. If CURCHAR already has value $EOR $
|
||||
and endread is performed, CURCHAR will remain the same and endread will,
|
||||
as usual, have value $EOR $.
|
||||
|
||||
advance is a function of no arguments which causes the next character to be read. The value of advance is that character. After the 72nd character on the card has been read, the next advance will have value $EOR$. After reading $EOR$, the next advance will act like a startread, i. e., will read the first char acter of the next card unless an end-of-file condition exists. The new value of CURCHAR is the same as the output of advance; executing advance also increases the value of CHARCOUNT by 1. However, CHARCOUNT is undefined when CURCHAR is either $EOR $ or $EOF $.
|
||||
|
||||
#### 3. endread [ ] : SUBR pseudo-function
|
||||
Diagnostic Function
|
||||
|
||||
endread is a function of no arguments which causes the remainder of the card to be read and ignored. endread sets CURCHAR to $EOR$ and leaves CHARCOUNT undefined; the value of endread is always $EOR $. An advance following endread acts like a startread. If CURCHAR already has value $EOR $ and endread is performed, CURCHAR will remain the same and endread will, as usual, have value $EOR $.
|
||||
|
||||
### Diagnostic Function
|
||||
|
||||
#### error 1 [ ]: SUBR pseudo-function
|
||||
|
||||
error1 is a function of no arguments and has value NIL. It should be executed
|
||||
error 1 [ 1: SUBR pseudo-function
|
||||
errorL is a function of no arguments and has value NIL. It should be executed
|
||||
only while reading characters from a card (or tape). Its effect is to mark the char-
|
||||
acter just read, i. e., CURCHAR, so that when the end of the card is reached, either
|
||||
by successive advances or by an endread, the entire card is printed out along with
|
||||
a visual pointer to the defective character. For a line consisting of ABCDEFG fol-
|
||||
lowed by blanks, a pointer to C would look like this:
|
||||
|
||||
```
|
||||
v
|
||||
v
|
||||
ABCDEFG
|
||||
A
|
||||
```
|
||||
A
|
||||
If error 1 is performed an even number of times on the same character, the A will
|
||||
not appear. If error1 is performed before the first startread or while CURCHAR
|
||||
has value $EOR $ or $EOF $, it will have no effect. Executing a startread before
|
||||
|
@ -4159,27 +4122,28 @@ card is considered to have been completed when CURCHAR has been set to $EOR$.
|
|||
Successive endreads will cause the error l printout to be reprinted. Any number
|
||||
of characters in a given line may be marked by error1.
|
||||
|
||||
<a name="page89">page 89</a>
|
||||
|
||||
## APPENDIX G : MEMORY ALLOCATION AND THE GARBAGE COLLECTOR
|
||||
|
||||
The following diagram shows the way in which space is allocated in the LISP System.
|
||||
|
||||
| Address (octal) | Assigned to |
|
||||
| --------------- | ------------------------------------------------------------ |
|
||||
| 77777 | ----- |
|
||||
| | Loader |
|
||||
| 77600 | ----- |
|
||||
| | LAP |
|
||||
| | Compiler |
|
||||
| 70000 | ----- |
|
||||
| | Free storage |
|
||||
| | Full words |
|
||||
| | Pushdown list |
|
||||
| | Binary program space |
|
||||
| 17000 | |
|
||||
| | Interpreter, I/O, Read Print, Arithmetic, Overlord, Garbage Collector, and other system coding |
|
||||
| 00000 | |
|
||||
Loader
|
||||
LAP
|
||||
|
||||
Compiler
|
||||
|
||||
Free Storage
|
||||
|
||||
Full Words
|
||||
|
||||
Push-Down List
|
||||
|
||||
Binary Program Space
|
||||
|
||||
Interpreter, I/O, Read
|
||||
Print, Arithmetic,
|
||||
Overlord, Garbage
|
||||
Collector, and other
|
||||
system coding
|
||||
|
||||
The addresses in this chart are only approximate. The available space is divided
|
||||
among binary program space, push-down list, full-word space, and free-storage space
|
||||
|
@ -4195,9 +4159,6 @@ FEXPR1s, evalquote doublets waiting to be executed, APVALts, and partial results
|
|||
the computation that is in progress.
|
||||
|
||||
Full-word space is filled with the BCD characters of PNAMEts, the actual numbers
|
||||
|
||||
<a name="page90">page 90</a>
|
||||
|
||||
of numerical atomic structures, and the TXL words of SUBRtsB FSUBRts, and SYMts.
|
||||
All available words in the free-storage area that are not in use are strung together
|
||||
in one long list called the free-storage list. Every time a word is needed (for example,
|
||||
|
@ -4232,8 +4193,6 @@ can be recognized by the stationary pattern of the MQ lights. Any trap that prev
|
|||
completion of a garbage collection will create a panic condition in memory from which
|
||||
there is no recovery.
|
||||
|
||||
<a name="page91">page 91</a>
|
||||
|
||||
## APPENDIX H : RECURSION AND THE PUSH-DOWN LIST
|
||||
|
||||
One of the most powerful resources of the LISP language is its ability to accept
|
||||
|
@ -4280,9 +4239,6 @@ ter 1, to place the arguments on the push-down list, and to set up the parameter
|
|||
the push-down block.
|
||||
|
||||
Because pointers to list structures are normally stored on the push-down list, the
|
||||
|
||||
<a name="page92">page 92</a>
|
||||
|
||||
garbage collector must mark the currently active portion of the push-down list during a
|
||||
garbage collection. Sometimes quantities are placed on the push- down list which should
|
||||
not be marked. In this case, the sign bit must be negative. Cells on the active portion
|
||||
|
@ -4294,8 +4250,6 @@ list has the name of the function to which it belongs, it is possible to form a
|
|||
these names. This is called the backtrace, and is normally printed out after error
|
||||
diagnostics.
|
||||
|
||||
<a name="page93">page 93</a>
|
||||
|
||||
## APPENDIX I : LISP FOR SHARE DISTRIBUTION
|
||||
|
||||
The Artificial Intelligence Project at Stanford University has produced a version of
|
||||
|
@ -4340,8 +4294,6 @@ the time spent in the packet being finished. This time printout, to be meaningfu
|
|||
requires the computer to have a millisecond clock in cell 5 (RPQ F 89349, with mil-
|
||||
lisecond feature).
|
||||
|
||||
<a name="page94">page 94</a>
|
||||
|
||||
It is also possible to determine how much time is required to execute a given func-
|
||||
tion. llTIMEl()lt initializes two time cells to zero and prints out, in the same format
|
||||
that is used for the evalquote time printout, two times, and these are both zero.
|
||||
|
@ -4386,9 +4338,6 @@ after x number of function entrances. Furthermore, when the tracecount mecha-
|
|||
nism has been activated, by execution of ltTRACECOUNT(x)ll, some of the blank
|
||||
space in the garbage collector printout will be used to output the number of function
|
||||
entrances which have taken place up to the time of the garbage collection; each time
|
||||
|
||||
<a name="page95">page 95</a>
|
||||
|
||||
the arguments or value of a traced function are printed the number of function en-
|
||||
trances will be printed; and if an error occurs, the number of function entrances ac-
|
||||
complished before the error will be printed.
|
||||
|
@ -4435,9 +4384,6 @@ of LISP to communicate between different systems. The functions tape, -- rewind,
|
|||
ttTAPE(s)tt, where s is a list, allows the user to specify up to ten scratch tapes;
|
||||
if more than ten are specified, only the first ten are used. The value of tape is its
|
||||
argument. The initial tape settings are, from one to ten, A4, A5, A6, A7, A8, B2,
|
||||
|
||||
<a name="page96">page 96</a>
|
||||
|
||||
B3, B4, B5, B6. The tapes must be specified by the octal number that occurs in the
|
||||
address portion of a machine-language instruction to rewind that tape; that is, a four-
|
||||
digit octal number is required - the first (high-order) digit is a 1 if channel A is de-
|
||||
|
@ -4483,8 +4429,6 @@ Evalquote is available to the programmer as a LISP function - thus, one may now
|
|||
write I1(EVALQUOTE APPEND ((A)(B C D)))I1, rather than "(EVAL (QUOTE (APPEND
|
||||
(A)(B C D))) NIL)", should one desire to do so.
|
||||
|
||||
<a name="page97">page 97</a>
|
||||
|
||||
### Backtrace
|
||||
|
||||
This function was copied (not quite literally) from M. I. T.'s LISP system on the
|
||||
|
@ -4533,9 +4477,6 @@ defined results.
|
|||
|
||||
For the convenience of those who find it difficult to get along with the tlCONDn form
|
||||
of the conditional statement, the following "IF" forms are provided in the new system.
|
||||
|
||||
<a name="page98">page 98</a>
|
||||
|
||||
"IF (a THEN b ELSE c)I1 and "IF (a b c)I1 are equivalent to nCOND ((a b)(T c))". "IF
|
||||
(a THEN b)n and "IF (a b)" are equivalent to "COND ((a b))".
|
||||
|
||||
|
@ -4577,8 +4518,6 @@ Characteristics of the System
|
|||
The set-up deck supplied with the SHARE LISP system produces a system tape
|
||||
with the following properties:
|
||||
|
||||
<a name="page99">page 99</a>
|
||||
|
||||
Size (in words) -
|
||||
Binary Program Space 14000 octal
|
||||
Push-Down List 5000 octal
|
||||
|
@ -4600,9 +4539,7 @@ SW5 on to suppress SYSPOT output
|
|||
SW6 on to return to overlord after accumulator printout resulting from
|
||||
error *I? 5*. SW6 off for error printout.
|
||||
|
||||
<a name="page100">page 100</a>
|
||||
|
||||
## Index to function descriptions
|
||||
## Index
|
||||
|
||||
| Function | Call type | Implementation | Pages |
|
||||
|--------------|------------|------------------|------------------------------|
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# The properties of the system, and their values
|
||||
|
||||
## here be dragons
|
||||
# The properties of the system, and their values: here be dragons
|
||||
|
||||
Lisp is the list processing language; that is what its name means. It processes data structures built of lists - which may be lists of lists, or lists of numbers, or lists of any other sort of data item provided for by the designers of the system.
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -11,394 +11,238 @@
|
|||
002 "Essentially, the `-main` function and the bootstrap read-eval-print loop."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
003 (:require [beowulf.bootstrap :refer [EVAL]]
|
||||
003 (:require [beowulf.bootstrap :refer [EVAL oblist *options*]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
004 [beowulf.io :refer [default-sysout SYSIN]]
|
||||
004 [beowulf.read :refer [READ]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
005 [beowulf.oblist :refer [*options* NIL]]
|
||||
005 [clojure.java.io :as io]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
006 [beowulf.read :refer [READ read-from-console]]
|
||||
006 [clojure.pprint :refer [pprint]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
007 [clojure.java.io :as io]
|
||||
007 [clojure.tools.cli :refer [parse-opts]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
008 [clojure.pprint :refer [pprint]]
|
||||
008 [environ.core :refer [env]])
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
009 [clojure.string :refer [trim]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
010 [clojure.tools.cli :refer [parse-opts]])
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
011 (:gen-class))
|
||||
009 (:gen-class))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
012
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
013 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
014 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
015 ;;; Copyright (C) 2022-2023 Simon Brooke
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
016 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
017 ;;; This program is free software; you can redistribute it and/or
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
018 ;;; modify it under the terms of the GNU General Public License
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
019 ;;; as published by the Free Software Foundation; either version 2
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
020 ;;; of the License, or (at your option) any later version.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
021 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
022 ;;; This program is distributed in the hope that it will be useful,
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
023 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
024 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
025 ;;; GNU General Public License for more details.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
026 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
027 ;;; You should have received a copy of the GNU General Public License
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
028 ;;; along with this program; if not, write to the Free Software
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
029 ;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
030 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
031 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
032
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
033 (def stop-word
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
034 "The word which, if submitted an an input line, will cause Beowulf to quit.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
035 Question: should this be `forlǣte`?"
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
036 "STOP")
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
037
|
||||
010
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
038 (def cli-options
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
039 [["-f FILEPATH" "--file-path FILEPATH"
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
040 "Set the path to the directory for reading and writing Lisp files."
|
||||
</span><br/>
|
||||
<span class="partial" title="3 out of 20 forms covered">
|
||||
041 :validate [#(and (.exists (io/file %))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
042 (.isDirectory (io/file %))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
043 (.canRead (io/file %))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
044 (.canWrite (io/file %)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
045 "File path must exist and must be a directory."]]
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
046 ["-h" "--help"]
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
047 ["-p PROMPT" "--prompt PROMPT" "Set the REPL prompt to PROMPT"
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
048 :default "Sprecan::"]
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
049 ["-r SYSOUTFILE" "--read SYSOUTFILE" "Read Lisp system from file SYSOUTFILE"
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
050 :default default-sysout
|
||||
</span><br/>
|
||||
<span class="partial" title="3 out of 8 forms covered">
|
||||
051 :validate [#(and
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
052 (.exists (io/file %))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
053 (.canRead (io/file %)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
054 "Could not find sysout file"]]
|
||||
011 (def cli-options
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
055 ["-s" "--strict" "Strictly interpret the Lisp 1.5 language, without extensions."]
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
056 ["-t" "--time" "Time evaluations."]])
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
057
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
058 (defn- re
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
059 "Like REPL, but it isn't a loop and doesn't print."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
060 [input]
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
061 (EVAL (READ input) NIL 0))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
062
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
063 (defn repl
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
064 "Read/eval/print loop."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
065 [prompt]
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
066 (loop []
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
067 (print prompt)
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
068 (flush)
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
069 (try
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
070 (if-let [input (trim (read-from-console))]
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
071 (if (= input stop-word)
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
072 (throw (ex-info "\nFærwell!" {:cause :quit}))
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
073 (println
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
074 (str "> "
|
||||
012 [["-h" "--help"]
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
075 (print-str (if (:time *options*)
|
||||
013 ["-p PROMPT" "--prompt PROMPT" "Set the REPL prompt to PROMPT"
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 18 forms covered">
|
||||
076 (time (re input))
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
014 :default "Sprecan::"]
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
015 ["-r INITFILE" "--read INITFILE" "Read Lisp functions from the file INITFILE"
|
||||
</span><br/>
|
||||
<span class="covered" title="8 out of 8 forms covered">
|
||||
016 :validate [#(and
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
017 (.exists (io/file %))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
018 (.canRead (io/file %)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
019 "Could not find initfile"]]
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
020 ["-s" "--strict" "Strictly interpret the Lisp 1.5 language, without extensions."]
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
021 ["-t" "--trace" "Trace Lisp evaluation."]])
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
022
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
023 (defn repl
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
024 "Read/eval/print loop."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
025 [prompt]
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
026 (loop []
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
077 (re input))))))
|
||||
027 (print prompt)
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
028 (flush)
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
029 (try
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
030 (let [input (read-line)]
|
||||
</span><br/>
|
||||
<span class="partial" title="2 out of 3 forms covered">
|
||||
031 (cond
|
||||
</span><br/>
|
||||
<span class="covered" title="11 out of 11 forms covered">
|
||||
032 (= input "quit") (throw (ex-info "\nFærwell!" {:cause :quit}))
|
||||
</span><br/>
|
||||
<span class="covered" title="16 out of 16 forms covered">
|
||||
033 input (println (str "> " (print-str (EVAL (READ input) @oblist))))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
078 (println))
|
||||
034 :else (println)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
079 (catch
|
||||
035 (catch
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
080 Exception
|
||||
036 Exception
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
081 e
|
||||
037 e
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
082 (let [data (ex-data e)]
|
||||
038 (let [data (ex-data e)]
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
083 (println (.getMessage e))
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
084 (when
|
||||
039 (println (.getMessage e))
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
085 data
|
||||
040 (if
|
||||
</span><br/>
|
||||
<span class="partial" title="5 out of 6 forms covered">
|
||||
086 (case (:cause data)
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
041 data
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
042 (case (:cause data)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
087 :parse-failure (println (:failure data))
|
||||
043 :parse-failure (println (:failure data))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
088 :strict nil ;; the message, which has already been printed, is enough.
|
||||
044 :strict nil ;; the message, which has already been printed, is enough.
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
089 :quit (throw e)
|
||||
045 :quit (throw e)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
090 ;; default
|
||||
046 ;; default
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
091 (pprint data))))))
|
||||
047 (pprint data))))))
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
092 (recur)))
|
||||
048 (recur)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
093
|
||||
049
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
094 (defn -main
|
||||
050 (defn -main
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
095 "Parse options, print the banner, read the init file if any, and enter the
|
||||
051 "Parse options, print the banner, read the init file if any, and enter the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
096 read/eval/print loop."
|
||||
052 read/eval/print loop."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
097 [& opts]
|
||||
053 [& opts]
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
098 (let [args (parse-opts opts cli-options)]
|
||||
054 (let [args (parse-opts opts cli-options)]
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
099 (println
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
100 (str
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
101 "\nHider wilcuman. Béowulf is mín nama.\n"
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
102 (when
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
103 (System/getProperty "beowulf.version")
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
104 (str "Síðe " (System/getProperty "beowulf.version") "\n"))
|
||||
</span><br/>
|
||||
<span class="partial" title="1 out of 2 forms covered">
|
||||
105 (when
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
106 (:help (:options args))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
107 (:summary args))
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
108 (when (:errors args)
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
109 (apply str (interpose "; " (:errors args))))
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
110 "\nSprecan '" stop-word "' tó laéfan\n"))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
111
|
||||
</span><br/>
|
||||
<span class="covered" title="12 out of 12 forms covered">
|
||||
112 (binding [*options* (:options args)]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
113 ;; (pprint *options*)
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
114 (when (:read *options*)
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
115 (try (SYSIN (:read *options*))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
116 (catch Throwable any
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
117 (println any))))
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
118 (try
|
||||
</span><br/>
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
119 (repl (str (:prompt (:options args)) " "))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
120 (catch
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
121 Exception
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
122 e
|
||||
055 (println
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
123 (let [data (ex-data e)]
|
||||
056 (str
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
057 "\nHider wilcuman. Béowulf is mín nama.\n"
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
124 (if
|
||||
058 (if
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
125 data
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
059 (System/getProperty "beowulf.version")
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
126 (case (:cause data)
|
||||
060 (str "Síðe " (System/getProperty "beowulf.version") "\n"))
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
061 (if
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
062 (:help (:options args))
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
063 (:summary args))
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
064 (if (:errors args)
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
065 (apply str (interpose "; " (:errors args))))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
127 :quit nil
|
||||
066 "\nSprecan 'quit' tó laéfan\n"))
|
||||
</span><br/>
|
||||
<span class="covered" title="12 out of 12 forms covered">
|
||||
067 (binding [*options* (:options args)]
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
068 (try
|
||||
</span><br/>
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
069 (repl (str (:prompt (:options args)) " "))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
128 ;; default
|
||||
070 (catch
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
129 (do
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
071 Exception
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
130 (println "STÆFLEAHTER: " (.getMessage e))
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
072 e
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
073 (let [data (ex-data e)]
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
074 (if
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
075 data
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
076 (case (:cause data)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
077 :quit nil
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
078 ;; default
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
131 (pprint data)))
|
||||
079 (pprint data))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
132 (println e))))))))
|
||||
080 (println e))))))))
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,395 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<link rel="stylesheet" href="../coverage.css"/> <title> beowulf/interop.clj </title>
|
||||
</head>
|
||||
<body>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
001 (ns beowulf.interop
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
002 (:require [beowulf.cons-cell :refer [make-beowulf-list]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
003 [beowulf.host :refer [CAR CDR]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
004 [beowulf.oblist :refer [*options* NIL]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
005 [clojure.string :as s :refer [last-index-of lower-case split
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
006 upper-case]]))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
007
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
008 ;;;; INTEROP feature ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
009
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
010 (defn listify-qualified-name
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
011 "We need to be able to print something we can link to the particular Clojure
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
012 function `subr` in a form in which Lisp 1.5 is able to read it back in and
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
013 relink it.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
014
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
015 This assumes `subr` is either
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
016 1. a string in the format `#'beowulf.io/SYSIN` or `beowulf.io/SYSIN`; or
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
017 2. something which, when coerced to a string with `str`, will have such
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
018 a format."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
019 [subr]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
020 (make-beowulf-list
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
021 (map
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
022 #(symbol (upper-case %))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 9 forms covered">
|
||||
023 (remove empty? (split (str subr) #"[#'./]")))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
024
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
025
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
026 (defn interpret-qualified-name
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
027 "For interoperation with Clojure, it will often be necessary to pass
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
028 qualified names that are not representable in Lisp 1.5. This function
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
029 takes a sequence in the form `(PART PART PART... NAME)` and returns
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
030 a symbol in the form `part.part.part/NAME`. This symbol will then be
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
031 tried in both that form and lower-cased. Names with hyphens or
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
032 underscores cannot be represented with this scheme."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
033 ([l]
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
034 (symbol
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
035 (let [n (s/join "."
|
||||
</span><br/>
|
||||
<span class="covered" title="13 out of 13 forms covered">
|
||||
036 (concat (map #(lower-case (str %)) (butlast l))
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
037 (list (last l))))
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
038 s (last-index-of n ".")]
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
039 (if s
|
||||
</span><br/>
|
||||
<span class="covered" title="13 out of 13 forms covered">
|
||||
040 (str (subs n 0 s) "/" (subs n (inc s)))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
041 n)))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
042
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
043 (defn to-beowulf
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
044 "Return a beowulf-native representation of the Clojure object `o`.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
045 Numbers and symbols are unaffected. Collections have to be converted;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
046 strings must be converted to symbols."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
047 [o]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
048 (cond
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
049 (coll? o) (make-beowulf-list o)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 8 forms covered">
|
||||
050 (string? o) (symbol (s/upper-case o))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
051 :else o))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
052
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
053 (defn to-clojure
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
054 "If l is a `beowulf.cons_cell.ConsCell`, return a Clojure list having the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
055 same members in the same order."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
056 [l]
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
057 (cond
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
058 (not (instance? beowulf.cons_cell.ConsCell l))
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
059 l
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
060 (= (CDR l) NIL)
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
061 (list (to-clojure (CAR l)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
062 :else
|
||||
</span><br/>
|
||||
<span class="covered" title="12 out of 12 forms covered">
|
||||
063 (conj (to-clojure (CDR l)) (to-clojure (CAR l)))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
064
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
065 (defn INTEROP
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
066 "Clojure (or other host environment) interoperation API. `fn-symbol` is expected
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
067 to be either
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
068
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
069 1. a symbol bound in the host environment to a function; or
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
070 2. a sequence (list) of symbols forming a qualified path name bound to a
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
071 function.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
072
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
073 Lower case characters cannot normally be represented in Lisp 1.5, so both the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
074 upper case and lower case variants of `fn-symbol` will be tried. If the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
075 function you're looking for has a mixed case name, that is not currently
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
076 accessible.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
077
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
078 `args` is expected to be a Lisp 1.5 list of arguments to be passed to that
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
079 function. Return value must be something acceptable to Lisp 1.5, so either
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
080 a symbol, a number, or a Lisp 1.5 list.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
081
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
082 If `fn-symbol` is not found (even when cast to lower case), or is not a function,
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
083 or the value returned cannot be represented in Lisp 1.5, an exception is thrown
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
084 with `:cause` bound to `:interop` and `:detail` set to a value representing the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
085 actual problem."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
086 [fn-symbol args]
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
087 (if-not (:strict *options*)
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
088 (let
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
089 [q-name (if
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
090 (seq? fn-symbol)
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
091 (interpret-qualified-name fn-symbol)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
092 fn-symbol)
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
093 l-name (symbol (s/lower-case q-name))
|
||||
</span><br/>
|
||||
<span class="partial" title="1 out of 3 forms covered">
|
||||
094 f (cond
|
||||
</span><br/>
|
||||
<span class="partial" title="1 out of 2 forms covered">
|
||||
095 (try
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
096 (fn? (eval l-name))
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
097 (catch java.lang.ClassNotFoundException _ nil)) l-name
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
098 (try
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
099 (fn? (eval q-name))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
100 (catch java.lang.ClassNotFoundException _ nil)) q-name
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
101 :else (throw
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
102 (ex-info
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
103 (str "INTEROP: ungecnáwen þegnung `" fn-symbol "`")
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 7 forms covered">
|
||||
104 {:cause :interop
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
105 :detail :not-found
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
106 :name fn-symbol
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
107 :also-tried l-name})))
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
108 args' (to-clojure args)]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
109 ;; (print (str "INTEROP: eahtiende `" (cons f args') "`"))
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
110 (flush)
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
111 (let [result (eval (conj args' f))] ;; this has the potential to blow up the world
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
112 ;; (println (str "; ágiefende `" result "`"))
|
||||
</span><br/>
|
||||
<span class="partial" title="4 out of 6 forms covered">
|
||||
113 (cond
|
||||
</span><br/>
|
||||
<span class="partial" title="4 out of 5 forms covered">
|
||||
114 (instance? beowulf.cons_cell.ConsCell result) result
|
||||
</span><br/>
|
||||
<span class="partial" title="3 out of 6 forms covered">
|
||||
115 (coll? result) (make-beowulf-list result)
|
||||
</span><br/>
|
||||
<span class="partial" title="3 out of 4 forms covered">
|
||||
116 (symbol? result) result
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
117 (string? result) (symbol result)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
118 (number? result) result
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
119 :else (throw
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
120 (ex-info
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
121 (str "INTEROP: Ne can eahtiende `" result "` to Lisp 1.5.")
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
122 {:cause :interop
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
123 :detail :not-representable
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
124 :result result})))))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
125 (throw
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
126 (ex-info
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
127 (str "INTEROP ne āfand innan Lisp 1.5.")
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
128 {:cause :interop
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
129 :detail :strict}))))
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
|
@ -1,521 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<link rel="stylesheet" href="../coverage.css"/> <title> beowulf/io.clj </title>
|
||||
</head>
|
||||
<body>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
001 (ns beowulf.io
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
002 "Non-standard extensions to Lisp 1.5 to read and write to the filesystem.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
003
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
004 Lisp 1.5 had only `READ`, which read one S-Expression at a time, and
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
005 various forms of `PRIN*` functions, which printed to the line printer.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
006 There was also `PUNCH`, which wrote to a card punch. It does not seem
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
007 that there was any concept of an interactive terminal.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
008
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
009 See Appendix E, `OVERLORD - THE MONITOR`, and Appendix F, `LISP INPUT
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
010 AND OUTPUT`.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
011
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
012 For our purposes, to save the current state of the Lisp system it should
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
013 be sufficient to print the current contents of the oblist to file; and to
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
014 restore a previous state from file, to overwrite the contents of the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
015 oblist with data from that file.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
016
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
017 Hence functions SYSOUT and SYSIN, which do just that."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
018 (:require [beowulf.cons-cell :refer [make-beowulf-list make-cons-cell
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
019 pretty-print]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
020 [beowulf.host :refer [CADR CAR CDDR CDR]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
021 [beowulf.interop :refer [interpret-qualified-name
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
022 listify-qualified-name]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
023 [beowulf.oblist :refer [*options* NIL oblist]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
024 [beowulf.read :refer [READ]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
025 [clojure.java.io :refer [file resource]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
026 [clojure.string :refer [ends-with?]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
027 [java-time.api :refer [local-date local-date-time]]))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
028
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
029 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
030 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
031 ;;; Copyright (C) 2022-2023 Simon Brooke
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
032 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
033 ;;; This program is free software; you can redistribute it and/or
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
034 ;;; modify it under the terms of the GNU General Public License
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
035 ;;; as published by the Free Software Foundation; either version 2
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
036 ;;; of the License, or (at your option) any later version.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
037 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
038 ;;; This program is distributed in the hope that it will be useful,
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
039 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
040 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
041 ;;; GNU General Public License for more details.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
042 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
043 ;;; You should have received a copy of the GNU General Public License
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
044 ;;; along with this program; if not, write to the Free Software
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
045 ;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
046 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
047 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
048
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
049 (def ^:constant default-sysout "lisp1.5.lsp")
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
050
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
051 (defn- full-path
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
052 [fp]
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
053 (str
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
054 (if (:filepath *options*)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
055 (str (:filepath *options*) (java.io.File/separator))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
056 "")
|
||||
</span><br/>
|
||||
<span class="partial" title="12 out of 14 forms covered">
|
||||
057 (if (and (string? fp)
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
058 (> (count fp) 0)
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
059 (not= fp "NIL"))
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
060 fp
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
061 (str "Sysout-" (local-date)))
|
||||
</span><br/>
|
||||
<span class="partial" title="6 out of 7 forms covered">
|
||||
062 (if (ends-with? fp ".lsp")
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
063 ""
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
064 ".lsp")))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
065
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
066 ;; (find-var (symbol "beowulf.io/SYSIN"))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
067 ;; (@(resolve (symbol "beowulf.host/TIMES")) 2 2)
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
068
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
069 (defn safely-wrap-subr
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
070 [entry]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 7 forms covered">
|
||||
071 (cond (= entry NIL) NIL
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 7 forms covered">
|
||||
072 (= (CAR entry) 'SUBR) (make-cons-cell
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
073 (CAR entry)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
074 (make-cons-cell
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
075 (listify-qualified-name (CADR entry))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
076 (CDDR entry)))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
077 :else (make-cons-cell
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 8 forms covered">
|
||||
078 (CAR entry) (safely-wrap-subr (CDR entry)))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
079
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
080 (defn safely-wrap-subrs
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
081 [objects]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
082 (make-beowulf-list (map safely-wrap-subr objects)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
083
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
084 (defn SYSOUT
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
085 "Dump the current content of the object list to file. If no `filepath` is
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
086 specified, a file name will be constructed of the symbol `Sysout` and
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
087 the current date. File paths will be considered relative to the filepath
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
088 set when starting Lisp.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
089
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
090 **NOTE THAT** this is an extension function, not available in strct mode."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
091 ([]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
092 (SYSOUT nil))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
093 ([filepath]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 7 forms covered">
|
||||
094 (spit (full-path (str filepath))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 15 forms covered">
|
||||
095 (with-out-str
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 9 forms covered">
|
||||
096 (println (apply str (repeat 79 ";")))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
097 (println (format ";; Beowulf %s Sysout file generated at %s"
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 7 forms covered">
|
||||
098 (or (System/getProperty "beowulf.version") "")
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
099 (local-date-time)))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
100 (when (System/getenv "USER")
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 7 forms covered">
|
||||
101 (println (format ";; generated by %s" (System/getenv "USER"))))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 9 forms covered">
|
||||
102 (println (apply str (repeat 79 ";")))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
103 (println)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
104 (let [output (safely-wrap-subrs @oblist)]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
105 (pretty-print output)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
106 )))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
107
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
108 (defn resolve-subr
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
109 "If this oblist `entry` references a subroutine, attempt to fix up that
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
110 reference."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
111 ([entry]
|
||||
</span><br/>
|
||||
<span class="partial" title="9 out of 12 forms covered">
|
||||
112 (or (resolve-subr entry 'SUBR)
|
||||
</span><br/>
|
||||
<span class="partial" title="1 out of 6 forms covered">
|
||||
113 (resolve-subr entry 'FSUBR)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
114 ([entry prop]
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
115 (cond (= entry NIL) NIL
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
116 (= (CAR entry) prop) (try
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
117 (make-cons-cell
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
118 (CAR entry)
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
119 (make-cons-cell
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
120 (interpret-qualified-name
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
121 (CADR entry))
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
122 (CDDR entry)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
123 (catch Exception _
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
124 (print "Warnung: ne can āfinde "
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
125 (CADR entry))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
126 (CDDR entry)))
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
127 :else (make-cons-cell
|
||||
</span><br/>
|
||||
<span class="covered" title="8 out of 8 forms covered">
|
||||
128 (CAR entry) (resolve-subr (CDR entry))))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
129
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
130
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
131 (defn- resolve-subroutines
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
132 "Attempt to fix up the references to subroutines (Clojure functions) among
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
133 these `objects`, being new content for the object list."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
134 [objects]
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
135 (make-beowulf-list
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
136 (map
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
137 resolve-subr
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
138 objects)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
139
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
140 (defn SYSIN
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
141 "Read the contents of the file at this `filename` into the object list.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
142
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
143 If the file is not a valid Beowulf sysout file, this will probably
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
144 corrupt the system, you have been warned. File paths will be considered
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
145 relative to the filepath set when starting Lisp.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
146
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
147 It is intended that sysout files can be read both from resources within
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
148 the jar file, and from the file system. If a named file exists in both the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
149 file system and the resources, the file system will be preferred.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
150
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
151 **NOTE THAT** if the provided `filename` does not end with `.lsp` (which,
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
152 if you're writing it from the Lisp REPL, it won't), the extension `.lsp`
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
153 will be appended.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
154
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
155 **NOTE THAT** this is an extension function, not available in strct mode."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
156 ([]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 13 forms covered">
|
||||
157 (SYSIN (or (:read *options*) (str "resources/" default-sysout))))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
158 ([filename]
|
||||
</span><br/>
|
||||
<span class="covered" title="8 out of 8 forms covered">
|
||||
159 (let [fp (file (full-path (str filename)))
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
160 file (when (and (.exists fp) (.canRead fp)) fp)
|
||||
</span><br/>
|
||||
<span class="partial" title="4 out of 5 forms covered">
|
||||
161 res (try (resource filename)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
162 (catch Throwable _ nil))
|
||||
</span><br/>
|
||||
<span class="covered" title="11 out of 11 forms covered">
|
||||
163 content (try (READ (slurp (or file res)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
164 (catch Throwable _
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
165 (throw (ex-info "Ne can ārǣde"
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
166 {:context "SYSIN"
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
167 :filename filename
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
168 :filepath fp}))))]
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
169 (swap! oblist
|
||||
</span><br/>
|
||||
<span class="partial" title="7 out of 10 forms covered">
|
||||
170 #(when (or % (seq content))
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
171 (resolve-subroutines content))))))
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because it is too large
Load diff
|
@ -1,143 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<link rel="stylesheet" href="../coverage.css"/> <title> beowulf/oblist.clj </title>
|
||||
</head>
|
||||
<body>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
001 (ns beowulf.oblist
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
002 "A namespace mainly devoted to the object list and other top level
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
003 global variables.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
004
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
005 Yes, this makes little sense, but if you put them anywhere else you end
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
006 up in cyclic dependency hell."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
007 )
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
008
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
009 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
010 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
011 ;;; Copyright (C) 2022-2023 Simon Brooke
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
012 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
013 ;;; This program is free software; you can redistribute it and/or
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
014 ;;; modify it under the terms of the GNU General Public License
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
015 ;;; as published by the Free Software Foundation; either version 2
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
016 ;;; of the License, or (at your option) any later version.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
017 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
018 ;;; This program is distributed in the hope that it will be useful,
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
019 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
020 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
021 ;;; GNU General Public License for more details.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
022 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
023 ;;; You should have received a copy of the GNU General Public License
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
024 ;;; along with this program; if not, write to the Free Software
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
025 ;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
026 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
027 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
028
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
029 (def NIL
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
030 "The canonical empty list symbol.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
031
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
032 TODO: this doesn't really work, because (from Clojure) `(empty? NIL)` throws
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
033 an exception. It might be better to subclass beowulf.cons_cell.ConsCell to create
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
034 a new singleton class Nil which overrides the `empty` method of
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
035 IPersistentCollection?"
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
036 'NIL)
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
037
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
038 (def oblist
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
039 "The default environment."
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
040 (atom NIL))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
041
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
042 (def ^:dynamic *options*
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
043 "Command line options from invocation."
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
044 {})
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
045
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because it is too large
Load diff
|
@ -1,233 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<link rel="stylesheet" href="../../coverage.css"/> <title> beowulf/reader/char_reader.clj </title>
|
||||
</head>
|
||||
<body>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
001 (ns beowulf.reader.char-reader
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
002 "Provide sensible line editing, auto completion, and history recall.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
003
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
004 None of what's needed here is really working yet, and a pull request with
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
005 a working implementation would be greatly welcomed.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
006
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
007 ## What's needed (rough specification)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
008
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
009 1. Carriage return **does not** cause input to be returned, **unless**
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
010 a. the number of open brackets `(` and closing brackets `)` match; and
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
011 b. the number of open square brackets `[` and closing square brackets `]` also match;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
012 2. <Ctrl-D> aborts editing and returns the string `STOP`;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
013 3. <Up-arrow> and <down-arrow> scroll back and forward through history, but ideally I'd like
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
014 this to be the Lisp history (i.e. the history of S-Expressions actually read by `READ`,
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
015 rather than the strings which were supplied to `READ`);
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
016 4. <Tab> offers potential auto-completions taken from the value of `(OBLIST)`, ideally the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
017 current value, not the value at the time the session started;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
018 5. <Back-arrow> and <Forward-arrow> offer movement and editing within the line.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
019
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
020 TODO: There are multiple problems with JLine; a better solution might be
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
021 to start from here:
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
022 https://stackoverflow.com/questions/7931988/how-to-manipulate-control-characters"
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
023 ;; (:import [org.jline.reader LineReader LineReaderBuilder]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
024 ;; [org.jline.terminal TerminalBuilder])
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
025 )
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
026
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
027 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
028 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
029 ;;; Copyright (C) 2022-2023 Simon Brooke
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
030 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
031 ;;; This program is free software; you can redistribute it and/or
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
032 ;;; modify it under the terms of the GNU General Public License
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
033 ;;; as published by the Free Software Foundation; either version 2
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
034 ;;; of the License, or (at your option) any later version.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
035 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
036 ;;; This program is distributed in the hope that it will be useful,
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
037 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
038 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
039 ;;; GNU General Public License for more details.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
040 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
041 ;;; You should have received a copy of the GNU General Public License
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
042 ;;; along with this program; if not, write to the Free Software
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
043 ;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
044 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
045 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
046
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
047 ;; It looks from the example given [here](https://github.com/jline/jline3/blob/master/demo/src/main/java/org/jline/demo/Repl.java)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
048 ;; as though JLine could be used to build a perfect line-reader for Beowulf; but it also
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
049 ;; looks as though you'd need a DPhil in JLine to write it, and I don't have
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
050 ;; the time.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
051
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
052 ;; (def get-reader
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
053 ;; "Return a reader, first constructing it if necessary.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
054
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
055 ;; **NOTE THAT** this is not settled API. The existence and call signature of
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
056 ;; this function is not guaranteed in future versions."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
057 ;; (memoize (fn []
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
058 ;; (let [term (.build (.system (TerminalBuilder/builder) true))]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
059 ;; (.build (.terminal (LineReaderBuilder/builder) term))))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
060
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
061 ;; (defn read-chars
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
062 ;; "A drop-in replacement for `clojure.core/read-line`, except that line editing
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
063 ;; and history should be enabled.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
064
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
065 ;; **NOTE THAT** this does not work yet, but it is in the API because I hope
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
066 ;; that it will work later!"
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
067 ;; []
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
068 ;; (let [eddie (get-reader)]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
069 ;; (loop [s (.readLine eddie)]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
070 ;; (if (and (= (count (re-seq #"\(" s))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
071 ;; (count (re-seq #"\)" s)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
072 ;; (= (count (re-seq #"\[]" s))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
073 ;; (count (re-seq #"\]" s))))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
074 ;; s
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
075 ;; (recur (str s " " (.readLine eddie)))))))
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
|
@ -1,836 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<link rel="stylesheet" href="../../coverage.css"/> <title> beowulf/reader/generate.clj </title>
|
||||
</head>
|
||||
<body>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
001 (ns beowulf.reader.generate
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
002 "Generating S-Expressions from parse trees.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
003
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
004 ## From Lisp 1.5 Programmers Manual, page 10
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
005 *Note that I've retyped much of this, since copy/pasting out of PDF is less
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
006 than reliable. Any typos are mine.*
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
007
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
008 *Quote starts:*
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
009
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
010 We are now in a position to define the universal LISP function
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
011 `evalquote[fn;args]`, When evalquote is given a function and a list of arguments
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
012 for that function, it computes the value of the function applied to the arguments.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
013 LISP functions have S-expressions as arguments. In particular, the argument `fn`
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
014 of the function evalquote must be an S-expression. Since we have been
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
015 writing functions as M-expressions, it is necessary to translate them into
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
016 S-expressions.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
017
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
018 The following rules define a method of translating functions written in the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
019 meta-language into S-expressions.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
020 1. If the function is represented by its name, it is translated by changing
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
021 all of the letters to upper case, making it an atomic symbol. Thus `car` is
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
022 translated to `CAR`.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
023 2. If the function uses the lambda notation, then the expression
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
024 `λ[[x ..;xn]; ε]` is translated into `(LAMBDA (X1 ...XN) ε*)`, where ε* is the translation
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
025 of ε.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
026 3. If the function begins with label, then the translation of
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
027 `label[α;ε]` is `(LABEL α* ε*)`.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
028
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
029 Forms are translated as follows:
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
030 1. A variable, like a function name, is translated by using uppercase letters.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
031 Thus the translation of `var1` is `VAR1`.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
032 2. The obvious translation of letting a constant translate into itself will not
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
033 work. Since the translation of `x` is `X`, the translation of `X` must be something
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
034 else to avoid ambiguity. The solution is to quote it. Thus `X` is translated
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
035 into `(QUOTE X)`.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
036 3. The form `fn[argl;. ..;argn]` is translated into `(fn* argl* ...argn*)`
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
037 4. The conditional expression `[pl-el;...;pn-en]` is translated into
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
038 `(COND (p1* e1*)...(pn* en*))`
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
039
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
040 ## Examples
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
041 ```
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
042 M-expressions S-expressions
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
043
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
044 x X
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
045 car CAR
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
046 car[x] (CAR X)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
047 T (QUOTE T)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
048 ff[car [x]] (FF (CAR X))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
049 [atom[x]->x; T->ff[car[x]]] (COND ((ATOM X) X)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
050 ((QUOTE T)(FF (CAR X))))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
051 label[ff;λ[[x];[atom[x]->x; (LABEL FF (LAMBDA (X)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
052 T->ff[car[x]]]]] (COND ((ATOM X) X)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
053 ((QUOTE T)(FF (CAR X))))))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
054 ```
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
055
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
056 *quote ends*
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
057 "
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
058 (:require [beowulf.cons-cell :refer [make-beowulf-list make-cons-cell]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
059 [beowulf.reader.macros :refer [expand-macros]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
060 [beowulf.oblist :refer [NIL]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
061 [clojure.math.numeric-tower :refer [expt]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
062 [clojure.string :refer [upper-case]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
063 [clojure.tools.trace :refer [deftrace]]))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
064
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
065 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
066 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
067 ;;; Copyright (C) 2022-2023 Simon Brooke
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
068 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
069 ;;; This program is free software; you can redistribute it and/or
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
070 ;;; modify it under the terms of the GNU General Public License
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
071 ;;; as published by the Free Software Foundation; either version 2
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
072 ;;; of the License, or (at your option) any later version.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
073 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
074 ;;; This program is distributed in the hope that it will be useful,
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
075 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
076 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
077 ;;; GNU General Public License for more details.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
078 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
079 ;;; You should have received a copy of the GNU General Public License
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
080 ;;; along with this program; if not, write to the Free Software
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
081 ;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
082 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
083 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
084
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
085 (declare generate)
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
086
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
087 (defn gen-cond-clause
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
088 "Generate a cond clause from this simplified parse tree fragment `p`;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
089 returns `nil` if `p` does not represent a cond clause."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
090 [p context]
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
091 (when
|
||||
</span><br/>
|
||||
<span class="partial" title="11 out of 12 forms covered">
|
||||
092 (and (coll? p) (= :cond-clause (first p)))
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
093 (make-beowulf-list
|
||||
</span><br/>
|
||||
<span class="partial" title="12 out of 13 forms covered">
|
||||
094 (list (if (= (nth p 1) [:quoted-expr [:atom "T"]])
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
095 'T
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
096 (generate (nth p 1) context))
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
097 (generate (nth p 2) context)))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
098
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
099 (defn gen-cond
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
100 "Generate a cond statement from this simplified parse tree fragment `p`;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
101 returns `nil` if `p` does not represent a (MEXPR) cond statement."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
102 [p context]
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
103 (when
|
||||
</span><br/>
|
||||
<span class="partial" title="11 out of 12 forms covered">
|
||||
104 (and (coll? p) (= :cond (first p)))
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
105 (make-beowulf-list
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
106 (cons
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
107 'COND
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
108 (map
|
||||
</span><br/>
|
||||
<span class="partial" title="8 out of 9 forms covered">
|
||||
109 #(generate % (if (= context :mexpr) :cond-mexpr context))
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
110 (rest p))))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
111
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
112 (defn gen-fn-call
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
113 "Generate a function call from this simplified parse tree fragment `p`;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
114 returns `nil` if `p` does not represent a (MEXPR) function call."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
115 [p context]
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
116 (when
|
||||
</span><br/>
|
||||
<span class="partial" title="21 out of 23 forms covered">
|
||||
117 (and (coll? p) (= :fncall (first p)) (= :mvar (first (second p))))
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
118 (make-cons-cell
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
119 (generate (second p) context)
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
120 (generate (nth p 2) context))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
121
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
122
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
123 (defn gen-dot-terminated-list
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
124 "Generate a list, which may be dot-terminated, from this partial parse tree
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
125 'p'. Note that the function acts recursively and progressively decapitates
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
126 its argument, so that the argument will not always be a valid parse tree."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
127 [p]
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
128 (cond
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
129 (empty? p)
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
130 NIL
|
||||
</span><br/>
|
||||
<span class="partial" title="15 out of 16 forms covered">
|
||||
131 (and (coll? (first p)) (= :dot-terminal (first (first p))))
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
132 (let [dt (first p)]
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
133 (make-cons-cell
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
134 (generate (nth dt 1))
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
135 (generate (nth dt 2))))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
136 :else
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
137 (make-cons-cell
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
138 (generate (first p))
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
139 (gen-dot-terminated-list (rest p)))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
140
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
141 ;; null[x] = [x = NIL -> T; T -> F]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
142 ;; [:defn
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
143 ;; [:mexpr [:fncall [:mvar "null"] [:bindings [:args [:mexpr [:mvar "x"]]]]]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
144 ;; "="
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
145 ;; [:mexpr [:cond
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
146 ;; [:cond-clause [:mexpr [:iexpr [:lhs [:mexpr [:mvar "x"]]] [:iop "="] [:rhs [:mexpr [:mconst "NIL"]]]]] [:mexpr [:mconst "T"]]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
147 ;; [:cond-clause [:mexpr [:mconst "T"]] [:mexpr [:mconst "F"]]]]]]
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
148
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
149 (defn generate-defn
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
150 [tree context]
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
151 (if (= :mexpr (first tree))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
152 (generate-defn (second tree) context)
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
153 (make-beowulf-list
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
154 (list 'PUT
|
||||
</span><br/>
|
||||
<span class="covered" title="13 out of 13 forms covered">
|
||||
155 (list 'QUOTE (generate (-> tree second second second) context))
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
156 (list 'QUOTE 'EXPR)
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
157 (list 'QUOTE
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
158 (cons 'LAMBDA
|
||||
</span><br/>
|
||||
<span class="covered" title="12 out of 12 forms covered">
|
||||
159 (list (generate (nth (-> tree second second) 2) context)
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
160 (generate (nth tree 3) context))))))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
161
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
162 (defn gen-iexpr
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
163 [tree context]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 11 forms covered">
|
||||
164 (let [bundle (reduce #(assoc %1 (first %2) %2)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
165 {}
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
166 (rest tree))]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 8 forms covered">
|
||||
167 (list (generate (:iop bundle) context)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
168 (generate (:lhs bundle) context)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
169 (generate (:rhs bundle) context))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
170
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
171 (defn generate-set
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
172 "Actually not sure what the mexpr representation of set looks like"
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
173 [tree context]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 7 forms covered">
|
||||
174 (throw (ex-info "Not Yet Implemented" {:feature "generate-set"})))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
175
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
176 (defn generate-assign
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
177 "Generate an assignment statement based on this `tree`. If the thing
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
178 being assigned to is a function signature, then we have to do something
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
179 different to if it's an atom."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
180 [tree context]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 13 forms covered">
|
||||
181 (case (first (second tree))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
182 :fncall (generate-defn tree context)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 12 forms covered">
|
||||
183 :mexpr (map #(generate % context) (rest (second tree)))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 8 forms covered">
|
||||
184 (:mvar :atom) (generate-set tree context)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
185
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
186 (defn strip-leading-zeros
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
187 "`read-string` interprets strings with leading zeros as octal; strip
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
188 any from this string `s`. If what's left is empty (i.e. there were
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
189 only zeros, return `\"0\"`."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
190 ([s]
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
191 (strip-leading-zeros s ""))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
192 ([s prefix]
|
||||
</span><br/>
|
||||
<span class="partial" title="1 out of 2 forms covered">
|
||||
193 (if
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
194 (empty? s) "0"
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
195 (case (first s)
|
||||
</span><br/>
|
||||
<span class="partial" title="12 out of 24 forms covered">
|
||||
196 (\+ \-) (strip-leading-zeros (subs s 1) (str (first s) prefix))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 7 forms covered">
|
||||
197 "0" (strip-leading-zeros (subs s 1) prefix)
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
198 (str prefix s)))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
199
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
200 (defn generate
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
201 "Generate lisp structure from this parse tree `p`. It is assumed that
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
202 `p` has been simplified."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
203 ([p]
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
204 (generate p :expr))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
205 ([p context]
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
206 (try
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
207 (expand-macros
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
208 (if
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
209 (coll? p)
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
210 (case (first p)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
211 :λ "LAMBDA"
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
212 :λexpr (make-cons-cell
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
213 (generate (nth p 1) context)
|
||||
</span><br/>
|
||||
<span class="covered" title="8 out of 8 forms covered">
|
||||
214 (make-cons-cell (generate (nth p 2) context)
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
215 (generate (nth p 3) context)))
|
||||
</span><br/>
|
||||
<span class="covered" title="12 out of 12 forms covered">
|
||||
216 :args (make-beowulf-list (map #(generate % context) (rest p)))
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
217 :atom (symbol (second p))
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
218 :bindings (generate (second p) context)
|
||||
</span><br/>
|
||||
<span class="covered" title="12 out of 12 forms covered">
|
||||
219 :body (make-beowulf-list (map #(generate % context) (rest p)))
|
||||
</span><br/>
|
||||
<span class="covered" title="12 out of 12 forms covered">
|
||||
220 (:coefficient :exponent) (generate (second p) context)
|
||||
</span><br/>
|
||||
<span class="partial" title="8 out of 9 forms covered">
|
||||
221 :cond (gen-cond p (if (= context :mexpr) :cond-mexpr context))
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
222 :cond-clause (gen-cond-clause p context)
|
||||
</span><br/>
|
||||
<span class="covered" title="11 out of 11 forms covered">
|
||||
223 :decimal (read-string (apply str (map second (rest p))))
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
224 :defn (generate-defn p context)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
225 :dotted-pair (make-cons-cell
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
226 (generate (nth p 1) context)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
227 (generate (nth p 2) context))
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
228 :fncall (gen-fn-call p context)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
229 :iexpr (gen-iexpr p context)
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
230 :integer (read-string (strip-leading-zeros (second p)))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 11 forms covered">
|
||||
231 :iop (case (second p)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
232 "/" 'DIFFERENCE
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
233 "=" 'EQUAL
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
234 ">" 'GREATERP
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
235 "<" 'LESSP
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
236 "+" 'PLUS
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
237 "*" 'TIMES
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
238 ;; else
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
239 (throw (ex-info "Unrecognised infix operator symbol"
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
240 {:phase :generate
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
241 :fragment p})))
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
242 :list (gen-dot-terminated-list (rest p))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 12 forms covered">
|
||||
243 (:lhs :rhs) (generate (second p) context)
|
||||
</span><br/>
|
||||
<span class="covered" title="11 out of 11 forms covered">
|
||||
244 :mexpr (generate (second p) (if (= context :cond-mexpr) context :mexpr))
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
245 :mconst (if (= context :cond-mexpr)
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
246 (case (second p)
|
||||
</span><br/>
|
||||
<span class="partial" title="5 out of 15 forms covered">
|
||||
247 ("T" "F" "NIL") (symbol (second p))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
248 ;; else
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 8 forms covered">
|
||||
249 (list 'QUOTE (symbol (second p))))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
250 ;; else
|
||||
</span><br/>
|
||||
<span class="covered" title="8 out of 8 forms covered">
|
||||
251 (list 'QUOTE (symbol (second p))))
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
252 :mvar (symbol (upper-case (second p)))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
253 :number (generate (second p) context)
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
254 :octal (let [n (read-string (strip-leading-zeros (second p) "0"))
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
255 scale (generate (nth p 3) context)]
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
256 (* n (expt 8 scale)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
257
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
258 ;; the quote read macro (which probably didn't exist in Lisp 1.5, but...)
|
||||
</span><br/>
|
||||
<span class="covered" title="11 out of 11 forms covered">
|
||||
259 :quoted-expr (make-beowulf-list (list 'QUOTE (generate (second p) context)))
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
260 :scale-factor (if
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
261 (empty? (second p)) 0
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
262 (read-string (strip-leading-zeros (second p))))
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
263 :scientific (let [n (generate (second p) context)
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
264 exponent (generate (nth p 3) context)]
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
265 (* n (expt 10 exponent)))
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
266 :sexpr (generate (second p) :sexpr)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
267 :subr (symbol (second p))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
268
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
269 ;; default
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 9 forms covered">
|
||||
270 (throw (ex-info (str "Unrecognised head: " (first p))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
271 {:generating p})))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
272 p))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
273 (catch Throwable any
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
274 (throw (ex-info "Could not generate"
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
275 {:generating p}
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
276 any))))))
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
|
@ -1,212 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<link rel="stylesheet" href="../../coverage.css"/> <title> beowulf/reader/macros.clj </title>
|
||||
</head>
|
||||
<body>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
001 (ns beowulf.reader.macros
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
002 "Can I implement reader macros? let's see!
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
003
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
004 We don't need (at least, in the Clojure reader) to rewrite forms like
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
005 `'FOO`, because that's handled by the parser. But we do need to rewrite
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
006 things which don't evaluate their arguments, like `SETQ`, because (unless
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
007 LABEL does it, which I'm not yet sure of) we're not yet able to implement
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
008 things which don't evaluate arguments.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
009
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
010 TODO: at this stage, the following should probably also be read macros:
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
011 DEFINE"
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
012 (:require [beowulf.cons-cell :refer [make-beowulf-list]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
013 [beowulf.host :refer [CONS LIST]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
014 [clojure.string :refer [join]]))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
015
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
016 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
017 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
018 ;;; We don't need (at least, in the Clojure reader) to rewrite forms like
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
019 ;;; "'FOO", because that's handled by the parser. But we do need to rewrite
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
020 ;;; things which don't evaluate their arguments, like `SETQ`, because (unless
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
021 ;;; LABEL does it, which I'm not yet sure of) we're not yet able to implement
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
022 ;;; things which don't evaluate arguments.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
023 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
024 ;;; TODO: at this stage, the following should probably also be read macros:
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
025 ;;; DEFINE
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
026 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
027 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
028 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
029 ;;; Copyright (C) 2022-2023 Simon Brooke
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
030 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
031 ;;; This program is free software; you can redistribute it and/or
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
032 ;;; modify it under the terms of the GNU General Public License
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
033 ;;; as published by the Free Software Foundation; either version 2
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
034 ;;; of the License, or (at your option) any later version.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
035 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
036 ;;; This program is distributed in the hope that it will be useful,
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
037 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
038 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
039 ;;; GNU General Public License for more details.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
040 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
041 ;;; You should have received a copy of the GNU General Public License
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
042 ;;; along with this program; if not, write to the Free Software
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
043 ;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
044 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
045 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
046
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
047 (def ^:dynamic *readmacros*
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
048 {:car {'DEFUN (fn [f]
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
049 (LIST 'SET (LIST 'QUOTE (second f))
|
||||
</span><br/>
|
||||
<span class="covered" title="11 out of 11 forms covered">
|
||||
050 (LIST 'QUOTE (CONS 'LAMBDA (rest (rest f))))))
|
||||
</span><br/>
|
||||
<span class="covered" title="13 out of 13 forms covered">
|
||||
051 'SETQ (fn [f] (LIST 'SET (LIST 'QUOTE (second f)) (nth f 2)))}})
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
052
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
053 (defn expand-macros
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
054 [form]
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
055 (try
|
||||
</span><br/>
|
||||
<span class="covered" title="19 out of 19 forms covered">
|
||||
056 (if-let [car (when (and (coll? form) (symbol? (first form)))
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
057 (first form))]
|
||||
</span><br/>
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
058 (if-let [macro (-> *readmacros* :car car)]
|
||||
</span><br/>
|
||||
<span class="covered" title="8 out of 8 forms covered">
|
||||
059 (make-beowulf-list (apply macro (list form)))
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
060 form)
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
061 form)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
062 (catch Exception any
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
063 (println (join "\n"
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
064 ["# ERROR while expanding macro:"
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
065 (str "# Form: " form)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
066 (str "# Error class: " (.getName (.getClass any)))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
067 (str "# Message: " (.getMessage any))]))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
068 form)))
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
|
@ -1,368 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<link rel="stylesheet" href="../../coverage.css"/> <title> beowulf/reader/parser.clj </title>
|
||||
</head>
|
||||
<body>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
001 (ns beowulf.reader.parser
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
002 "The actual parser, supporting both S-expression and M-expression syntax."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
003 (:require [instaparse.core :as i]))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
004
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
005 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
006 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
007 ;;; Copyright (C) 2022-2023 Simon Brooke
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
008 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
009 ;;; This program is free software; you can redistribute it and/or
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
010 ;;; modify it under the terms of the GNU General Public License
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
011 ;;; as published by the Free Software Foundation; either version 2
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
012 ;;; of the License, or (at your option) any later version.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
013 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
014 ;;; This program is distributed in the hope that it will be useful,
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
015 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
016 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
017 ;;; GNU General Public License for more details.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
018 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
019 ;;; You should have received a copy of the GNU General Public License
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
020 ;;; along with this program; if not, write to the Free Software
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
021 ;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
022 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
023 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
024
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
025 (def parse
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
026 "Parse a string presented as argument into a parse tree which can then
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
027 be operated upon further."
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
028 (i/parser
|
||||
</span><br/>
|
||||
<span class="covered" title="13 out of 13 forms covered">
|
||||
029 (str
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
030 ;; we tolerate whitespace and comments around legitimate input
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
031 "raw := expr | opt-comment expr opt-comment;"
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
032 ;; top level: we accept mexprs as well as sexprs.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
033 "expr := mexpr | sexpr ;"
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
034
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
035 ;; comments. I'm pretty confident Lisp 1.5 did NOT have these.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
036 "comment := opt-space <';;'> opt-space #'[^\\n\\r]*';"
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
037
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
038 ;; there's a notation comprising a left brace followed by mexprs
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
039 ;; followed by a right brace which doesn't seem to be documented
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
040 ;; but I think must represent assembly code(?)
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
041
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
042 ;; "assembly := lbrace exprs rbrace;"
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
043
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
044 ;; mexprs. I'm pretty clear that Lisp 1.5 could never read these,
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
045 ;; but it's a convenience.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
046
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
047 ;; TODO: this works for now but in fact the Programmer's Manual
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
048 ;; gives a much simpler formulation of M-expression grammar on
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
049 ;; page 9, and of the S-expression grammar on page 8. It would
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
050 ;; be worth going back and redoing this from the book.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
051
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
052 "exprs := expr | exprs;"
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
053 "mexpr := λexpr | fncall | defn | cond | mvar | mconst | iexpr | number | mexpr comment;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
054 λexpr := λ lsqb bindings semi-colon opt-space body opt-space rsqb;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
055 λ := 'λ' | 'lambda';
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
056 bindings := lsqb args rsqb | lsqb rsqb;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
057 body := (opt-space mexpr semi-colon)* opt-space mexpr;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
058 fncall := fn-name bindings;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
059 lsqb := '[';
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
060 rsqb := ']';
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
061 lbrace := '{';
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
062 rbrace := '}';
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
063 defn := mexpr opt-space '=' opt-space mexpr;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
064 cond := lsqb (opt-space cond-clause semi-colon opt-space)* cond-clause rsqb;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
065 cond-clause := mexpr opt-space arrow opt-space mexpr opt-space;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
066 arrow := '->';
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
067 args := arg | (opt-space arg semi-colon opt-space)* opt-space arg opt-space;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
068 arg := mexpr;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
069 fn-name := mvar;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
070 mvar := #'[a-z][a-z0-9]*';
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
071 mconst := #'[A-Z][A-Z0-9]*';
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
072 semi-colon := ';';"
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
073
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
074 ;; Infix operators appear in mexprs, e.g. on page 7. Ooops!
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
075 ;; I do not know what infix operators are considered legal.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
076 ;; In particular I do not know what symbol was used for
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
077 ;; multiply
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
078 "iexpr := iexp iop iexp;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
079 iexp := mexpr | number | opt-space iexp opt-space;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
080 iop := '>' | '<' | '+' | '-' | '*' '/' | '=' ;"
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
081
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
082 ;; comments. I'm pretty confident Lisp 1.5 did NOT have these.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
083 "opt-comment := opt-space | comment;"
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
084 "comment := opt-space <';;'> #'[^\\n\\r]*' opt-space;"
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
085
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
086 ;; sexprs. Note it's not clear to me whether Lisp 1.5 had the quote macro,
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
087 ;; but I've included it on the basis that it can do little harm.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
088 "sexpr := quoted-expr | atom | number | subr | dotted-pair | list | sexpr comment;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
089 list := lpar sexpr rpar | lpar (sexpr sep)* rpar | lpar (sexpr sep)* dot-terminal | lbrace exprs rbrace;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
090 list := lpar opt-space sexpr rpar | lpar opt-space (sexpr sep)* rpar | lpar opt-space (sexpr sep)* dot-terminal;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
091 dotted-pair := lpar dot-terminal ;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
092 dot := '.';
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
093 lpar := '(';
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
094 rpar := ')';
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
095 quoted-expr := quote sexpr;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
096 quote := '\\'';
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
097 dot-terminal := sexpr space dot space sexpr rpar;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
098 space := #'\\p{javaWhitespace}+';
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
099 opt-space := #'\\p{javaWhitespace}*';
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
100 sep := ',' | opt-space;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
101 atom := #'[A-Z][A-Z0-9]*';"
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
102
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
103 ;; we need a way of representing Clojure functions on the object list;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
104 ;; subr objects aren't expected to be normally entered on the REPL, but
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
105 ;; must be on the object list or functions to which functions are passed
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
106 ;; won't be able to access them.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
107 "subr := #'[a-z][a-z.]*/[A-Za-z][A-Za-z0-9]*';"
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
108
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
109 ;; Lisp 1.5 supported octal as well as decimal and scientific notation
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
110 "number := integer | decimal | scientific | octal;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
111 integer := #'-?[0-9]+';
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
112 decimal := integer dot integer;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
113 scientific := coefficient e exponent;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
114 coefficient := decimal | integer;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
115 exponent := integer;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
116 e := 'E';
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
117 octal := #'[+-]?[0-7]+{1,12}' q scale-factor;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
118 q := 'Q';
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
119 scale-factor := #'[0-9]*'")))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
120
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
|
@ -1,401 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<link rel="stylesheet" href="../../coverage.css"/> <title> beowulf/reader/simplify.clj </title>
|
||||
</head>
|
||||
<body>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
001 (ns beowulf.reader.simplify
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
002 "Simplify parse trees. Be aware that this is very tightly coupled
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
003 with the parser."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
004 (:require [beowulf.oblist :refer [*options*]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
005 [instaparse.failure :as f])
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
006 (:import [instaparse.gll Failure]))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
007
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
008 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
009 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
010 ;;; Copyright (C) 2022-2023 Simon Brooke
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
011 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
012 ;;; This program is free software; you can redistribute it and/or
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
013 ;;; modify it under the terms of the GNU General Public License
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
014 ;;; as published by the Free Software Foundation; either version 2
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
015 ;;; of the License, or (at your option) any later version.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
016 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
017 ;;; This program is distributed in the hope that it will be useful,
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
018 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
019 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
020 ;;; GNU General Public License for more details.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
021 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
022 ;;; You should have received a copy of the GNU General Public License
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
023 ;;; along with this program; if not, write to the Free Software
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
024 ;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
025 ;;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
026 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
027
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
028 (declare simplify-tree)
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
029
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
030 (defn remove-optional-space
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
031 [tree]
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
032 (if (vector? tree)
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
033 (if (= :opt-space (first tree))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
034 nil
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
035 (let [v (remove nil?
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
036 (map remove-optional-space tree))]
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
037 (if (seq v)
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
038 (apply vector v)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
039 v)))
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
040 tree))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
041
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
042 (defn remove-nesting
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
043 [tree context]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
044 (let [tree' (remove-optional-space tree)]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 15 forms covered">
|
||||
045 (if-let [key (when (and (vector? tree')
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
046 (keyword? (first tree')))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
047 (first tree'))]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
048 (loop [r tree']
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 18 forms covered">
|
||||
049 (if (and r (vector? r) (keyword? (first r)))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
050 (if (= (first r) key)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
051 (recur (simplify-tree (second r) context))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
052 r)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
053 r))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
054 tree')))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
055
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
056 (defn simplify-tree
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
057 "Simplify this parse tree `p`. If `p` is an instaparse failure object, throw
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
058 an `ex-info`, with `p` as the value of its `:failure` key.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
059
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
060 **NOTE THAT** it is assumed that `remove-optional-space` has been run on the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
061 parse tree **BEFORE** it is passed to `simplify-tree`."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
062 ([p]
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
063 (if
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
064 (instance? Failure p)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
065 (throw (ex-info
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
066 (str "Ic ne behæfd: " (f/pprint-failure p))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
067 {:cause :parse-failure
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
068 :phase :simplify
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
069 :failure p}))
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
070 (simplify-tree p :expr)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
071 ([p context]
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
072 (cond
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
073 (string? p) p
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
074 (coll? p) (apply
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
075 vector
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
076 (remove
|
||||
</span><br/>
|
||||
<span class="covered" title="8 out of 8 forms covered">
|
||||
077 #(when (coll? %) (empty? %))
|
||||
</span><br/>
|
||||
<span class="partial" title="16 out of 19 forms covered">
|
||||
078 (case (first p)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
079 (:λexpr
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
080 :args :bindings :body :cond :cond-clause :defn :dot-terminal
|
||||
</span><br/>
|
||||
<span class="partial" title="80 out of 96 forms covered">
|
||||
081 :fncall :lhs :quoted-expr :rhs ) (map #(simplify-tree % context) p)
|
||||
</span><br/>
|
||||
<span class="partial" title="24 out of 30 forms covered">
|
||||
082 (:arg :expr :coefficient :fn-name :number) (simplify-tree (second p) context)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
083 (:arrow :dot :e :lpar :lsqb :opt-comment :opt-space :q :quote :rpar :rsqb
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
084 :semi-colon :sep :space) nil
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
085 :atom (if
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
086 (= context :mexpr)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
087 [:quoted-expr p]
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
088 p)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
089 :comment (when
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
090 (:strict *options*)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
091 (throw
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
092 (ex-info "Cannot parse comments in strict mode"
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
093 {:cause :strict})))
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
094 (:decimal :integer :mconst :octal :scientific) p
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
095 :dotted-pair (if
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
096 (= context :mexpr)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
097 [:fncall
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
098 [:mvar "cons"]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
099 [:args
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
100 (simplify-tree (nth p 1) context)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
101 (simplify-tree (nth p 2) context)]]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 8 forms covered">
|
||||
102 (map #(simplify-tree % context) p))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
103 :iexp (simplify-tree (second p) context)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
104 :iexpr [:iexpr
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 8 forms covered">
|
||||
105 [:lhs (simplify-tree (second p) context)]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
106 (simplify-tree (nth p 2) context) ;; really should be the operator
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 8 forms covered">
|
||||
107 [:rhs (simplify-tree (nth p 3) context)]]
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
108 :mexpr (if
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
109 (:strict *options*)
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
110 (throw
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
111 (ex-info "Cannot parse meta expressions in strict mode"
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
112 {:cause :strict}))
|
||||
</span><br/>
|
||||
<span class="covered" title="8 out of 8 forms covered">
|
||||
113 [:mexpr (simplify-tree (second p) :mexpr)])
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
114 :list (if
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
115 (= context :mexpr)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
116 [:fncall
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
117 [:mvar "list"]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 11 forms covered">
|
||||
118 [:args (apply vector (map simplify-tree (rest p)))]]
|
||||
</span><br/>
|
||||
<span class="covered" title="8 out of 8 forms covered">
|
||||
119 (map #(simplify-tree % context) p))
|
||||
</span><br/>
|
||||
<span class="covered" title="11 out of 11 forms covered">
|
||||
120 :raw (first (remove empty? (map simplify-tree (rest p))))
|
||||
</span><br/>
|
||||
<span class="covered" title="8 out of 8 forms covered">
|
||||
121 :sexpr [:sexpr (simplify-tree (second p) :sexpr)]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
122 ;;default
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
123 p)))
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
124 :else p)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
125
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
126 (defn simplify
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
127 "Simplify this parse tree `p`. If `p` is an instaparse failure object, throw
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
128 an `ex-info`, with `p` as the value of its `:failure` key. Calls
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
129 `remove-optional-space` before processing."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
130 [p]
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
131 (simplify-tree (remove-optional-space p)))
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
|
@ -16,225 +16,88 @@
|
|||
</tr></thead>
|
||||
<tr>
|
||||
<td><a href="beowulf/bootstrap.clj.html">beowulf.bootstrap</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:63.9344262295082%;
|
||||
float:left;"> 624 </div><div class="not-covered"
|
||||
style="width:36.0655737704918%;
|
||||
float:left;"> 352 </div></td>
|
||||
<td class="with-number">63.93 %</td>
|
||||
style="width:60.47808764940239%;
|
||||
float:left;"> 759 </div><div class="not-covered"
|
||||
style="width:39.52191235059761%;
|
||||
float:left;"> 496 </div></td>
|
||||
<td class="with-number">60.48 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:59.48275862068966%;
|
||||
float:left;"> 138 </div><div class="partial"
|
||||
style="width:8.189655172413794%;
|
||||
float:left;"> 19 </div><div class="not-covered"
|
||||
style="width:32.327586206896555%;
|
||||
float:left;"> 75 </div></td>
|
||||
<td class="with-number">67.67 %</td>
|
||||
<td class="with-number">422</td><td class="with-number">33</td><td class="with-number">232</td>
|
||||
style="width:47.92626728110599%;
|
||||
float:left;"> 104 </div><div class="partial"
|
||||
style="width:19.35483870967742%;
|
||||
float:left;"> 42 </div><div class="not-covered"
|
||||
style="width:32.71889400921659%;
|
||||
float:left;"> 71 </div></td>
|
||||
<td class="with-number">67.28 %</td>
|
||||
<td class="with-number">414</td><td class="with-number">46</td><td class="with-number">217</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="beowulf/cons_cell.clj.html">beowulf.cons-cell</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:72.34927234927235%;
|
||||
float:left;"> 348 </div><div class="not-covered"
|
||||
style="width:27.65072765072765%;
|
||||
float:left;"> 133 </div></td>
|
||||
<td class="with-number">72.35 %</td>
|
||||
style="width:56.82819383259912%;
|
||||
float:left;"> 129 </div><div class="not-covered"
|
||||
style="width:43.17180616740088%;
|
||||
float:left;"> 98 </div></td>
|
||||
<td class="with-number">56.83 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:75.17241379310344%;
|
||||
float:left;"> 109 </div><div class="partial"
|
||||
style="width:6.206896551724138%;
|
||||
float:left;"> 9 </div><div class="not-covered"
|
||||
style="width:18.620689655172413%;
|
||||
float:left;"> 27 </div></td>
|
||||
<td class="with-number">81.38 %</td>
|
||||
<td class="with-number">274</td><td class="with-number">23</td><td class="with-number">145</td>
|
||||
style="width:57.35294117647059%;
|
||||
float:left;"> 39 </div><div class="partial"
|
||||
style="width:4.411764705882353%;
|
||||
float:left;"> 3 </div><div class="not-covered"
|
||||
style="width:38.23529411764706%;
|
||||
float:left;"> 26 </div></td>
|
||||
<td class="with-number">61.76 %</td>
|
||||
<td class="with-number">156</td><td class="with-number">15</td><td class="with-number">68</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="beowulf/core.clj.html">beowulf.core</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:69.47368421052632%;
|
||||
float:left;"> 198 </div><div class="not-covered"
|
||||
style="width:30.526315789473685%;
|
||||
float:left;"> 87 </div></td>
|
||||
<td class="with-number">69.47 %</td>
|
||||
style="width:90.9090909090909%;
|
||||
float:left;"> 170 </div><div class="not-covered"
|
||||
style="width:9.090909090909092%;
|
||||
float:left;"> 17 </div></td>
|
||||
<td class="with-number">90.91 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:72.46376811594203%;
|
||||
float:left;"> 50 </div><div class="partial"
|
||||
style="width:5.797101449275362%;
|
||||
float:left;"> 4 </div><div class="not-covered"
|
||||
style="width:21.73913043478261%;
|
||||
float:left;"> 15 </div></td>
|
||||
<td class="with-number">78.26 %</td>
|
||||
<td class="with-number">132</td><td class="with-number">6</td><td class="with-number">69</td>
|
||||
style="width:87.75510204081633%;
|
||||
float:left;"> 43 </div><div class="partial"
|
||||
style="width:2.0408163265306123%;
|
||||
float:left;"> 1 </div><div class="not-covered"
|
||||
style="width:10.204081632653061%;
|
||||
float:left;"> 5 </div></td>
|
||||
<td class="with-number">89.80 %</td>
|
||||
<td class="with-number">80</td><td class="with-number">3</td><td class="with-number">49</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="beowulf/host.clj.html">beowulf.host</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:42.77384423157018%;
|
||||
float:left;"> 1027 </div><div class="not-covered"
|
||||
style="width:57.22615576842982%;
|
||||
float:left;"> 1374 </div></td>
|
||||
<td class="with-number">42.77 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:53.72549019607843%;
|
||||
float:left;"> 137 </div><div class="partial"
|
||||
style="width:14.509803921568627%;
|
||||
float:left;"> 37 </div><div class="not-covered"
|
||||
style="width:31.764705882352942%;
|
||||
float:left;"> 81 </div></td>
|
||||
<td class="with-number">68.24 %</td>
|
||||
<td class="with-number">571</td><td class="with-number">66</td><td class="with-number">255</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="beowulf/interop.clj.html">beowulf.interop</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:57.72357723577236%;
|
||||
float:left;"> 142 </div><div class="not-covered"
|
||||
style="width:42.27642276422764%;
|
||||
float:left;"> 104 </div></td>
|
||||
<td class="with-number">57.72 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:46.96969696969697%;
|
||||
float:left;"> 31 </div><div class="partial"
|
||||
style="width:9.090909090909092%;
|
||||
float:left;"> 6 </div><div class="not-covered"
|
||||
style="width:43.93939393939394%;
|
||||
float:left;"> 29 </div></td>
|
||||
<td class="with-number">56.06 %</td>
|
||||
<td class="with-number">129</td><td class="with-number">11</td><td class="with-number">66</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="beowulf/io.clj.html">beowulf.io</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:43.962848297213625%;
|
||||
float:left;"> 142 </div><div class="not-covered"
|
||||
style="width:56.037151702786375%;
|
||||
float:left;"> 181 </div></td>
|
||||
<td class="with-number">43.96 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:46.478873239436616%;
|
||||
float:left;"> 33 </div><div class="partial"
|
||||
style="width:8.450704225352112%;
|
||||
float:left;"> 6 </div><div class="not-covered"
|
||||
style="width:45.070422535211264%;
|
||||
float:left;"> 32 </div></td>
|
||||
<td class="with-number">54.93 %</td>
|
||||
<td class="with-number">171</td><td class="with-number">12</td><td class="with-number">71</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="beowulf/manual.clj.html">beowulf.manual</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:95.93088071348942%;
|
||||
float:left;"> 1721 </div><div class="not-covered"
|
||||
style="width:4.069119286510591%;
|
||||
float:left;"> 73 </div></td>
|
||||
<td class="with-number">95.93 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:94.60317460317461%;
|
||||
float:left;"> 298 </div><div class="not-covered"
|
||||
style="width:5.396825396825397%;
|
||||
float:left;"> 17 </div></td>
|
||||
<td class="with-number">94.60 %</td>
|
||||
<td class="with-number">769</td><td class="with-number">4</td><td class="with-number">315</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="beowulf/oblist.clj.html">beowulf.oblist</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:100.0%;
|
||||
float:left;"> 9 </div></td>
|
||||
float:left;"> 1 </div></td>
|
||||
<td class="with-number">100.00 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:100.0%;
|
||||
float:left;"> 6 </div></td>
|
||||
float:left;"> 1 </div></td>
|
||||
<td class="with-number">100.00 %</td>
|
||||
<td class="with-number">45</td><td class="with-number">5</td><td class="with-number">6</td>
|
||||
<td class="with-number">5</td><td class="with-number">1</td><td class="with-number">1</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="beowulf/read.clj.html">beowulf.read</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:49.43181818181818%;
|
||||
float:left;"> 87 </div><div class="not-covered"
|
||||
style="width:50.56818181818182%;
|
||||
float:left;"> 89 </div></td>
|
||||
<td class="with-number">49.43 %</td>
|
||||
style="width:81.8941504178273%;
|
||||
float:left;"> 588 </div><div class="not-covered"
|
||||
style="width:18.105849582172702%;
|
||||
float:left;"> 130 </div></td>
|
||||
<td class="with-number">81.89 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:53.84615384615385%;
|
||||
float:left;"> 21 </div><div class="partial"
|
||||
style="width:7.6923076923076925%;
|
||||
float:left;"> 3 </div><div class="not-covered"
|
||||
style="width:38.46153846153846%;
|
||||
float:left;"> 15 </div></td>
|
||||
<td class="with-number">61.54 %</td>
|
||||
<td class="with-number">108</td><td class="with-number">9</td><td class="with-number">39</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="beowulf/reader/char_reader.clj.html">beowulf.reader.char-reader</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:100.0%;
|
||||
float:left;"> 1 </div></td>
|
||||
<td class="with-number">100.00 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:100.0%;
|
||||
float:left;"> 1 </div></td>
|
||||
<td class="with-number">100.00 %</td>
|
||||
<td class="with-number">75</td><td class="with-number">4</td><td class="with-number">1</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="beowulf/reader/generate.clj.html">beowulf.reader.generate</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:69.7872340425532%;
|
||||
float:left;"> 492 </div><div class="not-covered"
|
||||
style="width:30.21276595744681%;
|
||||
float:left;"> 213 </div></td>
|
||||
<td class="with-number">69.79 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:67.46031746031746%;
|
||||
float:left;"> 85 </div><div class="partial"
|
||||
style="width:73.80952380952381%;
|
||||
float:left;"> 93 </div><div class="partial"
|
||||
style="width:7.936507936507937%;
|
||||
float:left;"> 10 </div><div class="not-covered"
|
||||
style="width:24.603174603174605%;
|
||||
float:left;"> 31 </div></td>
|
||||
<td class="with-number">75.40 %</td>
|
||||
<td class="with-number">276</td><td class="with-number">21</td><td class="with-number">126</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="beowulf/reader/macros.clj.html">beowulf.reader.macros</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:80.18867924528301%;
|
||||
float:left;"> 85 </div><div class="not-covered"
|
||||
style="width:19.81132075471698%;
|
||||
float:left;"> 21 </div></td>
|
||||
<td class="with-number">80.19 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:70.0%;
|
||||
float:left;"> 14 </div><div class="not-covered"
|
||||
style="width:30.0%;
|
||||
float:left;"> 6 </div></td>
|
||||
<td class="with-number">70.00 %</td>
|
||||
<td class="with-number">68</td><td class="with-number">4</td><td class="with-number">20</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="beowulf/reader/parser.clj.html">beowulf.reader.parser</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:100.0%;
|
||||
float:left;"> 17 </div></td>
|
||||
<td class="with-number">100.00 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:100.0%;
|
||||
float:left;"> 4 </div></td>
|
||||
<td class="with-number">100.00 %</td>
|
||||
<td class="with-number">120</td><td class="with-number">14</td><td class="with-number">4</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="beowulf/reader/simplify.clj.html">beowulf.reader.simplify</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:57.30337078651685%;
|
||||
float:left;"> 255 </div><div class="not-covered"
|
||||
style="width:42.69662921348315%;
|
||||
float:left;"> 190 </div></td>
|
||||
<td class="with-number">57.30 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:49.382716049382715%;
|
||||
float:left;"> 40 </div><div class="partial"
|
||||
style="width:3.7037037037037037%;
|
||||
float:left;"> 3 </div><div class="not-covered"
|
||||
style="width:46.91358024691358%;
|
||||
float:left;"> 38 </div></td>
|
||||
<td class="with-number">53.09 %</td>
|
||||
<td class="with-number">131</td><td class="with-number">6</td><td class="with-number">81</td>
|
||||
style="width:18.253968253968253%;
|
||||
float:left;"> 23 </div></td>
|
||||
<td class="with-number">81.75 %</td>
|
||||
<td class="with-number">315</td><td class="with-number">31</td><td class="with-number">126</td>
|
||||
</tr>
|
||||
<tr><td>Totals:</td>
|
||||
<td class="with-bar"></td>
|
||||
<td class="with-number">64.63 %</td>
|
||||
<td class="with-number">68.97 %</td>
|
||||
<td class="with-bar"></td>
|
||||
<td class="with-number">74.41 %</td>
|
||||
<td class="with-number">72.89 %</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,28 +1,12 @@
|
|||
body {
|
||||
font-family: Helvetica, Arial, sans-serif;
|
||||
font-size: 15px;
|
||||
color: limegreen;
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
a {
|
||||
color: lime;
|
||||
}
|
||||
|
||||
a:active, a:hover {
|
||||
color: yellowgreen;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: green;
|
||||
}
|
||||
|
||||
pre, code {
|
||||
font-family: Monaco, DejaVu Sans Mono, Consolas, monospace;
|
||||
font-size: 9pt;
|
||||
margin: 15px 0;
|
||||
color: limegreen;
|
||||
background-color: #111;
|
||||
}
|
||||
|
||||
h1 {
|
||||
|
@ -37,13 +21,9 @@ h2 {
|
|||
font-size: 25px;
|
||||
}
|
||||
|
||||
th, td {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
h5.license {
|
||||
margin: 9px 0 22px 0;
|
||||
color: lime;
|
||||
color: #555;
|
||||
font-weight: normal;
|
||||
font-size: 12px;
|
||||
font-style: italic;
|
||||
|
@ -63,7 +43,7 @@ h5.license {
|
|||
left: 0;
|
||||
right: 0;
|
||||
height: 22px;
|
||||
color: limegreen;
|
||||
color: #f5f5f5;
|
||||
padding: 5px 7px;
|
||||
}
|
||||
|
||||
|
@ -72,8 +52,8 @@ h5.license {
|
|||
right: 0;
|
||||
bottom: 0;
|
||||
overflow: auto;
|
||||
background: black;
|
||||
color: green;
|
||||
background: #fff;
|
||||
color: #333;
|
||||
padding: 0 18px;
|
||||
}
|
||||
|
||||
|
@ -85,15 +65,15 @@ h5.license {
|
|||
}
|
||||
|
||||
.sidebar.primary {
|
||||
background: #080808;
|
||||
border-right: solid 1px forestgreen;
|
||||
background: #e2e2e2;
|
||||
border-right: solid 1px #cccccc;
|
||||
left: 0;
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
.sidebar.secondary {
|
||||
background: #111;
|
||||
border-right: solid 1px darkgreen;
|
||||
background: #f2f2f2;
|
||||
border-right: solid 1px #d7d7d7;
|
||||
left: 251px;
|
||||
width: 200px;
|
||||
}
|
||||
|
@ -111,8 +91,8 @@ h5.license {
|
|||
}
|
||||
|
||||
#header {
|
||||
background: #080808;
|
||||
box-shadow: 0 0 8px rgba(192, 255, 192, 0.4);
|
||||
background: #3f3f3f;
|
||||
box-shadow: 0 0 8px rgba(0, 0, 0, 0.4);
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
|
@ -137,13 +117,21 @@ h5.license {
|
|||
text-decoration: none;
|
||||
}
|
||||
|
||||
#header a {
|
||||
color: #f5f5f5;
|
||||
}
|
||||
|
||||
.sidebar a {
|
||||
color: #333;
|
||||
}
|
||||
|
||||
#header h2 {
|
||||
float: right;
|
||||
font-size: 9pt;
|
||||
font-weight: normal;
|
||||
margin: 4px 3px;
|
||||
padding: 0;
|
||||
color: #5f5;
|
||||
color: #bbb;
|
||||
}
|
||||
|
||||
#header h2 a {
|
||||
|
@ -158,11 +146,11 @@ h5.license {
|
|||
}
|
||||
|
||||
.sidebar h3 a {
|
||||
color: #4f4;
|
||||
color: #444;
|
||||
}
|
||||
|
||||
.sidebar h3.no-link {
|
||||
color: green;
|
||||
color: #636363;
|
||||
}
|
||||
|
||||
.sidebar ul {
|
||||
|
@ -187,7 +175,7 @@ h5.license {
|
|||
|
||||
.sidebar li .no-link {
|
||||
display: block;
|
||||
color: #7F7;
|
||||
color: #777;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
|
@ -229,8 +217,8 @@ h5.license {
|
|||
}
|
||||
|
||||
.sidebar li .tree .top {
|
||||
border-left: 1px solid yellowgreen;
|
||||
border-bottom: 1px solid yellowgreen;
|
||||
border-left: 1px solid #aaa;
|
||||
border-bottom: 1px solid #aaa;
|
||||
height: 19px;
|
||||
}
|
||||
|
||||
|
@ -239,17 +227,17 @@ h5.license {
|
|||
}
|
||||
|
||||
.sidebar li.branch .tree .bottom {
|
||||
border-left: 1px solid yellowgreen;
|
||||
border-left: 1px solid #aaa;
|
||||
}
|
||||
|
||||
.sidebar.primary li.current a {
|
||||
border-left: 3px solid goldenrod;
|
||||
color: goldenrod;
|
||||
border-left: 3px solid #a33;
|
||||
color: #a33;
|
||||
}
|
||||
|
||||
.sidebar.secondary li.current a {
|
||||
border-left: 3px solid yellow;
|
||||
color: yellow;
|
||||
border-left: 3px solid #33a;
|
||||
color: #33a;
|
||||
}
|
||||
|
||||
.namespace-index h2 {
|
||||
|
@ -287,7 +275,7 @@ h5.license {
|
|||
|
||||
.public {
|
||||
margin: 0;
|
||||
border-top: 1px solid lime;
|
||||
border-top: 1px solid #e0e0e0;
|
||||
padding-top: 14px;
|
||||
padding-bottom: 6px;
|
||||
}
|
||||
|
@ -305,7 +293,7 @@ h5.license {
|
|||
}
|
||||
|
||||
.members h4 {
|
||||
color: lime;
|
||||
color: #555;
|
||||
font-weight: normal;
|
||||
font-variant: small-caps;
|
||||
margin: 0 0 5px 0;
|
||||
|
@ -316,7 +304,7 @@ h5.license {
|
|||
padding-left: 12px;
|
||||
margin-top: 2px;
|
||||
margin-left: 7px;
|
||||
border-left: 1px solid #5f5;
|
||||
border-left: 1px solid #bbb;
|
||||
}
|
||||
|
||||
#content .members .inner h3 {
|
||||
|
@ -369,7 +357,7 @@ h4.dynamic {
|
|||
}
|
||||
|
||||
h4.added {
|
||||
color: #7acc32;
|
||||
color: #508820;
|
||||
}
|
||||
|
||||
h4.deprecated {
|
||||
|
@ -409,7 +397,7 @@ h4.deprecated {
|
|||
|
||||
.type-sig {
|
||||
clear: both;
|
||||
color: goldenrod;
|
||||
color: #088;
|
||||
}
|
||||
|
||||
.type-sig pre {
|
||||
|
@ -419,8 +407,8 @@ h4.deprecated {
|
|||
|
||||
.usage code {
|
||||
display: block;
|
||||
color: #008;
|
||||
margin: 2px 0;
|
||||
color: limegreen;
|
||||
}
|
||||
|
||||
.usage code:first-child {
|
||||
|
@ -488,27 +476,27 @@ p {
|
|||
}
|
||||
|
||||
.markdown pre > code, .src-link a {
|
||||
border: 1px solid lime;
|
||||
border: 1px solid #e4e4e4;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.markdown code:not(.hljs), .src-link a {
|
||||
background: #111;
|
||||
background: #f6f6f6;
|
||||
}
|
||||
|
||||
pre.deps {
|
||||
display: inline-block;
|
||||
margin: 0 10px;
|
||||
border: 1px solid lime;
|
||||
border: 1px solid #e4e4e4;
|
||||
border-radius: 2px;
|
||||
padding: 10px;
|
||||
background-color: #111;
|
||||
background-color: #f6f6f6;
|
||||
}
|
||||
|
||||
.markdown hr {
|
||||
border-style: solid;
|
||||
border-top: none;
|
||||
color: goldenrod;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.doc ul, .doc ol {
|
||||
|
@ -521,12 +509,12 @@ pre.deps {
|
|||
}
|
||||
|
||||
.doc table td, .doc table th {
|
||||
border: 1px solid goldenrod;
|
||||
border: 1px solid #dddddd;
|
||||
padding: 4px 6px;
|
||||
}
|
||||
|
||||
.doc table th {
|
||||
background: #111;
|
||||
background: #f2f2f2;
|
||||
}
|
||||
|
||||
.doc dl {
|
||||
|
@ -537,7 +525,7 @@ pre.deps {
|
|||
font-weight: bold;
|
||||
margin: 0;
|
||||
padding: 3px 0;
|
||||
border-bottom: 1px solid goldenrod;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.doc dl dd {
|
||||
|
@ -546,7 +534,7 @@ pre.deps {
|
|||
}
|
||||
|
||||
.doc abbr {
|
||||
border-bottom: 1px dotted goldenrod;
|
||||
border-bottom: 1px dotted #333;
|
||||
font-variant: none;
|
||||
cursor: help;
|
||||
}
|
||||
|
@ -559,5 +547,5 @@ pre.deps {
|
|||
font-size: 70%;
|
||||
padding: 1px 4px;
|
||||
text-decoration: none;
|
||||
color: lime5bb;
|
||||
color: #5555bb;
|
||||
}
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
<!DOCTYPE html PUBLIC ""
|
||||
"">
|
||||
<html><head><meta charset="UTF-8" /><title>Further Reading</title><link rel="icon" type="image/x-icon" href="../img/beowulf_logo_favicon.png" /><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">Beowulf</span> <span class="project-version">0.3.0</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 current"><a href="further_reading.html"><div class="inner"><span>Further Reading</span></div></a></li><li class="depth-1 "><a href="intro.html"><div class="inner"><span>beowulf</span></div></a></li><li class="depth-1 "><a href="mexpr.html"><div class="inner"><span>Interpreting M-Expressions</span></div></a></li><li class="depth-1 "><a href="values.html"><div class="inner"><span>The properties of the system, and their values</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>beowulf</span></div></div></li><li class="depth-2 branch"><a href="beowulf.bootstrap.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>bootstrap</span></div></a></li><li class="depth-2 branch"><a href="beowulf.cons-cell.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>cons-cell</span></div></a></li><li class="depth-2 branch"><a href="beowulf.core.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>core</span></div></a></li><li class="depth-2 branch"><a href="beowulf.gendoc.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>gendoc</span></div></a></li><li class="depth-2 branch"><a href="beowulf.host.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>host</span></div></a></li><li class="depth-2 branch"><a href="beowulf.interop.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>interop</span></div></a></li><li class="depth-2 branch"><a href="beowulf.io.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>io</span></div></a></li><li class="depth-2 branch"><a href="beowulf.manual.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>manual</span></div></a></li><li class="depth-2 branch"><a href="beowulf.oblist.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>oblist</span></div></a></li><li class="depth-2 branch"><a href="beowulf.read.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>read</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>reader</span></div></div></li><li class="depth-3 branch"><a href="beowulf.reader.char-reader.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>char-reader</span></div></a></li><li class="depth-3 branch"><a href="beowulf.reader.generate.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>generate</span></div></a></li><li class="depth-3 branch"><a href="beowulf.reader.macros.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>macros</span></div></a></li><li class="depth-3 branch"><a href="beowulf.reader.parser.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>parser</span></div></a></li><li class="depth-3"><a href="beowulf.reader.simplify.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>simplify</span></div></a></li></ul></div><div class="document" id="content"><div class="doc"><div class="markdown"><h1><a href="#further-reading" name="further-reading"></a>Further Reading</h1>
|
||||
<ol>
|
||||
<li><a href="http://bitsavers.org/pdf/mit/computer_center/Coding_for_the_MIT-IBM_704_Computer_Oct57.pdf">CODING for the MIT-IBM 704 COMPUTER, October 1957</a> This paper is not about Lisp. But it is about the particular individual computer on which Lisp was first implemented, and it is written in part by members of the Lisp team. I have found it useful in understanding the software environment in which, and the constraints under which, Lisp was written.</li>
|
||||
<li><a href="https://www.softwarepreservation.org/projects/LISP/MIT/AIM-001.pdf">MIT AI Memo 1, John McCarthy, September 1958</a> This is, as far as I can find, the earliest specification document of the Lisp project.</li>
|
||||
<li><a href="https://bitsavers.org/pdf/mit/rle_lisp/LISP_I_Programmers_Manual_Mar60.pdf">Lisp 1 Programmer’s Manual, Phyllis Fox, March 1960</a></li>
|
||||
<li><a href="https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf#page=81">Lisp 1.5 Programmer’s Manual, Michael I. Levin, August 1962</a> This book is essential reading: it documents in some detail the first fully realised Lisp language system.</li>
|
||||
<li><a href="https://dl.acm.org/doi/pdf/10.1145/800055.802047#page=3">Early LISP History (1956 - 1959), Herbert Stoyan, August 1984</a></li>
|
||||
<li>
|
||||
<p><a href="http://www.paulgraham.com/rootsoflisp.html">The Roots of Lisp, Paul Graham, 2001</a></p></li>
|
||||
<li>
|
||||
<p><a href="http://www.paulgraham.com/icad.html">The Revenge of the Nerds, Paul Graham, 2002</a> This is mainly about why to use Lisp as a language for modern commercial software, but has useful insights into where it comes from.</p>
|
||||
<blockquote>
|
||||
<p>So the short explanation of why this 1950s language is not obsolete is that it was not technology but math, and math doesn’t get stale.</p>
|
||||
</blockquote></li>
|
||||
</ol></div></div></div></body></html>
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
BIN
docs/favicon.ico
BIN
docs/favicon.ico
Binary file not shown.
Before Width: | Height: | Size: 17 KiB |
Binary file not shown.
Before Width: | Height: | Size: 147 KiB |
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 6.5 KiB |
Binary file not shown.
Before Width: | Height: | Size: 47 KiB |
|
@ -1,14 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Beowulf: Documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="codox/css/default.css" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>Beowulf: Documentation</h1>
|
||||
<ul>
|
||||
<li><a href="codox/index.html">Primary documentaion</a></li>
|
||||
<li><a href="cloverage/index.html">Test coverage</a></li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
26
project.clj
26
project.clj
|
@ -1,37 +1,30 @@
|
|||
(defproject beowulf "0.3.0"
|
||||
:aot :all
|
||||
(defproject beowulf "0.3.0-SNAPSHOT"
|
||||
:cloverage {:output "docs/cloverage"
|
||||
:ns-exclude-regex [#"beowulf\.gendoc" #"beowulf\.scratch"]}
|
||||
:codox {:html {:transforms [[:head] [:append
|
||||
[:link {:rel "icon"
|
||||
:type "image/x-icon"
|
||||
:href "../img/beowulf_logo_favicon.png"}]]]}
|
||||
:metadata {:doc "**TODO**: write docs"
|
||||
:codox {:metadata {:doc "**TODO**: write docs"
|
||||
:doc/format :markdown}
|
||||
:output-path "docs/codox"
|
||||
:source-uri "https://github.com/simon-brooke/beowulf/blob/master/{filepath}#L{line}"
|
||||
;; :themes [:journeyman]
|
||||
}
|
||||
:description "LISP 1.5 is to all Lisp dialects as Beowulf is to English literature."
|
||||
:source-uri "https://github.com/simon-brooke/beowulf/blob/master/{filepath}#L{line}"}
|
||||
:description "An implementation of LISP 1.5 in Clojure"
|
||||
:license {:name "GPL-2.0-or-later"
|
||||
:url "https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html"}
|
||||
:dependencies [[org.clojure/clojure "1.11.1"]
|
||||
[org.clojure/math.combinatorics "0.2.0"] ;; not needed in production builds
|
||||
[org.clojure/math.numeric-tower "0.0.5"]
|
||||
[org.clojure/tools.cli "1.0.214"]
|
||||
[org.clojure/tools.trace "0.7.11"]
|
||||
[clojure.java-time "1.2.0"]
|
||||
[environ "1.2.0"]
|
||||
[instaparse "1.4.12"]
|
||||
;; [org.jline/jline "3.23.0"]
|
||||
[org.jline/jline "3.23.0"]
|
||||
[rhizome "0.2.9"] ;; not needed in production builds
|
||||
]
|
||||
:main beowulf.core
|
||||
:main ^:skip-aot beowulf.core
|
||||
:plugins [[lein-cloverage "1.2.2"]
|
||||
[lein-codox "0.10.7"]
|
||||
[lein-environ "1.1.0"]]
|
||||
:profiles {:jar {:aot :all}
|
||||
:uberjar {:aot :all}}
|
||||
:profiles {:uberjar {:aot :all
|
||||
:omit-source true
|
||||
:uberjar-exclusions [#"beowulf\.scratch"]}}
|
||||
:release-tasks [["vcs" "assert-committed"]
|
||||
["change" "version" "leiningen.release/bump-version" "release"]
|
||||
["vcs" "commit"]
|
||||
|
@ -41,5 +34,6 @@
|
|||
["uberjar"]
|
||||
["change" "version" "leiningen.release/bump-version"]
|
||||
["vcs" "commit"]]
|
||||
|
||||
:target-path "target/%s"
|
||||
:url "https://github.com/simon-brooke/the-great-game")
|
||||
|
|
|
@ -1,563 +0,0 @@
|
|||
body {
|
||||
font-family: Helvetica, Arial, sans-serif;
|
||||
font-size: 15px;
|
||||
color: limegreen;
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
a {
|
||||
color: lime;
|
||||
}
|
||||
|
||||
a:active, a:hover {
|
||||
color: yellowgreen;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: green;
|
||||
}
|
||||
|
||||
pre, code {
|
||||
font-family: Monaco, DejaVu Sans Mono, Consolas, monospace;
|
||||
font-size: 9pt;
|
||||
margin: 15px 0;
|
||||
color: limegreen;
|
||||
background-color: #111;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-weight: normal;
|
||||
font-size: 29px;
|
||||
margin: 10px 0 2px 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-weight: normal;
|
||||
font-size: 25px;
|
||||
}
|
||||
|
||||
th, td {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
h5.license {
|
||||
margin: 9px 0 22px 0;
|
||||
color: lime;
|
||||
font-weight: normal;
|
||||
font-size: 12px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.document h1, .namespace-index h1 {
|
||||
font-size: 32px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
#header, #content, .sidebar {
|
||||
position: fixed;
|
||||
}
|
||||
|
||||
#header {
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 22px;
|
||||
color: limegreen;
|
||||
padding: 5px 7px;
|
||||
}
|
||||
|
||||
#content {
|
||||
top: 32px;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
overflow: auto;
|
||||
background: black;
|
||||
color: green;
|
||||
padding: 0 18px;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
position: fixed;
|
||||
top: 32px;
|
||||
bottom: 0;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.sidebar.primary {
|
||||
background: #080808;
|
||||
border-right: solid 1px forestgreen;
|
||||
left: 0;
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
.sidebar.secondary {
|
||||
background: #111;
|
||||
border-right: solid 1px darkgreen;
|
||||
left: 251px;
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
#content.namespace-index, #content.document {
|
||||
left: 251px;
|
||||
}
|
||||
|
||||
#content.namespace-docs {
|
||||
left: 452px;
|
||||
}
|
||||
|
||||
#content.document {
|
||||
padding-bottom: 10%;
|
||||
}
|
||||
|
||||
#header {
|
||||
background: #080808;
|
||||
box-shadow: 0 0 8px rgba(192, 255, 192, 0.4);
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
#header h1 {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 18px;
|
||||
font-weight: lighter;
|
||||
text-shadow: -1px -1px 0px #333;
|
||||
}
|
||||
|
||||
#header h1 .project-version {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.project-version {
|
||||
padding-left: 0.15em;
|
||||
}
|
||||
|
||||
#header a, .sidebar a {
|
||||
display: block;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#header h2 {
|
||||
float: right;
|
||||
font-size: 9pt;
|
||||
font-weight: normal;
|
||||
margin: 4px 3px;
|
||||
padding: 0;
|
||||
color: #5f5;
|
||||
}
|
||||
|
||||
#header h2 a {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.sidebar h3 {
|
||||
margin: 0;
|
||||
padding: 10px 13px 0 13px;
|
||||
font-size: 19px;
|
||||
font-weight: lighter;
|
||||
}
|
||||
|
||||
.sidebar h3 a {
|
||||
color: #4f4;
|
||||
}
|
||||
|
||||
.sidebar h3.no-link {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.sidebar ul {
|
||||
padding: 7px 0 6px 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.sidebar ul.index-link {
|
||||
padding-bottom: 4px;
|
||||
}
|
||||
|
||||
.sidebar li {
|
||||
display: block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.sidebar li a, .sidebar li .no-link {
|
||||
border-left: 3px solid transparent;
|
||||
padding: 0 10px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.sidebar li .no-link {
|
||||
display: block;
|
||||
color: #7F7;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.sidebar li .inner {
|
||||
display: inline-block;
|
||||
padding-top: 7px;
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
.sidebar li a, .sidebar li .tree {
|
||||
height: 31px;
|
||||
}
|
||||
|
||||
.depth-1 .inner { padding-left: 2px; }
|
||||
.depth-2 .inner { padding-left: 6px; }
|
||||
.depth-3 .inner { padding-left: 20px; }
|
||||
.depth-4 .inner { padding-left: 34px; }
|
||||
.depth-5 .inner { padding-left: 48px; }
|
||||
.depth-6 .inner { padding-left: 62px; }
|
||||
|
||||
.sidebar li .tree {
|
||||
display: block;
|
||||
float: left;
|
||||
position: relative;
|
||||
top: -10px;
|
||||
margin: 0 4px 0 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.sidebar li.depth-1 .tree {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.sidebar li .tree .top, .sidebar li .tree .bottom {
|
||||
display: block;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 7px;
|
||||
}
|
||||
|
||||
.sidebar li .tree .top {
|
||||
border-left: 1px solid yellowgreen;
|
||||
border-bottom: 1px solid yellowgreen;
|
||||
height: 19px;
|
||||
}
|
||||
|
||||
.sidebar li .tree .bottom {
|
||||
height: 22px;
|
||||
}
|
||||
|
||||
.sidebar li.branch .tree .bottom {
|
||||
border-left: 1px solid yellowgreen;
|
||||
}
|
||||
|
||||
.sidebar.primary li.current a {
|
||||
border-left: 3px solid goldenrod;
|
||||
color: goldenrod;
|
||||
}
|
||||
|
||||
.sidebar.secondary li.current a {
|
||||
border-left: 3px solid yellow;
|
||||
color: yellow;
|
||||
}
|
||||
|
||||
.namespace-index h2 {
|
||||
margin: 30px 0 0 0;
|
||||
}
|
||||
|
||||
.namespace-index h3 {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.namespace-index .topics {
|
||||
padding-left: 30px;
|
||||
margin: 11px 0 0 0;
|
||||
}
|
||||
|
||||
.namespace-index .topics li {
|
||||
padding: 5px 0;
|
||||
}
|
||||
|
||||
.namespace-docs h3 {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.public h3 {
|
||||
margin: 0;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.usage {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.public {
|
||||
margin: 0;
|
||||
border-top: 1px solid lime;
|
||||
padding-top: 14px;
|
||||
padding-bottom: 6px;
|
||||
}
|
||||
|
||||
.public:last-child {
|
||||
margin-bottom: 20%;
|
||||
}
|
||||
|
||||
.members .public:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.members {
|
||||
margin: 15px 0;
|
||||
}
|
||||
|
||||
.members h4 {
|
||||
color: lime;
|
||||
font-weight: normal;
|
||||
font-variant: small-caps;
|
||||
margin: 0 0 5px 0;
|
||||
}
|
||||
|
||||
.members .inner {
|
||||
padding-top: 5px;
|
||||
padding-left: 12px;
|
||||
margin-top: 2px;
|
||||
margin-left: 7px;
|
||||
border-left: 1px solid #5f5;
|
||||
}
|
||||
|
||||
#content .members .inner h3 {
|
||||
font-size: 12pt;
|
||||
}
|
||||
|
||||
.members .public {
|
||||
border-top: none;
|
||||
margin-top: 0;
|
||||
padding-top: 6px;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.members .public:first-child {
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
h4.type,
|
||||
h4.dynamic,
|
||||
h4.added,
|
||||
h4.deprecated {
|
||||
float: left;
|
||||
margin: 3px 10px 15px 0;
|
||||
font-size: 15px;
|
||||
font-weight: bold;
|
||||
font-variant: small-caps;
|
||||
}
|
||||
|
||||
.public h4.type,
|
||||
.public h4.dynamic,
|
||||
.public h4.added,
|
||||
.public h4.deprecated {
|
||||
font-size: 13px;
|
||||
font-weight: bold;
|
||||
margin: 3px 0 0 10px;
|
||||
}
|
||||
|
||||
.members h4.type,
|
||||
.members h4.added,
|
||||
.members h4.deprecated {
|
||||
margin-top: 1px;
|
||||
}
|
||||
|
||||
h4.type {
|
||||
color: #717171;
|
||||
}
|
||||
|
||||
h4.dynamic {
|
||||
color: #9933aa;
|
||||
}
|
||||
|
||||
h4.added {
|
||||
color: #7acc32;
|
||||
}
|
||||
|
||||
h4.deprecated {
|
||||
color: #880000;
|
||||
}
|
||||
|
||||
.namespace {
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.namespace:last-child {
|
||||
margin-bottom: 10%;
|
||||
}
|
||||
|
||||
.index {
|
||||
padding: 0;
|
||||
font-size: 80%;
|
||||
margin: 15px 0;
|
||||
line-height: 16px;
|
||||
}
|
||||
|
||||
.index * {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.index p {
|
||||
padding-right: 3px;
|
||||
}
|
||||
|
||||
.index li {
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
.index ul {
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.type-sig {
|
||||
clear: both;
|
||||
color: goldenrod;
|
||||
}
|
||||
|
||||
.type-sig pre {
|
||||
padding-top: 10px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.usage code {
|
||||
display: block;
|
||||
margin: 2px 0;
|
||||
color: limegreen;
|
||||
}
|
||||
|
||||
.usage code:first-child {
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 15px 0;
|
||||
}
|
||||
|
||||
.public p:first-child, .public pre.plaintext {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.doc {
|
||||
margin: 0 0 26px 0;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.public .doc {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.namespace-index .doc {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.namespace-index .namespace .doc {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.markdown p, .markdown li, .markdown dt, .markdown dd, .markdown td {
|
||||
line-height: 22px;
|
||||
}
|
||||
|
||||
.markdown li {
|
||||
padding: 2px 0;
|
||||
}
|
||||
|
||||
.markdown h2 {
|
||||
font-weight: normal;
|
||||
font-size: 25px;
|
||||
margin: 30px 0 10px 0;
|
||||
}
|
||||
|
||||
.markdown h3 {
|
||||
font-weight: normal;
|
||||
font-size: 20px;
|
||||
margin: 30px 0 0 0;
|
||||
}
|
||||
|
||||
.markdown h4 {
|
||||
font-size: 15px;
|
||||
margin: 22px 0 -4px 0;
|
||||
}
|
||||
|
||||
.doc, .public, .namespace .index {
|
||||
max-width: 680px;
|
||||
overflow-x: visible;
|
||||
}
|
||||
|
||||
.markdown pre > code {
|
||||
display: block;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.markdown pre > code, .src-link a {
|
||||
border: 1px solid lime;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.markdown code:not(.hljs), .src-link a {
|
||||
background: #111;
|
||||
}
|
||||
|
||||
pre.deps {
|
||||
display: inline-block;
|
||||
margin: 0 10px;
|
||||
border: 1px solid lime;
|
||||
border-radius: 2px;
|
||||
padding: 10px;
|
||||
background-color: #111;
|
||||
}
|
||||
|
||||
.markdown hr {
|
||||
border-style: solid;
|
||||
border-top: none;
|
||||
color: goldenrod;
|
||||
}
|
||||
|
||||
.doc ul, .doc ol {
|
||||
padding-left: 30px;
|
||||
}
|
||||
|
||||
.doc table {
|
||||
border-collapse: collapse;
|
||||
margin: 0 10px;
|
||||
}
|
||||
|
||||
.doc table td, .doc table th {
|
||||
border: 1px solid goldenrod;
|
||||
padding: 4px 6px;
|
||||
}
|
||||
|
||||
.doc table th {
|
||||
background: #111;
|
||||
}
|
||||
|
||||
.doc dl {
|
||||
margin: 0 10px 20px 10px;
|
||||
}
|
||||
|
||||
.doc dl dt {
|
||||
font-weight: bold;
|
||||
margin: 0;
|
||||
padding: 3px 0;
|
||||
border-bottom: 1px solid goldenrod;
|
||||
}
|
||||
|
||||
.doc dl dd {
|
||||
padding: 5px 0;
|
||||
margin: 0 0 5px 10px;
|
||||
}
|
||||
|
||||
.doc abbr {
|
||||
border-bottom: 1px dotted goldenrod;
|
||||
font-variant: none;
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
.src-link {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.src-link a {
|
||||
font-size: 70%;
|
||||
padding: 1px 4px;
|
||||
text-decoration: none;
|
||||
color: lime5bb;
|
||||
}
|
|
@ -1,97 +0,0 @@
|
|||
/*
|
||||
github.com style (c) Vasily Polovnyov <vast@whiteants.net>
|
||||
*/
|
||||
|
||||
.hljs {
|
||||
display: block;
|
||||
overflow-x: auto;
|
||||
padding: 0.5em;
|
||||
color: #333;
|
||||
background: #f8f8f8;
|
||||
}
|
||||
|
||||
.hljs-comment,
|
||||
.hljs-quote {
|
||||
color: #998;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.hljs-keyword,
|
||||
.hljs-selector-tag,
|
||||
.hljs-subst {
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.hljs-number,
|
||||
.hljs-literal,
|
||||
.hljs-variable,
|
||||
.hljs-template-variable,
|
||||
.hljs-tag .hljs-attr {
|
||||
color: #008080;
|
||||
}
|
||||
|
||||
.hljs-string,
|
||||
.hljs-doctag {
|
||||
color: #d14;
|
||||
}
|
||||
|
||||
.hljs-title,
|
||||
.hljs-section,
|
||||
.hljs-selector-id {
|
||||
color: #900;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.hljs-subst {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.hljs-type,
|
||||
.hljs-class .hljs-title {
|
||||
color: #458;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.hljs-tag,
|
||||
.hljs-name,
|
||||
.hljs-attribute {
|
||||
color: #000080;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.hljs-regexp,
|
||||
.hljs-link {
|
||||
color: #009926;
|
||||
}
|
||||
|
||||
.hljs-symbol,
|
||||
.hljs-bullet {
|
||||
color: #990073;
|
||||
}
|
||||
|
||||
.hljs-built_in,
|
||||
.hljs-builtin-name {
|
||||
color: #0086b3;
|
||||
}
|
||||
|
||||
.hljs-meta {
|
||||
color: #999;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.hljs-deletion {
|
||||
background: #fdd;
|
||||
}
|
||||
|
||||
.hljs-addition {
|
||||
background: #dfd;
|
||||
}
|
||||
|
||||
.hljs-emphasis {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.hljs-strong {
|
||||
font-weight: bold;
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
{:resources ["css/default.css" "css/highlight.css"]}
|
|
@ -12,7 +12,7 @@
|
|||
32767
|
||||
EXPR
|
||||
(LAMBDA
|
||||
(X Y) (COND ((NULL X) Y) (T (CONS (CAR X) (APPEND (CDR X) Y))))))
|
||||
(X Y) (COND ((NULL X) Y) ((QUOTE T) (CONS (CAR X) (APPEND (CDR X) Y))))))
|
||||
(APPLY 32767 SUBR (BEOWULF BOOTSTRAP APPLY))
|
||||
(ASSOC
|
||||
32767
|
||||
|
@ -20,9 +20,9 @@
|
|||
(LAMBDA
|
||||
(X L)
|
||||
(COND
|
||||
((NULL L) NIL)
|
||||
((NULL L) (QUOTE NIL))
|
||||
((AND (CONSP (CAR L)) (EQ (CAAR L) X)) (CAR L))
|
||||
(T (ASSOC X (CDR L)))))
|
||||
((QUOTE T) (ASSOC X (CDR L)))))
|
||||
SUBR (BEOWULF HOST ASSOC))
|
||||
(ATOM 32767 SUBR (BEOWULF HOST ATOM))
|
||||
(CAR 32767 SUBR (BEOWULF HOST CAR))
|
||||
|
@ -63,14 +63,14 @@
|
|||
(LAMBDA
|
||||
(X)
|
||||
(COND
|
||||
((NULL X) NIL)
|
||||
((ATOM X) X) (T (CONS (COPY (CAR X)) (COPY (CDR X)))))))
|
||||
((NULL X) (QUOTE NIL))
|
||||
((ATOM X) X) ((QUOTE T) (CONS (COPY (CAR X)) (COPY (CDR X)))))))
|
||||
(DEFINE 32767 SUBR (BEOWULF HOST DEFINE))
|
||||
(DIFFERENCE 32767 SUBR (BEOWULF HOST DIFFERENCE))
|
||||
(DIVIDE
|
||||
32767
|
||||
EXPR
|
||||
(LAMBDA (X Y) (CONS (QUOTIENT X Y) (CONS (REMAINDER X Y) NIL))))
|
||||
(LAMBDA (X Y) (CONS (QUOTIENT X Y) (CONS (REMAINDER X Y) (QUOTE NIL)))))
|
||||
(DOC 32767 SUBR (BEOWULF HOST DOC))
|
||||
(EFFACE
|
||||
32767
|
||||
|
@ -78,8 +78,8 @@
|
|||
(LAMBDA
|
||||
(X L)
|
||||
(COND
|
||||
((NULL L) NIL)
|
||||
((EQUAL X (CAR L)) (CDR L)) (T (RPLACD L (EFFACE X (CDR L)))))))
|
||||
((NULL L) (QUOTE NIL))
|
||||
((EQUAL X (CAR L)) (CDR L)) ((QUOTE T) (RPLACD L (EFFACE X (CDR L)))))))
|
||||
(ERROR 32767 SUBR (BEOWULF HOST ERROR))
|
||||
(EQ 32767 SUBR (BEOWULF HOST EQ))
|
||||
(EQUAL 32767 SUBR (BEOWULF HOST EQUAL))
|
||||
|
@ -91,12 +91,12 @@
|
|||
(GENSYM 32767 SUBR (BEOWULF HOST GENSYM))
|
||||
(GET
|
||||
32767
|
||||
;; EXPR
|
||||
;; (LAMBDA
|
||||
;; (X Y)
|
||||
;; (COND
|
||||
;; ((NULL X) NIL)
|
||||
;; ((EQ (CAR X) Y) (CAR (CDR X))) (T (GET (CDR X) Y))))
|
||||
EXPR
|
||||
(LAMBDA
|
||||
(X Y)
|
||||
(COND
|
||||
((NULL X) (QUOTE NIL))
|
||||
((EQ (CAR X) Y) (CAR (CDR X))) ((QUOTE T) (GET (CDR X) Y))))
|
||||
SUBR (BEOWULF HOST GET))
|
||||
(GREATERP 32767 SUBR (BEOWULF HOST GREATERP))
|
||||
(INTEROP 32767 SUBR (BEOWULF INTEROP INTEROP))
|
||||
|
@ -106,15 +106,15 @@
|
|||
(LAMBDA
|
||||
(X Y)
|
||||
(COND
|
||||
((NULL X) NIL)
|
||||
((NULL X) (QUOTE NIL))
|
||||
((MEMBER (CAR X) Y) (CONS (CAR X) (INTERSECTION (CDR X) Y)))
|
||||
(T (INTERSECTION (CDR X) Y)))))
|
||||
((QUOTE T) (INTERSECTION (CDR X) Y)))))
|
||||
(LENGTH
|
||||
32767
|
||||
EXPR
|
||||
(LAMBDA
|
||||
(L)
|
||||
(COND ((EQ NIL L) 0) ((CONSP (CDR L)) (ADD1 (LENGTH (CDR L)))) (T 1))))
|
||||
(COND ((EQ NIL L) 0) ((CONSP (CDR L)) (ADD1 (LENGTH (CDR L)))) (T 0))))
|
||||
(LESSP 32767 SUBR (BEOWULF HOST LESSP))
|
||||
(MAPLIST
|
||||
32767
|
||||
|
@ -122,7 +122,7 @@
|
|||
(LAMBDA
|
||||
(L F)
|
||||
(COND
|
||||
((NULL L) NIL) (T (CONS (F (CAR L)) (MAPLIST (CDR L) F))))))
|
||||
((NULL L) NIL) ((QUOTE T) (CONS (F (CAR L)) (MAPLIST (CDR L) F))))))
|
||||
(MEMBER
|
||||
32767
|
||||
EXPR
|
||||
|
@ -130,15 +130,14 @@
|
|||
(A X)
|
||||
(COND
|
||||
((NULL X) (QUOTE F))
|
||||
((EQ A (CAR X)) T) (T (MEMBER A (CDR X))))))
|
||||
((EQ A (CAR X)) (QUOTE T)) ((QUOTE T) (MEMBER A (CDR X))))))
|
||||
(MINUSP 32767 EXPR (LAMBDA (X) (LESSP X 0)))
|
||||
(NOT 32767 EXPR (LAMBDA (X) (COND (X NIL) (T T))))
|
||||
(NOT 32767 EXPR (LAMBDA (X) (COND (X (QUOTE NIL)) ((QUOTE T) (QUOTE T)))))
|
||||
(NULL
|
||||
32767 EXPR (LAMBDA (X) (COND ((EQUAL X NIL) T) (T (QUOTE F)))))
|
||||
32767 EXPR (LAMBDA (X) (COND ((EQUAL X NIL) (QUOTE T)) (T (QUOTE F)))))
|
||||
(NUMBERP 32767 SUBR (BEOWULF HOST NUMBERP))
|
||||
(OBLIST 32767 SUBR (BEOWULF HOST OBLIST))
|
||||
(ONEP 32767 EXPR (LAMBDA (X) (EQ X 1)))
|
||||
(OR 32767 SUBR (BEOWULF HOST OR))
|
||||
(PAIR
|
||||
32767
|
||||
EXPR
|
||||
|
@ -156,12 +155,11 @@
|
|||
(X Y A)
|
||||
(COND
|
||||
((NULL X) A)
|
||||
(T (CONS (CONS (CAR X) (CAR Y)) (PAIRLIS (CDR X) (CDR Y) A)))))
|
||||
((QUOTE T) (CONS (CONS (CAR X) (CAR Y)) (PAIRLIS (CDR X) (CDR Y) A)))))
|
||||
SUBR (BEOWULF HOST PAIRLIS))
|
||||
(PLUS 32767 SUBR (BEOWULF HOST PLUS))
|
||||
(PRETTY 32767)
|
||||
(PRINT 32767)
|
||||
(PROG 32767 FSUBR (BEOWULF HOST PROG))
|
||||
(PROP
|
||||
32767
|
||||
EXPR
|
||||
|
@ -169,7 +167,7 @@
|
|||
(X Y U)
|
||||
(COND
|
||||
((NULL X) (U))
|
||||
((EQ (CAR X) Y) (CDR X)) (T (PROP (CDR X) Y U)))))
|
||||
((EQ (CAR X) Y) (CDR X)) ((QUOTE T) (PROP (CDR X) Y U)))))
|
||||
(QUOTE 32767 EXPR (LAMBDA (X) X))
|
||||
(QUOTIENT 32767 SUBR (BEOWULF HOST QUOTIENT))
|
||||
(RANGE
|
||||
|
@ -178,7 +176,7 @@
|
|||
(LAMBDA
|
||||
(N M)
|
||||
(COND
|
||||
((LESSP M N) NIL) (T (CONS N (RANGE (ADD1 N) M))))))
|
||||
((LESSP M N) (QUOTE NIL)) ((QUOTE T) (CONS N (RANGE (ADD1 N) M))))))
|
||||
(READ 32767 SUBR (BEOWULF READ READ))
|
||||
(REMAINDER 32767 SUBR (BEOWULF HOST REMAINDER))
|
||||
(REPEAT
|
||||
|
@ -187,11 +185,6 @@
|
|||
(LAMBDA (N X) (COND ((EQ N 0) NIL) (T (CONS X (REPEAT (SUB1 N) X))))))
|
||||
(RPLACA 32767 SUBR (BEOWULF HOST RPLACA))
|
||||
(RPLACD 32767 SUBR (BEOWULF HOST RPLACD))
|
||||
(SEARCH 32767 EXPR
|
||||
(LAMBDA (X P F U)
|
||||
(COND ((NULL X) (U X))
|
||||
((P X) (F X))
|
||||
((QUOTE T) (SEARCH (CDR X) P F U)))))
|
||||
(SET 32767 SUBR (BEOWULF HOST SET))
|
||||
(SUB1 32767 EXPR (LAMBDA (N) (DIFFERENCE N 1)) SUBR (BEOWULF HOST SUB1))
|
||||
(SUB2
|
||||
|
@ -200,19 +193,9 @@
|
|||
(LAMBDA
|
||||
(A Z)
|
||||
(COND
|
||||
((NULL A) Z) ((EQ (CAAR A) Z) (CDAR A)) (T (SUB2 (CDAR A) Z)))))
|
||||
((NULL A) Z) ((EQ (CAAR A) Z) (CDAR A)) ((QUOTE T) (SUB2 (CDAR A) Z)))))
|
||||
(SUBLIS
|
||||
32767 EXPR
|
||||
(LAMBDA (X Y)
|
||||
(COND ((NULL X) Y)
|
||||
((NULL Y) Y)
|
||||
((QUOTE T) (SEARCH X
|
||||
(LAMBDA (J) (EQUAL Y (CAAR J)))
|
||||
(LAMBDA (J) (CDAR J))
|
||||
(LAMBDA (J) (COND ((ATOM Y) Y)
|
||||
((QUOTE T) (CONS
|
||||
(SUBLIS X (CAR Y))
|
||||
(SUBLIS X (CDR Y)))))))))))
|
||||
32767 EXPR (LAMBDA (A Y) (COND ((ATOM Y) (SUB2 A Y)) ((QUOTE T) (CONS)))))
|
||||
(SUBST
|
||||
32767
|
||||
EXPR
|
||||
|
@ -221,7 +204,7 @@
|
|||
(COND
|
||||
((EQUAL Y Z) X)
|
||||
((ATOM Z) Z)
|
||||
(T (CONS (SUBST X Y (CAR Z)) (SUBST X Y (CDR Z)))))))
|
||||
((QUOTE T) (CONS (SUBST X Y (CAR Z)) (SUBST X Y (CDR Z)))))))
|
||||
(SYSIN 32767 SUBR (BEOWULF IO SYSIN))
|
||||
(SYSOUT 32767 SUBR (BEOWULF IO SYSOUT))
|
||||
(TERPRI 32767)
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
not[x] = [x = F -> T; x = NIL -> T; T -> F]
|
|
@ -1,5 +0,0 @@
|
|||
# page 63
|
||||
|
||||
search[x; p; f; u] = [null[x] -> u[x];
|
||||
p[x] -> f[x];
|
||||
T -> search[cdr[x]; p; f; u]]
|
|
@ -7,19 +7,4 @@ sub2[a; z] = [null[a] -> z;
|
|||
T -> sub2[cdar[a]; z]]
|
||||
|
||||
sublis[a; y] = [atom[y] -> sub2[a; y];
|
||||
T -> cons[sublis[a; car[y]];
|
||||
sublis[a; cdr[y]]]]
|
||||
|
||||
;; this is the version from page 61
|
||||
|
||||
sublis[x;y] = [null[x] -> y;
|
||||
null[y] -> y;
|
||||
T -> search[x;
|
||||
λ[[j]; equal[y; caar[j]]];
|
||||
λ[[j]; cdar[j]];
|
||||
λ[[j]; [atom[y] -> y;
|
||||
T -> cons[sublis[x; car[y]];
|
||||
sublis[x; cdr[y]]]]]]]
|
||||
|
||||
;; the test for this is:
|
||||
;; (SUBLIS '((X . SHAKESPEARE) (Y . (THE TEMPEST))) '(X WROTE Y))
|
||||
T -> cons[]]
|
|
@ -9,8 +9,7 @@
|
|||
ALLUPPERCASE are Lisp 1.5 functions (although written in Clojure) and that
|
||||
therefore all arguments must be numbers, symbols or `beowulf.cons_cell.ConsCell`
|
||||
objects."
|
||||
(:require [beowulf.cons-cell :refer [F make-beowulf-list make-cons-cell
|
||||
pretty-print T]]
|
||||
(:require [beowulf.cons-cell :refer [make-beowulf-list make-cons-cell T]]
|
||||
[beowulf.host :refer [ASSOC ATOM CAAR CADAR CADDR CADR CAR CDR GET
|
||||
LIST NUMBERP PAIRLIS traced?]]
|
||||
[beowulf.oblist :refer [*options* NIL oblist]])
|
||||
|
@ -37,169 +36,20 @@
|
|||
;;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(declare APPLY EVAL prog-eval)
|
||||
(declare APPLY EVAL)
|
||||
|
||||
;;;; The PROGram feature ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(def find-target
|
||||
(memoize
|
||||
(fn [target body]
|
||||
(loop [body' body]
|
||||
(cond
|
||||
(= body' NIL) (throw (ex-info (str "Mislar GO miercels: `" target "`")
|
||||
{:phase :lisp
|
||||
:function 'PROG
|
||||
:type :lisp
|
||||
:code :A6
|
||||
:target target}))
|
||||
(= (.getCar body') target) body'
|
||||
:else (recur (.getCdr body')))))))
|
||||
|
||||
(defn- prog-cond
|
||||
"Like `EVCON`, q.v. except using `prog-eval` instead of `EVAL` and not
|
||||
throwing an error if no clause matches."
|
||||
[clauses vars env depth]
|
||||
(loop [clauses' clauses]
|
||||
(if-not (= clauses' NIL)
|
||||
(let [test (prog-eval (CAAR clauses') vars env depth)]
|
||||
(if (not (#{NIL F} test))
|
||||
(prog-eval (CADAR clauses') vars env depth)
|
||||
(recur (.getCdr clauses'))))
|
||||
NIL)))
|
||||
|
||||
(defn- merge-vars [vars env]
|
||||
(reduce
|
||||
#(make-cons-cell
|
||||
(make-cons-cell %2 (@vars %2))
|
||||
env)
|
||||
env
|
||||
(keys @vars)))
|
||||
|
||||
(defn prog-eval
|
||||
"Like `EVAL`, q.v., except handling symbols, and expressions starting
|
||||
`GO`, `RETURN`, `SET` and `SETQ` specially."
|
||||
[expr vars env depth]
|
||||
(cond
|
||||
(number? expr) expr
|
||||
(symbol? expr) (@vars expr)
|
||||
(instance? ConsCell expr) (case (.getCar expr)
|
||||
COND (prog-cond (.getCdr expr)
|
||||
vars env depth)
|
||||
GO (make-cons-cell
|
||||
'*PROGGO* (.getCar (.getCdr expr)))
|
||||
RETURN (make-cons-cell
|
||||
'*PROGRETURN*
|
||||
(prog-eval (.getCar (.getCdr expr))
|
||||
vars env depth))
|
||||
SET (let [v (CADDR expr)]
|
||||
(swap! vars
|
||||
assoc
|
||||
(prog-eval (CADR expr)
|
||||
vars env depth)
|
||||
(prog-eval (CADDR expr)
|
||||
vars env depth))
|
||||
v)
|
||||
SETQ (let [v (CADDR expr)]
|
||||
(swap! vars
|
||||
assoc
|
||||
(CADR expr)
|
||||
(prog-eval v
|
||||
vars env depth))
|
||||
v)
|
||||
;; else
|
||||
(beowulf.bootstrap/EVAL expr
|
||||
(merge-vars vars env)
|
||||
depth))))
|
||||
|
||||
(defn PROG
|
||||
"The accursed `PROG` feature. See page 71 of the manual.
|
||||
|
||||
Lisp 1.5 introduced `PROG`, and most Lisps have been stuck with it ever
|
||||
since. It introduces imperative programming into what should be a pure
|
||||
functional language, and consequently it's going to be a pig to implement.
|
||||
|
||||
Broadly, `PROG` is a variadic pseudo function called as a `FEXPR` (or
|
||||
possibly an `FSUBR`, although I'm not presently sure that would even work.)
|
||||
|
||||
The arguments, which are unevaluated, are a list of forms, the first of
|
||||
which is expected to be a list of symbols which will be treated as names
|
||||
of variables within the program, and the rest of which (the 'program body')
|
||||
are either lists or symbols. Lists are treated as Lisp expressions which
|
||||
may be evaulated in turn. Symbols are treated as targets for the `GO`
|
||||
statement.
|
||||
|
||||
**GO:**
|
||||
A `GO` statement takes the form of `(GO target)`, where
|
||||
`target` should be one of the symbols which occur at top level among that
|
||||
particular invocation of `PROG`s arguments. A `GO` statement may occur at
|
||||
top level in a PROG, or in a clause of a `COND` statement in a `PROG`, but
|
||||
not in a function called from the `PROG` statement. When a `GO` statement
|
||||
is evaluated, execution should transfer immediately to the expression which
|
||||
is the argument list immediately following the symbol which is its target.
|
||||
|
||||
If the target is not found, an error with the code `A6` should be thrown.
|
||||
|
||||
**RETURN:**
|
||||
A `RETURN` statement takes the form `(RETURN value)`, where
|
||||
`value` is any value. Following the evaluation of a `RETURN` statement,
|
||||
the `PROG` should immediately exit without executing any further
|
||||
expressions, returning the value.
|
||||
|
||||
**SET and SETQ:**
|
||||
In addition to the above, if a `SET` or `SETQ` expression is encountered
|
||||
in any expression within the `PROG` body, it should affect not the global
|
||||
object list but instead only the local variables of the program.
|
||||
|
||||
**COND:**
|
||||
In **strict** mode, when in normal execution, a `COND` statement none of
|
||||
whose clauses match should not return `NIL` but should throw an error with
|
||||
the code `A3`... *except* that inside a `PROG` body, it should not do so.
|
||||
*sigh*.
|
||||
|
||||
**Flow of control:**
|
||||
Apart from the exceptions specified above, expressions in the program body
|
||||
are evaluated sequentially. If execution reaches the end of the program
|
||||
body, `NIL` is returned.
|
||||
|
||||
Got all that?
|
||||
|
||||
Good."
|
||||
[program env depth]
|
||||
(let [trace (traced? 'PROG)
|
||||
vars (atom (reduce merge (map #(assoc {} % NIL) (.getCar program))))
|
||||
body (.getCdr program)
|
||||
targets (set (filter symbol? body))]
|
||||
(when trace (do
|
||||
(println "Program:")
|
||||
(pretty-print program))) ;; for debugging
|
||||
(loop [cursor body]
|
||||
(let [step (.getCar cursor)]
|
||||
(when trace (do (println "Executing step: " step)
|
||||
(println " with vars: " @vars)))
|
||||
(cond (= cursor NIL) NIL
|
||||
(symbol? step) (recur (.getCdr cursor))
|
||||
:else (let [v (prog-eval (.getCar cursor) vars env depth)]
|
||||
(when trace (println " --> " v))
|
||||
(if (instance? ConsCell v)
|
||||
(case (.getCar v)
|
||||
*PROGGO* (let [target (.getCdr v)]
|
||||
(if (targets target)
|
||||
(recur (find-target target body))
|
||||
(throw (ex-info (str "Uncynlic GO miercels `"
|
||||
target "`")
|
||||
{:phase :lisp
|
||||
:function 'PROG
|
||||
:args program
|
||||
:type :lisp
|
||||
:code :A6
|
||||
:target target
|
||||
:targets targets}))))
|
||||
*PROGRETURN* (.getCdr v)
|
||||
;; else
|
||||
(recur (.getCdr cursor)))
|
||||
(recur (.getCdr cursor)))))))))
|
||||
|
||||
;;;; Tracing execution ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
(defn try-resolve-subroutine
|
||||
"Attempt to resolve this `subr` with these `arg`."
|
||||
[subr args]
|
||||
(when (and subr (not= subr NIL))
|
||||
(try @(resolve subr)
|
||||
(catch Throwable any
|
||||
(throw (ex-info "Failed to resolve subroutine"
|
||||
{:phase :apply
|
||||
:function subr
|
||||
:args args
|
||||
:type :beowulf}
|
||||
any))))))
|
||||
|
||||
(defn- trace-call
|
||||
"Show a trace of a call to the function named by this `function-symbol`
|
||||
|
@ -228,46 +78,21 @@
|
|||
(first (remove #(= % NIL) (map #(GET s %)
|
||||
indicators))))))
|
||||
|
||||
;;;; APPLY ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn try-resolve-subroutine
|
||||
"Attempt to resolve this `subr` with these `args`."
|
||||
[subr args]
|
||||
(when (and subr (not= subr NIL))
|
||||
(try @(resolve subr)
|
||||
(catch Throwable any
|
||||
(throw (ex-info "þegnung (SUBR) ne āfand"
|
||||
{:phase :apply
|
||||
:function subr
|
||||
:args args
|
||||
:type :beowulf}
|
||||
any))))))
|
||||
|
||||
(defn- apply-symbolic
|
||||
"Apply this `funtion-symbol` to these `args` in this `environment` and
|
||||
return the result."
|
||||
[^Symbol function-symbol args ^ConsCell environment depth]
|
||||
(trace-call function-symbol args depth)
|
||||
(let [lisp-fn (value function-symbol '(EXPR FEXPR))
|
||||
args' (cond (= NIL args) args
|
||||
(empty? args) NIL
|
||||
(instance? ConsCell args) args
|
||||
:else (make-beowulf-list args))
|
||||
(let [lisp-fn ;; (try
|
||||
(value function-symbol '(EXPR FEXPR))
|
||||
;; (catch Exception any (when (traced? function-symbol)
|
||||
;; (println any))))
|
||||
subr (value function-symbol '(SUBR FSUBR))
|
||||
host-fn (try-resolve-subroutine subr args')
|
||||
host-fn (try-resolve-subroutine subr args)
|
||||
result (cond (and lisp-fn
|
||||
(not= lisp-fn NIL)) (APPLY lisp-fn args' environment depth)
|
||||
host-fn (try
|
||||
(apply host-fn (when (instance? ConsCell args') args'))
|
||||
(catch Exception any
|
||||
(throw (ex-info (str "Uncynlic þegnung: "
|
||||
(.getMessage any))
|
||||
{:phase :apply
|
||||
:function function-symbol
|
||||
:args args
|
||||
:type :beowulf}
|
||||
any))))
|
||||
:else (ex-info "þegnung ne āfand"
|
||||
(not= lisp-fn NIL)) (APPLY lisp-fn args environment depth)
|
||||
host-fn (apply host-fn (when (instance? ConsCell args) args))
|
||||
:else (ex-info "No function found"
|
||||
{:phase :apply
|
||||
:function function-symbol
|
||||
:args args
|
||||
|
@ -287,7 +112,7 @@
|
|||
(let [result (cond
|
||||
(= NIL function) (if (:strict *options*)
|
||||
NIL
|
||||
(throw (ex-info "NIL sí ne þegnung"
|
||||
(throw (ex-info "NIL is not a function"
|
||||
{:phase :apply
|
||||
:function "NIL"
|
||||
:args args
|
||||
|
@ -307,7 +132,7 @@
|
|||
LAMBDA (EVAL
|
||||
(CADDR function)
|
||||
(PAIRLIS (CADR function) args environment) depth)
|
||||
(throw (ex-info "Ungecnáwen wyrþan sí þegnung-weard"
|
||||
(throw (ex-info "Unrecognised value in function position"
|
||||
{:phase :apply
|
||||
:function function
|
||||
:args args
|
||||
|
@ -315,31 +140,18 @@
|
|||
(trace-response 'APPLY result depth)
|
||||
result))
|
||||
|
||||
;;;; EVAL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn- EVCON
|
||||
"Inner guts of primitive COND. All `clauses` are assumed to be
|
||||
`beowulf.cons-cell/ConsCell` objects. Note that tests in Lisp 1.5
|
||||
often return `F`, not `NIL`, on failure. If no clause matches,
|
||||
then, strictly, we throw an error with code `:A3`.
|
||||
often return `F`, not `NIL`, on failure.
|
||||
|
||||
See pages 13 and 71 of the Lisp 1.5 Programmers Manual."
|
||||
See page 13 of the Lisp 1.5 Programmers Manual."
|
||||
[clauses env depth]
|
||||
(loop [clauses' clauses]
|
||||
(if-not (= clauses' NIL)
|
||||
(let [test (EVAL (CAAR clauses') env depth)]
|
||||
(if (not (#{NIL F} test))
|
||||
;; (and (not= test NIL) (not= test F))
|
||||
(EVAL (CADAR clauses') env depth)
|
||||
(recur (.getCdr clauses'))))
|
||||
(if (:strict *options*)
|
||||
(throw (ex-info "Ne ġefōg dǣl in COND"
|
||||
{:phase :eval
|
||||
:function 'COND
|
||||
:args (list clauses)
|
||||
:type :lisp
|
||||
:code :A3}))
|
||||
NIL))))
|
||||
(let [test (EVAL (CAAR clauses) env depth)]
|
||||
(if
|
||||
(and (not= test NIL) (not= test 'F))
|
||||
(EVAL (CADAR clauses) env depth)
|
||||
(EVCON (CDR clauses) env depth))))
|
||||
|
||||
(defn- EVLIS
|
||||
"Map `EVAL` across this list of `args` in the context of this
|
||||
|
@ -355,18 +167,18 @@
|
|||
|
||||
(defn- eval-symbolic
|
||||
[expr env depth]
|
||||
(let [v (ASSOC expr env)
|
||||
(let [v (value expr (list 'APVAL))
|
||||
indent (apply str (repeat depth "-"))]
|
||||
(when (traced? 'EVAL)
|
||||
(println (str indent ": EVAL: sceald bindele: " (or v "nil"))))
|
||||
(if (instance? ConsCell v)
|
||||
(.getCdr v)
|
||||
(let [v' (value expr (list 'APVAL))]
|
||||
(println (str indent ": EVAL: deep binding (" expr " . " (or v "nil") ")")))
|
||||
(if (and v (not= v NIL))
|
||||
v
|
||||
(let [v' (ASSOC expr env)]
|
||||
(when (traced? 'EVAL)
|
||||
(println (str indent ": EVAL: deóp bindele: (" expr " . " (or v' "nil") ")")))
|
||||
(if v'
|
||||
v'
|
||||
(throw (ex-info "Ne tácen-bindele āfand"
|
||||
(println (str indent ": EVAL: shallow binding: " (or v' "nil"))))
|
||||
(if (and v' (not= v' NIL))
|
||||
(.getCdr v')
|
||||
(throw (ex-info "No binding for symbol found"
|
||||
{:phase :eval
|
||||
:function 'EVAL
|
||||
:args (list expr env depth)
|
||||
|
@ -385,12 +197,10 @@
|
|||
(let [expr' (if (and (coll? expr) (not (instance? ConsCell expr)))
|
||||
(make-beowulf-list expr)
|
||||
expr)]
|
||||
(EVAL expr' NIL 0)))
|
||||
(EVAL expr' @oblist 0)))
|
||||
([expr env depth]
|
||||
(trace-call 'EVAL (list expr env depth) depth)
|
||||
(let [result (cond
|
||||
(= NIL expr) NIL ;; it was probably a mistake to make Lisp
|
||||
;; NIL distinct from Clojure nil
|
||||
(= (NUMBERP expr) T) expr
|
||||
(symbol? expr) (eval-symbolic expr env depth)
|
||||
(string? expr) (if (:strict *options*)
|
||||
|
@ -402,10 +212,9 @@
|
|||
:expr expr}))
|
||||
(symbol expr))
|
||||
(= (ATOM (CAR expr)) T) (case (CAR expr)
|
||||
COND (EVCON (CDR expr) env depth)
|
||||
FUNCTION (LIST 'FUNARG (CADR expr))
|
||||
PROG (PROG (CDR expr) env depth)
|
||||
QUOTE (CADR expr)
|
||||
FUNCTION (LIST 'FUNARG (CADR expr))
|
||||
COND (EVCON (CDR expr) env depth)
|
||||
;; else
|
||||
(APPLY
|
||||
(CAR expr)
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
(set! (. this CAR) value)
|
||||
this)
|
||||
(throw (ex-info
|
||||
(str "Uncynlic miercels in RPLACA: `" value "` (" (type value) ")")
|
||||
(str "Invalid value in RPLACA: `" value "` (" (type value) ")")
|
||||
{:cause :bad-value
|
||||
:detail :rplaca}))))
|
||||
|
||||
|
@ -92,7 +92,7 @@
|
|||
(set! (. this CDR) value)
|
||||
this)
|
||||
(throw (ex-info
|
||||
(str "Uncynlic miercels in RPLACD: `" value "` (" (type value) ")")
|
||||
(str "Invalid value in RPLACD: `" value "` (" (type value) ")")
|
||||
{:cause :bad-value
|
||||
:detail :rplaca}))))
|
||||
|
||||
|
@ -248,7 +248,7 @@
|
|||
(try
|
||||
(ConsCell. car cdr (gensym "c"))
|
||||
(catch Exception any
|
||||
(throw (ex-info "Ne meahte cræfte cons cell" {:car car
|
||||
(throw (ex-info "Cound not construct cons cell" {:car car
|
||||
:cdr cdr} any)))))
|
||||
|
||||
(defn make-beowulf-list
|
||||
|
@ -269,6 +269,6 @@
|
|||
:else
|
||||
NIL)
|
||||
(catch Exception any
|
||||
(throw (ex-info "Ne meahte cræfte Beowulf líste"
|
||||
(throw (ex-info "Could not construct Beowulf list"
|
||||
{:content x}
|
||||
any)))))
|
||||
|
|
|
@ -30,10 +30,7 @@
|
|||
;;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(def stop-word
|
||||
"The word which, if submitted an an input line, will cause Beowulf to quit.
|
||||
Question: should this be `forlǣte`?"
|
||||
"STOP")
|
||||
(def stop-word "STOP")
|
||||
|
||||
(def cli-options
|
||||
[["-f FILEPATH" "--file-path FILEPATH"
|
||||
|
@ -46,12 +43,12 @@
|
|||
["-h" "--help"]
|
||||
["-p PROMPT" "--prompt PROMPT" "Set the REPL prompt to PROMPT"
|
||||
:default "Sprecan::"]
|
||||
["-r SYSOUTFILE" "--read SYSOUTFILE" "Read Lisp system from file SYSOUTFILE"
|
||||
["-r INITFILE" "--read INITFILE" "Read Lisp system from file INITFILE"
|
||||
:default default-sysout
|
||||
:validate [#(and
|
||||
(.exists (io/file %))
|
||||
(.canRead (io/file %)))
|
||||
"Could not find sysout file"]]
|
||||
"Could not find initfile"]]
|
||||
["-s" "--strict" "Strictly interpret the Lisp 1.5 language, without extensions."]
|
||||
["-t" "--time" "Time evaluations."]])
|
||||
|
||||
|
@ -127,6 +124,6 @@
|
|||
:quit nil
|
||||
;; default
|
||||
(do
|
||||
(println "STÆFLEAHTER: " (.getMessage e))
|
||||
(println "ERROR: " (.getMessage e))
|
||||
(pprint data)))
|
||||
(println e))))))))
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*manual-url* page-url]]
|
||||
[beowulf.oblist :refer [NIL oblist]]
|
||||
[clojure.java.browse :refer [browse-url]]
|
||||
[clojure.string :as s]))
|
||||
[clojure.string :as s ]))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;
|
||||
|
@ -60,6 +60,7 @@
|
|||
(when (keyword? key)
|
||||
(key (get-metadata-for-function function)))))
|
||||
|
||||
|
||||
(defn- get-metadata-for-entry [entry key]
|
||||
(let [fn ((host-functions) (symbol (first entry)))]
|
||||
(get-metadata-for-function fn key)))
|
||||
|
@ -68,25 +69,13 @@
|
|||
"Try to work out what this `entry` from the oblist actually
|
||||
represents."
|
||||
[entry]
|
||||
(let [interpretation {'APVAL "Lisp variable"
|
||||
'EXPR "Lisp lambda function"
|
||||
'FEXPR "Lisp nlambda function"
|
||||
'SUBR "Host lambda function"
|
||||
'FSUBR "Host nlambda function"}]
|
||||
(s/join ", "
|
||||
(remove nil?
|
||||
(map
|
||||
#(when (some #{%} entry) (interpretation %))
|
||||
(keys interpretation))))))
|
||||
;; (cond
|
||||
;; (= (nth entry 2) 'EXPR) "Lisp function"
|
||||
;; (= (nth entry 2) 'FEXPR) "Labeled form"
|
||||
;; ((host-functions) (first entry)) (try (if (fn? (eval (symbol ((host-functions) (first entry)))))
|
||||
;; "Host function"
|
||||
;; "Host variable")
|
||||
;; (catch Exception _
|
||||
;; "?Host macro?"))
|
||||
;; :else "Lisp variable"))
|
||||
(cond
|
||||
(= (second entry) 'LAMBDA) "Lisp function"
|
||||
(= (second entry) 'LABEL) "Labeled form"
|
||||
((host-functions) (first entry)) (if (fn? (eval (symbol ((host-functions) (first entry)))))
|
||||
"Host function"
|
||||
"Host variable")
|
||||
:else "Lisp variable"))
|
||||
|
||||
(defn- format-clj-signature
|
||||
"Format the signature of the Clojure function represented by `symbol` for
|
||||
|
@ -98,7 +87,7 @@
|
|||
(map
|
||||
(fn [l]
|
||||
(s/join (concat (list "(" symbol " ")
|
||||
(s/join " " (map #(s/upper-case (str %)) l)) (list ")"))))
|
||||
(s/join " " (map #(s/upper-case (str %)) l)) (list ")"))))
|
||||
arglists))))
|
||||
|
||||
(defn infer-signature
|
||||
|
@ -113,18 +102,17 @@
|
|||
|
||||
(defn infer-implementation
|
||||
[entry]
|
||||
(or (:implementation (index (keyword (first entry)))) "?"))
|
||||
;; (case (second entry)
|
||||
;; LAMBDA (format "%s-fn" (second entry))
|
||||
;; LABEL (format "%s-fn" (second entry))
|
||||
;; (or (:implementation (index (keyword (first entry)))) (str entry))))
|
||||
(case (second entry)
|
||||
LAMBDA (format "%s-fn" (second entry))
|
||||
LABEL (format "%s-fn" (second entry))
|
||||
(or (:implementation (index (keyword (first entry)))) (str entry))))
|
||||
|
||||
(defn find-documentation
|
||||
"Find appropriate documentation for this `entry` from the oblist."
|
||||
[entry]
|
||||
(let [k (keyword (first entry))]
|
||||
(cond
|
||||
(some #{'SUBR 'FSUBR} entry) (if-let [doc (get-metadata-for-entry entry :doc)]
|
||||
(= (count entry) 1) (if-let [doc (get-metadata-for-entry entry :doc)]
|
||||
(s/replace doc "\n" " ")
|
||||
"?")
|
||||
(k index) (str "see manual pages " (format-page-references k))
|
||||
|
@ -171,12 +159,12 @@
|
|||
web browser."
|
||||
[symbol]
|
||||
(let [doc (get-metadata-for-function symbol :doc)]
|
||||
(if-let [pages (:page-nos (index (keyword symbol)))]
|
||||
(browse-url (page-url (first pages)))
|
||||
(if doc
|
||||
(println doc)
|
||||
(throw (ex-info "No documentation found"
|
||||
{:phase :host
|
||||
:function 'DOC
|
||||
:args (list symbol)
|
||||
:type :beowulf}))))))
|
||||
(if-let [pages (:page-nos (index (keyword symbol)))]
|
||||
(browse-url (page-url (first pages)))
|
||||
(if doc
|
||||
(println doc)
|
||||
(throw (ex-info "No documentation found"
|
||||
{:phase :host
|
||||
:function 'DOC
|
||||
:args (list symbol)
|
||||
:type :beowulf}))))))
|
|
@ -2,8 +2,7 @@
|
|||
"provides Lisp 1.5 functions which can't be (or can't efficiently
|
||||
be) implemented in Lisp 1.5, which therefore need to be implemented in the
|
||||
host language, in this case Clojure."
|
||||
(:require [beowulf.cons-cell :refer [F make-beowulf-list make-cons-cell
|
||||
pretty-print T]] ;; note hyphen - this is Clojure...
|
||||
(:require [beowulf.cons-cell :refer [F make-beowulf-list make-cons-cell T]] ;; note hyphen - this is Clojure...
|
||||
[beowulf.gendoc :refer [open-doc]]
|
||||
[beowulf.oblist :refer [*options* NIL oblist]]
|
||||
[clojure.set :refer [union]]
|
||||
|
@ -41,7 +40,7 @@
|
|||
this `symbol`."
|
||||
[symbol]
|
||||
(when (:strict *options*)
|
||||
(throw (ex-info (format "%s ne āfand innan Lisp 1.5" symbol)
|
||||
(throw (ex-info (format "%s is not available in Lisp 1.5" symbol)
|
||||
{:type :strict
|
||||
:phase :host
|
||||
:function symbol})))
|
||||
|
@ -58,30 +57,41 @@
|
|||
"Return the item indicated by the first pointer of a pair. NIL is treated
|
||||
specially: the CAR of NIL is NIL."
|
||||
[x]
|
||||
(cond
|
||||
(= x NIL) NIL
|
||||
(instance? ConsCell x) (or (.getCar x) NIL)
|
||||
:else (throw (ex-info
|
||||
(str "Ne can tace CAR of `" x "` (" (.getName (.getClass x)) ")")
|
||||
{:phase :host
|
||||
:function 'CAR
|
||||
:args (list x)
|
||||
:type :beowulf}))))
|
||||
(if
|
||||
(= x NIL) NIL
|
||||
(try
|
||||
(or (.getCar x) NIL)
|
||||
(catch Exception any
|
||||
(throw (ex-info
|
||||
(str "Cannot take CAR of `" x "` (" (.getName (.getClass x)) ")")
|
||||
{:phase :host
|
||||
:function 'CAR
|
||||
:args (list x)
|
||||
:type :beowulf}
|
||||
;; startlingly, Lisp 1.5 did not flag an error when you took the
|
||||
;; CAR of something that wasn't cons cell. The result, as the
|
||||
;; manual says (page 56), could be garbage.
|
||||
any))))))
|
||||
|
||||
(defn CDR
|
||||
"Return the item indicated by the second pointer of a pair. NIL is treated
|
||||
specially: the CDR of NIL is NIL."
|
||||
[x]
|
||||
(cond
|
||||
(= x NIL) NIL
|
||||
(instance? ConsCell x) (or (.getCdr x) NIL)
|
||||
:else (throw (ex-info
|
||||
(str "Ne can tace CDR of `" x "` (" (.getName (.getClass x)) ")")
|
||||
{:phase :host
|
||||
:function 'CDR
|
||||
:args (list x)
|
||||
:type :beowulf}))))
|
||||
|
||||
(if
|
||||
(= x NIL) NIL
|
||||
(try
|
||||
(.getCdr x)
|
||||
(catch Exception any
|
||||
(throw (ex-info
|
||||
(str "Cannot take CDR of `" x "` (" (.getName (.getClass x)) ")")
|
||||
{:phase :host
|
||||
:function 'CDR
|
||||
:args (list x)
|
||||
:type :beowulf}
|
||||
;; startlingly, Lisp 1.5 did not flag an error when you took the
|
||||
;; CAR of something that wasn't cons cell. The result, as the
|
||||
;; manual says (page 56), could be garbage.
|
||||
any))))))
|
||||
|
||||
(defn uaf
|
||||
"Universal access function; `l` is expected to be an arbitrary LISP list, `path`
|
||||
|
@ -165,14 +175,14 @@
|
|||
:type :beowulf}
|
||||
any))))
|
||||
(throw (ex-info
|
||||
(str "Un-ġefōg þing in RPLACA: `" value "` (" (type value) ")")
|
||||
(str "Invalid value in RPLACA: `" value "` (" (type value) ")")
|
||||
{:cause :bad-value
|
||||
:phase :host
|
||||
:function :rplaca
|
||||
:args (list cell value)
|
||||
:type :beowulf})))
|
||||
(throw (ex-info
|
||||
(str "Uncynlic miercels in RPLACA: `" cell "` (" (type cell) ")")
|
||||
(str "Invalid cell in RPLACA: `" cell "` (" (type cell) ")")
|
||||
{:cause :bad-cell
|
||||
:phase :host
|
||||
:function :rplaca
|
||||
|
@ -205,14 +215,14 @@
|
|||
:type :beowulf}
|
||||
any))))
|
||||
(throw (ex-info
|
||||
(str "Un-ġefōg þing in RPLACD: `" value "` (" (type value) ")")
|
||||
(str "Invalid value in RPLACD: `" value "` (" (type value) ")")
|
||||
{:cause :bad-value
|
||||
:phase :host
|
||||
:function :rplacd
|
||||
:args (list cell value)
|
||||
:type :beowulf})))
|
||||
(throw (ex-info
|
||||
(str "Uncynlic miercels in RPLACD: `" cell "` (" (type cell) ")")
|
||||
(str "Invalid cell in RPLACD: `" cell "` (" (type cell) ")")
|
||||
{:cause :bad-cell
|
||||
:phase :host
|
||||
:detail :rplacd
|
||||
|
@ -278,13 +288,10 @@
|
|||
In `beowulf.host` principally because I don't yet feel confident to define
|
||||
varargs functions in Lisp."
|
||||
[& args]
|
||||
;; (println "AND: " args " type: " (type args) " seq? " (seq? args))
|
||||
;; (println " filtered: " (seq (filter #{F NIL} args)))
|
||||
(cond (= NIL args) T
|
||||
(seq? args) (if (seq (filter #{F NIL} args)) F T)
|
||||
(not (#{NIL F} (.getCar args))) (AND (.getCdr args))
|
||||
:else T))
|
||||
|
||||
|
||||
(defn OR
|
||||
"`T` if and only if at least one of my `args` evaluates to something other
|
||||
than either `F` or `NIL`, else `F`.
|
||||
|
@ -292,12 +299,9 @@
|
|||
In `beowulf.host` principally because I don't yet feel confident to define
|
||||
varargs functions in Lisp."
|
||||
[& args]
|
||||
;; (println "OR: " args " type: " (type args) " seq? " (seq? args))
|
||||
;; (println " filtered: " (seq (remove #{F NIL} args)))
|
||||
(cond (= NIL args) F
|
||||
(seq? args) (if (seq (remove #{F NIL} args)) T F)
|
||||
:else F))
|
||||
|
||||
(not (#{NIL F} (.getCar args))) T
|
||||
:else (OR (.getCdr args))))
|
||||
|
||||
;;;; Operations on lists ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
|
@ -410,11 +414,11 @@
|
|||
(defn ERROR
|
||||
"Throw an error"
|
||||
[& args]
|
||||
(throw (ex-info "LISP STÆFLEAHTER" {:args args
|
||||
:phase :eval
|
||||
:function 'ERROR
|
||||
:type :lisp
|
||||
:code (or (first args) 'A1)})))
|
||||
(throw (ex-info "LISP ERROR" {:args args
|
||||
:phase :eval
|
||||
:function 'ERROR
|
||||
:type :lisp
|
||||
:code (or (first args) 'A1)})))
|
||||
|
||||
;;;; Assignment and the object list ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
@ -473,26 +477,19 @@
|
|||
first argument is always an atom. Since it's `ASSOC` and `EVAL` which I
|
||||
need to make work, I'm going to assume that page 59 is wrong."
|
||||
[symbol indicator]
|
||||
(let [binding (ASSOC symbol @oblist)
|
||||
val (cond
|
||||
(= binding NIL) NIL
|
||||
(= magic-marker
|
||||
(CADR binding)) (loop [b binding]
|
||||
;; (println "GET loop, seeking " indicator ":")
|
||||
;; (pretty-print b)
|
||||
(if (instance? ConsCell b)
|
||||
(if (= (CAR b) indicator)
|
||||
(CADR b) ;; <- this is what we should actually be returning
|
||||
(recur (CDR b)))
|
||||
NIL))
|
||||
:else (throw
|
||||
(ex-info "Misformatted property list (missing magic marker)"
|
||||
{:phase :host
|
||||
:function :get
|
||||
:args (list symbol indicator)
|
||||
:type :beowulf})))]
|
||||
;; (println "<< GET returning: " val)
|
||||
val))
|
||||
(let [binding (ASSOC symbol @oblist)]
|
||||
(cond
|
||||
(= binding NIL) NIL
|
||||
(= magic-marker (CADR binding)) (loop [b binding]
|
||||
(cond (= b NIL) NIL
|
||||
(= (CAR b) indicator) (CADR b)
|
||||
:else (recur (CDR b))))
|
||||
:else (throw
|
||||
(ex-info "Misformatted property list (missing magic marker)"
|
||||
{:phase :host
|
||||
:function :get
|
||||
:args (list symbol indicator)
|
||||
:type :beowulf})))))
|
||||
|
||||
(defn DEFLIST
|
||||
"For each pair in this association list `a-list`, set the property with this
|
||||
|
@ -568,4 +565,4 @@
|
|||
argument was, or was not, a cons cell."
|
||||
[o]
|
||||
(when (lax? 'CONSP)
|
||||
(if (instance? ConsCell o) 'T 'F)))
|
||||
(if (instance? o ConsCell) 'T 'F)))
|
|
@ -100,16 +100,16 @@
|
|||
(catch java.lang.ClassNotFoundException _ nil)) q-name
|
||||
:else (throw
|
||||
(ex-info
|
||||
(str "INTEROP: ungecnáwen þegnung `" fn-symbol "`")
|
||||
(str "INTEROP: unknown function `" fn-symbol "`")
|
||||
{:cause :interop
|
||||
:detail :not-found
|
||||
:name fn-symbol
|
||||
:also-tried l-name})))
|
||||
args' (to-clojure args)]
|
||||
;; (print (str "INTEROP: eahtiende `" (cons f args') "`"))
|
||||
(print (str "INTEROP: evaluating `" (cons f args') "`"))
|
||||
(flush)
|
||||
(let [result (eval (conj args' f))] ;; this has the potential to blow up the world
|
||||
;; (println (str "; ágiefende `" result "`"))
|
||||
(println (str "; returning `" result "`"))
|
||||
(cond
|
||||
(instance? beowulf.cons_cell.ConsCell result) result
|
||||
(coll? result) (make-beowulf-list result)
|
||||
|
@ -118,12 +118,12 @@
|
|||
(number? result) result
|
||||
:else (throw
|
||||
(ex-info
|
||||
(str "INTEROP: Ne can eahtiende `" result "` to Lisp 1.5.")
|
||||
(str "INTEROP: Cannot return `" result "` to Lisp 1.5.")
|
||||
{:cause :interop
|
||||
:detail :not-representable
|
||||
:result result})))))
|
||||
(throw
|
||||
(ex-info
|
||||
(str "INTEROP ne āfand innan Lisp 1.5.")
|
||||
(str "INTEROP not allowed in strict mode.")
|
||||
{:cause :interop
|
||||
:detail :strict}))))
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
;;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(def ^:constant default-sysout "lisp1.5.lsp")
|
||||
(def ^:constant default-sysout "resources/lisp1.5.lsp")
|
||||
|
||||
(defn- full-path
|
||||
[fp]
|
||||
|
@ -105,15 +105,12 @@
|
|||
(pretty-print output)
|
||||
)))))
|
||||
|
||||
(defn resolve-subr
|
||||
(defn- resolve-subr
|
||||
"If this oblist `entry` references a subroutine, attempt to fix up that
|
||||
reference."
|
||||
([entry]
|
||||
(or (resolve-subr entry 'SUBR)
|
||||
(resolve-subr entry 'FSUBR)))
|
||||
([entry prop]
|
||||
(cond (= entry NIL) NIL
|
||||
(= (CAR entry) prop) (try
|
||||
[entry]
|
||||
(cond (= entry NIL) NIL
|
||||
(= (CAR entry) 'SUBR) (try
|
||||
(make-cons-cell
|
||||
(CAR entry)
|
||||
(make-cons-cell
|
||||
|
@ -121,11 +118,11 @@
|
|||
(CADR entry))
|
||||
(CDDR entry)))
|
||||
(catch Exception _
|
||||
(print "Warnung: ne can āfinde "
|
||||
(print "Warning: failed to resolve "
|
||||
(CADR entry))
|
||||
(CDDR entry)))
|
||||
:else (make-cons-cell
|
||||
(CAR entry) (resolve-subr (CDR entry))))))
|
||||
(CAR entry) (resolve-subr (CDR entry)))))
|
||||
|
||||
|
||||
(defn- resolve-subroutines
|
||||
|
@ -154,18 +151,18 @@
|
|||
|
||||
**NOTE THAT** this is an extension function, not available in strct mode."
|
||||
([]
|
||||
(SYSIN (or (:read *options*) (str "resources/" default-sysout))))
|
||||
(SYSIN (or (:read *options*) default-sysout)))
|
||||
([filename]
|
||||
(let [fp (file (full-path (str filename)))
|
||||
file (when (and (.exists fp) (.canRead fp)) fp)
|
||||
res (try (resource filename)
|
||||
(catch Throwable _ nil))
|
||||
content (try (READ (slurp (or file res)))
|
||||
(catch Throwable _
|
||||
(throw (ex-info "Ne can ārǣde"
|
||||
(catch Throwable any
|
||||
(throw (ex-info "Could not read from file"
|
||||
{:context "SYSIN"
|
||||
:filename filename
|
||||
:filepath fp}))))]
|
||||
:filepath fp}
|
||||
any))))]
|
||||
(swap! oblist
|
||||
#(when (or % (seq content))
|
||||
(resolve-subroutines content))))))
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
Both these extensions can be disabled by using the `--strict` command line
|
||||
switch."
|
||||
(:require ;; [beowulf.reader.char-reader :refer [read-chars]]
|
||||
(:require [beowulf.reader.char-reader :refer [read-chars]]
|
||||
[beowulf.reader.generate :refer [generate]]
|
||||
[beowulf.reader.parser :refer [parse]]
|
||||
[beowulf.reader.simplify :refer [simplify]]
|
||||
|
@ -79,7 +79,7 @@
|
|||
parse-tree (parse source)]
|
||||
(if (instance? Failure parse-tree)
|
||||
(doall (println (number-lines source parse-tree))
|
||||
(throw (ex-info "Ne can forstande " (assoc parse-tree :source source))))
|
||||
(throw (ex-info "Parse failed" (assoc parse-tree :source source))))
|
||||
(generate (simplify parse-tree)))))
|
||||
|
||||
(defn read-from-console
|
||||
|
@ -99,7 +99,7 @@
|
|||
the final Lisp reader. `input` should be either a string representation of a LISP
|
||||
expression, or else an input stream. A single form will be read."
|
||||
([]
|
||||
(gsp (read-from-console)))
|
||||
(gsp (read-chars)))
|
||||
([input]
|
||||
(cond
|
||||
(empty? input) (READ)
|
||||
|
|
|
@ -15,14 +15,9 @@
|
|||
rather than the strings which were supplied to `READ`);
|
||||
4. <Tab> offers potential auto-completions taken from the value of `(OBLIST)`, ideally the
|
||||
current value, not the value at the time the session started;
|
||||
5. <Back-arrow> and <Forward-arrow> offer movement and editing within the line.
|
||||
|
||||
TODO: There are multiple problems with JLine; a better solution might be
|
||||
to start from here:
|
||||
https://stackoverflow.com/questions/7931988/how-to-manipulate-control-characters"
|
||||
;; (:import [org.jline.reader LineReader LineReaderBuilder]
|
||||
;; [org.jline.terminal TerminalBuilder])
|
||||
)
|
||||
5. <Back-arrow> and <Forward-arrow> offer movement and editing within the line."
|
||||
(:import [org.jline.reader LineReader LineReaderBuilder]
|
||||
[org.jline.terminal TerminalBuilder]))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;
|
||||
|
@ -49,27 +44,27 @@
|
|||
;; looks as though you'd need a DPhil in JLine to write it, and I don't have
|
||||
;; the time.
|
||||
|
||||
;; (def get-reader
|
||||
;; "Return a reader, first constructing it if necessary.
|
||||
(def get-reader
|
||||
"Return a reader, first constructing it if necessary.
|
||||
|
||||
;; **NOTE THAT** this is not settled API. The existence and call signature of
|
||||
;; this function is not guaranteed in future versions."
|
||||
;; (memoize (fn []
|
||||
;; (let [term (.build (.system (TerminalBuilder/builder) true))]
|
||||
;; (.build (.terminal (LineReaderBuilder/builder) term))))))
|
||||
**NOTE THAT** this is not settled API. The existence and call signature of
|
||||
this function is not guaranteed in future versions."
|
||||
(memoize (fn []
|
||||
(let [term (.build (.system (TerminalBuilder/builder) true))]
|
||||
(.build (.terminal (LineReaderBuilder/builder) term))))))
|
||||
|
||||
;; (defn read-chars
|
||||
;; "A drop-in replacement for `clojure.core/read-line`, except that line editing
|
||||
;; and history should be enabled.
|
||||
(defn read-chars
|
||||
"A drop-in replacement for `clojure.core/read-line`, except that line editing
|
||||
and history should be enabled.
|
||||
|
||||
;; **NOTE THAT** this does not work yet, but it is in the API because I hope
|
||||
;; that it will work later!"
|
||||
;; []
|
||||
;; (let [eddie (get-reader)]
|
||||
;; (loop [s (.readLine eddie)]
|
||||
;; (if (and (= (count (re-seq #"\(" s))
|
||||
;; (count (re-seq #"\)" s)))
|
||||
;; (= (count (re-seq #"\[]" s))
|
||||
;; (count (re-seq #"\]" s))))
|
||||
;; s
|
||||
;; (recur (str s " " (.readLine eddie)))))))
|
||||
**NOTE THAT** this does not work yet, but it is in the API because I hope
|
||||
that it will work later!"
|
||||
[]
|
||||
(let [eddie (get-reader)]
|
||||
(loop [s (.readLine eddie)]
|
||||
(if (and (= (count (re-seq #"\(" s))
|
||||
(count (re-seq #"\)" s)))
|
||||
(= (count (re-seq #"\[]" s))
|
||||
(count (re-seq #"\]" s))))
|
||||
s
|
||||
(recur (str s " " (.readLine eddie)))))))
|
|
@ -59,8 +59,7 @@
|
|||
[beowulf.reader.macros :refer [expand-macros]]
|
||||
[beowulf.oblist :refer [NIL]]
|
||||
[clojure.math.numeric-tower :refer [expt]]
|
||||
[clojure.string :refer [upper-case]]
|
||||
[clojure.tools.trace :refer [deftrace]]))
|
||||
[clojure.string :refer [upper-case]]))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;
|
||||
|
@ -87,37 +86,37 @@
|
|||
(defn gen-cond-clause
|
||||
"Generate a cond clause from this simplified parse tree fragment `p`;
|
||||
returns `nil` if `p` does not represent a cond clause."
|
||||
[p context]
|
||||
[p]
|
||||
(when
|
||||
(and (coll? p) (= :cond-clause (first p)))
|
||||
(make-beowulf-list
|
||||
(list (if (= (nth p 1) [:quoted-expr [:atom "T"]])
|
||||
'T
|
||||
(generate (nth p 1) context))
|
||||
(generate (nth p 2) context)))))
|
||||
(generate (nth p 1)))
|
||||
(generate (nth p 2))))))
|
||||
|
||||
(defn gen-cond
|
||||
"Generate a cond statement from this simplified parse tree fragment `p`;
|
||||
returns `nil` if `p` does not represent a (MEXPR) cond statement."
|
||||
[p context]
|
||||
[p]
|
||||
(when
|
||||
(and (coll? p) (= :cond (first p)))
|
||||
(make-beowulf-list
|
||||
(cons
|
||||
'COND
|
||||
(map
|
||||
#(generate % (if (= context :mexpr) :cond-mexpr context))
|
||||
generate
|
||||
(rest p))))))
|
||||
|
||||
(defn gen-fn-call
|
||||
"Generate a function call from this simplified parse tree fragment `p`;
|
||||
returns `nil` if `p` does not represent a (MEXPR) function call."
|
||||
[p context]
|
||||
[p]
|
||||
(when
|
||||
(and (coll? p) (= :fncall (first p)) (= :mvar (first (second p))))
|
||||
(make-cons-cell
|
||||
(generate (second p) context)
|
||||
(generate (nth p 2) context))))
|
||||
(generate (second p))
|
||||
(generate (nth p 2)))))
|
||||
|
||||
|
||||
(defn gen-dot-terminated-list
|
||||
|
@ -138,50 +137,38 @@
|
|||
(generate (first p))
|
||||
(gen-dot-terminated-list (rest p)))))
|
||||
|
||||
;; null[x] = [x = NIL -> T; T -> F]
|
||||
;; [:defn
|
||||
;; [:mexpr [:fncall [:mvar "null"] [:bindings [:args [:mexpr [:mvar "x"]]]]]]
|
||||
;; "="
|
||||
;; [:mexpr [:cond
|
||||
;; [:cond-clause [:mexpr [:iexpr [:lhs [:mexpr [:mvar "x"]]] [:iop "="] [:rhs [:mexpr [:mconst "NIL"]]]]] [:mexpr [:mconst "T"]]]
|
||||
;; [:cond-clause [:mexpr [:mconst "T"]] [:mexpr [:mconst "F"]]]]]]
|
||||
|
||||
(defn generate-defn
|
||||
[tree context]
|
||||
(if (= :mexpr (first tree))
|
||||
(generate-defn (second tree) context)
|
||||
(make-beowulf-list
|
||||
(list 'PUT
|
||||
(list 'QUOTE (generate (-> tree second second second) context))
|
||||
(list 'QUOTE 'EXPR)
|
||||
(list 'QUOTE
|
||||
(cons 'LAMBDA
|
||||
(list (generate (nth (-> tree second second) 2) context)
|
||||
(generate (nth tree 3) context))))))))
|
||||
[tree]
|
||||
(make-beowulf-list
|
||||
(list 'SET
|
||||
(list 'QUOTE (generate (-> tree second second)))
|
||||
(list 'QUOTE
|
||||
(cons 'LAMBDA
|
||||
(cons (generate (nth (second tree) 2))
|
||||
(map generate (-> tree rest rest rest))))))))
|
||||
|
||||
(defn gen-iexpr
|
||||
[tree context]
|
||||
(let [bundle (reduce #(assoc %1 (first %2) %2)
|
||||
{}
|
||||
[tree]
|
||||
(let [bundle (reduce #(assoc %1 (first %2) %2)
|
||||
{}
|
||||
(rest tree))]
|
||||
(list (generate (:iop bundle) context)
|
||||
(generate (:lhs bundle) context)
|
||||
(generate (:rhs bundle) context))))
|
||||
(list (generate (:iop bundle))
|
||||
(generate (:lhs bundle))
|
||||
(generate (:rhs bundle)))))
|
||||
|
||||
(defn generate-set
|
||||
"Actually not sure what the mexpr representation of set looks like"
|
||||
[tree context]
|
||||
[tree]
|
||||
(throw (ex-info "Not Yet Implemented" {:feature "generate-set"})))
|
||||
|
||||
(defn generate-assign
|
||||
"Generate an assignment statement based on this `tree`. If the thing
|
||||
being assigned to is a function signature, then we have to do something
|
||||
different to if it's an atom."
|
||||
[tree context]
|
||||
[tree]
|
||||
(case (first (second tree))
|
||||
:fncall (generate-defn tree context)
|
||||
:mexpr (map #(generate % context) (rest (second tree)))
|
||||
(:mvar :atom) (generate-set tree context)))
|
||||
:fncall (generate-defn tree)
|
||||
(:mvar :atom) (generate-set tree)))
|
||||
|
||||
(defn strip-leading-zeros
|
||||
"`read-string` interprets strings with leading zeros as octal; strip
|
||||
|
@ -200,77 +187,69 @@
|
|||
(defn generate
|
||||
"Generate lisp structure from this parse tree `p`. It is assumed that
|
||||
`p` has been simplified."
|
||||
([p]
|
||||
(generate p :expr))
|
||||
([p context]
|
||||
(try
|
||||
(expand-macros
|
||||
(if
|
||||
(coll? p)
|
||||
(case (first p)
|
||||
:λ "LAMBDA"
|
||||
:λexpr (make-cons-cell
|
||||
(generate (nth p 1) context)
|
||||
(make-cons-cell (generate (nth p 2) context)
|
||||
(generate (nth p 3) context)))
|
||||
:args (make-beowulf-list (map #(generate % context) (rest p)))
|
||||
:atom (symbol (second p))
|
||||
:bindings (generate (second p) context)
|
||||
:body (make-beowulf-list (map #(generate % context) (rest p)))
|
||||
(:coefficient :exponent) (generate (second p) context)
|
||||
:cond (gen-cond p (if (= context :mexpr) :cond-mexpr context))
|
||||
:cond-clause (gen-cond-clause p context)
|
||||
:decimal (read-string (apply str (map second (rest p))))
|
||||
:defn (generate-defn p context)
|
||||
:dotted-pair (make-cons-cell
|
||||
(generate (nth p 1) context)
|
||||
(generate (nth p 2) context))
|
||||
:fncall (gen-fn-call p context)
|
||||
:iexpr (gen-iexpr p context)
|
||||
:integer (read-string (strip-leading-zeros (second p)))
|
||||
:iop (case (second p)
|
||||
"/" 'DIFFERENCE
|
||||
"=" 'EQUAL
|
||||
">" 'GREATERP
|
||||
"<" 'LESSP
|
||||
"+" 'PLUS
|
||||
"*" 'TIMES
|
||||
[p]
|
||||
(try
|
||||
(expand-macros
|
||||
(if
|
||||
(coll? p)
|
||||
(case (first p)
|
||||
:λ "LAMBDA"
|
||||
:λexpr (make-cons-cell
|
||||
(generate (nth p 1))
|
||||
(make-cons-cell (generate (nth p 2))
|
||||
(generate (nth p 3))))
|
||||
:args (make-beowulf-list (map generate (rest p)))
|
||||
:atom (symbol (second p))
|
||||
:bindings (generate (second p))
|
||||
:body (make-beowulf-list (map generate (rest p)))
|
||||
(:coefficient :exponent) (generate (second p))
|
||||
:cond (gen-cond p)
|
||||
:cond-clause (gen-cond-clause p)
|
||||
:decimal (read-string (apply str (map second (rest p))))
|
||||
:defn (generate-assign p)
|
||||
:dotted-pair (make-cons-cell
|
||||
(generate (nth p 1))
|
||||
(generate (nth p 2)))
|
||||
:fncall (gen-fn-call p)
|
||||
:iexpr (gen-iexpr p)
|
||||
:integer (read-string (strip-leading-zeros (second p)))
|
||||
:iop (case (second p)
|
||||
"/" 'DIFFERENCE
|
||||
"=" 'EQUAL
|
||||
">" 'GREATERP
|
||||
"<" 'LESSP
|
||||
"+" 'PLUS
|
||||
"*" 'TIMES
|
||||
;; else
|
||||
(throw (ex-info "Unrecognised infix operator symbol"
|
||||
{:phase :generate
|
||||
:fragment p})))
|
||||
:list (gen-dot-terminated-list (rest p))
|
||||
(:lhs :rhs) (generate (second p) context)
|
||||
:mexpr (generate (second p) (if (= context :cond-mexpr) context :mexpr))
|
||||
:mconst (if (= context :cond-mexpr)
|
||||
(case (second p)
|
||||
("T" "F" "NIL") (symbol (second p))
|
||||
;; else
|
||||
(list 'QUOTE (symbol (second p))))
|
||||
;; else
|
||||
(list 'QUOTE (symbol (second p))))
|
||||
:mvar (symbol (upper-case (second p)))
|
||||
:number (generate (second p) context)
|
||||
:octal (let [n (read-string (strip-leading-zeros (second p) "0"))
|
||||
scale (generate (nth p 3) context)]
|
||||
(* n (expt 8 scale)))
|
||||
(throw (ex-info "Unrecognised infix operator symbol"
|
||||
{:phase :generate
|
||||
:fragment p})))
|
||||
:list (gen-dot-terminated-list (rest p))
|
||||
(:lhs :rhs) (generate (second p))
|
||||
:mexpr (generate (second p))
|
||||
:mconst (make-beowulf-list
|
||||
(list 'QUOTE (symbol (upper-case (second p)))))
|
||||
:mvar (symbol (upper-case (second p)))
|
||||
:number (generate (second p))
|
||||
:octal (let [n (read-string (strip-leading-zeros (second p) "0"))
|
||||
scale (generate (nth p 3))]
|
||||
(* n (expt 8 scale)))
|
||||
|
||||
;; the quote read macro (which probably didn't exist in Lisp 1.5, but...)
|
||||
:quoted-expr (make-beowulf-list (list 'QUOTE (generate (second p) context)))
|
||||
:scale-factor (if
|
||||
(empty? (second p)) 0
|
||||
(read-string (strip-leading-zeros (second p))))
|
||||
:scientific (let [n (generate (second p) context)
|
||||
exponent (generate (nth p 3) context)]
|
||||
(* n (expt 10 exponent)))
|
||||
:sexpr (generate (second p) :sexpr)
|
||||
:subr (symbol (second p))
|
||||
:quoted-expr (make-beowulf-list (list 'QUOTE (generate (second p))))
|
||||
:scale-factor (if
|
||||
(empty? (second p)) 0
|
||||
(read-string (strip-leading-zeros (second p))))
|
||||
:scientific (let [n (generate (second p))
|
||||
exponent (generate (nth p 3))]
|
||||
(* n (expt 10 exponent)))
|
||||
:subr (symbol (second p))
|
||||
|
||||
;; default
|
||||
(throw (ex-info (str "Unrecognised head: " (first p))
|
||||
{:generating p})))
|
||||
p))
|
||||
(catch Throwable any
|
||||
(throw (ex-info "Could not generate"
|
||||
{:generating p}
|
||||
any))))))
|
||||
(throw (ex-info (str "Unrecognised head: " (first p))
|
||||
{:generating p})))
|
||||
p))
|
||||
(catch Throwable any
|
||||
(throw (ex-info "Could not generate"
|
||||
{:generating p}
|
||||
any)))))
|
||||
|
|
|
@ -51,21 +51,21 @@
|
|||
|
||||
"exprs := expr | exprs;"
|
||||
"mexpr := λexpr | fncall | defn | cond | mvar | mconst | iexpr | number | mexpr comment;
|
||||
λexpr := λ lsqb bindings semi-colon opt-space body opt-space rsqb;
|
||||
λ := 'λ' | 'lambda';
|
||||
λexpr := λ lsqb bindings semi-colon body rsqb;
|
||||
λ := 'λ';
|
||||
bindings := lsqb args rsqb | lsqb rsqb;
|
||||
body := (opt-space mexpr semi-colon)* opt-space mexpr;
|
||||
body := (mexpr semi-colon opt-space)* mexpr;
|
||||
fncall := fn-name bindings;
|
||||
lsqb := '[';
|
||||
rsqb := ']';
|
||||
lbrace := '{';
|
||||
rbrace := '}';
|
||||
lbrace := '{';
|
||||
rbrace := '}';
|
||||
defn := mexpr opt-space '=' opt-space mexpr;
|
||||
cond := lsqb (opt-space cond-clause semi-colon opt-space)* cond-clause rsqb;
|
||||
cond-clause := mexpr opt-space arrow opt-space mexpr opt-space;
|
||||
arrow := '->';
|
||||
args := arg | (opt-space arg semi-colon opt-space)* opt-space arg opt-space;
|
||||
arg := mexpr;
|
||||
arg := mexpr | sexpr;
|
||||
fn-name := mvar;
|
||||
mvar := #'[a-z][a-z0-9]*';
|
||||
mconst := #'[A-Z][A-Z0-9]*';
|
||||
|
|
|
@ -110,7 +110,7 @@
|
|||
(throw
|
||||
(ex-info "Cannot parse meta expressions in strict mode"
|
||||
{:cause :strict}))
|
||||
[:mexpr (simplify-tree (second p) :mexpr)])
|
||||
(simplify-tree (second p) :mexpr))
|
||||
:list (if
|
||||
(= context :mexpr)
|
||||
[:fncall
|
||||
|
@ -118,7 +118,7 @@
|
|||
[:args (apply vector (map simplify-tree (rest p)))]]
|
||||
(map #(simplify-tree % context) p))
|
||||
:raw (first (remove empty? (map simplify-tree (rest p))))
|
||||
:sexpr [:sexpr (simplify-tree (second p) :sexpr)]
|
||||
:sexpr (simplify-tree (second p) :sexpr)
|
||||
;;default
|
||||
p)))
|
||||
:else p)))
|
||||
|
|
|
@ -1,27 +1,20 @@
|
|||
(ns beowulf.bootstrap-test
|
||||
(:require [beowulf.bootstrap :refer [EVAL]]
|
||||
[beowulf.cons-cell :refer [F make-cons-cell T]]
|
||||
[beowulf.host :refer [ASSOC ATOM ATOM? CAAAAR CADDDR CADDR CADR
|
||||
CAR CDR EQ EQUAL PAIRLIS]]
|
||||
(:require [clojure.test :refer [deftest testing is]]
|
||||
[beowulf.cons-cell :refer [make-cons-cell T F]]
|
||||
[beowulf.host :refer [ASSOC ATOM ATOM? CAR CAAAAR CADR
|
||||
CADDR CADDDR CDR EQ EQUAL
|
||||
PAIRLIS]]
|
||||
[beowulf.oblist :refer [NIL]]
|
||||
[beowulf.read :refer [gsp READ]]
|
||||
[clojure.test :refer [deftest is testing]]))
|
||||
[beowulf.read :refer [gsp]]))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;
|
||||
;;; This file is primarily tests of the functions in `beowulf.bootstrap` - which
|
||||
;;; This file is primarily tests of the functions in `beowulf.eval` - which
|
||||
;;; are Clojure functions, but aim to provide sufficient functionality that
|
||||
;;; Beowulf can get up to the level of running its own code.
|
||||
;;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn- reps
|
||||
"'Read eval print string', or 'read eval print single'.
|
||||
Reads and evaluates one input string, and returns the
|
||||
output string."
|
||||
[input]
|
||||
(with-out-str (print (EVAL (READ input)))))
|
||||
|
||||
(deftest atom-tests
|
||||
(testing "ATOM"
|
||||
(let [expected T
|
||||
|
@ -70,12 +63,12 @@
|
|||
(is (= actual expected) "A is CAR of (A B C D)"))
|
||||
(is (thrown-with-msg?
|
||||
Exception
|
||||
#"Ne can tace CAR of `.*"
|
||||
#"Cannot take CAR of `.*"
|
||||
(CAR 'T))
|
||||
"Can't take the CAR of an atom")
|
||||
(is (thrown-with-msg?
|
||||
Exception
|
||||
#"Ne can tace CAR of `.*"
|
||||
#"Cannot take CAR of `.*"
|
||||
(CAR 7))
|
||||
"Can't take the CAR of a number"))
|
||||
(testing "CDR"
|
||||
|
@ -89,12 +82,12 @@
|
|||
(is (= (CAR actual) expected) "the CAR of that cons-cell is B"))
|
||||
(is (thrown-with-msg?
|
||||
Exception
|
||||
#"Ne can tace CDR of `.*"
|
||||
#"Cannot take CDR of `.*"
|
||||
(CDR 'T))
|
||||
"Can't take the CDR of an atom")
|
||||
(is (thrown-with-msg?
|
||||
Exception
|
||||
#"Ne can tace CDR of `.*"
|
||||
#"Cannot take CDR of `.*"
|
||||
(CDR 7))
|
||||
"Can't take the CDR of a number"))
|
||||
(let [s (gsp "((((1 . 2) 3)(4 5) 6)(7 (8 9) (10 11 12) 13) 14 (15 16) 17)")]
|
||||
|
@ -203,3 +196,13 @@
|
|||
'D
|
||||
(gsp "((A . (M N)) (B . (CAR X)) (C . (QUOTE M)) (C . (CDR X)))")))]
|
||||
(is (= actual expected)))))
|
||||
|
||||
;; TODO: need to reimplement this in lisp_test
|
||||
;; (deftest sublis-tests
|
||||
;; (testing "sublis"
|
||||
;; (let [expected "(SHAKESPEARE WROTE (THE TEMPEST))"
|
||||
;; actual (print-str
|
||||
;; (SUBLIS
|
||||
;; (gsp "((X . SHAKESPEARE) (Y . (THE TEMPEST)))")
|
||||
;; (gsp "(X WROTE Y)")))]
|
||||
;; (is (= actual expected)))))
|
||||
|
|
|
@ -15,12 +15,12 @@
|
|||
(is (= actual expected)))
|
||||
(is (thrown-with-msg?
|
||||
Exception
|
||||
#"Un-ġefōg þing in RPLACA.*"
|
||||
#"Invalid value in RPLACA.*"
|
||||
(RPLACA (make-beowulf-list '(A B C D E)) "F"))
|
||||
"You can't represent a string in Lisp 1.5")
|
||||
(is (thrown-with-msg?
|
||||
Exception
|
||||
#"Uncynlic miercels in RPLACA.*"
|
||||
#"Invalid cell in RPLACA.*"
|
||||
(RPLACA '(A B C D E) 'F))
|
||||
"You can't RPLACA into anything which isn't a MutableSequence.")
|
||||
)
|
||||
|
|
|
@ -24,22 +24,22 @@
|
|||
:file "resources/lisp1.5.lsp"}
|
||||
any))))))
|
||||
|
||||
(deftest APPEND-tests
|
||||
(testing "append - dot-terminated lists"
|
||||
(let [expected "(A B C . D)"
|
||||
actual (reps "(APPEND '(A B) (CONS 'C 'D))")]
|
||||
(is (= actual expected)))
|
||||
(let [expected "(A B C . D)"
|
||||
actual (reps "(APPEND (CONS 'A (CONS 'B NIL)) (CONS 'C 'D))")]
|
||||
(is (= actual expected)))
|
||||
(deftest APPEND-tests
|
||||
(testing "append - dot-terminated lists"
|
||||
(let [expected "(A B C . D)"
|
||||
actual (reps "(APPEND '(A B) (CONS 'C 'D))")]
|
||||
(is (= actual expected)))
|
||||
(let [expected "(A B C . D)"
|
||||
actual (reps "(APPEND (CONS 'A (CONS 'B NIL)) (CONS 'C 'D))")]
|
||||
(is (= actual expected)))
|
||||
;; this is failing: https://github.com/simon-brooke/beowulf/issues/5
|
||||
(let [expected "(A B C . D)"
|
||||
actual (reps "(APPEND '(A B) '(C . D))")]
|
||||
(is (= actual expected))))
|
||||
(testing "append - straight lists"
|
||||
(let [expected "(A B C D E)"
|
||||
actual (reps "(APPEND '(A B) '(C D E))")]
|
||||
(is (= actual expected)))))
|
||||
(let [expected "(A B C . D)"
|
||||
actual (reps "(APPEND '(A B) '(C . D))")]
|
||||
(is (= actual expected))))
|
||||
(testing "append - straight lists"
|
||||
(let [expected "(A B C D E)"
|
||||
actual (reps "(APPEND '(A B) '(C D E))")]
|
||||
(is (= actual expected)))))
|
||||
|
||||
(deftest COPY-tests
|
||||
(testing "copy NIL"
|
||||
|
@ -74,10 +74,10 @@
|
|||
(is (= actual expected))))
|
||||
(testing "divide by zero"
|
||||
(let [input "(DIVIDE 22 0)"]
|
||||
(is (thrown-with-msg? clojure.lang.ExceptionInfo
|
||||
#"Uncynlic þegnung: Divide by zero"
|
||||
(is (thrown-with-msg? ArithmeticException
|
||||
#"Divide by zero"
|
||||
(reps input)))))
|
||||
|
||||
|
||||
;; TODO: need to write tests for GET but I don't really
|
||||
;; understand what the correct behaviour is.
|
||||
|
||||
|
@ -107,7 +107,7 @@
|
|||
input "(INTERSECTION '(A B C D) '(F D E C))"
|
||||
actual (reps input)]
|
||||
(is (= actual expected)))))
|
||||
|
||||
|
||||
(deftest LENGTH-tests
|
||||
(testing "length of NIL"
|
||||
(let [expected "0"
|
||||
|
@ -129,8 +129,8 @@
|
|||
input "(LENGTH (PAIR '(A B C) '(1 2 3)))"
|
||||
actual (reps input)]
|
||||
(is (= actual expected))))))
|
||||
|
||||
|
||||
|
||||
|
||||
(deftest MEMBER-tests
|
||||
(testing "member"
|
||||
(let [expected "T"
|
||||
|
@ -146,23 +146,5 @@
|
|||
actual (reps "(MEMBER 'BERTRAM '(ALBERT BELINDA CHARLIE DORIS ELFREDA FRED))")]
|
||||
(is (= actual expected)))))
|
||||
|
||||
;; This is failing, and although yes, it does matter, I have not yet tracked the reason.
|
||||
;; (deftest sublis-tests
|
||||
;; (testing "sublis"
|
||||
;; (let [expected "(SHAKESPEARE WROTE (THE TEMPEST))"
|
||||
;; actual (reps
|
||||
;; "(SUBLIS
|
||||
;; '((X . SHAKESPEARE) (Y . (THE TEMPEST)))
|
||||
;; '(X WROTE Y))")]
|
||||
;; (is (= actual expected)))))
|
||||
|
||||
(deftest prog-tests
|
||||
(testing "PROG"
|
||||
(let [expected "5"
|
||||
actual (reps "(PROG (X)
|
||||
(SETQ X 1)
|
||||
START
|
||||
(SETQ X (ADD1 X))
|
||||
(COND ((EQ X 5) (RETURN X))
|
||||
(T (GO START))))")]
|
||||
(is (= actual expected)))))
|
||||
|
||||
|
|
@ -68,10 +68,10 @@
|
|||
|
||||
(deftest conditional-tests
|
||||
(testing "Conditional expressions"
|
||||
(let [expected "(COND ((ATOM X) X) (T (FF (CAR X))))"
|
||||
(let [expected "(COND ((ATOM X) X) ((QUOTE T) (FF (CAR X))))"
|
||||
actual (print-str (gsp "[atom[x]->x; T->ff[car[x]]]"))]
|
||||
(is (= actual expected)))
|
||||
(let [expected "(LABEL FF (LAMBDA (X) (COND ((ATOM X) X) (T (FF (CAR X))))))"
|
||||
(let [expected "(LABEL FF (LAMBDA (X) (COND ((ATOM X) X) ((QUOTE T) (FF (CAR X))))))"
|
||||
actual (print-str
|
||||
(generate
|
||||
(simplify-tree
|
||||
|
@ -88,6 +88,6 @@
|
|||
|
||||
(deftest assignment-tests
|
||||
(testing "Function assignment"
|
||||
(let [expected "(PUT (QUOTE FF) (QUOTE EXPR) (QUOTE (LAMBDA (X) (COND ((ATOM X) X) (T (FF (CAR X)))))))"
|
||||
(let [expected "(SET (QUOTE FF) (QUOTE (LAMBDA (X) (COND ((ATOM X) X) ((QUOTE T) (FF (CAR X)))))))"
|
||||
actual (print-str (gsp "ff[x]=[atom[x] -> x; T -> ff[car[x]]]"))]
|
||||
(is (= actual expected)))))
|
||||
|
|
Loading…
Reference in a new issue