File tree Expand file tree Collapse file tree 3 files changed +25
-33
lines changed
Expand file tree Collapse file tree 3 files changed +25
-33
lines changed Original file line number Diff line number Diff line change @@ -322,13 +322,10 @@ const definition = choiceOnlyOne<Definition>(
322322 adjective . skip ( keyword ( "and" ) ) . skip ( tag ( keyword ( "c" ) ) ) ,
323323 adjective ,
324324 )
325- . filter ( ( [ first , second ] ) => {
326- if ( first . adverb . length === 0 && second . adverb . length === 0 ) {
327- return true ;
328- } else {
329- throw new ArrayResultError ( "compound adjective cannot have adverb" ) ;
330- }
331- } )
325+ . filter ( ( [ first , second ] ) =>
326+ ( first . adverb . length === 0 && second . adverb . length === 0 ) ||
327+ throwError ( new ArrayResultError ( "compound adjective cannot have adverb" ) )
328+ )
332329 . skip ( semicolon )
333330 . map ( ( adjective ) => ( { type : "compound adjective" , adjective } ) ) ,
334331 noun
Original file line number Diff line number Diff line change @@ -193,17 +193,11 @@ export const PHRASE_RULE: ReadonlyArray<(phrase: Phrase) => boolean> = [
193193 ! phraseHasTopLevelEmphasis ( phrase . phrase ) ,
194194
195195 // Emphasis must not be nested
196- ( phrase ) => {
197- if (
198- phrase . emphasis == null ||
199- everyWordUnitInPhrase ( phrase )
200- . every ( ( { emphasis } ) => emphasis == null )
201- ) {
202- return true ;
203- } else {
204- throw new UnrecognizedError ( "nested emphasis" ) ;
205- }
206- } ,
196+ ( phrase ) =>
197+ phrase . emphasis == null ||
198+ everyWordUnitInPhrase ( phrase )
199+ . every ( ( { emphasis } ) => emphasis == null ) ||
200+ throwError ( new UnrecognizedError ( "nested emphasis" ) ) ,
207201] ;
208202export const PREPOSITION_RULE : ReadonlyArray < ( phrase : Preposition ) => boolean > =
209203 [
Original file line number Diff line number Diff line change 1+ import { throwError } from "../../misc/misc.ts" ;
12import { ArrayResult } from "../array_result.ts" ;
23import * as TokiPona from "../parser/ast.ts" ;
34import * as English from "./ast.ts" ;
@@ -13,18 +14,19 @@ export function nanpa(
1314 includeGerund : true ,
1415 includeVerb : false ,
1516 } )
16- . map ( ( phrase ) => {
17- if ( phrase . type !== "noun" ) {
18- throw new FilteredError (
19- `${ phrase . type } within "position X" phrase` ,
20- ) ;
21- } else if (
22- ( phrase . noun as English . NounPhrase & { type : "simple" } )
23- . preposition . length > 0
24- ) {
25- throw new FilteredError ( 'preposition within "position X" phrase' ) ;
26- } else {
27- return {
17+ . map ( ( phrase ) =>
18+ phrase . type !== "noun"
19+ ? throwError (
20+ new FilteredError (
21+ `${ phrase . type } within "position X" phrase` ,
22+ ) ,
23+ )
24+ : ( phrase . noun as English . NounPhrase & { type : "simple" } )
25+ . preposition . length > 0
26+ ? throwError (
27+ new FilteredError ( 'preposition within "position X" phrase' ) ,
28+ )
29+ : {
2830 type : "simple" ,
2931 determiner : [ ] ,
3032 adjective : [ ] ,
@@ -38,7 +40,6 @@ export function nanpa(
3840 postAdjective : null ,
3941 preposition : [ ] ,
4042 emphasis : false ,
41- } ;
42- }
43- } ) ;
43+ }
44+ ) ;
4445}
You can’t perform that action at this time.
0 commit comments