Fix: regexes with forward slashes are printed with extra escaping #23

wants to merge 72 commits into


None yet
2 participants

Gozala commented Jan 8, 2013

No description provided.

kanaka added some commits Nov 16, 2012

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.
Add chouser's jsrepl modified to use the analyzer/compiler.
Build like this:

cd web
../bin/cljsc ../src/cljs/jsrepl.cljs > jsrepl.js
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).
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).
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.
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
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).
Properly munge symbols to JS names in get-expander.
Downside is that this creates an implicit dependency of cljs.analyzer
on cljs.compiler (munge).
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.
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
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.
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.
Add array macros and add commented out '.. and 'js-obj
This brings core.cljs more in sync with core from
Clojure/ClojureScript core.clj
Add type/protocol macros from ClojureScript core.clj
Add these macros and supporting functions/macros.

reify, extend-type, deftype, defrecord, defprotocol

kanaka and others added some commits Dec 27, 2012

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.
Add in-ns, fix munging of names in create-ns
Also, move *ns* and create-ns to cljs.core.
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
Implement ".." macro with analyzer/compiler fixes.
- In compiler/munge, replace ".." with "_DOTDOT_".
- In analyzer/resolve*var, do not treat ".." as ".abc" form.
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.
Add declare, defonce and stub defn-
- defn- marks the def :private but there is nothing that will stop
  non-local lookups as yet.
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).
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)
Merge pull request #1 from Gozala/selfhosted/regexp
Fix for regexps containing / character
Merge pull request #2 from Gozala/selfhosted/travis
Configure integration tests.
Merge pull request #3 from Gozala/selfhosted/debug-print
Print read & analysed forms in debug mode.
Update README, REPL debug, quick.cljs tests.
- Update bugs and TODOs in README.
- Separately print the read, analyzed and emitted code so that if it
  breaks after one step the intermediate results are still output.
- Add a regex test for fixed cases. Remove a couple of redundant tests
  (this focus is quick after all). Add a case for the time macro.
Revert "Move PushbackReader to core.cljs."
This reverts commit eaa8eeb.

Having it in core.cljs doesn't really clean up dependencies and there
are tighter relationships between the push-back-reader and the other
read functions in reader.cljs.


Add File/file ops to io.cljs. Restore analyzer/compiler file routines.
- Add File type, file I/O, path operations to src/cljs/cljs/io.cljs.
- Restore analyze-file in analyzer.cljs
- Restore compile-file, compile-root and other file related functions
  to compiler.cljs.
- Copy ns-snap (namespace snapshot) from src/clj/cljs/compiler.cljs to

@Gozala Gozala closed this Jan 8, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment