aboutsummaryrefslogtreecommitdiff
path: root/src/parse.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-04-06 14:52:59 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-04-06 14:52:59 -0400
commit4043a99e0df9fab6791c485721c0046971754175 (patch)
tree5e9c966ecf315be98bd292d6d39511d6c0447ee5 /src/parse.c
parent2bb2ff871fa1761478442bec5f6a32c9428360a1 (diff)
Expand reducers so they support stuff like `(+.abs(): nums)` and
`(==.length: texts)`
Diffstat (limited to 'src/parse.c')
-rw-r--r--src/parse.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/src/parse.c b/src/parse.c
index d686bb6d..a11fc971 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -840,24 +840,21 @@ PARSER(parse_reduction) {
ast_e op = match_binary_operator(&pos);
if (op == Unknown) return NULL;
- ast_t *key = NULL;
- if (op == Min || op == Max) {
- key = NewAST(ctx->file, pos, pos, Var, .name="$");
- 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))
- );
- if (progress) key = new_term;
- }
- if (key->tag == Var) key = NULL;
- else pos = key->end;
+ ast_t *key = NewAST(ctx->file, pos, pos, Var, .name="$");
+ 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))
+ );
+ if (progress) key = new_term;
}
+ if (key->tag == Var) key = NULL;
+ else pos = key->end;
whitespace(&pos);
if (!match(&pos, ":")) return NULL;