many fixes using prelimtest
This commit is contained in:
+1
-1
@@ -13,7 +13,7 @@
|
||||
#define HEAP_SIZE (1024*1024)
|
||||
#define MAXLINE 65535
|
||||
#define PAD_OFFSET 340 // why? copied from somewhere
|
||||
#define WORDBUF_SIZE 128
|
||||
#define WORDBUF_SIZE 256
|
||||
#define INPUT_BUFFER_SIZE 256
|
||||
|
||||
#define CELL 4
|
||||
|
||||
@@ -27,6 +27,7 @@ enum fh_error {
|
||||
FH_ERR_ILLEGAL_STORE,
|
||||
FH_ERR_DIV_BY_ZERO,
|
||||
FH_ERR_SYNTAX,
|
||||
FH_ERR_NOT_APPLICABLE,
|
||||
FH_ERR_MAX,
|
||||
};
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ struct fh_global_s {
|
||||
bool verbose;
|
||||
/** Interactive mode (i.e. not started with a file argument) */
|
||||
bool interactive;
|
||||
/** Echo read lines in non-interactive mode */
|
||||
bool echo;
|
||||
};
|
||||
|
||||
extern struct fh_global_s fh_globals;
|
||||
|
||||
@@ -29,6 +29,7 @@ enum fh_error fh_heap_reserve(
|
||||
void fh_heap_write(struct fh_thread_s *fh, uint32_t addr, const void *src, uint32_t len);
|
||||
enum fh_error fh_heap_put(struct fh_thread_s *fh, const void *src, uint32_t len);
|
||||
void fh_heap_copy(struct fh_thread_s *fh, uint32_t addr, uint32_t srcaddr, uint32_t len);
|
||||
void fh_heap_copyptr(struct fh_thread_s *fh, uint32_t addr, char * source, uint32_t len);
|
||||
|
||||
enum fh_error fh_put_instr(struct fh_thread_s *fh, enum fb_instruction_kind kind, uint32_t data);
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Parsing
|
||||
*
|
||||
* Created on 2021/11/17.
|
||||
*/
|
||||
|
||||
#ifndef FORTH_FH_PARSE_H
|
||||
#define FORTH_FH_PARSE_H
|
||||
|
||||
typedef bool (*chartest_t)(char c, void* param);
|
||||
|
||||
void fh_input_consume_matching(struct fh_thread_s *fh, chartest_t test, void* param);
|
||||
|
||||
void fh_input_consume_spaces(struct fh_thread_s *fh);
|
||||
|
||||
enum fh_error fh_input_read_delimited(struct fh_thread_s *fh, char **out, size_t *len, chartest_t test, void* param);
|
||||
enum fh_error fh_input_read_word(struct fh_thread_s *fh, char **out, size_t *len);
|
||||
|
||||
enum fh_error fh_input_read_quotedstring(struct fh_thread_s *fh, bool escaped, char *outbuf, size_t capacity, size_t *out_len);
|
||||
|
||||
#endif //FORTH_FH_PARSE_H
|
||||
@@ -197,19 +197,17 @@ struct fh_thread_s {
|
||||
#define INPUTBUF_ADDR (HEAP_END + WORDBUF_SIZE)
|
||||
|
||||
enum fh_error fh_loop_nest(struct fh_thread_s *fh, uint32_t indexvalue);
|
||||
|
||||
enum fh_error fh_loop_unnest(struct fh_thread_s *fh);
|
||||
|
||||
enum fh_error fh_add_word(const struct fh_word_s *w, struct fh_thread_s *fh);
|
||||
|
||||
void fh_setstate(struct fh_thread_s *fh, enum fh_state state, enum fh_substate substate);
|
||||
|
||||
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,
|
||||
@@ -226,9 +224,11 @@ enum fh_error fh_see_word(
|
||||
/* if the return address is this, we should drop back to interactive mode */
|
||||
|
||||
// SFR and magic addresses are "negative"
|
||||
#define MAGICADDR_INTERACTIVE 0xFFFFFFFFULL
|
||||
#define MAGICADDR_EXEC_INTERACTIVE 0xFFFFFFFFULL
|
||||
|
||||
#define MAGICADDR_BASE 0xFFFFBA5EULL
|
||||
#define MAGICADDR_HERE 0xFFFF4E7EULL
|
||||
#define MAGICADDR_INPTR 0xFFFFF111ULL
|
||||
#define MAGICADDR_UNRESOLVED 0xFFFFFBADULL
|
||||
|
||||
/** Get a value rounded up to multiple of word size */
|
||||
|
||||
Reference in New Issue
Block a user