summaryrefslogtreecommitdiff
path: root/basic.h
blob: a2701307fb425777ac2a59c3132f51663df7cd54 (plain) (blame)
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
#ifndef _BASIC_H
#define _BASIC_H

typedef struct sexpr {
    int type;
    union contents {
        float f;
        char *s;
        int i;
        struct node {
            struct sexpr *l;
            struct sexpr *r;
        } n;
    } contents;
} sexpr;

typedef struct node node;
typedef union contents contents;

sexpr *new_int(int num);
sexpr *new_float(float num);
sexpr *new_id(char *id);
sexpr *new_node(sexpr *l, sexpr *r);
sexpr *new_str(char *str);

void print_sexpr(sexpr *se);
void fprint_sexpr(FILE *f, sexpr *se);

void codegen(sexpr *sexpr);

#endif /* _BASIC_H */