Renaming
This commit is contained in:
parent
9c72959cd3
commit
ec6ba36220
1 changed files with 14 additions and 8 deletions
22
src/index.ts
22
src/index.ts
|
|
@ -21,11 +21,11 @@ export const DIGIT_9: CodePoint = char('9');
|
||||||
export const DOT: CodePoint = char('.');
|
export const DOT: CodePoint = char('.');
|
||||||
|
|
||||||
// Hex Boundaries
|
// 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 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 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');
|
export const UPPERCASE_Z: CodePoint = char('Z');
|
||||||
|
|
||||||
// === Predicates ===
|
// === Predicates ===
|
||||||
|
|
@ -39,7 +39,7 @@ export function isDigit(x: CodePoint): boolean {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isAsciiAlpha(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);
|
|| isBetween(UPPERCASE_A, x, UPPERCASE_Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -69,6 +69,12 @@ export type CodePointSpan = {
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Source Text ===
|
// === Source Text ===
|
||||||
|
// TODO:
|
||||||
|
// @deprecated and say to use `SourceText.makeFromString` instead.
|
||||||
|
export function sourceText(s: string): SourceText {
|
||||||
|
return SourceText.makeFromString(s);
|
||||||
|
}
|
||||||
|
|
||||||
export class SourceText {
|
export class SourceText {
|
||||||
readonly source: string;
|
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.
|
// 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
|
// Stores the CodePointIndex where each line begins
|
||||||
readonly lineStarts: CodePointIndex[];
|
readonly lineStarts: CodePointIndex[];
|
||||||
|
|
||||||
|
static makeFromString(s: string): SourceText {
|
||||||
|
return new SourceText(s);
|
||||||
|
}
|
||||||
|
|
||||||
constructor(rawSource: string) {
|
constructor(rawSource: string) {
|
||||||
// TODO: This shouldn't really be a concern of the library.
|
// TODO: This shouldn't really be a concern of the library.
|
||||||
// const source = rawSource.normalize('NFC');
|
// 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.
|
// Creates a Span from two SourceLocations.
|
||||||
export function span(start: SourceLocation, end: SourceLocation): Span {
|
export function span(start: SourceLocation, end: SourceLocation): Span {
|
||||||
return { start, end };
|
return { start, end };
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue