import { createErrorForUnclosedQuote } from "../../Error" ; import { createQuotedToken , QuotedToken } from "../Token" ; import { SeekProcessor } from "../LexerProcessor" ; const seekQuotedToken = ( context ) => { const quote = context . buffer . charAt ( context . position ) ; let endPosition = context . position ; while ( endPosition < context . length ) { endPosition = context . buffer . indexOf ( quote , endPosition + 1 ) ; if ( endPosition === - 1 ) { throw createErrorForUnclosedQuote ( context . position , context . buffer ) ; } let escaped = false ; for ( let scanPosition = endPosition - 1 ; context . buffer [ scanPosition ] === "\\" && scanPosition > context . position ; scanPosition -- ) { escaped = ! escaped ; } if ( ! escaped ) { break ; } } const value = context . buffer . substring ( context . position , endPosition + 1 ) ; const token = createQuotedToken ( value , context . position ) ; context . position = endPosition + 1 ; return token ; } ; export default seekQuotedToken ;