src/reactTemplates.js
function parseScopeSyntax(text) {
    // the regex below was built using the following pseudo-code:
    // double_quoted_string = `"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"`
    // single_quoted_string = `'[^'\\\\]*(?:\\\\.[^'\\\\]*)*'`
    // text_out_of_quotes = `[^"']*?`
    // expr_parts = double_quoted_string + "|" + single_quoted_string + "|" + text_out_of_quotes
    // expression = zeroOrMore(nonCapture(expr_parts)) + "?"
    // id = "[$_a-zA-Z]+[$_a-zA-Z0-9]*"
    // as = " as" + OneOrMore(" ")
    // optional_spaces = zeroOrMore(" ")
    // semicolon = nonCapture(or(text(";"), "$"))
    //
    // regex = capture(expression) + as + capture(id) + optional_spaces + semicolon + optional_spaces

    const regex = RegExp("((?:(?:\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"|'[^'\\\\]*(?:\\\\.[^'\\\\]*)*'|[^\"']*?))*?) as(?: )+([$_a-zA-Z]+[$_a-zA-Z0-9]*)(?: )*(?:;|$)(?: )*", 'g')
    const res = []
    do {
        const idx = regex.lastIndex
        const match = regex.exec(text)
        if (regex.lastIndex === idx || match === null) {
            throw text.substr(idx)
        }
        if (match.index === regex.lastIndex) {
            regex.lastIndex++
        }
        res.push({expression: match[1].trim(), identifier: match[2]})
    } while (regex.lastIndex < text.length)

    return res
}
function parseScopeSyntax(text) {
    // the regex below was built using the following pseudo-code:
    // double_quoted_string = `"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"`
    // single_quoted_string = `'[^'\\\\]*(?:\\\\.[^'\\\\]*)*'`
    // text_out_of_quotes = `[^"']*?`
    // expr_parts = double_quoted_string + "|" + single_quoted_string + "|" + text_out_of_quotes
    // expression = zeroOrMore(nonCapture(expr_parts)) + "?"
    // id = "[$_a-zA-Z]+[$_a-zA-Z0-9]*"
    // as = " as" + OneOrMore(" ")
    // optional_spaces = zeroOrMore(" ")
    // semicolon = nonCapture(or(text(";"), "$"))
    //
    // regex = capture(expression) + as + capture(id) + optional_spaces + semicolon + optional_spaces

    const regex = RegExp("((?:(?:\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"|'[^'\\\\]*(?:\\\\.[^'\\\\]*)*'|[^\"']*?))*?) as(?: )+([$_a-zA-Z]+[$_a-zA-Z0-9]*)(?: )*(?:;|$)(?: )*", 'g')
    const res = []
    do {
        const idx = regex.lastIndex
        const match = regex.exec(text)
        if (regex.lastIndex === idx || match === null) {
            throw text.substr(idx)
        }
        if (match.index === regex.lastIndex) {
            regex.lastIndex++
        }
        res.push({expression: match[1].trim(), identifier: match[2]})
    } while (regex.lastIndex < text.length)

    return res
}
function parseScopeSyntax ( text ) { // the regex below was built using the following pseudo-code: // double_quoted_string = `"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"` // single_quoted_string = `'[^'\\\\]*(?:\\\\.[^'\\\\]*)*'` // text_out_of_quotes = `[^"']*?` // expr_parts = double_quoted_string + "|" + single_quoted_string + "|" + text_out_of_quotes // expression = zeroOrMore(nonCapture(expr_parts)) + "?" // id = "[$_a-zA-Z]+[$_a-zA-Z0-9]*" // as = " as" + OneOrMore(" ") // optional_spaces = zeroOrMore(" ") // semicolon = nonCapture(or(text(";"), "$")) // // regex = capture(expression) + as + capture(id) + optional_spaces + semicolon + optional_spaces const regex = RegExp ( "((?:(?:\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"|'[^'\\\\]*(?:\\\\.[^'\\\\]*)*'|[^\"']*?))*?) as(?: )+([$_a-zA-Z]+[$_a-zA-Z0-9]*)(?: )*(?:;|$)(?: )*" , 'g' ) const res = [ ] do { const idx = regex . lastIndex const match = regex . exec ( text ) if ( regex . lastIndex === idx || match === null ) { throw text . substr ( idx ) } if ( match . index === regex . lastIndex ) { regex . lastIndex ++ } res . push ( { expression : match [ 1 ] . trim ( ) , identifier : match [ 2 ] } ) } while ( regex . lastIndex < text . length ) return res }
Parses the rt-scope attribute returning an array of parsed sections

@param {String} scope The scope attribute to parse
@returns {Array} an array of {expression,identifier}
@throws {String} the part of the string that failed to parse
Parses the rt - scope attribute returning an array of parsed sections