flow-parser
Advanced tools
Comparing version 0.21.0 to 0.23.1
{ | ||
"name": "flow-parser", | ||
"version": "0.21.0", | ||
"version": "0.23.1", | ||
"license": "BSD-3-Clause", | ||
@@ -5,0 +5,0 @@ "description": "JavaScript parser written in OCaml. Produces SpiderMonkey AST", |
@@ -1,33 +0,37 @@ | ||
# The Flow Parser | ||
# The flow-parser package | ||
The Flow Parser is a JavaScript parser written in OCaml. It produces an AST that conforms to [SpiderMonkey's Parser API](https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Parser_API) and that mostly matches what [esprima](http://esprima.org/) produces. The Flow Parser can be compiled to native code or can be compiled to JavaScript using [js_of_ocaml](http://ocsigen.org/js_of_ocaml/). | ||
This package contains the Flow parser in its compiled-to-JavaScript form. | ||
## Building the Flow Parser | ||
# What is Flow | ||
Building the Flow Parser requires OCaml. Compiling to JavaScript requires js_of_ocaml. | ||
See [flowtype.org](http://flowtype.org/). The code for the Flow parser [lives on GitHub](https://github.com/facebook/flow/tree/master/src/parser). | ||
### Initial set up | ||
# What is the Flow Parser | ||
* [Install opam](https://opam.ocaml.org/doc/Install.html) | ||
* `opam install js_of_ocaml` | ||
The Flow Parser is a JavaScript parser written in OCaml. It produces an AST that conforms to the [ESTree spec](https://github.com/estree/estree) and that mostly matches what [esprima](http://esprima.org/) produces. The Flow Parser can be compiled to native code or can be compiled to JavaScript using [js_of_ocaml](http://ocsigen.org/js_of_ocaml/). This npm package contains the Flow parser compiled to JavaScript. | ||
### Building the OCaml Flow Parser library | ||
# Usage | ||
make | ||
### Compiling the Flow Parser to JavaScript | ||
You can use the Flow parser in your browser or in node. To use in node you can just do | ||
make js | ||
```JavaScript | ||
require('flow-parser').parse('1+1'); | ||
``` | ||
## Tests | ||
To use in the browser, you can add | ||
The Flow Parser's test suite tests the JavaScript version of the parser, so you will need js_of_ocaml installed. The tests and tools also have some node module dependencies, so you will need to run | ||
```HTML | ||
<script src="flow_parser.js"></script> | ||
``` | ||
### Initial set up | ||
which will make the `flow` object available to use like so: | ||
* Follow the steps in [Building the Flow Parser](https://github.com/facebook/flow/blob/master/src/parser/README.md#building-the-flow-parser) | ||
* `npm install` | ||
```JavaScript | ||
flow.parse('1+1'); | ||
``` | ||
### Running the Tests | ||
# bin scripts | ||
make test | ||
* `flowparse` - Pass it a string to parse or a file to parse and it dumps the AST to stdout | ||
* `flowvalidate` - Pass it one or more files and it checks if they parse | ||
@@ -175,2 +175,7 @@ /** | ||
} | ||
// Class Decorator are not part of esprima but supported by flow | ||
if (esprima.decorators === undefined) { | ||
esprima.decorators = []; | ||
} | ||
break; | ||
@@ -187,2 +192,7 @@ case "ClassDeclaration": | ||
} | ||
// Class Decorator are not part of esprima but supported by flow | ||
if (esprima.decorators === undefined) { | ||
esprima.decorators = []; | ||
} | ||
break; | ||
@@ -189,0 +199,0 @@ case "ClassBody": |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
621110
16281
38
16