diff options
Diffstat (limited to 'include/readchar.h')
| -rw-r--r-- | include/readchar.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/include/readchar.h b/include/readchar.h new file mode 100644 index 0000000..e881dcb --- /dev/null +++ b/include/readchar.h @@ -0,0 +1,44 @@ +#ifndef __CCL_READCHAR_H__ +#define __CCL_READCHAR_H__ + +#include "3cl.h" + + +/** + * Flags to tell ccl_readchar how to read next character + * + * Bits + * 4 Die if char is not whitelisted + * 3 Brackets + * 2 Instruction symbols + * 1 English alphabet + * 0 Underscore + * + * @see ccl_readchar + */ +enum CCLRCFlags +{ + CCL_RC_DIE = 0b10000, /**< Die if char is not whitelisted */ + CCL_RC_BRACK = 0b01000, /**< Brackes */ + CCL_RC_IS = 0b00100, /**< Instruction symbols */ + CCL_RC_ALP = 0b00010, /**< English alphabet */ + CCL_RC_US = 0b00001, /**< Underscore */ + CCL_RC_VAR = 0b11010, /**< (Used by 3CL) Variable names */ + CCL_RC_CCL_VARUS = 0b11011, /**< (Used by 3CL) Variable names including underscore */ + CCL_RC_CCL_BRACK = 0b01000, /**< (Used by 3CL) Brackets */ + CCL_RC_CCL_INSTR = 0b11111, /**< (Used by 3CL) Instruction */ +}; + +/** + * Function to read next character + * Skips whitespace and comments, returns '\0' if reaches EOF + * ccl_readchar will die on invalid symbol (e.g. cyrillic one) even if CCL_RC_DIE is set + * @see CCLRCFlags + * @param ccl CCL instance + * @param frame Current frame + * @param flags CCLRCFlags + * @return Next character + */ +char ccl_readchar(struct CCL *ccl, struct CCLFrame *frame, enum CCLRCFlags flags); + +#endif /* __CCL_READCHAR_H__ */ |