-
Notifications
You must be signed in to change notification settings - Fork 886
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX: Support some missing Unicode properties.
- Loading branch information
Showing
6 changed files
with
71 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// This file was generated by "bin/generate-unicode-script-values.js". Do not modify manually! | ||
export default "Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
"use strict" | ||
|
||
const fs = require("fs") | ||
const path = require("path") | ||
|
||
import("../acorn/src/unicode-property-data.js") | ||
.then(m => { | ||
return m.default[13].nonBinary.Script | ||
}) | ||
.then(async(reScriptValuesAddedInES) => { | ||
const scriptValues = new Set() | ||
for await (const value of getLatestUnicodeScriptValues()) { | ||
scriptValues.add(value) | ||
} | ||
const scriptValuesAddedInUnicode = "export default " + | ||
JSON.stringify( | ||
[...scriptValues] | ||
// The unicode script values now follow the Unicode spec as of ES2023, | ||
// but prior to ES2022 they were listed in the ES2022 spec. | ||
// The generated file lists all the unicode script values except those listed before ES2022. | ||
.filter(value => !reScriptValuesAddedInES.test(value)) | ||
.sort() | ||
.join(" ") | ||
) | ||
|
||
writeGeneratedFile("scriptValuesAddedInUnicode", scriptValuesAddedInUnicode) | ||
|
||
console.log("Done. The generated files must be committed.") | ||
}) | ||
|
||
function writeGeneratedFile(filename, content) { | ||
const comment = "// This file was generated by \"bin/" + path.basename(__filename) + "\". Do not modify manually!" | ||
fs.writeFileSync(path.resolve("./acorn/src/generated", filename + ".js"), comment + "\n" + content + "\n", "utf8") | ||
} | ||
|
||
/** | ||
* Gets the all unicode script values from the latest PropertyValueAliases. | ||
*/ | ||
async function * getLatestUnicodeScriptValues() { | ||
const response = await fetch("https://unicode.org/Public/UCD/latest/ucd/PropertyValueAliases.txt") | ||
const lines = (await response.text()).split("\n") | ||
for (const line of lines) { | ||
if (!line || line.startsWith("#")) { | ||
continue | ||
} | ||
const [propertyAlias, alias, canonical, ...remaining] = line | ||
.split("#")[0] // strip comments | ||
.split(";") // split by semicolon | ||
.map((x) => x.trim()) // trim | ||
|
||
if (propertyAlias !== "sc") { | ||
continue | ||
} | ||
|
||
yield canonical | ||
yield alias | ||
yield * remaining | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,4 @@ | ||
built-ins/RegExp/property-escapes/generated/Script_-_Garay.js (default) | ||
built-ins/RegExp/property-escapes/generated/Script_-_Garay.js (strict mode) | ||
built-ins/RegExp/property-escapes/generated/Script_-_Gurung_Khema.js (default) | ||
built-ins/RegExp/property-escapes/generated/Script_-_Gurung_Khema.js (strict mode) | ||
built-ins/RegExp/property-escapes/generated/Script_-_Kirat_Rai.js (default) | ||
built-ins/RegExp/property-escapes/generated/Script_-_Kirat_Rai.js (strict mode) | ||
built-ins/RegExp/property-escapes/generated/Script_-_Ol_Onal.js (default) | ||
built-ins/RegExp/property-escapes/generated/Script_-_Ol_Onal.js (strict mode) | ||
built-ins/RegExp/property-escapes/generated/Script_-_Sunuwar.js (default) | ||
built-ins/RegExp/property-escapes/generated/Script_-_Sunuwar.js (strict mode) | ||
built-ins/RegExp/property-escapes/generated/Script_-_Todhri.js (default) | ||
built-ins/RegExp/property-escapes/generated/Script_-_Todhri.js (strict mode) | ||
built-ins/RegExp/property-escapes/generated/Script_-_Tulu_Tigalari.js (default) | ||
built-ins/RegExp/property-escapes/generated/Script_-_Tulu_Tigalari.js (strict mode) | ||
built-ins/RegExp/property-escapes/generated/Script_Extensions_-_Garay.js (default) | ||
built-ins/RegExp/property-escapes/generated/Script_Extensions_-_Garay.js (strict mode) | ||
built-ins/RegExp/property-escapes/generated/Script_Extensions_-_Gurung_Khema.js (default) | ||
built-ins/RegExp/property-escapes/generated/Script_Extensions_-_Gurung_Khema.js (strict mode) | ||
built-ins/RegExp/property-escapes/generated/Script_Extensions_-_Kirat_Rai.js (default) | ||
built-ins/RegExp/property-escapes/generated/Script_Extensions_-_Kirat_Rai.js (strict mode) | ||
built-ins/RegExp/property-escapes/generated/Script_Extensions_-_Ol_Onal.js (default) | ||
built-ins/RegExp/property-escapes/generated/Script_Extensions_-_Ol_Onal.js (strict mode) | ||
built-ins/RegExp/property-escapes/generated/Script_Extensions_-_Sunuwar.js (default) | ||
built-ins/RegExp/property-escapes/generated/Script_Extensions_-_Sunuwar.js (strict mode) | ||
built-ins/RegExp/property-escapes/generated/Script_Extensions_-_Todhri.js (default) | ||
built-ins/RegExp/property-escapes/generated/Script_Extensions_-_Todhri.js (strict mode) | ||
built-ins/RegExp/property-escapes/generated/Script_Extensions_-_Tulu_Tigalari.js (default) | ||
built-ins/RegExp/property-escapes/generated/Script_Extensions_-_Tulu_Tigalari.js (strict mode) | ||
language/import/import-attributes/json-invalid.js (default) | ||
language/import/import-attributes/json-invalid.js (strict mode) | ||
language/import/import-attributes/json-named-bindings.js (default) | ||
language/import/import-attributes/json-named-bindings.js (strict mode) | ||
language/import/import-attributes/json-invalid.js (default) | ||
language/import/import-attributes/json-invalid.js (strict mode) | ||
language/import/import-attributes/json-named-bindings.js (default) | ||
language/import/import-attributes/json-named-bindings.js (strict mode) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters