lib/parse.js
function readSimpleToken(type, endRegex, trimRight) {
		if (trimRight) {
			let matchTrim = exec(/\S/g)
			if (matchTrim) {
				advanceTo(matchTrim.index)
			}
		}
		let match = exec(endRegex)
		if (!match) {
			throwSyntaxError(`Unterminated ${type}`)
		}
		let start = getSourcePoint()
		advanceTo(match.index)
		let token = createContentToken(type, start)
		advanceTo(endRegex.lastIndex)
		return token
	}
function readSimpleToken(type, endRegex, trimRight) {
		if (trimRight) {
			let matchTrim = exec(/\S/g)
			if (matchTrim) {
				advanceTo(matchTrim.index)
			}
		}
		let match = exec(endRegex)
		if (!match) {
			throwSyntaxError(`Unterminated ${type}`)
		}
		let start = getSourcePoint()
		advanceTo(match.index)
		let token = createContentToken(type, start)
		advanceTo(endRegex.lastIndex)
		return token
	}
function readSimpleToken ( type , endRegex , trimRight ) { if ( trimRight ) { let matchTrim = exec ( / \S / g ) if ( matchTrim ) { advanceTo ( matchTrim . index ) } } let match = exec ( endRegex ) if ( ! match ) { throwSyntaxError ( ` ${ type } ` ) } let start = getSourcePoint ( ) advanceTo ( match . index ) let token = createContentToken ( type , start ) advanceTo ( endRegex . lastIndex ) return token }
Read a single token that has a known end
@param {string} type
@param {RegExp} endRegex
@param {boolean} trimRight - ignore starting empty spaces (\s)
@returns {Token}
Read a single token that has a known end