Skip to content

Commit ace91f0

Browse files
committed
implement composer for vocative and dependent clause
1 parent 66a8b36 commit ace91f0

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/composer.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ function adjective(phrases: AdjectivePhrase, depth: number): string {
7676
function preposition(preposition: Preposition): string {
7777
return `${word(preposition.preposition)} ${noun(preposition.object, 0)}`;
7878
}
79-
function clause(clause: Clause): string {
80-
switch (clause.type) {
79+
function clause(ast: Clause): string {
80+
switch (ast.type) {
8181
case "free form":
82-
return clause.text;
82+
return ast.text;
8383
case "interjection":
84-
return word(clause.interjection);
84+
return word(ast.interjection);
8585
case "implied it's": {
86-
const verb = clause.verb;
86+
const verb = ast.verb;
8787
let text: string;
8888
switch (verb.type) {
8989
case "linking noun":
@@ -96,9 +96,13 @@ function clause(clause: Clause): string {
9696
return [text!, ...verb.preposition.map(preposition)].join(" ");
9797
}
9898
case "subject phrase":
99-
return noun(clause.subject, 0);
99+
return noun(ast.subject, 0);
100+
case "vocative":
101+
return `${ast.call} ${noun(ast.addressee, 0)}`;
102+
case "dependent":
103+
return `${ast.conjunction} ${clause(ast.clause)}`;
100104
default:
101-
throw new TodoError(`composing ${clause.type}`);
105+
throw new TodoError(`composing ${ast.type}`);
102106
}
103107
}
104108
function sentence(sentence: Sentence): string {

0 commit comments

Comments
 (0)