tinyvm/include/tvm/tvm_preprocessor.h
Payton Turnage e99a0428f3 Implement defines using the htab structure.
The htab_structure has been modified in two ways, which should not break
compatability with any of its uses.

It includes a void pointer, which is in this commit used to point to a
string for defines, and will in the future be used to point to the address
space for words, bytes, and double words.

It now includes a function htab_add_str specifically for storing strings.
It calls htab_add so as not to be redundant, but makes the node's value
their index for the lexer to fetch using htab_find, and assigns their
void pointer.

The lexer will now use htab_find on all tokens to see if they are a define
string, and if so, substitute them with the appropriate token.

The defines htab is destroyed after lexing, because that memory is done.
2014-01-13 10:20:21 -05:00

8 lines
154 B
C

#ifndef TVM_PREPROCESSOR_H_
#define TVM_PREPROCESSOR_H_
#include "tvm_htab.h"
int tvm_preprocess(char *src, int *src_len, tvm_htab_t *defines);
#endif