This repository has been archived on 2026-05-18. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
piquant/src/basic.h

78 lines
1.6 KiB
C
Raw Normal View History

#ifndef _BASIC_H_
#define _BASIC_H_
2015-01-26 21:55:55 -08:00
#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
2015-01-26 21:55:55 -08:00
#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
2015-01-26 21:55:55 -08:00
#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
2015-01-26 21:55:55 -08:00
#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;
2015-01-26 21:55:55 -08:00
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;
2015-01-26 21:55:55 -08:00
#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;
2015-01-26 21:55:55 -08:00
};
typedef struct basic_variable basic_variable;
2015-01-26 21:55:55 -08:00
#define BASIC_CONST_TRUE 1
#define BASIC_CONST_FALSE 0
extern int basic_errno;
2015-01-27 18:56:12 -08:00
void basic_repl(void);
#endif /* _BASIC_H_ */