Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
bracketExpression: function(skip){
skip = skip || 0;
var start = this.input[skip];
assert(start === '(' || start === '{' || start === '[',
'The start character should be "(", "{" or "["');
var end = characterParser.BRACKETS[start];
var range;
try {
range = characterParser.parseUntil(this.input, end, {start: skip + 1});
} catch (ex) {
if (ex.index !== undefined) {
var idx = ex.index;
// starting from this.input[skip]
var tmp = this.input.substr(skip).indexOf('\n');
// starting from this.input[0]
var nextNewline = tmp + skip;
var ptr = 0;
while (idx > nextNewline && tmp !== -1) {
this.incrementLine(1);
idx -= nextNewline + 1;
ptr += nextNewline + 1;
tmp = nextNewline = this.input.substr(ptr).indexOf('\n');
};
this.incrementColumn(idx);
bracketExpression: function(skip){
skip = skip || 0;
var start = this.input[skip];
assert(start === '(' || start === '{' || start === '[',
'The start character should be "(", "{" or "["');
var end = characterParser.BRACKETS[start];
var range;
try {
range = characterParser.parseUntil(this.input, end, {start: skip + 1});
} catch (ex) {
if (ex.index !== undefined) {
var idx = ex.index;
// starting from this.input[skip]
var tmp = this.input.substr(skip).indexOf('\n');
// starting from this.input[0]
var nextNewline = tmp + skip;
var ptr = 0;
while (idx > nextNewline && tmp !== -1) {
this.incrementLine(1);
idx -= nextNewline + 1;
ptr += nextNewline + 1;
tmp = nextNewline = this.input.substr(ptr).indexOf('\n');
};
this.incrementColumn(idx);
bracketExpression: function(skip){
skip = skip || 0;
var start = this.input[skip];
assert(start === '(' || start === '{' || start === '[',
'The start character should be "(", "{" or "["');
var end = characterParser.BRACKETS[start];
var range;
try {
range = characterParser.parseUntil(this.input, end, {start: skip + 1});
} catch (ex) {
if (ex.index !== undefined) {
var idx = ex.index;
// starting from this.input[skip]
var tmp = this.input.substr(skip).indexOf('\n');
// starting from this.input[0]
var nextNewline = tmp + skip;
var ptr = 0;
while (idx > nextNewline && tmp !== -1) {
this.incrementLine(1);
idx -= nextNewline + 1;
ptr += nextNewline + 1;
tmp = nextNewline = this.input.substr(ptr).indexOf('\n');
};
this.incrementColumn(idx);
code: function() {
var captures;
if (captures = /^(!?=|-)[ \t]*([^\n]+)/.exec(this.input)) {
var flags = captures[1];
var code = captures[2];
var shortened = 0;
if (this.interpolated) {
var parsed;
try {
parsed = characterParser.parseUntil(code, ']');
} catch (err) {
if (err.index !== undefined) {
this.incrementColumn(captures[0].length - code.length + err.index);
}
if (err.code === 'CHARACTER_PARSER:END_OF_STRING_REACHED') {
this.error('NO_END_BRACKET', 'End of line was reached with no closing bracket for interpolation.');
} else if (err.code === 'CHARACTER_PARSER:MISMATCHED_BRACKET') {
this.error('BRACKET_MISMATCH', err.message);
} else {
throw err;
}
}
shortened = code.length - parsed.end;
code = parsed.src;
}
var consumed = captures[0].length - shortened;
return this.addText(type, value.substring(indexOfStringInterp + 3), prefix, escaped + 1);
}
var before = value.substr(0, indexOfStringInterp);
if (prefix || before) {
before = prefix + before;
tok = this.tok(type, before);
this.incrementColumn(before.length + escaped);
this.tokens.push(this.tokEnd(tok));
}
var rest = matchOfStringInterp[3];
var range;
tok = this.tok('interpolated-code');
this.incrementColumn(2);
try {
range = characterParser.parseUntil(rest, '}');
} catch (ex) {
if (ex.index !== undefined) {
this.incrementColumn(ex.index);
}
if (ex.code === 'CHARACTER_PARSER:END_OF_STRING_REACHED') {
this.error('NO_END_BRACKET', 'End of line was reached with no closing bracket for interpolation.');
} else if (ex.code === 'CHARACTER_PARSER:MISMATCHED_BRACKET') {
this.error('BRACKET_MISMATCH', ex.message);
} else {
throw ex;
}
}
tok.mustEscape = matchOfStringInterp[2] === '#';
tok.buffer = true;
tok.val = range.src;
this.assertExpression(range.src);
prefix = prefix + value.substring(0, indexOfStringInterp) + '#{';
return this.addText(type, value.substring(indexOfStringInterp + 3), prefix);
}
var before = value.substr(0, indexOfStringInterp);
if (prefix || before) {
before = prefix + before;
this.tokens.push(this.tok(type, before));
this.incrementColumn(before.length);
}
var rest = matchOfStringInterp[3];
var range;
var tok = this.tok('interpolated-code');
this.incrementColumn(2);
try {
range = characterParser.parseUntil(rest, '}');
} catch (ex) {
if (ex.index !== undefined) {
this.incrementColumn(ex.index);
}
if (ex.code === 'CHARACTER_PARSER:END_OF_STRING_REACHED') {
this.error('NO_END_BRACKET', 'End of line was reached with no closing bracket for interpolation.');
} else if (ex.code === 'CHARACTER_PARSER:MISMATCHED_BRACKET') {
this.error('BRACKET_MISMATCH', ex.message);
} else {
throw ex;
}
}
tok.mustEscape = matchOfStringInterp[2] === '#';
tok.buffer = true;
tok.val = range.src;
this.assertExpression(range.src);
code: function() {
var captures;
if (captures = /^(!?=|-)[ \t]*([^\n]+)/.exec(this.input)) {
var flags = captures[1];
var code = captures[2];
var shortened = 0;
if (this.interpolated) {
var parsed;
try {
parsed = characterParser.parseUntil(code, ']');
} catch (err) {
if (err.index !== undefined) {
this.incrementColumn(captures[0].length - code.length + err.index);
}
if (err.code === 'CHARACTER_PARSER:END_OF_STRING_REACHED') {
this.error('NO_END_BRACKET', 'End of line was reached with no closing bracket for interpolation.');
} else if (err.code === 'CHARACTER_PARSER:MISMATCHED_BRACKET') {
this.error('BRACKET_MISMATCH', err.message);
} else {
throw err;
}
}
shortened = code.length - parsed.end;
code = parsed.src;
}
var consumed = captures[0].length - shortened;
code: function() {
var captures;
if (captures = /^(!?=|-)[ \t]*([^\n]+)/.exec(this.input)) {
var flags = captures[1];
var code = captures[2];
var shortened = 0;
if (this.interpolated) {
var parsed;
try {
parsed = characterParser.parseUntil(code, ']');
} catch (err) {
if (err.index !== undefined) {
this.incrementColumn(captures[0].length - code.length + err.index);
}
if (err.code === 'CHARACTER_PARSER:END_OF_STRING_REACHED') {
this.error('NO_END_BRACKET', 'End of line was reached with no closing bracket for interpolation.');
} else if (err.code === 'CHARACTER_PARSER:MISMATCHED_BRACKET') {
this.error('BRACKET_MISMATCH', err.message);
} else {
throw err;
}
}
shortened = code.length - parsed.end;
code = parsed.src;
}
var consumed = captures[0].length - shortened;
return this.addText(type, value.substring(indexOfStringInterp + 3), prefix, escaped + 1);
}
var before = value.substr(0, indexOfStringInterp);
if (prefix || before) {
before = prefix + before;
tok = this.tok(type, before);
this.incrementColumn(before.length + escaped);
this.tokens.push(this.tokEnd(tok));
}
var rest = matchOfStringInterp[3];
var range;
tok = this.tok('interpolated-code');
this.incrementColumn(2);
try {
range = characterParser.parseUntil(rest, '}');
} catch (ex) {
if (ex.index !== undefined) {
this.incrementColumn(ex.index);
}
if (ex.code === 'CHARACTER_PARSER:END_OF_STRING_REACHED') {
this.error('NO_END_BRACKET', 'End of line was reached with no closing bracket for interpolation.');
} else if (ex.code === 'CHARACTER_PARSER:MISMATCHED_BRACKET') {
this.error('BRACKET_MISMATCH', ex.message);
} else {
throw ex;
}
}
tok.mustEscape = matchOfStringInterp[2] === '#';
tok.buffer = true;
tok.val = range.src;
this.assertExpression(range.src);