Skip to content

Commit 25cd00e

Browse files
committed
rename
1 parent 4da33c4 commit 25cd00e

File tree

10 files changed

+51
-54
lines changed

10 files changed

+51
-54
lines changed

dictionary/parser.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ import {
3434
IndirectObject,
3535
Noun,
3636
NounForms,
37-
PartialVerb,
3837
PostAdjective,
38+
VerbAccessory,
3939
} from "./type.ts";
4040

4141
const RESERVED_SYMBOLS = "#()*+/:;<=>@[\\]^`{|}~";
@@ -459,7 +459,7 @@ const verbDefinition = checkedSequence(
459459
))
460460
.map(nullableAsArray),
461461
)
462-
.map(([_, indirectObjects]): null | PartialVerb => ({
462+
.map(([_, indirectObjects]): null | VerbAccessory => ({
463463
directObject: null,
464464
indirectObjects,
465465
forObject: true,
@@ -469,7 +469,7 @@ const verbDefinition = checkedSequence(
469469
sequence(closeParenthesis, openBracket, keyword("predicate")),
470470
closeBracket,
471471
)
472-
.map((): null | PartialVerb => ({
472+
.map((): null | VerbAccessory => ({
473473
directObject: null,
474474
indirectObjects: [],
475475
forObject: false,
@@ -479,12 +479,12 @@ const verbDefinition = checkedSequence(
479479
keyword("modal"),
480480
sequence(closeParenthesis, template(keyword("predicate"))),
481481
)
482-
.map((): null | PartialVerb => null),
482+
.map((): null | VerbAccessory => null),
483483
checkedSequence(
484484
keyword("linking"),
485485
sequence(closeParenthesis, template(keyword("predicate"))),
486486
)
487-
.map((): null | PartialVerb => ({
487+
.map((): null | VerbAccessory => ({
488488
directObject: null,
489489
indirectObjects: [],
490490
forObject: false,
@@ -509,7 +509,7 @@ const verbDefinition = checkedSequence(
509509
),
510510
),
511511
)
512-
.map(([_, [directObject, rawIndirectObject]]): PartialVerb => {
512+
.map(([_, [directObject, rawIndirectObject]]): VerbAccessory => {
513513
if (rawIndirectObject == null) {
514514
return {
515515
directObject,

dictionary/type.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ export type IndirectObject = Readonly<{
6464
preposition: string;
6565
object: Noun;
6666
}>;
67-
export type PartialVerb = Readonly<{
67+
export type VerbAccessory = Readonly<{
6868
directObject: null | Noun;
6969
indirectObjects: ReadonlyArray<IndirectObject>;
7070
forObject: boolean | string;
7171
predicateType: null | "verb" | "noun adjective";
7272
}>;
73-
export type Verb = VerbForms & PartialVerb;
73+
export type Verb = VerbForms & VerbAccessory;
7474
export type Definition =
7575
| Readonly<{ type: "filler"; before: string; repeat: string; after: string }>
7676
| Readonly<{ type: "particle definition"; definition: string }>

src/parser/parser_lib.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ import { MemoizationCacheResult, memoize } from "@std/cache/memoize";
33
import { lazy as lazyEval } from "../../misc/misc.ts";
44
import { ArrayResult, ResultError } from "../compound.ts";
55

6-
type SingleResult<T> = Readonly<{ value: T; length: number }>;
7-
type ParserResult<T> = ArrayResult<SingleResult<T>>;
8-
type InnerParser<T> = (input: number) => ParserResult<T>;
6+
type ValueLength<T> = Readonly<{ value: T; length: number }>;
7+
type ParserResult<T> = ArrayResult<ValueLength<T>>;
8+
type RawParser<T> = (input: number) => ParserResult<T>;
99
type Cache<T> = Map<number, MemoizationCacheResult<ParserResult<T>>>;
1010

1111
let currentSource = "";
1212
const allCache: Set<WeakRef<Cache<unknown>>> = new Set();
1313

1414
export class Parser<T> {
15-
readonly rawParser: InnerParser<T>;
16-
constructor(parser: InnerParser<T>) {
15+
readonly rawParser: RawParser<T>;
16+
constructor(parser: RawParser<T>) {
1717
const cache: Cache<T> = new Map();
1818
allCache.add(new WeakRef(cache));
19-
this.rawParser = memoize<InnerParser<T>, number, Cache<T>>(
19+
this.rawParser = memoize<RawParser<T>, number, Cache<T>>(
2020
parser,
2121
{ cache },
2222
);
@@ -36,7 +36,7 @@ export class Parser<T> {
3636
map<U>(mapper: (value: T) => U): Parser<U> {
3737
return new Parser((input) =>
3838
this.rawParser(input)
39-
.map(({ value, length }): SingleResult<U> => ({
39+
.map(({ value, length }): ValueLength<U> => ({
4040
value: mapper(value),
4141
length,
4242
}))
@@ -62,7 +62,7 @@ export class Parser<T> {
6262
.flatMap(({ value, length }) =>
6363
mapper(value)
6464
.rawParser(position + length)
65-
.map(({ value, length: addedLength }): SingleResult<U> => ({
65+
.map(({ value, length: addedLength }): ValueLength<U> => ({
6666
value,
6767
length: length + addedLength,
6868
}))
@@ -131,7 +131,7 @@ export const emptyArray: Parser<ReadonlyArray<never>> = nothing.map(() => []);
131131
export function lookAhead<T>(parser: Parser<T>): Parser<T> {
132132
return new Parser((input) =>
133133
parser.rawParser(input)
134-
.map(({ value }): SingleResult<T> => ({ value, length: 0 }))
134+
.map(({ value }): ValueLength<T> => ({ value, length: 0 }))
135135
);
136136
}
137137
export function lazy<T>(parser: () => Parser<T>): Parser<T> {
@@ -316,7 +316,7 @@ export type WithSource<T> = readonly [value: T, source: string];
316316
export function withSource<T>(parser: Parser<T>): Parser<WithSource<T>> {
317317
return new Parser((position) =>
318318
parser.rawParser(position).map(
319-
({ value, length }): SingleResult<WithSource<T>> => ({
319+
({ value, length }): ValueLength<WithSource<T>> => ({
320320
value: [
321321
value,
322322
currentSource.slice(position, position + length),
@@ -330,7 +330,7 @@ export type WithPosition<T> = Readonly<{ value: T }> & Position;
330330
export function withPosition<T>(parser: Parser<T>): Parser<WithPosition<T>> {
331331
return new Parser((position) =>
332332
parser.rawParser(position).map(
333-
({ value, length }): SingleResult<WithPosition<T>> => ({
333+
({ value, length }): ValueLength<WithPosition<T>> => ({
334334
value: { value, position, length },
335335
length,
336336
}),

src/settings.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
export type RedundancySettings = "both" | "condensed" | "default only";
1+
export type Redundancy = "both" | "condensed" | "default only";
22

33
// may be extended but existing properties must stay unchanged
44
export type Settings = {
55
teloMisikeke: boolean;
66
randomize: boolean;
77
multiline: boolean;
8-
quantity: RedundancySettings;
9-
tense: RedundancySettings;
8+
quantity: Redundancy;
9+
tense: Redundancy;
1010
xAlaXPartialParsing: boolean;
1111
separateRepeatedModifiers: boolean;
1212
hardcodedAnuLa: boolean;

src/settings_frontend.ts

+4-9
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22

33
import { toKebabCase } from "@std/text/to-kebab-case";
44
import { checkLocalStorage, setIgnoreError } from "./local_storage.ts";
5-
import {
6-
defaultSettings,
7-
RedundancySettings,
8-
Settings,
9-
settings,
10-
} from "./settings.ts";
5+
import { defaultSettings, Redundancy, Settings, settings } from "./settings.ts";
116

127
type Updater<T> = Readonly<{
138
parse: (value: string) => null | T;
@@ -32,13 +27,13 @@ const BOOL_UPDATER: Updater<boolean> = {
3227
(input as HTMLInputElement).checked = value;
3328
},
3429
};
35-
const REDUNDANCY_UPDATER: Updater<RedundancySettings> = {
30+
const REDUNDANCY_UPDATER: Updater<Redundancy> = {
3631
parse: (value) =>
3732
["both", "condensed", "default only"].includes(value)
38-
? value as RedundancySettings
33+
? value as Redundancy
3934
: null,
4035
stringify: (value) => value,
41-
load: ({ value }) => value as RedundancySettings,
36+
load: ({ value }) => value as Redundancy,
4237
set: (input, value) => {
4338
input.value = value;
4439
},

src/translator/ast.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,19 @@ export type Adverb = Readonly<{
5252
adverb: Word;
5353
negative: boolean;
5454
}>;
55-
export type AdverbVerb = {
55+
export type Verb = {
5656
preAdverbs: ReadonlyArray<Adverb>;
5757
verb: Word;
5858
postAdverb: null | Adverb;
5959
};
60-
export type Verb = Readonly<{
61-
modal: null | AdverbVerb;
62-
verbs: ReadonlyArray<AdverbVerb>;
60+
export type WholeVerb = Readonly<{
61+
modal: null | Verb;
62+
verbs: ReadonlyArray<Verb>;
6363
}>;
6464
export type VerbPhrase =
6565
| Readonly<{
6666
type: "simple";
67-
verb: Verb;
67+
verb: WholeVerb;
6868
subjectComplement: null | Complement;
6969
contentClause: null | Clause;
7070
object: null | NounPhrase;

src/translator/composer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function complement(complement: English.Complement) {
7171
return adjective(complement.adjective, 0);
7272
}
7373
}
74-
function adverbVerb(verbAdverb: English.AdverbVerb) {
74+
function singeVerb(verbAdverb: English.Verb) {
7575
const { preAdverbs, verb, postAdverb } = verbAdverb;
7676
const verbPost = verb.word === "can" && postAdverb != null &&
7777
postAdverb.adverb.word === "not"
@@ -95,7 +95,7 @@ export function verb(phrase: English.VerbPhrase, depth: number): string {
9595
...nullableAsArray(modal),
9696
...verbs,
9797
]
98-
.map(adverbVerb)
98+
.map(singeVerb)
9999
: [];
100100
text = [
101101
...verbText,

src/translator/fixer.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,16 @@ function fixComplement(complement: English.Complement): English.Complement {
181181
};
182182
}
183183
}
184-
function fixAdverbVerb(adverbVerb: English.AdverbVerb): English.AdverbVerb {
184+
function fixSingleVerb(adverbVerb: English.Verb): English.Verb {
185185
return {
186186
...adverbVerb,
187187
preAdverbs: fixMultipleAdverbs(adverbVerb.preAdverbs),
188188
};
189189
}
190-
function fixVerb(verb: English.Verb): English.Verb {
190+
function fixVerb(verb: English.WholeVerb): English.WholeVerb {
191191
return {
192-
modal: mapNullable(verb.modal, fixAdverbVerb),
193-
verbs: verb.verbs.map(fixAdverbVerb),
192+
modal: mapNullable(verb.modal, fixSingleVerb),
193+
verbs: verb.verbs.map(fixSingleVerb),
194194
};
195195
}
196196
function fixVerbPhrase(verb: English.VerbPhrase): English.VerbPhrase {

src/translator/noun.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ type NounQuantity = Readonly<{ noun: string; quantity: English.Quantity }>;
5454
export function fromNounForms(
5555
nounForms: Dictionary.NounForms,
5656
determinerNumber: Dictionary.Quantity,
57-
): IterableResult<{ noun: string; quantity: English.Quantity }> {
57+
): IterableResult<NounQuantity> {
5858
const { singular, plural } = nounForms;
5959
switch (determinerNumber) {
6060
case "singular":

src/translator/verb.ts

+13-11
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ export type VerbForms =
1818
reduplicationCount: number;
1919
emphasis: boolean;
2020
}>;
21-
export type VerbObjects = Readonly<{
21+
export type VerbAccessory = Readonly<{
2222
object: null | English.NounPhrase;
2323
objectComplement: null | English.Complement;
2424
prepositions: ReadonlyArray<English.Preposition>;
2525
}>;
2626
export type FirstVerb =
27-
| (Readonly<{ type: "modal" }> & English.AdverbVerb)
27+
| (Readonly<{ type: "modal" }> & English.Verb)
2828
| (Readonly<{ type: "conjugated" }> & VerbForms);
2929
export type PartialVerb =
30-
& VerbObjects
30+
& VerbAccessory
3131
& Readonly<{
3232
first: FirstVerb;
33-
rest: ReadonlyArray<English.AdverbVerb>;
33+
rest: ReadonlyArray<English.Verb>;
3434
subjectComplement: null | English.Complement;
3535
forObject: boolean | string;
3636
predicateType: null | "verb" | "noun adjective";
@@ -44,7 +44,7 @@ export type PartialCompoundVerb =
4444
conjunction: string;
4545
verbs: ReadonlyArray<PartialCompoundVerb>;
4646
}>
47-
& VerbObjects
47+
& VerbAccessory
4848
);
4949
function condenseVerb(present: string, past: string) {
5050
const [first, ...rest] = present.split(" ");
@@ -65,7 +65,7 @@ function addModal(
6565
throw new FilteredError("nested modal verb");
6666
case "conjugated": {
6767
const newRest = nullableAsArray(first)
68-
.map((first): English.AdverbVerb => {
68+
.map((first): English.Verb => {
6969
const { adverbs, presentPlural, negated } = first;
7070
const useVerb = presentPlural === "are" ? "be" : presentPlural;
7171
const preAdverbs = takeNegative ? adverbs : [
@@ -189,7 +189,7 @@ function fromVerbForms(
189189
verbForms: VerbForms,
190190
perspective: Dictionary.Perspective,
191191
quantity: English.Quantity,
192-
): IterableResult<English.Verb> {
192+
): IterableResult<English.WholeVerb> {
193193
const { negated, adverbs } = verbForms;
194194
const is = verbForms.presentSingular === "is";
195195
const presentSingular = is && perspective === "first"
@@ -203,8 +203,8 @@ function fromVerbForms(
203203
? [pastPlural, verbForms.presentPlural, "do"]
204204
: [pastSingular, presentSingular, "does"];
205205
type Result = Readonly<{
206-
modal: null | English.AdverbVerb;
207-
doesNot: null | English.AdverbVerb;
206+
modal: null | English.Verb;
207+
doesNot: null | English.Verb;
208208
verb: string;
209209
postAdverb: null | English.Adverb;
210210
}>;
@@ -344,7 +344,9 @@ function fromVerbForms(
344344
}
345345
break;
346346
}
347-
return result.map(({ modal, doesNot, verb, postAdverb }): English.Verb => ({
347+
return result.map((
348+
{ modal, doesNot, verb, postAdverb },
349+
): English.WholeVerb => ({
348350
modal,
349351
verbs: [
350352
...nullableAsArray(doesNot),
@@ -400,6 +402,6 @@ export function verb(
400402
}
401403
}
402404
}
403-
export function noAdverbs(verb: English.Word): English.AdverbVerb {
405+
export function noAdverbs(verb: English.Word): English.Verb {
404406
return { preAdverbs: [], verb, postAdverb: null };
405407
}

0 commit comments

Comments
 (0)