151 int Interpreter::compile_program() {
152 for (
Code *co=prg; co; co=co->
next) {
153 if (!strncmp(co->str,
"IF", 2)) { co->set_command(
CT_IF, co->str+2);
continue; }
154 if (!strncmp(co->str,
"ELSEIF", 6)) { co->set_command(
CT_ELSEIF, co->str+6);
continue; }
155 if (!strncmp(co->str,
"ELSE", 4)) { co->set_command(
CT_ELSE, co->str+4);
continue; }
156 if (!strncmp(co->str,
"ENDIF", 5)) { co->set_command(
CT_ENDIF, co->str+5);
continue; }
157 if (!strncmp(co->str,
"FOR", 3)) { co->set_command(
CT_FOR, co->str+3);
continue; }
158 if (!strncmp(co->str,
"ENDFOR", 6)) { co->set_command(
CT_ENDFOR, co->str+6);
continue; }
159 if (!strncmp(co->str,
"NEXT", 4)) { co->set_command(
CT_NEXT, co->str+4);
continue; }
161 if (!strncmp(co->str,
"LABEL", 5)) {
162 co->set_command(
CT_LABEL, co->str+5);
163 define_fun(co->str, co);
166 if (!strncmp(co->str,
"FUNCTION", 8)) {
185 define_fun(buf2, co);
191 co->cmd = find_command(co);
210 for (
int i = 0; i<size; ++i) {
213 if (e->val) free(e->val);
222 int hash::Index(
const char *key)
const {
228 x = (((x & 0x7fff)<<1) | ((x & 0x8000)>>15)) ^ c;
235 const hash_entry *hash::find_entry(
const char *key,
int idx)
const {
237 if (!strcmp(e->key, key))
return e;
243 int idx = Index(key);
246 freeset(e->
val, nulldup(val));
250 e->
next = entries[idx];
251 e->
key = strdup(key);
252 e->
val = val ? strdup(val) :
NULp;
260 for (
Stack *s = stack; s && !ref; s = s->next) {
261 ref = s->hs->ref(key);
static Code * aisc_calc_blocks(Code *co, Code *afor, Code *aif, int up)
void write(const char *key, const char *val)
var_ref get_local(const char *key)
#define print_error(code_or_loc, err)
CONSTEXPR_INLINE bool is_SPACE_SEP_LF_EOS(char c)
const char * read() const
const char * read_local(const char *key) const
void SKIP_SPACE_LF(const char *&var)
GB_write_int const char s