diff --git a/engine/slc.h b/engine/slc.h index 7a6e8c8..abf8a80 100644 --- a/engine/slc.h +++ b/engine/slc.h @@ -200,6 +200,38 @@ typedef iores (*ioconn)(SLC_IO_OP op, const char *param); */ typedef uint8_t (*coderead)(); +enum slc_state : uint32_t { + /** Before things */ + SLC_START, + /** In a comment */ + SLC_COMMENT, + /** In multi-line comment */ + SLC_MULTILINE_COMMENT, + /** Name part of word-definition (after ':') - whitespace ends it */ + SLC_DEF_NAME, + /** Variable-listing part of word-definition - endline, '(', '[' or '{' ends it */ + SLC_DEF_VAR, + /** Raw body part of the word definition - these can contain local variable accesses + words (state-stack in code_stack) */ + SLC_DEF_BODY, + /** ( .. ) part of the word definition - these can contain local variable accesses + words (state-stack in code_stack) */ + SLC_DEF_PAR, + /** [ .. ] part of the word definition - these can contain local variable accesses + words (state-stack in code_stack) */ + SLC_DEF_SQBR, + /** { .. } part of the word definition - these can contain local variable accesses + words (state-stack in code_stack) */ + SLC_DEF_BR, + /** Name part of a word "call" (non-definition). */ + SLC_WORD_NAME, + /** Variable part of a word "call" */ + SLC_WORD_VAR, + /** ( .. ) part of a word "call" */ + SLC_WORD_PAR, + /** [ .. ] part of a word "call" */ + SLC_WORD_SQBR, + /** { .. } part of a word "call" */ + SLC_WORD_BR, +}; +typedef enum slc_state slc_state; + /** * This function runs the main slc engine over a snippet of code. * @@ -229,26 +261,33 @@ typedef uint8_t (*coderead)(); * @param session_storage Can allocate and use arbitrary memory with this. * @param symbol_table The symbol table to use while processing. * @param code_stack The code stack (return addresses) to use. + * @param nesting_stack The stack used for the state-machine of the nested words. * @param data_stack The data stack (forth-like stack) to use. * @param insert_stack Used for temporarily expanding the input stream (one word level above current) with further words. * @param io_connector The engine uses this to open/close pipes/files and write/read them. + * @param singleline_comment OPTIONAL: Like "//" - the character string that makes the rest of the line being comment. + * @param multiline_comment_opener OPTIONAL: The character string that starts a multiline comment. Like / and * for C. + * @param multiline_comment_closer OPTIONAL: The character string that ends a multiline comment. Like * and / for C. * @param prefix The prefix added to the lookup of built-ins. Useful when you write a compiler with SLC. Defaults to "" (empty). * @param ender The character string that ends a word definition. Defaults to ";". * @param varprefix The character string that prefixes variable declarations. Defaults to "@". */ static inline void slc( - coderead code_src, - session session_storage, - sym symbol_table, - stack code_stack, - stack data_stack, - stack insert_stack, - ioconn io_connector, - const char *prefix, - const char *ender, - const char *varprefix -) { - // TODO + coderead code_src, + session session_storage, + sym symbol_table, + stack code_stack, + stack nesting_stack, + stack data_stack, + stack insert_stack, + ioconn io_connector, + const char *singleline_comment, + const char *multiline_comment_opener, + const char *multiline_comment_closer, + const char *prefix, + const char *ender, + const char *varprefix) { + slc_state main_state = SLC_START; } #endif /* SLC_H */