File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed
Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 1818
1919import matchPropertyValue from 'unicode-match-property-value-ecmascript' ;
2020
21+ import matchPropertyValueMappings from 'unicode-match-property-value-ecmascript/data/mappings' ;
22+
2123import matchProperty from 'unicode-match-property-ecmascript' ;
2224
2325import propertyAliases from 'unicode-property-aliases-ecmascript' ;
@@ -472,9 +474,26 @@ const acceptUnicodePropertyValue = state => {
472474 return { matched : characters . length > 0 , data : characters . join ( '' ) } ;
473475} ;
474476
477+ // excluding nonbinary properties from mathias' list
478+ // https://www.ecma-international.org/ecma-262/9.0/index.html#table-nonbinary-unicode-properties
479+ const illegalLoneUnicodePropertyNames = [
480+ 'General_Category' ,
481+ 'Script' ,
482+ 'Script_Extensions' ,
483+ 'scx' ,
484+ 'sc' ,
485+ 'gc' ,
486+ ] ;
487+
488+ const generalCategoryValues = matchPropertyValueMappings . get ( 'General_Category' ) ;
489+
475490const acceptLoneUnicodePropertyNameOrValue = state => {
476491 let loneValue = acceptUnicodePropertyValue ( state ) ;
477- return { matched : loneValue . matched && catchIsFalse ( ( ) => matchProperty ( loneValue . data ) ) } ;
492+ if ( ! loneValue . matched || illegalLoneUnicodePropertyNames . includes ( loneValue . data ) ) {
493+ return { matched : false } ;
494+ }
495+
496+ return { matched : catchIsFalse ( ( ) => matchProperty ( loneValue . data ) ) || generalCategoryValues . get ( loneValue . data ) != null } ;
478497} ;
479498
480499const acceptUnicodePropertyValueExpression = state =>
Original file line number Diff line number Diff line change @@ -177,6 +177,9 @@ suite('Parser', () => {
177177 /\p{General_Category=LC}/u
178178 /\p{General_Category=Cased_Letter}/u
179179 /\P{gc=LC}/u
180+ /\P{LC}/u
181+ /\p{Other_Number}/u
182+ /\p{No}/u
180183 /\k/
181184 /\k</
182185 /\k<x/
@@ -233,7 +236,10 @@ suite('Parser', () => {
233236 /(?<a>a)\k/
234237 /(?<a>a)\k</
235238 /(?<a>a)\k<a/
236- /(?<a>a)\k<x>/` ) ;
239+ /(?<a>a)\k<x>/
240+ /\p{Script_Extensions}/u
241+ /\p{Ahom}/u
242+ /\p{gc}/u` ) ;
237243 regexToPass . forEach ( args => testRegexSuccess ( ...args ) ) ;
238244 regexToFail . forEach ( args => testRegexFailure ( ...args ) ) ;
239245 } ) ;
You can’t perform that action at this time.
0 commit comments