Amend grammar for rulings 18 and 26
This commit is contained in:
parent
2d1d17899a
commit
c447eb7397
2 changed files with 14 additions and 6 deletions
|
|
@ -166,9 +166,11 @@ primary
|
||||||
| list
|
| list
|
||||||
;
|
;
|
||||||
|
|
||||||
|
// Ruling 26: λ is reserved — never an identifier. Every other Greek
|
||||||
|
// letter remains one (Fatima wants π).
|
||||||
greekVar
|
greekVar
|
||||||
: ALPHA | BETA | GAMMA | DELTA | EPSILON | ZETA | ETA | THETA
|
: 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
|
| 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.
|
// λ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
|
||||||
: LAMBDA_VAR pattern (IN condExpr)? COLON expr
|
: LAMBDA_VAR (pattern (IN condExpr)?)? COLON expr
|
||||||
;
|
;
|
||||||
|
|
||||||
forall
|
forall
|
||||||
|
|
@ -409,9 +412,9 @@ RAWSTRING
|
||||||
: '"""' .*? '"""'
|
: '"""' .*? '"""'
|
||||||
;
|
;
|
||||||
|
|
||||||
|
// Ruling 12: string escapes are exactly \n \t \" \\ — nothing else.
|
||||||
fragment ESC
|
fragment ESC
|
||||||
: '\\' [\\nrt0"]
|
: '\\' [\\nt"]
|
||||||
| '\\u{' [0-9a-fA-F]+ '}'
|
|
||||||
;
|
;
|
||||||
|
|
||||||
// Comments
|
// Comments
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,7 @@ public class ParserTest extends MPLTestBase {
|
||||||
assertParses("pi ≜ 3.14159;");
|
assertParses("pi ≜ 3.14159;");
|
||||||
assertParses("id ≜ λx: x;");
|
assertParses("id ≜ λx: x;");
|
||||||
assertParses("π ≜ 3.14159;"); // greek letter on the left
|
assertParses("π ≜ 3.14159;"); // greek letter on the left
|
||||||
|
assertParses("f ≜ λ: 1;"); // ruling 18: nullary λ, bare colon
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -237,9 +238,13 @@ public class ParserTest extends MPLTestBase {
|
||||||
assertDoesNotParse("x ++ y;");
|
assertDoesNotParse("x ++ y;");
|
||||||
assertDoesNotParse("a ** b;");
|
assertDoesNotParse("a ** b;");
|
||||||
|
|
||||||
// Invalid lambda syntax
|
// Invalid lambda syntax (λ: x became VALID under ruling 18)
|
||||||
assertDoesNotParse("λ: x;");
|
|
||||||
assertDoesNotParse("λx y: x + y;");
|
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
|
// Juxtaposition application was removed — calls need parentheses
|
||||||
assertDoesNotParse("f x;");
|
assertDoesNotParse("f x;");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue