forked from jasder/antlr
Add type mappings for BitSet; update mapping for BigInteger to use System.Numerics.BigInteger
This commit is contained in:
parent
9735d88274
commit
f8c643304b
|
@ -28,6 +28,7 @@
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Antlr4.Runtime.Atn;
|
using Antlr4.Runtime.Atn;
|
||||||
|
@ -81,7 +82,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
|
|
||||||
private int uniqueAlt;
|
private int uniqueAlt;
|
||||||
|
|
||||||
private BitSet conflictingAlts;
|
private BitArray conflictingAlts;
|
||||||
|
|
||||||
private bool hasSemanticContext;
|
private bool hasSemanticContext;
|
||||||
|
|
||||||
|
@ -159,13 +160,13 @@ namespace Antlr4.Runtime.Atn
|
||||||
/// set.
|
/// set.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[NotNull]
|
[NotNull]
|
||||||
public virtual BitSet GetRepresentedAlternatives()
|
public virtual BitArray GetRepresentedAlternatives()
|
||||||
{
|
{
|
||||||
if (conflictingAlts != null)
|
if (conflictingAlts != null)
|
||||||
{
|
{
|
||||||
return (BitSet)conflictingAlts.Clone();
|
return (BitArray)conflictingAlts.Clone();
|
||||||
}
|
}
|
||||||
BitSet alts = new BitSet();
|
BitArray alts = new BitArray();
|
||||||
foreach (ATNConfig config in this)
|
foreach (ATNConfig config in this)
|
||||||
{
|
{
|
||||||
alts.Set(config.GetAlt());
|
alts.Set(config.GetAlt());
|
||||||
|
@ -597,12 +598,12 @@ namespace Antlr4.Runtime.Atn
|
||||||
hasSemanticContext = true;
|
hasSemanticContext = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual BitSet GetConflictingAlts()
|
public virtual BitArray GetConflictingAlts()
|
||||||
{
|
{
|
||||||
return conflictingAlts;
|
return conflictingAlts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void SetConflictingAlts(BitSet conflictingAlts)
|
public virtual void SetConflictingAlts(BitArray conflictingAlts)
|
||||||
{
|
{
|
||||||
EnsureWritable();
|
EnsureWritable();
|
||||||
this.conflictingAlts = conflictingAlts;
|
this.conflictingAlts = conflictingAlts;
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Antlr4.Runtime.Atn;
|
using Antlr4.Runtime.Atn;
|
||||||
|
@ -799,7 +800,7 @@ nextState_break: ;
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
BitSet reachable = new BitSet(atn.states.Count);
|
BitArray reachable = new BitArray(atn.states.Count);
|
||||||
IDeque<ATNState> worklist = new ArrayDeque<ATNState>();
|
IDeque<ATNState> worklist = new ArrayDeque<ATNState>();
|
||||||
worklist.AddItem(transition.followState);
|
worklist.AddItem(transition.followState);
|
||||||
while (!worklist.IsEmpty())
|
while (!worklist.IsEmpty())
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Antlr4.Runtime;
|
using Antlr4.Runtime;
|
||||||
using Antlr4.Runtime.Atn;
|
using Antlr4.Runtime.Atn;
|
||||||
|
@ -543,7 +544,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
{
|
{
|
||||||
input.Seek(startIndex);
|
input.Seek(startIndex);
|
||||||
}
|
}
|
||||||
BitSet predictions = EvalSemanticContext(s.predicates, outerContext, true);
|
BitArray predictions = EvalSemanticContext(s.predicates, outerContext, true);
|
||||||
if (predictions.Cardinality() == 1)
|
if (predictions.Cardinality() == 1)
|
||||||
{
|
{
|
||||||
return predictions.NextSetBit(0);
|
return predictions.NextSetBit(0);
|
||||||
|
@ -574,8 +575,8 @@ namespace Antlr4.Runtime.Atn
|
||||||
{
|
{
|
||||||
input.Seek(startIndex);
|
input.Seek(startIndex);
|
||||||
}
|
}
|
||||||
BitSet alts = EvalSemanticContext(s.predicates, outerContext, reportAmbiguities &&
|
BitArray alts = EvalSemanticContext(s.predicates, outerContext, reportAmbiguities
|
||||||
predictionMode == PredictionMode.LlExactAmbigDetection);
|
&& predictionMode == PredictionMode.LlExactAmbigDetection);
|
||||||
switch (alts.Cardinality())
|
switch (alts.Cardinality())
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -726,7 +727,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
input.Seek(startIndex);
|
input.Seek(startIndex);
|
||||||
}
|
}
|
||||||
// always use complete evaluation here since we'll want to retry with full context if still ambiguous
|
// always use complete evaluation here since we'll want to retry with full context if still ambiguous
|
||||||
BitSet alts = EvalSemanticContext(predPredictions, outerContext, true);
|
BitArray alts = EvalSemanticContext(predPredictions, outerContext, true);
|
||||||
if (alts.Cardinality() == 1)
|
if (alts.Cardinality() == 1)
|
||||||
{
|
{
|
||||||
return alts.NextSetBit(0);
|
return alts.NextSetBit(0);
|
||||||
|
@ -756,8 +757,8 @@ namespace Antlr4.Runtime.Atn
|
||||||
{
|
{
|
||||||
input.Seek(startIndex);
|
input.Seek(startIndex);
|
||||||
}
|
}
|
||||||
BitSet alts = EvalSemanticContext(D.predicates, outerContext, reportAmbiguities &&
|
BitArray alts = EvalSemanticContext(D.predicates, outerContext, reportAmbiguities
|
||||||
predictionMode == PredictionMode.LlExactAmbigDetection);
|
&& predictionMode == PredictionMode.LlExactAmbigDetection);
|
||||||
D.prediction = ATN.InvalidAltNumber;
|
D.prediction = ATN.InvalidAltNumber;
|
||||||
switch (alts.Cardinality())
|
switch (alts.Cardinality())
|
||||||
{
|
{
|
||||||
|
@ -801,7 +802,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
{
|
{
|
||||||
if (previous.s0 != null)
|
if (previous.s0 != null)
|
||||||
{
|
{
|
||||||
BitSet alts = new BitSet();
|
BitArray alts = new BitArray();
|
||||||
foreach (ATNConfig config in previous.s0.configs)
|
foreach (ATNConfig config in previous.s0.configs)
|
||||||
{
|
{
|
||||||
if (config.GetReachesIntoOuterContext() || config.GetState() is RuleStopState)
|
if (config.GetReachesIntoOuterContext() || config.GetState() is RuleStopState)
|
||||||
|
@ -1138,7 +1139,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
public virtual DFAState.PredPrediction[] PredicateDFAState(DFAState D, ATNConfigSet
|
public virtual DFAState.PredPrediction[] PredicateDFAState(DFAState D, ATNConfigSet
|
||||||
configs, int nalts)
|
configs, int nalts)
|
||||||
{
|
{
|
||||||
BitSet conflictingAlts = GetConflictingAltsFromConfigSet(configs);
|
BitArray conflictingAlts = GetConflictingAltsFromConfigSet(configs);
|
||||||
SemanticContext[] altToPred = GetPredsForAmbigAlts(conflictingAlts, configs, nalts
|
SemanticContext[] altToPred = GetPredsForAmbigAlts(conflictingAlts, configs, nalts
|
||||||
);
|
);
|
||||||
// altToPred[uniqueAlt] is now our validating predicate (if any)
|
// altToPred[uniqueAlt] is now our validating predicate (if any)
|
||||||
|
@ -1155,7 +1156,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
return predPredictions;
|
return predPredictions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual SemanticContext[] GetPredsForAmbigAlts(BitSet ambigAlts, ATNConfigSet
|
public virtual SemanticContext[] GetPredsForAmbigAlts(BitArray ambigAlts, ATNConfigSet
|
||||||
configs, int nalts)
|
configs, int nalts)
|
||||||
{
|
{
|
||||||
// REACH=[1|1|[]|0:0, 1|2|[]|0:1]
|
// REACH=[1|1|[]|0:0, 1|2|[]|0:1]
|
||||||
|
@ -1192,7 +1193,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
return altToPred;
|
return altToPred;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual DFAState.PredPrediction[] GetPredicatePredictions(BitSet ambigAlts
|
public virtual DFAState.PredPrediction[] GetPredicatePredictions(BitArray ambigAlts
|
||||||
, SemanticContext[] altToPred)
|
, SemanticContext[] altToPred)
|
||||||
{
|
{
|
||||||
IList<DFAState.PredPrediction> pairs = new List<DFAState.PredPrediction>();
|
IList<DFAState.PredPrediction> pairs = new List<DFAState.PredPrediction>();
|
||||||
|
@ -1240,10 +1241,10 @@ namespace Antlr4.Runtime.Atn
|
||||||
/// predicate indicates an alt containing an
|
/// predicate indicates an alt containing an
|
||||||
/// unpredicated config which behaves as "always true."
|
/// unpredicated config which behaves as "always true."
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public virtual BitSet EvalSemanticContext(DFAState.PredPrediction[] predPredictions
|
public virtual BitArray EvalSemanticContext(DFAState.PredPrediction[] predPredictions
|
||||||
, ParserRuleContext outerContext, bool complete)
|
, ParserRuleContext outerContext, bool complete)
|
||||||
{
|
{
|
||||||
BitSet predictions = new BitSet();
|
BitArray predictions = new BitArray();
|
||||||
foreach (DFAState.PredPrediction pair in predPredictions)
|
foreach (DFAState.PredPrediction pair in predPredictions)
|
||||||
{
|
{
|
||||||
if (pair.pred == null)
|
if (pair.pred == null)
|
||||||
|
@ -1614,7 +1615,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
private static readonly IComparer<ATNConfig> StateAltSortComparator = new _IComparer_1557
|
private static readonly IComparer<ATNConfig> StateAltSortComparator = new _IComparer_1557
|
||||||
();
|
();
|
||||||
|
|
||||||
private BitSet IsConflicted(ATNConfigSet configset, PredictionContextCache contextCache
|
private BitArray IsConflicted(ATNConfigSet configset, PredictionContextCache contextCache
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (configset.GetUniqueAlt() != ATN.InvalidAltNumber || configset.Count <= 1)
|
if (configset.GetUniqueAlt() != ATN.InvalidAltNumber || configset.Count <= 1)
|
||||||
|
@ -1625,7 +1626,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
configs.Sort(StateAltSortComparator);
|
configs.Sort(StateAltSortComparator);
|
||||||
bool exact = !configset.GetDipsIntoOuterContext() && predictionMode == PredictionMode
|
bool exact = !configset.GetDipsIntoOuterContext() && predictionMode == PredictionMode
|
||||||
.LlExactAmbigDetection;
|
.LlExactAmbigDetection;
|
||||||
BitSet alts = new BitSet();
|
BitArray alts = new BitArray();
|
||||||
int minAlt = configs[0].GetAlt();
|
int minAlt = configs[0].GetAlt();
|
||||||
alts.Set(minAlt);
|
alts.Set(minAlt);
|
||||||
// quick check 1 & 2 => if we assume #1 holds and check #2 against the
|
// quick check 1 & 2 => if we assume #1 holds and check #2 against the
|
||||||
|
@ -1645,12 +1646,12 @@ namespace Antlr4.Runtime.Atn
|
||||||
currentState = stateNumber;
|
currentState = stateNumber;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BitSet representedAlts = null;
|
BitArray representedAlts = null;
|
||||||
if (exact)
|
if (exact)
|
||||||
{
|
{
|
||||||
currentState = configs[0].GetState().GetNonStopStateNumber();
|
currentState = configs[0].GetState().GetNonStopStateNumber();
|
||||||
// get the represented alternatives of the first state
|
// get the represented alternatives of the first state
|
||||||
representedAlts = new BitSet();
|
representedAlts = new BitArray();
|
||||||
int maxAlt = minAlt;
|
int maxAlt = minAlt;
|
||||||
for (int i_1 = 0; i_1 < configs.Count; i_1++)
|
for (int i_1 = 0; i_1 < configs.Count; i_1++)
|
||||||
{
|
{
|
||||||
|
@ -1801,19 +1802,19 @@ namespace Antlr4.Runtime.Atn
|
||||||
return alts;
|
return alts;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected internal virtual BitSet GetConflictingAltsFromConfigSet(ATNConfigSet configs
|
protected internal virtual BitArray GetConflictingAltsFromConfigSet(ATNConfigSet
|
||||||
)
|
configs)
|
||||||
{
|
{
|
||||||
BitSet conflictingAlts = configs.GetConflictingAlts();
|
BitArray conflictingAlts = configs.GetConflictingAlts();
|
||||||
if (conflictingAlts == null && configs.GetUniqueAlt() != ATN.InvalidAltNumber)
|
if (conflictingAlts == null && configs.GetUniqueAlt() != ATN.InvalidAltNumber)
|
||||||
{
|
{
|
||||||
conflictingAlts = new BitSet();
|
conflictingAlts = new BitArray();
|
||||||
conflictingAlts.Set(configs.GetUniqueAlt());
|
conflictingAlts.Set(configs.GetUniqueAlt());
|
||||||
}
|
}
|
||||||
return conflictingAlts;
|
return conflictingAlts;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected internal virtual int ResolveToMinAlt(DFAState D, BitSet conflictingAlts
|
protected internal virtual int ResolveToMinAlt(DFAState D, BitArray conflictingAlts
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// kill dead alts so we don't chase them ever
|
// kill dead alts so we don't chase them ever
|
||||||
|
@ -2115,7 +2116,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
|
|
||||||
/// <summary>If context sensitive parsing, we know it's ambiguity not conflict</summary>
|
/// <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
|
public virtual void ReportAmbiguity(DFA dfa, DFAState D, int startIndex, int stopIndex
|
||||||
, BitSet ambigAlts, ATNConfigSet configs)
|
, BitArray ambigAlts, ATNConfigSet configs)
|
||||||
{
|
{
|
||||||
if (debug || retry_debug)
|
if (debug || retry_debug)
|
||||||
{
|
{
|
||||||
|
|
|
@ -366,8 +366,9 @@ namespace Antlr4.Runtime.Atn
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <seealso cref="ParserATNSimulator.GetPredsForAmbigAlts(Sharpen.BitSet, ATNConfigSet, int)
|
/// <seealso cref="ParserATNSimulator.GetPredsForAmbigAlts(System.Collections.BitArray, ATNConfigSet, int)
|
||||||
/// ">ParserATNSimulator.GetPredsForAmbigAlts(Sharpen.BitSet, ATNConfigSet, int)</seealso>
|
/// ">ParserATNSimulator.GetPredsForAmbigAlts(System.Collections.BitArray, ATNConfigSet, int)
|
||||||
|
/// </seealso>
|
||||||
public static SemanticContext Or(SemanticContext a, SemanticContext b)
|
public static SemanticContext Or(SemanticContext a, SemanticContext b)
|
||||||
{
|
{
|
||||||
if (a == null)
|
if (a == null)
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
using System.Collections;
|
||||||
using Antlr4.Runtime;
|
using Antlr4.Runtime;
|
||||||
using Antlr4.Runtime.Atn;
|
using Antlr4.Runtime.Atn;
|
||||||
using Antlr4.Runtime.Dfa;
|
using Antlr4.Runtime.Dfa;
|
||||||
|
@ -44,7 +45,7 @@ namespace Antlr4.Runtime
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void ReportAmbiguity(Parser recognizer, DFA dfa, int startIndex, int
|
public virtual void ReportAmbiguity(Parser recognizer, DFA dfa, int startIndex, int
|
||||||
stopIndex, BitSet ambigAlts, ATNConfigSet configs)
|
stopIndex, BitArray ambigAlts, ATNConfigSet configs)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Antlr4.Runtime;
|
using Antlr4.Runtime;
|
||||||
|
@ -381,7 +382,7 @@ namespace Antlr4.Runtime
|
||||||
/// if no tokens were found. This
|
/// if no tokens were found. This
|
||||||
/// method looks at both on and off channel tokens.
|
/// method looks at both on and off channel tokens.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual IList<IToken> GetTokens(int start, int stop, BitSet types)
|
public virtual IList<IToken> GetTokens(int start, int stop, BitArray types)
|
||||||
{
|
{
|
||||||
LazyInit();
|
LazyInit();
|
||||||
if (start < 0 || stop >= tokens.Count || stop < 0 || start >= tokens.Count)
|
if (start < 0 || stop >= tokens.Count || stop < 0 || start >= tokens.Count)
|
||||||
|
@ -412,7 +413,7 @@ namespace Antlr4.Runtime
|
||||||
|
|
||||||
public virtual IList<IToken> GetTokens(int start, int stop, int ttype)
|
public virtual IList<IToken> GetTokens(int start, int stop, int ttype)
|
||||||
{
|
{
|
||||||
BitSet s = new BitSet(ttype);
|
BitArray s = new BitArray(ttype);
|
||||||
s.Set(ttype);
|
s.Set(ttype);
|
||||||
return GetTokens(start, stop, s);
|
return GetTokens(start, stop, s);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Antlr4.Runtime.Atn;
|
using Antlr4.Runtime.Atn;
|
||||||
|
@ -111,7 +112,7 @@ namespace Antlr4.Runtime.Dfa
|
||||||
/// <remarks>Symbols in this set require a global context transition before matching an input symbol.
|
/// <remarks>Symbols in this set require a global context transition before matching an input symbol.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Nullable]
|
[Nullable]
|
||||||
private BitSet contextSymbols;
|
private BitArray contextSymbols;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This list is computed by
|
/// This list is computed by
|
||||||
|
@ -190,7 +191,7 @@ namespace Antlr4.Runtime.Dfa
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
contextSymbols = new BitSet();
|
contextSymbols = new BitArray();
|
||||||
contextEdges = new SingletonEdgeMap<DFAState>(-1, atn.states.Count - 1);
|
contextEdges = new SingletonEdgeMap<DFAState>(-1, atn.states.Count - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
using System.Collections;
|
||||||
using Antlr4.Runtime;
|
using Antlr4.Runtime;
|
||||||
using Antlr4.Runtime.Atn;
|
using Antlr4.Runtime.Atn;
|
||||||
using Antlr4.Runtime.Dfa;
|
using Antlr4.Runtime.Dfa;
|
||||||
|
@ -38,7 +39,7 @@ namespace Antlr4.Runtime
|
||||||
public class DiagnosticErrorListener : BaseErrorListener
|
public class DiagnosticErrorListener : BaseErrorListener
|
||||||
{
|
{
|
||||||
public override void ReportAmbiguity(Parser recognizer, DFA dfa, int startIndex,
|
public override void ReportAmbiguity(Parser recognizer, DFA dfa, int startIndex,
|
||||||
int stopIndex, BitSet ambigAlts, ATNConfigSet configs)
|
int stopIndex, BitArray ambigAlts, ATNConfigSet configs)
|
||||||
{
|
{
|
||||||
string format = "reportAmbiguity d=%s: ambigAlts=%s, input='%s'";
|
string format = "reportAmbiguity d=%s: ambigAlts=%s, input='%s'";
|
||||||
recognizer.NotifyErrorListeners(string.Format(format, GetDecisionDescription(recognizer
|
recognizer.NotifyErrorListeners(string.Format(format, GetDecisionDescription(recognizer
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
using System.Collections;
|
||||||
using Antlr4.Runtime;
|
using Antlr4.Runtime;
|
||||||
using Antlr4.Runtime.Atn;
|
using Antlr4.Runtime.Atn;
|
||||||
using Antlr4.Runtime.Dfa;
|
using Antlr4.Runtime.Dfa;
|
||||||
|
@ -49,7 +50,7 @@ namespace Antlr4.Runtime
|
||||||
/// that can match the input sequence. This method is only called when we are parsing with
|
/// that can match the input sequence. This method is only called when we are parsing with
|
||||||
/// full context.
|
/// full context.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
void ReportAmbiguity(Parser recognizer, DFA dfa, int startIndex, int stopIndex, BitSet
|
void ReportAmbiguity(Parser recognizer, DFA dfa, int startIndex, int stopIndex, BitArray
|
||||||
ambigAlts, ATNConfigSet configs);
|
ambigAlts, ATNConfigSet configs);
|
||||||
|
|
||||||
void ReportAttemptingFullContext(Parser recognizer, DFA dfa, int startIndex, int
|
void ReportAttemptingFullContext(Parser recognizer, DFA dfa, int startIndex, int
|
||||||
|
|
|
@ -171,12 +171,12 @@ namespace Antlr4.Runtime.Misc
|
||||||
EnumSet<Dependents> dependents = EnumSet.Of(Dependents.Self, dependency.GetItem1(
|
EnumSet<Dependents> dependents = EnumSet.Of(Dependents.Self, dependency.GetItem1(
|
||||||
).Dependents());
|
).Dependents());
|
||||||
ReportUnimplementedDependents(dependency, dependents);
|
ReportUnimplementedDependents(dependency, dependents);
|
||||||
BitSet checked = new BitSet();
|
BitArray checked = new BitArray();
|
||||||
int highestRequiredDependency = CheckDependencyVersion(dependency, ruleNames, ruleVersions
|
int highestRequiredDependency = CheckDependencyVersion(dependency, ruleNames, ruleVersions
|
||||||
, effectiveRule, null);
|
, effectiveRule, null);
|
||||||
if (dependents.Contains(Dependents.Parents))
|
if (dependents.Contains(Dependents.Parents))
|
||||||
{
|
{
|
||||||
BitSet parents = relations.parents[dependency.GetItem1().Rule()];
|
BitArray parents = relations.parents[dependency.GetItem1().Rule()];
|
||||||
for (int parent = parents.NextSetBit(0); parent >= 0; parent = parents.NextSetBit
|
for (int parent = parents.NextSetBit(0); parent >= 0; parent = parents.NextSetBit
|
||||||
(parent + 1))
|
(parent + 1))
|
||||||
{
|
{
|
||||||
|
@ -192,7 +192,7 @@ namespace Antlr4.Runtime.Misc
|
||||||
}
|
}
|
||||||
if (dependents.Contains(Dependents.Children))
|
if (dependents.Contains(Dependents.Children))
|
||||||
{
|
{
|
||||||
BitSet children = relations.children[dependency.GetItem1().Rule()];
|
BitArray children = relations.children[dependency.GetItem1().Rule()];
|
||||||
for (int child = children.NextSetBit(0); child >= 0; child = children.NextSetBit(
|
for (int child = children.NextSetBit(0); child >= 0; child = children.NextSetBit(
|
||||||
child + 1))
|
child + 1))
|
||||||
{
|
{
|
||||||
|
@ -208,7 +208,7 @@ namespace Antlr4.Runtime.Misc
|
||||||
}
|
}
|
||||||
if (dependents.Contains(Dependents.Ancestors))
|
if (dependents.Contains(Dependents.Ancestors))
|
||||||
{
|
{
|
||||||
BitSet ancestors = relations.GetAncestors(dependency.GetItem1().Rule());
|
BitArray ancestors = relations.GetAncestors(dependency.GetItem1().Rule());
|
||||||
for (int ancestor = ancestors.NextSetBit(0); ancestor >= 0; ancestor = ancestors.
|
for (int ancestor = ancestors.NextSetBit(0); ancestor >= 0; ancestor = ancestors.
|
||||||
NextSetBit(ancestor + 1))
|
NextSetBit(ancestor + 1))
|
||||||
{
|
{
|
||||||
|
@ -224,7 +224,7 @@ namespace Antlr4.Runtime.Misc
|
||||||
}
|
}
|
||||||
if (dependents.Contains(Dependents.Descendants))
|
if (dependents.Contains(Dependents.Descendants))
|
||||||
{
|
{
|
||||||
BitSet descendants = relations.GetDescendants(dependency.GetItem1().Rule());
|
BitArray descendants = relations.GetDescendants(dependency.GetItem1().Rule());
|
||||||
for (int descendant = descendants.NextSetBit(0); descendant >= 0; descendant = descendants
|
for (int descendant = descendants.NextSetBit(0); descendant >= 0; descendant = descendants
|
||||||
.NextSetBit(descendant + 1))
|
.NextSetBit(descendant + 1))
|
||||||
{
|
{
|
||||||
|
@ -782,21 +782,21 @@ namespace Antlr4.Runtime.Misc
|
||||||
|
|
||||||
private sealed class RuleRelations
|
private sealed class RuleRelations
|
||||||
{
|
{
|
||||||
private readonly BitSet[] parents;
|
private readonly BitArray[] parents;
|
||||||
|
|
||||||
private readonly BitSet[] children;
|
private readonly BitArray[] children;
|
||||||
|
|
||||||
public RuleRelations(int ruleCount)
|
public RuleRelations(int ruleCount)
|
||||||
{
|
{
|
||||||
parents = new BitSet[ruleCount];
|
parents = new BitArray[ruleCount];
|
||||||
for (int i = 0; i < ruleCount; i++)
|
for (int i = 0; i < ruleCount; i++)
|
||||||
{
|
{
|
||||||
parents[i] = new BitSet();
|
parents[i] = new BitArray();
|
||||||
}
|
}
|
||||||
children = new BitSet[ruleCount];
|
children = new BitArray[ruleCount];
|
||||||
for (int i_1 = 0; i_1 < ruleCount; i_1++)
|
for (int i_1 = 0; i_1 < ruleCount; i_1++)
|
||||||
{
|
{
|
||||||
children[i_1] = new BitSet();
|
children[i_1] = new BitArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -817,9 +817,9 @@ namespace Antlr4.Runtime.Misc
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BitSet GetAncestors(int rule)
|
public BitArray GetAncestors(int rule)
|
||||||
{
|
{
|
||||||
BitSet ancestors = new BitSet();
|
BitArray ancestors = new BitArray();
|
||||||
ancestors.Or(parents[rule]);
|
ancestors.Or(parents[rule]);
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
@ -837,9 +837,9 @@ namespace Antlr4.Runtime.Misc
|
||||||
return ancestors;
|
return ancestors;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BitSet GetDescendants(int rule)
|
public BitArray GetDescendants(int rule)
|
||||||
{
|
{
|
||||||
BitSet descendants = new BitSet();
|
BitArray descendants = new BitArray();
|
||||||
descendants.Or(children[rule]);
|
descendants.Or(children[rule]);
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Antlr4.Runtime;
|
using Antlr4.Runtime;
|
||||||
using Antlr4.Runtime.Atn;
|
using Antlr4.Runtime.Atn;
|
||||||
|
@ -44,7 +45,7 @@ namespace Antlr4.Runtime
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void ReportAmbiguity(Parser recognizer, DFA dfa, int startIndex, int
|
public virtual void ReportAmbiguity(Parser recognizer, DFA dfa, int startIndex, int
|
||||||
stopIndex, BitSet ambigAlts, ATNConfigSet configs)
|
stopIndex, BitArray ambigAlts, ATNConfigSet configs)
|
||||||
{
|
{
|
||||||
foreach (IAntlrErrorListener<IToken> listener in GetDelegates())
|
foreach (IAntlrErrorListener<IToken> listener in GetDelegates())
|
||||||
{
|
{
|
||||||
|
|
|
@ -115,6 +115,7 @@
|
||||||
-typeMapping java.net.InetAddress System.Net.IPAddress
|
-typeMapping java.net.InetAddress System.Net.IPAddress
|
||||||
-typeMapping java.util.TimeZone System.TimeZoneInfo
|
-typeMapping java.util.TimeZone System.TimeZoneInfo
|
||||||
-typeMapping java.util.ArrayList<> System.Collections.Generic.List
|
-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.Inflater ICSharpCode.SharpZipLib.Zip.Compression.Inflater
|
||||||
-typeMapping java.util.zip.Deflater ICSharpCode.SharpZipLib.Zip.Compression.Deflater
|
-typeMapping java.util.zip.Deflater ICSharpCode.SharpZipLib.Zip.Compression.Deflater
|
||||||
-typeMapping java.util.zip.ZipException ICSharpCode.SharpZipLib.SharpZipBaseException
|
-typeMapping java.util.zip.ZipException ICSharpCode.SharpZipLib.SharpZipBaseException
|
||||||
|
@ -131,7 +132,7 @@
|
||||||
-typeMapping java.net.SocketAddress System.Net.EndPoint
|
-typeMapping java.net.SocketAddress System.Net.EndPoint
|
||||||
-typeMapping java.net.Socket System.Net.Sockets.Socket
|
-typeMapping java.net.Socket System.Net.Sockets.Socket
|
||||||
-typeMapping java.net.ServerSocket System.Net.Sockets.Socket
|
-typeMapping java.net.ServerSocket System.Net.Sockets.Socket
|
||||||
-typeMapping java.math.BigInteger Mono.Math.BigInteger
|
-typeMapping java.math.BigInteger System.Numerics.BigInteger
|
||||||
-typeMapping java.util.Properties Sharpen.Properties
|
-typeMapping java.util.Properties Sharpen.Properties
|
||||||
-typeMapping java.util.concurrent.Semaphore System.Threading.Semaphore
|
-typeMapping java.util.concurrent.Semaphore System.Threading.Semaphore
|
||||||
-typeMapping java.util.Enumeration System.Collections.Generic.IEnumeration
|
-typeMapping java.util.Enumeration System.Collections.Generic.IEnumeration
|
||||||
|
|
Loading…
Reference in New Issue