import type { ParseState , IReader } from "../api.js" ; class StringReader implements IReader < string > { constructor ( protected _src ) { } read ( state ) { return this . _src [ state . p ] ; } next ( state ) { if ( state . done ) return ; state . last = this . _src [ state . p ] ; if ( state . last === "\n" ) { state . l ++ ; state . c = 1 ; } else { state . c ++ ; } state . done = ++ state . p >= this . _src . length ; } isDone ( state ) { return ( state . done = state . p >= this . _src . length ) ; } format ( state ) { return `offset ${ state . p } (${ state . l }:${ state . c })` ; } } export const defStringReader = ( input ) => new StringReader ( input ) ;