diff --git a/contributors.txt b/contributors.txt index 3d973b8a4..693868d2a 100644 --- a/contributors.txt +++ b/contributors.txt @@ -208,6 +208,7 @@ YYYY/MM/DD, github id, Full name, email 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 +2018/10/08, xsIceman, Andreas Skaar, andreas.skaar@gmail.com 2018/10/18, edirgarcia, Edir GarcĂ­a Lazo, edirgl@hotmail.com 2018/07/31, Lucas Henrqiue, lucashenrique580@gmail.com 2018/08/03, ENDOH takanao, djmchl@gmail.com @@ -258,4 +259,5 @@ 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/09/16, trenki2, Markus Trenkwalder, trenki2[at]gmx[dot]net \ No newline at end of file +2020/09/16, trenki2, Markus Trenkwalder, trenki2[at]gmx[dot]net +2020/10/08, Marti2203, Martin Mirchev, mirchevmartin2203@gmail.com \ No newline at end of file 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: 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() 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