diff --git a/reference/antlr4 b/reference/antlr4 index a1b85fb2a..873001d30 160000 --- a/reference/antlr4 +++ b/reference/antlr4 @@ -1 +1 @@ -Subproject commit a1b85fb2ae7d6475ca83559f47978f2fefd13e4f +Subproject commit 873001d30c2baa6148783f2ce3be1044c5275d7d diff --git a/runtime/CSharp/Antlr4.Runtime/Dfa/DFAState.cs b/runtime/CSharp/Antlr4.Runtime/Dfa/DFAState.cs index 457c28f2f..44381d993 100644 --- a/runtime/CSharp/Antlr4.Runtime/Dfa/DFAState.cs +++ b/runtime/CSharp/Antlr4.Runtime/Dfa/DFAState.cs @@ -197,11 +197,14 @@ namespace Antlr4.Runtime.Dfa public virtual DFAState GetTarget(int symbol) { - if (edges == null) + lock (this) { - return null; + if (edges == null) + { + return null; + } + return edges[symbol]; } - return edges[symbol]; } public virtual void SetTarget(int symbol, DFAState target) @@ -230,15 +233,18 @@ namespace Antlr4.Runtime.Dfa public virtual DFAState GetContextTarget(int invokingState) { - if (contextEdges == null) + lock (this) { - return null; + if (contextEdges == null) + { + return null; + } + if (invokingState == PredictionContext.EmptyFullStateKey) + { + invokingState = -1; + } + return contextEdges[invokingState]; } - if (invokingState == PredictionContext.EmptyFullStateKey) - { - invokingState = -1; - } - return contextEdges[invokingState]; } public virtual void SetContextTarget(int invokingState, DFAState target) diff --git a/runtime/CSharp/Antlr4.Runtime/UnbufferedCharStream.cs b/runtime/CSharp/Antlr4.Runtime/UnbufferedCharStream.cs index 3afe65650..ab75c892d 100644 --- a/runtime/CSharp/Antlr4.Runtime/UnbufferedCharStream.cs +++ b/runtime/CSharp/Antlr4.Runtime/UnbufferedCharStream.cs @@ -234,7 +234,7 @@ namespace Antlr4.Runtime { for (int i = 0; i < n; i++) { - if (this.n > 0 && data[this.n - 1] == IntStreamConstants.Eof) + if (this.n > 0 && data[this.n - 1] == (char)IntStreamConstants.Eof) { return i; } @@ -284,7 +284,7 @@ namespace Antlr4.Runtime { throw new ArgumentOutOfRangeException(); } - if (index > n) + if (index >= n) { return IntStreamConstants.Eof; } @@ -432,7 +432,7 @@ namespace Antlr4.Runtime if (interval.a < bufferStartIndex || interval.b >= bufferStartIndex + n) { throw new NotSupportedException("interval " + interval + " outside buffer: " + bufferStartIndex - + ".." + (bufferStartIndex + n)); + + ".." + (bufferStartIndex + n - 1)); } // convert from absolute to local index int i = interval.a - bufferStartIndex;