X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=gmqcc.h;h=5acfbd57963ca3eeaaff524b951b0791fdda00b2;hb=02e9098d3dfc679137641c977bb9938ad9bacebb;hp=162eed48be74cc43a6d1ddaf7a58c49b6fadb5cd;hpb=fe6e142f85defcfec5e8b30d68e7348ab262d727;p=xonotic%2Fgmqcc.git diff --git a/gmqcc.h b/gmqcc.h index 162eed4..5acfbd5 100644 --- a/gmqcc.h +++ b/gmqcc.h @@ -20,8 +20,8 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#ifndef DPQCC_HDR -#define DPQCC_HDR +#ifndef GMQCC_HDR +#define GMQCC_HDR #include /* The types supported by the language */ @@ -121,9 +121,6 @@ #define INSTR_BITAND 59 #define INSTR_BITOR 60 -#define mem_a(x) malloc(x) -#define mem_d(x) free (x) - /* * This is the smallest lexer I've ever wrote: and I must say, it's quite * more nicer than those large bulky complex parsers that most people write @@ -140,12 +137,13 @@ struct lex_file { int current; int length; int size; + long line; /* Line the lexer is on */ char lastok[8192]; /* No token shall ever be bigger than this! */ }; /* * It's important that this table never exceed 32 keywords, the ascii - * table starts at 33 (which we need) + * table starts at 33 (and we don't want conflicts) */ #define TOKEN_DO 0 #define TOKEN_ELSE 1 @@ -155,38 +153,64 @@ struct lex_file { #define TOKEN_CONTINUE 5 #define TOKEN_RETURN 6 #define TOKEN_GOTO 7 -#define TOKEN_FOR 8 +#define TOKEN_FOR 8 // extension +#define TOKEN_TYPEDEF 9 // extension + + +#define TOKEN_FLOAT 110 +#define TOKEN_VECTOR 111 +#define TOKEN_STRING 112 +#define TOKEN_ENTITY 113 +#define TOKEN_VOID 114 /* * Lexer state constants, these are numbers for where exactly in * the lexing the lexer is at. Or where it decided to stop if a lexer * error occurs. */ -#define LEX_COMMENT 128 /* higher than ascii */ -#define LEX_CHRLIT 129 -#define LEX_STRLIT 130 -#define LEX_IDENT 131 -#define LEX_DO 132 -#define LEX_ELSE 133 -#define LEX_IF 134 -#define LEX_WHILE 135 -#define LEX_INCLUDE 136 -#define LEX_DEFINE 137 +#define LEX_COMMENT 1128 /* higher than ascii */ +#define LEX_CHRLIT 1129 +#define LEX_STRLIT 1130 +#define LEX_IDENT 1131 int lex_token(struct lex_file *); void lex_reset(struct lex_file *); -int lex_debug(struct lex_file *); int lex_close(struct lex_file *); -struct lex_file *lex_open (const char *); +struct lex_file *lex_open (FILE *); /* errors */ #define ERROR_LEX (SHRT_MAX+0) #define ERROR_PARSE (SHRT_MAX+1) #define ERROR_INTERNAL (SHRT_MAX+2) #define ERROR_COMPILER (SHRT_MAX+3) +#define ERROR_PREPRO (SHRT_MAX+4) int error(int, const char *, ...); /* parse.c */ int parse(struct lex_file *); +struct parsenode { + struct parsenode *next; + int type; /* some token */ +}; +/* typedef.c */ +typedef struct typedef_node_t { + char *name; /* name of actual type */ +} typedef_node; + +void typedef_init(); +void typedef_clear(); +typedef_node *typedef_find(const char *); +int typedef_add (const char *, const char *); + +/* alloc.c */ +void *memory_a(unsigned int, unsigned int, const char *); +void memory_d(void *, unsigned int, const char *); +#ifdef NOTRACK +# define mem_a(x) malloc(x) +# define mem_d(x) free (x) +#else +# define mem_a(x) memory_a((x), __LINE__, __FILE__) +# define mem_d(x) memory_d((x), __LINE__, __FILE__) +#endif #endif