'requires' SUPERclass for Lexers in split mode, symbols/modes/channels available on Lexer prototype for use in lexer actions (this.SOME_MODE) like in Java actions, Utils.escapeWhiteSpace uses regex for global replace (was replacing only first occurnce of \n etc).

This commit is contained in:
Venkat Peri 2017-07-22 18:11:37 -04:00
parent 2d6a4945a5
commit e01af374d2
2 changed files with 13 additions and 5 deletions

View File

@ -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;
exports.equalArrays = equalArrays;

View File

@ -160,6 +160,7 @@ Object.defineProperty(<parser.name>.prototype, "atn", {
});
<parser.name>.EOF = antlr4.Token.EOF;
<parser.name>.prototype.EOF = antlr4.Token.EOF;
<if(parser.tokens)>
<parser.tokens:{k | <parser.name>.<k> = <parser.tokens.(k)>;}; separator="\n", wrap, anchor>
<endif>
@ -802,6 +803,9 @@ var antlr4 = require('antlr4/index');
>>
Lexer(lexer, atn, actionFuncs, sempredFuncs, superClass) ::= <<
<if(superClass)>
var <superClass> = require('./<superClass>').<superClass>;
<endif>
<atn>
@ -819,14 +823,18 @@ function <lexer.name>(input) {
<lexer.name>.prototype.constructor = <lexer.name>;
<lexer.name>.EOF = antlr4.Token.EOF;
<lexer.name>.prototype.EOF = antlr4.Token.EOF;
<lexer.tokens:{k | <lexer.name>.<k> = <lexer.tokens.(k)>;}; separator="\n", wrap, anchor>
<lexer.tokens:{k | <lexer.name>.prototype.<k> = <lexer.tokens.(k)>;}; separator="\n", wrap, anchor>
<if(lexer.channels)>
<lexer.channels:{c| <lexer.name>.<c> = <lexer.channels.(c)>;}; separator="\n">
<lexer.channels:{c| <lexer.name>.prototype.<c> = <lexer.channels.(c)>;}; separator="\n">
<endif>
<if(rest(lexer.modes))>
<rest(lexer.modes):{m| <lexer.name>.<m> = <i>;}; separator="\n">
<rest(lexer.modes):{m| <lexer.name>.prototype.<m> = <i>;}; separator="\n">
<endif>
<lexer.name>.prototype.channelNames = [ "DEFAULT_TOKEN_CHANNEL", "HIDDEN"<if (lexer.channels)>, <lexer.channels:{c| "<c>"}; separator=", ", wrap, anchor><endif> ];