module /** */ import { ParsingState } from "../state" ; import { ResultKind } from "../result" ; import { ParjserBase } from "../parser" ; import { Parjser } from "../parjser" ; param str export function string ( str ) { return new class ParseString extends ParjserBase { expecting = `expecting '${ str }'` ; type = "string" ; _apply ( ps ) { let { position , input } = ps ; let i ; if ( position + str . length > input . length ) { ps . kind = ResultKind . SoftFail ; return ; } let substr = input . slice ( position , position + str . length ) ; if ( substr !== str ) { ps . kind = ResultKind . SoftFail ; return ; } ps . position += str . length ; ps . value = str ; ps . kind = ResultKind . Ok ; } } ( ) ; }