commit dca693c3073799b8d46cc9f6479839ea4c8d913d
parent 6761b0608d69551ae4bfe6e9b5a932ddcafb7b26
Author: Ryan Sepassi <rsepassi@gmail.com>
Date: Thu, 23 Apr 2026 16:58:19 -0700
m1pp: spell XOR as ^ (was \$); drop == alias for =
XOR is now ^ — the conventional spelling, no longer collides visually
with the \$(...) 8-byte hex builtin marker. Touches both m1pp/m1pp.c
and m1pp/m1pp.M1 (renamed op_dollar -> op_caret in rodata, swapped
the dispatch comparison).
= and == previously both returned EXPR_EQ. The expression language
has no assignment so there's no ambiguity to resolve, but two ways
to spell one thing is just noise. Dropped == (eliminated the dispatch
block in expr_op_code and the op_eq_eq rodata).
Updated tests/m1pp/04-expr-ops.M1pp accordingly and regenerated the
.expected. All 11 m1pp parity fixtures and the P1 hello fixture pass.
Diffstat:
4 files changed, 12 insertions(+), 29 deletions(-)
diff --git a/m1pp/m1pp.M1 b/m1pp/m1pp.M1
@@ -2548,9 +2548,8 @@ DEFINE EXPR_INVALID 1100000000000000
ret
## expr_op_code(a0=tok) -> a0 = EXPR_ADD..EXPR_GE, or EXPR_INVALID.
-## Accepts operator tokens: + - * / % << >> & | $ ~ = == !=
-## < <= > >=. XOR is spelled `$`, not `^`. Non-WORD tok or unknown
-## operator -> EXPR_INVALID.
+## Accepts operator tokens: + - * / % << >> & | ^ ~ = !=
+## < <= > >=. Non-WORD tok or unknown operator -> EXPR_INVALID.
##
## tok_eq_const is a leaf but clobbers a0..a3,t0..t2; spill tok to eoc_tok
## once, reload before each compare. Needs an enter_0 frame because it
@@ -2655,10 +2654,10 @@ DEFINE EXPR_INVALID 1100000000000000
la_br &eoc_or
bnez_a0
- # "$" -> EXPR_XOR (XOR is spelled `$`, not `^`)
+ # "^" -> EXPR_XOR
la_a0 &eoc_tok
ld_a0,a0,0
- la_a1 &op_dollar
+ la_a1 &op_caret
li_a2 %1 %0
la_br &tok_eq_const
call
@@ -2675,16 +2674,6 @@ DEFINE EXPR_INVALID 1100000000000000
la_br &eoc_not
bnez_a0
- # "==" -> EXPR_EQ (check before single "=" to honor longer match cleanly)
- la_a0 &eoc_tok
- ld_a0,a0,0
- la_a1 &op_eq_eq
- li_a2 %2 %0
- la_br &tok_eq_const
- call
- la_br &eoc_eq
- bnez_a0
-
# "=" -> EXPR_EQ
la_a0 &eoc_tok
ld_a0,a0,0
@@ -4245,9 +4234,8 @@ DEFINE EXPR_INVALID 1100000000000000
:const_select "%select"
## Operator strings for expr_op_code. Each is a raw byte literal; lengths
-## are passed separately to tok_eq_const. XOR is "$", not "^".
-## "==" must be tested before "=" so the longer match wins; same for
-## "<=" before "<" and ">=" before ">".
+## are passed separately to tok_eq_const. "<=" must be tested before "<"
+## so the longer match wins; same for ">=" before ">".
:op_plus "+"
:op_minus "-"
:op_star "*"
@@ -4257,10 +4245,9 @@ DEFINE EXPR_INVALID 1100000000000000
:op_shr ">>"
:op_amp "&"
:op_bar "|"
-:op_dollar "$"
+:op_caret "^"
:op_tilde "~"
:op_eq "="
-:op_eq_eq "=="
:op_ne "!="
:op_lt "<"
:op_le "<="
diff --git a/m1pp/m1pp.c b/m1pp/m1pp.c
@@ -780,13 +780,13 @@ static enum ExprOp expr_op_code(const struct Token *tok)
if (token_text_eq(tok, "|")) {
return EXPR_OR;
}
- if (token_text_eq(tok, "$")) {
+ if (token_text_eq(tok, "^")) {
return EXPR_XOR;
}
if (token_text_eq(tok, "~")) {
return EXPR_NOT;
}
- if (token_text_eq(tok, "=") || token_text_eq(tok, "==")) {
+ if (token_text_eq(tok, "=")) {
return EXPR_EQ;
}
if (token_text_eq(tok, "!=")) {
diff --git a/tests/m1pp/04-expr-ops.M1pp b/tests/m1pp/04-expr-ops.M1pp
@@ -1,12 +1,11 @@
-# Phase 7 parity: every operator in the oracle's apply_expr_op table.
-# `$` is the oracle's spelling of XOR (not `^`). `==` and `=` are aliases.
+# Every operator in apply_expr_op.
-# variadic: +, *, &, |, $, with argc >= 1 (>2 to exercise the fold)
+# variadic: +, *, &, |, ^, with argc >= 1 (>2 to exercise the fold)
$((+ 1 2 3 4 5))
$((* 2 3 4))
$((& 0xFF 0x0F 0x07))
$((| 0x10 0x20 0x40))
-$(($ 0xFF 0x0F 0xF0))
+$((^ 0xFF 0x0F 0xF0))
# subtract: unary negate AND left-assoc with > 2 args
$((- 7))
@@ -25,7 +24,6 @@ $((~ 0))
# comparisons (each returns 0 or 1)
$((= 5 5))
-$((== 5 5))
$((!= 5 5))
$((< 3 5))
$((<= 5 5))
diff --git a/tests/m1pp/04-expr-ops.expected b/tests/m1pp/04-expr-ops.expected
@@ -1,7 +1,6 @@
-
'0F00000000000000'
'1800000000000000'
'0700000000000000'
@@ -25,7 +24,6 @@
'0100000000000000'
-'0100000000000000'
'0000000000000000'
'0100000000000000'
'0100000000000000'