fix implementation of ABORT, ABORT" and QUIT
This commit is contained in:
@@ -22,7 +22,7 @@ enum fh_error register_builtin_words(struct fh_thread_s *fh);
|
||||
|
||||
#define ENSURE_STATE(__state) do { \
|
||||
if (fh->state != (__state)) { \
|
||||
LOGE("Invalid state %d, expected %d", fh->state, (__state)); \
|
||||
LOGE("Invalid state %d, expected %d in file " __FILE__ " line %d", fh->state, (__state), __LINE__); \
|
||||
return FH_ERR_INVALID_STATE; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
@@ -29,6 +29,7 @@ enum fh_error {
|
||||
FH_ERR_SYNTAX,
|
||||
FH_ERR_NOT_APPLICABLE,
|
||||
FH_ERR_PICTNUM_FULL,
|
||||
FH_ERR_BAD_DEFER,
|
||||
FH_ERR_MAX,
|
||||
};
|
||||
|
||||
|
||||
@@ -21,4 +21,10 @@ enum fh_error fh_input_read_quotedstring(struct fh_thread_s *fh, bool escaped, c
|
||||
|
||||
enum fh_error fh_handle_ascii_word(struct fh_thread_s *fh, const char *name, size_t wordlen);
|
||||
|
||||
// chartest space or 0, param is ignored
|
||||
bool fh_chartest_space_or_end(char c, void *param);
|
||||
|
||||
// chartest given char or 0. param is pointer to char.
|
||||
bool fh_chartest_equals_or_end(char c, void *param);
|
||||
|
||||
#endif //FORTH_FH_PARSE_H
|
||||
|
||||
@@ -43,6 +43,9 @@ enum fh_instruction_kind {
|
||||
/** This is the `."` instruction, same format as above. */
|
||||
FH_INSTR_TYPESTR,
|
||||
|
||||
/** abort" in compiled form */
|
||||
FH_INSTR_ABORTSTR,
|
||||
|
||||
/* Unconditional jump */
|
||||
FH_INSTR_JUMP,
|
||||
|
||||
@@ -76,12 +79,22 @@ enum fh_instruction_kind {
|
||||
|
||||
/* Postponed word */
|
||||
FH_INSTR_POSTPONED_WORD,
|
||||
|
||||
/* Action-of in compiled form */
|
||||
FH_INSTR_ACTIONOF,
|
||||
|
||||
/* IS in compiled form */
|
||||
FH_INSTR_ISDEFER,
|
||||
|
||||
FH_INSTR_MAX,
|
||||
};
|
||||
|
||||
const char *instr_name(enum fh_instruction_kind kind);
|
||||
|
||||
void fh_quit(struct fh_thread_s *fh);
|
||||
void fh_abort(struct fh_thread_s *fh);
|
||||
void fh_drop_to_interactive(struct fh_thread_s *fh);
|
||||
|
||||
/** One instruction in bytecode */
|
||||
struct fh_instruction_s {
|
||||
/** What is the meaning of data? */
|
||||
@@ -133,6 +146,8 @@ extern const char *substatenames[FH_SUBSTATE_MAX];
|
||||
#define WORDFLAG_CREATED 0x20
|
||||
/** Word marked as hidden is not findable, e.g. because it is being compiled. */
|
||||
#define WORDFLAG_HIDDEN 0x40
|
||||
/** Created using DEFER */
|
||||
#define WORDFLAG_DEFER 0x80
|
||||
|
||||
/** Word struct as they are stored in the dictionary */
|
||||
struct fh_word_s {
|
||||
|
||||
Reference in New Issue
Block a user