Last active
August 29, 2015 14:02
-
-
Save kl0tl/d2d76f41ac419b09a938 to your computer and use it in GitHub Desktop.
Parens free `while` statement
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
/* | |
`while cond {}` | |
Brackets are mandatory | |
The following syntaxes are also valid | |
`do {} while cond` | |
`while cond;` | |
*/ | |
let while = macro { | |
rule { $cond:expr { $body ... } } => { | |
while ($cond) { $body ... } | |
} | |
rule infix { do { $body ... } | $cond:expr } => { | |
do { $body ... } while ($cond) | |
} | |
rule { $cond:expr ; } => { | |
while ($cond); | |
} | |
} | |
export while; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment