aboutsummaryrefslogtreecommitdiff
path: root/src/parse
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-09-21 16:28:57 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-09-21 16:28:57 -0400
commitfd74479a2bf2e4ccc35d1c2fa206de8f28be1e54 (patch)
tree0cdf5c4659264b612b5f3fbb4ce6a3b11dd736f5 /src/parse
parent92185a002a2e8b669add454a945c0ecdc0904993 (diff)
Deprecate optional '?' postfix operator
Diffstat (limited to 'src/parse')
-rw-r--r--src/parse/binops.c3
-rw-r--r--src/parse/expressions.c15
-rw-r--r--src/parse/suffixes.c7
-rw-r--r--src/parse/suffixes.h1
4 files changed, 7 insertions, 19 deletions
diff --git a/src/parse/binops.c b/src/parse/binops.c
index 4676b249..dd1ac3c2 100644
--- a/src/parse/binops.c
+++ b/src/parse/binops.c
@@ -73,8 +73,7 @@ ast_t *parse_infix_expr(parse_ctx_t *ctx, const char *pos, int min_tightness) {
progress =
(false || (new_term = parse_index_suffix(ctx, key))
|| (new_term = parse_method_call_suffix(ctx, key)) || (new_term = parse_field_suffix(ctx, key))
- || (new_term = parse_fncall_suffix(ctx, key)) || (new_term = parse_optional_suffix(ctx, key))
- || (new_term = parse_non_optional_suffix(ctx, key)));
+ || (new_term = parse_fncall_suffix(ctx, key)) || (new_term = parse_non_optional_suffix(ctx, key)));
if (progress) key = new_term;
}
if (key && key->tag == Var) key = NULL;
diff --git a/src/parse/expressions.c b/src/parse/expressions.c
index 7410f678..3cb47669 100644
--- a/src/parse/expressions.c
+++ b/src/parse/expressions.c
@@ -54,10 +54,9 @@ ast_t *parse_reduction(parse_ctx_t *ctx, const char *pos) {
ast_t *key = NewAST(ctx->file, pos, pos, Var, .name = op_str);
for (bool progress = true; progress;) {
ast_t *new_term;
- progress =
- (false || (new_term = parse_index_suffix(ctx, key)) || (new_term = parse_method_call_suffix(ctx, key))
- || (new_term = parse_field_suffix(ctx, key)) || (new_term = parse_fncall_suffix(ctx, key))
- || (new_term = parse_optional_suffix(ctx, key)) || (new_term = parse_non_optional_suffix(ctx, key)));
+ progress = (false || (new_term = parse_index_suffix(ctx, key))
+ || (new_term = parse_method_call_suffix(ctx, key)) || (new_term = parse_field_suffix(ctx, key))
+ || (new_term = parse_fncall_suffix(ctx, key)) || (new_term = parse_non_optional_suffix(ctx, key)));
if (progress) key = new_term;
}
if (key && key->tag == Var) key = NULL;
@@ -98,8 +97,7 @@ ast_t *parse_heap_alloc(parse_ctx_t *ctx, const char *pos) {
ast_t *ast = NewAST(ctx->file, start, pos, HeapAllocate, .value = val);
for (;;) {
- ast_t *next = parse_optional_suffix(ctx, ast);
- if (!next) next = parse_non_optional_suffix(ctx, ast);
+ ast_t *next = parse_non_optional_suffix(ctx, ast);
if (!next) break;
ast = next;
}
@@ -123,8 +121,7 @@ ast_t *parse_stack_reference(parse_ctx_t *ctx, const char *pos) {
ast_t *ast = NewAST(ctx->file, start, pos, StackReference, .value = val);
for (;;) {
- ast_t *next = parse_optional_suffix(ctx, ast);
- if (!next) next = parse_non_optional_suffix(ctx, ast);
+ ast_t *next = parse_non_optional_suffix(ctx, ast);
if (!next) break;
ast = next;
}
@@ -212,7 +209,7 @@ ast_t *parse_term(parse_ctx_t *ctx, const char *pos) {
progress =
(false || (new_term = parse_index_suffix(ctx, term)) || (new_term = parse_method_call_suffix(ctx, term))
|| (new_term = parse_field_suffix(ctx, term)) || (new_term = parse_fncall_suffix(ctx, term))
- || (new_term = parse_optional_suffix(ctx, term)) || (new_term = parse_non_optional_suffix(ctx, term)));
+ || (new_term = parse_non_optional_suffix(ctx, term)));
if (progress) term = new_term;
}
return term;
diff --git a/src/parse/suffixes.c b/src/parse/suffixes.c
index 312f958f..7493a65d 100644
--- a/src/parse/suffixes.c
+++ b/src/parse/suffixes.c
@@ -25,13 +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);
}
-ast_t *parse_optional_suffix(parse_ctx_t *ctx, ast_t *lhs) {
- if (!lhs) return NULL;
- const char *pos = lhs->end;
- if (match(&pos, "?")) return NewAST(ctx->file, lhs->start, pos, Optional, .value = lhs);
- else return NULL;
-}
-
ast_t *parse_non_optional_suffix(parse_ctx_t *ctx, ast_t *lhs) {
if (!lhs) return NULL;
const char *pos = lhs->end;
diff --git a/src/parse/suffixes.h b/src/parse/suffixes.h
index da2f23a2..23ca7182 100644
--- a/src/parse/suffixes.h
+++ b/src/parse/suffixes.h
@@ -11,4 +11,3 @@ ast_t *parse_index_suffix(parse_ctx_t *ctx, ast_t *lhs);
ast_t *parse_method_call_suffix(parse_ctx_t *ctx, ast_t *self);
ast_t *parse_non_optional_suffix(parse_ctx_t *ctx, ast_t *lhs);
ast_t *parse_optional_conditional_suffix(parse_ctx_t *ctx, ast_t *stmt);
-ast_t *parse_optional_suffix(parse_ctx_t *ctx, ast_t *lhs);