Merge branch 'master' into query-pattern-is-definite

This commit is contained in:
Max Brunsfeld 2020-08-14 09:31:55 -07:00
commit 1ea29053e1
33 changed files with 2004 additions and 763 deletions

View file

@ -787,6 +787,8 @@ class Language {
}
break;
case 'not-match?':
isPositive = false;
case 'match?':
if (steps.length !== 3) throw new Error(
`Wrong number of arguments to \`#match?\` predicate. Expected 2, got ${steps.length - 1}.`
@ -801,7 +803,7 @@ class Language {
const regex = new RegExp(steps[2].value);
textPredicates[i].push(function(captures) {
for (const c of captures) {
if (c.name === captureName) return regex.test(c.node.text);
if (c.name === captureName) return regex.test(c.node.text) === isPositive;
}
return false;
});