BitArray isn't a good replacement for BitSet, will need to provide a proper implementation

This commit is contained in:
Sam Harwell 2013-02-18 17:17:17 -06:00
parent a6bd78893d
commit b12aff16b0
13 changed files with 90 additions and 103 deletions

View File

@ -28,7 +28,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Antlr4.Runtime.Atn;
@ -82,7 +81,7 @@ namespace Antlr4.Runtime.Atn
private int uniqueAlt;
private BitArray conflictingAlts;
private BitSet conflictingAlts;
private bool hasSemanticContext;
@ -160,13 +159,13 @@ namespace Antlr4.Runtime.Atn
/// set.
/// </remarks>
[NotNull]
public virtual BitArray GetRepresentedAlternatives()
public virtual BitSet GetRepresentedAlternatives()
{
if (conflictingAlts != null)
{
return (BitArray)conflictingAlts.Clone();
return (BitSet)conflictingAlts.Clone();
}
BitArray alts = new BitArray();
BitSet alts = new BitSet();
foreach (ATNConfig config in this)
{
alts.Set(config.GetAlt());
@ -605,7 +604,7 @@ namespace Antlr4.Runtime.Atn
hasSemanticContext = true;
}
public virtual BitArray ConflictingAlts
public virtual BitSet ConflictingAlts
{
get
{
@ -613,7 +612,7 @@ namespace Antlr4.Runtime.Atn
}
set
{
BitArray conflictingAlts = value;
BitSet conflictingAlts = value;
EnsureWritable();
this.conflictingAlts = conflictingAlts;
}

View File

@ -28,7 +28,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using Antlr4.Runtime.Atn;
@ -797,7 +796,7 @@ nextState_break: ;
{
return true;
}
BitArray reachable = new BitArray(atn.states.Count);
BitSet reachable = new BitSet(atn.states.Count);
IDeque<ATNState> worklist = new ArrayDeque<ATNState>();
worklist.AddItem(transition.followState);
while (!worklist.IsEmpty())

View File

@ -27,7 +27,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System.Collections;
using System.Collections.Generic;
using Antlr4.Runtime;
using Antlr4.Runtime.Atn;
@ -544,7 +543,7 @@ namespace Antlr4.Runtime.Atn
{
input.Seek(startIndex);
}
BitArray predictions = EvalSemanticContext(s.predicates, outerContext, true);
BitSet predictions = EvalSemanticContext(s.predicates, outerContext, true);
if (predictions.Cardinality() == 1)
{
return predictions.NextSetBit(0);
@ -575,8 +574,8 @@ namespace Antlr4.Runtime.Atn
{
input.Seek(startIndex);
}
BitArray alts = EvalSemanticContext(s.predicates, outerContext, reportAmbiguities
&& predictionMode == PredictionMode.LlExactAmbigDetection);
BitSet alts = EvalSemanticContext(s.predicates, outerContext, reportAmbiguities &&
predictionMode == PredictionMode.LlExactAmbigDetection);
switch (alts.Cardinality())
{
case 0:
@ -725,7 +724,7 @@ namespace Antlr4.Runtime.Atn
input.Seek(startIndex);
}
// always use complete evaluation here since we'll want to retry with full context if still ambiguous
BitArray alts = EvalSemanticContext(predPredictions, outerContext, true);
BitSet alts = EvalSemanticContext(predPredictions, outerContext, true);
if (alts.Cardinality() == 1)
{
return alts.NextSetBit(0);
@ -755,8 +754,8 @@ namespace Antlr4.Runtime.Atn
{
input.Seek(startIndex);
}
BitArray alts = EvalSemanticContext(D.predicates, outerContext, reportAmbiguities
&& predictionMode == PredictionMode.LlExactAmbigDetection);
BitSet alts = EvalSemanticContext(D.predicates, outerContext, reportAmbiguities &&
predictionMode == PredictionMode.LlExactAmbigDetection);
D.prediction = ATN.InvalidAltNumber;
switch (alts.Cardinality())
{
@ -800,7 +799,7 @@ namespace Antlr4.Runtime.Atn
{
if (previous.s0 != null)
{
BitArray alts = new BitArray();
BitSet alts = new BitSet();
foreach (ATNConfig config in previous.s0.configs)
{
if (config.GetReachesIntoOuterContext() || config.GetState() is RuleStopState)
@ -1137,7 +1136,7 @@ namespace Antlr4.Runtime.Atn
public virtual DFAState.PredPrediction[] PredicateDFAState(DFAState D, ATNConfigSet
configs, int nalts)
{
BitArray conflictingAlts = GetConflictingAltsFromConfigSet(configs);
BitSet conflictingAlts = GetConflictingAltsFromConfigSet(configs);
SemanticContext[] altToPred = GetPredsForAmbigAlts(conflictingAlts, configs, nalts
);
// altToPred[uniqueAlt] is now our validating predicate (if any)
@ -1154,7 +1153,7 @@ namespace Antlr4.Runtime.Atn
return predPredictions;
}
public virtual SemanticContext[] GetPredsForAmbigAlts(BitArray ambigAlts, ATNConfigSet
public virtual SemanticContext[] GetPredsForAmbigAlts(BitSet ambigAlts, ATNConfigSet
configs, int nalts)
{
// REACH=[1|1|[]|0:0, 1|2|[]|0:1]
@ -1191,7 +1190,7 @@ namespace Antlr4.Runtime.Atn
return altToPred;
}
public virtual DFAState.PredPrediction[] GetPredicatePredictions(BitArray ambigAlts
public virtual DFAState.PredPrediction[] GetPredicatePredictions(BitSet ambigAlts
, SemanticContext[] altToPred)
{
IList<DFAState.PredPrediction> pairs = new List<DFAState.PredPrediction>();
@ -1239,10 +1238,10 @@ namespace Antlr4.Runtime.Atn
/// predicate indicates an alt containing an
/// unpredicated config which behaves as "always true."
/// </remarks>
public virtual BitArray EvalSemanticContext(DFAState.PredPrediction[] predPredictions
public virtual BitSet EvalSemanticContext(DFAState.PredPrediction[] predPredictions
, ParserRuleContext outerContext, bool complete)
{
BitArray predictions = new BitArray();
BitSet predictions = new BitSet();
foreach (DFAState.PredPrediction pair in predPredictions)
{
if (pair.pred == null)
@ -1612,7 +1611,7 @@ namespace Antlr4.Runtime.Atn
private static readonly IComparer<ATNConfig> StateAltSortComparator = new _IComparer_1557
();
private BitArray IsConflicted(ATNConfigSet configset, PredictionContextCache contextCache
private BitSet IsConflicted(ATNConfigSet configset, PredictionContextCache contextCache
)
{
if (configset.UniqueAlt != ATN.InvalidAltNumber || configset.Count <= 1)
@ -1623,7 +1622,7 @@ namespace Antlr4.Runtime.Atn
configs.Sort(StateAltSortComparator);
bool exact = !configset.DipsIntoOuterContext && predictionMode == PredictionMode.
LlExactAmbigDetection;
BitArray alts = new BitArray();
BitSet alts = new BitSet();
int minAlt = configs[0].GetAlt();
alts.Set(minAlt);
// quick check 1 & 2 => if we assume #1 holds and check #2 against the
@ -1643,12 +1642,12 @@ namespace Antlr4.Runtime.Atn
currentState = stateNumber;
}
}
BitArray representedAlts = null;
BitSet representedAlts = null;
if (exact)
{
currentState = configs[0].GetState().NonStopStateNumber;
// get the represented alternatives of the first state
representedAlts = new BitArray();
representedAlts = new BitSet();
int maxAlt = minAlt;
for (int i_1 = 0; i_1 < configs.Count; i_1++)
{
@ -1799,19 +1798,19 @@ namespace Antlr4.Runtime.Atn
return alts;
}
protected internal virtual BitArray GetConflictingAltsFromConfigSet(ATNConfigSet
configs)
protected internal virtual BitSet GetConflictingAltsFromConfigSet(ATNConfigSet configs
)
{
BitArray conflictingAlts = configs.ConflictingAlts;
BitSet conflictingAlts = configs.ConflictingAlts;
if (conflictingAlts == null && configs.UniqueAlt != ATN.InvalidAltNumber)
{
conflictingAlts = new BitArray();
conflictingAlts = new BitSet();
conflictingAlts.Set(configs.UniqueAlt);
}
return conflictingAlts;
}
protected internal virtual int ResolveToMinAlt(DFAState D, BitArray conflictingAlts
protected internal virtual int ResolveToMinAlt(DFAState D, BitSet conflictingAlts
)
{
// kill dead alts so we don't chase them ever
@ -2112,7 +2111,7 @@ namespace Antlr4.Runtime.Atn
/// <summary>If context sensitive parsing, we know it's ambiguity not conflict</summary>
public virtual void ReportAmbiguity(DFA dfa, DFAState D, int startIndex, int stopIndex
, BitArray ambigAlts, ATNConfigSet configs)
, BitSet ambigAlts, ATNConfigSet configs)
{
if (debug || retry_debug)
{

View File

@ -27,7 +27,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System.Collections;
using System.Collections.Generic;
using Antlr4.Runtime.Atn;
using Antlr4.Runtime.Misc;
@ -77,7 +76,7 @@ namespace Antlr4.Runtime.Atn
/// <summary>A Map that uses just the state and the stack context as the key.</summary>
/// <remarks>A Map that uses just the state and the stack context as the key.</remarks>
internal class AltAndContextMap : Dictionary<ATNConfig, BitArray>
internal class AltAndContextMap : Dictionary<ATNConfig, BitSet>
{
public AltAndContextMap() : base(PredictionMode.AltAndContextConfigEqualityComparator
.Instance)
@ -268,7 +267,7 @@ namespace Antlr4.Runtime.Atn
}
// now we have combined contexts for configs with dissimilar preds
// pure SLL or combined SLL+LL mode parsing
ICollection<BitArray> altsets = GetConflictingAltSubsets(configs);
ICollection<BitSet> altsets = GetConflictingAltSubsets(configs);
bool heuristic = HasConflictingAltSet(altsets) && !HasStateAssociatedWithOneAlt(configs
);
return heuristic;
@ -645,7 +644,7 @@ namespace Antlr4.Runtime.Atn
///
/// {1,2},{1,2}}}, etc...
/// </remarks>
public static int ResolvesToJustOneViableAlt(ICollection<BitArray> altsets)
public static int ResolvesToJustOneViableAlt(ICollection<BitSet> altsets)
{
return GetSingleViableAlt(altsets);
}
@ -661,15 +660,15 @@ namespace Antlr4.Runtime.Atn
///
/// <code>true</code>
/// if every
/// <see cref="System.Collections.BitArray">System.Collections.BitArray</see>
/// <see cref="Sharpen.BitSet">Sharpen.BitSet</see>
/// in
/// <code>altsets</code>
/// has
/// <see cref="System.Collections.BitArray.Cardinality()">cardinality</see>
/// <see cref="Sharpen.BitSet.Cardinality()">cardinality</see>
/// &gt; 1, otherwise
/// <code>false</code>
/// </returns>
public static bool AllSubsetsConflict(ICollection<BitArray> altsets)
public static bool AllSubsetsConflict(ICollection<BitSet> altsets)
{
return !HasNonConflictingAltSet(altsets);
}
@ -687,15 +686,15 @@ namespace Antlr4.Runtime.Atn
/// if
/// <code>altsets</code>
/// contains a
/// <see cref="System.Collections.BitArray">System.Collections.BitArray</see>
/// <see cref="Sharpen.BitSet">Sharpen.BitSet</see>
/// with
/// <see cref="System.Collections.BitArray.Cardinality()">cardinality</see>
/// <see cref="Sharpen.BitSet.Cardinality()">cardinality</see>
/// 1, otherwise
/// <code>false</code>
/// </returns>
public static bool HasNonConflictingAltSet(ICollection<BitArray> altsets)
public static bool HasNonConflictingAltSet(ICollection<BitSet> altsets)
{
foreach (BitArray alts in altsets)
foreach (BitSet alts in altsets)
{
if (alts.Cardinality() == 1)
{
@ -718,15 +717,15 @@ namespace Antlr4.Runtime.Atn
/// if
/// <code>altsets</code>
/// contains a
/// <see cref="System.Collections.BitArray">System.Collections.BitArray</see>
/// <see cref="Sharpen.BitSet">Sharpen.BitSet</see>
/// with
/// <see cref="System.Collections.BitArray.Cardinality()">cardinality</see>
/// <see cref="Sharpen.BitSet.Cardinality()">cardinality</see>
/// &gt; 1, otherwise
/// <code>false</code>
/// </returns>
public static bool HasConflictingAltSet(ICollection<BitArray> altsets)
public static bool HasConflictingAltSet(ICollection<BitSet> altsets)
{
foreach (BitArray alts in altsets)
foreach (BitSet alts in altsets)
{
if (alts.Cardinality() > 1)
{
@ -751,13 +750,13 @@ namespace Antlr4.Runtime.Atn
/// others, otherwise
/// <code>false</code>
/// </returns>
public static bool AllSubsetsEqual(ICollection<BitArray> altsets)
public static bool AllSubsetsEqual(ICollection<BitSet> altsets)
{
IEnumerator<BitArray> it = altsets.GetEnumerator();
BitArray first = it.Next();
IEnumerator<BitSet> it = altsets.GetEnumerator();
BitSet first = it.Next();
while (it.HasNext())
{
BitArray next = it.Next();
BitSet next = it.Next();
if (!next.Equals(first))
{
return false;
@ -774,9 +773,9 @@ namespace Antlr4.Runtime.Atn
/// .
/// </summary>
/// <param name="altsets">a collection of alternative subsets</param>
public static int GetUniqueAlt(ICollection<BitArray> altsets)
public static int GetUniqueAlt(ICollection<BitSet> altsets)
{
BitArray all = GetAlts(altsets);
BitSet all = GetAlts(altsets);
if (all.Cardinality() == 1)
{
return all.NextSetBit(0);
@ -791,7 +790,7 @@ namespace Antlr4.Runtime.Atn
/// <remarks>
/// Gets the complete set of represented alternatives for a collection of
/// alternative subsets. This method returns the union of each
/// <see cref="System.Collections.BitArray">System.Collections.BitArray</see>
/// <see cref="Sharpen.BitSet">Sharpen.BitSet</see>
/// in
/// <code>altsets</code>
/// .
@ -801,10 +800,10 @@ namespace Antlr4.Runtime.Atn
/// the set of represented alternatives in
/// <code>altsets</code>
/// </returns>
public static BitArray GetAlts(ICollection<BitArray> altsets)
public static BitSet GetAlts(ICollection<BitSet> altsets)
{
BitArray all = new BitArray();
foreach (BitArray alts in altsets)
BitSet all = new BitSet();
foreach (BitSet alts in altsets)
{
all.Or(alts);
}
@ -828,17 +827,16 @@ namespace Antlr4.Runtime.Atn
/// </pre>
/// </remarks>
[NotNull]
public static ICollection<BitArray> GetConflictingAltSubsets(ATNConfigSet configs
)
public static ICollection<BitSet> GetConflictingAltSubsets(ATNConfigSet configs)
{
PredictionMode.AltAndContextMap configToAlts = new PredictionMode.AltAndContextMap
();
foreach (ATNConfig c in configs)
{
BitArray alts = configToAlts.Get(c);
BitSet alts = configToAlts.Get(c);
if (alts == null)
{
alts = new BitArray();
alts = new BitSet();
configToAlts.Put(c, alts);
}
alts.Set(c.GetAlt());
@ -862,16 +860,16 @@ namespace Antlr4.Runtime.Atn
/// </pre>
/// </remarks>
[NotNull]
public static IDictionary<ATNState, BitArray> GetStateToAltMap(ATNConfigSet configs
public static IDictionary<ATNState, BitSet> GetStateToAltMap(ATNConfigSet configs
)
{
IDictionary<ATNState, BitArray> m = new Dictionary<ATNState, BitArray>();
IDictionary<ATNState, BitSet> m = new Dictionary<ATNState, BitSet>();
foreach (ATNConfig c in configs)
{
BitArray alts = m.Get(c.GetState());
BitSet alts = m.Get(c.GetState());
if (alts == null)
{
alts = new BitArray();
alts = new BitSet();
m.Put(c.GetState(), alts);
}
alts.Set(c.GetAlt());
@ -881,8 +879,8 @@ namespace Antlr4.Runtime.Atn
public static bool HasStateAssociatedWithOneAlt(ATNConfigSet configs)
{
IDictionary<ATNState, BitArray> x = GetStateToAltMap(configs);
foreach (BitArray alts in x.Values)
IDictionary<ATNState, BitSet> x = GetStateToAltMap(configs);
foreach (BitSet alts in x.Values)
{
if (alts.Cardinality() == 1)
{
@ -892,10 +890,10 @@ namespace Antlr4.Runtime.Atn
return false;
}
public static int GetSingleViableAlt(ICollection<BitArray> altsets)
public static int GetSingleViableAlt(ICollection<BitSet> altsets)
{
BitArray viableAlts = new BitArray();
foreach (BitArray alts in altsets)
BitSet viableAlts = new BitSet();
foreach (BitSet alts in altsets)
{
int minAlt = alts.NextSetBit(0);
viableAlts.Set(minAlt);

View File

@ -367,9 +367,8 @@ namespace Antlr4.Runtime.Atn
return result;
}
/// <seealso cref="ParserATNSimulator.GetPredsForAmbigAlts(System.Collections.BitArray, ATNConfigSet, int)
/// ">ParserATNSimulator.GetPredsForAmbigAlts(System.Collections.BitArray, ATNConfigSet, int)
/// </seealso>
/// <seealso cref="ParserATNSimulator.GetPredsForAmbigAlts(Sharpen.BitSet, ATNConfigSet, int)
/// ">ParserATNSimulator.GetPredsForAmbigAlts(Sharpen.BitSet, ATNConfigSet, int)</seealso>
public static SemanticContext Or(SemanticContext a, SemanticContext b)
{
if (a == null)

View File

@ -27,7 +27,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System.Collections;
using Antlr4.Runtime;
using Antlr4.Runtime.Atn;
using Antlr4.Runtime.Dfa;
@ -45,7 +44,7 @@ namespace Antlr4.Runtime
}
public virtual void ReportAmbiguity(Parser recognizer, DFA dfa, int startIndex, int
stopIndex, BitArray ambigAlts, ATNConfigSet configs)
stopIndex, BitSet ambigAlts, ATNConfigSet configs)
{
}

View File

@ -28,7 +28,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Antlr4.Runtime;
@ -382,7 +381,7 @@ namespace Antlr4.Runtime
/// if no tokens were found. This
/// method looks at both on and off channel tokens.
/// </summary>
public virtual IList<IToken> GetTokens(int start, int stop, BitArray types)
public virtual IList<IToken> GetTokens(int start, int stop, BitSet types)
{
LazyInit();
if (start < 0 || stop >= tokens.Count || stop < 0 || start >= tokens.Count)
@ -413,7 +412,7 @@ namespace Antlr4.Runtime
public virtual IList<IToken> GetTokens(int start, int stop, int ttype)
{
BitArray s = new BitArray(ttype);
BitSet s = new BitSet(ttype);
s.Set(ttype);
return GetTokens(start, stop, s);
}

View File

@ -28,7 +28,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Antlr4.Runtime.Atn;
@ -112,7 +111,7 @@ namespace Antlr4.Runtime.Dfa
/// <remarks>Symbols in this set require a global context transition before matching an input symbol.
/// </remarks>
[Nullable]
private BitArray contextSymbols;
private BitSet contextSymbols;
/// <summary>
/// This list is computed by
@ -191,7 +190,7 @@ namespace Antlr4.Runtime.Dfa
{
return;
}
contextSymbols = new BitArray();
contextSymbols = new BitSet();
contextEdges = new SingletonEdgeMap<DFAState>(-1, atn.states.Count - 1);
}
}

View File

@ -27,7 +27,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System.Collections;
using Antlr4.Runtime;
using Antlr4.Runtime.Atn;
using Antlr4.Runtime.Dfa;
@ -39,7 +38,7 @@ namespace Antlr4.Runtime
public class DiagnosticErrorListener : BaseErrorListener
{
public override void ReportAmbiguity(Parser recognizer, DFA dfa, int startIndex,
int stopIndex, BitArray ambigAlts, ATNConfigSet configs)
int stopIndex, BitSet ambigAlts, ATNConfigSet configs)
{
string format = "reportAmbiguity d=%s: ambigAlts=%s, input='%s'";
recognizer.NotifyErrorListeners(string.Format(format, GetDecisionDescription(recognizer

View File

@ -27,7 +27,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System.Collections;
using Antlr4.Runtime;
using Antlr4.Runtime.Atn;
using Antlr4.Runtime.Dfa;
@ -50,7 +49,7 @@ namespace Antlr4.Runtime
/// that can match the input sequence. This method is only called when we are parsing with
/// full context.
/// </remarks>
void ReportAmbiguity(Parser recognizer, DFA dfa, int startIndex, int stopIndex, BitArray
void ReportAmbiguity(Parser recognizer, DFA dfa, int startIndex, int stopIndex, BitSet
ambigAlts, ATNConfigSet configs);
void ReportAttemptingFullContext(Parser recognizer, DFA dfa, int startIndex, int

View File

@ -170,12 +170,12 @@ namespace Antlr4.Runtime.Misc
EnumSet<Dependents> dependents = EnumSet.Of(Dependents.Self, dependency.Item1.Dependents
());
ReportUnimplementedDependents(dependency, dependents);
BitArray checked = new BitArray();
BitSet checked = new BitSet();
int highestRequiredDependency = CheckDependencyVersion(dependency, ruleNames, ruleVersions
, effectiveRule, null);
if (dependents.Contains(Dependents.Parents))
{
BitArray parents = relations.parents[dependency.Item1.Rule()];
BitSet parents = relations.parents[dependency.Item1.Rule()];
for (int parent = parents.NextSetBit(0); parent >= 0; parent = parents.NextSetBit
(parent + 1))
{
@ -191,7 +191,7 @@ namespace Antlr4.Runtime.Misc
}
if (dependents.Contains(Dependents.Children))
{
BitArray children = relations.children[dependency.Item1.Rule()];
BitSet children = relations.children[dependency.Item1.Rule()];
for (int child = children.NextSetBit(0); child >= 0; child = children.NextSetBit(
child + 1))
{
@ -207,7 +207,7 @@ namespace Antlr4.Runtime.Misc
}
if (dependents.Contains(Dependents.Ancestors))
{
BitArray ancestors = relations.GetAncestors(dependency.Item1.Rule());
BitSet ancestors = relations.GetAncestors(dependency.Item1.Rule());
for (int ancestor = ancestors.NextSetBit(0); ancestor >= 0; ancestor = ancestors.
NextSetBit(ancestor + 1))
{
@ -223,7 +223,7 @@ namespace Antlr4.Runtime.Misc
}
if (dependents.Contains(Dependents.Descendants))
{
BitArray descendants = relations.GetDescendants(dependency.Item1.Rule());
BitSet descendants = relations.GetDescendants(dependency.Item1.Rule());
for (int descendant = descendants.NextSetBit(0); descendant >= 0; descendant = descendants
.NextSetBit(descendant + 1))
{
@ -780,21 +780,21 @@ namespace Antlr4.Runtime.Misc
private sealed class RuleRelations
{
private readonly BitArray[] parents;
private readonly BitSet[] parents;
private readonly BitArray[] children;
private readonly BitSet[] children;
public RuleRelations(int ruleCount)
{
parents = new BitArray[ruleCount];
parents = new BitSet[ruleCount];
for (int i = 0; i < ruleCount; i++)
{
parents[i] = new BitArray();
parents[i] = new BitSet();
}
children = new BitArray[ruleCount];
children = new BitSet[ruleCount];
for (int i_1 = 0; i_1 < ruleCount; i_1++)
{
children[i_1] = new BitArray();
children[i_1] = new BitSet();
}
}
@ -815,9 +815,9 @@ namespace Antlr4.Runtime.Misc
return true;
}
public BitArray GetAncestors(int rule)
public BitSet GetAncestors(int rule)
{
BitArray ancestors = new BitArray();
BitSet ancestors = new BitSet();
ancestors.Or(parents[rule]);
while (true)
{
@ -835,9 +835,9 @@ namespace Antlr4.Runtime.Misc
return ancestors;
}
public BitArray GetDescendants(int rule)
public BitSet GetDescendants(int rule)
{
BitArray descendants = new BitArray();
BitSet descendants = new BitSet();
descendants.Or(children[rule]);
while (true)
{

View File

@ -27,7 +27,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System.Collections;
using System.Collections.Generic;
using Antlr4.Runtime;
using Antlr4.Runtime.Atn;
@ -45,7 +44,7 @@ namespace Antlr4.Runtime
}
public virtual void ReportAmbiguity(Parser recognizer, DFA dfa, int startIndex, int
stopIndex, BitArray ambigAlts, ATNConfigSet configs)
stopIndex, BitSet ambigAlts, ATNConfigSet configs)
{
foreach (IAntlrErrorListener<IToken> listener in GetDelegates())
{

View File

@ -120,7 +120,6 @@
-typeMapping java.net.InetAddress System.Net.IPAddress
-typeMapping java.util.TimeZone System.TimeZoneInfo
-typeMapping java.util.ArrayList<> System.Collections.Generic.List
-typeMapping java.util.BitSet System.Collections.BitArray
-typeMapping java.util.zip.Inflater ICSharpCode.SharpZipLib.Zip.Compression.Inflater
-typeMapping java.util.zip.Deflater ICSharpCode.SharpZipLib.Zip.Compression.Deflater
-typeMapping java.util.zip.ZipException ICSharpCode.SharpZipLib.SharpZipBaseException