Amend grammar for rulings 18 and 26

This commit is contained in:
developtheweb 2026-07-09 23:26:53 -04:00
parent 2d1d17899a
commit c447eb7397
2 changed files with 14 additions and 6 deletions

View file

@ -166,9 +166,11 @@ primary
| list
;
// Ruling 26: λ is reserved — never an identifier. Every other Greek
// letter remains one (Fatima wants π).
greekVar
: ALPHA | BETA | GAMMA | DELTA | EPSILON | ZETA | ETA | THETA
| IOTA | KAPPA | LAMBDA_VAR | MU | NU | XI | OMICRON | PI
| IOTA | KAPPA | MU | NU | XI | OMICRON | PI
| RHO | SIGMA | TAU | UPSILON | PHI | CHI | PSI | OMEGA
;
@ -177,8 +179,9 @@ typeSymbol
;
// λx: body λx,y: body λx∈: body — parameters are a bare pattern list.
// Ruling 18: nullary functions exist — `λ: e` (bare colon) is admitted.
lambda
: LAMBDA_VAR pattern (IN condExpr)? COLON expr
: LAMBDA_VAR (pattern (IN condExpr)?)? COLON expr
;
forall
@ -409,9 +412,9 @@ RAWSTRING
: '"""' .*? '"""'
;
// Ruling 12: string escapes are exactly \n \t \" \\ — nothing else.
fragment ESC
: '\\' [\\nrt0"]
| '\\u{' [0-9a-fA-F]+ '}'
: '\\' [\\nt"]
;
// Comments

View file

@ -86,6 +86,7 @@ public class ParserTest extends MPLTestBase {
assertParses("pi ≜ 3.14159;");
assertParses("id ≜ λx: x;");
assertParses("π ≜ 3.14159;"); // greek letter on the left
assertParses("f ≜ λ: 1;"); // ruling 18: nullary λ, bare colon
}
@Test
@ -237,9 +238,13 @@ public class ParserTest extends MPLTestBase {
assertDoesNotParse("x ++ y;");
assertDoesNotParse("a ** b;");
// Invalid lambda syntax
assertDoesNotParse("λ: x;");
// Invalid lambda syntax (λ: x became VALID under ruling 18)
assertDoesNotParse("λx y: x + y;");
// Ruling 25: the parenthesized parameter spelling stays rejected.
assertDoesNotParse("λ(a, b): a;");
// Ruling 26: λ is reserved never an identifier.
assertDoesNotParse("λ ≜ 3;");
assertDoesNotParse("{λ};");
// Juxtaposition application was removed calls need parentheses
assertDoesNotParse("f x;");