- Restructure conditionals into a condExpr precedence level and exception handling into a postfix rule, removing the mutual left recursion through expr/atomExpr (ANTLR error 119) - Rewrite pattern as patternAtom (COMMA patternAtom)*, removing left recursion with an empty-matchable tail (ANTLR error 148) - Drop the LAMBDA token fully shadowed by LAMBDA_VAR (warning 184) - Give \Rightarrow to EXPORT only; IMPLIES keeps \implies (warning 184) - Remove @header package declaration that duplicated the -package argument and made the generated parser uncompilable - Point the ANTLR source set at src/main/antlr4 so Gradle actually finds the grammar - Treat ANTLR warnings as errors (-Werror) - Record decisions in DECISIONS.md
1.6 KiB
1.6 KiB
Design decisions
One line per decision, with the rejected alternatives named. Governing principles, in order: One Right Answer, the Fatima test, minimal churn against the existing examples.
- Conditionals are guarded alternatives
(condition ⟹ result) | fallback, wired in as acondExprprecedence level; rejected: C-style ternarycond ? a : b(programmer convention, fails the Fatima test), standalone left-recursiveconditionalrule (ANTLR error 119). - Exception handling is a postfix operator
expr ↴ { … }; rejected: standaloneexceptionHandlerrule reachable fromatomExpr(mutual left recursion, ANTLR error 119). - λ has one token,
LAMBDA_VAR, used both as a variable and to open a lambda; rejected: separateLAMBDAtoken (identical alternatives, fully shadowed, ANTLR warning 184). \impliesmaps to ⟹ and\Rightarrowmaps to ⇒ — one escape, one glyph; rejected:\Rightarrowas an alias of ⟹ (shadowed EXPORT's escape, ANTLR warning 184).- The Java package for generated code comes from
-packagein build.gradle only; rejected:@headerpackage declaration in the grammar (combined with-packageit generates a duplicatepackagestatement that does not compile). - ANTLR warnings fail the build (
-Werrorin build.gradle); rejected: warnings as advisory output (they hid the shadowed-token bugs). - The choice-type rule is
⟨ expr ⟩with the interior|consumed bycondExpr; rejected: explicit⟨ expr | expr ⟩(the interior expr already consumes the bar, making the explicit BAR unreachable).