mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-10-14 23:41:30 +07:00
Improve code quality and write tests
This commit is contained in:
35
node_modules/regexp-tree/dist/interpreter/finite-automaton/transforms/char-plus-to-star-transform.js
generated
vendored
Normal file
35
node_modules/regexp-tree/dist/interpreter/finite-automaton/transforms/char-plus-to-star-transform.js
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
* Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* A regexp-tree plugin to replace `a+` to `aa*`, since NFA/DFA
|
||||
* handles Kleene-closure `a*`, and `a+` is just a syntactic sugar.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
Repetition: function Repetition(path) {
|
||||
var node = path.node,
|
||||
parent = path.parent;
|
||||
|
||||
|
||||
if (node.quantifier.kind !== '+') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (parent.type === 'Alternative') {
|
||||
path.getParent().insertChildAt(node.expression, path.index);
|
||||
} else {
|
||||
path.replace({
|
||||
type: 'Alternative',
|
||||
expressions: [node.expression, node]
|
||||
});
|
||||
}
|
||||
|
||||
// Change quantifier.
|
||||
node.quantifier.kind = '*';
|
||||
}
|
||||
};
|
10
node_modules/regexp-tree/dist/interpreter/finite-automaton/transforms/index.js
generated
vendored
Normal file
10
node_modules/regexp-tree/dist/interpreter/finite-automaton/transforms/index.js
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
* Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = [
|
||||
// a+ -> aa*
|
||||
require('./char-plus-to-star-transform')];
|
Reference in New Issue
Block a user