Welcome to the JSShaper group

Skip to first unread message

Olov Lassus

Mar 29, 2011, 5:15:13 PM3/29/11
to JSShaper
This is the google group for discussions about JSShaper and its
plugins, an extensible framework for JavaScript syntax tree shaping
(also known as rewriting or transforming). Feel free to post about
anything that relates to it, including restrict mode.

Snapshot of the README as of today follows:

JSShaper is an extensible framework for JavaScript syntax tree
shaping, created by Olov Lassus <olov....@gmail.com>.

There's a google group at <http://groups.google.com/group/jsshaper>
Follow me on <http://twitter.com/olov> or visit me at <http://

JSShaper and its plugins are implemented in JavaScript. Syntax tree
shaping means performing complex manipulations to a syntax tree
representation of your textual source code, and then turning it back
into source code again. JSShaper goes very far to keep all your source
code formatting, intendation, whitespace and comments.

JSShaper comes with the following plugins:
prints /* @annotations */
provides c-style assertions by shaping
assert(f(x) === 3) into
assert(f(x) === 3, "f(x) === 3, function myfn, file myfilename.js,
line 14")
static analysis. requires @bitwise annotation for the
bitwise operators | (or), & (and), to detect misspelling of the
logical operators ||, &&.
detects the ""+expr pattern and turns it into String(expr)
adds run-time checking for restrict mode programs by
converting operators into function calls in a compatible way. it
comes with a small run-time library. <http://restrictmode.org>

It also comes with a few small and simple examples.

Get the source code from <https://github.com/olov/jsshaper>:
git clone git://github.com/olov/jsshaper.git
cd jsshaper
git submodule init
git submodule update

JSShaper is young, not very documented, and may crash with horrible
error messages. Thanks for being an early adopter and reporting bugs
annoyances. Contributors are welcome!

JSShaper is designed to run from the command line. It should be
possible to use with the following JS shells:
js: recent versions of Mozilla SpiderMonkey/TraceMonkey
d8: Google V8 debug shell
node: Embedded V8 with lots more

It doesn't work with the JavaScriptCore jsc shell since it has no load

Run it like this (replace d8 with your preferred shell):
d8 run-shaper.js -- filename [shape1 .. shapeN]
where shape is a plugin (see plugins/) or --builtin (--tree or --
example: d8 run-shaper.js -- myfile.js plugins/annotater.js plugins/
bitwiser.js --source
example: d8 run-shaper.js -- myfile.js plugins/annotater.js plugins/
restricter.js --source

For restricter, you can also run the more convenient run-restricter:
example: d8 run-restricter.js -- myfile.js

JSShaper and its plugins are Open Source and licensed under the MIT
license, see LICENSE file for terms and conditions.

JSShaper uses the parser from the Mozilla Narcissus
JavaScript-in-JavaScript interpreter
<https://github.com/mozilla/narcissus>, under the terms of the MPL 1.1
license. For full Narcissus licensing information read the
src/narcissus/LICENSE file.
Reply all
Reply to author
0 new messages