diff --git a/runtime/JavaScript/src/antlr4/Utils.js b/runtime/JavaScript/src/antlr4/Utils.js index d7627be60..2cb939a66 100644 --- a/runtime/JavaScript/src/antlr4/Utils.js +++ b/runtime/JavaScript/src/antlr4/Utils.js @@ -401,11 +401,11 @@ DoubleDict.prototype.set = function (a, b, o) { function escapeWhitespace(s, escapeSpaces) { - s = s.replace("\t", "\\t"); - s = s.replace("\n", "\\n"); - s = s.replace("\r", "\\r"); + s = s.replace(/\t/g, "\\t") + .replace(/\n/g, "\\n") + .replace(/\r/g, "\\r"); if (escapeSpaces) { - s = s.replace(" ", "\u00B7"); + s = s.replace(/ /g, "\u00B7"); } return s; } @@ -443,4 +443,4 @@ exports.hashStuff = hashStuff; exports.escapeWhitespace = escapeWhitespace; exports.arrayToString = arrayToString; exports.titleCase = titleCase; -exports.equalArrays = equalArrays; \ No newline at end of file +exports.equalArrays = equalArrays; diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/JavaScript/JavaScript.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/JavaScript/JavaScript.stg index fb5883c02..6981ec03f 100644 --- a/tool/resources/org/antlr/v4/tool/templates/codegen/JavaScript/JavaScript.stg +++ b/tool/resources/org/antlr/v4/tool/templates/codegen/JavaScript/JavaScript.stg @@ -160,6 +160,7 @@ Object.defineProperty(.prototype, "atn", { }); .EOF = antlr4.Token.EOF; +.prototype.EOF = antlr4.Token.EOF; . = ;}; separator="\n", wrap, anchor> @@ -802,6 +803,9 @@ var antlr4 = require('antlr4/index'); >> Lexer(lexer, atn, actionFuncs, sempredFuncs, superClass) ::= << + +var = require('./').; + @@ -819,14 +823,18 @@ function (input) { .prototype.constructor = ; .EOF = antlr4.Token.EOF; +.prototype.EOF = antlr4.Token.EOF; . = ;}; separator="\n", wrap, anchor> +.prototype. = ;}; separator="\n", wrap, anchor> . = ;}; separator="\n"> +.prototype. = ;}; separator="\n"> . = ;}; separator="\n"> +.prototype. = ;}; separator="\n"> .prototype.channelNames = [ "DEFAULT_TOKEN_CHANNEL", "HIDDEN", "}; separator=", ", wrap, anchor> ];