diff --git a/contributors.txt b/contributors.txt index c20f1ab12..2f2afa415 100644 --- a/contributors.txt +++ b/contributors.txt @@ -1,5 +1,9 @@ ANTLR Project Contributors Certification of Origin and Rights +NOTE: This tool is mature and Terence is mostly occupied elsewhere. We +can't accept any changes that could have widespread effects on thousands +of existing projects. Sorry! + All contributors to ANTLR v4 must formally agree to abide by this certificate of origin by signing on the bottom with their github userid, full name, email address (you can obscure your e-mail, but it @@ -245,3 +249,4 @@ YYYY/MM/DD, github id, Full name, email 2020/04/30, TristonianJones, Tristan Swadell, tswadell@google.com 2020/05/31, d-markey, David Markey, dmarkey@free.fr 2020/06/15, mattpaletta, Matthew Paletta, mattpaletta@gmail.com +2020/07/01, sha-N, Shan M Mathews, admin@bluestarqatar.com diff --git a/runtime/JavaScript/src/antlr4/error/index.js b/runtime/JavaScript/src/antlr4/error/index.js index 73d7740c3..482b47edb 100644 --- a/runtime/JavaScript/src/antlr4/error/index.js +++ b/runtime/JavaScript/src/antlr4/error/index.js @@ -10,4 +10,5 @@ module.exports.InputMismatchException = require('./Errors').InputMismatchExcepti module.exports.FailedPredicateException = require('./Errors').FailedPredicateException; module.exports.DiagnosticErrorListener = require('./DiagnosticErrorListener'); module.exports.BailErrorStrategy = require('./ErrorStrategy').BailErrorStrategy; +module.exports.DefaultErrorStrategy = require('./ErrorStrategy').DefaultErrorStrategy; module.exports.ErrorListener = require('./ErrorListener').ErrorListener; diff --git a/runtime/JavaScript/src/antlr4/index.js b/runtime/JavaScript/src/antlr4/index.js index 7bad24203..a8392d6d7 100644 --- a/runtime/JavaScript/src/antlr4/index.js +++ b/runtime/JavaScript/src/antlr4/index.js @@ -20,4 +20,6 @@ var pc = require('./PredictionContext'); exports.PredictionContextCache = pc.PredictionContextCache; exports.ParserRuleContext = require('./ParserRuleContext'); exports.Interval = require('./IntervalSet').Interval; +exports.IntervalSet = require('./IntervalSet').IntervalSet; exports.Utils = require('./Utils'); +exports.LL1Analyzer = require('./LL1Analyzer').LL1Analyzer; diff --git a/tool/src/org/antlr/v4/codegen/Target.java b/tool/src/org/antlr/v4/codegen/Target.java index 36341723e..ec6d08f9a 100644 --- a/tool/src/org/antlr/v4/codegen/Target.java +++ b/tool/src/org/antlr/v4/codegen/Target.java @@ -282,7 +282,7 @@ public abstract class Target { return sb.toString(); } - private static boolean shouldUseUnicodeEscapeForCodePointInDoubleQuotedString(int codePoint) { + protected boolean shouldUseUnicodeEscapeForCodePointInDoubleQuotedString(int codePoint) { // We don't want anyone passing 0x0A (newline) or 0x22 // (double-quote) here because Java treats \\u000A as // a literal newline and \\u0022 as a literal diff --git a/tool/src/org/antlr/v4/codegen/target/CppTarget.java b/tool/src/org/antlr/v4/codegen/target/CppTarget.java index 8b5d7ac04..aed2f9ee4 100644 --- a/tool/src/org/antlr/v4/codegen/target/CppTarget.java +++ b/tool/src/org/antlr/v4/codegen/target/CppTarget.java @@ -47,6 +47,7 @@ public class CppTarget extends Target { public CppTarget(CodeGenerator gen) { super(gen, "Cpp"); + targetCharValueEscape['?'] = "\\?"; } public String getVersion() { @@ -69,6 +70,18 @@ public class CppTarget extends Target { badWords.add("parserRule"); } + @Override + protected boolean shouldUseUnicodeEscapeForCodePointInDoubleQuotedString(int codePoint) { + if (codePoint == '?') { + // in addition to the default escaped code points, also escape ? to prevent trigraphs + // ideally, we would escape ? with \?, but escaping as unicode \u003F works as well + return true; + } + else { + return super.shouldUseUnicodeEscapeForCodePointInDoubleQuotedString(codePoint); + } + } + @Override public String encodeIntAsCharEscape(int v) { return "0x" + Integer.toHexString(v) + ", ";