-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* dev: draft pattern matching * fix: unexpected .e in eval * fix: platform independent path for linker output * fix: workaround for noCore import handling * gg * revert: expression change * feat: pattern match on simple enum class * feat: pattern match on sample class instance * dev: match result * dev: reorder syntax cons * dev: pass all tests * dev: simplify matchPat * dev: start match building * dev: refactor a bit * dev: elementary value match * dev: draft recursive match building * dev: finish recursive match building * dev: fix some recursion bugs * dev: value coverage check * dev: pass all samples --------- Co-authored-by: seven-mile <[email protected]>
- Loading branch information
1 parent
7d7b870
commit e93a0b7
Showing
52 changed files
with
1,882 additions
and
770 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class T { val x = 1; } | ||
----- ----- | ||
T match { | ||
case T => 1 | ||
} | ||
----- | ||
T match { | ||
case _ => 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class T { val x = 1; val y = 1; } | ||
----- ----- | ||
T(x: 1, y: 2) match { | ||
case T(x, y) => x + y | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class ValueT(T: Type) { | ||
case Null; | ||
case Elem(T); | ||
} | ||
val v1 = ValueT(i32).Null; | ||
val v2: ValueT(i32) = v1; | ||
----- ----- | ||
ValueT(i32).Null match { | ||
case ValueT(i32).Null => 1 | ||
} | ||
----- | ||
v1 match { | ||
case ValueT(i32).Null => 1 | ||
} | ||
----- | ||
v2 match { | ||
case ValueT(i32).Null => 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
class Nat { | ||
case Zero | ||
case Succ(Nat) | ||
}; | ||
val v1 = Nat.Zero; | ||
val v2: Nat = Nat.Succ(Nat.Zero); | ||
----- ----- | ||
Nat.Zero match { | ||
case Nat.Zero => 1 | ||
} | ||
----- | ||
Nat.Succ(Nat.Zero) match { | ||
case Nat.Succ(Nat.Zero) => 1 | ||
} | ||
----- | ||
v2 match { | ||
case Nat.Zero => 0 | ||
case Nat.Succ(x) => 1 | ||
} | ||
----- | ||
v2 match { | ||
case Nat.Zero => 0 | ||
case Nat.Succ(Nat.Zero) => 1 | ||
case Nat.Succ(Nat.Succ(x)) => 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
val n1 = 1 | ||
----- ----- | ||
1 match { | ||
case 1 => 2 | ||
} | ||
----- | ||
1 match { | ||
case 0 => 2 | ||
} | ||
----- | ||
n1 match { | ||
case 1 => 3 | ||
} | ||
----- | ||
n1 match { | ||
case 0 => 4 | ||
} | ||
----- | ||
1 match { | ||
case 0 => 5 | ||
case 1 => 6 | ||
} | ||
----- | ||
1 match { | ||
case 0 => 7 | ||
case 1 => 8 | ||
} | ||
----- | ||
n1 + 1 match { | ||
case 0 => 3 | ||
case 1 => 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class Result[T, E] { | ||
case Ok(T); | ||
case Err(E); | ||
}; | ||
val v0: Result(i32, i32) = Result(i32, i32).Ok(1); | ||
val v1 = v0; | ||
----- ----- | ||
v0 match { | ||
case Result(i32, i32).Ok(t) => t | ||
} | ||
----- | ||
v1 match { | ||
case Result(i32, i32).Ok(t) => t | ||
case Result(i32, i32).Err(e) => ??? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
val v1 = "yes" | ||
----- ----- | ||
"yes" match { | ||
case "yes" => 1 | ||
} | ||
----- | ||
"yes" match { | ||
case "no" => 2 | ||
} | ||
----- | ||
v1 match { | ||
case "yes" => 3 | ||
} | ||
----- | ||
v1 match { | ||
case "no" => 4 | ||
} | ||
----- | ||
"yes" match { | ||
case "yes" => 5 | ||
case "no" => 6 | ||
} | ||
----- | ||
"no" match { | ||
case "yes" => 7 | ||
case "no" => 8 | ||
} | ||
----- | ||
v1 match { | ||
case "yes" => 5 | ||
case "no" => 6 | ||
} | ||
----- | ||
v1 match { | ||
case "yes" => 7 | ||
case "no" => 8 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class T { val x = 1; } | ||
----- | ||
T match T |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class T { val x = 1; } | ||
----- | ||
T(x: 1) match T | ||
T(x: 1) match T(x: 1) | ||
T match T(x: 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class T { val x = 1; val y = 1; } | ||
----- | ||
T(x: 1, y: 2) match T | ||
T(x: 1, y: 2) match T(x: 1) | ||
T(x: 1) match T(x: 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class Nat { | ||
case Zero | ||
case Succ(Nat) | ||
}; | ||
val v1 = Nat.Zero; | ||
val v2 = Nat.Succ(Nat.Zero); | ||
----- | ||
Nat.Zero match Nat.Zero | ||
Nat.Zero match Nat.Succ(Nat.Zero) | ||
Nat.Succ(Nat.Zero) match Nat.Succ(Nat.Zero) | ||
Nat.Succ(Nat.Zero) match Nat.Succ | ||
Nat.Succ(Nat.Zero) match Nat | ||
v1 match Nat.Succ(Nat.Zero) | ||
v2 match Nat.Succ(Nat.Zero) | ||
v2 match Nat.Succ | ||
v2 match Nat | ||
Nat.Zero match Nat.Succ(t) | ||
v1 match Nat.Succ(t) | ||
Nat.Succ(Nat.Zero) match Nat.Succ(t) | ||
v2 match Nat.Succ(t) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class Result[T, E] { | ||
case Ok(T); | ||
case Err(E); | ||
}; | ||
val v0: Result(i32, i32) = Result(i32, i32).Ok(1); | ||
val v1 = v0; | ||
----- | ||
Result(i32, i32).Ok(1) match Result(i32, i32).Ok(1) | ||
Result(i32, i32).Ok(1) match Result(i32, i32).Ok(t) | ||
Result(i32, i32).Ok(1) match Result(i32, i32).Ok(1) | ||
v0 match Result(i32, i32).Ok(t) | ||
v1 match Result(i32, i32).Ok(t) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
|
||
@noCore(); | ||
|
||
import std::result; | ||
import std::str; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
|
||
@noCore(); | ||
|
||
class Option[T] { | ||
case Some(T); | ||
case None; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
|
||
@noCore(); | ||
|
||
import cSys from "@lib/c++/cstdlib" | ||
|
||
import _ from std::prelude::lang | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.