diff --git a/src/main/antlr4/MPL.g4 b/src/main/antlr4/MPL.g4 index 3753c46..388593a 100644 --- a/src/main/antlr4/MPL.g4 +++ b/src/main/antlr4/MPL.g4 @@ -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 diff --git a/src/test/java/com/mpl/test/ParserTest.java b/src/test/java/com/mpl/test/ParserTest.java index ff1e209..0cf6eda 100644 --- a/src/test/java/com/mpl/test/ParserTest.java +++ b/src/test/java/com/mpl/test/ParserTest.java @@ -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;");