From ec6ba3622014e0f622f92a31326f5f82bdc703ac Mon Sep 17 00:00:00 2001 From: Yura Dupyn <2153100+omedusyo@users.noreply.github.com> Date: Sat, 25 Apr 2026 11:17:47 +0200 Subject: [PATCH] Renaming --- src/index.ts | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/index.ts b/src/index.ts index 4fe0547..1052ac6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -21,11 +21,11 @@ export const DIGIT_9: CodePoint = char('9'); export const DOT: CodePoint = char('.'); // Hex Boundaries -export const LOWERCASE_a: CodePoint = char('a'); +export const LOWERCASE_A: CodePoint = char('a'); export const UPPERCASE_A: CodePoint = char('A'); -export const LOWERCASE_f: CodePoint = char('f'); +export const LOWERCASE_F: CodePoint = char('f'); export const UPPERCASE_F: CodePoint = char('F'); -export const LOWERCASE_z: CodePoint = char('z'); +export const LOWERCASE_Z: CodePoint = char('z'); export const UPPERCASE_Z: CodePoint = char('Z'); // === Predicates === @@ -39,7 +39,7 @@ export function isDigit(x: CodePoint): boolean { } export function isAsciiAlpha(x: CodePoint): boolean { - return isBetween(LOWERCASE_a, x, LOWERCASE_z) + return isBetween(LOWERCASE_A, x, LOWERCASE_Z) || isBetween(UPPERCASE_A, x, UPPERCASE_Z); } @@ -69,6 +69,12 @@ export type CodePointSpan = { } // === Source Text === +// TODO: +// @deprecated and say to use `SourceText.makeFromString` instead. +export function sourceText(s: string): SourceText { + return SourceText.makeFromString(s); +} + export class SourceText { readonly source: string; // TODO: Later you can try to change this to two `Uint32Array`s - one for codepoints (each 20 bit but whatever), the other for pointers to original string. @@ -77,6 +83,10 @@ export class SourceText { // Stores the CodePointIndex where each line begins readonly lineStarts: CodePointIndex[]; + static makeFromString(s: string): SourceText { + return new SourceText(s); + } + constructor(rawSource: string) { // TODO: This shouldn't really be a concern of the library. // const source = rawSource.normalize('NFC'); @@ -265,10 +275,6 @@ export class SourceText { } } -export function sourceText(s: string): SourceText { - return new SourceText(s); -} - // Creates a Span from two SourceLocations. export function span(start: SourceLocation, end: SourceLocation): Span { return { start, end };