#ifndef _BASIC_H_ #define _BASIC_H_ #define BASIC_OPTP_ADD 1 #define BASIC_OPTP_SUB 2 #define BASIC_OPTP_MUL 3 #define BASIC_OPTP_DIV 4 #define BASIC_OPTP_MOD 5 #define BASIC_OPTP_EQL 6 #define BASIC_OPTP_ASN 7 #define BASIC_LVAL_EXPR 0 #define BASIC_LVAL_VAR 1 #define BASIC_LVAL_CONST 2 #define BASIC_RVAL_EXPR 3 #define BASIC_RVAL_VAR 4 #define BASIC_RVAL_CONST 5 #define BASIC_FOUND_LVAL 0x0001 #define BASIC_FOUND_RVAL 0x0002 #define BASIC_ERR_SYNTAX_MULTIPLE_LVALUES 1 #define BASIC_ERR_SYNTAX_TOKEN_LENGTH 2 #define BASIC_ERR_SYNTAX_GENERAL 3 #define BASIC_ERR_SYNTAX_MULTIPLE_RVALUES 4 #define BASIC_ERR_INVALID_ARGUMENTS 5 #define BASIC_ERR_INTERNAL_NULLPOINTER 6 #define BASIC_ERR_INTERNAL_MEMORY 7 #define BASIC_ERR_INTERNAL_UNDEFINED_BEHAVIOR 8 #define BASIC_ERR_INTERNAL_UNIMPLEMENTED 9 #define BASIC_ERR_MATH_DBZ 10 #define BASIC_TOKENIZER_TOKENS "+-/%*=" #define BASIC_TOKENIZER_MAX_LENGTH 512 #define BASIC_VARNAME_MAX_LENGTH 16 union basic_value { char c; int i; unsigned int uint; /* we don't handle floats yet. need to implement Fcomp, fpushf, fpushd. * float f; */ char *str; void *ptr; }; typedef union basic_value basic_value; struct basic_expr { char type; char lval_type; char rval_type; char pad; basic_value lval; basic_value rval; }; typedef struct basic_expr basic_expr; #define BASIC_VARFLAG_INIT 1 #define BASIC_VARFLAG_TINT 2 #define BASIC_VARFLAG_TSTR 4 struct basic_variable { char *name; char flags; basic_value value; }; typedef struct basic_variable basic_variable; struct basic_line { int lineno; char content[256]; struct basic_line *nextline; }; typedef struct basic_line basic_line; struct basic_program { char name[128]; basic_line *first; }; typedef struct basic_program basic_program; #define BASIC_CONST_TRUE 1 #define BASIC_CONST_FALSE 0 extern int basic_errno; void basic_repl(basic_program *program); basic_expr *basic_parse_expr(char *); #endif /* _BASIC_H_ */