From 10f8cac7f4b7accd7a647e1096c85241f0687805 Mon Sep 17 00:00:00 2001 From: Andreas Skaar Date: Mon, 8 Oct 2018 22:05:05 +0200 Subject: [PATCH 1/5] Update runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/SingletonPredictionContext.cs NullReferenceException in CSharp target #2304 --- .../CSharp/Antlr4.Runtime/Atn/SingletonPredictionContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/SingletonPredictionContext.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/SingletonPredictionContext.cs index 2f8f1bb5d..e162dcaca 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/SingletonPredictionContext.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/SingletonPredictionContext.cs @@ -79,7 +79,7 @@ namespace Antlr4.Runtime.Atn return false; } Antlr4.Runtime.Atn.SingletonPredictionContext other = (Antlr4.Runtime.Atn.SingletonPredictionContext)o; - return returnState == other.returnState && parent.Equals(other.parent); + return returnState == other.returnState && (parent != null && parent.Equals(other.parent)); } public override string ToString() From 8b458f85c02fa93e9e216c7899a28776f00185c9 Mon Sep 17 00:00:00 2001 From: Andreas Skaar Date: Mon, 8 Oct 2018 22:15:05 +0200 Subject: [PATCH 2/5] Update contributors.txt sign of contributors.txt --- contributors.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contributors.txt b/contributors.txt index 3a223169c..8afdd597d 100644 --- a/contributors.txt +++ b/contributors.txt @@ -192,4 +192,5 @@ YYYY/MM/DD, github id, Full name, email 2018/06/16, EternalPhane, Zongyuan Zuo, eternalphane@gmail.com 2018/07/03, jgoppert, James Goppert, james.goppert@gmail.com 2018/07/27, Maksim Novikov, mnovikov.work@gmail.com -2018/08/03, ENDOH takanao, djmchl@gmail.com \ No newline at end of file +2018/08/03, ENDOH takanao, djmchl@gmail.com +2018/10/08, xsIceman, Andreas Skaar, andreas.skaar@gmail.com \ No newline at end of file From 4aa1d59c1a3bf47c982b8eefc9859ec0e8f945ae Mon Sep 17 00:00:00 2001 From: cliid Date: Tue, 29 Sep 2020 11:03:03 +0900 Subject: [PATCH 3/5] Update cpp-target.md --- doc/cpp-target.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/cpp-target.md b/doc/cpp-target.md index 1fc8e8684..edf75f4f6 100644 --- a/doc/cpp-target.md +++ b/doc/cpp-target.md @@ -1,6 +1,6 @@ # C++ -The C++ target supports all platforms that can either run MS Visual Studio 2013 (or newer), XCode 7 (or newer) or CMake (C++11 required). All build tools can either create static or dynamic libraries, both as 64bit or 32bit arch. Additionally, XCode can create an iOS library. Also see [Antlr4 for C++ with CMake: A practical example](http://blorente.me//Antlr-,-C++-and-CMake-Wait-what.html). +The C++ target supports all platforms that can either run MS Visual Studio 2013 (or newer), XCode 7 (or newer) or CMake (C++11 required). All build tools can either create static or dynamic libraries, both as 64bit or 32bit arch. Additionally, XCode can create an iOS library. Also see [Antlr4 for C++ with CMake: A practical example](https://beyondtheloop.dev/Antlr-cpp-cmake/). ## How to create a C++ lexer or parser? This is pretty much the same as creating a Java lexer or parser, except you need to specify the language target, for example: From 0ead01fb97c562ba757bb534cfed185d4e4771de Mon Sep 17 00:00:00 2001 From: Martin Mirchev Date: Thu, 8 Oct 2020 14:40:03 +0200 Subject: [PATCH 4/5] Made C# Trace Listener usable --- .../CSharp/runtime/CSharp/Antlr4.Runtime/Parser.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Parser.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Parser.cs index b13919923..130e00418 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Parser.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Parser.cs @@ -22,20 +22,20 @@ namespace Antlr4.Runtime #if !PORTABLE public class TraceListener : IParseTreeListener { - private readonly TextWriter Output; - public TraceListener(TextWriter output) { - Output = output; + public TraceListener(TextWriter output,Parser enclosing) { + _output = output; + _enclosing = enclosing; } public virtual void EnterEveryRule(ParserRuleContext ctx) { - Output.WriteLine("enter " + this._enclosing.RuleNames[ctx.RuleIndex] + ", LT(1)=" + this._enclosing._input.LT(1).Text); + _output.WriteLine("enter " + this._enclosing.RuleNames[ctx.RuleIndex] + ", LT(1)=" + this._enclosing._input.LT(1).Text); } public virtual void ExitEveryRule(ParserRuleContext ctx) { - Output.WriteLine("exit " + this._enclosing.RuleNames[ctx.RuleIndex] + ", LT(1)=" + this._enclosing._input.LT(1).Text); + _output.WriteLine("exit " + this._enclosing.RuleNames[ctx.RuleIndex] + ", LT(1)=" + this._enclosing._input.LT(1).Text); } public virtual void VisitErrorNode(IErrorNode node) @@ -46,15 +46,17 @@ namespace Antlr4.Runtime { ParserRuleContext parent = (ParserRuleContext)((IRuleNode)node.Parent).RuleContext; IToken token = node.Symbol; - Output.WriteLine("consume " + token + " rule " + this._enclosing.RuleNames[parent.RuleIndex]); + _output.WriteLine("consume " + token + " rule " + this._enclosing.RuleNames[parent.RuleIndex]); } internal TraceListener(Parser _enclosing) { this._enclosing = _enclosing; + _output = Console.Out; } private readonly Parser _enclosing; + private readonly TextWriter _output; } #endif From 53611158427ad0162c1a68436e76d6f8bb0b5c42 Mon Sep 17 00:00:00 2001 From: Martin Mirchev Date: Thu, 8 Oct 2020 14:45:15 +0200 Subject: [PATCH 5/5] Add to contributors --- contributors.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/contributors.txt b/contributors.txt index 1ed7e468c..e556d6b0f 100644 --- a/contributors.txt +++ b/contributors.txt @@ -258,3 +258,4 @@ YYYY/MM/DD, github id, Full name, email 2020/09/06, ArthurSonzogni, Sonzogni Arthur, arthursonzogni@gmail.com 2020/09/12, Clcanny, Charles Ruan, a837940593@gmail.com 2020/09/15, rmcgregor1990, Robert McGregor, rmcgregor1990@gmail.com +2020/10/08, Marti2203, Martin Mirchev, mirchevmartin2203@gmail.com