|
楼主 |
发表于 2011-6-6 15:54:03
|
显示全部楼层
没法看了……
- #define TOKEN_BUFFER_SIZE 256
- #define SYMBOL_BUFFER_SZIE 32
- #define STRING_BUFFER_SIZE 128
- #define STACK_SIZE 64
- #define NAME_LENGTH 12
- extern const char *TYPE_TEXT[];
- int MalicalError (const char *);
- int MalicalTokenError ();
- typedef enum
- {
- B_NO,
- B_IF,
- B_OT
- } BLOCK;
- typedef enum
- {
- TT_NUM=1,
- TT_NIL,
- TT_BOOL,
- TT_STR,
- TT_SYM,
- TT_SIGN,
- TT_BK,
- TT_REF
- } TOKEN_TYPE;
- extern char token[];
- extern char line[];
- typedef enum
- {
- SIGN_ADD = 256,
- SIGN_SUB,
- SIGN_MUL,
- SIGN_DIV,
- SIGN_POW,
- SIGN_BLK,
- SIGN_BRK,
- SIGN_AND,
- SIGN_OR ,
- SIGN_NOT,
- SIGN_EQ ,
- SIGN_NEQ,
- SIGN_BT ,
- SIGN_BE ,
- SIGN_LT ,
- SIGN_LE ,
- SIGN_STO
- } SIGN;
- typedef struct
- {
- char *name;
- SIGN value;
- }SIGNVALUE;
- int GetToken (char *context,int pos,TOKEN_TYPE *type);
- int Match (char *text,char *find,TOKEN_TYPE type,int pl);
- int GetTokenE (char *text,char l,char r,int pl);
- int GetLine(char *text,int p);
- int LineEmpty (int p);
- int SignToValue (char *sign);
- typedef union
- {
- int b;
- char *str;
- double n;
- void *ref;
- }Value;
- typedef enum
- {
- VT_NIL,
- VT_BOOL,
- VT_STR,
- VT_NUM,
- VT_REF
- }Type;
- typedef struct
- {
- Type tag;
- Value value;
- }Object;
- typedef struct
- {
- Object *stk[STACK_SIZE];
- int size;
- }ObjectStack;
- void obj_ini (Object *d);
- void obj_clear (Object *d);
- Object* obj_copy (Object *d,const Object *s);
- Object* obj_create (Object *d,Type tag,void *value);
- char* obj_to_str(Object *s, char *str);
- void objs_push (ObjectStack *s,Object *n_o);
- void objs_pop (ObjectStack *s,Object *n_o);
- void objs_clear (ObjectStack *s);
- #define o_is_num(o) ((o)->tag==VT_NUM)
- #define o_is_bool(o) ((o)->tag==VT_BOOL)
- #define o_is_str(o) ((o)->tag==VT_STR)
- int EvalExpr (char *expr,Object *objr);
- typedef struct
- {
- char name[NAME_LENGTH];
- Object obj;
- }Variable;
- typedef struct
- {
- Variable *vars[STACK_SIZE];
- int size;
- }VarStack;
- void var_copy (Variable *d,Variable *s);
- void var_create (Variable *v,const char *name,Object *obj);
- void var_stk_push (VarStack * vs,Variable *v);
- void var_stk_clear (VarStack * vs);
- extern VarStack GlobalVar;
- extern VarStack *LocalVar[];
- extern int LocalTop;
- void new_local_var_stack ();
- void delete_local_var_stack ();
- Variable* find_var (char *name);
- typedef struct
- {
- char name[NAME_LENGTH];
- int pos;
- }FUNCTION;
- void func_push (const char *name,int pos);
- int find_func (const char *name);
- // parser
- void CallFun (const char *name,ObjectStack*);
- int RunIfBlock (int p,int todo,int _todo);
- int RunWhileBlock (int b,char *expr,int _todo);
- int RunFunction (int p,int todo,int is_block);
- int MalicalPrescan ();
- int RunFile (char* file_name);
- extern Object ReturnObject;
复制代码 |
|