/
ls9.nw
150 lines (122 loc) · 2.28 KB
/
ls9.nw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
This is a noweb file, see tools/nofake-README.txt for more information.
<<ls9 header>>=
/*
* LISP9 Interpreter
* Nils M Holm, 2018,2019
* In the public domain
*
* If your country does not have a concept like the public
* domain, the Creative Common Zero (CC0) licence applies,
* see https://creativecommons.org/publicdomain/zero/1.0/
*/
#define VERSION "<<VERSION>>"
@
<<VERSION>>=
20220131
@
<<IMAGENAME>>=
ls9
@
<<IMAGEFILE>>=
<<IMAGENAME>>.image
@
<<IMAGESRC>>=
<<IMAGENAME>>.ls9
@
<<ls9 definitions>>=
#define IMAGEFILE "<<IMAGEFILE>>"
#define IMAGESRC "<<IMAGESRC>>"
#define NNODES 262144
#define NVCELLS 262144
#define NPORTS 20
#define TOKLEN 80
#define CHUNKSIZE 1024
#define MXMAX 2000
#define NTRACE 10
#define PRDEPTH 1024
@
<<ls9.c>>=
<<ls9 header>>
<<ls9 definitions>>
<<ls9 macros>>
<<ls9 prototypes>>
<<ls9 globals>>
<<ls9 impl>>
@
<<ls9-trace.c>>=
<<ls9 header>>
<<ls9 definitions>>
<<ls9 macros>>
<<ls9 prototypes>>
<<ls9 trace>>
@
<<ls9 header: ctypes>>=
#include <ctype.h>
@
In case there is a need to use the explict prototypes instead of
macros.
<<ls9 header: ctypes 0>>=
int isalnum(int);
int isalpha(int);
int isblank(int);
int iscntrl(int);
int isdigit(int);
int isgraph(int);
int islower(int);
int isprint(int);
int ispunct(int);
int isspace(int);
int isupper(int);
int isxdigit(int);
int tolower(int);
int toupper(int);
int isascii(int);
int toascii(int);
@
<<ls9 header>>=
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <signal.h>
#include <setjmp.h>
#include <unistd.h>
#include <inttypes.h>
<<ls9 header: ctypes>>
<<size_t_aux.h>>
<<ls9 full and half>>
@
Full word bits and half word bits.
<<ls9 full and half>>=
<<ls9 full is size_t>>
/* TODO: half */
@
<<ls9 full is size_t>>=
#define full size_t
#define ifull ssize_t
#define byte unsigned char
#define PRIuFULL __PRIuSIZE
#define PRIxFULL __PRIxSIZE
#define PRIXFULL __PRIXSIZE
#define PRIdFULL __PRIdSIZE
#define PRIiFULL __PRIiSIZE
#define FULL_BITS SIZE_BITS
#define FULL_BYTES SIZE_BYTES
#define FULL_MAX SIZE_MAX
#define IFULL_MIN SSIZE_MIN
#define IFULL_MAX SSIZE_MAX
@
<<ls9 full is unsigned int>>=
TODO
@
<<ls9 full is unsigned long>>=
TODO
@
<<ls9 full is unsigned long long>>=
TODO
@
<<ls9 prototypes>>=
#ifndef INSIDE_CPROTO
#include "ls9_protos.h"
#endif
@