@@ -14,7 +14,7 @@ The regular expression parser for ECMAScript.
14
14
$ npm install regexpp
15
15
```
16
16
17
- - require Node.js 4.0 .0 or newer.
17
+ - require Node.js 6.5 .0 or newer.
18
18
19
19
## 📖 Usage
20
20
@@ -23,8 +23,10 @@ import {
23
23
AST ,
24
24
RegExpParser ,
25
25
RegExpValidator ,
26
+ RegExpVisitor ,
26
27
parseRegExpLiteral ,
27
28
validateRegExpLiteral ,
29
+ visitRegExpAST
28
30
} from " regexpp"
29
31
```
30
32
@@ -50,6 +52,16 @@ This is equivalent to `new RegExpValidator(options).validateLiteral(source)`.
50
52
- ` source ` (` string ` ) The source code to validate.
51
53
- ` options? ` ([ ` RegExpValidator.Options ` ] ) The options to validate.
52
54
55
+ ### visitRegExpAST(ast, handlers)
56
+
57
+ Visit each node of a given AST.
58
+
59
+ This is equivalent to ` new RegExpVisitor(handlers).visit(ast) ` .
60
+
61
+ - ** Parameters:**
62
+ - ` ast ` ([ ` AST.Node ` ] ) The AST to visit.
63
+ - ` handlers ` ([ ` RegExpVisitor.Handlers ` ] ) The callbacks.
64
+
53
65
### RegExpParser
54
66
55
67
#### new RegExpParser(options?)
@@ -126,6 +138,20 @@ Validate a regular expression flags.
126
138
- ` start? ` (` number ` ) The start index in the source code. Default is ` 0 ` .
127
139
- ` end? ` (` number ` ) The end index in the source code. Default is ` source.length ` .
128
140
141
+ ### RegExpVisitor
142
+
143
+ #### new RegExpVisitor(handlers)
144
+
145
+ - ** Parameters:**
146
+ - ` handlers ` ([ ` RegExpVisitor.Handlers ` ] ) The callbacks.
147
+
148
+ #### visitor.visit(ast)
149
+
150
+ Validate a regular expression literal.
151
+
152
+ - ** Parameters:**
153
+ - ` ast ` ([ ` AST.Node ` ] ) The AST to visit.
154
+
129
155
## 📰 Changelog
130
156
131
157
- [ GitHub Releases] ( https://github.com/mysticatea/regexpp/releases )
@@ -146,5 +172,7 @@ Please use GitHub's Issues/PRs.
146
172
- ` npm run update:ids ` updates ` src/unicode/ids.ts ` .
147
173
- ` npm run watch ` runs tests with ` --watch ` option.
148
174
149
- [ `RegExpParser.Options` ] : src/parser.ts#L527
175
+ [ `AST.Node` ] : src/ast.ts#L4
176
+ [ `RegExpParser.Options` ] : src/parser.ts#L539
150
177
[ `RegExpValidator.Options` ] : src/validator.ts#L127
178
+ [ `RegExpVisitor.Handlers` ] : src/visitor.ts#L204
0 commit comments