-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
compiler: preliminary support for guards.
Proper support for guards will take a lot more than this, I think, since guards can have any level of nested expressions son long as it follows the rules outlined here: https://erlang.org/doc/reference_manual/expressions.html#guard-expressions This makes it more likely that we will need to generate an expression, and traverse it with a function like `is_guard_safe : Erlang.Ast.expression -> bool`. For the time being, this should allow most common guards to be written. We'll improve support after v0.1. Closes #17
- Loading branch information
Showing
7 changed files
with
129 additions
and
4 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
open Erlang | ||
|
||
let g _ = false | ||
|
||
let f x = | ||
match x with | ||
| y when (g y) -> 3 | ||
| _ -> 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,10 @@ | ||
open Erlang | ||
|
||
let f x = | ||
match x with | ||
| y when (is_number y) -> 3 | ||
| y when Erlang.is_binary y -> 3 | ||
| y when y > 3 -> 3 | ||
| y when y <= 3 -> 3 | ||
| _ -> 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