-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #120 from billhails/macros
Macros
- Loading branch information
Showing
27 changed files
with
928 additions
and
471 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
let | ||
fn NOT { | ||
(true) { false } | ||
(false) { true } | ||
} | ||
prefix 40 "NOT" NOT; | ||
|
||
macro AND(a, b) { if (a) { b } else { false } } | ||
infix left 30 "AND" AND; | ||
|
||
macro OR(a, b) { if (a) { true } else { b } } | ||
infix left 30 "OR" OR; | ||
|
||
fn XOR { | ||
(true, true) { false } | ||
(true, false) { true } | ||
(false, true) { true } | ||
(false, false) { false } | ||
} | ||
infix left 30 "XOR" XOR; | ||
|
||
macro NAND(a, b) { NOT (a AND b) } | ||
infix left 30 "NAND" NAND; | ||
|
||
macro NOR(a, b) { NOT (a OR b) } | ||
infix left 30 "NOR" NOR; | ||
|
||
macro XNOR(a, b) { NOT (a XOR b) } | ||
infix left 30 "XNOR" XNOR; | ||
|
||
fn a() { print("a called"); false } | ||
fn b() { print("b called"); false } | ||
fn c() { print("c called"); true } | ||
in | ||
print(a() AND b() OR c()); | ||
print(a() AND (b() OR c())); |
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
Oops, something went wrong.