Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | 1x 1x 1x 22x 22x 22x 21x 29x 29x 15x 21x 1x 1x 1x | const Argument = require('./argument')
const TreeRegexp = require('./tree_regexp')
const ParameterType = require('./parameter_type')
class RegularExpression {
constructor(expressionRegexp, parameterTypeRegistry) {
this._expressionRegexp = expressionRegexp
this._parameterTypeRegistry = parameterTypeRegistry
this._treeRegexp = new TreeRegexp(expressionRegexp)
}
match(text) {
const parameterTypes = this._treeRegexp.groupBuilder.children.map(
groupBuilder => {
const parameterTypeRegexp = groupBuilder.source
return (
this._parameterTypeRegistry.lookupByRegexp(
parameterTypeRegexp,
this._treeRegexp,
text
) ||
new ParameterType(
null,
parameterTypeRegexp,
String,
s => s,
false,
false
)
)
}
)
return Argument.build(this._treeRegexp, text, parameterTypes)
}
get regexp() {
return this._expressionRegexp
}
get source() {
return this._expressionRegexp.source
}
}
module.exports = RegularExpression
|