Created
February 27, 2014 23:53
-
-
Save nsmaciej/9262303 to your computer and use it in GitHub Desktop.
Messing around with sweet.js (sweetjs.org)
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
macro $ttos { | |
case {_ $x} => { | |
var pattern = #{$x}; | |
var tokenString = pattern[0].token.value.toString(); | |
var stringValue = makeValue(tokenString, #{$here}); | |
return withSyntax($val = [stringValue]) { | |
return #{$val}; | |
} | |
} | |
} | |
macro < { | |
rule { $sel $($attr=$val) (,) ... > } => { | |
"<"+($ttos $sel)+" "+$(($ttos $attr)+"="+($ttos $val))...+">" | |
} | |
} | |
console.log(<a href='/'>); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Any way to make this repeating and/or recursive? Multi-line?