Skip to content

Commit c745daa

Browse files
committed
refactor
1 parent 9cc2907 commit c745daa

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

dictionary/parser.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -258,25 +258,25 @@ const checkedNoun = new CheckedParser(
258258
noun,
259259
);
260260
function checkedSimpleUnitWith<T>(
261-
tag: Parser<unknown>,
261+
tag: string,
262262
after: Parser<T>,
263263
): CheckedParser<readonly [string, T]> {
264264
return checkedSequence(
265-
word.skip(openParenthesis).skip(tag),
265+
word.skip(openParenthesis).skip(keyword(tag)),
266266
closeParenthesis.with(after),
267267
);
268268
}
269-
function checkedSimpleUnit(tag: Parser<unknown>): CheckedParser<string> {
269+
function checkedSimpleUnit(tag: string): CheckedParser<string> {
270270
return checkedSimpleUnitWith(tag, nothing).map(([word]) => word);
271271
}
272272
function checkedSimpleUnitWithTemplate(
273-
tag: Parser<unknown>,
273+
tag: string,
274274
templateInside: Parser<unknown>,
275275
): CheckedParser<string> {
276276
return checkedSimpleUnitWith(tag, template(templateInside))
277277
.map(([word]) => word);
278278
}
279-
const interjectionDefinition = checkedSimpleUnit(keyword("i"))
279+
const interjectionDefinition = checkedSimpleUnit("i")
280280
.map((interjection) => ({ type: "interjection", interjection }) as const);
281281
const particleDefinition = checkedSequence(
282282
word.skip(openParenthesis).skip(keyword("particle")),
@@ -285,14 +285,14 @@ const particleDefinition = checkedSequence(
285285
.map(([definition]) =>
286286
({ type: "particle definition", definition }) as const
287287
);
288-
const adverbDefinition = checkedSimpleUnit(keyword("adv"))
288+
const adverbDefinition = checkedSimpleUnit("adv")
289289
.map((adverb) => ({ type: "adverb", adverb }) as const);
290290
const prepositionDefinition = checkedSimpleUnitWithTemplate(
291-
keyword("prep"),
291+
"prep",
292292
sequence(keyword("indirect"), keyword("object")),
293293
)
294294
.map((preposition) => ({ type: "preposition", preposition }) as const);
295-
const numeralDefinition = checkedSimpleUnit(keyword("num"))
295+
const numeralDefinition = checkedSimpleUnit("num")
296296
.mapWithPositionedError((num) => {
297297
const numeral = Number.parseInt(num);
298298
if (Number.isNaN(numeral)) {
@@ -397,7 +397,7 @@ const nounDefinition = new CheckedParser(
397397
sequence(
398398
noun,
399399
optionalWithCheck(
400-
checkedSimpleUnitWithTemplate(keyword("prep"), keyword("headword")),
400+
checkedSimpleUnitWithTemplate("prep", keyword("headword")),
401401
),
402402
),
403403
)
@@ -433,7 +433,7 @@ const verbDefinition = checkedSequence(
433433
sequence(closeParenthesis, openBracket, keyword("object")),
434434
closeBracket
435435
.with(optionalWithCheck(
436-
checkedSimpleUnitWith(keyword("prep"), noun)
436+
checkedSimpleUnitWith("prep", noun)
437437
.map(([preposition, object]) => ({ preposition, object }) as const),
438438
))
439439
.map(nullableAsArray),
@@ -478,7 +478,7 @@ const verbDefinition = checkedSequence(
478478
),
479479
optionalWithCheck(
480480
checkedSimpleUnitWith(
481-
keyword("prep"),
481+
"prep",
482482
choiceWithCheck<"template" | Noun>(
483483
checkedSequence(
484484
openBracket,

0 commit comments

Comments
 (0)