Personal tools
You are here: Home Projects LISP XLISP XLISP 0.0 Sources unpacked xlisp.c
Document Actions

xlisp.c

by Paul McJones last modified 2011-01-24 09:58

Click here to get the file

Size 1.2 kB - File type text/x-csrc

File contents

/* xlisp - a small subset of lisp */

#include <setjmp.h>
#include "xlisp.h"

/* global variables */
jmp_buf xljmpbuf;

extern struct node *xlread();
extern struct node *xleval();

/* external variables */
extern struct node *xlenv;
extern struct node *xlstack;
extern int xlpvals;

/* inhibit the argv prompt */
int $$narg = 1;

/* main - the main routine */
main(argc,argv)
  int argc; char *argv[];
{
    struct node expr;

    /* initialize the dynamic memory module (must be first) */
    xldmeminit();

    /* initialize xlisp */
    xlinit();
    xleinit(); xllinit(); xlminit();
    xlkinit(); xloinit(); xlsinit();

    /* initialize terminal input */
    xltin();

    /* read the input file if specified */
    if (argc > 1)
	xlfin(argv[1]);

    /* main command processing loop */
    while (TRUE) {

	/* setup the error return */
	setjmp(xljmpbuf);

	/* free any previous expression and leftover context */
	xlstack = xlenv = NULL;

	/* create a new stack frame */
	xlsave(&expr,NULL);

	/* read an expression */
	expr.n_ptr = xlread();

	/* evaluate the expression */
	expr.n_ptr = xleval(expr.n_ptr);

	/* print it if necessary */
	if (xlpvals) {
	    xlprint(expr.n_ptr);
	    putchar('\n');
	}
    }
}
April 2013 »
Su Mo Tu We Th Fr Sa
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
 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: