stage0/stage2/High_level_prototypes/lisp.h

59 lines
1.4 KiB
C
Raw Normal View History

2017-04-01 22:26:44 +01:00
/* Copyright (C) 2016 Jeremiah Orians
* This file is part of stage0.
2017-03-29 01:25:39 +01:00
*
* 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
{
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 */
struct cell *all_symbols, *top_env, *nil, *tee, *quote, *s_if, *s_lambda, *s_define, *s_setb, *s_cond, *s_begin;