forked from jasder/antlr
Updated mappings
This commit is contained in:
parent
e0044cc4dd
commit
d676aa8c4c
|
@ -27,6 +27,7 @@
|
|||
* (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.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using Antlr4.Runtime.Atn;
|
||||
using Antlr4.Runtime.Dfa;
|
||||
|
@ -81,8 +82,8 @@ namespace Antlr4.Runtime.Atn
|
|||
/// <summary>used during construction from grammar AST</summary>
|
||||
internal int stateNumber = 0;
|
||||
|
||||
private readonly IConcurrentMap<PredictionContext, PredictionContext> contextCache
|
||||
= new ConcurrentHashMap<PredictionContext, PredictionContext>();
|
||||
private readonly ConcurrentDictionary<PredictionContext, PredictionContext> contextCache
|
||||
= new ConcurrentDictionary<PredictionContext, PredictionContext>();
|
||||
|
||||
[NotNull]
|
||||
public DFA[] decisionToDFA = new DFA[0];
|
||||
|
@ -90,7 +91,7 @@ namespace Antlr4.Runtime.Atn
|
|||
[NotNull]
|
||||
public DFA[] modeToDFA = new DFA[0];
|
||||
|
||||
protected internal readonly IConcurrentMap<int, int> LL1Table = new ConcurrentHashMap
|
||||
protected internal readonly ConcurrentDictionary<int, int> LL1Table = new ConcurrentDictionary
|
||||
<int, int>();
|
||||
|
||||
/// <summary>Used for runtime deserialization of ATNs from strings</summary>
|
||||
|
|
|
@ -396,10 +396,11 @@ namespace Antlr4.Runtime.Atn
|
|||
PredictionContext current = workList.Pop();
|
||||
for (int i = 0; i < current.Size; i++)
|
||||
{
|
||||
builder.Append(" s").Append(Sharpen.Runtime.IdentityHashCode(current));
|
||||
builder.Append(" s").Append(System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode
|
||||
(current));
|
||||
builder.Append("->");
|
||||
builder.Append("s").Append(Sharpen.Runtime.IdentityHashCode(current.GetParent(i))
|
||||
);
|
||||
builder.Append("s").Append(System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode
|
||||
(current.GetParent(i)));
|
||||
builder.Append("[label=\"").Append(current.GetReturnState(i)).Append("\"];\n");
|
||||
if (visited.Put(current.GetParent(i), current.GetParent(i)) == null)
|
||||
{
|
||||
|
|
|
@ -38,7 +38,7 @@ using Sharpen;
|
|||
namespace Antlr4.Runtime.Atn
|
||||
{
|
||||
/// <author>Sam Harwell</author>
|
||||
public class ATNConfigSet : ICollection<ATNConfig>
|
||||
public class ATNConfigSet : ISet<ATNConfig>
|
||||
{
|
||||
/// <summary>
|
||||
/// This maps (state, alt) -> merged
|
||||
|
@ -224,9 +224,9 @@ namespace Antlr4.Runtime.Atn
|
|||
this.outermostConfigSet = outermostConfigSet;
|
||||
}
|
||||
|
||||
public virtual ICollection<ATNState> GetStates()
|
||||
public virtual ISet<ATNState> GetStates()
|
||||
{
|
||||
ICollection<ATNState> states = new HashSet<ATNState>();
|
||||
ISet<ATNState> states = new HashSet<ATNState>();
|
||||
foreach (ATNConfig c in this.configs)
|
||||
{
|
||||
states.AddItem(c.GetState());
|
||||
|
|
|
@ -137,11 +137,11 @@ namespace Antlr4.Runtime.Atn
|
|||
// delay the assignment of loop back and end states until we know all the state instances have been initialized
|
||||
foreach (Tuple<LoopEndState, int> pair in loopBackStateNumbers)
|
||||
{
|
||||
pair.GetItem1().loopBackState = atn.states[pair.GetItem2()];
|
||||
pair.Item1.loopBackState = atn.states[pair.Item2];
|
||||
}
|
||||
foreach (Tuple<BlockStartState, int> pair_1 in endStateNumbers)
|
||||
{
|
||||
pair_1.GetItem1().endState = (BlockEndState)atn.states[pair_1.GetItem2()];
|
||||
pair_1.Item1.endState = (BlockEndState)atn.states[pair_1.Item2];
|
||||
}
|
||||
int numNonGreedyStates = ToInt(data[p++]);
|
||||
for (int i_2 = 0; i_2 < numNonGreedyStates; i_2++)
|
||||
|
|
|
@ -228,8 +228,8 @@ namespace Antlr4.Runtime.Atn
|
|||
>());
|
||||
}
|
||||
|
||||
private bool Equals(Antlr4.Runtime.Atn.ArrayPredictionContext other, ICollection<
|
||||
PredictionContextCache.IdentityCommutativePredictionContextOperands> visited)
|
||||
private bool Equals(Antlr4.Runtime.Atn.ArrayPredictionContext other, ISet<PredictionContextCache.IdentityCommutativePredictionContextOperands
|
||||
> visited)
|
||||
{
|
||||
IDeque<PredictionContext> selfWorkList = new ArrayDeque<PredictionContext>();
|
||||
IDeque<PredictionContext> otherWorkList = new ArrayDeque<PredictionContext>();
|
||||
|
|
|
@ -74,7 +74,7 @@ namespace Antlr4.Runtime.Atn
|
|||
for (int alt = 1; alt <= s.NumberOfTransitions; alt++)
|
||||
{
|
||||
look[alt] = new IntervalSet();
|
||||
ICollection<ATNConfig> lookBusy = new HashSet<ATNConfig>();
|
||||
ISet<ATNConfig> lookBusy = new HashSet<ATNConfig>();
|
||||
bool seeThruPreds = false;
|
||||
// fail to get lookahead upon pred
|
||||
Look(s.Transition(alt - 1).target, PredictionContext.EmptyFull, look[alt], lookBusy
|
||||
|
@ -138,7 +138,7 @@ namespace Antlr4.Runtime.Atn
|
|||
/// indicating we reached the end of the ruled out having to match a token.
|
||||
/// </remarks>
|
||||
protected internal virtual void Look(ATNState s, PredictionContext ctx, IntervalSet
|
||||
look, ICollection<ATNConfig> lookBusy, bool seeThruPreds, bool addEOF)
|
||||
look, ISet<ATNConfig> lookBusy, bool seeThruPreds, bool addEOF)
|
||||
{
|
||||
// System.out.println("_LOOK("+s.stateNumber+", ctx="+ctx);
|
||||
ATNConfig c = ATNConfig.Create(s, 0, ctx);
|
||||
|
|
|
@ -1286,7 +1286,7 @@ namespace Antlr4.Runtime.Atn
|
|||
contextCache = PredictionContextCache.Uncached;
|
||||
}
|
||||
ATNConfigSet currentConfigs = sourceConfigs;
|
||||
ICollection<ATNConfig> closureBusy = new HashSet<ATNConfig>();
|
||||
ISet<ATNConfig> closureBusy = new HashSet<ATNConfig>();
|
||||
while (currentConfigs.Count > 0)
|
||||
{
|
||||
ATNConfigSet intermediate = new ATNConfigSet();
|
||||
|
@ -1304,8 +1304,8 @@ namespace Antlr4.Runtime.Atn
|
|||
}
|
||||
|
||||
protected internal virtual void Closure(ATNConfig config, ATNConfigSet configs, ATNConfigSet
|
||||
intermediate, ICollection<ATNConfig> closureBusy, bool collectPredicates, bool
|
||||
hasMoreContexts, PredictionContextCache contextCache, int depth)
|
||||
intermediate, ISet<ATNConfig> closureBusy, bool collectPredicates, bool hasMoreContexts
|
||||
, PredictionContextCache contextCache, int depth)
|
||||
{
|
||||
if (!optimize_closure_busy && !closureBusy.AddItem(config))
|
||||
{
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
* (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.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Antlr4.Runtime;
|
||||
|
@ -339,7 +340,7 @@ namespace Antlr4.Runtime.Atn
|
|||
}
|
||||
|
||||
public static Antlr4.Runtime.Atn.PredictionContext GetCachedContext(Antlr4.Runtime.Atn.PredictionContext
|
||||
context, IConcurrentMap<Antlr4.Runtime.Atn.PredictionContext, Antlr4.Runtime.Atn.PredictionContext
|
||||
context, ConcurrentDictionary<Antlr4.Runtime.Atn.PredictionContext, Antlr4.Runtime.Atn.PredictionContext
|
||||
> contextCache, PredictionContext.IdentityHashMap visited)
|
||||
{
|
||||
if (context.IsEmpty)
|
||||
|
|
|
@ -202,7 +202,7 @@ namespace Antlr4.Runtime.Atn
|
|||
|
||||
public AND(SemanticContext a, SemanticContext b)
|
||||
{
|
||||
ICollection<SemanticContext> operands = new HashSet<SemanticContext>();
|
||||
ISet<SemanticContext> operands = new HashSet<SemanticContext>();
|
||||
if (a is SemanticContext.AND)
|
||||
{
|
||||
Sharpen.Collections.AddAll(operands, Arrays.AsList(((SemanticContext.AND)a).opnds
|
||||
|
@ -278,7 +278,7 @@ namespace Antlr4.Runtime.Atn
|
|||
|
||||
public OR(SemanticContext a, SemanticContext b)
|
||||
{
|
||||
ICollection<SemanticContext> operands = new HashSet<SemanticContext>();
|
||||
ISet<SemanticContext> operands = new HashSet<SemanticContext>();
|
||||
if (a is SemanticContext.OR)
|
||||
{
|
||||
Sharpen.Collections.AddAll(operands, Arrays.AsList(((SemanticContext.OR)a).opnds)
|
||||
|
|
|
@ -82,10 +82,10 @@ namespace Antlr4.Runtime
|
|||
this.channel = channel;
|
||||
this.start = start;
|
||||
this.stop = stop;
|
||||
if (source.GetItem1() != null)
|
||||
if (source.Item1 != null)
|
||||
{
|
||||
this.line = source.GetItem1().Line;
|
||||
this.charPositionInLine = source.GetItem1().Column;
|
||||
this.line = source.Item1.Line;
|
||||
this.charPositionInLine = source.Item1.Column;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,7 +248,7 @@ namespace Antlr4.Runtime
|
|||
{
|
||||
get
|
||||
{
|
||||
return source.GetItem1();
|
||||
return source.Item1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -256,7 +256,7 @@ namespace Antlr4.Runtime
|
|||
{
|
||||
get
|
||||
{
|
||||
return source.GetItem2();
|
||||
return source.Item2;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,9 +77,9 @@ namespace Antlr4.Runtime
|
|||
}
|
||||
else
|
||||
{
|
||||
if (copyText && source.GetItem2() != null)
|
||||
if (copyText && source.Item2 != null)
|
||||
{
|
||||
t.Text = source.GetItem2().GetText(Interval.Of(start, stop));
|
||||
t.Text = source.Item2.GetText(Interval.Of(start, stop));
|
||||
}
|
||||
}
|
||||
return t;
|
||||
|
|
|
@ -104,7 +104,7 @@ namespace Antlr4.Runtime.Dfa
|
|||
|
||||
public abstract bool ContainsKey(int arg1);
|
||||
|
||||
public abstract ICollection<KeyValuePair<int, T>> EntrySet();
|
||||
public abstract ISet<KeyValuePair<int, T>> EntrySet();
|
||||
|
||||
public abstract T Get(int arg1);
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ namespace Antlr4.Runtime.Dfa
|
|||
return result;
|
||||
}
|
||||
|
||||
public override ICollection<KeyValuePair<int, T>> EntrySet()
|
||||
public override ISet<KeyValuePair<int, T>> EntrySet()
|
||||
{
|
||||
return new ArrayEdgeMap.EntrySet(this);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
* (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.Concurrent;
|
||||
using Antlr4.Runtime.Atn;
|
||||
using Antlr4.Runtime.Dfa;
|
||||
using Antlr4.Runtime.Misc;
|
||||
|
@ -47,7 +48,7 @@ namespace Antlr4.Runtime.Dfa
|
|||
/// only allows you to see if it's there).
|
||||
/// </remarks>
|
||||
[NotNull]
|
||||
public readonly IConcurrentMap<DFAState, DFAState> states = new ConcurrentHashMap
|
||||
public readonly ConcurrentDictionary<DFAState, DFAState> states = new ConcurrentDictionary
|
||||
<DFAState, DFAState>();
|
||||
|
||||
[Nullable]
|
||||
|
|
|
@ -62,6 +62,6 @@ namespace Antlr4.Runtime.Dfa
|
|||
IDictionary<int, T> ToMap();
|
||||
|
||||
[NotNull]
|
||||
ICollection<KeyValuePair<int, T>> EntrySet();
|
||||
ISet<KeyValuePair<int, T>> EntrySet();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ namespace Antlr4.Runtime.Dfa
|
|||
return Sharpen.Collections.SingletonMap(key, value);
|
||||
}
|
||||
|
||||
public override ICollection<KeyValuePair<int, T>> EntrySet()
|
||||
public override ISet<KeyValuePair<int, T>> EntrySet()
|
||||
{
|
||||
return new SingletonEdgeMap.EntrySet(this);
|
||||
}
|
||||
|
|
|
@ -204,7 +204,7 @@ namespace Antlr4.Runtime.Dfa
|
|||
return result;
|
||||
}
|
||||
|
||||
public override ICollection<KeyValuePair<int, T>> EntrySet()
|
||||
public override ISet<KeyValuePair<int, T>> EntrySet()
|
||||
{
|
||||
return new SparseEdgeMap.EntrySet(this);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace Antlr4.Runtime.Misc
|
|||
/// <see cref="Sharpen.ISet{E}">Sharpen.ISet<E></see>
|
||||
/// implementation with closed hashing (open addressing).
|
||||
/// </summary>
|
||||
public class Array2DHashSet<T> : ICollection<T>
|
||||
public class Array2DHashSet<T> : ISet<T>
|
||||
{
|
||||
public const int InitalCapacity = 16;
|
||||
|
||||
|
|
|
@ -89,13 +89,13 @@ namespace Antlr4.Runtime.Misc
|
|||
}
|
||||
|
||||
/// <summary>get all primary keys</summary>
|
||||
public virtual ICollection<Key1> KeySet()
|
||||
public virtual ISet<Key1> KeySet()
|
||||
{
|
||||
return data.Keys;
|
||||
}
|
||||
|
||||
/// <summary>get all secondary keys associated with a primary key</summary>
|
||||
public virtual ICollection<Key2> KeySet(Key1 k1)
|
||||
public virtual ISet<Key2> KeySet(Key1 k1)
|
||||
{
|
||||
IDictionary<Key2, Value> data2 = data.Get(k1);
|
||||
if (data2 == null)
|
||||
|
|
|
@ -189,7 +189,7 @@ namespace Antlr4.Runtime.Misc
|
|||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public virtual ICollection<K> Keys
|
||||
public virtual ISet<K> Keys
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -217,7 +217,7 @@ namespace Antlr4.Runtime.Misc
|
|||
}
|
||||
}
|
||||
|
||||
public virtual ICollection<KeyValuePair<K, V>> EntrySet()
|
||||
public virtual ISet<KeyValuePair<K, V>> EntrySet()
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
|
|
@ -740,9 +740,9 @@ namespace Antlr4.Runtime.Misc
|
|||
return values;
|
||||
}
|
||||
|
||||
public virtual ICollection<int> ToSet()
|
||||
public virtual ISet<int> ToSet()
|
||||
{
|
||||
ICollection<int> s = new HashSet<int>();
|
||||
ISet<int> s = new HashSet<int>();
|
||||
foreach (Interval I in intervals)
|
||||
{
|
||||
int a = I.a;
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace Antlr4.Runtime.Misc
|
|||
private static readonly Logger Logger = Logger.GetLogger(typeof(Antlr4.Runtime.Misc.RuleDependencyChecker
|
||||
).FullName);
|
||||
|
||||
private static readonly ICollection<Type> checkedTypes = new HashSet<Type>();
|
||||
private static readonly ISet<Type> checkedTypes = new HashSet<Type>();
|
||||
|
||||
public static void CheckDependencies<_T0>(Type<_T0> dependentClass)
|
||||
{
|
||||
|
@ -69,7 +69,7 @@ namespace Antlr4.Runtime.Misc
|
|||
{
|
||||
continue;
|
||||
}
|
||||
CheckDependencies(dependencies, dependencies[0].GetItem1().Recognizer());
|
||||
CheckDependencies(dependencies, dependencies[0].Item1.Recognizer());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,25 +98,24 @@ namespace Antlr4.Runtime.Misc
|
|||
StringBuilder incompatible = new StringBuilder();
|
||||
foreach (Tuple<RuleDependency, IAnnotatedElement> dependency in dependencies)
|
||||
{
|
||||
if (!recognizerClass.IsAssignableFrom(dependency.GetItem1().Recognizer()))
|
||||
if (!recognizerClass.IsAssignableFrom(dependency.Item1.Recognizer()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (dependency.GetItem1().Rule() < 0 || dependency.GetItem1().Rule() >= ruleVersions
|
||||
.Length)
|
||||
if (dependency.Item1.Rule() < 0 || dependency.Item1.Rule() >= ruleVersions.Length)
|
||||
{
|
||||
incompatible.Append(string.Format("Element %s dependent on unknown rule %d@%d in %s\n"
|
||||
, dependency.GetItem2().ToString(), dependency.GetItem1().Rule(), dependency.
|
||||
GetItem1().Version(), dependency.GetItem1().Recognizer().Name));
|
||||
, dependency.Item2.ToString(), dependency.Item1.Rule(), dependency.Item1.Version
|
||||
(), dependency.Item1.Recognizer().Name));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ruleVersions[dependency.GetItem1().Rule()] != dependency.GetItem1().Version())
|
||||
if (ruleVersions[dependency.Item1.Rule()] != dependency.Item1.Version())
|
||||
{
|
||||
incompatible.Append(string.Format("Element %s dependent on rule %s@%d (found @%d) in %s\n"
|
||||
, dependency.GetItem2().ToString(), ruleNames[dependency.GetItem1().Rule()],
|
||||
dependency.GetItem1().Version(), ruleVersions[dependency.GetItem1().Rule()],
|
||||
dependency.GetItem1().Recognizer().Name));
|
||||
, dependency.Item2.ToString(), ruleNames[dependency.Item1.Rule()], dependency
|
||||
.Item1.Version(), ruleVersions[dependency.Item1.Rule()], dependency.Item1.Recognizer
|
||||
().Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,8 +59,8 @@ namespace Antlr4.Runtime.Misc
|
|||
{
|
||||
}
|
||||
|
||||
public override bool Process<_T0>(ICollection<_T0> annotations, IRoundEnvironment
|
||||
roundEnv)
|
||||
public override bool Process<_T0>(ISet<_T0> annotations, IRoundEnvironment roundEnv
|
||||
)
|
||||
{
|
||||
if (!CheckClassNameConstants())
|
||||
{
|
||||
|
@ -71,7 +71,7 @@ namespace Antlr4.Runtime.Misc
|
|||
= new Dictionary<ITypeMirror, IList<Tuple<RuleDependency, IElement>>>();
|
||||
foreach (Tuple<RuleDependency, IElement> dependency in dependencies)
|
||||
{
|
||||
ITypeMirror recognizerType = GetRecognizerType(dependency.GetItem1());
|
||||
ITypeMirror recognizerType = GetRecognizerType(dependency.Item1);
|
||||
IList<Tuple<RuleDependency, IElement>> list = recognizerDependencies.Get(recognizerType
|
||||
);
|
||||
if (list == null)
|
||||
|
@ -141,42 +141,41 @@ namespace Antlr4.Runtime.Misc
|
|||
{
|
||||
try
|
||||
{
|
||||
if (!processingEnv.GetTypeUtils().IsAssignable(GetRecognizerType(dependency.GetItem1
|
||||
()), recognizerType))
|
||||
if (!processingEnv.GetTypeUtils().IsAssignable(GetRecognizerType(dependency.Item1
|
||||
), recognizerType))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// this is the rule in the dependency set with the highest version number
|
||||
int effectiveRule = dependency.GetItem1().Rule();
|
||||
int effectiveRule = dependency.Item1.Rule();
|
||||
if (effectiveRule < 0 || effectiveRule >= ruleVersions.Length)
|
||||
{
|
||||
Tuple<IAnnotationMirror, IAnnotationValue> ruleReferenceElement = FindRuleDependencyProperty
|
||||
(dependency, RuleDependencyProcessor.RuleDependencyProperty.Rule);
|
||||
string message = string.Format("Rule dependency on unknown rule %d@%d in %s", dependency
|
||||
.GetItem1().Rule(), dependency.GetItem1().Version(), GetRecognizerType(dependency
|
||||
.GetItem1()).ToString());
|
||||
.Item1.Rule(), dependency.Item1.Version(), GetRecognizerType(dependency.Item1
|
||||
).ToString());
|
||||
if (ruleReferenceElement != null)
|
||||
{
|
||||
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Error, message, dependency
|
||||
.GetItem2(), ruleReferenceElement.GetItem1(), ruleReferenceElement.GetItem2()
|
||||
);
|
||||
.Item2, ruleReferenceElement.Item1, ruleReferenceElement.Item2);
|
||||
}
|
||||
else
|
||||
{
|
||||
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Error, message, dependency
|
||||
.GetItem2());
|
||||
.Item2);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
EnumSet<Dependents> dependents = EnumSet.Of(Dependents.Self, dependency.GetItem1(
|
||||
).Dependents());
|
||||
EnumSet<Dependents> dependents = EnumSet.Of(Dependents.Self, dependency.Item1.Dependents
|
||||
());
|
||||
ReportUnimplementedDependents(dependency, dependents);
|
||||
BitArray checked = new BitArray();
|
||||
int highestRequiredDependency = CheckDependencyVersion(dependency, ruleNames, ruleVersions
|
||||
, effectiveRule, null);
|
||||
if (dependents.Contains(Dependents.Parents))
|
||||
{
|
||||
BitArray parents = relations.parents[dependency.GetItem1().Rule()];
|
||||
BitArray parents = relations.parents[dependency.Item1.Rule()];
|
||||
for (int parent = parents.NextSetBit(0); parent >= 0; parent = parents.NextSetBit
|
||||
(parent + 1))
|
||||
{
|
||||
|
@ -192,7 +191,7 @@ namespace Antlr4.Runtime.Misc
|
|||
}
|
||||
if (dependents.Contains(Dependents.Children))
|
||||
{
|
||||
BitArray children = relations.children[dependency.GetItem1().Rule()];
|
||||
BitArray children = relations.children[dependency.Item1.Rule()];
|
||||
for (int child = children.NextSetBit(0); child >= 0; child = children.NextSetBit(
|
||||
child + 1))
|
||||
{
|
||||
|
@ -208,7 +207,7 @@ namespace Antlr4.Runtime.Misc
|
|||
}
|
||||
if (dependents.Contains(Dependents.Ancestors))
|
||||
{
|
||||
BitArray ancestors = relations.GetAncestors(dependency.GetItem1().Rule());
|
||||
BitArray ancestors = relations.GetAncestors(dependency.Item1.Rule());
|
||||
for (int ancestor = ancestors.NextSetBit(0); ancestor >= 0; ancestor = ancestors.
|
||||
NextSetBit(ancestor + 1))
|
||||
{
|
||||
|
@ -224,7 +223,7 @@ namespace Antlr4.Runtime.Misc
|
|||
}
|
||||
if (dependents.Contains(Dependents.Descendants))
|
||||
{
|
||||
BitArray descendants = relations.GetDescendants(dependency.GetItem1().Rule());
|
||||
BitArray descendants = relations.GetDescendants(dependency.Item1.Rule());
|
||||
for (int descendant = descendants.NextSetBit(0); descendant >= 0; descendant = descendants
|
||||
.NextSetBit(descendant + 1))
|
||||
{
|
||||
|
@ -239,37 +238,37 @@ namespace Antlr4.Runtime.Misc
|
|||
highestRequiredDependency = Math.Max(highestRequiredDependency, required);
|
||||
}
|
||||
}
|
||||
int declaredVersion = dependency.GetItem1().Version();
|
||||
int declaredVersion = dependency.Item1.Version();
|
||||
if (declaredVersion > highestRequiredDependency)
|
||||
{
|
||||
Tuple<IAnnotationMirror, IAnnotationValue> versionElement = FindRuleDependencyProperty
|
||||
(dependency, RuleDependencyProcessor.RuleDependencyProperty.Version);
|
||||
string message = string.Format("Rule dependency version mismatch: %s has maximum dependency version %d (expected %d) in %s"
|
||||
, ruleNames[dependency.GetItem1().Rule()], highestRequiredDependency, declaredVersion
|
||||
, GetRecognizerType(dependency.GetItem1()).ToString());
|
||||
, ruleNames[dependency.Item1.Rule()], highestRequiredDependency, declaredVersion
|
||||
, GetRecognizerType(dependency.Item1).ToString());
|
||||
if (versionElement != null)
|
||||
{
|
||||
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Error, message, dependency
|
||||
.GetItem2(), versionElement.GetItem1(), versionElement.GetItem2());
|
||||
.Item2, versionElement.Item1, versionElement.Item2);
|
||||
}
|
||||
else
|
||||
{
|
||||
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Error, message, dependency
|
||||
.GetItem2());
|
||||
.Item2);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (AnnotationTypeMismatchException)
|
||||
{
|
||||
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Warning, string.Format("Could not validate rule dependencies for element %s"
|
||||
, dependency.GetItem2().ToString()), dependency.GetItem2());
|
||||
, dependency.Item2.ToString()), dependency.Item2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly ICollection<Dependents> ImplementedDependents = EnumSet.Of
|
||||
(Dependents.Self, Dependents.Parents, Dependents.Children, Dependents.Ancestors
|
||||
, Dependents.Descendants);
|
||||
private static readonly ISet<Dependents> ImplementedDependents = EnumSet.Of(Dependents
|
||||
.Self, Dependents.Parents, Dependents.Children, Dependents.Ancestors, Dependents
|
||||
.Descendants);
|
||||
|
||||
private void ReportUnimplementedDependents(Tuple<RuleDependency, IElement> dependency
|
||||
, EnumSet<Dependents> dependents)
|
||||
|
@ -286,16 +285,16 @@ namespace Antlr4.Runtime.Misc
|
|||
.Rule);
|
||||
}
|
||||
string message = string.Format("Cannot validate the following dependents of rule %d: %s"
|
||||
, dependency.GetItem1().Rule(), unimplemented);
|
||||
, dependency.Item1.Rule(), unimplemented);
|
||||
if (dependentsElement != null)
|
||||
{
|
||||
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Warning, message, dependency
|
||||
.GetItem2(), dependentsElement.GetItem1(), dependentsElement.GetItem2());
|
||||
.Item2, dependentsElement.Item1, dependentsElement.Item2);
|
||||
}
|
||||
else
|
||||
{
|
||||
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Warning, message, dependency
|
||||
.GetItem2());
|
||||
.Item2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -303,7 +302,7 @@ namespace Antlr4.Runtime.Misc
|
|||
private int CheckDependencyVersion(Tuple<RuleDependency, IElement> dependency, string
|
||||
[] ruleNames, int[] ruleVersions, int relatedRule, string relation)
|
||||
{
|
||||
string ruleName = ruleNames[dependency.GetItem1().Rule()];
|
||||
string ruleName = ruleNames[dependency.Item1.Rule()];
|
||||
string path;
|
||||
if (relation == null)
|
||||
{
|
||||
|
@ -315,24 +314,24 @@ namespace Antlr4.Runtime.Misc
|
|||
path = string.Format("rule %s (%s of %s)", mismatchedRuleName, relation, ruleName
|
||||
);
|
||||
}
|
||||
int declaredVersion = dependency.GetItem1().Version();
|
||||
int declaredVersion = dependency.Item1.Version();
|
||||
int actualVersion = ruleVersions[relatedRule];
|
||||
if (actualVersion > declaredVersion)
|
||||
{
|
||||
Tuple<IAnnotationMirror, IAnnotationValue> versionElement = FindRuleDependencyProperty
|
||||
(dependency, RuleDependencyProcessor.RuleDependencyProperty.Version);
|
||||
string message = string.Format("Rule dependency version mismatch: %s has version %d (expected <= %d) in %s"
|
||||
, path, actualVersion, declaredVersion, GetRecognizerType(dependency.GetItem1
|
||||
()).ToString());
|
||||
, path, actualVersion, declaredVersion, GetRecognizerType(dependency.Item1).ToString
|
||||
());
|
||||
if (versionElement != null)
|
||||
{
|
||||
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Error, message, dependency
|
||||
.GetItem2(), versionElement.GetItem1(), versionElement.GetItem2());
|
||||
.Item2, versionElement.Item1, versionElement.Item2);
|
||||
}
|
||||
else
|
||||
{
|
||||
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Error, message, dependency
|
||||
.GetItem2());
|
||||
.Item2);
|
||||
}
|
||||
}
|
||||
return actualVersion;
|
||||
|
@ -489,7 +488,7 @@ namespace Antlr4.Runtime.Misc
|
|||
{
|
||||
IList<Tuple<RuleDependency, IElement>> result = new List<Tuple<RuleDependency, IElement
|
||||
>>();
|
||||
ICollection<IElement> elements = roundEnv.GetElementsAnnotatedWith(typeof(RuleDependency
|
||||
ISet<IElement> elements = roundEnv.GetElementsAnnotatedWith(typeof(RuleDependency
|
||||
));
|
||||
foreach (IElement element in elements)
|
||||
{
|
||||
|
@ -533,7 +532,7 @@ namespace Antlr4.Runtime.Misc
|
|||
(RuleDependencyClassName);
|
||||
ITypeElement ruleDependenciesTypeElement = processingEnv.GetElementUtils().GetTypeElement
|
||||
(RuleDependenciesClassName);
|
||||
IList<IAnnotationMirror> mirrors = dependency.GetItem2().GetAnnotationMirrors();
|
||||
IList<IAnnotationMirror> mirrors = dependency.Item2.GetAnnotationMirrors();
|
||||
foreach (IAnnotationMirror annotationMirror in mirrors)
|
||||
{
|
||||
if (processingEnv.GetTypeUtils().IsSameType(ruleDependencyTypeElement.AsType(), annotationMirror
|
||||
|
@ -562,7 +561,7 @@ namespace Antlr4.Runtime.Misc
|
|||
if (!(annotationValue.GetValue() is IList))
|
||||
{
|
||||
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Warning, "Expected array of RuleDependency annotations for annotation property 'value()'."
|
||||
, dependency.GetItem2(), annotationMirror, annotationValue);
|
||||
, dependency.Item2, annotationMirror, annotationValue);
|
||||
break;
|
||||
}
|
||||
IList<object> annotationValueList = (IList<object>)annotationValue.GetValue();
|
||||
|
@ -571,7 +570,7 @@ namespace Antlr4.Runtime.Misc
|
|||
if (!(obj is IAnnotationMirror))
|
||||
{
|
||||
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Warning, "Expected RuleDependency annotation mirror for element of property 'value()'."
|
||||
, dependency.GetItem2(), annotationMirror, annotationValue);
|
||||
, dependency.Item2, annotationMirror, annotationValue);
|
||||
break;
|
||||
}
|
||||
IAnnotationValue element = FindRuleDependencyProperty(dependency, (IAnnotationMirror
|
||||
|
@ -585,8 +584,7 @@ namespace Antlr4.Runtime.Misc
|
|||
else
|
||||
{
|
||||
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Error, string.Format("Unexpected annotation property %s."
|
||||
, value.Key.ToString()), dependency.GetItem2(), annotationMirror, value.Value
|
||||
);
|
||||
, value.Key.ToString()), dependency.Item2, annotationMirror, value.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -616,10 +614,10 @@ namespace Antlr4.Runtime.Misc
|
|||
if (!(annotationValue.GetValue() is int))
|
||||
{
|
||||
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Warning, "Expected int constant for annotation property 'rule()'."
|
||||
, dependency.GetItem2(), annotationMirror, annotationValue);
|
||||
, dependency.Item2, annotationMirror, annotationValue);
|
||||
return null;
|
||||
}
|
||||
if ((int)annotationValue.GetValue() != dependency.GetItem1().Rule())
|
||||
if ((int)annotationValue.GetValue() != dependency.Item1.Rule())
|
||||
{
|
||||
// this is a valid dependency annotation, but not the one we're looking for
|
||||
return null;
|
||||
|
@ -633,11 +631,11 @@ namespace Antlr4.Runtime.Misc
|
|||
if (!(annotationValue.GetValue() is ITypeMirror))
|
||||
{
|
||||
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Warning, "Expected Class constant for annotation property 'recognizer()'."
|
||||
, dependency.GetItem2(), annotationMirror, annotationValue);
|
||||
, dependency.Item2, annotationMirror, annotationValue);
|
||||
return null;
|
||||
}
|
||||
ITypeMirror annotationRecognizer = (ITypeMirror)annotationValue.GetValue();
|
||||
ITypeMirror expectedRecognizer = GetRecognizerType(dependency.GetItem1());
|
||||
ITypeMirror expectedRecognizer = GetRecognizerType(dependency.Item1);
|
||||
if (!processingEnv.GetTypeUtils().IsSameType(expectedRecognizer, annotationRecognizer
|
||||
))
|
||||
{
|
||||
|
@ -653,10 +651,10 @@ namespace Antlr4.Runtime.Misc
|
|||
if (!(annotationValue.GetValue() is int))
|
||||
{
|
||||
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Warning, "Expected int constant for annotation property 'version()'."
|
||||
, dependency.GetItem2(), annotationMirror, annotationValue);
|
||||
, dependency.Item2, annotationMirror, annotationValue);
|
||||
return null;
|
||||
}
|
||||
if ((int)annotationValue.GetValue() != dependency.GetItem1().Version())
|
||||
if ((int)annotationValue.GetValue() != dependency.Item1.Version())
|
||||
{
|
||||
// this is a valid dependency annotation, but not the one we're looking for
|
||||
return null;
|
||||
|
@ -702,7 +700,7 @@ namespace Antlr4.Runtime.Misc
|
|||
if (recognizerValue == null)
|
||||
{
|
||||
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Warning, "Could not find 'recognizer()' element in annotation."
|
||||
, dependency.GetItem2(), annotationMirror);
|
||||
, dependency.Item2, annotationMirror);
|
||||
}
|
||||
if (property == RuleDependencyProcessor.RuleDependencyProperty.Recognizer)
|
||||
{
|
||||
|
@ -711,7 +709,7 @@ namespace Antlr4.Runtime.Misc
|
|||
if (ruleValue == null)
|
||||
{
|
||||
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Warning, "Could not find 'rule()' element in annotation."
|
||||
, dependency.GetItem2(), annotationMirror);
|
||||
, dependency.Item2, annotationMirror);
|
||||
}
|
||||
if (property == RuleDependencyProcessor.RuleDependencyProperty.Rule)
|
||||
{
|
||||
|
@ -720,7 +718,7 @@ namespace Antlr4.Runtime.Misc
|
|||
if (versionValue == null)
|
||||
{
|
||||
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Warning, "Could not find 'version()' element in annotation."
|
||||
, dependency.GetItem2(), annotationMirror);
|
||||
, dependency.Item2, annotationMirror);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ namespace Antlr4.Runtime
|
|||
{
|
||||
if (ctx.children is ArrayList)
|
||||
{
|
||||
((List<object>)ctx.children).TrimToSize();
|
||||
((List<object>)ctx.children).TrimExcess();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
-methodMapping java.util.List<>.remove RemoveAt
|
||||
-methodMapping java.util.IList<>.remove RemoveAt
|
||||
-methodMapping java.util.ArrayList.remove RemoveAt
|
||||
-methodMapping java.util.ArrayList.trimToSize TrimExcess
|
||||
-methodMapping java.lang.Integer.toOctalString Sharpen.Extensions.ToOctalString
|
||||
-methodMapping java.lang.Integer.toHexString Sharpen.Extensions.ToHexString
|
||||
-methodMapping java.lang.Integer.bitCount Sharpen.Extensions.BitCount
|
||||
|
@ -67,6 +68,7 @@
|
|||
-methodMapping java.lang.Character.toLowerCase System.Char.ToLower
|
||||
-methodMapping java.lang.Character.toUpperCase System.Char.ToUpper
|
||||
-methodMapping java.util.HashMap<,>.containsKey ContainsKey
|
||||
-methodMapping java.lang.System.identityHashCode System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode
|
||||
-methodMapping java.lang.System.gc System.GC.Collect
|
||||
-methodMapping java.lang.System.runFinalization System.GC.WaitForPendingFinalizers
|
||||
-methodMapping java.lang.System.getenv(String) System.Environment.GetEnvironmentVariable
|
||||
|
@ -99,7 +101,9 @@
|
|||
-typeMapping java.lang.Comparable System.IComparable
|
||||
-typeMapping java.util.Comparator<> System.Collections.Generic.IComparer
|
||||
-typeMapping java.util.HashSet<> System.Collections.Generic.HashSet
|
||||
-typeMapping java.util.HashSet<> System.Collections.Generic.HashSet
|
||||
-typeMapping java.util.Set<> System.Collections.Generic.ISet
|
||||
-typeMapping java.util.concurrent.ConcurrentMap<,> System.Collections.Concurrent.ConcurrentDictionary
|
||||
-typeMapping java.util.concurrent.ConcurrentHashMap<,> System.Collections.Concurrent.ConcurrentDictionary
|
||||
-typeMapping java.io.File Sharpen.FilePath
|
||||
-typeMapping java.lang.StringBuilder System.Text.StringBuilder
|
||||
-typeMapping java.nio.charset.Charset System.Text.Encoding
|
||||
|
@ -185,7 +189,13 @@
|
|||
|
||||
-typeMapping org.antlr.v4.runtime.misc.Tuple System.Tuple
|
||||
-typeMapping org.antlr.v4.runtime.misc.Tuple2<,> System.Tuple
|
||||
-propertyMapping org.antlr.v4.runtime.misc.Tuple2.getItem1 Item1
|
||||
-propertyMapping org.antlr.v4.runtime.misc.Tuple2.getItem2 Item2
|
||||
-typeMapping org.antlr.v4.runtime.misc.Tuple3<,,> System.Tuple
|
||||
-propertyMapping org.antlr.v4.runtime.misc.Tuple3.getItem1 Item1
|
||||
-propertyMapping org.antlr.v4.runtime.misc.Tuple3.getItem2 Item2
|
||||
-propertyMapping org.antlr.v4.runtime.misc.Tuple3.getItem3 Item3
|
||||
|
||||
-typeMapping org.antlr.v4.runtime.misc.IntegerList System.Collections.Generic.List<int>
|
||||
|
||||
-typeMapping org.antlr.v4.runtime.ANTLRErrorListener<> IAntlrErrorListener
|
||||
|
|
Loading…
Reference in New Issue