Update
This commit is contained in:
parent
4e8c187050
commit
bd9b51be9a
8 changed files with 142 additions and 85 deletions
|
@ -76,11 +76,11 @@ typedef struct HYDROFORTH__SCAN_NEXT_WORD_RESULT
|
|||
|
||||
extern HYDROFORTH__SCAN_NEXT_WORD_RESULT hydroforth__scan_next_word(HYDROFORTH__INTERPRETER *interpreter);
|
||||
|
||||
extern bool hydroforth__parse(HYDROFORTH__INTERPRETER *interpreter);
|
||||
extern void hydroforth__parse(HYDROFORTH__RESULT *const result, HYDROFORTH__INTERPRETER *interpreter);
|
||||
|
||||
extern bool hydroforth__run_call_stack(HYDROFORTH__INTERPRETER *interpreter);
|
||||
extern void hydroforth__run_call_stack(HYDROFORTH__RESULT *const result, HYDROFORTH__INTERPRETER *interpreter);
|
||||
|
||||
extern bool hydroforth__run(HYDROFORTH__INTERPRETER *interpreter);
|
||||
extern void hydroforth__run(HYDROFORTH__RESULT *const result, HYDROFORTH__INTERPRETER *interpreter);
|
||||
|
||||
typedef struct __HYDROFORTH
|
||||
{
|
||||
|
@ -90,15 +90,16 @@ typedef struct __HYDROFORTH
|
|||
bool (*is_space)(char c);
|
||||
HYDROFORTH__SCAN_NEXT_WORD_RESULT(*scan_next_word)
|
||||
(HYDROFORTH__INTERPRETER *interpreter);
|
||||
bool (*parse)(HYDROFORTH__INTERPRETER *interpreter);
|
||||
bool (*run_call_stack)(HYDROFORTH__INTERPRETER *interpreter);
|
||||
bool (*run)(HYDROFORTH__INTERPRETER *interpreter);
|
||||
void (*parse)(HYDROFORTH__RESULT *const result, HYDROFORTH__INTERPRETER *interpreter);
|
||||
void (*run_call_stack)(HYDROFORTH__RESULT *const result, HYDROFORTH__INTERPRETER *interpreter);
|
||||
void (*run)(HYDROFORTH__RESULT *const result, HYDROFORTH__INTERPRETER *interpreter);
|
||||
} __HYDROFORTH;
|
||||
|
||||
static const __HYDROFORTH hydroforth = {
|
||||
.result = {
|
||||
.add_backtrace = hydroforth__result__add_backtrace,
|
||||
.get_error_message = hydroforth__result__get_error_message,
|
||||
.unwrap = hydroforth__result__unwrap,
|
||||
},
|
||||
.number = {
|
||||
.is_digit = hydroforth__number__is_digit,
|
||||
|
|
|
@ -3,20 +3,20 @@
|
|||
|
||||
extern bool hydroforth__number__is_digit(char c);
|
||||
|
||||
extern void hydroforth__number__convert_hex_digit(HYDROFORTH__RESULT *const result, char c, unsigned char *const val);
|
||||
extern unsigned char hydroforth__number__convert_hex_digit(HYDROFORTH__RESULT *const result, char c);
|
||||
|
||||
extern void hydroforth__number__parse_number_hex(HYDROFORTH__RESULT *const result, const char *const start, unsigned char len, int *const val);
|
||||
extern int hydroforth__number__parse_number_hex(HYDROFORTH__RESULT *const result, const char *const start, unsigned char len);
|
||||
|
||||
extern void hydroforth__number__parse_number(HYDROFORTH__RESULT *const result, const char *const start, unsigned char len, int *const val);
|
||||
extern int hydroforth__number__parse_number(HYDROFORTH__RESULT *const result, const char *const start, unsigned char len);
|
||||
|
||||
extern unsigned char hydroforth__number__count_digits(int n);
|
||||
|
||||
typedef struct __HYDROFORTH__NUMBER
|
||||
{
|
||||
bool (*is_digit)(char c);
|
||||
void (*convert_hex_digit)(HYDROFORTH__RESULT *const result, char c, unsigned char *const val);
|
||||
void (*parse_number_hex)(HYDROFORTH__RESULT *const result, const char *const start, unsigned char len, int *const val);
|
||||
void (*parse_number)(HYDROFORTH__RESULT *const result, const char *const start, unsigned char len, int *const val);
|
||||
unsigned char (*convert_hex_digit)(HYDROFORTH__RESULT *const result, char c);
|
||||
int (*parse_number_hex)(HYDROFORTH__RESULT *const result, const char *const start, unsigned char len);
|
||||
int (*parse_number)(HYDROFORTH__RESULT *const result, const char *const start, unsigned char len);
|
||||
unsigned char (*count_digits)(int n);
|
||||
} __HYDROFORTH__NUMBER;
|
||||
|
||||
|
|
|
@ -3,10 +3,15 @@
|
|||
|
||||
typedef enum HYDROFORTH__RESULT__ERROR
|
||||
{
|
||||
OK,
|
||||
OK = 0,
|
||||
|
||||
ERR_UNKNOWN,
|
||||
|
||||
ERR_INVALID_HEX_CHAR,
|
||||
ERR_UNKNOWN_SINGLE_CHAR_WORD,
|
||||
ERR_UNKNOWN_WORD,
|
||||
ERR_UNTERMINATED_WORD_DEFINITION,
|
||||
ERR_WORD_NAME_CANT_BE_NUMBER,
|
||||
} HYDROFORTH__RESULT__ERROR;
|
||||
|
||||
typedef HYDROFORTH__RESULT__ERROR HYDROFORTH__ERROR;
|
||||
|
@ -14,8 +19,8 @@ typedef HYDROFORTH__RESULT__ERROR HYDROFORTH__ERROR;
|
|||
typedef struct HYDROFORTH__RESULT__RESULT
|
||||
{
|
||||
HYDROFORTH__ERROR error;
|
||||
char **const backtrace;
|
||||
unsigned backtrace_len;
|
||||
const char **backtrace;
|
||||
unsigned short backtrace_len;
|
||||
} HYDROFORTH__RESULT__RESULT;
|
||||
|
||||
typedef HYDROFORTH__RESULT__RESULT HYDROFORTH__RESULT;
|
||||
|
@ -30,11 +35,14 @@ extern const char *hydroforth__result__get_error_message(HYDROFORTH__ERROR error
|
|||
|
||||
#define hydroforth__add_func_backtrace(result) hydroforth__result__add_backtrace(result, __func__);
|
||||
|
||||
extern int hydroforth__result__unwrap(HYDROFORTH__RESULT *const result, int code);
|
||||
|
||||
typedef struct __HYDROFORTH__RESULT
|
||||
{
|
||||
void (*add_backtrace)(HYDROFORTH__RESULT *const result, const char *const s);
|
||||
void (*set)(HYDROFORTH__RESULT *const result, HYDROFORTH__ERROR error, const char *const s);
|
||||
const char *(*get_error_message)(HYDROFORTH__ERROR error);
|
||||
int (*unwrap)(HYDROFORTH__RESULT *const result, int code);
|
||||
} __HYDROFORTH__RESULT;
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue