📄 compiler.h
字号:
/****************************************************************//* *//* Name: compiler.h *//* *//* Project: NeuroBasic, basic package *//* *//* Survey: Header file for basic.c, the basic compiler. *//* *//* Author: Urs Muller *//* Electronics Laboratory, ETH Zurich *//* Switzerland *//* *//* Created: October 21, 1994 *//* Modified: July 27, 1995 (um) *//* *//****************************************************************//* macros *//**********/#define BLOCKING_SIZE 1000 /* Buffers are reallocated in blocks of this size (number of code words). *//* function macros *//*******************//* extend isalpha() and isalnum() to accept '_' as well */#define ISXALPHA(ch) (isalpha(ch) || (ch) == '_')#define ISXALNUM(ch) (isalnum(ch) || (ch) == '_')/* token type definitions *//**************************//*===== token values =====*/typedef enum{ EQU, /* "=" */ /* punctiation tokens... */ NEQ, /* "<>" or "#" */ GEQ, /* ">=" */ LEQ, /* "<=" */ GTH, /* ">" */ LTH, /* "<" */ PLUS, /* "+" */ MINUS, /* "-" */ MUL, /* "*" */ DIV, /* "/" */ IDIV, /* integer divide */ MOD, /* "%" */ POW, /* "^" or "**" */ LPAR, /* "(" */ RPAR, /* ")" */ RBRA, /* "]" */ COLON, /* ":" */ SEMICOLON, /* ";" */ COMMA, /* "," */ AND, OR, EXOR, NOT, FOR, TO, DOWNTO, NEXT, LABEL, RETURN, INPUT, IF, THEN, PRINT, FPRINT, DEFFN, ENDFN, DIM, LET, /* assignment command */ GOTO, GOSUB, NUMBER, /* a number */ /* other tokesn... */ CONST, /* a symbolic constant */ NAME, /* a (not yet specified) name */ ARRAY_NAME, /* an array name */ FCT_NAME, /* a function name */ STRFCT_NAME, /* name of a function which returns a string */ STRING, /* an immediate string */ STRING_NAME, /* a string variable name */ END_LINE, /* end of source line */ END, /* end of program */ NO_TOKEN /* not a legal token */} token_value_t;/*===== keyword/punctuation table =====*/typedef struct{ const char *string; token_value_t token_value;} token_table_t;/* other type definitions *//**************************//*===== symbol tables =====*/typedef struct{ char **names; /* pointer to array of symbol names */ MINT max; /* current allocated size of table */ MINT pos; /* current used size of table */} symbol_table_t;/*===== b-code types =====*/typedef enum{ CODE, OFFSET, VALUE, RESET, IDLE} code_t;/*===== relocation table type =====*/typedef struct{ size_t b_pos; long src_line_nr; long ref_line_nr; char *name;} reloc_tab_t;/*===== etc =====*/typedef struct{ const char *name; MINT nargs;} ifct_ref_t;typedef struct{ size_t b_pos; MINT nargs;} ufct_ref_t;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -