Trying to build a forth runtime in C
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
forth/include/fh_parse.h

31 lines
948 B

/**
* 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);
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