iris

small scheme interpreter
git clone git://git.2f30.org/iris
Log | Files | Refs | LICENSE

debug.c (1029B)


      1 /* See LICENSE file for copyright and license details. */
      2 #include <stdio.h>
      3 #include <stdlib.h>
      4 #include "lexer.h"
      5 #include "debug.h"
      6 
      7 void
      8 printtok(struct tok *t)
      9 {
     10 	char *l;
     11 
     12 	l = lexeme(t);
     13 	if (!l)
     14 		return;
     15 	switch (t->type) {
     16 	case TError:
     17 		printf("token: error, value: '%s'", l);
     18 		break;
     19 	case TEof:
     20 		printf("token: eof");
     21 		break;
     22 	case TIdentifier:
     23 		printf("token: identifier, value: '%s'", l);
     24 		break;
     25 	case TBoolean:
     26 		printf("token: boolean, value: '%s'", l);
     27 		break;
     28 	case TInteger:
     29 		printf("token integer, value: '%s'", l);
     30 		break;
     31 	case TCharacter:
     32 		printf("token character, value: '%s'", l);
     33 		break;
     34 	case TString:
     35 		printf("token string, value: '%s'", l);
     36 		break;
     37 	case TLparen:
     38 		printf("token: lparen, value: '%s'", l);
     39 		break;
     40 	case TRparen:
     41 		printf("token rparen, value: '%s'", l);
     42 		break;
     43 	case TQuote:
     44 		printf("token quote, value: '%s'", l);
     45 		break;
     46 	case TDot:
     47 		printf("token dot, value: '%s'", l);
     48 		break;
     49 	default:
     50 		printf("unknown token type: %d", t->type);
     51 		break;
     52 	}
     53 	free(l);
     54 }