Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement RegExp named capture groups #1390

Merged
merged 1 commit into from
Jul 27, 2021

Conversation

raskad
Copy link
Member

@raskad raskad commented Jul 7, 2021

This Pull Request implements named capture groups for regular expressions.

It changes the following:

  • Implement support named capture groups regular expressions
  • Implement support backreferences to named capture groups regular expressions
  • Fix regexp lastIndex to be the number for utf16 codepoints instead of utf8

I implemented this feature in the regress library in ridiculousfish/regress#34.

The 262 test annexB/built-ins/RegExp/named-groups/non-unicode-malformed-lookbehind.js is expected to fail, because regress now parses named backreferences and assumes that the unicode flag is always true.

@Razican
Copy link
Member

Razican commented Jul 8, 2021

Test262 conformance changes:

Test result master count PR count difference
Total 78,897 78,897 0
Passed 27,936 27,988 +52
Ignored 15,616 15,616 0
Failed 35,345 35,293 -52
Panics 0 0 0
Conformance 35.41% 35.47% +0.07%
Fixed tests:
test/built-ins/String/prototype/split/argument-is-regexp-and-instance-is-number.js [strict mode] (previously Failed)
test/built-ins/String/prototype/split/argument-is-regexp-and-instance-is-number.js (previously Failed)
test/built-ins/RegExp/S15.10.2.10_A4.1_T2.js [strict mode] (previously Failed)
test/built-ins/RegExp/S15.10.2.10_A4.1_T2.js (previously Failed)
test/built-ins/RegExp/S15.10.2.10_A4.1_T3.js [strict mode] (previously Failed)
test/built-ins/RegExp/S15.10.2.10_A4.1_T3.js (previously Failed)
test/built-ins/RegExp/unicode_restricted_identity_escape_u.js [strict mode] (previously Failed)
test/built-ins/RegExp/unicode_restricted_identity_escape_u.js (previously Failed)
test/built-ins/RegExp/S15.10.2.10_A4.1_T1.js [strict mode] (previously Failed)
test/built-ins/RegExp/S15.10.2.10_A4.1_T1.js (previously Failed)
test/built-ins/RegExp/named-groups/unicode-property-names.js [strict mode] (previously Failed)
test/built-ins/RegExp/named-groups/unicode-property-names.js (previously Failed)
test/built-ins/RegExp/named-groups/string-replace-get.js [strict mode] (previously Failed)
test/built-ins/RegExp/named-groups/string-replace-get.js (previously Failed)
test/built-ins/RegExp/named-groups/unicode-property-names-valid.js [strict mode] (previously Failed)
test/built-ins/RegExp/named-groups/unicode-property-names-valid.js (previously Failed)
test/built-ins/RegExp/named-groups/string-replace-undefined.js [strict mode] (previously Failed)
test/built-ins/RegExp/named-groups/string-replace-undefined.js (previously Failed)
test/built-ins/RegExp/named-groups/non-unicode-property-names-valid.js [strict mode] (previously Failed)
test/built-ins/RegExp/named-groups/non-unicode-property-names-valid.js (previously Failed)
test/built-ins/RegExp/named-groups/functional-replace-non-global.js [strict mode] (previously Failed)
test/built-ins/RegExp/named-groups/functional-replace-non-global.js (previously Failed)
test/built-ins/RegExp/named-groups/string-replace-missing.js [strict mode] (previously Failed)
test/built-ins/RegExp/named-groups/string-replace-missing.js (previously Failed)
test/built-ins/RegExp/named-groups/non-unicode-property-names.js [strict mode] (previously Failed)
test/built-ins/RegExp/named-groups/non-unicode-property-names.js (previously Failed)
test/built-ins/RegExp/named-groups/functional-replace-global.js [strict mode] (previously Failed)
test/built-ins/RegExp/named-groups/functional-replace-global.js (previously Failed)
test/built-ins/RegExp/named-groups/string-replace-numbered.js [strict mode] (previously Failed)
test/built-ins/RegExp/named-groups/string-replace-numbered.js (previously Failed)
test/built-ins/RegExp/named-groups/string-replace-unclosed.js [strict mode] (previously Failed)
test/built-ins/RegExp/named-groups/string-replace-unclosed.js (previously Failed)
test/built-ins/RegExp/named-groups/groups-object-unmatched.js [strict mode] (previously Failed)
test/built-ins/RegExp/named-groups/groups-object-unmatched.js (previously Failed)
test/built-ins/RegExp/named-groups/string-replace-escaped.js [strict mode] (previously Failed)
test/built-ins/RegExp/named-groups/string-replace-escaped.js (previously Failed)
test/built-ins/RegExp/prototype/Symbol.replace/result-coerce-groups-prop-err.js [strict mode] (previously Failed)
test/built-ins/RegExp/prototype/Symbol.replace/result-coerce-groups-prop-err.js (previously Failed)
test/built-ins/RegExp/prototype/Symbol.replace/result-coerce-groups-prop.js [strict mode] (previously Failed)
test/built-ins/RegExp/prototype/Symbol.replace/result-coerce-groups-prop.js (previously Failed)
test/built-ins/RegExp/prototype/Symbol.replace/named-groups.js [strict mode] (previously Failed)
test/built-ins/RegExp/prototype/Symbol.replace/named-groups.js (previously Failed)
test/built-ins/RegExp/prototype/Symbol.replace/result-coerce-groups.js [strict mode] (previously Failed)
test/built-ins/RegExp/prototype/Symbol.replace/result-coerce-groups.js (previously Failed)
test/built-ins/RegExp/prototype/Symbol.replace/result-get-groups-prop-err.js [strict mode] (previously Failed)
test/built-ins/RegExp/prototype/Symbol.replace/result-get-groups-prop-err.js (previously Failed)
test/language/literals/regexp/u-surrogate-pairs-atom-char-class.js [strict mode] (previously Failed)
test/language/literals/regexp/u-surrogate-pairs-atom-char-class.js (previously Failed)
test/language/literals/regexp/u-unicode-esc.js [strict mode] (previously Failed)
test/language/literals/regexp/u-unicode-esc.js (previously Failed)
test/language/literals/regexp/u-surrogate-pairs.js [strict mode] (previously Failed)
test/language/literals/regexp/u-surrogate-pairs.js (previously Failed)
test/language/literals/regexp/named-groups/forward-reference.js [strict mode] (previously Failed)
test/language/literals/regexp/named-groups/forward-reference.js (previously Failed)
Broken tests:
test/annexB/built-ins/RegExp/named-groups/non-unicode-malformed-lookbehind.js [strict mode] (previously Passed)
test/annexB/built-ins/RegExp/named-groups/non-unicode-malformed-lookbehind.js (previously Passed)

@Razican Razican added this to the v0.13.0 milestone Jul 8, 2021
@Razican Razican added builtins PRs and Issues related to builtins/intrinsics enhancement New feature or request labels Jul 8, 2021
@raskad raskad force-pushed the regexp-named-capture-groups branch from c9303a5 to 830f321 Compare July 14, 2021 17:05
@jasonwilliams
Copy link
Member

Thanks this looks awesome, great work on regress also.
Will hopefully get around to taking a look

@raskad raskad force-pushed the regexp-named-capture-groups branch from 830f321 to e582993 Compare July 22, 2021 20:32
@raskad
Copy link
Member Author

raskad commented Jul 22, 2021

Rebased on master. Got a few less fixed tests now, because some where already passing with the regress upgrade.

Test262 conformance changes:

Test result master count PR count difference
Total 78,897 78,897 0
Passed 28,204 28,238 +34
Ignored 15,616 15,616 0
Failed 35,077 35,043 -34
Panics 2 2 0
Conformance 35.75% 35.79% +0.04%
Fixed tests:
test/built-ins/RegExp/named-groups/unicode-property-names.js [strict mode] (previously Failed)
test/built-ins/RegExp/named-groups/unicode-property-names.js (previously Failed)
test/built-ins/RegExp/named-groups/string-replace-get.js [strict mode] (previously Failed)
test/built-ins/RegExp/named-groups/string-replace-get.js (previously Failed)
test/built-ins/RegExp/named-groups/unicode-property-names-valid.js [strict mode] (previously Failed)
test/built-ins/RegExp/named-groups/unicode-property-names-valid.js (previously Failed)
test/built-ins/RegExp/named-groups/string-replace-undefined.js [strict mode] (previously Failed)
test/built-ins/RegExp/named-groups/string-replace-undefined.js (previously Failed)
test/built-ins/RegExp/named-groups/non-unicode-property-names-valid.js [strict mode] (previously Failed)
test/built-ins/RegExp/named-groups/non-unicode-property-names-valid.js (previously Failed)
test/built-ins/RegExp/named-groups/functional-replace-non-global.js [strict mode] (previously Failed)
test/built-ins/RegExp/named-groups/functional-replace-non-global.js (previously Failed)
test/built-ins/RegExp/named-groups/string-replace-missing.js [strict mode] (previously Failed)
test/built-ins/RegExp/named-groups/string-replace-missing.js (previously Failed)
test/built-ins/RegExp/named-groups/non-unicode-property-names.js [strict mode] (previously Failed)
test/built-ins/RegExp/named-groups/non-unicode-property-names.js (previously Failed)
test/built-ins/RegExp/named-groups/functional-replace-global.js [strict mode] (previously Failed)
test/built-ins/RegExp/named-groups/functional-replace-global.js (previously Failed)
test/built-ins/RegExp/named-groups/string-replace-numbered.js [strict mode] (previously Failed)
test/built-ins/RegExp/named-groups/string-replace-numbered.js (previously Failed)
test/built-ins/RegExp/named-groups/string-replace-unclosed.js [strict mode] (previously Failed)
test/built-ins/RegExp/named-groups/string-replace-unclosed.js (previously Failed)
test/built-ins/RegExp/named-groups/groups-object-unmatched.js [strict mode] (previously Failed)
test/built-ins/RegExp/named-groups/groups-object-unmatched.js (previously Failed)
test/built-ins/RegExp/prototype/Symbol.replace/result-coerce-groups-prop-err.js [strict mode] (previously Failed)
test/built-ins/RegExp/prototype/Symbol.replace/result-coerce-groups-prop-err.js (previously Failed)
test/built-ins/RegExp/prototype/Symbol.replace/result-coerce-groups-prop.js [strict mode] (previously Failed)
test/built-ins/RegExp/prototype/Symbol.replace/result-coerce-groups-prop.js (previously Failed)
test/built-ins/RegExp/prototype/Symbol.replace/named-groups.js [strict mode] (previously Failed)
test/built-ins/RegExp/prototype/Symbol.replace/named-groups.js (previously Failed)
test/built-ins/RegExp/prototype/Symbol.replace/result-coerce-groups.js [strict mode] (previously Failed)
test/built-ins/RegExp/prototype/Symbol.replace/result-coerce-groups.js (previously Failed)
test/built-ins/RegExp/prototype/Symbol.replace/result-get-groups-prop-err.js [strict mode] (previously Failed)
test/built-ins/RegExp/prototype/Symbol.replace/result-get-groups-prop-err.js (previously Failed)

@raskad raskad mentioned this pull request Jul 24, 2021
8 tasks
@HalidOdat HalidOdat merged commit a7ebfc8 into boa-dev:master Jul 27, 2021
@raskad raskad deleted the regexp-named-capture-groups branch August 14, 2021 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builtins PRs and Issues related to builtins/intrinsics enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants