3 [![npm version](https://img.shields.io/npm/v/regexpp.svg)](https://www.npmjs.com/package/regexpp)
4 [![Downloads/month](https://img.shields.io/npm/dm/regexpp.svg)](http://www.npmtrends.com/regexpp)
5 [![Build Status](https://github.com/mysticatea/regexpp/workflows/CI/badge.svg)](https://github.com/mysticatea/regexpp/actions)
6 [![codecov](https://codecov.io/gh/mysticatea/regexpp/branch/master/graph/badge.svg)](https://codecov.io/gh/mysticatea/regexpp)
7 [![Dependency Status](https://david-dm.org/mysticatea/regexpp.svg)](https://david-dm.org/mysticatea/regexpp)
9 A regular expression parser for ECMAScript.
17 - require Node.js 8 or newer.
28 validateRegExpLiteral,
33 ### parseRegExpLiteral(source, options?)
35 Parse a given regular expression literal then make AST object.
37 This is equivalent to `new RegExpParser(options).parseLiteral(source)`.
40 - `source` (`string | RegExp`) The source code to parse.
41 - `options?` ([`RegExpParser.Options`]) The options to parse.
43 - The AST of the regular expression.
45 ### validateRegExpLiteral(source, options?)
47 Validate a given regular expression literal.
49 This is equivalent to `new RegExpValidator(options).validateLiteral(source)`.
52 - `source` (`string`) The source code to validate.
53 - `options?` ([`RegExpValidator.Options`]) The options to validate.
55 ### visitRegExpAST(ast, handlers)
57 Visit each node of a given AST.
59 This is equivalent to `new RegExpVisitor(handlers).visit(ast)`.
62 - `ast` ([`AST.Node`]) The AST to visit.
63 - `handlers` ([`RegExpVisitor.Handlers`]) The callbacks.
67 #### new RegExpParser(options?)
70 - `options?` ([`RegExpParser.Options`]) The options to parse.
72 #### parser.parseLiteral(source, start?, end?)
74 Parse a regular expression literal.
77 - `source` (`string`) The source code to parse. E.g. `"/abc/g"`.
78 - `start?` (`number`) The start index in the source code. Default is `0`.
79 - `end?` (`number`) The end index in the source code. Default is `source.length`.
81 - The AST of the regular expression.
83 #### parser.parsePattern(source, start?, end?, uFlag?)
85 Parse a regular expression pattern.
88 - `source` (`string`) The source code to parse. E.g. `"abc"`.
89 - `start?` (`number`) The start index in the source code. Default is `0`.
90 - `end?` (`number`) The end index in the source code. Default is `source.length`.
91 - `uFlag?` (`boolean`) The flag to enable Unicode mode.
93 - The AST of the regular expression pattern.
95 #### parser.parseFlags(source, start?, end?)
97 Parse a regular expression flags.
100 - `source` (`string`) The source code to parse. E.g. `"gim"`.
101 - `start?` (`number`) The start index in the source code. Default is `0`.
102 - `end?` (`number`) The end index in the source code. Default is `source.length`.
104 - The AST of the regular expression flags.
108 #### new RegExpValidator(options)
111 - `options` ([`RegExpValidator.Options`]) The options to validate.
113 #### validator.validateLiteral(source, start, end)
115 Validate a regular expression literal.
118 - `source` (`string`) The source code to validate.
119 - `start?` (`number`) The start index in the source code. Default is `0`.
120 - `end?` (`number`) The end index in the source code. Default is `source.length`.
122 #### validator.validatePattern(source, start, end, uFlag)
124 Validate a regular expression pattern.
127 - `source` (`string`) The source code to validate.
128 - `start?` (`number`) The start index in the source code. Default is `0`.
129 - `end?` (`number`) The end index in the source code. Default is `source.length`.
130 - `uFlag?` (`boolean`) The flag to enable Unicode mode.
132 #### validator.validateFlags(source, start, end)
134 Validate a regular expression flags.
137 - `source` (`string`) The source code to validate.
138 - `start?` (`number`) The start index in the source code. Default is `0`.
139 - `end?` (`number`) The end index in the source code. Default is `source.length`.
143 #### new RegExpVisitor(handlers)
146 - `handlers` ([`RegExpVisitor.Handlers`]) The callbacks.
148 #### visitor.visit(ast)
150 Validate a regular expression literal.
153 - `ast` ([`AST.Node`]) The AST to visit.
157 - [GitHub Releases](https://github.com/mysticatea/regexpp/releases)
161 Welcome contributing!
163 Please use GitHub's Issues/PRs.
165 ### Development Tools
167 - `npm test` runs tests and measures coverage.
168 - `npm run build` compiles TypeScript source code to `index.js`, `index.js.map`, and `index.d.ts`.
169 - `npm run clean` removes the temporary files which are created by `npm test` and `npm run build`.
170 - `npm run lint` runs ESLint.
171 - `npm run update:test` updates test fixtures.
172 - `npm run update:ids` updates `src/unicode/ids.ts`.
173 - `npm run watch` runs tests with `--watch` option.
175 [`AST.Node`]: src/ast.ts#L4
176 [`RegExpParser.Options`]: src/parser.ts#L539
177 [`RegExpValidator.Options`]: src/validator.ts#L127
178 [`RegExpVisitor.Handlers`]: src/visitor.ts#L204