Skip to content

Commit eb073a5

Browse files
committed
remove quotation
1 parent 2a9447b commit eb073a5

File tree

8 files changed

+16
-90
lines changed

8 files changed

+16
-90
lines changed

src/parser/ast.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ export type Modifier =
2222
| Readonly<{ type: "default"; word: WordUnit }>
2323
| Readonly<{ type: "proper words"; words: string }>
2424
| Readonly<{ type: "pi"; phrase: Phrase }>
25-
| (Readonly<{ type: "nanpa" }> & Nanpa)
26-
| (Readonly<{ type: "quotation" }> & Quotation);
25+
| (Readonly<{ type: "nanpa" }> & Nanpa);
2726
export type Phrase =
2827
| Readonly<{
2928
type: "default";
@@ -38,8 +37,7 @@ export type Phrase =
3837
phrase: Phrase;
3938
emphasis: null | Emphasis;
4039
}>
41-
| (Readonly<{ type: "preposition" }> & Preposition)
42-
| (Readonly<{ type: "quotation" }> & Quotation);
40+
| (Readonly<{ type: "preposition" }> & Preposition);
4341
export type MultiplePhrases =
4442
| Readonly<{ type: "single"; phrase: Phrase }>
4543
| Readonly<{
@@ -77,8 +75,9 @@ export type Clause =
7775
subjects: null | MultiplePhrases;
7876
predicates: Predicate;
7977
}>
80-
| Readonly<{ type: "prepositions"; prepositions: ReadonlyArray<Preposition> }>
81-
| (Readonly<{ type: "quotation" }> & Quotation);
78+
| Readonly<
79+
{ type: "prepositions"; prepositions: ReadonlyArray<Preposition> }
80+
>;
8281
export type ContextClause =
8382
| Clause
8483
| (Readonly<{ type: "nanpa" }> & Nanpa);

src/parser/composer.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ export function modifier(modifier: Modifier): string {
6868
return `pi ${phrase(modifier.phrase)}`;
6969
case "nanpa":
7070
return nanpa(modifier);
71-
case "quotation":
72-
return quotation(modifier);
7371
}
7472
}
7573
export function phrase(value: Phrase): string {
@@ -91,8 +89,6 @@ export function phrase(value: Phrase): string {
9189
.join(" ");
9290
case "preposition":
9391
return preposition(value);
94-
case "quotation":
95-
return quotation(value);
9692
}
9793
}
9894
function particle(type: "and conjunction" | "anu", particle: string): string {
@@ -175,8 +171,6 @@ export function clause(clause: Clause): string {
175171
.join(" ");
176172
case "prepositions":
177173
return clause.prepositions.map(preposition).join(" ");
178-
case "quotation":
179-
throw new Error();
180174
}
181175
}
182176
export function contextClause(contextClause: ContextClause): string {

src/parser/extract.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export function everyWordUnitInModifier(
2525
return everyWordUnitInPhrase(modifier.phrase);
2626
case "nanpa":
2727
return everyWordUnitInNanpa(modifier);
28-
case "quotation":
2928
case "proper words":
3029
return [];
3130
}
@@ -45,8 +44,6 @@ export function everyWordUnitInPhrase(phrase: Phrase): ReadonlyArray<WordUnit> {
4544
];
4645
case "preposition":
4746
return everyWordUnitInPreposition(phrase);
48-
case "quotation":
49-
return [];
5047
}
5148
}
5249
export function everyWordUnitInMultiplePhrases(
@@ -99,8 +96,6 @@ export function everyWordUnitInClause(clause: Clause): ReadonlyArray<WordUnit> {
9996
];
10097
case "prepositions":
10198
return clause.prepositions.flatMap(everyWordUnitInPreposition);
102-
case "quotation":
103-
return [];
10499
}
105100
}
106101
export function everyWordUnitInContextClause(
@@ -142,8 +137,6 @@ export function everyModifierInPhrase(phrase: Phrase): ReadonlyArray<Modifier> {
142137
...phrase.modifiers,
143138
...everyModifierInMultiplePhrases(phrase.phrases),
144139
];
145-
case "quotation":
146-
return [];
147140
}
148141
}
149142
export function everyModifierInMultiplePhrases(

src/parser/filter.ts

Lines changed: 10 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ export const NANPA_RULES: ReadonlyArray<(nanpa: Nanpa) => boolean> = [
4242
modifier.phrase.type !== "preverb" ||
4343
throwError(new UnrecognizedError("preverb inside nanpa")),
4444

45-
// nanpa construction cannot contain quotation
46-
(modifier) =>
47-
modifier.phrase.type !== "quotation" ||
48-
throwError(new UnrecognizedError("quotation inside nanpa")),
49-
5045
// nanpa construction cannot contain pi
5146
(modifier) =>
5247
modifier.phrase.type !== "default" ||
@@ -60,24 +55,9 @@ export const NANPA_RULES: ReadonlyArray<(nanpa: Nanpa) => boolean> = [
6055
throwError(new UnrecognizedError("nanpa inside nanpa")),
6156

6257
// nanpa cannot have emphasis particle
63-
(modifier) => {
64-
const { phrase } = modifier;
65-
switch (phrase.type) {
66-
case "preposition":
67-
case "preverb":
68-
case "default":
69-
return phrase.emphasis == null;
70-
case "quotation":
71-
return true;
72-
}
73-
},
58+
(modifier) => modifier.phrase.emphasis == null,
7459
];
7560
export const MODIFIER_RULES: ReadonlyArray<(modifier: Modifier) => boolean> = [
76-
// quotation modifier cannot exist
77-
(modifier) =>
78-
modifier.type !== "quotation" ||
79-
throwError(new UnrecognizedError("quotation as modifier")),
80-
8161
// pi cannot contain preposition
8262
(modifier) =>
8363
modifier.type !== "pi" || modifier.phrase.type !== "preposition" ||
@@ -99,8 +79,6 @@ export const MODIFIER_RULES: ReadonlyArray<(modifier: Modifier) => boolean> = [
9979
// switch (modifier.type) {
10080
// case "default":
10181
// case "proper words":
102-
// case "quotation":
103-
// return false;
10482
// case "nanpa":
10583
// return everyModifierInPhrase(modifier.phrase).some(checker);
10684
// case "pi":
@@ -116,21 +94,7 @@ export const MODIFIER_RULES: ReadonlyArray<(modifier: Modifier) => boolean> = [
11694
// },
11795

11896
// pi cannot have emphasis particle
119-
(modifier) => {
120-
if (modifier.type === "pi") {
121-
const { phrase } = modifier;
122-
switch (phrase.type) {
123-
case "default":
124-
case "preposition":
125-
case "preverb":
126-
return phrase.emphasis == null;
127-
case "quotation":
128-
return true;
129-
}
130-
} else {
131-
return true;
132-
}
133-
},
97+
(modifier) => modifier.type !== "pi" || modifier.phrase.emphasis == null,
13498
];
13599
export const MULTIPLE_MODIFIERS_RULES: ReadonlyArray<
136100
(modifier: ReadonlyArray<Modifier>) => boolean
@@ -179,7 +143,6 @@ export const MULTIPLE_MODIFIERS_RULES: ReadonlyArray<
179143
} else {
180144
return [];
181145
}
182-
case "quotation":
183146
case "proper words":
184147
case "nanpa":
185148
return [];
@@ -195,11 +158,6 @@ export const MULTIPLE_MODIFIERS_RULES: ReadonlyArray<
195158
},
196159
];
197160
export const PHRASE_RULE: ReadonlyArray<(phrase: Phrase) => boolean> = [
198-
// Disallow quotation
199-
(phrase) =>
200-
phrase.type !== "quotation" ||
201-
throwError(new UnrecognizedError("quotation as phrase")),
202-
203161
// Disallow preverb modifiers other than "ala"
204162
(phrase) =>
205163
phrase.type !== "preverb" || modifiersIsAlaOrNone(phrase.modifiers) ||
@@ -227,21 +185,14 @@ export const PHRASE_RULE: ReadonlyArray<(phrase: Phrase) => boolean> = [
227185

228186
// Emphasis must not be nested
229187
(phrase) => {
230-
switch (phrase.type) {
231-
case "preposition":
232-
case "preverb":
233-
case "default":
234-
if (
235-
phrase.emphasis == null ||
236-
everyWordUnitInPhrase(phrase)
237-
.every((wordUnit) => wordUnit.emphasis == null)
238-
) {
239-
return true;
240-
} else {
241-
throw new UnrecognizedError("nested emphasis");
242-
}
243-
case "quotation":
244-
return true;
188+
if (
189+
phrase.emphasis == null ||
190+
everyWordUnitInPhrase(phrase)
191+
.every((wordUnit) => wordUnit.emphasis == null)
192+
) {
193+
return true;
194+
} else {
195+
throw new UnrecognizedError("nested emphasis");
245196
}
246197
},
247198
];
@@ -294,7 +245,6 @@ export const CLAUSE_RULE: ReadonlyArray<(clause: Clause) => boolean> = [
294245
}
295246
break;
296247
case "prepositions":
297-
case "quotation":
298248
return true;
299249
}
300250
if (
@@ -458,8 +408,6 @@ function hasPrepositionInPhrase(phrase: Phrase): boolean {
458408
return true;
459409
case "preverb":
460410
return hasPrepositionInPhrase(phrase.phrase);
461-
case "quotation":
462-
return false;
463411
}
464412
}
465413
function phraseHasTopLevelEmphasis(phrase: Phrase): boolean {
@@ -468,7 +416,5 @@ function phraseHasTopLevelEmphasis(phrase: Phrase): boolean {
468416
case "preverb":
469417
case "preposition":
470418
return phrase.emphasis != null;
471-
case "quotation":
472-
return false;
473419
}
474420
}

src/parser/parser.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -574,9 +574,7 @@ const clause = choice<Clause>(
574574
prepositions,
575575
})),
576576
subjectPhrases
577-
.filter((phrases) =>
578-
phrases.type !== "single" || phrases.phrase.type !== "quotation"
579-
)
577+
.filter((phrases) => phrases.type !== "single")
580578
.map((phrases) => ({ type: "phrases", phrases })),
581579
subjectPhrases
582580
.skip(specificWord("o"))

src/translator/clause.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ export function clause(clause: TokiPona.Clause): ArrayResult<English.Clause> {
119119
return liClause(clause);
120120
case "prepositions":
121121
case "o clause":
122-
case "quotation":
123122
return new ArrayResult(new TranslationTodoError(clause.type));
124123
}
125124
}

src/translator/modifier.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,6 @@ function modifier(
217217
return piModifier(modifier.phrase);
218218
case "nanpa":
219219
return nanpaModifier(modifier);
220-
case "quotation":
221-
return new ArrayResult(new TranslationTodoError(modifier.type));
222220
}
223221
}
224222
export function multipleModifiers(

src/translator/phrase.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ export function phrase(
219219
return defaultPhrase({ ...options, phrase });
220220
case "preverb":
221221
case "preposition":
222-
case "quotation":
223222
return new ArrayResult(new TranslationTodoError(phrase.type));
224223
}
225224
}

0 commit comments

Comments
 (0)