Closed ye closed 11 years ago
@ye Yes. I think that would be a natural direction to go in. My guess is it would be beneficial to both compile frak to a jar and a JavaScript file; the latter being preferable.
:+1: Nice work @noprompt, the benchmarks you've posted are really impressive. A JS library would be extremely appreciated.
@philipkobernik Thanks. A command line version and a standalone JS lib will be available soon (for those who don't use ClojureScript).
If you have leiningen and nodejs installed and want to try out the command line version, clone this repo and checkout
the cli
branch. Then compile the code to JavaScript:
$ lein cljsbuild once prod
Compiling ClojureScript.
Compiling "bin/frak.prod.js" from ["src/clj" "src/cljs"]...
Successfully compiled "bin/frak.prod.js" in 25.508828 seconds.
Then try:
$ mv bin/frak.prod.js bin/frak
$ chmod +x bin/frak
$ bin/frak --help
Usage: frak <flags*> <strings+>
-e, --exact Generated pattern requires an exact match
-c, --capture Generated pattern captures
-h, --help Display this help message
$ bin/frak --exact bat ban barn bar box born bird
^b(?:a(?:[tn]|r(?:n)?)|o(?:x|rn)|ird)$
@noprompt I've followed the steps above and tried to run it but had this error:
[ye@Yes-rMBP:~/dev/frak (master)] ye$ git pull
remote: Counting objects: 56, done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 52 (delta 16), reused 50 (delta 14)
Unpacking objects: 100% (52/52), done.
From https://github.com/noprompt/frak
edb9813..45176ae master -> github/master
* [new branch] cli -> github/cli
Updating edb9813..45176ae
Fast-forward
README.md | 3 +++
1 file changed, 3 insertions(+)
[ye@Yes-rMBP:~/dev/frak (master)] ye$ git co -b cli github/cli
Branch cli set up to track remote branch cli from github.
Switched to a new branch 'cli'
[ye@Yes-rMBP:~/dev/frak (cli)] ye$ lein cljsbuild once prod
Retrieving lein-cljsbuild/lein-cljsbuild/0.3.2/lein-cljsbuild-0.3.2.pom from clojars
Retrieving fs/fs/1.1.2/fs-1.1.2.pom from clojars
Retrieving org/apache/commons/commons-compress/1.3/commons-compress-1.3.pom from central
Retrieving org/apache/commons/commons-parent/22/commons-parent-22.pom from central
Retrieving org/apache/apache/9/apache-9.pom from central
Retrieving org/clojure/clojure/1.3.0/clojure-1.3.0.jar from central
Retrieving org/apache/commons/commons-compress/1.3/commons-compress-1.3.jar from central
Retrieving fs/fs/1.1.2/fs-1.1.2.jar from clojars
Retrieving lein-cljsbuild/lein-cljsbuild/0.3.2/lein-cljsbuild-0.3.2.jar from clojars
Compiling ClojureScript.
Retrieving criterium/criterium/0.4.1/criterium-0.4.1.pom from clojars
Retrieving cljsbuild/cljsbuild/0.3.2/cljsbuild-0.3.2.pom from clojars
Retrieving org/clojure/clojure/1.5.1/clojure-1.5.1.pom from central
Retrieving org/clojure/clojurescript/0.0-1806/clojurescript-0.0-1806.pom from central
Retrieving com/google/javascript/closure-compiler/r2180/closure-compiler-r2180.pom from central
Retrieving args4j/args4j/2.0.16/args4j-2.0.16.pom from central
Retrieving args4j/args4j-site/2.0.16/args4j-site-2.0.16.pom from central
Retrieving com/google/guava/guava/13.0.1/guava-13.0.1.pom from central
Retrieving com/google/guava/guava-parent/13.0.1/guava-parent-13.0.1.pom from central
Retrieving com/google/protobuf/protobuf-java/2.4.1/protobuf-java-2.4.1.pom from central
Retrieving com/google/google/1/google-1.pom from central
Retrieving org/json/json/20090211/json-20090211.pom from central
Retrieving com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.pom from central
Retrieving com/googlecode/jarjar/jarjar/1.1/jarjar-1.1.pom from central
Retrieving org/clojure/google-closure-library/0.0-2029-2/google-closure-library-0.0-2029-2.pom from central
Retrieving org/clojure/google-closure-library-third-party/0.0-2029-2/google-closure-library-third-party-0.0-2029-2.pom from central
Retrieving org/clojure/data.json/0.2.2/data.json-0.2.2.pom from central
Retrieving org/clojure/pom.contrib/0.0.25/pom.contrib-0.0.25.pom from central
Retrieving org/mozilla/rhino/1.7R4/rhino-1.7R4.pom from central
Retrieving clj-stacktrace/clj-stacktrace/0.2.5/clj-stacktrace-0.2.5.pom from clojars
Retrieving org/clojure/clojure/1.4.0/clojure-1.4.0.pom from central
Retrieving args4j/args4j/2.0.16/args4j-2.0.16.jar from central
Retrieving com/google/javascript/closure-compiler/r2180/closure-compiler-r2180.jar from central
Retrieving org/clojure/clojurescript/0.0-1806/clojurescript-0.0-1806.jar from central
Retrieving com/google/guava/guava/13.0.1/guava-13.0.1.jar from central
Retrieving com/google/protobuf/protobuf-java/2.4.1/protobuf-java-2.4.1.jar from central
Retrieving org/json/json/20090211/json-20090211.jar from central
Retrieving com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar from central
Retrieving com/googlecode/jarjar/jarjar/1.1/jarjar-1.1.jar from central
Retrieving org/clojure/google-closure-library/0.0-2029-2/google-closure-library-0.0-2029-2.jar from central
Retrieving org/clojure/google-closure-library-third-party/0.0-2029-2/google-closure-library-third-party-0.0-2029-2.jar from central
Retrieving org/clojure/data.json/0.2.2/data.json-0.2.2.jar from central
Retrieving org/mozilla/rhino/1.7R4/rhino-1.7R4.jar from central
Retrieving org/clojure/clojure/1.5.1/clojure-1.5.1.jar from central
Retrieving cljsbuild/cljsbuild/0.3.2/cljsbuild-0.3.2.jar from clojars
Retrieving criterium/criterium/0.4.1/criterium-0.4.1.jar from clojars
Retrieving clj-stacktrace/clj-stacktrace/0.2.5/clj-stacktrace-0.2.5.jar from clojars
Compiling "bin/frak.prod.js" from ["src/clj" "src/cljs"]...
WARNING: Use of undeclared Var frak/char? at line 75 /Users/ye/dev/frak/crossovers/frak.cljs
WARNING: Use of undeclared Var frak/char? at line 75 /Users/ye/dev/frak/crossovers/frak.cljs
Successfully compiled "bin/frak.prod.js" in 11.858417 seconds.
[ye@Yes-rMBP:~/dev/frak (cli)] ye$ less bin/frak.prod.js
[ye@Yes-rMBP:~/dev/frak (cli)] ye$ mv bin/frak.prod.js ~/bin/frak
[ye@Yes-rMBP:~/dev/frak (cli)] ye$ chmod +x ~/bin/frak
[ye@Yes-rMBP:~/dev/frak (cli)] ye$ frak --help
/Users/ye/bin/frak:83
+=1}else break;return Jd(i.T(),Ie(b,lb(d)))}f=I(d);d=L(d);return t(b.b?b.b(f):
^
TypeError: Cannot read property 'b' of undefined
at /Users/ye/bin/frak:83:275
at Bd (/Users/ye/bin/frak:57:59)
at X.r.F (/Users/ye/bin/frak:57:373)
at H (/Users/ye/bin/frak:18:317)
at Function.Mc [as a] (/Users/ye/bin/frak:42:21)
at Function.Rc [as e] (/Users/ye/bin/frak:43:30)
at Function.Qc [as a] (/Users/ye/bin/frak:42:477)
at jh (/Users/ye/bin/frak:157:347)
at Function.oh [as a] (/Users/ye/bin/frak:160:290)
at Function.nh [as b] (/Users/ye/bin/frak:160:152)
@ye Apparently ClojureScript doesn't like the char?
function. I've changed the code to use a different strategy and retried everything. It should work properly now.
I've merged the cli
branch with master and plan to release instructions when I push the new version of frak this week. The new instructions until then are:
$ lein do cljx once, cljsbuild once node
$ chmod +x bin/frak
Edit: Correction to lein
command
@noprompt Dit you push it yet ?
$ git clone https://github.com/noprompt/frak.git
Cloning into 'frak'...
remote: Counting objects: 215, done.
remote: Compressing objects: 100% (109/109), done.
remote: Total 215 (delta 86), reused 196 (delta 70)
Receiving objects: 100% (215/215), 29.12 KiB, done.
Resolving deltas: 100% (86/86), done.
$ cd frak
$ lein do cljx once, cljsbuild node
Copying 25 files to /home/px/tmp/frak/.lein-plugins
That's not a task. Use "lein help" to list all tasks.
I tried checking out the cli branch, but Leininger keeps complaining about the command syntax..?
@xaccrocheur Oh, whoops! I made a mistake. It should be lein do cljx once, cljsbuild once node
.
Instructions are now available in the README.
Hi Joel,
Nice work! In order to make this piece of code more widely usable, can you make this compiled into a command line tool?
Much appreciate it!
Ye