diff options
| -rw-r--r-- | src/parse/binops.c | 2 | ||||
| -rw-r--r-- | src/parse/controlflow.c | 12 | ||||
| -rw-r--r-- | src/parse/functions.c | 3 | ||||
| -rw-r--r-- | src/parse/numbers.c | 2 | ||||
| -rw-r--r-- | src/parse/statements.c | 6 | ||||
| -rw-r--r-- | src/parse/suffixes.c | 7 | ||||
| -rw-r--r-- | src/parse/text.c | 3 | ||||
| -rw-r--r-- | src/parse/utils.c | 16 |
8 files changed, 0 insertions, 51 deletions
diff --git a/src/parse/binops.c b/src/parse/binops.c index cbbdd44d..e70bcd7e 100644 --- a/src/parse/binops.c +++ b/src/parse/binops.c @@ -36,7 +36,6 @@ int op_tightness[] = { [Xor] = 1, }; -public ast_e match_binary_operator(const char **pos) { switch (**pos) { case '+': { @@ -85,7 +84,6 @@ ast_e match_binary_operator(const char **pos) { } } -public ast_t *parse_infix_expr(parse_ctx_t *ctx, const char *pos, int min_tightness) { ast_t *lhs = optional(ctx, &pos, parse_term); if (!lhs) return NULL; diff --git a/src/parse/controlflow.c b/src/parse/controlflow.c index e2e8dbc3..c5b90e00 100644 --- a/src/parse/controlflow.c +++ b/src/parse/controlflow.c @@ -13,7 +13,6 @@ #include "suffixes.h" #include "utils.h" -public ast_t *parse_block(parse_ctx_t *ctx, const char *pos) { const char *start = pos; spaces(&pos); @@ -75,13 +74,11 @@ ast_t *parse_block(parse_ctx_t *ctx, const char *pos) { return NewAST(ctx->file, start, pos, Block, .statements = statements); } -public ast_t *parse_pass(parse_ctx_t *ctx, const char *pos) { const char *start = pos; return match_word(&pos, "pass") ? NewAST(ctx->file, start, pos, Pass) : NULL; } -public ast_t *parse_defer(parse_ctx_t *ctx, const char *pos) { const char *start = pos; if (!match_word(&pos, "defer")) return NULL; @@ -89,7 +86,6 @@ ast_t *parse_defer(parse_ctx_t *ctx, const char *pos) { return NewAST(ctx->file, start, pos, Defer, .body = body); } -public ast_t *parse_skip(parse_ctx_t *ctx, const char *pos) { const char *start = pos; if (!match_word(&pos, "continue") && !match_word(&pos, "skip")) return NULL; @@ -102,7 +98,6 @@ ast_t *parse_skip(parse_ctx_t *ctx, const char *pos) { return skip; } -public ast_t *parse_stop(parse_ctx_t *ctx, const char *pos) { const char *start = pos; if (!match_word(&pos, "stop") && !match_word(&pos, "break")) return NULL; @@ -115,7 +110,6 @@ ast_t *parse_stop(parse_ctx_t *ctx, const char *pos) { return stop; } -public ast_t *parse_return(parse_ctx_t *ctx, const char *pos) { const char *start = pos; if (!match_word(&pos, "return")) return NULL; @@ -125,7 +119,6 @@ ast_t *parse_return(parse_ctx_t *ctx, const char *pos) { return ret; } -public ast_t *parse_do(parse_ctx_t *ctx, const char *pos) { // do [<indent>] body const char *start = pos; @@ -134,7 +127,6 @@ ast_t *parse_do(parse_ctx_t *ctx, const char *pos) { return NewAST(ctx->file, start, pos, Block, .statements = Match(body, Block)->statements); } -public ast_t *parse_while(parse_ctx_t *ctx, const char *pos) { // while condition ["do"] [<indent>] body const char *start = pos; @@ -155,7 +147,6 @@ ast_t *parse_while(parse_ctx_t *ctx, const char *pos) { return NewAST(ctx->file, start, pos, While, .condition = condition, .body = body); } -public ast_t *parse_repeat(parse_ctx_t *ctx, const char *pos) { // repeat [<indent>] body const char *start = pos; @@ -164,7 +155,6 @@ ast_t *parse_repeat(parse_ctx_t *ctx, const char *pos) { return NewAST(ctx->file, start, pos, Repeat, .body = body); } -public ast_t *parse_if(parse_ctx_t *ctx, const char *pos) { // "if" <condition> ["then"] <body> ["else" <body>] | "unless" <condition> <body> ["else" <body>] const char *start = pos; @@ -196,7 +186,6 @@ ast_t *parse_if(parse_ctx_t *ctx, const char *pos) { return NewAST(ctx->file, start, pos, If, .condition = condition, .body = body, .else_body = else_body); } -public ast_t *parse_when(parse_ctx_t *ctx, const char *pos) { // when <expr> (is var : Tag <body>)* [else <body>] const char *start = pos; @@ -241,7 +230,6 @@ ast_t *parse_when(parse_ctx_t *ctx, const char *pos) { return NewAST(ctx->file, start, pos, When, .subject = subject, .clauses = clauses, .else_body = else_body); } -public ast_t *parse_for(parse_ctx_t *ctx, const char *pos) { // for [k,] v in iter [<indent>] body const char *start = pos; diff --git a/src/parse/functions.c b/src/parse/functions.c index 4293b43b..39444762 100644 --- a/src/parse/functions.c +++ b/src/parse/functions.c @@ -18,7 +18,6 @@ #include "types.h" #include "utils.h" -public arg_ast_t *parse_args(parse_ctx_t *ctx, const char **pos) { arg_ast_t *args = NULL; for (;;) { @@ -74,7 +73,6 @@ arg_ast_t *parse_args(parse_ctx_t *ctx, const char **pos) { return args; } -public ast_t *parse_func_def(parse_ctx_t *ctx, const char *pos) { const char *start = pos; if (!match_word(&pos, "func")) return NULL; @@ -146,7 +144,6 @@ ast_t *parse_convert_def(parse_ctx_t *ctx, const char *pos) { .cache = cache_ast, .is_inline = is_inline); } -public ast_t *parse_lambda(parse_ctx_t *ctx, const char *pos) { const char *start = pos; if (!match_word(&pos, "func")) return NULL; diff --git a/src/parse/numbers.c b/src/parse/numbers.c index 39851f2a..c12a68b2 100644 --- a/src/parse/numbers.c +++ b/src/parse/numbers.c @@ -17,7 +17,6 @@ static const double RADIANS_PER_DEGREE = 0.0174532925199432957692369076848861271344287188854172545609719144; -public ast_t *parse_int(parse_ctx_t *ctx, const char *pos) { const char *start = pos; (void)match(&pos, "-"); @@ -51,7 +50,6 @@ ast_t *parse_int(parse_ctx_t *ctx, const char *pos) { return NewAST(ctx->file, start, pos, Int, .str = str); } -public ast_t *parse_num(parse_ctx_t *ctx, const char *pos) { const char *start = pos; bool negative = match(&pos, "-"); diff --git a/src/parse/statements.c b/src/parse/statements.c index c4ab5608..6f73d279 100644 --- a/src/parse/statements.c +++ b/src/parse/statements.c @@ -15,7 +15,6 @@ #include "types.h" #include "utils.h" -public ast_t *parse_declaration(parse_ctx_t *ctx, const char *pos) { const char *start = pos; ast_t *var = parse_var(ctx, pos); @@ -38,7 +37,6 @@ ast_t *parse_declaration(parse_ctx_t *ctx, const char *pos) { return NewAST(ctx->file, start, pos, Declare, .var = var, .type = type, .value = val); } -public ast_t *parse_assignment(parse_ctx_t *ctx, const char *pos) { const char *start = pos; ast_list_t *targets = NULL; @@ -73,7 +71,6 @@ ast_t *parse_assignment(parse_ctx_t *ctx, const char *pos) { return NewAST(ctx->file, start, pos, Assign, .targets = targets, .values = values); } -public ast_t *parse_update(parse_ctx_t *ctx, const char *pos) { const char *start = pos; ast_t *lhs = optional(ctx, &pos, parse_expr); @@ -99,7 +96,6 @@ ast_t *parse_update(parse_ctx_t *ctx, const char *pos) { .__data.PlusUpdate.rhs = rhs); } -public ast_t *parse_doctest(parse_ctx_t *ctx, const char *pos) { const char *start = pos; if (!match(&pos, ">>")) return NULL; @@ -116,7 +112,6 @@ ast_t *parse_doctest(parse_ctx_t *ctx, const char *pos) { return NewAST(ctx->file, start, pos, DocTest, .expr = expr, .expected = expected); } -public ast_t *parse_assert(parse_ctx_t *ctx, const char *pos) { const char *start = pos; if (!match_word(&pos, "assert")) return NULL; @@ -133,7 +128,6 @@ ast_t *parse_assert(parse_ctx_t *ctx, const char *pos) { return NewAST(ctx->file, start, pos, Assert, .expr = expr, .message = message); } -public ast_t *parse_statement(parse_ctx_t *ctx, const char *pos) { ast_t *stmt = NULL; if ((stmt = parse_declaration(ctx, pos)) || (stmt = parse_doctest(ctx, pos)) || (stmt = parse_assert(ctx, pos))) diff --git a/src/parse/suffixes.c b/src/parse/suffixes.c index 77c61830..cc1905b9 100644 --- a/src/parse/suffixes.c +++ b/src/parse/suffixes.c @@ -11,7 +11,6 @@ #include "parse.h" #include "utils.h" -public ast_t *parse_field_suffix(parse_ctx_t *ctx, ast_t *lhs) { if (!lhs) return NULL; const char *pos = lhs->end; @@ -26,7 +25,6 @@ ast_t *parse_field_suffix(parse_ctx_t *ctx, ast_t *lhs) { return NewAST(ctx->file, lhs->start, pos, FieldAccess, .fielded = lhs, .field = field); } -public ast_t *parse_optional_suffix(parse_ctx_t *ctx, ast_t *lhs) { if (!lhs) return NULL; const char *pos = lhs->end; @@ -34,7 +32,6 @@ ast_t *parse_optional_suffix(parse_ctx_t *ctx, ast_t *lhs) { else return NULL; } -public ast_t *parse_non_optional_suffix(parse_ctx_t *ctx, ast_t *lhs) { if (!lhs) return NULL; const char *pos = lhs->end; @@ -42,7 +39,6 @@ ast_t *parse_non_optional_suffix(parse_ctx_t *ctx, ast_t *lhs) { else return NULL; } -public ast_t *parse_index_suffix(parse_ctx_t *ctx, ast_t *lhs) { if (!lhs) return NULL; const char *start = lhs->start; @@ -56,7 +52,6 @@ ast_t *parse_index_suffix(parse_ctx_t *ctx, ast_t *lhs) { return NewAST(ctx->file, start, pos, Index, .indexed = lhs, .index = index, .unchecked = unchecked); } -public ast_t *parse_comprehension_suffix(parse_ctx_t *ctx, ast_t *expr) { // <expr> "for" [<index>,]<var> "in" <iter> ["if" <condition> | "unless" <condition>] if (!expr) return NULL; @@ -91,7 +86,6 @@ ast_t *parse_comprehension_suffix(parse_ctx_t *ctx, ast_t *expr) { return NewAST(ctx->file, start, pos, Comprehension, .expr = expr, .vars = vars, .iter = iter, .filter = filter); } -public ast_t *parse_optional_conditional_suffix(parse_ctx_t *ctx, ast_t *stmt) { // <statement> "if" <condition> | <statement> "unless" <condition> if (!stmt) return stmt; @@ -109,7 +103,6 @@ ast_t *parse_optional_conditional_suffix(parse_ctx_t *ctx, ast_t *stmt) { } } -public ast_t *parse_method_call_suffix(parse_ctx_t *ctx, ast_t *self) { if (!self) return NULL; diff --git a/src/parse/text.c b/src/parse/text.c index 5fe58da4..b5fd3422 100644 --- a/src/parse/text.c +++ b/src/parse/text.c @@ -116,7 +116,6 @@ static ast_list_t *_parse_text_helper(parse_ctx_t *ctx, const char **out_pos, ch return chunks; } -public ast_t *parse_text(parse_ctx_t *ctx, const char *pos) { // ('"' ... '"' / "'" ... "'" / "`" ... "`") // "$" [name] [interp-char] quote-char ... close-quote @@ -157,7 +156,6 @@ ast_t *parse_text(parse_ctx_t *ctx, const char *pos) { return NewAST(ctx->file, start, pos, TextJoin, .lang = lang, .children = chunks, .colorize = colorize); } -public ast_t *parse_inline_c(parse_ctx_t *ctx, const char *pos) { const char *start = pos; if (!match_word(&pos, "C_code")) return NULL; @@ -184,7 +182,6 @@ ast_t *parse_inline_c(parse_ctx_t *ctx, const char *pos) { return NewAST(ctx->file, start, pos, InlineCCode, .chunks = chunks, .type_ast = type); } -public ast_t *parse_path(parse_ctx_t *ctx, const char *pos) { // "(" ("~/" / "./" / "../" / "/") ... ")" const char *start = pos; diff --git a/src/parse/utils.c b/src/parse/utils.c index d745dec8..3b502cbc 100644 --- a/src/parse/utils.c +++ b/src/parse/utils.c @@ -18,7 +18,6 @@ static const char *keywords[] = { "struct", "then", "unless", "use", "when", "while", "xor", "yes", }; -public CONSTFUNC bool is_keyword(const char *word) { int64_t lo = 0, hi = sizeof(keywords) / sizeof(keywords[0]) - 1; while (lo <= hi) { @@ -31,30 +30,25 @@ CONSTFUNC bool is_keyword(const char *word) { return false; } -public size_t some_of(const char **pos, const char *allow) { size_t len = strspn(*pos, allow); *pos += len; return len; } -public size_t some_not(const char **pos, const char *forbid) { size_t len = strcspn(*pos, forbid); *pos += len; return len; } -public size_t spaces(const char **pos) { return some_of(pos, " \t"); } -public void whitespace(const char **pos) { while (some_of(pos, " \t\r\n") || comment(pos)) continue; } -public size_t match(const char **pos, const char *target) { size_t len = strlen(target); if (strncmp(*pos, target, len) != 0) return 0; @@ -62,14 +56,12 @@ size_t match(const char **pos, const char *target) { return len; } -public bool is_xid_continue_next(const char *pos) { ucs4_t point = 0; u8_next(&point, (const uint8_t *)pos); return uc_is_property_xid_continue(point); } -public size_t match_word(const char **out, const char *word) { const char *pos = *out; spaces(&pos); @@ -79,7 +71,6 @@ size_t match_word(const char **out, const char *word) { return strlen(word); } -public const char *get_word(const char **inout) { const char *word = *inout; spaces(&word); @@ -95,7 +86,6 @@ const char *get_word(const char **inout) { return GC_strndup(word, (size_t)((const char *)pos - word)); } -public const char *get_id(const char **inout) { const char *pos = *inout; const char *word = get_word(&pos); @@ -104,10 +94,8 @@ const char *get_id(const char **inout) { return word; } -public const char *eol(const char *str) { return str + strcspn(str, "\r\n"); } -public bool comment(const char **pos) { if ((*pos)[0] == '#') { *pos += strcspn(*pos, "\r\n"); @@ -117,7 +105,6 @@ bool comment(const char **pos) { } } -public PUREFUNC int64_t get_indent(parse_ctx_t *ctx, const char *pos) { int64_t line_num = get_line_number(ctx->file, pos); const char *line = get_line(ctx->file, line_num); @@ -140,7 +127,6 @@ PUREFUNC int64_t get_indent(parse_ctx_t *ctx, const char *pos) { } } -public bool indent(parse_ctx_t *ctx, const char **out) { const char *pos = *out; int64_t starting_indent = get_indent(ctx, pos); @@ -154,7 +140,6 @@ bool indent(parse_ctx_t *ctx, const char **out) { return true; } -public bool newline_with_indentation(const char **out, int64_t target) { const char *pos = *out; if (*pos == '\r') ++pos; @@ -255,7 +240,6 @@ const char *unescape(parse_ctx_t *ctx, const char **out) { #pragma GCC diagnostic pop #endif -public bool match_separator(const char **pos) { // Either comma or newline const char *p = *pos; int separators = 0; |
