summaryrefslogtreecommitdiff
path: root/test.c
blob: f41ae64faadd9ed8d188dfc9dd92d6a158d3f551 (plain)
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
31
#include <stdio.h>

#define fixnum_mask 3
#define fixnum_tag 0
#define fixnum_shift 2
#define char_mask 255
#define char_shift 8
#define char_tag 15
#define boolean_mask 127
#define boolean_shift 7
#define boolean_tag 31
#define empty_list 47

int main(int argc, char** argv) {
  int val = scheme_entry();

  if((val & fixnum_mask) == fixnum_tag) {
    printf("%d\n", val >> fixnum_shift);
  } else if((val & char_mask) == char_tag) {
    printf("%c\n", val >> char_shift);
  } else if((val & boolean_mask) == boolean_tag) {
    if((val >> boolean_shift) == 1) {
      printf("#t\n");
    } else {
      printf("#f\n");
    }
  } else if(val == empty_list) {
    printf("()\n");
  }
  return 0;
}