diff options
author | s-over-4 | 2023-07-07 20:56:29 -0400 |
---|---|---|
committer | s-over-4 | 2023-07-07 20:56:29 -0400 |
commit | 5b37568baac046ac6b21453bbe037e0eeec16e89 (patch) | |
tree | 3a7a3de8c14cea25b4e2cd05cd55fbc7f3239137 /src/include | |
parent | e850a08fa7a763140b9c86308cfdff9bae421c2e (diff) |
expectf
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/parser.h | 3 | ||||
-rw-r--r-- | src/include/token.h | 6 | ||||
-rw-r--r-- | src/include/tree.h | 16 |
3 files changed, 16 insertions, 9 deletions
diff --git a/src/include/parser.h b/src/include/parser.h index 32cd4bc..694bd5e 100644 --- a/src/include/parser.h +++ b/src/include/parser.h @@ -13,7 +13,8 @@ parser_t* parser_init(lexer_t* lexer); void parser_destroy(parser_t* parser); // expect token, or die -void parser_token_expect(parser_t* parser, int (*expected_token)(token_t*)); +void parser_token_expect(parser_t* parser, token_t* token); +void parser_token_expectf(parser_t* parser, int (*expected_token)(token_t*)); // do the parse tree_t* parser_parse(parser_t* parser); diff --git a/src/include/token.h b/src/include/token.h index a2a47bc..d3dda67 100644 --- a/src/include/token.h +++ b/src/include/token.h @@ -1,8 +1,8 @@ #ifndef TOKEN_H #define TOKEN_H -#define TOKEN_DEFNAME_FIRST_CHAR_ALLOWED_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_" -#define TOKEN_DEFNAME_FIRST_CHAR_ALLOWED_CHARS_LEN 53 +#define TOKEN_DEFNAME_FIRST_CHAR_ALLOWED_CHARS "+-/*abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_" +#define TOKEN_DEFNAME_FIRST_CHAR_ALLOWED_CHARS_LEN 57 #define TOKEN_DEFNAME_SPLIT_CHAR_ALLOWED_CHARS "1234567890_-" #define TOKEN_DEFNAME_SPLIT_CHAR_ALLOWED_CHARS_LEN 12 #define TOKEN_CHAR_IGNORE " \t\n\r" @@ -16,7 +16,7 @@ typedef struct TOKEN_STRUC { TOKEN_PRIM_STR, // 'string' TOKEN_PRIM_INT, // 42 TOKEN_COMM, // `comment` - TOKEN_EXPR_END, // ; + TOKEN_STMNT_END, // ; TOKEN_LGROUP, // ( TOKEN_RGROUP, // ) TOKEN_DIRECTIVE, // #DIRECTIVE# diff --git a/src/include/tree.h b/src/include/tree.h index 4ffefcf..6374062 100644 --- a/src/include/tree.h +++ b/src/include/tree.h @@ -5,6 +5,7 @@ typedef struct TREE_STRUC { enum { + TREE_COMP, TREE_DEF, TREE_CALL, TREE_TYPE_STR, @@ -12,25 +13,30 @@ typedef struct TREE_STRUC { } type; union { - struct { // === DEFINITIONS === + struct { // === "COMPOUND" === + struct TREE_STRUC** value; + size_t size; + } comp; + + struct { // === DEFINITIONS === char* name; // name of definition int mutability; // mutability of definition struct TREE_STRUC* value; // value of definition } def; - struct { // === CALLS === + struct { // === CALLS === char* target; // name of definition being called struct TREE_STRUC** args; // arguments passed to definition size_t args_size; // size of arguments } call; // === TYPES === - struct { // strings + struct { // strings char* value; } type_str; - struct { // integers - int* value; + struct { // integers + int value; } type_int; } data; } tree_t; |