Skip to content

Instantly share code, notes, and snippets.

@WayneCui
Last active August 29, 2015 14:10
Show Gist options
  • Save WayneCui/0435543758e3d0ed642f to your computer and use it in GitHub Desktop.
Save WayneCui/0435543758e3d0ed642f to your computer and use it in GitHub Desktop.
remove comments from JS source files
Rebol [
Title: {remove comments from JS source files}
Author: "Cui Wen"
File: %comment-cleaner.reb
Version: 0.1.0
Tabs: 4
]
data: {
/**
* Helper function for iterating over an array.
*/
function each(ary, func) {} //Similar to ....
/**
* Allow getting a global that is expressed in dot notation, like 'a.b.c'.
*/
var s = 1;
function getGlobal(value) {}
//the end
var url = "http://www.rebol.com"
}
parse data [
any [
to [ {/*} | {//} | {://} ][
remove [
{/*} thru {*/} | {//} to lf
]
|
{://} skip ; match branch REMOVE
]
|
skip ;match branch TO
]
]
probe data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment