File tree Expand file tree Collapse file tree 7 files changed +28
-17
lines changed
Expand file tree Collapse file tree 7 files changed +28
-17
lines changed Original file line number Diff line number Diff line change @@ -80,11 +80,12 @@ export type Clause =
8080 > ;
8181export type ContextClause =
8282 | Clause
83- | ( Readonly < { type : "nanpa" } > & Nanpa ) ;
83+ | ( Readonly < { type : "nanpa" } > & Nanpa )
84+ | ( Readonly < { type : "anu" ; anu : HeadedWordUnit } > ) ;
8485export type Sentence =
8586 | Readonly < {
8687 type : "default" ;
87- kinOrTaso : null | HeadedWordUnit ;
88+ startingParticle : null | HeadedWordUnit ;
8889 laClauses : ReadonlyArray < ContextClause > ;
8990 finalClause : Clause ;
9091 anuSeme : null | HeadedWordUnit ;
Original file line number Diff line number Diff line change @@ -176,6 +176,8 @@ export function contextClause(contextClause: ContextClause): string {
176176 switch ( contextClause . type ) {
177177 case "nanpa" :
178178 return nanpa ( contextClause ) ;
179+ case "anu" :
180+ return wordUnit ( contextClause . anu ) ;
179181 default :
180182 return clause ( contextClause ) ;
181183 }
@@ -185,7 +187,7 @@ export function sentence(sentence: Sentence): string {
185187 switch ( sentence . type ) {
186188 case "default" :
187189 text = [
188- ...nullableAsArray ( sentence . kinOrTaso ) . map ( wordUnit ) ,
190+ ...nullableAsArray ( sentence . startingParticle ) . map ( wordUnit ) ,
189191 ...sentence . laClauses
190192 . map ( contextClause )
191193 . map ( ( clause ) => `${ clause } la` ) ,
Original file line number Diff line number Diff line change @@ -104,6 +104,8 @@ export function everyWordUnitInContextClause(
104104 switch ( contextClause . type ) {
105105 case "nanpa" :
106106 return everyWordUnitInNanpa ( contextClause ) ;
107+ case "anu" :
108+ return [ contextClause . anu ] ;
107109 default :
108110 return everyWordUnitInClause ( contextClause ) ;
109111 }
@@ -114,7 +116,7 @@ export function everyWordUnitInSentence(
114116 switch ( sentence . type ) {
115117 case "default" :
116118 return [
117- ...nullableAsArray ( sentence . kinOrTaso ) ,
119+ ...nullableAsArray ( sentence . startingParticle ) ,
118120 ...sentence . laClauses . flatMap ( everyWordUnitInContextClause ) ,
119121 ...everyWordUnitInClause ( sentence . finalClause ) ,
120122 ...nullableAsArray ( sentence . anuSeme ) ,
Original file line number Diff line number Diff line change @@ -301,20 +301,21 @@ export const SENTENCE_RULE: ReadonlyArray<(sentence: Sentence) => boolean> = [
301301 ( sentence ) => {
302302 if ( sentence . type === "default" ) {
303303 if (
304- sentence . kinOrTaso != null && sentence . kinOrTaso . type === "x ala x"
304+ sentence . startingParticle != null &&
305+ sentence . startingParticle . type === "x ala x"
305306 ) {
306- const { kinOrTaso : { word } } = sentence ;
307+ const { startingParticle : { word } } = sentence ;
307308 throw new UnrecognizedError ( `"${ word } ala ${ word } "` ) ;
308309 }
309310 }
310311 return true ;
311312 } ,
312- // If there is "la", there can't be "taso" or "kin"
313+ // If there is "la", there can't be starting particle e.g. taso
313314 ( sentence ) =>
314315 sentence . type !== "default" || sentence . laClauses . length === 0 ||
315- sentence . kinOrTaso == null || throwError (
316+ sentence . startingParticle == null || throwError (
316317 new UnrecognizedError (
317- `${ sentence . kinOrTaso . word } particle with "la"` ,
318+ `${ sentence . startingParticle . word } particle with "la"` ,
318319 ) ,
319320 ) ,
320321
Original file line number Diff line number Diff line change @@ -605,6 +605,7 @@ const clause = choice<Clause>(
605605 . filter ( filter ( CLAUSE_RULE ) ) ;
606606const contextClause = choice < ContextClause > (
607607 nanpa . map ( ( nanpa ) => ( { ...nanpa , type : "nanpa" } ) ) ,
608+ wordUnit ( new Set ( [ "anu" ] ) , '"anu"' ) . map ( ( anu ) => ( { type : "anu" , anu } ) ) ,
608609 clause ,
609610) ;
610611const la = choice (
@@ -652,7 +653,8 @@ const anuSeme = choice(
652653const sentence = choice < Sentence > (
653654 sequence (
654655 optional (
655- wordUnit ( new Set ( [ "kin" , "taso" ] ) , "taso/kin" ) . skip ( optionalComma ) ,
656+ wordUnit ( new Set ( [ "taso" , "kin" , "anu" ] ) , "taso/kin/anu" )
657+ . skip ( optionalComma ) ,
656658 ) ,
657659 many ( contextClause . skip ( la ) ) ,
658660 clause ,
@@ -668,7 +670,7 @@ const sentence = choice<Sentence>(
668670 . map < Sentence & { type : "default" } > (
669671 (
670672 [
671- kinOrTaso ,
673+ startingParticle ,
672674 laClauses ,
673675 finalClause ,
674676 anuSeme ,
@@ -678,7 +680,7 @@ const sentence = choice<Sentence>(
678680 ) => {
679681 const sentence : Sentence & { type : "default" } = {
680682 type : "default" ,
681- kinOrTaso ,
683+ startingParticle ,
682684 laClauses,
683685 finalClause,
684686 anuSeme,
Original file line number Diff line number Diff line change @@ -209,7 +209,10 @@ export function contextClause(
209209) : ArrayResult < English . Clause > {
210210 switch ( contextClause . type ) {
211211 case "nanpa" :
212- return new ArrayResult ( new TranslationTodoError ( "nanpa context clause" ) ) ;
212+ case "anu" :
213+ return new ArrayResult (
214+ new TranslationTodoError ( `${ contextClause . type } context clause` ) ,
215+ ) ;
213216 default :
214217 return clause ( contextClause ) ;
215218 }
Original file line number Diff line number Diff line change @@ -144,18 +144,18 @@ function sentence(
144144 clause,
145145 } ) )
146146 ) ;
147- if ( sentence . kinOrTaso != null ) {
147+ if ( sentence . startingParticle != null ) {
148148 return new ArrayResult (
149149 new TranslationTodoError (
150- `"${ sentence . kinOrTaso . word } " starting particle` ,
150+ `"${ sentence . startingParticle . word } " starting particle` ,
151151 ) ,
152152 ) ;
153153 }
154154 const lastEngClause = clause ( sentence . finalClause ) ;
155155 const right = nullableAsArray ( sentence . anuSeme ) . map ( anuSeme ) ;
156156 const interjectionClause =
157- sentence . laClauses . length === 0 && sentence . kinOrTaso == null &&
158- sentence . kinOrTaso == null
157+ sentence . laClauses . length === 0 && sentence . startingParticle == null &&
158+ sentence . startingParticle == null
159159 ? interjection ( sentence . finalClause )
160160 : new ArrayResult < English . Clause > ( ) ;
161161 const engClauses = ArrayResult . combine (
You can’t perform that action at this time.
0 commit comments