@montajs/compiler
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -106,2 +106,6 @@ "use strict"; | ||
} | ||
if (next === `'` || next === `"`) { | ||
currentSection.content += collectString(source, next); | ||
continue; | ||
} | ||
currentSection.content += next; | ||
@@ -111,2 +115,13 @@ } | ||
} | ||
function collectString(source, delimiter) { | ||
let value = delimiter; | ||
while (source.hasNext()) { | ||
let next = source.next(); | ||
value += next; | ||
if (next === delimiter && source.peekBack(2) !== '\\') { | ||
return value; | ||
} | ||
} | ||
throw new Error(`Unexpected end of file, expected: ${delimiter}`); | ||
} | ||
/** | ||
@@ -113,0 +128,0 @@ * Gets the name of a block in plain text |
@@ -79,3 +79,3 @@ "use strict"; | ||
exports.tokenise = tokenise; | ||
function getStringLiteral(source, quote) { | ||
function getStringLiteral(source, delimiter) { | ||
let { line, col } = source; | ||
@@ -85,3 +85,8 @@ let value = ''; | ||
let next = source.next(); | ||
if (next === quote && source.peekBack() !== '\\') { | ||
if (next === '\\' && source.peekMatch(delimiter)) { | ||
value += delimiter; | ||
source.skip(); | ||
continue; | ||
} | ||
if (next === delimiter) { | ||
return { | ||
@@ -96,3 +101,3 @@ type: "T_LIT" /* Literal */, | ||
} | ||
throw new Error(`Unexpected end of string, expected: ${quote}`); | ||
throw new Error(`Unexpected end of string, expected: ${delimiter}`); | ||
} | ||
@@ -99,0 +104,0 @@ function getNumberLiteral(source, start) { |
@@ -10,3 +10,3 @@ { | ||
"bugs": "https://github.com/montajs/compiler/issues", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"main": "dist/index.js", | ||
@@ -13,0 +13,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
142826
155
2042