From ae5efa8a30f55eeff63cceed65bcf36e44ab1920 Mon Sep 17 00:00:00 2001 From: parrt Date: Tue, 16 Jun 2020 13:38:04 -0700 Subject: [PATCH 1/6] tweak contrib --- contributors.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contributors.txt b/contributors.txt index e24449596..9c76f107d 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 From c134dac863ea8f988eb3d7f38b3e7fd29a30e92f Mon Sep 17 00:00:00 2001 From: Felix Nieuwenhuizen Date: Sun, 19 Apr 2020 19:30:56 +0200 Subject: [PATCH 2/6] escape ? character in c++ codegen to prevent accidental trigraphs (using an override of shouldUseUnicodeEscapeForCodePointInDoubleQuotedString in CppTarget) --- tool/src/org/antlr/v4/codegen/Target.java | 2 +- tool/src/org/antlr/v4/codegen/target/CppTarget.java | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) 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) + ", "; From 5f3654dea7c802b57d56d7b710ab754b605054ee Mon Sep 17 00:00:00 2001 From: Shan M Date: Wed, 1 Jul 2020 11:59:04 +0300 Subject: [PATCH 3/6] Sign contributors.txt --- contributors.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/contributors.txt b/contributors.txt index 9c76f107d..ab0d17bbc 100644 --- a/contributors.txt +++ b/contributors.txt @@ -248,3 +248,4 @@ YYYY/MM/DD, github id, Full name, email 2020/04/07, deniskyashif, Denis Kyashif, denis.kyashif@gmail.com 2020/04/30, TristonianJones, Tristan Swadell, tswadell@google.com 2020/05/31, d-markey, David Markey, dmarkey@free.fr +2020/07/01, sha-N, Shan M Mathews, admin@bluestarqatar.com From f780421da707beb81ec2f5b638abcb9cbb561239 Mon Sep 17 00:00:00 2001 From: Shan M Date: Wed, 1 Jul 2020 12:00:41 +0300 Subject: [PATCH 4/6] Adds DefaultErrorStrategy to export list --- runtime/JavaScript/src/antlr4/error/index.js | 1 + 1 file changed, 1 insertion(+) 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; From 795cd3b682bbc80adc6945d5ed2d3d41ad7fb968 Mon Sep 17 00:00:00 2001 From: Shan M Date: Wed, 1 Jul 2020 12:01:44 +0300 Subject: [PATCH 5/6] adds IntervalSet to the export list --- runtime/JavaScript/src/antlr4/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/runtime/JavaScript/src/antlr4/index.js b/runtime/JavaScript/src/antlr4/index.js index 7bad24203..06b439a8d 100644 --- a/runtime/JavaScript/src/antlr4/index.js +++ b/runtime/JavaScript/src/antlr4/index.js @@ -20,4 +20,5 @@ 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'); From e74443546306c8a975964cb1cc0277fcb1fc8a13 Mon Sep 17 00:00:00 2001 From: Shan M Date: Wed, 1 Jul 2020 12:10:47 +0300 Subject: [PATCH 6/6] Adds LL1Analyzer to exports list --- runtime/JavaScript/src/antlr4/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/runtime/JavaScript/src/antlr4/index.js b/runtime/JavaScript/src/antlr4/index.js index 06b439a8d..a8392d6d7 100644 --- a/runtime/JavaScript/src/antlr4/index.js +++ b/runtime/JavaScript/src/antlr4/index.js @@ -22,3 +22,4 @@ exports.ParserRuleContext = require('./ParserRuleContext'); exports.Interval = require('./IntervalSet').Interval; exports.IntervalSet = require('./IntervalSet').IntervalSet; exports.Utils = require('./Utils'); +exports.LL1Analyzer = require('./LL1Analyzer').LL1Analyzer;