lib/Language/Helpers/parseParentheses.js
function createLiterallyObjects(query, openPos, stringPositions) {
    const firstRaw = query.substr(0, openPos)
    const result = [firstRaw.trim()]
    let pointer = 0

    stringPositions.forEach((stringPosition) => {
        if (!stringPosition.end) {
            throw new SyntaxException('Invalid string ending found.')
        }

        if (stringPosition.end < firstRaw.length) {
            // At least one string exists in first part, create a new object.

            // Remove the last part, since this wasn't parsed.
            result.pop()

            // Add part between pointer and string occurrence.
            result.push(firstRaw.substr(pointer, stringPosition.start - pointer).trim())

            // Add the string as object.
            result.push(new Literally(firstRaw.substr(
                stringPosition.start + 1,
                stringPosition.end - stringPosition.start
            )))

            result.push(firstRaw.substr(stringPosition.end + 2).trim())

            pointer = stringPosition.end + 2
        }
    })

    return result
}
function createLiterallyObjects(query, openPos, stringPositions) {
    const firstRaw = query.substr(0, openPos)
    const result = [firstRaw.trim()]
    let pointer = 0

    stringPositions.forEach((stringPosition) => {
        if (!stringPosition.end) {
            throw new SyntaxException('Invalid string ending found.')
        }

        if (stringPosition.end < firstRaw.length) {
            // At least one string exists in first part, create a new object.

            // Remove the last part, since this wasn't parsed.
            result.pop()

            // Add part between pointer and string occurrence.
            result.push(firstRaw.substr(pointer, stringPosition.start - pointer).trim())

            // Add the string as object.
            result.push(new Literally(firstRaw.substr(
                stringPosition.start + 1,
                stringPosition.end - stringPosition.start
            )))

            result.push(firstRaw.substr(stringPosition.end + 2).trim())

            pointer = stringPosition.end + 2
        }
    })

    return result
}
function createLiterallyObjects ( query , openPos , stringPositions ) { const firstRaw = query . substr ( 0 , openPos ) const result = [ firstRaw . trim ( ) ] let pointer = 0 stringPositions . forEach ( ( stringPosition ) => { if ( ! stringPosition . end ) { throw new SyntaxException ( 'Invalid string ending found.' ) } if ( stringPosition . end < firstRaw . length ) { // At least one string exists in first part, create a new object. // Remove the last part, since this wasn't parsed. result . pop ( ) // Add part between pointer and string occurrence. result . push ( firstRaw . substr ( pointer , stringPosition . start - pointer ) . trim ( ) ) // Add the string as object. result . push ( new Literally ( firstRaw . substr ( stringPosition . start + 1 , stringPosition . end - stringPosition . start ) ) ) result . push ( firstRaw . substr ( stringPosition . end + 2 ) . trim ( ) ) pointer = stringPosition . end + 2 } } ) return result }
Replace all "literal strings" with a Literally object to simplify parsing later on.

@param  {string} string
@param  {number} openPos
@param  {array} stringPositions
@return {array}
@throws {SyntaxException}
Replace all literal strings with a Literally object to simplify parsing later on .