Use '$' for min/max variable

This commit is contained in:
Bruce Hill 2024-03-07 12:15:38 -05:00
parent 98d86d1934
commit fa66053e13
2 changed files with 3 additions and 3 deletions

View File

@ -523,7 +523,7 @@ CORD compile(env_t *env, ast_t *ast)
ast_t *key = ast->tag == Min ? Match(ast, Min)->key : Match(ast, Max)->key;
ast_t *lhs = ast->tag == Min ? Match(ast, Min)->lhs : Match(ast, Max)->lhs;
ast_t *rhs = ast->tag == Min ? Match(ast, Min)->rhs : Match(ast, Max)->rhs;
const char *key_name = ast->tag == Min ? "_min_" : "_max_";
const char *key_name = "$";
if (key == NULL) key = FakeAST(Var, key_name);
env_t *expr_env = fresh_scope(env);

View File

@ -738,7 +738,7 @@ PARSER(parse_reduction) {
ast_t *lhs = NewAST(ctx->file, pos, pos, Var, .name="$reduction");
ast_t *rhs = NewAST(ctx->file, pos, pos, Var, .name="$iter_value");
if (op == BINOP_MIN || op == BINOP_MAX) {
ast_t *key = NewAST(ctx->file, pos, pos, Var, .name=(op == BINOP_MIN ? "_min_" : "_max_"));
ast_t *key = NewAST(ctx->file, pos, pos, Var, .name="$");
for (bool progress = true; progress; ) {
ast_t *new_term;
progress = (false
@ -1302,7 +1302,7 @@ static ast_t *parse_infix_expr(parse_ctx_t *ctx, const char *pos, int min_tightn
for (binop_e op; (op=match_binary_operator(&pos)) != BINOP_UNKNOWN && op_tightness[op] >= min_tightness; spaces(&pos)) {
ast_t *key = NULL;
if (op == BINOP_MIN || op == BINOP_MAX) {
key = NewAST(ctx->file, pos, pos, Var, .name=op == BINOP_MIN ? "_min_" : "_max_");
key = NewAST(ctx->file, pos, pos, Var, .name="$");
for (bool progress = true; progress; ) {
ast_t *new_term;
progress = (false