Skip to content

Instantly share code, notes, and snippets.

@dustinboston
Created April 15, 2013 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dustinboston/5390799 to your computer and use it in GitHub Desktop.
Save dustinboston/5390799 to your computer and use it in GitHub Desktop.
A sweet.js macro for Python. See https://groups.google.com/forum/#!topic/sweetjs/n82-yrjXhgo for more info.
macro python {
// Print
case print $params (,) ... => {
console.log(( $params (,) ... ))
}
// Function definition
case def $name:ident ( $params (,) ... ) : $a $b ... => {
function $name( $params (,) ... ) { python $a $b ... }
}
// Function call
case $name:ident ( $params (,) ... ) => {
$name(( $params (,) ... ))
}
}
python
def sweet(msg):
print msg
sweet("Macros are sweet!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment