(text: string)
| 1 | /** |
| 2 | * Reserved prefix for parser-generated parameter names. |
| 3 | * |
| 4 | * A **literal parameter** in an Epsil function definition (`function f(0) = |
| 5 | * 1`, `f("yes") = …`) lowers to an anonymous value-typed parameter |
| 6 | * `["Typed", "literalParam_1", {str: "0"}]` — the name is generated (1-based |
| 7 | * parameter position), never written by the author, and the body cannot |
| 8 | * reference it. The prefix is reserved: diagnostic and serialization |
| 9 | * surfaces render such a parameter by its value type alone (`f(0)`), so the |
| 10 | * generated name never surfaces. (`_` is NOT used for these: it collides |
| 11 | * with the wildcard/implicit-parameter conventions, and repeated literal |
| 12 | * parameters would collide with each other.) |
| 13 | */ |
| 14 | export const LITERAL_PARAM_PREFIX = 'literalParam_'; |
| 15 | |
| 16 | /** Whether a symbol is a parser-generated literal-parameter name (reserved |
| 17 | * prefix — see {@link LITERAL_PARAM_PREFIX}). */ |
| 18 | export function isLiteralParamName(s: string): boolean { |
| 19 | return s.startsWith(LITERAL_PARAM_PREFIX); |
| 20 | } |
| 21 | |
| 22 | let recommendedScriptsRegex: RegExp; |
| 23 | |
| 24 | function isRecommendedScripts(text: string): boolean { |
| 25 | if (!recommendedScriptsRegex) { |
| 26 | // Define the recommended script property notation from UAX#31Table 5 |
| 27 | // https://www.unicode.org/reports/tr31/#Table_Recommended_Scripts |
| 28 | const recommendedScripts = [ |
| 29 | 'Zyyy', |
| 30 | 'Zinh', |
| 31 | 'Arab', |
| 32 | 'Armn', |
| 33 | 'Beng', |
| 34 | 'Bopo', |
| 35 | 'Cyrl', |
| 36 | 'Deva', |
| 37 | 'Ethi', |
| 38 | 'Geor', |
| 39 | 'Grek', |
| 40 | 'Gujr', |
| 41 | 'Guru', |
| 42 | 'Hang', |
| 43 | 'Hani', |
| 44 | 'Hebr', |
| 45 | 'Hira', |
| 46 | 'Kana', |
| 47 | 'Knda', |
| 48 | 'Khmr', |
| 49 | 'Laoo', |
| 50 | 'Latn', |
| 51 | 'Mlym', |
| 52 | 'Mymr', |
| 53 | 'Orya', |
| 54 | 'Sinh', |
no test coverage detected