(this is mostly an FYI post on JS regexes processing tool)
Recently I've been posting about ES RegExp parser[1], which eventually got
evolved into a generic ES RegExp processor (called regexp-tree). This can
be used for different kinds of purposes, and regarding ECMAScript spec --
it can be used to check/implement new proposals, new syntax, etc.
Currently the tool includes the following modules:
Parser (including support for recent stage 3 proposals)
Traversal
Generic transformer
Optimizer
Compat-transpiler
Interpreter (work in progress)
For example, the optimizer[2] module is capable of translating, and
fixing your regexes from:
/[a-zA-Z_0-9][A-Z_\da-z]*\e{1,}/
To equivalent:
/\w+e+/
There is also an ESLint plugin with auto-fixing exist for it.
And the compat-transpiler[3] can be used to run/translate named capturing
groups, "dotAll" flag, etc.
/(?<value>a)\k<value>\1/
Translated into (with tracking group names for further runtime purposes):
/(a)\1\1/
The interpreter module can be used to actually run new regexes, or check
semantics of the spec, when new features are added. This may follow at
implementation an actual ES spec (and other DFA/NFA engines can be built).
Note: there is also a way to run newer regexes using compat-transpiler.
Please feel free to reach me in case you have any questions, or would like
to add/implement any new feature in the tool.
(this is mostly an FYI post on JS regexes processing tool)
Recently I've been posting about ES RegExp parser[1], which eventually got
evolved into a generic ES RegExp processor (called `regexp-tree`). This can
be used for different kinds of purposes, and regarding ECMAScript spec --
it can be used to check/implement new proposals, new syntax, etc.
Currently the tool includes the following modules:
- Parser (including support for recent stage 3 proposals)
- Traversal
- Generic transformer
- Optimizer
- Compat-transpiler
- Interpreter (work in progress)
For example, the `optimizer`[2] module is capable of translating, and
fixing your regexes from:
```js
/[a-zA-Z_0-9][A-Z_\da-z]*\e{1,}/
```
To equivalent:
```js
/\w+e+/
```
There is also an ESLint plugin with auto-fixing exist for it.
And the `compat-transpiler`[3] can be used to run/translate named capturing
groups, "dotAll" flag, etc.
```js
/(?<value>a)\k<value>\1/
```
Translated into (with tracking group names for further runtime purposes):
```js
/(a)\1\1/
```
The `interpreter` module can be used to actually run new regexes, or check
semantics of the spec, when new features are added. This may follow at
implementation an actual ES spec (and other DFA/NFA engines can be built).
Note: there is also a way to run newer regexes using compat-transpiler.
Please feel free to reach me in case you have any questions, or would like
to add/implement any new feature in the tool.
Dmitry
[1] https://esdiscuss.org/topic/es-regexp-parser
[2] https://www.npmjs.com/package/regexp-tree#using-optimizer-api
[3] https://www.npmjs.com/package/regexp-tree#using-compat-transpiler-api
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170415/5a087d8c/attachment.html>
(this is mostly an FYI post on JS regexes processing tool)
Recently I've been posting about ES RegExp parser[1], which eventually got evolved into a generic ES RegExp processor (called
regexp-tree
). This can be used for different kinds of purposes, and regarding ECMAScript spec -- it can be used to check/implement new proposals, new syntax, etc.Currently the tool includes the following modules:
For example, the
optimizer
[2] module is capable of translating, and fixing your regexes from:/[a-zA-Z_0-9][A-Z_\da-z]*\e{1,}/
To equivalent:
There is also an ESLint plugin with auto-fixing exist for it.
And the
compat-transpiler
[3] can be used to run/translate named capturing groups, "dotAll" flag, etc.Translated into (with tracking group names for further runtime purposes):
/(a)\1\1/
The
interpreter
module can be used to actually run new regexes, or check semantics of the spec, when new features are added. This may follow at implementation an actual ES spec (and other DFA/NFA engines can be built). Note: there is also a way to run newer regexes using compat-transpiler.Please feel free to reach me in case you have any questions, or would like to add/implement any new feature in the tool.
Dmitry
[1] esdiscuss.org/topic/es-regexp-parser [2] www.npmjs.com/package/regexp-tree#using-optimizer-api [3] www.npmjs.com/package/regexp-tree#using