Fix for (re-seq #"^$" "") #22

wants to merge 62 commits into


None yet

2 participants

Gozala commented Jan 7, 2013

No description provided.

kanaka and others added some commits Nov 16, 2012
@kanaka kanaka Start of ClojureScript compiler in ClojureScript.
Compile like this:

rm -rf out/; bin/cljsc bs.cljs > bs.js && \
    bin/cljsc src/cljs/cljs/compiler.cljs > compiler.js && \
    bin/cljsc src/cljs/cljs/reader.cljs > reader.js

Then load comp.html. You will have a rep JavaScript function which
will read, eval and print:

    rep("(+ 1 1)");

CAVEAT: macros are not yet supported.
@kanaka kanaka Misc cleanup and add ns-snap. 9055ada
@kanaka kanaka Fix strings, numbers, false, regexp. 9e88716
@kanaka kanaka Add chouser's jsrepl modified to use the analyzer/compiler.
Build like this:

cd web
../bin/cljsc ../src/cljs/jsrepl.cljs > jsrepl.js
@kanaka kanaka Add build script for jsrepl.js. df22857
@kanaka kanaka Add some explanatory text to the jsrepl page. 3184a66
@kanaka kanaka Update README to explain the patched version. e58ebc2
@kanaka kanaka CLJS compiler and REPL working in Node.js
Compile and run the CLJS REPL:
    cd node
    ../bin/cljsc ../src/cljs/noderepl.cljs > noderepl.js
    cp ../src/cljs/goog.js out/
    ./run.js noderepl.js

Compile and run the the CLJS compiler wrapper:
    cd node
    ../bin/cljsc ../src/cljs/nodecljs.cljs > nodecljs.js
    cp ../src/cljs/goog.js out/
    ./run.js nodecljs.js hello.cljs

The :nodejs compilation target is currently broken. However, the
node/run.js bootstrap script enables compiled CLJS code to be
invoked that was not compiled with a :target.

Also, rename the jsrepl.cljs to webrepl.cljs to disambiguate with the
node.js equivalent (noderepl.js).
@kanaka kanaka Generate analyzer namespace snapshot while compiling.
This replaces the hardcoded bs.cljs file that only
provided cljs.core and cljs.user for the analyzer.

In order to load the snapshot, in Javascript (either in web/jsrepl.html
for web based or node/run.js) we set cljs.analyzer.namespaces to point
to cljs.namespaces (the snapshot built up during compilation).
@kanaka kanaka Define *out* and *ns* to squelch compile warnings. fe0a35e
@kanaka kanaka Make node and web REPL prompt be *cljs-ns* 39d13a9
@kanaka kanaka Remove verbose reader debug. 8b24ba0
@kanaka kanaka Move namespaces to cljs.core and "refer" it from cljs.analyzer.
This removes the need for the custom Javascript code in the bootstrap
files and in the namespace snapshot code.
@kanaka kanaka Add macro support to JS built cljs analyzer/compiler.
This doesn't yet enable defining and immediate use of macros during
JVM based analyze/compile of cljs.

In other words, in the live Node.js and web REPL you can define new
macros and use them via the REPL. However, you can't define them yet
in a file, analyzer/compile it and then use them during or after
@kanaka kanaka Remove old multimethod version of emit-constant. f9d971e
@kanaka kanaka Remove old version of ns-snap from compiler.cljs f0e8369
@kanaka kanaka Move PushbackReader to core.cljs.
In normal Clojure this comes from java so it makes sense to put it in
core.cljs to make it more widely available (analyzer.cljs and
compiler.cljs will want this when they begin supporting whole files).
@kanaka kanaka Add syntax quote/unquote to the reader. 0345cad
@kanaka kanaka Remove debug. ca7996f
@kanaka kanaka Remove require of bs from jsrepl.html. 0e23110
@kanaka kanaka Fix nodecljs.cljs wrapper to use correct push-back-reader location. fc472bf
@kanaka kanaka Update README and add runtime macro examples. bb7a168
@kanaka kanaka Correction to web and node.js REPL startup comments. 68081b5
@kanaka kanaka Properly munge symbols to JS names in get-expander.
Downside is that this creates an implicit dependency of cljs.analyzer
on cljs.compiler (munge).
@kanaka kanaka Debug and stack trace in noderepl and webrepl. fbd5901
@kanaka kanaka Fix syntax quote typos and syntax quote nil handling. 4255b31
@kanaka kanaka Activate and fix reader for ";" comments. 74ed2d3
@kanaka kanaka Add readers for anonymous functions and args. 75dc7ca
@kanaka kanaka Add destructure and Clojure core macros.
Add macros from Clojure core (specifically src/clj/clojure/core.clj).

In order to eval macros during analysis, we :use-macros to include
clj-defmacro which is then used to define precompile/analyzed macros
for later use at runtime.

Some minor changes have to be made to the macros to make them work
in ClojureScript via clj-defmacro:

- Use cljs.core/* symbols explicitly within syntax quoted sections of
  the macros.
- Convert java exceptions to Javascript exceptions.
- Stub out any code that tries to apply metadata to var/symbols.

Macros added:

- Add non destructuring stubs for let, loop.

- Add macros from Clojure (JVM) core:
    defn, when, when-not, cond, if-not, and, or, ->, ->>, if-let,
    when-let, doto, memfn, fn, when-first, comment, while, letfn.
@kanaka kanaka Add ClojureScript core macros.
This adds macros from ClojureScript (specifically
src/clj/cljs/core.clj) to the runtime.

- Add destructuring forms of let and loop

- Other macros added:
    satisfies?, binding, lazy-seq, delay, condp, case, try, assert,
    for, doseq, amap, areduce, dotimes, time, with-out-str
@kanaka kanaka Misc node and web REPL fixes/cleanup.
- Save last exception as noderepl/*e or webrepl/*e.
- Split ep function out of pep in webrepl to match noderepl.
- Don't throw EOF error in noderepl when line is blank.
@kanaka kanaka Update README. c4d36bf
@kanaka kanaka Remove REPL note about missing predefined macros. b197f9f
@kanaka kanaka Make symbols first class objects rather than prefixed strings.
Specifically this allows symbols to have metadata. This is widely used
for communicating metadata among the type/protocol macros and the
analyzer. The downside is that symbol map keys can be slower because
in Javascript objects cannot be used as attribute keys. This means
that a slower path is used for objects that contain symbols as keys.
@kanaka kanaka Cleanup various exceptions. 913c689
@kanaka kanaka Synchronize spacing/ordering with Clojure/ClojureScript core.* e9a9405
@kanaka kanaka Add array macros and add commented out '.. and 'js-obj
This brings core.cljs more in sync with core from
Clojure/ClojureScript core.clj
@kanaka kanaka Add type/protocol macros from ClojureScript core.clj
Add these macros and supporting functions/macros.

reify, extend-type, deftype, defrecord, defprotocol
@kanaka kanaka Add multimethod macros (defmulti, defmethod). 3654132
@kanaka kanaka Update TODOs and bugs in README. 9140c7c
@kanaka kanaka Fix iEquiv of namespaced symbols. ba2fe80
@kanaka kanaka Fix protocol-prefix regex to match multiple delimiters. ec757d8
@kanaka kanaka Allow ns multiple times for same namespace.
The ns "macro" normally generates goog.provide for the namespace,
however, goog.provide will error if the name already exists. We set
the *emittted-provides* to an empty var even if we are compiling
outside a file (i.e. REPL) so that multiple invocation of ns will not
cause an error. This mirrors Clojure behavior.
@kanaka kanaka Add in-ns, fix munging of names in create-ns
Also, move *ns* and create-ns to cljs.core.
@kanaka kanaka Web and node REPL namespace related fixups.
- Better bootstrap of initial cljs.user namespace that allows
  switching back in.
- Redefine analyzer environment for each new form before evaluation so
  that the current namespace is set correctly based on *cljs-ns*.
- Update current namespace in front of the prompt textarea.
- Remove some old debug functions from jsrepl.html
@kanaka kanaka Add extend-protocol. 29ecdba
@kanaka kanaka Implement ".." macro with analyzer/compiler fixes.
- In compiler/munge, replace ".." with "_DOTDOT_".
- In analyzer/resolve*var, do not treat ".." as ".abc" form.
@kanaka kanaka Update README 1d7b6de
@kanaka kanaka Fix webrepl typo. 31d296d
@kanaka kanaka Refactor namespaces as normal Clojure datastructure.
In Clojure, a namespace is a mutable Java object that changes as the
namespace is modified (new vars are added). For example, *ns* will
hash to the same thing before and after def'ing a new var even though
*ns* now contains the new var. In ClojureScript, all namespaces are
contained ina single atom cljs.core/namespaces that are indexed by
namespace symbol.

Instead of using a special global *ns* symbol that holds the current
namespace as a mutable Java object, use *ns-sym* as the symbol name of
the current namespace and whenever the namespace is needed, deref the
namespaces atom to look it up.

Remove ns related functions from analyzer and add some ns functions to
core based on those in Clojure core but using cljs.core/namespaces:
create-ns, find-ns, resolve, resolve-ns.
@kanaka kanaka Add declare, defonce and stub defn-
- defn- marks the def :private but there is nothing that will stop
  non-local lookups as yet.
@kanaka kanaka Fix -prototype call in extend-type. 9a420c1
@kanaka kanaka Add load-file, forms-seq, compile-forms*.
load-file is similar to the Clojure version but returns a map of
compile info rather than the result of the final form in the file.
load-file* returns the same map but includes :emit-str (the emitted
Javascript) and :output (any output printed during load, rather than
printing it directly).
@kanaka kanaka Fix typo in comment. daf59f0
@kanaka kanaka Fix nodecljs.cljs to not rely on js/env. a3cce03
@kanaka kanaka Add quick.cljs test to cover basics quickly.
At the REPL load and run like this:

> (load-file "../test/cljs/cljs/quick.cljs")
> (runt-tests)
@Gozala Gozala Fix reader to read regexp properly. d963f82
@Gozala Gozala Remove repeated definition of emit-str function b7619ff
@Gozala Gozala Move regexp escaping from reader to compiler. 45a222d
@kanaka kanaka Merge pull request #1 from Gozala/selfhosted/regexp
Fix for regexps containing / character
@Gozala Gozala `re-seq` has tail only if `past-match` is non empty string. cded82c
@Gozala Gozala Fix regression introduced by #1 c2805bc
Gozala commented Jan 7, 2013

Oops sorry wrong target.

@Gozala Gozala closed this Jan 7, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment