• Stars
    star
    192
  • Rank 202,019 (Top 4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 13 years ago
  • Updated about 12 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

an extensible framework for JavaScript syntax tree shaping
JSShaper is an extensible framework for JavaScript syntax tree
shaping, created by Olov Lassus <[email protected]>.

The JSShaper web site is available at <http://jsshaper.org>.

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

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 a number of plugins, some of which are listed below:
  annotation-printer:
    prints /* @annotations */
  asserter:
    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")
  bitwiser:
    static analysis. requires @bitwise annotation for the
    bitwise operators | (or), & (and), to detect misspelling of the
    logical operators ||, &&.
  stringconverter:
    detects the ""+expr pattern and turns it into String(expr)
  restricter:
    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>
  logger:
    formatted logging with great detail (file, function, line)
  watcher:
    trap (watch) object modifications for debugging purposes

It also comes with a few small and simple examples (src/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 or
annoyances. Contributors are welcome!

JSShaper is designed to run with node.js or in the browser. It uses AMD.

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

For restricter (the restrict mode checker), you can also run the more
convenient run-restricter:
example: node run-restricter.js myfile.js

JSShaper can also execute on the fly, in your browser. Check out
example-restrict-mode-on-the-fly.html for an example of how to use that to
get restrict mode checking without a precomplilation step.

If you want to restrict mode check your node.js code,
plugins/restricter/restrict-mode.js can be loaded with require once and its
helper functions (such as __add) will be accessible to all other modules.

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.

More Repositories

1

ng-annotate

Add, remove and rebuild AngularJS dependency injection annotations
JavaScript
2,028
star
2

defs

Static scope analysis and transpilation of ES6 block scoped const and let variables to ES3 vars
JavaScript
116
star
3

jekyll-references

Jekyll Markdown references plugin
Ruby
43
star
4

ast-traverse

simple but flexible AST traversal with pre and post visitors
JavaScript
38
star
5

stringmap

Fast and robust stringmap for JavaScript
JavaScript
35
star
6

dart-range

Dart
11
star
7

node-harmony-wrapper

A node --harmony shell wrapper
Shell
10
star
8

tryor

return fn() or default value (in case of exception)
JavaScript
8
star
9

dart-scanner

Dart scanner implemented in Dart, ported from the dartc Java implementation
8
star
10

alter

Alters a string by replacing multiple range fragments in one fast pass
JavaScript
7
star
11

simple-is

Maximally minimal type-testing library for JavaScript
JavaScript
6
star
12

simple-fmt

Maximally minimal string formatting library for JavaScript
JavaScript
6
star
13

ordered-ast-traverse

Simple but flexible lexically ordered AST traversal with pre and post visitors
JavaScript
6
star
14

stringset

Fast and robust stringset for JavaScript
JavaScript
6
star
15

breakable

Break out of functions, recursive or not, in a more composable way than by using exceptions explicitly. Non-local return.
JavaScript
6
star
16

ordered-esprima-props

Lexical ordering of property names per Esprima AST type
JavaScript
3
star
17

fdelta

command-line tools for creating and applying delta files in Fossil delta format
C
2
star
18

vectorspace

Vectors are fun. Written for no particular reason other than trying out Ruby. Is likely pretty redundant, overall. Written on Ruby 1.9.1-preview 1 but should be mostly Ruby 1.8.x compatible. Again, vectors are fun.
Ruby
2
star
19

hookhttp

hook node.js require() via HTTP experiment
JavaScript
1
star
20

strto

strto is a strict string-to-number conversion library
JavaScript
1
star
21

jsoncomma

JSON with trailing commas for happy diffs
JavaScript
1
star