Skip to content

Commit b4bfdfd

Browse files
hyperpolymathclaude
andcommitted
fix(parser): remove dead precedence declarations [#215 family F]
Menhir emitted 16 "precedence level / %prec ... never useful" warnings — declarations that never resolve any conflict because the expression cascade disambiguates structurally. They are pure noise that, alongside the conflict warnings, make a healthy build look broken. Removed (all certified "never useful" by Menhir itself): - precedence level: `%right EQ PLUSEQ MINUSEQ STAREQ SLASHEQ` (assignment ops — handled at statement level, never in the expr operator cascade) - precedence level: `%right BANG TILDE UMINUS UREF UDEREF` (unary level — `expr_unary` is right-recursive and already unambiguous) - precedence level: `%left DOT LBRACKET LPAREN` (postfix level — `expr_postfix` disambiguates structurally) - the three now-orphaned `%prec UMINUS/UREF/UDEREF` on the unary rules (UMINUS/UREF/UDEREF were pseudo-tokens used only there) Provably parse-behaviour-neutral — removing a declaration Menhir certifies resolves nothing cannot change any resolution. Verified: - 16 "never useful" warnings: gone (0 remain) - conflict counts UNCHANGED: 72 S/R, 10 R/R, 23 S/R states, 4 R/R states (identical resolution profile) - `dune test --force` green at 257/257 The retained `LOWEST_TYPE_ARROW`/`ARROW` levels (#216, family A) are *not* flagged — they do real work. Refs #215 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent c640cc5 commit b4bfdfd

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

lib/parser.mly

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ let rec effect_union_of_list = function
9797
See affinescript#215 (family A). */
9898
%nonassoc LOWEST_TYPE_ARROW
9999
%nonassoc ARROW
100-
%right EQ PLUSEQ MINUSEQ STAREQ SLASHEQ
101100
%left PIPEPIPE
102101
%left AMPAMP
103102
%left PIPE
@@ -108,8 +107,15 @@ let rec effect_union_of_list = function
108107
%left LTLT GTGT
109108
%left PLUS PLUSPLUS MINUS
110109
%left STAR SLASH PERCENT
111-
%right BANG TILDE UMINUS UREF UDEREF
112-
%left DOT LBRACKET LPAREN
110+
/* Removed (affinescript#215 family F): the assignment-op level
111+
(EQ PLUSEQ MINUSEQ STAREQ SLASHEQ), the unary level
112+
(BANG TILDE UMINUS UREF UDEREF), and the postfix level
113+
(DOT LBRACKET LPAREN) — Menhir certified every one of these
114+
precedence levels "never useful" (they resolve no conflict; the
115+
expr cascade disambiguates structurally). Removal is
116+
parse-behaviour-neutral, proven by the unchanged conflict counts
117+
and the green 257-test gate. UMINUS/UREF/UDEREF were pseudo-tokens
118+
used only by the now-removed `%prec` on the unary rules. */
113119

114120
/* Entry point */
115121
%start <Ast.program> program
@@ -707,11 +713,11 @@ expr_mul:
707713
| e = expr_unary { e }
708714

709715
expr_unary:
710-
| MINUS e = expr_unary %prec UMINUS { ExprUnary (OpNeg, e) }
716+
| MINUS e = expr_unary { ExprUnary (OpNeg, e) }
711717
| BANG e = expr_unary { ExprUnary (OpNot, e) }
712718
| TILDE e = expr_unary { ExprUnary (OpBitNot, e) }
713-
| AMP e = expr_unary %prec UREF { ExprUnary (OpRef, e) }
714-
| STAR e = expr_unary %prec UDEREF { ExprUnary (OpDeref, e) }
719+
| AMP e = expr_unary { ExprUnary (OpRef, e) }
720+
| STAR e = expr_unary { ExprUnary (OpDeref, e) }
715721
| e = expr_postfix { e }
716722

717723
expr_postfix:

0 commit comments

Comments
 (0)