mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-08-12 00:24:41 +07:00
Improve code quality and write tests
This commit is contained in:
69
node_modules/regexp-tree/dist/compat-transpiler/transforms/compat-dotall-s-transform.js
generated
vendored
Normal file
69
node_modules/regexp-tree/dist/compat-transpiler/transforms/compat-dotall-s-transform.js
generated
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
* Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* A regexp-tree plugin to translate `/./s` to `/[\0-\uFFFF]/`.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
|
||||
// Whether `u` flag present. In which case we transform to
|
||||
// \u{10FFFF} instead of \uFFFF.
|
||||
_hasUFlag: false,
|
||||
|
||||
// Only run this plugin if we have `s` flag.
|
||||
shouldRun: function shouldRun(ast) {
|
||||
var shouldRun = ast.flags.includes('s');
|
||||
|
||||
if (!shouldRun) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Strip the `s` flag.
|
||||
ast.flags = ast.flags.replace('s', '');
|
||||
|
||||
// Whether we have also `u`.
|
||||
this._hasUFlag = ast.flags.includes('u');
|
||||
|
||||
return true;
|
||||
},
|
||||
Char: function Char(path) {
|
||||
var node = path.node;
|
||||
|
||||
|
||||
if (node.kind !== 'meta' || node.value !== '.') {
|
||||
return;
|
||||
}
|
||||
|
||||
var toValue = '\\uFFFF';
|
||||
var toSymbol = '\uFFFF';
|
||||
|
||||
if (this._hasUFlag) {
|
||||
toValue = '\\u{10FFFF}';
|
||||
toSymbol = '\uDBFF\uDFFF';
|
||||
}
|
||||
|
||||
path.replace({
|
||||
type: 'CharacterClass',
|
||||
expressions: [{
|
||||
type: 'ClassRange',
|
||||
from: {
|
||||
type: 'Char',
|
||||
value: '\\0',
|
||||
kind: 'decimal',
|
||||
symbol: '\0'
|
||||
},
|
||||
to: {
|
||||
type: 'Char',
|
||||
value: toValue,
|
||||
kind: 'unicode',
|
||||
symbol: toSymbol
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
};
|
59
node_modules/regexp-tree/dist/compat-transpiler/transforms/compat-named-capturing-groups-transform.js
generated
vendored
Normal file
59
node_modules/regexp-tree/dist/compat-transpiler/transforms/compat-named-capturing-groups-transform.js
generated
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
* Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* A regexp-tree plugin to translate `/(?<name>a)\k<name>/` to `/(a)\1/`.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
// To track the names of the groups, and return them
|
||||
// in the transform result state.
|
||||
//
|
||||
// A map from name to number: {foo: 2, bar: 4}
|
||||
_groupNames: {},
|
||||
|
||||
/**
|
||||
* Initialises the trasnform.
|
||||
*/
|
||||
init: function init() {
|
||||
this._groupNames = {};
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Returns extra state, which eventually is returned to
|
||||
*/
|
||||
getExtra: function getExtra() {
|
||||
return this._groupNames;
|
||||
},
|
||||
Group: function Group(path) {
|
||||
var node = path.node;
|
||||
|
||||
|
||||
if (!node.name) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Record group name.
|
||||
this._groupNames[node.name] = node.number;
|
||||
|
||||
delete node.name;
|
||||
delete node.nameRaw;
|
||||
},
|
||||
Backreference: function Backreference(path) {
|
||||
var node = path.node;
|
||||
|
||||
|
||||
if (node.kind !== 'name') {
|
||||
return;
|
||||
}
|
||||
|
||||
node.kind = 'number';
|
||||
node.reference = node.number;
|
||||
delete node.referenceRaw;
|
||||
}
|
||||
};
|
23
node_modules/regexp-tree/dist/compat-transpiler/transforms/compat-x-flag-transform.js
generated
vendored
Normal file
23
node_modules/regexp-tree/dist/compat-transpiler/transforms/compat-x-flag-transform.js
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
* Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* A regexp-tree plugin to remove `x` flag `/foo/x` to `/foo/`.
|
||||
*
|
||||
* Note: other features of `x` flags (whitespace, comments) are
|
||||
* already removed at parsing stage.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
RegExp: function RegExp(_ref) {
|
||||
var node = _ref.node;
|
||||
|
||||
if (node.flags.includes('x')) {
|
||||
node.flags = node.flags.replace('x', '');
|
||||
}
|
||||
}
|
||||
};
|
17
node_modules/regexp-tree/dist/compat-transpiler/transforms/index.js
generated
vendored
Normal file
17
node_modules/regexp-tree/dist/compat-transpiler/transforms/index.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
* Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
// "dotAll" `s` flag
|
||||
dotAll: require('./compat-dotall-s-transform'),
|
||||
|
||||
// Named capturing groups.
|
||||
namedCapturingGroups: require('./compat-named-capturing-groups-transform'),
|
||||
|
||||
// `x` flag
|
||||
xFlag: require('./compat-x-flag-transform')
|
||||
};
|
Reference in New Issue
Block a user