flow-parser
v0.322.0
Published
JavaScript parser written in OCaml. Produces ESTree AST
Keywords
Readme
The flow-parser package
This package contains the Flow parser in its JavaScript package form.
What is Flow
See flow.org. The code for the Flow parser lives on GitHub.
What is the Flow Parser
The Flow Parser is a JavaScript parser for Flow syntax. It produces an AST that conforms to the ESTree spec. This npm package contains the Flow Rust parser compiled to WASM with JavaScript bindings.
Usage
You can use the Flow parser in node:
const {parse} = require('flow-parser');
parse('1+1', {});Options
The second argument to parse is the options object. Common options:
Basic options
flow('detect'or'all', default'detect') - parse Flow syntax only with an@flowpragma, or always parse Flow syntaxsourceType('module','script', or'unambiguous') - parse the file as a module, script, or infer it from the contentstokens(boolean, defaultfalse) - include a list of all parsed tokens in a top-leveltokenspropertybabel(boolean, defaultfalse) - return a Babel-shaped AST
Language features
enableEnums(boolean, defaulttrue) - enable parsing of enumsenableExperimentalFlowMatchSyntax(boolean, defaulttrue) - enable parsing of match expressions and match statementsenableExperimentalComponentSyntax(boolean, defaulttrue) - enable parsing of component syntaxassertOperator(boolean, defaultfalse) - enable parsing of the assert operatorenableExperimentalDecorators(boolean, defaulttrue) - enable parsing of decorators
