aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorc+12023-05-18 17:57:56 -0400
committerc+12023-05-18 17:57:56 -0400
commitf6ae20caf8191f78eea90edfb17f316db8f8c6b5 (patch)
tree076bec3d50cb23b11f1240d0926f5f8d42b57cc4 /src/include
parent9c78e75eb59da9c7fb8fbdd5b536ab1b22727859 (diff)
finished the lexer, for real this time
Diffstat (limited to 'src/include')
-rw-r--r--src/include/lexer.h13
-rw-r--r--src/include/token.h5
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,