diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/lexer.h | 28 | ||||
-rw-r--r-- | src/include/parser.h | 37 | ||||
-rw-r--r-- | src/include/token.h | 6 | ||||
-rw-r--r-- | src/include/tree.h | 4 |
4 files changed, 27 insertions, 48 deletions
diff --git a/src/include/lexer.h b/src/include/lexer.h index 7364910..a86f5bb 100644 --- a/src/include/lexer.h +++ b/src/include/lexer.h @@ -15,7 +15,7 @@ typedef struct LEXER_STRUC { } lexer_t; -// constructor / destroyer +// constructor/destroyer extern lexer_t* lexer_init (char* content); extern void lexer_destroy (lexer_t* lexer); @@ -27,31 +27,13 @@ extern token_t* lexer_next_token (lexer_t* lexer, token_t* token); extern char* lexer_get_c_as_string (lexer_t* lexer); // collectors -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); +extern token_t* lexer_get_arr (lexer_t* lexer); +extern token_t* lexer_get_str (lexer_t* lexer); +extern token_t* lexer_get_com (lexer_t* lexer); // 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_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) -extern token_t* lexer_det_def_name (lexer_t* lexer); // get the def name (required) -extern token_t* lexer_get_def_deftype (lexer_t* lexer); // get the deftype, either var or fn (ie checks for a . after the def name) - -// var def methods -extern token_t* lexer_get_def_var (lexer_t* lexer); -extern token_t* lexer_get_var_value (lexer_t* lexer); // get the variable value (optional, default null) - -// fn def methods -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/parser.h b/src/include/parser.h index c77fd29..dcacabe 100644 --- a/src/include/parser.h +++ b/src/include/parser.h @@ -1,7 +1,6 @@ #ifndef PARSER_H #define PARSER_H - #include "token.h" #include "tree.h" #include "lexer.h" @@ -16,28 +15,30 @@ typedef struct PARSER_STRUC { parser_t* parser_init(lexer_t* lexer); // check for expected token, or throw syntax error -void parser_check_expect(parser_t* parser, int token_type); +void parser_token_expect(parser_t* parser, int token_type); -// creates the abstract syntax tree +// do the parse tree_t* parser_parse(parser_t* parser); -tree_t* parser_parse_token_id(parser_t* parser); - -// parse a single chunk -tree_t* parser_parse_chunk(parser_t* parser); +tree_t* parser_parse_token(parser_t* parser); -// parse all in list of chunks -tree_t* parser_parse_chunks(parser_t* parser); +// parse hunks +tree_t* parser_parse_hunk(parser_t* parser); +tree_t* parser_parse_hunks(parser_t* parser); // leaves of the tree -tree_t* parser_parse_expr(parser_t* parser); -tree_t* parser_parse_fac(parser_t* parser); -tree_t* parser_parse_term(parser_t* parser); -tree_t* parser_parse_fn_call(parser_t* parser); -tree_t* parser_parse_fn_def(parser_t* parser); -tree_t* parser_parse_var(parser_t* parser); -tree_t* parser_parse_var_def(parser_t* parser); -tree_t* parser_parse_str(parser_t* parser); -tree_t* parser_parse_keyword(parser_t* parser); +tree_t* parser_parse_prim(parser_t* parser); +tree_t* parser_parse_subtree(parser_t* parser); +tree_t* parser_parse_def(parser_t* parser); +tree_t* parser_parse_call(parser_t* parser); + +// primitives +tree_t* parser_parse_prim_str(parser_t* parser); +tree_t* parser_parse_prim_int(parser_t* parser); +tree_t* parser_parse_prim_unkwn(parser_t* parser); + +// defs +tree_t* parser_parse_def_tags(parser_t* parser); +int parser_is_def_tag(char* maybe_tag); #endif diff --git a/src/include/token.h b/src/include/token.h index e52c3a0..8964ccd 100644 --- a/src/include/token.h +++ b/src/include/token.h @@ -12,9 +12,9 @@ typedef struct TOKEN_STRUC { enum { TOKEN_KEYWORD, // keyword - TOKEN_PRIM_STR_DELIM, // ' - TOKEN_PRIM_STR, // 'string' - TOKEN_PRIM_INT, // 'string' + TOKEN_PRIM_STR_DELIM, // ' + TOKEN_PRIM_STR, // 'string' + TOKEN_PRIM_INT, // 'string' TOKEN_COMM_DELIM, // ` TOKEN_COMM, // `comment` TOKEN_EXPR_END, // ; diff --git a/src/include/tree.h b/src/include/tree.h index 284a823..20c6714 100644 --- a/src/include/tree.h +++ b/src/include/tree.h @@ -11,10 +11,6 @@ typedef struct PRIM_STRUC { STR, INT, UNKWN, - //ARR, - //FLOAT, - //STRUCT, - //NAMESPACE, } type; union prim_union { |