JSX wrapper for Esprima that is a high performance, standard-compliant ECMAScript parser.
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.gitignore
.npmignore
.travis.yml
LICENSE.md
README.md
gruntfile.js
package.json

README.md

esprima.jsx

Synopsis

JSX wrapper for Esprima that is a high performance, standard-compliant ECMAScript parser.

Code Example

import "esprima.jsx";
import "console.jsx";

class _Main {
    static function main(argv : string[]) : void
    {
        var tokens = esprima.parse('var message = "Hello World!";');
        console.log(tokens);
    }
}

Motivation

You can create JS code modify/analyse code with awesome static type checking of JSX.

Installation

Type following command in your JSX project (if you don't create package.json, omit --save parameter):

$ npm install esprima.jsx --save
$ npm install esprima --save

Adds the following statement in your code:

import "./node_modules/esprima.jsx/lib/esprima.jsx";

API Reference

  • esprima.parse(sourcecode : string) : EsprimaToken

    Return tokens.

  • esprima.parse(sourcecode : string, option : Map.<boolean>) : EsprimaToken

    Return tokens with options.

    var tokens = esprima.parse(source, new EsprimaOption({
      loc: true,
      range : true,
      raw : false,
      tokens : true,
      comment : true,
      tolerant : false
    });
    • loc: Nodes have line and column-based location info
    • range: Nodes have an index-based location range (array)
    • raw: Literals have extra property which stores the verbatim source
    • tokens: An extra array containing all found tokens
    • comment: An extra array containing all line and block comments
    • tolerant: An extra array containing all errors found, attempts to continue parsing when an error is encountered

Development

Repository

Run Test

$ grunt test

Build

# Generate API reference
$ grunt doc

# Build application or library for JS project
$ grunt build

Author

License

BSD-2-Clause

Complete license is written in LICENSE.md.