module /** */ import { ParsingState } from "../state" ; import { ResultKind } from "../result" ; import { ParjserBase } from "../parser" ; import { Parjser } from "../parjser" ; param strs export function anyStringOf ( ... strs ) { return new class StringOf extends ParjserBase { type = "anyStringOf" ; expecting = `expecting any of ${ strs . map ( x => `'${ x }'` ) . join ( ", " ) }` ; _apply ( ps ) { let { position , input } = ps ; for ( let i = 0 ; i < strs . length ; i ++ ) { let curStr = strs [ i ] ; if ( input . length - position < curStr . length ) continue ; let curSubstr = input . slice ( position , position + curStr . length ) ; if ( curSubstr === curStr ) { ps . position = position + curStr . length ; ps . value = curStr ; ps . kind = ResultKind . Ok ; return ; } } ps . kind = ResultKind . SoftFail ; } } ( ) ; }