refactor "next word/string" parsing to work inside the definition without substates, add char and [char], add .\" and s\"

This commit is contained in:
2021-11-16 01:09:23 +01:00
parent 7f08e8717f
commit f74d157a7c
6 changed files with 230 additions and 109 deletions
+1
View File
@@ -26,6 +26,7 @@ enum fh_error {
FH_ERR_ILLEGAL_FETCH,
FH_ERR_ILLEGAL_STORE,
FH_ERR_DIV_BY_ZERO,
FH_ERR_SYNTAX,
FH_ERR_MAX,
};
+16 -6
View File
@@ -82,15 +82,9 @@ enum fh_state {
/** Forth runtime minor state */
enum fh_substate {
FH_SUBSTATE_NONE = 0,
FH_SUBSTATE_COLON_NAME,
FH_SUBSTATE_S_QUOTE,
FH_SUBSTATE_DOT_QUOTE,
FH_SUBSTATE_PAREN_COMMENT,
FH_SUBSTATE_LINE_COMMENT,
FH_SUBSTATE_EXIT,
FH_SUBSTATE_SEE_NAME,
FH_SUBSTATE_POSTPONE_NAME,
FH_SUBSTATE_CHAR,
FH_SUBSTATE_MAX,
};
@@ -174,6 +168,22 @@ void fh_setsubstate(struct fh_thread_s *fh, enum fh_substate substate);
enum fh_error w_user_word(struct fh_thread_s *fh, const struct fh_word_s *w);
enum fh_error fh_input_read_quotedstring(struct fh_thread_s *fh, bool escaped, char *outbuf, size_t capacity, size_t *out_len);
enum fh_error fh_input_read_word(struct fh_thread_s *fh, char **out, size_t *len);
void fh_input_consume_spaces(struct fh_thread_s *fh);
enum fh_error fh_postpone_word(
struct fh_thread_s *fh,
const char *name,
size_t wordlen
);
enum fh_error fh_see_word(
struct fh_thread_s *fh,
const char *name,
size_t wordlen
);
/* if the return address is this, we should drop back to interactive mode */
// SFR and magic addresses are "negative"