Permalink
Browse files

Add support for Rhino.

  • Loading branch information...
1 parent 508ffe2 commit 8020706773832186a351d5b19ad66e7a0ead7011 @ariya committed Oct 16, 2012
Showing with 18 additions and 7 deletions.
  1. +13 −2 doc/index.html
  2. +4 −4 esprima.js
  3. +1 −1 index.html
View
@@ -37,7 +37,7 @@
<h2 id="usage">Basic Usage</h2>
<p>Esprima runs on web browsers (IE 6+, Firefox 1+, Safari 3+, Chrome 1+, Konqueror 4.6+, Opera 8+) as well as
-<a href="http://nodejs.org">Node.js</a>.</p>
+<a href="http://www.mozilla.org/rhino">Rhino</a> and <a href="http://nodejs.org">Node.js</a>.</p>
<h3>In a web browser</h3>
@@ -80,7 +80,18 @@ <h2 id="usage">Basic Usage</h2>
<h3>With Rhino</h3>
-<p>Note: This would be available soon.</p>
+<p>Load the source file from another script:</p>
+
+<pre class="prettyprint lang-js">
+load('/path/to/esprima.js');
+</pre>
+
+<p>The module <code>esprima</code> will be available as part of the global object:</p>
+
+<pre class="prettyprint lang-js">
+var syntax = esprima.parse('42');
+print(JSON.stringify(syntax, null, 2));
+</pre>
<h3>Parsing Interface</h3>
View
@@ -37,19 +37,19 @@ parseFunctionSourceElements: true, parseVariableIdentifier: true,
parseLeftHandSideExpression: true,
parseStatement: true, parseSourceElement: true */
-(function (factory) {
+(function (root, factory) {
'use strict';
// Universal Module Definition (UMD) to support AMD, CommonJS/Node.js,
- // and plain browser loading,
+ // Rhino, and plain browser loading.
if (typeof define === 'function' && define.amd) {
define(['exports'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports);
} else {
- factory((window.esprima = {}));
+ factory((root.esprima = {}));
}
-}(function (exports) {
+}(this, function (exports) {
'use strict';
var Token,
View
@@ -26,7 +26,7 @@
<a href="http://en.wikipedia.org/wiki/JavaScript">JavaScript</a>).</p>
<p>Esprima runs on web browsers (IE 6+, Firefox 1+, Safari 3+, Chrome 1+, Konqueror 4.6+, Opera 8+) as well as
-<a href="http://nodejs.org">Node.js</a>.</p>
+<a href="http://www.mozilla.org/rhino">Rhino</a> and <a href="http://nodejs.org">Node.js</a>.</p>
<h3>Features</h3>

0 comments on commit 8020706

Please sign in to comment.