diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/lexer.h | 13 | ||||
-rw-r--r-- | src/include/token.h | 5 |
2 files changed, 12 insertions, 6 deletions
diff --git a/src/include/lexer.h b/src/include/lexer.h index 6d9dff8..7364910 100644 --- a/src/include/lexer.h +++ b/src/include/lexer.h @@ -5,6 +5,9 @@ #include "token.h" +#define LEXER_VALID (lexer->c != '\0' && lexer->i < strlen(lexer->content)) + + typedef struct LEXER_STRUC { char c; // current character in content unsigned int i; // index of c @@ -19,8 +22,7 @@ extern void lexer_destroy (lexer_t* lexer); // advance the lexer extern void lexer_next (lexer_t* lexer); extern void lexer_pass (lexer_t* lexer); -extern int lexer_is_valid (lexer_t* lexer); -extern token_t* lexer_get_next_token (lexer_t* lexer); +extern token_t* lexer_get_next_token (lexer_t* lexer); // chars -> tokens extern token_t* lexer_next_token (lexer_t* lexer, token_t* token); extern char* lexer_get_c_as_string (lexer_t* lexer); @@ -29,12 +31,13 @@ extern token_t* lexer_get_array (lexer_t* lexer); extern token_t* lexer_get_string (lexer_t* lexer); extern token_t* lexer_get_comment (lexer_t* lexer); -// def collectors +// special def collectors extern token_t* lexer_get_directive (lexer_t* lexer); extern token_t* lexer_get_keyword (lexer_t* lexer); -extern token_t* lexer_get_def (lexer_t* lexer); +extern token_t* lexer_get_def_var (lexer_t* lexer); // <mutability:?><type:><name>=<value?> +/* extern token_t* lexer_get_def (lexer_t* lexer); // get the definition extern token_t* lexer_get_def_mutability (lexer_t* lexer); // look for mut: or immut: (optional, default immut) extern token_t* lexer_get_def_type (lexer_t* lexer); // get the def type (required) @@ -49,6 +52,6 @@ extern token_t* lexer_get_var_value (lexer_t* lexer); // get the var extern token_t* lexer_get_fn_def (lexer_t* lexer); extern token_t* lexer_get_fn_args (lexer_t* lexer); // get the function args (optional, default empty) extern token_t* lexer_get_fn_body (lexer_t* lexer); // get the function body (required) - +*/ #endif diff --git a/src/include/token.h b/src/include/token.h index 45154f4..f7a166f 100644 --- a/src/include/token.h +++ b/src/include/token.h @@ -16,7 +16,8 @@ typedef struct TOKEN_STRUC { TOKEN_DIRECTIVE, // #DIRECTIVE; TOKEN_FN_APPLY, // . TOKEN_LIST_DELIM, // , - TOKEN_DEF_ARGS_DELIM, // : + TOKEN_DEF_TAGS_DELIM, // : + TOKEN_DEF, // def:def TOKEN_BLOCK_DELIM_START, // { TOKEN_BLOCK_DELIM_END, // } TOKEN_NAMESPACE_DELIM, // / @@ -28,6 +29,8 @@ typedef struct TOKEN_STRUC { char* value; } token_t; +token_t* token_init(int type, char* val); + char TOKEN_DEFNAME_FIRST_CHAR_ALLOWED_CHARS[] = "abcdefghijklmnopqrstuvwxyz_"; // chars that can begin a var name int TOKEN_DEFNAME_FIRST_CHAR_ALLOWED_CHARS_LEN = 27; // maximum efficiency! char TOKEN_DEFNAME_SPLIT_CHAR_ALLOWED_CHARS[] = "1234567890_-"; // chars that can be in the rest of the var name, |