#ifndef APLWC_INTERNAL_H #define APLWC_INTERNAL_H #include #include #define RETURN_ERROR(aplwcp, rc, msg) do{ \ return ((aplwc)->last_error = (rc)); \ }while(0) #include #include #include #include struct memory { uint8_t *data; size_t size; size_t offset; }; struct aplwc { enum aplwc_rc last_error; struct memory memory; }; struct aplwc_line { struct aplwc *aplwc; struct string *text; struct token_list *tokens; }; struct string { size_t bytes; size_t chars; uint8_t utf8[1]; }; enum token_tag { TOKEN_TAG_IDENTIFIER, TOKEN_TAG_NEWLINE }; struct token { enum token_tag tag; }; struct token_list { size_t length; struct token tokens[1]; }; /* eval.c */ void eval_line(struct aplwc_line *); /* memory.c */ struct memory memory_init(uint8_t *, size_t); struct aplwc *memory_alloc_aplwc(struct memory *); struct aplwc_line *memory_alloc_aplwc_line(struct memory *); struct string *memory_alloc_string(struct memory *, size_t); struct token_list *memory_alloc_token_list(struct memory *, size_t); void memory_free_aplwc(struct memory *, struct aplwc *); void memory_free_aplwc_line(struct memory *, struct aplwc_line *); void memory_free_string(struct memory *, struct string *); void memory_free_token_list(struct memory *, struct token_list *); /* string.c */ struct string *chars_to_string(struct aplwc *, const char *); uint32_t string_char(struct string *, size_t); size_t char_length(struct string *, size_t); /* syntax.c */ struct token_list *scan_line(struct aplwc *, struct string *); #endif /* APLWC_INTERNAL_H */