Created
September 24, 2013 19:22
-
-
Save cmcculloh/6689909 to your computer and use it in GitHub Desktop.
JS to CS translation utilities
This file contains hidden or 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
| #take an object definition and translate it's member function wrappers into coffee script | |
| # | |
| #eg: | |
| # { | |
| # blah: function(whatevs){ | |
| # var buncha = 'stuff here'; | |
| # } | |
| # } | |
| # | |
| #becomes: | |
| # { | |
| # blah = (whatevs) -> | |
| # var buncha = 'stuff here'; | |
| # } | |
| # | |
| ([a-zA-Z0-9\_]+)\:\ ?function\ ?[a-zA-Z0-9\_]*\(([a-zA-Z0-9\,\ \_]*)\)\{([\w\W]+?)\}{1}(?!\))\,? | |
| #rewrite var decs in a CS manner | |
| #rewrite boilerplate for loops in CS | |
| #eg: | |
| #for (var i = 0; i < list.length; i++) { | |
| # var buf = list[i]; | |
| # length += buf.length; | |
| #} | |
| #becomes: | |
| # for i in list | |
| # var buf = list[i]; | |
| # length += buf.length | |
| # | |
| for\ ?\(var\ ([a-zA-Z0-9\_]+)\ ?\=\ ?[0-9]+\;\ ?[a-zA-Z0-9\_\.]+\ ?\<\ ?([a-zA-Z0-9\.\_]+)\.length\;\ ?[a-zA-Z0-9\_\.]+\+\+\)\ {([\w\W])+\} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment