Skip to content

Instantly share code, notes, and snippets.

@kl0tl
Last active August 29, 2015 14:02
Show Gist options
  • Save kl0tl/d2d76f41ac419b09a938 to your computer and use it in GitHub Desktop.
Save kl0tl/d2d76f41ac419b09a938 to your computer and use it in GitHub Desktop.
Parens free `while` statement
/*
`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