Skip to content

Commit a4e5bfb

Browse files
committed
Fix build errors
1 parent 8111fa5 commit a4e5bfb

21 files changed

+77
-54
lines changed

runtime/CSharp/Antlr4.Runtime.Test/TestPerformance.cs

+9-9
Original file line numberDiff line numberDiff line change
@@ -988,41 +988,41 @@ public override void SyntaxError(IRecognizer recognizer, IToken offendingSymbol,
988988

989989
private class SummarizingDiagnosticErrorListener : DiagnosticErrorListener
990990
{
991-
public override void ReportAmbiguity(Parser recognizer, DFA dfa, int startIndex, int stopIndex, BitSet ambigAlts, ATNConfigSet configs)
991+
public override void ReportAmbiguity(Parser recognizer, DFA dfa, int startIndex, int stopIndex, bool exact, BitSet ambigAlts, ATNConfigSet configs)
992992
{
993993
if (!REPORT_AMBIGUITIES)
994994
{
995995
return;
996996
}
997997

998-
base.ReportAmbiguity(recognizer, dfa, startIndex, stopIndex, ambigAlts, configs);
998+
base.ReportAmbiguity(recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs);
999999
}
10001000

1001-
public override void ReportAttemptingFullContext(Parser recognizer, DFA dfa, int startIndex, int stopIndex, SimulatorState initialState)
1001+
public override void ReportAttemptingFullContext(Parser recognizer, DFA dfa, int startIndex, int stopIndex, BitSet conflictingAlts, SimulatorState initialState)
10021002
{
10031003
if (!REPORT_FULL_CONTEXT)
10041004
{
10051005
return;
10061006
}
10071007

1008-
base.ReportAttemptingFullContext(recognizer, dfa, startIndex, stopIndex, initialState);
1008+
base.ReportAttemptingFullContext(recognizer, dfa, startIndex, stopIndex, conflictingAlts, initialState);
10091009
}
10101010

1011-
public override void ReportContextSensitivity(Parser recognizer, DFA dfa, int startIndex, int stopIndex, SimulatorState acceptState)
1011+
public override void ReportContextSensitivity(Parser recognizer, DFA dfa, int startIndex, int stopIndex, int prediction, SimulatorState acceptState)
10121012
{
10131013
if (!REPORT_CONTEXT_SENSITIVITY)
10141014
{
10151015
return;
10161016
}
10171017

1018-
base.ReportContextSensitivity(recognizer, dfa, startIndex, stopIndex, acceptState);
1018+
base.ReportContextSensitivity(recognizer, dfa, startIndex, stopIndex, prediction, acceptState);
10191019
}
10201020

1021-
protected override string GetDecisionDescription(Parser recognizer, int decision)
1021+
protected override string GetDecisionDescription(Parser recognizer, DFA dfa)
10221022
{
10231023
string format = "{0}({1})";
1024-
string ruleName = recognizer.RuleNames[recognizer.Atn.decisionToState[decision].ruleIndex];
1025-
return string.Format(format, decision, ruleName);
1024+
string ruleName = recognizer.RuleNames[recognizer.Atn.decisionToState[dfa.decision].ruleIndex];
1025+
return string.Format(format, dfa.decision, ruleName);
10261026
}
10271027
}
10281028

runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.CF3.5.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
<Compile Include="Atn\ATNConfigSet.cs" />
7676
<Compile Include="Atn\ATNSimulator.cs" />
7777
<Compile Include="Atn\ATNState.cs" />
78+
<Compile Include="Atn\ATNType.cs" />
7879
<Compile Include="Atn\AtomTransition.cs" />
7980
<Compile Include="Atn\BasicBlockStartState.cs" />
8081
<Compile Include="Atn\BasicState.cs" />
@@ -88,7 +89,6 @@
8889
<Compile Include="Atn\LoopEndState.cs" />
8990
<Compile Include="Atn\NotSetTransition.cs" />
9091
<Compile Include="Atn\OrderedATNConfigSet.cs" />
91-
<Compile Include="Atn\ParserATNPathFinder.cs" />
9292
<Compile Include="Atn\ParserATNSimulator.cs" />
9393
<Compile Include="Atn\PlusBlockStartState.cs" />
9494
<Compile Include="Atn\PlusLoopbackState.cs" />
@@ -152,6 +152,7 @@
152152
<Link>Key.snk</Link>
153153
</None>
154154
<None Include="Misc\Array2DHashSet`1.cs" />
155+
<Compile Include="Misc\MurmurHash.cs" />
155156
<Compile Include="Misc\NullableAttribute.cs" />
156157
<None Include="Misc\DoubleKeyMap`3.cs" />
157158
<Compile Include="Misc\IIntSet.cs" />

runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.Portable.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
<Compile Include="Atn\ATNConfigSet.cs" />
6060
<Compile Include="Atn\ATNSimulator.cs" />
6161
<Compile Include="Atn\ATNState.cs" />
62+
<Compile Include="Atn\ATNType.cs" />
6263
<Compile Include="Atn\AtomTransition.cs" />
6364
<Compile Include="Atn\BasicBlockStartState.cs" />
6465
<Compile Include="Atn\BasicState.cs" />
@@ -72,7 +73,6 @@
7273
<Compile Include="Atn\LoopEndState.cs" />
7374
<Compile Include="Atn\NotSetTransition.cs" />
7475
<Compile Include="Atn\OrderedATNConfigSet.cs" />
75-
<Compile Include="Atn\ParserATNPathFinder.cs" />
7676
<Compile Include="Atn\ParserATNSimulator.cs" />
7777
<Compile Include="Atn\PlusBlockStartState.cs" />
7878
<Compile Include="Atn\PlusLoopbackState.cs" />
@@ -136,6 +136,7 @@
136136
<Link>Key.snk</Link>
137137
</None>
138138
<None Include="Misc\Array2DHashSet`1.cs" />
139+
<Compile Include="Misc\MurmurHash.cs" />
139140
<Compile Include="Misc\NullableAttribute.cs" />
140141
<None Include="Misc\DoubleKeyMap`3.cs" />
141142
<Compile Include="Misc\IIntSet.cs" />

runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.v2.0.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
<Compile Include="Atn\ATNConfigSet.cs" />
5959
<Compile Include="Atn\ATNSimulator.cs" />
6060
<Compile Include="Atn\ATNState.cs" />
61+
<Compile Include="Atn\ATNType.cs" />
6162
<Compile Include="Atn\AtomTransition.cs" />
6263
<Compile Include="Atn\BasicBlockStartState.cs" />
6364
<Compile Include="Atn\BasicState.cs" />
@@ -71,7 +72,6 @@
7172
<Compile Include="Atn\LoopEndState.cs" />
7273
<Compile Include="Atn\NotSetTransition.cs" />
7374
<Compile Include="Atn\OrderedATNConfigSet.cs" />
74-
<Compile Include="Atn\ParserATNPathFinder.cs" />
7575
<Compile Include="Atn\ParserATNSimulator.cs" />
7676
<Compile Include="Atn\PlusBlockStartState.cs" />
7777
<Compile Include="Atn\PlusLoopbackState.cs" />
@@ -135,6 +135,7 @@
135135
<Link>Key.snk</Link>
136136
</None>
137137
<None Include="Misc\Array2DHashSet`1.cs" />
138+
<Compile Include="Misc\MurmurHash.cs" />
138139
<Compile Include="Misc\NullableAttribute.cs" />
139140
<None Include="Misc\DoubleKeyMap`3.cs" />
140141
<Compile Include="Misc\IIntSet.cs" />

runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.v3.0.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
<Compile Include="Atn\ATNConfigSet.cs" />
5959
<Compile Include="Atn\ATNSimulator.cs" />
6060
<Compile Include="Atn\ATNState.cs" />
61+
<Compile Include="Atn\ATNType.cs" />
6162
<Compile Include="Atn\AtomTransition.cs" />
6263
<Compile Include="Atn\BasicBlockStartState.cs" />
6364
<Compile Include="Atn\BasicState.cs" />
@@ -71,7 +72,6 @@
7172
<Compile Include="Atn\LoopEndState.cs" />
7273
<Compile Include="Atn\NotSetTransition.cs" />
7374
<Compile Include="Atn\OrderedATNConfigSet.cs" />
74-
<Compile Include="Atn\ParserATNPathFinder.cs" />
7575
<Compile Include="Atn\ParserATNSimulator.cs" />
7676
<Compile Include="Atn\PlusBlockStartState.cs" />
7777
<Compile Include="Atn\PlusLoopbackState.cs" />
@@ -135,6 +135,7 @@
135135
<Link>Key.snk</Link>
136136
</None>
137137
<None Include="Misc\Array2DHashSet`1.cs" />
138+
<Compile Include="Misc\MurmurHash.cs" />
138139
<Compile Include="Misc\NullableAttribute.cs" />
139140
<None Include="Misc\DoubleKeyMap`3.cs" />
140141
<Compile Include="Misc\IIntSet.cs" />

runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.v3.5.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
<Compile Include="Atn\ATNConfigSet.cs" />
6262
<Compile Include="Atn\ATNSimulator.cs" />
6363
<Compile Include="Atn\ATNState.cs" />
64+
<Compile Include="Atn\ATNType.cs" />
6465
<Compile Include="Atn\AtomTransition.cs" />
6566
<Compile Include="Atn\BasicBlockStartState.cs" />
6667
<Compile Include="Atn\BasicState.cs" />
@@ -74,7 +75,6 @@
7475
<Compile Include="Atn\LoopEndState.cs" />
7576
<Compile Include="Atn\NotSetTransition.cs" />
7677
<Compile Include="Atn\OrderedATNConfigSet.cs" />
77-
<Compile Include="Atn\ParserATNPathFinder.cs" />
7878
<Compile Include="Atn\ParserATNSimulator.cs" />
7979
<Compile Include="Atn\PlusBlockStartState.cs" />
8080
<Compile Include="Atn\PlusLoopbackState.cs" />
@@ -138,6 +138,7 @@
138138
<Link>Key.snk</Link>
139139
</None>
140140
<None Include="Misc\Array2DHashSet`1.cs" />
141+
<Compile Include="Misc\MurmurHash.cs" />
141142
<Compile Include="Misc\NullableAttribute.cs" />
142143
<None Include="Misc\DoubleKeyMap`3.cs" />
143144
<Compile Include="Misc\IIntSet.cs" />

runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.v4.0.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
<Compile Include="Atn\ATNConfigSet.cs" />
6363
<Compile Include="Atn\ATNSimulator.cs" />
6464
<Compile Include="Atn\ATNState.cs" />
65+
<Compile Include="Atn\ATNType.cs" />
6566
<Compile Include="Atn\AtomTransition.cs" />
6667
<Compile Include="Atn\BasicBlockStartState.cs" />
6768
<Compile Include="Atn\BasicState.cs" />
@@ -75,7 +76,6 @@
7576
<Compile Include="Atn\LoopEndState.cs" />
7677
<Compile Include="Atn\NotSetTransition.cs" />
7778
<Compile Include="Atn\OrderedATNConfigSet.cs" />
78-
<Compile Include="Atn\ParserATNPathFinder.cs" />
7979
<Compile Include="Atn\ParserATNSimulator.cs" />
8080
<Compile Include="Atn\PlusBlockStartState.cs" />
8181
<Compile Include="Atn\PlusLoopbackState.cs" />
@@ -139,6 +139,7 @@
139139
<Link>Key.snk</Link>
140140
</None>
141141
<None Include="Misc\Array2DHashSet`1.cs" />
142+
<Compile Include="Misc\MurmurHash.cs" />
142143
<Compile Include="Misc\NullableAttribute.cs" />
143144
<None Include="Misc\DoubleKeyMap`3.cs" />
144145
<Compile Include="Misc\IIntSet.cs" />

runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.v4.5.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@
144144
<Compile Include="Misc\IIntSet.cs" />
145145
<Compile Include="Misc\Interval.cs" />
146146
<Compile Include="Misc\IntervalSet.cs" />
147-
<Compile Include="Misc\JFileChooserConfirmOverwrite.cs" />
148147
<None Include="Misc\MultiMap`2.cs" />
149148
<Compile Include="Misc\MurmurHash.cs" />
150149
<Compile Include="Misc\NotNullAttribute.cs" />

runtime/CSharp/Antlr4.Runtime/Atn/ATN.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public DFA[] GetDecisionToDFA()
174174
/// <code>s</code>
175175
/// 's rule.
176176
/// </summary>
177-
[NotNull]
177+
[return: NotNull]
178178
public virtual IntervalSet NextTokens(ATNState s, PredictionContext ctx)
179179
{
180180
Args.NotNull("ctx", ctx);
@@ -192,7 +192,7 @@ public virtual IntervalSet NextTokens(ATNState s, PredictionContext ctx)
192192
/// is in set if we reach end of
193193
/// rule.
194194
/// </summary>
195-
[NotNull]
195+
[return: NotNull]
196196
public virtual IntervalSet NextTokens(ATNState s)
197197
{
198198
if (s.nextTokenWithinRule != null)
@@ -286,7 +286,7 @@ public virtual int GetNumberOfDecisions()
286286
/// number
287287
/// <code>stateNumber</code>
288288
/// </exception>
289-
[NotNull]
289+
[return: NotNull]
290290
public virtual IntervalSet GetExpectedTokens(int stateNumber, RuleContext context
291291
)
292292
{

runtime/CSharp/Antlr4.Runtime/Atn/ATNSimulator.cs

+14-10
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public abstract class ATNSimulator
4242
{
4343
public static readonly int SerializedVersion = 3;
4444

45-
public static readonly UUID SerializedUuid = UUID.FromString("E4178468-DF95-44D0-AD87-F22A5D5FB6D3");
45+
public static readonly Guid SerializedUuid = new Guid("E4178468-DF95-44D0-AD87-F22A5D5FB6D3");
4646

4747
public const char RuleVariantDelimiter = '$';
4848

@@ -89,16 +89,15 @@ public static ATN Deserialize(char[] data, bool optimize)
8989
, version, SerializedVersion);
9090
throw new NotSupportedException(reason);
9191
}
92-
UUID uuid = ToUUID(data, p);
92+
Guid uuid = ToUUID(data, p);
9393
p += 8;
9494
if (!uuid.Equals(SerializedUuid))
9595
{
96-
string reason = string.Format(CultureInfo.CurrentCulture, "Could not deserialize ATN with UUID %s (expected %s)."
96+
string reason = string.Format(CultureInfo.CurrentCulture, "Could not deserialize ATN with UUID {0} (expected {1})."
9797
, uuid, SerializedUuid);
98-
throw new NotSupportedException(new InvalidClassException(typeof(ATN).FullName, reason
99-
));
98+
throw new NotSupportedException(reason);
10099
}
101-
ATNType grammarType = ATNType.Values()[ToInt(data[p++])];
100+
ATNType grammarType = (ATNType)ToInt(data[p++]);
102101
int maxTokenType = ToInt(data[p++]);
103102
ATN atn = new ATN(grammarType, maxTokenType);
104103
//
@@ -863,11 +862,16 @@ public static long ToLong(char[] data, int offset)
863862
return lowOrder | ((long)ToInt32(data, offset + 2) << 32);
864863
}
865864

866-
public static UUID ToUUID(char[] data, int offset)
865+
public static Guid ToUUID(char[] data, int offset)
867866
{
868-
long leastSigBits = ToLong(data, offset);
869-
long mostSigBits = ToLong(data, offset + 4);
870-
return new UUID(mostSigBits, leastSigBits);
867+
byte[] leastSigBits = BitConverter.GetBytes(ToLong(data, offset));
868+
byte[] mostSigBits = BitConverter.GetBytes(ToLong(data, offset + 4));
869+
870+
byte[] bits = leastSigBits;
871+
Array.Resize(ref bits, leastSigBits.Length + mostSigBits.Length);
872+
Buffer.BlockCopy(mostSigBits, 0, bits, leastSigBits.Length, mostSigBits.Length);
873+
874+
return new Guid(bits);
871875
}
872876

873877
[return: NotNull]

runtime/CSharp/Antlr4.Runtime/Atn/ATNState.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public virtual void AddTransition(int index, Antlr4.Runtime.Atn.Transition e)
210210
if (epsilonOnlyTransitions != e.IsEpsilon)
211211
{
212212
#if !PORTABLE
213-
System.Console.Error.Format(CultureInfo.CurrentCulture, "ATN state {0} has both epsilon and non-epsilon transitions."
213+
System.Console.Error.WriteLine("ATN state {0} has both epsilon and non-epsilon transitions."
214214
, stateNumber);
215215
#endif
216216
epsilonOnlyTransitions = false;

runtime/CSharp/Antlr4.Runtime/Atn/LL1Analyzer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public virtual IntervalSet[] GetDecisionLookahead(ATNState s)
139139
/// <code>ctx</code>
140140
/// .
141141
/// </returns>
142-
[NotNull]
142+
[return: NotNull]
143143
public virtual IntervalSet Look(ATNState s, PredictionContext ctx)
144144
{
145145
return Look(s, null, ctx);

runtime/CSharp/Antlr4.Runtime/Atn/LexerATNSimulator.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -262,15 +262,17 @@ protected internal virtual int ExecATN(ICharStream input, DFAState ds0)
262262
/// if the target state for this edge is not
263263
/// already cached
264264
/// </returns>
265-
[Nullable]
265+
[return: Nullable]
266266
protected internal virtual DFAState GetExistingTargetState(DFAState s, int t)
267267
{
268268
DFAState target = s.GetTarget(t);
269+
#if !PORTABLE
269270
if (debug && target != null)
270271
{
271272
System.Console.Out.WriteLine("reuse state " + s.stateNumber + " edge to " + target
272273
.stateNumber);
273274
}
275+
#endif
274276
return target;
275277
}
276278

@@ -295,7 +297,7 @@ protected internal virtual DFAState GetExistingTargetState(DFAState s, int t)
295297
/// <see cref="ATNSimulator.Error">ATNSimulator.Error</see>
296298
/// .
297299
/// </returns>
298-
[NotNull]
300+
[return: NotNull]
299301
protected internal virtual DFAState ComputeTargetState(ICharStream input, DFAState
300302
s, int t)
301303
{

runtime/CSharp/Antlr4.Runtime/Atn/ParserATNSimulator.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ protected internal virtual SimulatorState ComputeReachSet(DFA dfa, SimulatorStat
850850
/// if the target state for this edge is not
851851
/// already cached
852852
/// </returns>
853-
[Nullable]
853+
[return: Nullable]
854854
protected internal virtual DFAState GetExistingTargetState(DFAState s, int t)
855855
{
856856
return s.GetTarget(t);
@@ -880,7 +880,7 @@ protected internal virtual DFAState GetExistingTargetState(DFAState s, int t)
880880
/// <see cref="ATNSimulator.Error">ATNSimulator.Error</see>
881881
/// .
882882
/// </returns>
883-
[NotNull]
883+
[return: NotNull]
884884
protected internal virtual Tuple<DFAState, ParserRuleContext> ComputeTargetState(
885885
DFA dfa, DFAState s, ParserRuleContext remainingGlobalContext, int t, bool useContext
886886
, PredictionContextCache contextCache)
@@ -1405,7 +1405,7 @@ protected internal virtual void Closure(ATNConfig config, ATNConfigSet configs,
14051405
// track how far we dip into outer context. Might
14061406
// come in handy and we avoid evaluating context dependent
14071407
// preds if this is > 0.
1408-
if (!closureBusy.AddItem(c))
1408+
if (!closureBusy.Add(c))
14091409
{
14101410
// avoid infinite recursion for right-recursive rules
14111411
continue;

runtime/CSharp/Antlr4.Runtime/DefaultErrorStrategy.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ protected internal virtual bool SingleTokenInsertion(Parser recognizer)
711711
/// deletion successfully recovers from the mismatched input, otherwise
712712
/// <code>null</code>
713713
/// </returns>
714-
[Nullable]
714+
[return: Nullable]
715715
protected internal virtual IToken SingleTokenDeletion(Parser recognizer)
716716
{
717717
int nextTokenType = ((ITokenStream)recognizer.InputStream).La(2);
@@ -750,7 +750,7 @@ protected internal virtual IToken SingleTokenDeletion(Parser recognizer)
750750
/// If you change what tokens must be created by the lexer,
751751
/// override this method to create the appropriate tokens.
752752
/// </remarks>
753-
[NotNull]
753+
[return: NotNull]
754754
protected internal virtual IToken GetMissingSymbol(Parser recognizer)
755755
{
756756
IToken currentSymbol = recognizer.CurrentToken;
@@ -785,7 +785,7 @@ protected internal virtual IToken ConstructToken(ITokenSource tokenSource, int e
785785
Line, current.Column);
786786
}
787787

788-
[NotNull]
788+
[return: NotNull]
789789
protected internal virtual IntervalSet GetExpectedTokens(Parser recognizer)
790790
{
791791
return recognizer.GetExpectedTokens();
@@ -836,7 +836,7 @@ protected internal virtual int GetSymbolType(IToken symbol)
836836
return symbol.Type;
837837
}
838838

839-
[NotNull]
839+
[return: NotNull]
840840
protected internal virtual string EscapeWSAndQuote(string s)
841841
{
842842
// if ( s==null ) return s;
@@ -846,7 +846,7 @@ protected internal virtual string EscapeWSAndQuote(string s)
846846
return "'" + s + "'";
847847
}
848848

849-
[NotNull]
849+
[return: NotNull]
850850
protected internal virtual IntervalSet GetErrorRecoverySet(Parser recognizer)
851851
{
852852
ATN atn = recognizer.Interpreter.atn;

0 commit comments

Comments
 (0)