src/emitter.js: Sync |escape| in generated parsers with utils.js

Fixes the following JSHint errors:

  ./src/parser.js: line 102, col 26, 'escapeChar' is already defined.
  ./src/parser.js: line 103, col 22, 'length' is already defined.
  ./src/parser.js: line 106, col 23, 'escapeChar' used out of scope.
  ./src/parser.js: line 106, col 86, 'length' used out of scope.
redux
David Majda 13 years ago
parent e0ef7e1abb
commit 559db3a812

@ -141,13 +141,15 @@ PEG.compiler.emitter = function(ast) {
/* This needs to be in sync with |escape| in utils.js. */
" function escape(ch) {",
" var charCode = ch.charCodeAt(0);",
" var escapeChar;",
" var length;",
" ",
" if (charCode <= 0xFF) {",
" var escapeChar = 'x';",
" var length = 2;",
" escapeChar = 'x';",
" length = 2;",
" } else {",
" var escapeChar = 'u';",
" var length = 4;",
" escapeChar = 'u';",
" length = 4;",
" }",
" ",
" return '\\\\' + escapeChar + padLeft(charCode.toString(16).toUpperCase(), '0', length);",

@ -94,13 +94,15 @@ PEG.parser = (function(){
function escape(ch) {
var charCode = ch.charCodeAt(0);
var escapeChar;
var length;
if (charCode <= 0xFF) {
var escapeChar = 'x';
var length = 2;
escapeChar = 'x';
length = 2;
} else {
var escapeChar = 'u';
var length = 4;
escapeChar = 'u';
length = 4;
}
return '\\' + escapeChar + padLeft(charCode.toString(16).toUpperCase(), '0', length);

Loading…
Cancel
Save