diff --git a/lib/compiler/passes/generate-js.js b/lib/compiler/passes/generate-js.js index 4c80939..4b9124d 100644 --- a/lib/compiler/passes/generate-js.js +++ b/lib/compiler/passes/generate-js.js @@ -6,9 +6,10 @@ let op = require("../opcodes"); // Generates parser JavaScript code. function generateJS(ast, options) { - // These only indent non-empty lines to avoid trailing whitespace. - function indent2(code) { return code.replace(/^(.+)$/gm, " $1"); } - function indent10(code) { return code.replace(/^(.+)$/gm, " $1"); } + /* These only indent non-empty lines to avoid trailing whitespace. */ + const lineMatchRE = /^([^`\r\n]+?(?:`[^`]*?`[^\r\n]*?)?)$/gm; + function indent2(code) { return code.replace(lineMatchRE, " $1"); } + function indent10(code) { return code.replace(lineMatchRE, " $1"); } function generateTables() { if (options.optimize === "size") {