Skip to content

Fix for hex literal reader bug #25

wants to merge 91 commits into from

4 participants

Gozala commented Jan 20, 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 Configure integration tests. 4308fb2
@Gozala Gozala Print read & analysed forms in debug mode. 8a719e4
@kanaka kanaka Merge pull request #2 from Gozala/selfhosted/travis
Configure integration tests.
@Gozala Gozala `re-seq` has tail only if `past-match` is non empty string. cded82c
@kanaka kanaka Merge pull request #3 from Gozala/selfhosted/debug-print
Print read & analysed forms in debug mode.
@Gozala Gozala Fix regression introduced by #1 c2805bc
@kanaka kanaka Merge pull request #4 from Gozala/selfhosted/re-seq
Fix for (re-seq #"^$" "")
@kanaka kanaka 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.
@kanaka kanaka 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.


@kanaka kanaka Fix typo in quick.cljs test. 004c0d3
@kanaka kanaka 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 Unescape regerxp source before printing it. 644ea39
@kanaka kanaka Merge pull request #5 from Gozala/selfhosted/print-regexp
Fix: regexes with forward slashes are printed with extra escaping
@kanaka kanaka Web REPL clean. Split out CSS. Fix multiline entry. 2caa19d
@kanaka kanaka Merge remote branch 'kanaka/cljs_in_cljs' into cljs_in_cljs 0317c18
@arthuredelstein arthuredelstein use the same font for input and output code f4642f3
@kanaka kanaka Merge pull request #11 from arthuredelstein/cljs_in_cljs
use the same font for input and output code
@arthuredelstein arthuredelstein Add support for *1,*2,*3 a5a849f
@kanaka kanaka Cleanup web and node REPL/compiler bootstrap code.
Move the pre-compiled bootstrap code from JavaScript to the .cljs
@kanaka kanaka Merge pull request #13 from arthuredelstein/a5a849fef5bcfcc0a79d0d1e1…

Support in web REPL for *1, *2, *3
@kanaka kanaka Add web REPL UI based on Himera.
- Import base HTML, stylesheets and images from Himera
  ( Also, import synonym.html
  sibling file that has JavaScript to ClojureScript translations.
- Add src/cljs/webrepl2.cljs that implements the new REPL.

The new REPL can be built like this:

    cd web
    ../bin/cljsc ../src/cljs/webrepl2.cljs > webrepl2.js

Then open web/repl.html. The new REPL page has a much better design
and style with the reference/links from the Himera front page. The
REPL window is based on jquery.console and has history (up arrow)
@fogus fogus Minor modifications.
 * Made header link and tweaked style to support that
 * Added attribution
@kanaka kanaka Merge pull request #14 from fogus/cljs_in_cljs
Minor modifications.
@kanaka kanaka Fix division symbol.
- In ns-snap munge the cljs.core// symbol before and after read-string
  to avoid the Clojure-side exception.
- For cljs.core/name and cljs.core/namespace, correctly handle / and
  cljs.core//. This brings these functions in sync with
@kanaka kanaka Misc README updates. be624b7
@Gozala Gozala Fix keyword reader. eb17897
@Gozala Gozala Fix keyword function to match clojure's behaviour. 32ba9d9
@kanaka kanaka Merge pull request #16 from Gozala/bug/numeric-keywords
Fix for numeric keywords #7
@Gozala Gozala Write keyword tests. a99adce
@kanaka kanaka Merge pull request #17 from Gozala/bug/numeric-keywords
Write keyword tests for #16 (numeric keywords)
@Gozala Gozala Fix reader bug for a hex literals #9 e51c76d
@Gozala Gozala closed this Jan 20, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.