1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- 'use strict';
- module.exports = {
- Quantifier: function Quantifier(path) {
- var node = path.node;
- if (node.kind !== 'Range') {
- return;
- }
-
- rewriteOpenZero(path);
-
- rewriteOpenOne(path);
-
- rewriteExactOne(path);
- }
- };
- function rewriteOpenZero(path) {
- var node = path.node;
- if (node.from !== 0 || node.to) {
- return;
- }
- node.kind = '*';
- delete node.from;
- }
- function rewriteOpenOne(path) {
- var node = path.node;
- if (node.from !== 1 || node.to) {
- return;
- }
- node.kind = '+';
- delete node.from;
- }
- function rewriteExactOne(path) {
- var node = path.node;
- if (node.from !== 1 || node.to !== 1) {
- return;
- }
- path.parentPath.replace(path.parentPath.node.expression);
- }
|