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

xlprin.c

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

Click here to get the file

Size 1 kB - File type text/x-csrc

File contents

/* xlprint - xlisp print routine */

#include "xlisp.h"

/* xlprint - print an xlisp value */
xlprint(vptr)
  struct node *vptr;
{
    struct node *nptr,*next;

    /* print null as the empty list */
    if (vptr == NULL) {
	printf("()");
	return;
    }

    /* check value type */
    switch (vptr->n_type) {
    case SUBR:
	    printf("#%o",vptr->n_subr);
	    break;
    case FUN:
    case LIST:
	    putchar('(');
	    for (nptr = vptr; nptr != NULL; nptr = next) {
	        xlprint(nptr->n_listvalue);
		if ((next = nptr->n_listnext) != NULL)
		    if (next->n_type == LIST)
			putchar(' ');
		    else {
			putchar('.');
			xlprint(next);
			break;
		    }
	    }
	    putchar(')');
	    break;
    case SYM:
	    printf("%s",vptr->n_symname);
	    break;
    case INT:
	    printf("%d",vptr->n_int);
	    break;
    case STR:
	    printf("%s",vptr->n_str);
	    break;
    }
}
« September 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: