2017-03-29 01:25:39 +01:00
|
|
|
/* This file is part of stage0.
|
|
|
|
*
|
|
|
|
* stage0 is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* stage0 is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with stage0. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2016-12-17 01:59:57 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
enum otype
|
|
|
|
{
|
2017-02-04 19:27:24 +00:00
|
|
|
FREE = 1,
|
|
|
|
MARKED = (1 << 1),
|
|
|
|
INT = (1 << 2),
|
|
|
|
SYM = (1 << 3),
|
|
|
|
CONS = (1 << 4),
|
|
|
|
PROC = (1 << 5),
|
|
|
|
PRIMOP = (1 << 6),
|
|
|
|
ASCII = (1 << 7)
|
2016-12-17 01:59:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct cell* (*Operation)(struct cell *);
|
|
|
|
|
|
|
|
typedef struct cell
|
|
|
|
{
|
|
|
|
enum otype type;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct cell* car;
|
|
|
|
int value;
|
|
|
|
char* string;
|
|
|
|
Operation function;
|
|
|
|
};
|
|
|
|
struct cell* cdr;
|
|
|
|
struct cell* env;
|
|
|
|
} cell;
|
|
|
|
|
|
|
|
#define MAXLEN 256
|
|
|
|
|
|
|
|
|
|
|
|
struct cell* make_cons(struct cell* a, struct cell* b);
|
|
|
|
|
|
|
|
/* Global objects */
|
2017-02-04 19:27:24 +00:00
|
|
|
struct cell *all_symbols, *top_env, *nil, *tee, *quote, *s_if, *s_lambda, *s_define, *s_setb, *s_cond, *s_begin;
|