trying to get ulisp to compile
This commit is contained in:
parent
0dbfc80cf3
commit
82ed29ab03
|
@ -12,3 +12,4 @@
|
||||||
platform = atmelsam
|
platform = atmelsam
|
||||||
board = adafruit_feather_m4
|
board = adafruit_feather_m4
|
||||||
framework = arduino
|
framework = arduino
|
||||||
|
lib_deps = arduino-libraries/SD
|
||||||
|
|
|
@ -14,7 +14,7 @@ const char LispLibrary[] PROGMEM = "";
|
||||||
// #define resetautorun
|
// #define resetautorun
|
||||||
#define printfreespace
|
#define printfreespace
|
||||||
// #define printgcs
|
// #define printgcs
|
||||||
// #define sdcardsupport
|
#define sdcardsupport
|
||||||
// #define gfxsupport
|
// #define gfxsupport
|
||||||
// #define lisplibrary
|
// #define lisplibrary
|
||||||
#define assemblerlist
|
#define assemblerlist
|
||||||
|
@ -183,7 +183,7 @@ typedef int PinMode;
|
||||||
#define CPU_ATSAMD21
|
#define CPU_ATSAMD21
|
||||||
|
|
||||||
#elif defined(ARDUINO_METRO_M4) || defined(ARDUINO_ITSYBITSY_M4) || defined(ARDUINO_FEATHER_M4) || defined(ARDUINO_PYBADGE_M4) || defined(ARDUINO_PYGAMER_M4)
|
#elif defined(ARDUINO_METRO_M4) || defined(ARDUINO_ITSYBITSY_M4) || defined(ARDUINO_FEATHER_M4) || defined(ARDUINO_PYBADGE_M4) || defined(ARDUINO_PYGAMER_M4)
|
||||||
#define WORKSPACESIZE 20480-SDSIZE /* Objects (8*bytes) */
|
#define WORKSPACESIZE (20480-SDSIZE) /* Objects (8*bytes) */
|
||||||
#define DATAFLASHSIZE 2048000 /* 2 MBytes */
|
#define DATAFLASHSIZE 2048000 /* 2 MBytes */
|
||||||
#define SYMBOLTABLESIZE 1024 /* Bytes */
|
#define SYMBOLTABLESIZE 1024 /* Bytes */
|
||||||
#define CODESIZE 256 /* Bytes */
|
#define CODESIZE 256 /* Bytes */
|
||||||
|
@ -309,16 +309,55 @@ enum flag { PRINTREADABLY, RETURNFLAG, ESCAPE, EXITEDITOR, LIBRARYLOADED, NOESC
|
||||||
volatile char Flags = 0b00001; // PRINTREADABLY set by default
|
volatile char Flags = 0b00001; // PRINTREADABLY set by default
|
||||||
|
|
||||||
// Forward references
|
// Forward references
|
||||||
|
bool consp (object *x);
|
||||||
|
bool atom (object *x);
|
||||||
|
bool listp (object *x);
|
||||||
|
bool improperp (object *x);
|
||||||
|
object *quote (object *arg);
|
||||||
object *tee;
|
object *tee;
|
||||||
object *tf_progn (object *form, object *env);
|
object *tf_progn (object *form, object *env);
|
||||||
object *eval (object *form, object *env);
|
object *eval (object *form, object *env);
|
||||||
object *read (gfun_t gfun);
|
object *read (pfun_t pfun);
|
||||||
void repl (object *env);
|
void repl(object *env);
|
||||||
void printobject (object *form, pfun_t pfun);
|
void printobject (object *form, pfun_t pfun);
|
||||||
char *lookupbuiltin (symbol_t name);
|
char *lookupbuiltin (symbol_t name);
|
||||||
intptr_t lookupfn (symbol_t name);
|
int lookupfn (symbol_t name);
|
||||||
|
int lookupmin(symbol_t name);
|
||||||
|
int lookupmax(symbol_t name);
|
||||||
int builtin (char* n);
|
int builtin (char* n);
|
||||||
|
void Display (char c);
|
||||||
|
void error (const __FlashStringHelper *);
|
||||||
|
void pfstring (const char *s, pfun_t pfun);
|
||||||
|
void pfstring (const __FlashStringHelper *);
|
||||||
|
void pln (pfun_t pfun);
|
||||||
|
void pfl (pfun_t pfun);
|
||||||
|
void pchar (char c);
|
||||||
|
int gchar ();
|
||||||
|
object *apply (object *function, object *args, object **env);
|
||||||
|
char *lookupsymbol (symbol_t name);
|
||||||
|
void deletesymbol (symbol_t name);
|
||||||
|
object *edit(object *fun);
|
||||||
|
int subwidthlist (object *form, int w);
|
||||||
|
void superprint (object *form, int lm);
|
||||||
|
void supersub (object *form, int lm, int super, pfun_t pfun);
|
||||||
|
void pserial (char c);
|
||||||
|
char *symbolname (symbol_t x);
|
||||||
|
void pstring (char *s, pfun_t pfun);
|
||||||
|
int maxbuffer (char *buffer);
|
||||||
|
char nthchar (object *string, int n);
|
||||||
|
object *apply (symbol_t name, object *function, object *args, object *env);
|
||||||
|
int listlength (symbol_t name, object *list);
|
||||||
|
void checkminmax (symbol_t name, int nargs);
|
||||||
|
void pint (int i, pfun_t pfun);
|
||||||
|
void testescape ();
|
||||||
|
int gserial ();
|
||||||
|
void pinthex (uint32_t i, pfun_t pfun);
|
||||||
|
void printhex4 (int i, pfun_t pfun);
|
||||||
|
void prin1object (object *form, pfun_t pfun);
|
||||||
|
int assemble (int pass, int origin, object *entries, object *env, object *pcpair);
|
||||||
|
void printstring (object *form, pfun_t pfun);
|
||||||
|
int glibrary ();
|
||||||
|
|
||||||
// Error handling
|
// Error handling
|
||||||
|
|
||||||
void errorsub (symbol_t fname, PGM_P string) {
|
void errorsub (symbol_t fname, PGM_P string) {
|
||||||
|
@ -902,7 +941,9 @@ object *quote (object *arg) {
|
||||||
int toradix40 (char ch) {
|
int toradix40 (char ch) {
|
||||||
if (ch == 0) return 0;
|
if (ch == 0) return 0;
|
||||||
if (ch >= '0' && ch <= '9') return ch-'0'+30;
|
if (ch >= '0' && ch <= '9') return ch-'0'+30;
|
||||||
if (ch == '$') return 27; if (ch == '*') return 28; if (ch == '-') return 29;
|
if (ch == '$') return 27;
|
||||||
|
if (ch == '*') return 28;
|
||||||
|
if (ch == '-') return 29;
|
||||||
ch = ch | 0x20;
|
ch = ch | 0x20;
|
||||||
if (ch >= 'a' && ch <= 'z') return ch-'a'+1;
|
if (ch >= 'a' && ch <= 'z') return ch-'a'+1;
|
||||||
return -1; // Invalid
|
return -1; // Invalid
|
||||||
|
@ -910,7 +951,9 @@ int toradix40 (char ch) {
|
||||||
|
|
||||||
int fromradix40 (int n) {
|
int fromradix40 (int n) {
|
||||||
if (n >= 1 && n <= 26) return 'a'+n-1;
|
if (n >= 1 && n <= 26) return 'a'+n-1;
|
||||||
if (n == 27) return '$'; if (n == 28) return '*'; if (n == 29) return '-';
|
if (n == 27) return '$';
|
||||||
|
if (n == 28) return '*';
|
||||||
|
if (n == 29) return '-';
|
||||||
if (n >= 30 && n <= 39) return '0'+n-30;
|
if (n >= 30 && n <= 39) return '0'+n-30;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -3623,7 +3666,7 @@ object *fn_readfromstring (object *args, object *env) {
|
||||||
if (!stringp(arg)) error(READFROMSTRING, notastring, arg);
|
if (!stringp(arg)) error(READFROMSTRING, notastring, arg);
|
||||||
GlobalString = arg;
|
GlobalString = arg;
|
||||||
GlobalStringIndex = 0;
|
GlobalStringIndex = 0;
|
||||||
return read(gstr);
|
return read((pfun_t)gstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
object *fn_princtostring (object *args, object *env) {
|
object *fn_princtostring (object *args, object *env) {
|
||||||
|
@ -3734,7 +3777,7 @@ object *fn_break (object *args, object *env) {
|
||||||
object *fn_read (object *args, object *env) {
|
object *fn_read (object *args, object *env) {
|
||||||
(void) env;
|
(void) env;
|
||||||
gfun_t gfun = gstreamfun(args);
|
gfun_t gfun = gstreamfun(args);
|
||||||
return read(gfun);
|
return read((pfun_t)gfun);
|
||||||
}
|
}
|
||||||
|
|
||||||
object *fn_prin1 (object *args, object *env) {
|
object *fn_prin1 (object *args, object *env) {
|
||||||
|
@ -3964,9 +4007,9 @@ object *edit (object *fun) {
|
||||||
char c = gserial();
|
char c = gserial();
|
||||||
if (c == 'q') setflag(EXITEDITOR);
|
if (c == 'q') setflag(EXITEDITOR);
|
||||||
else if (c == 'b') return fun;
|
else if (c == 'b') return fun;
|
||||||
else if (c == 'r') fun = read(gserial);
|
else if (c == 'r') fun = read((pfun_t)gserial);
|
||||||
else if (c == '\n') { pfl(pserial); superprint(fun, 0, pserial); pln(pserial); }
|
else if (c == '\n') { pfl(pserial); superprint(fun, 0, pserial); pln(pserial); }
|
||||||
else if (c == 'c') fun = cons(read(gserial), fun);
|
else if (c == 'c') fun = cons(read((pfun_t)gserial), fun);
|
||||||
else if (atom(fun)) pserial('!');
|
else if (atom(fun)) pserial('!');
|
||||||
else if (c == 'd') fun = cons(car(fun), edit(cdr(fun)));
|
else if (c == 'd') fun = cons(car(fun), edit(cdr(fun)));
|
||||||
else if (c == 'a') fun = cons(edit(car(fun)), cdr(fun));
|
else if (c == 'a') fun = cons(edit(car(fun)), cdr(fun));
|
||||||
|
@ -4112,7 +4155,7 @@ object *fn_require (object *args, object *env) {
|
||||||
globals = cdr(globals);
|
globals = cdr(globals);
|
||||||
}
|
}
|
||||||
GlobalStringIndex = 0;
|
GlobalStringIndex = 0;
|
||||||
object *line = read(glibrary);
|
object *line = read((pfun_t)glibrary);
|
||||||
while (line != NULL) {
|
while (line != NULL) {
|
||||||
// Is this the definition we want
|
// Is this the definition we want
|
||||||
int fname = first(line)->name;
|
int fname = first(line)->name;
|
||||||
|
@ -4120,7 +4163,7 @@ object *fn_require (object *args, object *env) {
|
||||||
eval(line, env);
|
eval(line, env);
|
||||||
return tee;
|
return tee;
|
||||||
}
|
}
|
||||||
line = read(glibrary);
|
line = read((pfun_t)glibrary);
|
||||||
}
|
}
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
@ -4128,13 +4171,13 @@ object *fn_require (object *args, object *env) {
|
||||||
object *fn_listlibrary (object *args, object *env) {
|
object *fn_listlibrary (object *args, object *env) {
|
||||||
(void) args, (void) env;
|
(void) args, (void) env;
|
||||||
GlobalStringIndex = 0;
|
GlobalStringIndex = 0;
|
||||||
object *line = read(glibrary);
|
object *line = read((pfun_t)glibrary);
|
||||||
while (line != NULL) {
|
while (line != NULL) {
|
||||||
int fname = first(line)->name;
|
int fname = first(line)->name;
|
||||||
if (fname == DEFUN || fname == DEFVAR) {
|
if (fname == DEFUN || fname == DEFVAR) {
|
||||||
pstring(symbolname(second(line)->name), pserial); pserial(' ');
|
pstring(symbolname(second(line)->name), pserial); pserial(' ');
|
||||||
}
|
}
|
||||||
line = read(glibrary);
|
line = read((pfun_t)glibrary);
|
||||||
}
|
}
|
||||||
return symbol(NOTHING);
|
return symbol(NOTHING);
|
||||||
}
|
}
|
||||||
|
@ -5193,10 +5236,10 @@ int glibrary () {
|
||||||
|
|
||||||
void loadfromlibrary (object *env) {
|
void loadfromlibrary (object *env) {
|
||||||
GlobalStringIndex = 0;
|
GlobalStringIndex = 0;
|
||||||
object *line = read(glibrary);
|
object *line = read((pfun_t)glibrary);
|
||||||
while (line != NULL) {
|
while (line != NULL) {
|
||||||
eval(line, env);
|
eval(line, env);
|
||||||
line = read(glibrary);
|
line = read((pfun_t)glibrary);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5370,13 +5413,13 @@ object *nextitem (gfun_t gfun) {
|
||||||
else if (ch == '\'') return nextitem(gfun);
|
else if (ch == '\'') return nextitem(gfun);
|
||||||
else if (ch == '.') {
|
else if (ch == '.') {
|
||||||
setflag(NOESC);
|
setflag(NOESC);
|
||||||
object *result = eval(read(gfun), NULL);
|
object *result = eval(read((pfun_t)gfun), NULL);
|
||||||
clrflag(NOESC);
|
clrflag(NOESC);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else if (ch == '(') { LastChar = ch; return readarray(1, read(gfun)); }
|
else if (ch == '(') { LastChar = ch; return readarray(1, read((pfun_t)gfun)); }
|
||||||
else if (ch == '*') return readbitarray(gfun);
|
else if (ch == '*') return readbitarray((gfun_t)gfun);
|
||||||
else if (ch >= '1' && ch <= '9' && (gfun() & ~0x20) == 'A') return readarray(ch - '0', read(gfun));
|
else if (ch >= '1' && ch <= '9' && (gfun() & ~0x20) == 'A') return readarray(ch - '0', read((pfun_t)gfun));
|
||||||
else error2(0, PSTR("illegal character after #"));
|
else error2(0, PSTR("illegal character after #"));
|
||||||
ch = gfun();
|
ch = gfun();
|
||||||
}
|
}
|
||||||
|
@ -5447,9 +5490,9 @@ object *readrest (gfun_t gfun) {
|
||||||
if (item == (object *)BRA) {
|
if (item == (object *)BRA) {
|
||||||
item = readrest(gfun);
|
item = readrest(gfun);
|
||||||
} else if (item == (object *)QUO) {
|
} else if (item == (object *)QUO) {
|
||||||
item = cons(symbol(QUOTE), cons(read(gfun), NULL));
|
item = cons(symbol(QUOTE), cons(read((pfun_t)gfun), NULL));
|
||||||
} else if (item == (object *)DOT) {
|
} else if (item == (object *)DOT) {
|
||||||
tail->cdr = read(gfun);
|
tail->cdr = read((pfun_t)gfun);
|
||||||
if (readrest(gfun) != NULL) error2(0, PSTR("malformed list"));
|
if (readrest(gfun) != NULL) error2(0, PSTR("malformed list"));
|
||||||
return head;
|
return head;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue