aboutsummaryrefslogtreecommitdiff
path: root/src/csxbind.c
blob: cc430122089632d3e8d75fde569d1f180fd92561 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#include "csxbind.h"

#include <stdarg.h>


char *name;
char *pair;
char *str;
char *_int;
char *base;
char *fn;
char *sx;
char *set;
char *_isset;
char *sethead;
char *settail;
char *head;
char *tail;
char *qt;
char *same;
char *type;
char *_do;
char *_if;
char *_plus;
char *_star;
char *neg;
char *div;
char *mod;
char *_less;
char *_more;
char *out;
char *in;
char *len;
char *run;
char *context;
char *newcontext;
char *_exit;


static csxi csx;


void csxbind_init()
{
    csxbasenames *n;
    csx_init(&csx);
    n          = &csx.basenames;
    name       = n->name;
    pair       = n->pair;
    str        = n->str;
    _int       = n->_int;
    base       = n->base;
    fn         = n->fn;
    sx         = n->sx;
    set        = n->set;
    _isset     = n->_isset;
    sethead    = n->sethead;
    settail    = n->settail;
    head       = n->tail;
    tail       = n->tail;
    qt         = n->qt;
    same       = n->same;
    type       = n->type;
    _do        = n->_do;
    _if        = n->_if;
    _plus      = n->_plus;
    _star      = n->_star;
    neg        = n->neg;
    div        = n->div;
    mod        = n->mod;
    _less      = n->_less;
    _more      = n->_more;
    out        = n->out;
    in         = n->in;
    len        = n->len;
    run        = n->run;
    context    = n->context;
    newcontext = n->newcontext;
    _exit      = n->_exit;
}

void csxbind_free()
{
    csx_free(&csx);
}


csxpair *L(void *head, ...)
{
    va_list args;
    csxpair *res;
    csxpair **p;
    if (!head) return csx.null;
    res = csx_pair(&csx, head, csx.null);
    p = (csxpair **)&res->tail;
    va_start(args, head);
    for (head = va_arg(args, void *); head; head = va_arg(args, void *)) {
        *p = csx_pair(&csx, head, csx.null);
        p = (csxpair **)&(*p)->tail;
    }
    va_end(args);
    return res;
}
csxpair *D(void *a, void *b, void *c, ...)
{
    va_list args;
    csxpair *res;
    csxpair **p;
    if (!c) return csx_pair(&csx, a, b);
    res = csx_pair(&csx, a, b);
    p = (csxpair **)&res->tail;
    *p = csx_pair(&csx, *p, c);
    p = (csxpair **)&(*p)->tail;
    va_start(args, c);
    for (c = va_arg(args, void *); c; c = va_arg(args, void *)) {
        *p = csx_pair(&csx, *p, c);
        p = (csxpair **)&(*p)->tail;
    }
    va_end(args);
    return res;
}
csxpair *P(void *head, void *tail)
{
    return csx_pair(&csx, head, tail);
}
char *N(const char *name)
{
    return csx_name(&csx, name);
}
char *S(const char *str)
{
    return csx_str(&csx, str);
}
int *I(int num)
{
    return csx_int(&csx, num);
}

void *R(void *expression)
{
    return csx_run(&csx, expression);
}

csxbase *newbase(csxbase base)
{
    return csx_base(&csx, base);
}