SYSOUT now sort-of working; SYSIN present but not tested

Masses of stuff has had to be moved around because of cyclic dependency hell, and some of that may need to be revisited.
This commit is contained in:
Simon Brooke 2023-03-26 20:23:48 +01:00
parent eef64ab08c
commit 46f75a0c4f
No known key found for this signature in database
GPG key ID: A7A4F18D1D4DF987
28 changed files with 215 additions and 111 deletions

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

View file

@ -0,0 +1,8 @@
<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>beowulf.io documentation</title><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.2.1-SNAPSHOT</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 "><a href="intro.html"><div class="inner"><span>Introduction to beowulf</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.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 current"><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.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.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="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="beowulf.io.html#var-SYSOUT"><div class="inner"><span>SYSOUT</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">beowulf.io</h1><div class="doc"><div class="markdown"><p>Non-standard extensions to Lisp 1.5 to read and write to the filesystem.</p>
<p>Lisp 1.5 had only <code>READ</code>, which read one S-Expression at a time, and various forms of <code>PRIN*</code> functions, which printed to the line printer. There was also <code>PUNCH</code>, which wrote to a card punch. It does not seem that there was any concept of an interactive terminal.</p>
<p>See Appendix E, <code>OVERLORD - THE MONITOR</code>, and Appendix F, <code>LISP INPUT
AND OUTPUT</code>.</p>
<p>For our purposes, to save the current state of the Lisp system it should be sufficient to print the current contents of the oblist to file; and to restore a previous state from file, to overwrite the contents of the oblist with data from that file.</p>
<p>Hence functions SYSOUT and SYSIN, which do just that.</p></div></div><div class="public anchor" id="var-SYSOUT"><h3>SYSOUT</h3><div class="usage"><code>(SYSOUT)</code></div><div class="doc"><div class="markdown"><p><strong>TODO</strong>: write docs</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/beowulf/blob/master/src/beowulf/io.clj#L20">view source</a></div></div></div></body></html>

View file

@ -1,9 +1,9 @@
<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>beowulf.read documentation</title><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.2.1-SNAPSHOT</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 "><a href="intro.html"><div class="inner"><span>Introduction to beowulf</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.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 current"><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.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="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="beowulf.read.html#var-gsp"><div class="inner"><span>gsp</span></div></a></li><li class="depth-1"><a href="beowulf.read.html#var-number-lines"><div class="inner"><span>number-lines</span></div></a></li><li class="depth-1"><a href="beowulf.read.html#var-READ"><div class="inner"><span>READ</span></div></a></li><li class="depth-1"><a href="beowulf.read.html#var-read-from-console"><div class="inner"><span>read-from-console</span></div></a></li><li class="depth-1"><a href="beowulf.read.html#var-strip-line-comments"><div class="inner"><span>strip-line-comments</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">beowulf.read</h1><div class="doc"><div class="markdown"><p>This provides the reader required for boostrapping. Its not a bad reader - it provides feedback on errors found in the input - but it isnt the real Lisp reader.</p>
<html><head><meta charset="UTF-8" /><title>beowulf.read documentation</title><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.2.1-SNAPSHOT</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 "><a href="intro.html"><div class="inner"><span>Introduction to beowulf</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.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.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 current"><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.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="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="beowulf.read.html#var-gsp"><div class="inner"><span>gsp</span></div></a></li><li class="depth-1"><a href="beowulf.read.html#var-number-lines"><div class="inner"><span>number-lines</span></div></a></li><li class="depth-1"><a href="beowulf.read.html#var-READ"><div class="inner"><span>READ</span></div></a></li><li class="depth-1"><a href="beowulf.read.html#var-read-from-console"><div class="inner"><span>read-from-console</span></div></a></li><li class="depth-1"><a href="beowulf.read.html#var-strip-line-comments"><div class="inner"><span>strip-line-comments</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">beowulf.read</h1><div class="doc"><div class="markdown"><p>This provides the reader required for boostrapping. Its not a bad reader - it provides feedback on errors found in the input - but it isnt the real Lisp reader.</p>
<p>Intended deviations from the behaviour of the real Lisp reader are as follows:</p>
<ol>
<li>It reads the meta-expression language <code>MEXPR</code> in addition to fLAMthe symbolic expression language <code>SEXPR</code>, which I do not believe the Lisp 1.5 reader ever did;</li>
<li>It treats everything between a semi-colon and an end of line as a comment, as most modern Lisps do; but I do not believe Lisp 1.5 had this feature.</li>
<li>It reads the meta-expression language <code>MEXPR</code> in addition to the symbolic expression language <code>SEXPR</code>, which I do not believe the Lisp 1.5 reader ever did;</li>
<li>It treats everything between a double semi-colon and an end of line as a comment, as most modern Lisps do; but I do not believe Lisp 1.5 had this feature.</li>
</ol>
<p>Both these extensions can be disabled by using the <code>--strict</code> command line switch.</p></div></div><div class="public anchor" id="var-gsp"><h3>gsp</h3><div class="usage"><code>(gsp s)</code></div><div class="doc"><div class="markdown"><p>Shortcut macro - the internals of read; or, if you like, read-string. Argument <code>s</code> should be a string representation of a valid Lisp expression.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/beowulf/blob/master/src/beowulf/read.clj#L54">view source</a></div></div><div class="public anchor" id="var-number-lines"><h3>number-lines</h3><div class="usage"><code>(number-lines s)</code><code>(number-lines s e)</code></div><div class="doc"><div class="markdown"><p><strong>TODO</strong>: write docs</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/beowulf/blob/master/src/beowulf/read.clj#L41">view source</a></div></div><div class="public anchor" id="var-READ"><h3>READ</h3><div class="usage"><code>(READ)</code><code>(READ input)</code></div><div class="doc"><div class="markdown"><p>An implementation of a Lisp reader sufficient for bootstrapping; not necessarily the final Lisp reader. <code>input</code> should be either a string representation of a LISP expression, or else an input stream. A single form will be read.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/beowulf/blob/master/src/beowulf/read.clj#L75">view source</a></div></div><div class="public anchor" id="var-read-from-console"><h3>read-from-console</h3><div class="usage"><code>(read-from-console)</code></div><div class="doc"><div class="markdown"><p>Attempt to read a complete lisp expression from the console.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/beowulf/blob/master/src/beowulf/read.clj#L66">view source</a></div></div><div class="public anchor" id="var-strip-line-comments"><h3>strip-line-comments</h3><div class="usage"><code>(strip-line-comments s)</code></div><div class="doc"><div class="markdown"><p>Strip blank lines and comment lines from this string <code>s</code>, expected to be Lisp source.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/beowulf/blob/master/src/beowulf/read.clj#L31">view source</a></div></div></div></body></html>
<p>Both these extensions can be disabled by using the <code>--strict</code> command line switch.</p></div></div><div class="public anchor" id="var-gsp"><h3>gsp</h3><div class="usage"><code>(gsp s)</code></div><div class="doc"><div class="markdown"><p>Shortcut macro - the internals of read; or, if you like, read-string. Argument <code>s</code> should be a string representation of a valid Lisp expression.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/beowulf/blob/master/src/beowulf/read.clj#L54">view source</a></div></div><div class="public anchor" id="var-number-lines"><h3>number-lines</h3><div class="usage"><code>(number-lines s)</code><code>(number-lines s e)</code></div><div class="doc"><div class="markdown"><p><strong>TODO</strong>: write docs</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/beowulf/blob/master/src/beowulf/read.clj#L41">view source</a></div></div><div class="public anchor" id="var-READ"><h3>READ</h3><div class="usage"><code>(READ)</code><code>(READ input)</code></div><div class="doc"><div class="markdown"><p>An implementation of a Lisp reader sufficient for bootstrapping; not necessarily the final Lisp reader. <code>input</code> should be either a string representation of a LISP expression, or else an input stream. A single form will be read.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/beowulf/blob/master/src/beowulf/read.clj#L76">view source</a></div></div><div class="public anchor" id="var-read-from-console"><h3>read-from-console</h3><div class="usage"><code>(read-from-console)</code></div><div class="doc"><div class="markdown"><p>Attempt to read a complete lisp expression from the console. NOTE that this will only really work for S-Expressions, not M-Expressions.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/beowulf/blob/master/src/beowulf/read.clj#L66">view source</a></div></div><div class="public anchor" id="var-strip-line-comments"><h3>strip-line-comments</h3><div class="usage"><code>(strip-line-comments s)</code></div><div class="doc"><div class="markdown"><p>Strip blank lines and comment lines from this string <code>s</code>, expected to be Lisp source.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/beowulf/blob/master/src/beowulf/read.clj#L31">view source</a></div></div></div></body></html>

File diff suppressed because one or more lines are too long

View file

@ -1,3 +1,3 @@
<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>beowulf.reader.macros documentation</title><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.2.1-SNAPSHOT</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 "><a href="intro.html"><div class="inner"><span>Introduction to beowulf</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.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.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.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 current"><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="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="beowulf.reader.macros.html#var-*readmacros*"><div class="inner"><span>*readmacros*</span></div></a></li><li class="depth-1"><a href="beowulf.reader.macros.html#var-expand-macros"><div class="inner"><span>expand-macros</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">beowulf.reader.macros</h1><div class="doc"><div class="markdown"><p>Can I implement reader macros? lets see!</p></div></div><div class="public anchor" id="var-*readmacros*"><h3>*readmacros*</h3><h4 class="dynamic">dynamic</h4><div class="usage"></div><div class="doc"><div class="markdown"><p><strong>TODO</strong>: write docs</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/beowulf/blob/master/src/beowulf/reader/macros.clj#L15">view source</a></div></div><div class="public anchor" id="var-expand-macros"><h3>expand-macros</h3><div class="usage"><code>(expand-macros form)</code></div><div class="doc"><div class="markdown"><p><strong>TODO</strong>: write docs</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/beowulf/blob/master/src/beowulf/reader/macros.clj#L21">view source</a></div></div></div></body></html>
<html><head><meta charset="UTF-8" /><title>beowulf.reader.macros documentation</title><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.2.1-SNAPSHOT</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 "><a href="intro.html"><div class="inner"><span>Introduction to beowulf</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.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.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.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.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 current"><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="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="beowulf.reader.macros.html#var-*readmacros*"><div class="inner"><span>*readmacros*</span></div></a></li><li class="depth-1"><a href="beowulf.reader.macros.html#var-expand-macros"><div class="inner"><span>expand-macros</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">beowulf.reader.macros</h1><div class="doc"><div class="markdown"><p>Can I implement reader macros? lets see!</p></div></div><div class="public anchor" id="var-*readmacros*"><h3>*readmacros*</h3><h4 class="dynamic">dynamic</h4><div class="usage"></div><div class="doc"><div class="markdown"><p><strong>TODO</strong>: write docs</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/beowulf/blob/master/src/beowulf/reader/macros.clj#L15">view source</a></div></div><div class="public anchor" id="var-expand-macros"><h3>expand-macros</h3><div class="usage"><code>(expand-macros form)</code></div><div class="doc"><div class="markdown"><p><strong>TODO</strong>: write docs</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/beowulf/blob/master/src/beowulf/reader/macros.clj#L21">view source</a></div></div></div></body></html>

View file

@ -1,3 +1,3 @@
<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>beowulf.reader.parser documentation</title><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.2.1-SNAPSHOT</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 "><a href="intro.html"><div class="inner"><span>Introduction to beowulf</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.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.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.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 current"><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="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="beowulf.reader.parser.html#var-parse"><div class="inner"><span>parse</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">beowulf.reader.parser</h1><div class="doc"><div class="markdown"><p>The actual parser, supporting both S-expression and M-expression syntax.</p></div></div><div class="public anchor" id="var-parse"><h3>parse</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>Parse a string presented as argument into a parse tree which can then be operated upon further.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/beowulf/blob/master/src/beowulf/reader/parser.clj#L5">view source</a></div></div></div></body></html>
<html><head><meta charset="UTF-8" /><title>beowulf.reader.parser documentation</title><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.2.1-SNAPSHOT</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 "><a href="intro.html"><div class="inner"><span>Introduction to beowulf</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.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.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.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.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 current"><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="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="beowulf.reader.parser.html#var-parse"><div class="inner"><span>parse</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">beowulf.reader.parser</h1><div class="doc"><div class="markdown"><p>The actual parser, supporting both S-expression and M-expression syntax.</p></div></div><div class="public anchor" id="var-parse"><h3>parse</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>Parse a string presented as argument into a parse tree which can then be operated upon further.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/beowulf/blob/master/src/beowulf/reader/parser.clj#L5">view source</a></div></div></div></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,4 @@
<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>Introduction to beowulf</title><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.2.1-SNAPSHOT</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="intro.html"><div class="inner"><span>Introduction to beowulf</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.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.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.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="#introduction-to-beowulf" name="introduction-to-beowulf"></a>Introduction to beowulf</h1>
<html><head><meta charset="UTF-8" /><title>Introduction to beowulf</title><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.2.1-SNAPSHOT</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="intro.html"><div class="inner"><span>Introduction to beowulf</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.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.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.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.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="#introduction-to-beowulf" name="introduction-to-beowulf"></a>Introduction to beowulf</h1>
<p>TODO: write <a href="http://jacobian.org/writing/what-to-write/">great documentation</a></p></div></div></div></body></html>

View file

@ -11,6 +11,7 @@
[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"]
[rhizome "0.2.9"] ;; not needed in production builds

View file

@ -11,10 +11,12 @@
objects."
(:require [clojure.string :as s]
[clojure.tools.trace :refer [deftrace]]
[beowulf.cons-cell :refer [cons-cell? make-beowulf-list make-cons-cell
NIL pretty-print T F]]
[beowulf.cons-cell :refer [CAR CDR CONS LIST make-beowulf-list make-cons-cell
pretty-print T F]]
[beowulf.host :refer [ADD1 DIFFERENCE FIXP NUMBERP PLUS2 QUOTIENT
REMAINDER RPLACA RPLACD SUB1 TIMES2]])
REMAINDER RPLACA RPLACD SUB1 TIMES2]]
[beowulf.io :refer [SYSIN SYSOUT]]
[beowulf.oblist :refer [*options* oblist NIL]])
(:import [beowulf.cons_cell ConsCell]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -29,13 +31,6 @@
(declare EVAL)
(def oblist
"The default environment."
(atom NIL))
(def ^:dynamic *options*
"Command line options from invocation."
{})
(defmacro NULL
"Returns `T` if and only if the argument `x` is bound to `NIL`; else `F`."
@ -61,35 +56,6 @@
[x]
`(if (or (symbol? ~x) (number? ~x)) T NIL))
(defn CONS
"Construct a new instance of cons cell with this `car` and `cdr`."
[car cdr]
(beowulf.cons_cell.ConsCell. car cdr (gensym "c")))
(defn CAR
"Return the item indicated by the first pointer of a pair. NIL is treated
specially: the CAR of NIL is NIL."
[x]
(if
(= x NIL) NIL
(try
(or (.getCar x) NIL)
(catch Exception any
(throw (Exception.
(str "Cannot take CAR of `" x "` (" (.getName (.getClass x)) ")") 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]
(if
(= x NIL) NIL
(try
(.getCdr x)
(catch Exception any
(throw (Exception.
(str "Cannot take CDR of `" x "` (" (.getName (.getClass x)) ")") any))))))
(defn uaf
"Universal access function; `l` is expected to be an arbitrary LISP list, `path`
a (clojure) list of the characters `a` and `d`. Intended to make declaring
@ -267,7 +233,7 @@
:else
(make-cons-cell (SUBLIS a (CAR y)) (SUBLIS a (CDR y)))))
(deftrace interop-interpret-q-name
(defn interop-interpret-q-name
"For interoperation with Clojure, it will often be necessary to pass
qualified names that are not representable in Lisp 1.5. This function
takes a sequence in the form `(PART PART PART... NAME)` and returns
@ -308,7 +274,7 @@
:else
(conj (to-clojure (CDR l)) (to-clojure (CAR l)))))
(deftrace INTEROP
(defn INTEROP
"Clojure (or other host environment) interoperation API. `fn-symbol` is expected
to be either
@ -437,6 +403,8 @@
(= function 'EQ) (apply EQ args)
(= function 'INTEROP) (INTEROP (CAR args) (CDR args))
(= function 'SET) (SET (CAR args) (CADR args))
(= function 'SYSIN) (SYSIN (CAR args))
(= function 'SYSOUT) (SYSOUT (CAR args))
(EVAL function environment) (APPLY
(EVAL function environment)
args

View file

@ -2,9 +2,10 @@
"The fundamental cons cell on which all Lisp structures are built.
Lisp 1.5 lists do not necessarily have a sequence as their CDR, and
must have both CAR and CDR mutable, so cannot be implemented on top
of Clojure lists.")
of Clojure lists."
(:require [beowulf.oblist :refer [NIL]]))
(declare cons-cell? NIL)
(declare cons-cell?)
(def T
"The canonical true value."
@ -222,10 +223,6 @@
(throw (ex-info "Cound not construct cons cell" {:car car
:cdr cdr} any)))))
(def NIL
"The canonical empty list symbol."
'NIL)
(defn cons-cell?
"Is this object `o` a beowulf cons-cell?"
[o]
@ -251,3 +248,36 @@
(throw (ex-info "Could not construct Beowulf list"
{:content x}
any)))))
(defn CONS
"Construct a new instance of cons cell with this `car` and `cdr`."
[car cdr]
(beowulf.cons_cell.ConsCell. car cdr (gensym "c")))
(defn CAR
"Return the item indicated by the first pointer of a pair. NIL is treated
specially: the CAR of NIL is NIL."
[x]
(if
(= x NIL) NIL
(try
(or (.getCar x) NIL)
(catch Exception any
(throw (Exception.
(str "Cannot take CAR of `" x "` (" (.getName (.getClass x)) ")") 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]
(if
(= x NIL) NIL
(try
(.getCdr x)
(catch Exception any
(throw (Exception.
(str "Cannot take CDR of `" x "` (" (.getName (.getClass x)) ")") any))))))
(defn LIST
[& args]
(make-beowulf-list args))

View file

@ -1,7 +1,8 @@
(ns beowulf.core
"Essentially, the `-main` function and the bootstrap read-eval-print loop."
(:require [beowulf.bootstrap :refer [EVAL oblist *options*]]
(:require [beowulf.bootstrap :refer [EVAL]]
[beowulf.read :refer [READ read-from-console]]
[beowulf.oblist :refer [*options* oblist]]
[clojure.java.io :as io]
[clojure.pprint :refer [pprint]]
[clojure.string :refer [trim]]
@ -11,7 +12,14 @@
(def stop-word "STOP")
(def cli-options
[["-h" "--help"]
[["-f FILEPATH" "--file-path FILEPATH"
"Set the path to the directory for reading and writing Lisp files."
:validate [#(and (.exists (io/file %))
(.isDirectory (io/file %))
(.canRead (io/file %))
(.canWrite (io/file %)))
"File path must exist and must be a directory."]]
["-h" "--help"]
["-p PROMPT" "--prompt PROMPT" "Set the REPL prompt to PROMPT"
:default "Sprecan::"]
["-r INITFILE" "--read INITFILE" "Read Lisp functions from the file INITFILE"
@ -29,8 +37,6 @@
(print prompt)
(flush)
(try
;; TODO: does not currently allow the reading of forms covering multiple
;; lines.
(let [input (trim (read-from-console))]
(cond
(= input stop-word) (throw (ex-info "\nFærwell!" {:cause :quit}))

View file

@ -2,9 +2,9 @@
"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 NIL T]]
(:require [beowulf.cons-cell :refer [F make-beowulf-list T]]
;; note hyphen - this is Clojure...
)
[beowulf.oblist :refer [NIL]])
(:import [beowulf.cons_cell ConsCell]
;; note underscore - same namespace, but Java.
))
@ -108,7 +108,3 @@
(defn NUMBERP
[x]
(if (number? x) T F))
(defn LIST
[& args]
(make-beowulf-list args))

77
src/beowulf/io.clj Normal file
View file

@ -0,0 +1,77 @@
(ns beowulf.io
"Non-standard extensions to Lisp 1.5 to read and write to the filesystem.
Lisp 1.5 had only `READ`, which read one S-Expression at a time, and
various forms of `PRIN*` functions, which printed to the line printer.
There was also `PUNCH`, which wrote to a card punch. It does not seem
that there was any concept of an interactive terminal.
See Appendix E, `OVERLORD - THE MONITOR`, and Appendix F, `LISP INPUT
AND OUTPUT`.
For our purposes, to save the current state of the Lisp system it should
be sufficient to print the current contents of the oblist to file; and to
restore a previous state from file, to overwrite the contents of the
oblist with data from that file.
Hence functions SYSOUT and SYSIN, which do just that."
(:require [beowulf.cons-cell :refer [pretty-print]]
[beowulf.oblist :refer [*options* oblist]]
[beowulf.read :refer [READ]]
[clojure.string :refer [ends-with?]]
[java-time.api :refer [local-date local-date-time]]))
(defn- full-path
[fp]
(str
(if (:filepath *options*)
(str (:filepath *options*) (java.io.File/separator))
"")
(if (and (string? fp)
(> (count fp) 0))
fp
(str "Sysout-" (local-date)))
(if (ends-with? fp ".lsp")
fp
(str fp ".lsp"))))
(defn 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."
([]
(SYSOUT nil))
([filepath]
(spit (full-path (str filepath))
(with-out-str
(println (apply str (repeat 79 ";")))
(println (format ";; Beowulf %s Sysout file generated at %s"
(System/getProperty "beowulf.version")
(local-date-time)))
(when (System/getenv "USER")
(println (format ";; generated by %s" (System/getenv "USER"))))
(println (apply str (repeat 79 ";")))
(println)
(pretty-print @oblist)))))
(defn SYSIN
"Read the contents of the file at this `filepath` 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.
**NOTE THAT** if the provided `filepath` does not end with `.lsp` (which,
if you're writing it from the Lisp REPL it won't), the extension `.lsp`
will be appended."
[filepath]
(let [fp (full-path (str filepath))
content (try (READ (slurp fp))
(catch Throwable any
(throw (ex-info "Could not read from sysout"
{:context "SYSIN"
:filepath fp}
any))))]
(swap! oblist #(when (or % (seq content)) content))))

19
src/beowulf/oblist.clj Normal file
View file

@ -0,0 +1,19 @@
(ns beowulf.oblist
"A namespace mainly devoted to the object list.
Yes, this makes little sense, but if you put it anywhere else you end
up in cyclic dependency hell."
)
(def NIL
"The canonical empty list symbol."
'NIL)
(def oblist
"The default environment."
(atom NIL))
(def ^:dynamic *options*
"Command line options from invocation."
{})

View file

@ -5,10 +5,10 @@
Intended deviations from the behaviour of the real Lisp reader are as follows:
1. It reads the meta-expression language `MEXPR` in addition to fLAMthe
1. It reads the meta-expression language `MEXPR` in addition to the
symbolic expression language `SEXPR`, which I do not believe the Lisp 1.5
reader ever did;
2. It treats everything between a semi-colon and an end of line as a comment,
2. It treats everything between a double semi-colon and an end of line as a comment,
as most modern Lisps do; but I do not believe Lisp 1.5 had this feature.
Both these extensions can be disabled by using the `--strict` command line
@ -64,7 +64,8 @@
(generate (simplify (remove-optional-space parse-tree))))))
(defn read-from-console
"Attempt to read a complete lisp expression from the console."
"Attempt to read a complete lisp expression from the console. NOTE that this
will only really work for S-Expressions, not M-Expressions."
[]
(loop [r (read-line)]
(if (= (count (re-seq #"\(" r))

View file

@ -55,8 +55,9 @@
*quote ends*
"
(:require [beowulf.cons-cell :refer [make-beowulf-list make-cons-cell NIL]]
(:require [beowulf.cons-cell :refer [make-beowulf-list make-cons-cell]]
[beowulf.reader.macros :refer [expand-macros]]
[beowulf.oblist :refer [NIL]]
[clojure.math.numeric-tower :refer [expt]]
[clojure.string :refer [upper-case]]))

View file

@ -1,8 +1,6 @@
(ns beowulf.reader.macros
"Can I implement reader macros? let's see!"
(:require [beowulf.bootstrap :refer [CADR CADDR CDDR CONS]]
[beowulf.cons-cell :refer [make-beowulf-list]]
[beowulf.host :refer [LIST]]
(:require [beowulf.cons-cell :refer [CONS LIST make-beowulf-list]]
[clojure.string :refer [join]])
(:import [beowulf.cons_cell ConsCell]))
@ -14,9 +12,9 @@
(def ^:dynamic *readmacros*
{:car {'DEFUN (fn [f]
(LIST 'SET (LIST 'QUOTE (CADR f))
(CONS 'LAMBDA (CDDR f))))
'SETQ (fn [f] (LIST 'SET (LIST 'QUOTE (CADR f)) (CADDR f)))}})
(LIST 'SET (LIST 'QUOTE (second f))
(CONS 'LAMBDA (rest (rest f)))))
'SETQ (fn [f] (LIST 'SET (LIST 'QUOTE (second f)) (nth f 2)))}})
(defn expand-macros
[form]

View file

@ -1,8 +1,7 @@
(ns beowulf.reader.simplify
"Simplify parse trees. Be aware that this is very tightly coupled
with the parser."
(:require [beowulf.bootstrap :refer [*options*]]
[clojure.tools.trace :refer [deftrace]]
(:require [beowulf.oblist :refer [*options*]]
[instaparse.failure :as f])
(:import [instaparse.gll Failure]))

View file

@ -1,9 +1,10 @@
(ns beowulf.bootstrap-test
(:require [clojure.test :refer [deftest testing is]]
[beowulf.cons-cell :refer [make-cons-cell NIL T F]]
[beowulf.bootstrap :refer [APPEND ASSOC ATOM ATOM? CAR CAAAAR CADR
CADDR CADDDR CDR EQ EQUAL MEMBER
[beowulf.cons-cell :refer [CAR CDR make-cons-cell T F]]
[beowulf.bootstrap :refer [APPEND ASSOC ATOM ATOM? CAAAAR CADR
CADDR CADDDR EQ EQUAL MEMBER
PAIRLIS SUBLIS SUBST]]
[beowulf.oblist :refer [NIL]]
[beowulf.read :refer [gsp]]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View file

@ -1,8 +1,8 @@
(ns beowulf.host-test
(:require [clojure.test :refer [deftest is testing]]
[beowulf.bootstrap :refer [CDR]]
[beowulf.cons-cell :refer [F make-beowulf-list NIL T]]
[beowulf.cons-cell :refer [CDR F make-beowulf-list T]]
[beowulf.host :refer [DIFFERENCE NUMBERP PLUS2 RPLACA RPLACD TIMES2]]
[beowulf.oblist :refer [NIL]]
[beowulf.read :refer [gsp]]))
(deftest destructive-change-test

View file

@ -1,6 +1,6 @@
(ns beowulf.interop-test
(:require [clojure.test :refer [deftest is testing]]
[beowulf.bootstrap :refer [EVAL INTEROP QUOTE]]
[beowulf.bootstrap :refer [EVAL INTEROP]]
[beowulf.read :refer [gsp]]))
@ -11,6 +11,6 @@
(is (= actual expected))))
;; (testing "INTEROP called from Lisp"
;; (let [expected 'ABC
;; actual (EVAL (gsp "(INTEROP '(CLOJURE CORE STR) '(A B C))") (gsp "((A . A)(B . B)(C . C))"))]
;; actual (EVAL (gsp "(INTEROP '(CLOJURE CORE STR) '(QUOTE (A B C)))") (gsp "((A . P)(B . Q)(C . R))"))]
;; (is (= actual expected))))
)

View file

@ -2,7 +2,7 @@
"These tests are taken generally from the examples on page 10 of
Lisp 1.5 Programmers Manual"
(:require [clojure.test :refer [deftest is testing]]
[beowulf.bootstrap :refer [*options*]]
[beowulf.oblist :refer [*options*]]
[beowulf.read :refer [gsp]]
[beowulf.reader.generate :refer [generate]]
[beowulf.reader.parser :refer [parse]]

View file

@ -1,6 +1,5 @@
(ns beowulf.sexpr-test
(:require [clojure.test :refer [deftest is testing]]
[beowulf.bootstrap :refer [*options*]]
[beowulf.cons-cell :refer []]
[beowulf.read :refer [gsp]]))