forked from jasder/antlr
Updated properties and parameter types
This commit is contained in:
parent
c865930973
commit
b0a106eaa4
|
@ -86,19 +86,20 @@ namespace Antlr4.Runtime.Atn
|
||||||
public static Antlr4.Runtime.Atn.ATNConfig Create(ATNState state, int alt, PredictionContext
|
public static Antlr4.Runtime.Atn.ATNConfig Create(ATNState state, int alt, PredictionContext
|
||||||
context)
|
context)
|
||||||
{
|
{
|
||||||
return Create(state, alt, context, SemanticContext.None, -1);
|
return Create(state, alt, context, Antlr4.Runtime.Atn.SemanticContext.None, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Antlr4.Runtime.Atn.ATNConfig Create(ATNState state, int alt, PredictionContext
|
public static Antlr4.Runtime.Atn.ATNConfig Create(ATNState state, int alt, PredictionContext
|
||||||
context, SemanticContext semanticContext)
|
context, Antlr4.Runtime.Atn.SemanticContext semanticContext)
|
||||||
{
|
{
|
||||||
return Create(state, alt, context, semanticContext, -1);
|
return Create(state, alt, context, semanticContext, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Antlr4.Runtime.Atn.ATNConfig Create(ATNState state, int alt, PredictionContext
|
public static Antlr4.Runtime.Atn.ATNConfig Create(ATNState state, int alt, PredictionContext
|
||||||
context, SemanticContext semanticContext, int actionIndex)
|
context, Antlr4.Runtime.Atn.SemanticContext semanticContext, int actionIndex
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (semanticContext != SemanticContext.None)
|
if (semanticContext != Antlr4.Runtime.Atn.SemanticContext.None)
|
||||||
{
|
{
|
||||||
if (actionIndex != -1)
|
if (actionIndex != -1)
|
||||||
{
|
{
|
||||||
|
@ -124,124 +125,143 @@ namespace Antlr4.Runtime.Atn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Gets the ATN state associated with this configuration</summary>
|
/// <summary>Gets the ATN state associated with this configuration.</summary>
|
||||||
[NotNull]
|
/// <remarks>Gets the ATN state associated with this configuration.</remarks>
|
||||||
public ATNState GetState()
|
public ATNState State
|
||||||
{
|
{
|
||||||
return state;
|
get
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>What alt (or lexer rule) is predicted by this configuration</summary>
|
|
||||||
public int GetAlt()
|
|
||||||
{
|
|
||||||
return altAndOuterContextDepth & unchecked((int)(0x00FFFFFF));
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsHidden()
|
|
||||||
{
|
|
||||||
return altAndOuterContextDepth < 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void SetHidden(bool value)
|
|
||||||
{
|
|
||||||
if (value)
|
|
||||||
{
|
{
|
||||||
altAndOuterContextDepth |= unchecked((int)(0x80000000));
|
return state;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
altAndOuterContextDepth &= ~unchecked((int)(0x80000000));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[NotNull]
|
/// <summary>What alt (or lexer rule) is predicted by this configuration.</summary>
|
||||||
public PredictionContext GetContext()
|
/// <remarks>What alt (or lexer rule) is predicted by this configuration.</remarks>
|
||||||
|
public int Alt
|
||||||
{
|
{
|
||||||
return context;
|
get
|
||||||
|
{
|
||||||
|
return altAndOuterContextDepth & unchecked((int)(0x00FFFFFF));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void SetContext(PredictionContext context)
|
public virtual bool IsHidden
|
||||||
{
|
{
|
||||||
this.context = context;
|
get
|
||||||
|
{
|
||||||
|
return altAndOuterContextDepth < 0;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
altAndOuterContextDepth |= unchecked((int)(0x80000000));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
altAndOuterContextDepth &= ~unchecked((int)(0x80000000));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool GetReachesIntoOuterContext()
|
public virtual PredictionContext Context
|
||||||
{
|
{
|
||||||
return GetOuterContextDepth() != 0;
|
get
|
||||||
|
{
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
PredictionContext context = value;
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ReachesIntoOuterContext
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return OuterContextDepth != 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// We cannot execute predicates dependent upon local context unless
|
/// We cannot execute predicates dependent upon local context unless we know
|
||||||
/// we know for sure we are in the correct context.
|
/// for sure we are in the correct context.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// We cannot execute predicates dependent upon local context unless
|
/// We cannot execute predicates dependent upon local context unless we know
|
||||||
/// we know for sure we are in the correct context. Because there is
|
/// for sure we are in the correct context. Because there is no way to do
|
||||||
/// no way to do this efficiently, we simply cannot evaluate
|
/// this efficiently, we simply cannot evaluate dependent predicates unless
|
||||||
/// dependent predicates unless we are in the rule that initially
|
/// we are in the rule that initially invokes the ATN simulator.
|
||||||
/// invokes the ATN simulator.
|
/// closure() tracks the depth of how far we dip into the outer context:
|
||||||
/// closure() tracks the depth of how far we dip into the
|
/// depth > 0. Note that it may not be totally accurate depth since I don't
|
||||||
/// outer context: depth > 0. Note that it may not be totally
|
/// ever decrement. TODO: make it a boolean then
|
||||||
/// accurate depth since I don't ever decrement. TODO: make it a boolean then
|
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public int GetOuterContextDepth()
|
public virtual int OuterContextDepth
|
||||||
{
|
{
|
||||||
return ((int)(((uint)altAndOuterContextDepth) >> 24)) & unchecked((int)(0x7F));
|
get
|
||||||
|
{
|
||||||
|
return ((int)(((uint)altAndOuterContextDepth) >> 24)) & unchecked((int)(0x7F));
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
int outerContextDepth = value;
|
||||||
|
System.Diagnostics.Debug.Assert(outerContextDepth >= 0);
|
||||||
|
// saturate at 0x7F - everything but zero/positive is only used for debug information anyway
|
||||||
|
outerContextDepth = Math.Min(outerContextDepth, unchecked((int)(0x7F)));
|
||||||
|
this.altAndOuterContextDepth = (outerContextDepth << 24) | (altAndOuterContextDepth
|
||||||
|
& ~unchecked((int)(0x7F000000)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void SetOuterContextDepth(int outerContextDepth)
|
public virtual int ActionIndex
|
||||||
{
|
{
|
||||||
System.Diagnostics.Debug.Assert(outerContextDepth >= 0);
|
get
|
||||||
// saturate at 0x7F - everything but zero/positive is only used for debug information anyway
|
{
|
||||||
outerContextDepth = Math.Min(outerContextDepth, unchecked((int)(0x7F)));
|
return -1;
|
||||||
this.altAndOuterContextDepth = (outerContextDepth << 24) | (altAndOuterContextDepth
|
}
|
||||||
& ~unchecked((int)(0x7F000000)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual int GetActionIndex()
|
public virtual Antlr4.Runtime.Atn.SemanticContext SemanticContext
|
||||||
{
|
{
|
||||||
return -1;
|
get
|
||||||
}
|
{
|
||||||
|
return Antlr4.Runtime.Atn.SemanticContext.None;
|
||||||
[NotNull]
|
}
|
||||||
public virtual SemanticContext GetSemanticContext()
|
|
||||||
{
|
|
||||||
return SemanticContext.None;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Antlr4.Runtime.Atn.ATNConfig Clone()
|
public Antlr4.Runtime.Atn.ATNConfig Clone()
|
||||||
{
|
{
|
||||||
return Transform(this.GetState());
|
return Transform(this.State);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Antlr4.Runtime.Atn.ATNConfig Transform(ATNState state)
|
public Antlr4.Runtime.Atn.ATNConfig Transform(ATNState state)
|
||||||
{
|
{
|
||||||
return Transform(state, this.context, this.GetSemanticContext(), this.GetActionIndex
|
return Transform(state, this.context, this.SemanticContext, this.ActionIndex);
|
||||||
());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Antlr4.Runtime.Atn.ATNConfig Transform(ATNState state, SemanticContext semanticContext
|
public Antlr4.Runtime.Atn.ATNConfig Transform(ATNState state, Antlr4.Runtime.Atn.SemanticContext
|
||||||
)
|
semanticContext)
|
||||||
{
|
{
|
||||||
return Transform(state, this.context, semanticContext, this.GetActionIndex());
|
return Transform(state, this.context, semanticContext, this.ActionIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Antlr4.Runtime.Atn.ATNConfig Transform(ATNState state, PredictionContext context
|
public Antlr4.Runtime.Atn.ATNConfig Transform(ATNState state, PredictionContext context
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return Transform(state, context, this.GetSemanticContext(), this.GetActionIndex()
|
return Transform(state, context, this.SemanticContext, this.ActionIndex);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Antlr4.Runtime.Atn.ATNConfig Transform(ATNState state, int actionIndex)
|
public Antlr4.Runtime.Atn.ATNConfig Transform(ATNState state, int actionIndex)
|
||||||
{
|
{
|
||||||
return Transform(state, context, this.GetSemanticContext(), actionIndex);
|
return Transform(state, context, this.SemanticContext, actionIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Antlr4.Runtime.Atn.ATNConfig Transform(ATNState state, PredictionContext
|
private Antlr4.Runtime.Atn.ATNConfig Transform(ATNState state, PredictionContext
|
||||||
context, SemanticContext semanticContext, int actionIndex)
|
context, Antlr4.Runtime.Atn.SemanticContext semanticContext, int actionIndex)
|
||||||
{
|
{
|
||||||
if (semanticContext != SemanticContext.None)
|
if (semanticContext != Antlr4.Runtime.Atn.SemanticContext.None)
|
||||||
{
|
{
|
||||||
if (actionIndex != -1)
|
if (actionIndex != -1)
|
||||||
{
|
{
|
||||||
|
@ -270,33 +290,30 @@ namespace Antlr4.Runtime.Atn
|
||||||
public virtual Antlr4.Runtime.Atn.ATNConfig AppendContext(int context, PredictionContextCache
|
public virtual Antlr4.Runtime.Atn.ATNConfig AppendContext(int context, PredictionContextCache
|
||||||
contextCache)
|
contextCache)
|
||||||
{
|
{
|
||||||
PredictionContext appendedContext = GetContext().AppendContext(context, contextCache
|
PredictionContext appendedContext = Context.AppendContext(context, contextCache);
|
||||||
);
|
Antlr4.Runtime.Atn.ATNConfig result = Transform(State, appendedContext);
|
||||||
Antlr4.Runtime.Atn.ATNConfig result = Transform(GetState(), appendedContext);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual Antlr4.Runtime.Atn.ATNConfig AppendContext(PredictionContext context
|
public virtual Antlr4.Runtime.Atn.ATNConfig AppendContext(PredictionContext context
|
||||||
, PredictionContextCache contextCache)
|
, PredictionContextCache contextCache)
|
||||||
{
|
{
|
||||||
PredictionContext appendedContext = GetContext().AppendContext(context, contextCache
|
PredictionContext appendedContext = Context.AppendContext(context, contextCache);
|
||||||
);
|
Antlr4.Runtime.Atn.ATNConfig result = Transform(State, appendedContext);
|
||||||
Antlr4.Runtime.Atn.ATNConfig result = Transform(GetState(), appendedContext);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool Contains(Antlr4.Runtime.Atn.ATNConfig subconfig)
|
public virtual bool Contains(Antlr4.Runtime.Atn.ATNConfig subconfig)
|
||||||
{
|
{
|
||||||
if (this.GetState().stateNumber != subconfig.GetState().stateNumber || this.GetAlt
|
if (this.State.stateNumber != subconfig.State.stateNumber || this.Alt != subconfig
|
||||||
() != subconfig.GetAlt() || !this.GetSemanticContext().Equals(subconfig.GetSemanticContext
|
.Alt || !this.SemanticContext.Equals(subconfig.SemanticContext))
|
||||||
()))
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
IDeque<PredictionContext> leftWorkList = new ArrayDeque<PredictionContext>();
|
IDeque<PredictionContext> leftWorkList = new ArrayDeque<PredictionContext>();
|
||||||
IDeque<PredictionContext> rightWorkList = new ArrayDeque<PredictionContext>();
|
IDeque<PredictionContext> rightWorkList = new ArrayDeque<PredictionContext>();
|
||||||
leftWorkList.AddItem(GetContext());
|
leftWorkList.AddItem(Context);
|
||||||
rightWorkList.AddItem(subconfig.GetContext());
|
rightWorkList.AddItem(subconfig.Context);
|
||||||
while (!leftWorkList.IsEmpty())
|
while (!leftWorkList.IsEmpty())
|
||||||
{
|
{
|
||||||
PredictionContext left = leftWorkList.Pop();
|
PredictionContext left = leftWorkList.Pop();
|
||||||
|
@ -363,21 +380,20 @@ namespace Antlr4.Runtime.Atn
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.GetState().stateNumber == other.GetState().stateNumber && this.GetAlt
|
return this.State.stateNumber == other.State.stateNumber && this.Alt == other.Alt
|
||||||
() == other.GetAlt() && this.GetReachesIntoOuterContext() == other.GetReachesIntoOuterContext
|
&& this.ReachesIntoOuterContext == other.ReachesIntoOuterContext && this.Context
|
||||||
() && this.GetContext().Equals(other.GetContext()) && this.GetSemanticContext
|
.Equals(other.Context) && this.SemanticContext.Equals(other.SemanticContext)
|
||||||
().Equals(other.GetSemanticContext()) && this.GetActionIndex() == other.GetActionIndex
|
&& this.ActionIndex == other.ActionIndex;
|
||||||
();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
{
|
{
|
||||||
int hashCode = 7;
|
int hashCode = 7;
|
||||||
hashCode = 5 * hashCode + GetState().stateNumber;
|
hashCode = 5 * hashCode + State.stateNumber;
|
||||||
hashCode = 5 * hashCode + GetAlt();
|
hashCode = 5 * hashCode + Alt;
|
||||||
hashCode = 5 * hashCode + (GetReachesIntoOuterContext() ? 1 : 0);
|
hashCode = 5 * hashCode + (ReachesIntoOuterContext ? 1 : 0);
|
||||||
hashCode = 5 * hashCode + (GetContext() != null ? GetContext().GetHashCode() : 0);
|
hashCode = 5 * hashCode + (Context != null ? Context.GetHashCode() : 0);
|
||||||
hashCode = 5 * hashCode + GetSemanticContext().GetHashCode();
|
hashCode = 5 * hashCode + SemanticContext.GetHashCode();
|
||||||
return hashCode;
|
return hashCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,8 +405,8 @@ namespace Antlr4.Runtime.Atn
|
||||||
IDictionary<PredictionContext, PredictionContext> visited = new IdentityHashMap<PredictionContext
|
IDictionary<PredictionContext, PredictionContext> visited = new IdentityHashMap<PredictionContext
|
||||||
, PredictionContext>();
|
, PredictionContext>();
|
||||||
IDeque<PredictionContext> workList = new ArrayDeque<PredictionContext>();
|
IDeque<PredictionContext> workList = new ArrayDeque<PredictionContext>();
|
||||||
workList.AddItem(GetContext());
|
workList.AddItem(Context);
|
||||||
visited.Put(GetContext(), GetContext());
|
visited.Put(Context, Context);
|
||||||
while (!workList.IsEmpty())
|
while (!workList.IsEmpty())
|
||||||
{
|
{
|
||||||
PredictionContext current = workList.Pop();
|
PredictionContext current = workList.Pop();
|
||||||
|
@ -433,7 +449,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
string[] contexts;
|
string[] contexts;
|
||||||
if (showContext)
|
if (showContext)
|
||||||
{
|
{
|
||||||
contexts = GetContext().ToStrings(recog, this.GetState().stateNumber);
|
contexts = Context.ToStrings(recog, this.State.stateNumber);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -451,25 +467,26 @@ namespace Antlr4.Runtime.Atn
|
||||||
buf.Append(", ");
|
buf.Append(", ");
|
||||||
}
|
}
|
||||||
buf.Append('(');
|
buf.Append('(');
|
||||||
buf.Append(GetState());
|
buf.Append(State);
|
||||||
if (showAlt)
|
if (showAlt)
|
||||||
{
|
{
|
||||||
buf.Append(",");
|
buf.Append(",");
|
||||||
buf.Append(GetAlt());
|
buf.Append(Alt);
|
||||||
}
|
}
|
||||||
if (GetContext() != null)
|
if (Context != null)
|
||||||
{
|
{
|
||||||
buf.Append(",");
|
buf.Append(",");
|
||||||
buf.Append(contextDesc);
|
buf.Append(contextDesc);
|
||||||
}
|
}
|
||||||
if (GetSemanticContext() != null && GetSemanticContext() != SemanticContext.None)
|
if (SemanticContext != null && SemanticContext != Antlr4.Runtime.Atn.SemanticContext
|
||||||
|
.None)
|
||||||
{
|
{
|
||||||
buf.Append(",");
|
buf.Append(",");
|
||||||
buf.Append(GetSemanticContext());
|
buf.Append(SemanticContext);
|
||||||
}
|
}
|
||||||
if (GetReachesIntoOuterContext())
|
if (ReachesIntoOuterContext)
|
||||||
{
|
{
|
||||||
buf.Append(",up=").Append(GetOuterContextDepth());
|
buf.Append(",up=").Append(OuterContextDepth);
|
||||||
}
|
}
|
||||||
buf.Append(')');
|
buf.Append(')');
|
||||||
}
|
}
|
||||||
|
@ -479,23 +496,28 @@ namespace Antlr4.Runtime.Atn
|
||||||
private class SemanticContextATNConfig : ATNConfig
|
private class SemanticContextATNConfig : ATNConfig
|
||||||
{
|
{
|
||||||
[NotNull]
|
[NotNull]
|
||||||
private readonly SemanticContext semanticContext;
|
private readonly Antlr4.Runtime.Atn.SemanticContext semanticContext;
|
||||||
|
|
||||||
public SemanticContextATNConfig(SemanticContext semanticContext, ATNState state,
|
public SemanticContextATNConfig(Antlr4.Runtime.Atn.SemanticContext semanticContext
|
||||||
int alt, PredictionContext context) : base(state, alt, context)
|
, ATNState state, int alt, PredictionContext context) : base(state, alt, context
|
||||||
|
)
|
||||||
{
|
{
|
||||||
this.semanticContext = semanticContext;
|
this.semanticContext = semanticContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SemanticContextATNConfig(SemanticContext semanticContext, ATNConfig c, ATNState
|
public SemanticContextATNConfig(Antlr4.Runtime.Atn.SemanticContext semanticContext
|
||||||
state, PredictionContext context) : base(c, state, context)
|
, ATNConfig c, ATNState state, PredictionContext context) : base(c, state, context
|
||||||
|
)
|
||||||
{
|
{
|
||||||
this.semanticContext = semanticContext;
|
this.semanticContext = semanticContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override SemanticContext GetSemanticContext()
|
public override Antlr4.Runtime.Atn.SemanticContext SemanticContext
|
||||||
{
|
{
|
||||||
return semanticContext;
|
get
|
||||||
|
{
|
||||||
|
return semanticContext;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -512,16 +534,19 @@ namespace Antlr4.Runtime.Atn
|
||||||
protected internal ActionATNConfig(int actionIndex, ATNConfig c, ATNState state,
|
protected internal ActionATNConfig(int actionIndex, ATNConfig c, ATNState state,
|
||||||
PredictionContext context) : base(c, state, context)
|
PredictionContext context) : base(c, state, context)
|
||||||
{
|
{
|
||||||
if (c.GetSemanticContext() != SemanticContext.None)
|
if (c.SemanticContext != SemanticContext.None)
|
||||||
{
|
{
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
this.actionIndex = actionIndex;
|
this.actionIndex = actionIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetActionIndex()
|
public override int ActionIndex
|
||||||
{
|
{
|
||||||
return actionIndex;
|
get
|
||||||
|
{
|
||||||
|
return actionIndex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -543,9 +568,12 @@ namespace Antlr4.Runtime.Atn
|
||||||
this.actionIndex = actionIndex;
|
this.actionIndex = actionIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetActionIndex()
|
public override int ActionIndex
|
||||||
{
|
{
|
||||||
return actionIndex;
|
get
|
||||||
|
{
|
||||||
|
return actionIndex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
/// <see cref="ATNConfig">ATNConfig</see>
|
/// <see cref="ATNConfig">ATNConfig</see>
|
||||||
/// . The key does not account for
|
/// . The key does not account for
|
||||||
/// the
|
/// the
|
||||||
/// <see cref="ATNConfig.GetSemanticContext()">ATNConfig.GetSemanticContext()</see>
|
/// <see cref="ATNConfig.SemanticContext()">ATNConfig.SemanticContext()</see>
|
||||||
/// of the value, which is only a problem if a single
|
/// of the value, which is only a problem if a single
|
||||||
/// <code>ATNConfigSet</code>
|
/// <code>ATNConfigSet</code>
|
||||||
/// contains two configs with the same state and alternative
|
/// contains two configs with the same state and alternative
|
||||||
|
@ -168,7 +168,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
BitSet alts = new BitSet();
|
BitSet alts = new BitSet();
|
||||||
foreach (ATNConfig config in this)
|
foreach (ATNConfig config in this)
|
||||||
{
|
{
|
||||||
alts.Set(config.GetAlt());
|
alts.Set(config.Alt);
|
||||||
}
|
}
|
||||||
return alts;
|
return alts;
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
();
|
();
|
||||||
while (iterator.HasNext())
|
while (iterator.HasNext())
|
||||||
{
|
{
|
||||||
if (iterator.Next().Value.IsHidden())
|
if (iterator.Next().Value.IsHidden)
|
||||||
{
|
{
|
||||||
iterator.Remove();
|
iterator.Remove();
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
IListIterator<ATNConfig> iterator2 = unmerged.ListIterator();
|
IListIterator<ATNConfig> iterator2 = unmerged.ListIterator();
|
||||||
while (iterator2.HasNext())
|
while (iterator2.HasNext())
|
||||||
{
|
{
|
||||||
if (iterator2.Next().IsHidden())
|
if (iterator2.Next().IsHidden)
|
||||||
{
|
{
|
||||||
iterator2.Remove();
|
iterator2.Remove();
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
iterator2 = configs.ListIterator();
|
iterator2 = configs.ListIterator();
|
||||||
while (iterator2.HasNext())
|
while (iterator2.HasNext())
|
||||||
{
|
{
|
||||||
if (iterator2.Next().IsHidden())
|
if (iterator2.Next().IsHidden)
|
||||||
{
|
{
|
||||||
iterator2.Remove();
|
iterator2.Remove();
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
ISet<ATNState> states = new HashSet<ATNState>();
|
ISet<ATNState> states = new HashSet<ATNState>();
|
||||||
foreach (ATNConfig c in this.configs)
|
foreach (ATNConfig c in this.configs)
|
||||||
{
|
{
|
||||||
states.AddItem(c.GetState());
|
states.AddItem(c.State);
|
||||||
}
|
}
|
||||||
return states;
|
return states;
|
||||||
}
|
}
|
||||||
|
@ -248,7 +248,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
for (int i = 0; i < configs.Count; i++)
|
for (int i = 0; i < configs.Count; i++)
|
||||||
{
|
{
|
||||||
ATNConfig config = configs[i];
|
ATNConfig config = configs[i];
|
||||||
config.SetContext(interpreter.atn.GetCachedContext(config.GetContext()));
|
config.Context = interpreter.atn.GetCachedContext(config.Context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,9 +317,9 @@ namespace Antlr4.Runtime.Atn
|
||||||
public virtual bool Add(ATNConfig e, PredictionContextCache contextCache)
|
public virtual bool Add(ATNConfig e, PredictionContextCache contextCache)
|
||||||
{
|
{
|
||||||
EnsureWritable();
|
EnsureWritable();
|
||||||
System.Diagnostics.Debug.Assert(!outermostConfigSet || !e.GetReachesIntoOuterContext
|
System.Diagnostics.Debug.Assert(!outermostConfigSet || !e.ReachesIntoOuterContext
|
||||||
());
|
);
|
||||||
System.Diagnostics.Debug.Assert(!e.IsHidden());
|
System.Diagnostics.Debug.Assert(!e.IsHidden);
|
||||||
if (contextCache == null)
|
if (contextCache == null)
|
||||||
{
|
{
|
||||||
contextCache = PredictionContextCache.Uncached;
|
contextCache = PredictionContextCache.Uncached;
|
||||||
|
@ -330,16 +330,16 @@ namespace Antlr4.Runtime.Atn
|
||||||
addKey = (mergedConfig == null);
|
addKey = (mergedConfig == null);
|
||||||
if (mergedConfig != null && CanMerge(e, key, mergedConfig))
|
if (mergedConfig != null && CanMerge(e, key, mergedConfig))
|
||||||
{
|
{
|
||||||
mergedConfig.SetOuterContextDepth(Math.Max(mergedConfig.GetOuterContextDepth(), e
|
mergedConfig.OuterContextDepth = Math.Max(mergedConfig.OuterContextDepth, e.OuterContextDepth
|
||||||
.GetOuterContextDepth()));
|
);
|
||||||
PredictionContext joined = PredictionContext.Join(mergedConfig.GetContext(), e.GetContext
|
PredictionContext joined = PredictionContext.Join(mergedConfig.Context, e.Context
|
||||||
(), contextCache);
|
, contextCache);
|
||||||
UpdatePropertiesForMergedConfig(e);
|
UpdatePropertiesForMergedConfig(e);
|
||||||
if (mergedConfig.GetContext() == joined)
|
if (mergedConfig.Context == joined)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mergedConfig.SetContext(joined);
|
mergedConfig.Context = joined;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < unmerged.Count; i++)
|
for (int i = 0; i < unmerged.Count; i++)
|
||||||
|
@ -347,16 +347,16 @@ namespace Antlr4.Runtime.Atn
|
||||||
ATNConfig unmergedConfig = unmerged[i];
|
ATNConfig unmergedConfig = unmerged[i];
|
||||||
if (CanMerge(e, key, unmergedConfig))
|
if (CanMerge(e, key, unmergedConfig))
|
||||||
{
|
{
|
||||||
unmergedConfig.SetOuterContextDepth(Math.Max(unmergedConfig.GetOuterContextDepth(
|
unmergedConfig.OuterContextDepth = Math.Max(unmergedConfig.OuterContextDepth, e.OuterContextDepth
|
||||||
), e.GetOuterContextDepth()));
|
);
|
||||||
PredictionContext joined = PredictionContext.Join(unmergedConfig.GetContext(), e.
|
PredictionContext joined = PredictionContext.Join(unmergedConfig.Context, e.Context
|
||||||
GetContext(), contextCache);
|
, contextCache);
|
||||||
UpdatePropertiesForMergedConfig(e);
|
UpdatePropertiesForMergedConfig(e);
|
||||||
if (unmergedConfig.GetContext() == joined)
|
if (unmergedConfig.Context == joined)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
unmergedConfig.SetContext(joined);
|
unmergedConfig.Context = joined;
|
||||||
if (addKey)
|
if (addKey)
|
||||||
{
|
{
|
||||||
mergedConfigs.Put(key, unmergedConfig);
|
mergedConfigs.Put(key, unmergedConfig);
|
||||||
|
@ -381,7 +381,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
private void UpdatePropertiesForMergedConfig(ATNConfig config)
|
private void UpdatePropertiesForMergedConfig(ATNConfig config)
|
||||||
{
|
{
|
||||||
// merged configs can't change the alt or semantic context
|
// merged configs can't change the alt or semantic context
|
||||||
dipsIntoOuterContext |= config.GetReachesIntoOuterContext();
|
dipsIntoOuterContext |= config.ReachesIntoOuterContext;
|
||||||
System.Diagnostics.Debug.Assert(!outermostConfigSet || !dipsIntoOuterContext);
|
System.Diagnostics.Debug.Assert(!outermostConfigSet || !dipsIntoOuterContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,24 +389,24 @@ namespace Antlr4.Runtime.Atn
|
||||||
{
|
{
|
||||||
if (configs.Count == 1)
|
if (configs.Count == 1)
|
||||||
{
|
{
|
||||||
uniqueAlt = config.GetAlt();
|
uniqueAlt = config.Alt;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (uniqueAlt != config.GetAlt())
|
if (uniqueAlt != config.Alt)
|
||||||
{
|
{
|
||||||
uniqueAlt = ATN.InvalidAltNumber;
|
uniqueAlt = ATN.InvalidAltNumber;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hasSemanticContext |= !SemanticContext.None.Equals(config.GetSemanticContext());
|
hasSemanticContext |= !SemanticContext.None.Equals(config.SemanticContext);
|
||||||
dipsIntoOuterContext |= config.GetReachesIntoOuterContext();
|
dipsIntoOuterContext |= config.ReachesIntoOuterContext;
|
||||||
System.Diagnostics.Debug.Assert(!outermostConfigSet || !dipsIntoOuterContext);
|
System.Diagnostics.Debug.Assert(!outermostConfigSet || !dipsIntoOuterContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected internal virtual bool CanMerge(ATNConfig left, long leftKey, ATNConfig
|
protected internal virtual bool CanMerge(ATNConfig left, long leftKey, ATNConfig
|
||||||
right)
|
right)
|
||||||
{
|
{
|
||||||
if (left.GetState().stateNumber != right.GetState().stateNumber)
|
if (left.State.stateNumber != right.State.stateNumber)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -414,13 +414,13 @@ namespace Antlr4.Runtime.Atn
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return left.GetSemanticContext().Equals(right.GetSemanticContext());
|
return left.SemanticContext.Equals(right.SemanticContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected internal virtual long GetKey(ATNConfig e)
|
protected internal virtual long GetKey(ATNConfig e)
|
||||||
{
|
{
|
||||||
long key = e.GetState().stateNumber;
|
long key = e.State.stateNumber;
|
||||||
key = (key << 12) | (e.GetAlt() & unchecked((int)(0xFFF)));
|
key = (key << 12) | (e.Alt & unchecked((int)(0xFFF)));
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -557,20 +557,20 @@ namespace Antlr4.Runtime.Atn
|
||||||
|
|
||||||
public int Compare(ATNConfig o1, ATNConfig o2)
|
public int Compare(ATNConfig o1, ATNConfig o2)
|
||||||
{
|
{
|
||||||
if (o1.GetAlt() != o2.GetAlt())
|
if (o1.Alt != o2.Alt)
|
||||||
{
|
{
|
||||||
return o1.GetAlt() - o2.GetAlt();
|
return o1.Alt - o2.Alt;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (o1.GetState().stateNumber != o2.GetState().stateNumber)
|
if (o1.State.stateNumber != o2.State.stateNumber)
|
||||||
{
|
{
|
||||||
return o1.GetState().stateNumber - o2.GetState().stateNumber;
|
return o1.State.stateNumber - o2.State.stateNumber;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return string.CompareOrdinal(o1.GetSemanticContext().ToString(), o2.GetSemanticContext
|
return string.CompareOrdinal(o1.SemanticContext.ToString(), o2.SemanticContext.ToString
|
||||||
().ToString());
|
());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -307,15 +307,15 @@ namespace Antlr4.Runtime.Atn
|
||||||
int skipAlt = ATN.InvalidAltNumber;
|
int skipAlt = ATN.InvalidAltNumber;
|
||||||
foreach (ATNConfig c in closure)
|
foreach (ATNConfig c in closure)
|
||||||
{
|
{
|
||||||
if (c.GetAlt() == skipAlt)
|
if (c.Alt == skipAlt)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int n = c.GetState().NumberOfOptimizedTransitions;
|
int n = c.State.NumberOfOptimizedTransitions;
|
||||||
for (int ti = 0; ti < n; ti++)
|
for (int ti = 0; ti < n; ti++)
|
||||||
{
|
{
|
||||||
// for each optimized transition
|
// for each optimized transition
|
||||||
Transition trans = c.GetState().GetOptimizedTransition(ti);
|
Transition trans = c.State.GetOptimizedTransition(ti);
|
||||||
ATNState target = GetReachableTarget(trans, t);
|
ATNState target = GetReachableTarget(trans, t);
|
||||||
if (target != null)
|
if (target != null)
|
||||||
{
|
{
|
||||||
|
@ -323,7 +323,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
{
|
{
|
||||||
// any remaining configs for this alt have a lower priority than
|
// any remaining configs for this alt have a lower priority than
|
||||||
// the one that just reached an accept state.
|
// the one that just reached an accept state.
|
||||||
skipAlt = c.GetAlt();
|
skipAlt = c.Alt;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -397,9 +397,9 @@ namespace Antlr4.Runtime.Atn
|
||||||
protected internal virtual bool Closure(ICharStream input, ATNConfig config, ATNConfigSet
|
protected internal virtual bool Closure(ICharStream input, ATNConfig config, ATNConfigSet
|
||||||
configs, bool speculative)
|
configs, bool speculative)
|
||||||
{
|
{
|
||||||
if (config.GetState() is RuleStopState)
|
if (config.State is RuleStopState)
|
||||||
{
|
{
|
||||||
PredictionContext context = config.GetContext();
|
PredictionContext context = config.Context;
|
||||||
if (context.IsEmpty)
|
if (context.IsEmpty)
|
||||||
{
|
{
|
||||||
configs.AddItem(config);
|
configs.AddItem(config);
|
||||||
|
@ -409,7 +409,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
{
|
{
|
||||||
if (context.HasEmpty)
|
if (context.HasEmpty)
|
||||||
{
|
{
|
||||||
configs.AddItem(config.Transform(config.GetState(), PredictionContext.EmptyFull));
|
configs.AddItem(config.Transform(config.State, PredictionContext.EmptyFull));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -423,7 +423,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
PredictionContext newContext = context.GetParent(i);
|
PredictionContext newContext = context.GetParent(i);
|
||||||
// "pop" return state
|
// "pop" return state
|
||||||
ATNState returnState = atn.states[returnStateNumber];
|
ATNState returnState = atn.states[returnStateNumber];
|
||||||
ATNConfig c = ATNConfig.Create(returnState, config.GetAlt(), newContext);
|
ATNConfig c = ATNConfig.Create(returnState, config.Alt, newContext);
|
||||||
if (Closure(input, c, configs, speculative))
|
if (Closure(input, c, configs, speculative))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
@ -432,11 +432,11 @@ namespace Antlr4.Runtime.Atn
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// optimization
|
// optimization
|
||||||
if (!config.GetState().OnlyHasEpsilonTransitions)
|
if (!config.State.OnlyHasEpsilonTransitions)
|
||||||
{
|
{
|
||||||
configs.AddItem(config);
|
configs.AddItem(config);
|
||||||
}
|
}
|
||||||
ATNState p = config.GetState();
|
ATNState p = config.State;
|
||||||
for (int i_1 = 0; i_1 < p.NumberOfOptimizedTransitions; i_1++)
|
for (int i_1 = 0; i_1 < p.NumberOfOptimizedTransitions; i_1++)
|
||||||
{
|
{
|
||||||
Transition t = p.GetOptimizedTransition(i_1);
|
Transition t = p.GetOptimizedTransition(i_1);
|
||||||
|
@ -463,14 +463,13 @@ namespace Antlr4.Runtime.Atn
|
||||||
case TransitionType.Rule:
|
case TransitionType.Rule:
|
||||||
{
|
{
|
||||||
RuleTransition ruleTransition = (RuleTransition)t;
|
RuleTransition ruleTransition = (RuleTransition)t;
|
||||||
if (optimize_tail_calls && ruleTransition.optimizedTailCall && !config.GetContext
|
if (optimize_tail_calls && ruleTransition.optimizedTailCall && !config.Context.HasEmpty)
|
||||||
().HasEmpty)
|
|
||||||
{
|
{
|
||||||
c = config.Transform(t.target);
|
c = config.Transform(t.target);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PredictionContext newContext = config.GetContext().GetChild(ruleTransition.followState
|
PredictionContext newContext = config.Context.GetChild(ruleTransition.followState
|
||||||
.stateNumber);
|
.stateNumber);
|
||||||
c = config.Transform(t.target, newContext);
|
c = config.Transform(t.target, newContext);
|
||||||
}
|
}
|
||||||
|
@ -661,7 +660,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
ATNConfig firstConfigWithRuleStopState = null;
|
ATNConfig firstConfigWithRuleStopState = null;
|
||||||
foreach (ATNConfig c in configs)
|
foreach (ATNConfig c in configs)
|
||||||
{
|
{
|
||||||
if (c.GetState() is RuleStopState)
|
if (c.State is RuleStopState)
|
||||||
{
|
{
|
||||||
firstConfigWithRuleStopState = c;
|
firstConfigWithRuleStopState = c;
|
||||||
break;
|
break;
|
||||||
|
@ -670,8 +669,8 @@ namespace Antlr4.Runtime.Atn
|
||||||
if (firstConfigWithRuleStopState != null)
|
if (firstConfigWithRuleStopState != null)
|
||||||
{
|
{
|
||||||
newState.isAcceptState = true;
|
newState.isAcceptState = true;
|
||||||
newState.lexerRuleIndex = firstConfigWithRuleStopState.GetState().ruleIndex;
|
newState.lexerRuleIndex = firstConfigWithRuleStopState.State.ruleIndex;
|
||||||
newState.lexerActionIndex = firstConfigWithRuleStopState.GetActionIndex();
|
newState.lexerActionIndex = firstConfigWithRuleStopState.ActionIndex;
|
||||||
newState.prediction = atn.ruleToTokenType[newState.lexerRuleIndex];
|
newState.prediction = atn.ruleToTokenType[newState.lexerRuleIndex];
|
||||||
}
|
}
|
||||||
return atn.modeToDFA[mode].AddState(newState);
|
return atn.modeToDFA[mode].AddState(newState);
|
||||||
|
|
|
@ -204,7 +204,8 @@ namespace Antlr4.Runtime.Atn
|
||||||
|
|
||||||
public const bool retry_debug = false;
|
public const bool retry_debug = false;
|
||||||
|
|
||||||
private PredictionMode predictionMode = PredictionMode.Ll;
|
private Antlr4.Runtime.Atn.PredictionMode predictionMode = Antlr4.Runtime.Atn.PredictionMode
|
||||||
|
.Ll;
|
||||||
|
|
||||||
public bool force_global_context = false;
|
public bool force_global_context = false;
|
||||||
|
|
||||||
|
@ -273,15 +274,17 @@ namespace Antlr4.Runtime.Atn
|
||||||
this.parser = parser;
|
this.parser = parser;
|
||||||
}
|
}
|
||||||
|
|
||||||
[NotNull]
|
public Antlr4.Runtime.Atn.PredictionMode PredictionMode
|
||||||
public PredictionMode GetPredictionMode()
|
|
||||||
{
|
{
|
||||||
return predictionMode;
|
get
|
||||||
}
|
{
|
||||||
|
return predictionMode;
|
||||||
public void SetPredictionMode(PredictionMode predictionMode)
|
}
|
||||||
{
|
set
|
||||||
this.predictionMode = predictionMode;
|
{
|
||||||
|
Antlr4.Runtime.Atn.PredictionMode predictionMode = value;
|
||||||
|
this.predictionMode = predictionMode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Reset()
|
public override void Reset()
|
||||||
|
@ -323,8 +326,8 @@ namespace Antlr4.Runtime.Atn
|
||||||
useContext |= dfa != null && dfa.IsContextSensitive();
|
useContext |= dfa != null && dfa.IsContextSensitive();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
userWantsCtxSensitive = useContext || (predictionMode != PredictionMode.Sll && outerContext
|
userWantsCtxSensitive = useContext || (predictionMode != Antlr4.Runtime.Atn.PredictionMode
|
||||||
!= null && !atn.decisionToState[decision].sll);
|
.Sll && outerContext != null && !atn.decisionToState[decision].sll);
|
||||||
if (outerContext == null)
|
if (outerContext == null)
|
||||||
{
|
{
|
||||||
outerContext = ParserRuleContext.EmptyContext;
|
outerContext = ParserRuleContext.EmptyContext;
|
||||||
|
@ -575,7 +578,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
input.Seek(startIndex);
|
input.Seek(startIndex);
|
||||||
}
|
}
|
||||||
BitSet alts = EvalSemanticContext(s.predicates, outerContext, reportAmbiguities &&
|
BitSet alts = EvalSemanticContext(s.predicates, outerContext, reportAmbiguities &&
|
||||||
predictionMode == PredictionMode.LlExactAmbigDetection);
|
predictionMode == Antlr4.Runtime.Atn.PredictionMode.LlExactAmbigDetection);
|
||||||
switch (alts.Cardinality())
|
switch (alts.Cardinality())
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -755,7 +758,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
input.Seek(startIndex);
|
input.Seek(startIndex);
|
||||||
}
|
}
|
||||||
BitSet alts = EvalSemanticContext(D.predicates, outerContext, reportAmbiguities &&
|
BitSet alts = EvalSemanticContext(D.predicates, outerContext, reportAmbiguities &&
|
||||||
predictionMode == PredictionMode.LlExactAmbigDetection);
|
predictionMode == Antlr4.Runtime.Atn.PredictionMode.LlExactAmbigDetection);
|
||||||
D.prediction = ATN.InvalidAltNumber;
|
D.prediction = ATN.InvalidAltNumber;
|
||||||
switch (alts.Cardinality())
|
switch (alts.Cardinality())
|
||||||
{
|
{
|
||||||
|
@ -802,9 +805,9 @@ namespace Antlr4.Runtime.Atn
|
||||||
BitSet alts = new BitSet();
|
BitSet alts = new BitSet();
|
||||||
foreach (ATNConfig config in previous.s0.configs)
|
foreach (ATNConfig config in previous.s0.configs)
|
||||||
{
|
{
|
||||||
if (config.GetReachesIntoOuterContext() || config.GetState() is RuleStopState)
|
if (config.ReachesIntoOuterContext || config.State is RuleStopState)
|
||||||
{
|
{
|
||||||
alts.Set(config.GetAlt());
|
alts.Set(config.Alt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!alts.IsEmpty())
|
if (!alts.IsEmpty())
|
||||||
|
@ -867,10 +870,10 @@ namespace Antlr4.Runtime.Atn
|
||||||
IList<ATNConfig> skippedStopStates = null;
|
IList<ATNConfig> skippedStopStates = null;
|
||||||
foreach (ATNConfig c in closureConfigs)
|
foreach (ATNConfig c in closureConfigs)
|
||||||
{
|
{
|
||||||
if (c.GetState() is RuleStopState)
|
if (c.State is RuleStopState)
|
||||||
{
|
{
|
||||||
System.Diagnostics.Debug.Assert(c.GetContext().IsEmpty);
|
System.Diagnostics.Debug.Assert(c.Context.IsEmpty);
|
||||||
if (useContext && !c.GetReachesIntoOuterContext() || t == IntStreamConstants.Eof)
|
if (useContext && !c.ReachesIntoOuterContext || t == IntStreamConstants.Eof)
|
||||||
{
|
{
|
||||||
if (skippedStopStates == null)
|
if (skippedStopStates == null)
|
||||||
{
|
{
|
||||||
|
@ -880,11 +883,11 @@ namespace Antlr4.Runtime.Atn
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int n = c.GetState().NumberOfOptimizedTransitions;
|
int n = c.State.NumberOfOptimizedTransitions;
|
||||||
for (int ti = 0; ti < n; ti++)
|
for (int ti = 0; ti < n; ti++)
|
||||||
{
|
{
|
||||||
// for each optimized transition
|
// for each optimized transition
|
||||||
Transition trans = c.GetState().GetOptimizedTransition(ti);
|
Transition trans = c.State.GetOptimizedTransition(ti);
|
||||||
ATNState target = GetReachableTarget(c, trans, t);
|
ATNState target = GetReachableTarget(c, trans, t);
|
||||||
if (target != null)
|
if (target != null)
|
||||||
{
|
{
|
||||||
|
@ -907,8 +910,8 @@ namespace Antlr4.Runtime.Atn
|
||||||
{
|
{
|
||||||
reach = RemoveAllConfigsNotInRuleStopState(reach, contextCache);
|
reach = RemoveAllConfigsNotInRuleStopState(reach, contextCache);
|
||||||
}
|
}
|
||||||
if (skippedStopStates != null && (!useContext || !PredictionMode.HasConfigInRuleStopState
|
if (skippedStopStates != null && (!useContext || !Antlr4.Runtime.Atn.PredictionMode
|
||||||
(reach)))
|
.HasConfigInRuleStopState(reach)))
|
||||||
{
|
{
|
||||||
System.Diagnostics.Debug.Assert(!skippedStopStates.IsEmpty());
|
System.Diagnostics.Debug.Assert(!skippedStopStates.IsEmpty());
|
||||||
foreach (ATNConfig c_1 in skippedStopStates)
|
foreach (ATNConfig c_1 in skippedStopStates)
|
||||||
|
@ -994,14 +997,14 @@ namespace Antlr4.Runtime.Atn
|
||||||
protected internal virtual ATNConfigSet RemoveAllConfigsNotInRuleStopState(ATNConfigSet
|
protected internal virtual ATNConfigSet RemoveAllConfigsNotInRuleStopState(ATNConfigSet
|
||||||
configs, PredictionContextCache contextCache)
|
configs, PredictionContextCache contextCache)
|
||||||
{
|
{
|
||||||
if (PredictionMode.AllConfigsInRuleStopStates(configs))
|
if (Antlr4.Runtime.Atn.PredictionMode.AllConfigsInRuleStopStates(configs))
|
||||||
{
|
{
|
||||||
return configs;
|
return configs;
|
||||||
}
|
}
|
||||||
ATNConfigSet result = new ATNConfigSet();
|
ATNConfigSet result = new ATNConfigSet();
|
||||||
foreach (ATNConfig config in configs)
|
foreach (ATNConfig config in configs)
|
||||||
{
|
{
|
||||||
if (!(config.GetState() is RuleStopState))
|
if (!(config.State is RuleStopState))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1161,10 +1164,9 @@ namespace Antlr4.Runtime.Atn
|
||||||
int n = altToPred.Length;
|
int n = altToPred.Length;
|
||||||
foreach (ATNConfig c in configs)
|
foreach (ATNConfig c in configs)
|
||||||
{
|
{
|
||||||
if (ambigAlts.Get(c.GetAlt()))
|
if (ambigAlts.Get(c.Alt))
|
||||||
{
|
{
|
||||||
altToPred[c.GetAlt()] = SemanticContext.Or(altToPred[c.GetAlt()], c.GetSemanticContext
|
altToPred[c.Alt] = SemanticContext.Or(altToPred[c.Alt], c.SemanticContext);
|
||||||
());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int nPredAlts = 0;
|
int nPredAlts = 0;
|
||||||
|
@ -1309,26 +1311,26 @@ namespace Antlr4.Runtime.Atn
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// avoid infinite recursion
|
// avoid infinite recursion
|
||||||
if (config.GetState() is RuleStopState)
|
if (config.State is RuleStopState)
|
||||||
{
|
{
|
||||||
// We hit rule end. If we have context info, use it
|
// We hit rule end. If we have context info, use it
|
||||||
if (!config.GetContext().IsEmpty)
|
if (!config.Context.IsEmpty)
|
||||||
{
|
{
|
||||||
bool hasEmpty = config.GetContext().HasEmpty;
|
bool hasEmpty = config.Context.HasEmpty;
|
||||||
int nonEmptySize = config.GetContext().Size - (hasEmpty ? 1 : 0);
|
int nonEmptySize = config.Context.Size - (hasEmpty ? 1 : 0);
|
||||||
for (int i = 0; i < nonEmptySize; i++)
|
for (int i = 0; i < nonEmptySize; i++)
|
||||||
{
|
{
|
||||||
PredictionContext newContext = config.GetContext().GetParent(i);
|
PredictionContext newContext = config.Context.GetParent(i);
|
||||||
// "pop" return state
|
// "pop" return state
|
||||||
ATNState returnState = atn.states[config.GetContext().GetReturnState(i)];
|
ATNState returnState = atn.states[config.Context.GetReturnState(i)];
|
||||||
ATNConfig c = ATNConfig.Create(returnState, config.GetAlt(), newContext, config.GetSemanticContext
|
ATNConfig c = ATNConfig.Create(returnState, config.Alt, newContext, config.SemanticContext
|
||||||
());
|
);
|
||||||
// While we have context to pop back from, we may have
|
// While we have context to pop back from, we may have
|
||||||
// gotten that context AFTER having fallen off a rule.
|
// gotten that context AFTER having fallen off a rule.
|
||||||
// Make sure we track that we are now out of context.
|
// Make sure we track that we are now out of context.
|
||||||
c.SetOuterContextDepth(config.GetOuterContextDepth());
|
c.OuterContextDepth = config.OuterContextDepth;
|
||||||
System.Diagnostics.Debug.Assert(depth > int.MinValue);
|
System.Diagnostics.Debug.Assert(depth > int.MinValue);
|
||||||
if (optimize_closure_busy && c.GetContext().IsEmpty && !closureBusy.AddItem(c))
|
if (optimize_closure_busy && c.Context.IsEmpty && !closureBusy.AddItem(c))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1339,7 +1341,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
config = config.Transform(config.GetState(), PredictionContext.EmptyLocal);
|
config = config.Transform(config.State, PredictionContext.EmptyLocal);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1351,15 +1353,15 @@ namespace Antlr4.Runtime.Atn
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// else if we have no context info, just chase follow links (if greedy)
|
// else if we have no context info, just chase follow links (if greedy)
|
||||||
if (config.GetContext() == PredictionContext.EmptyFull)
|
if (config.Context == PredictionContext.EmptyFull)
|
||||||
{
|
{
|
||||||
// no need to keep full context overhead when we step out
|
// no need to keep full context overhead when we step out
|
||||||
config = config.Transform(config.GetState(), PredictionContext.EmptyLocal);
|
config = config.Transform(config.State, PredictionContext.EmptyLocal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ATNState p = config.GetState();
|
ATNState p = config.State;
|
||||||
// optimization
|
// optimization
|
||||||
if (!p.OnlyHasEpsilonTransitions)
|
if (!p.OnlyHasEpsilonTransitions)
|
||||||
{
|
{
|
||||||
|
@ -1384,7 +1386,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
if (optimize_closure_busy)
|
if (optimize_closure_busy)
|
||||||
{
|
{
|
||||||
bool checkClosure = false;
|
bool checkClosure = false;
|
||||||
switch (c.GetState().StateType)
|
switch (c.State.StateType)
|
||||||
{
|
{
|
||||||
case StateType.StarLoopEntry:
|
case StateType.StarLoopEntry:
|
||||||
case StateType.BlockEnd:
|
case StateType.BlockEnd:
|
||||||
|
@ -1402,7 +1404,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
|
|
||||||
case StateType.RuleStop:
|
case StateType.RuleStop:
|
||||||
{
|
{
|
||||||
checkClosure = c.GetContext().IsEmpty;
|
checkClosure = c.Context.IsEmpty;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1418,14 +1420,14 @@ namespace Antlr4.Runtime.Atn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int newDepth = depth;
|
int newDepth = depth;
|
||||||
if (config.GetState() is RuleStopState)
|
if (config.State is RuleStopState)
|
||||||
{
|
{
|
||||||
// target fell off end of rule; mark resulting c as having dipped into outer context
|
// target fell off end of rule; mark resulting c as having dipped into outer context
|
||||||
// We can't get here if incoming config was rule stop and we had context
|
// We can't get here if incoming config was rule stop and we had context
|
||||||
// track how far we dip into outer context. Might
|
// track how far we dip into outer context. Might
|
||||||
// come in handy and we avoid evaluating context dependent
|
// come in handy and we avoid evaluating context dependent
|
||||||
// preds if this is > 0.
|
// preds if this is > 0.
|
||||||
c.SetOuterContextDepth(c.GetOuterContextDepth() + 1);
|
c.OuterContextDepth = c.OuterContextDepth + 1;
|
||||||
System.Diagnostics.Debug.Assert(newDepth > int.MinValue);
|
System.Diagnostics.Debug.Assert(newDepth > int.MinValue);
|
||||||
newDepth--;
|
newDepth--;
|
||||||
}
|
}
|
||||||
|
@ -1434,20 +1436,19 @@ namespace Antlr4.Runtime.Atn
|
||||||
if (t is Antlr4.Runtime.Atn.RuleTransition)
|
if (t is Antlr4.Runtime.Atn.RuleTransition)
|
||||||
{
|
{
|
||||||
if (optimize_tail_calls && ((Antlr4.Runtime.Atn.RuleTransition)t).optimizedTailCall
|
if (optimize_tail_calls && ((Antlr4.Runtime.Atn.RuleTransition)t).optimizedTailCall
|
||||||
&& (!tail_call_preserves_sll || !PredictionContext.IsEmptyLocal(config.GetContext
|
&& (!tail_call_preserves_sll || !PredictionContext.IsEmptyLocal(config.Context
|
||||||
())))
|
)))
|
||||||
{
|
{
|
||||||
System.Diagnostics.Debug.Assert(c.GetContext() == config.GetContext());
|
System.Diagnostics.Debug.Assert(c.Context == config.Context);
|
||||||
if (newDepth == 0)
|
if (newDepth == 0)
|
||||||
{
|
{
|
||||||
// the pop/push of a tail call would keep the depth
|
// the pop/push of a tail call would keep the depth
|
||||||
// constant, except we latch if it goes negative
|
// constant, except we latch if it goes negative
|
||||||
newDepth--;
|
newDepth--;
|
||||||
if (!tail_call_preserves_sll && PredictionContext.IsEmptyLocal(config.GetContext(
|
if (!tail_call_preserves_sll && PredictionContext.IsEmptyLocal(config.Context))
|
||||||
)))
|
|
||||||
{
|
{
|
||||||
// make sure the SLL config "dips into the outer context" or prediction may not fall back to LL on conflict
|
// make sure the SLL config "dips into the outer context" or prediction may not fall back to LL on conflict
|
||||||
c.SetOuterContextDepth(c.GetOuterContextDepth() + 1);
|
c.OuterContextDepth = c.OuterContextDepth + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1532,7 +1533,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
ATNConfig c = null;
|
ATNConfig c = null;
|
||||||
if (collectPredicates && inContext)
|
if (collectPredicates && inContext)
|
||||||
{
|
{
|
||||||
SemanticContext newSemCtx = SemanticContext.And(config.GetSemanticContext(), pt.GetPredicate
|
SemanticContext newSemCtx = SemanticContext.And(config.SemanticContext, pt.GetPredicate
|
||||||
());
|
());
|
||||||
c = config.Transform(pt.target, newSemCtx);
|
c = config.Transform(pt.target, newSemCtx);
|
||||||
}
|
}
|
||||||
|
@ -1550,7 +1551,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
ATNConfig c;
|
ATNConfig c;
|
||||||
if (collectPredicates && (!pt.isCtxDependent || (pt.isCtxDependent && inContext)))
|
if (collectPredicates && (!pt.isCtxDependent || (pt.isCtxDependent && inContext)))
|
||||||
{
|
{
|
||||||
SemanticContext newSemCtx = SemanticContext.And(config.GetSemanticContext(), pt.GetPredicate
|
SemanticContext newSemCtx = SemanticContext.And(config.SemanticContext, pt.GetPredicate
|
||||||
());
|
());
|
||||||
c = config.Transform(pt.target, newSemCtx);
|
c = config.Transform(pt.target, newSemCtx);
|
||||||
}
|
}
|
||||||
|
@ -1568,38 +1569,38 @@ namespace Antlr4.Runtime.Atn
|
||||||
ATNState returnState = t.followState;
|
ATNState returnState = t.followState;
|
||||||
PredictionContext newContext;
|
PredictionContext newContext;
|
||||||
if (optimize_tail_calls && t.optimizedTailCall && (!tail_call_preserves_sll || !PredictionContext
|
if (optimize_tail_calls && t.optimizedTailCall && (!tail_call_preserves_sll || !PredictionContext
|
||||||
.IsEmptyLocal(config.GetContext())))
|
.IsEmptyLocal(config.Context)))
|
||||||
{
|
{
|
||||||
newContext = config.GetContext();
|
newContext = config.Context;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (contextCache != null)
|
if (contextCache != null)
|
||||||
{
|
{
|
||||||
newContext = contextCache.GetChild(config.GetContext(), returnState.stateNumber);
|
newContext = contextCache.GetChild(config.Context, returnState.stateNumber);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
newContext = config.GetContext().GetChild(returnState.stateNumber);
|
newContext = config.Context.GetChild(returnState.stateNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return config.Transform(t.target, newContext);
|
return config.Transform(t.target, newContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
private sealed class _IComparer_1557 : IComparer<ATNConfig>
|
private sealed class _IComparer_1563 : IComparer<ATNConfig>
|
||||||
{
|
{
|
||||||
public _IComparer_1557()
|
public _IComparer_1563()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Compare(ATNConfig o1, ATNConfig o2)
|
public int Compare(ATNConfig o1, ATNConfig o2)
|
||||||
{
|
{
|
||||||
int diff = o1.GetState().NonStopStateNumber - o2.GetState().NonStopStateNumber;
|
int diff = o1.State.NonStopStateNumber - o2.State.NonStopStateNumber;
|
||||||
if (diff != 0)
|
if (diff != 0)
|
||||||
{
|
{
|
||||||
return diff;
|
return diff;
|
||||||
}
|
}
|
||||||
diff = o1.GetAlt() - o2.GetAlt();
|
diff = o1.Alt - o2.Alt;
|
||||||
if (diff != 0)
|
if (diff != 0)
|
||||||
{
|
{
|
||||||
return diff;
|
return diff;
|
||||||
|
@ -1608,7 +1609,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly IComparer<ATNConfig> StateAltSortComparator = new _IComparer_1557
|
private static readonly IComparer<ATNConfig> StateAltSortComparator = new _IComparer_1563
|
||||||
();
|
();
|
||||||
|
|
||||||
private BitSet IsConflicted(ATNConfigSet configset, PredictionContextCache contextCache
|
private BitSet IsConflicted(ATNConfigSet configset, PredictionContextCache contextCache
|
||||||
|
@ -1620,22 +1621,22 @@ namespace Antlr4.Runtime.Atn
|
||||||
}
|
}
|
||||||
IList<ATNConfig> configs = new List<ATNConfig>(configset);
|
IList<ATNConfig> configs = new List<ATNConfig>(configset);
|
||||||
configs.Sort(StateAltSortComparator);
|
configs.Sort(StateAltSortComparator);
|
||||||
bool exact = !configset.DipsIntoOuterContext && predictionMode == PredictionMode.
|
bool exact = !configset.DipsIntoOuterContext && predictionMode == Antlr4.Runtime.Atn.PredictionMode
|
||||||
LlExactAmbigDetection;
|
.LlExactAmbigDetection;
|
||||||
BitSet alts = new BitSet();
|
BitSet alts = new BitSet();
|
||||||
int minAlt = configs[0].GetAlt();
|
int minAlt = configs[0].Alt;
|
||||||
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
|
||||||
// minAlt from the first state, #2 will fail if the assumption was
|
// minAlt from the first state, #2 will fail if the assumption was
|
||||||
// incorrect
|
// incorrect
|
||||||
int currentState = configs[0].GetState().NonStopStateNumber;
|
int currentState = configs[0].State.NonStopStateNumber;
|
||||||
for (int i = 0; i < configs.Count; i++)
|
for (int i = 0; i < configs.Count; i++)
|
||||||
{
|
{
|
||||||
ATNConfig config = configs[i];
|
ATNConfig config = configs[i];
|
||||||
int stateNumber = config.GetState().NonStopStateNumber;
|
int stateNumber = config.State.NonStopStateNumber;
|
||||||
if (stateNumber != currentState)
|
if (stateNumber != currentState)
|
||||||
{
|
{
|
||||||
if (config.GetAlt() != minAlt)
|
if (config.Alt != minAlt)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1645,29 +1646,29 @@ namespace Antlr4.Runtime.Atn
|
||||||
BitSet representedAlts = null;
|
BitSet representedAlts = null;
|
||||||
if (exact)
|
if (exact)
|
||||||
{
|
{
|
||||||
currentState = configs[0].GetState().NonStopStateNumber;
|
currentState = configs[0].State.NonStopStateNumber;
|
||||||
// get the represented alternatives of the first state
|
// get the represented alternatives of the first state
|
||||||
representedAlts = new BitSet();
|
representedAlts = new BitSet();
|
||||||
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++)
|
||||||
{
|
{
|
||||||
ATNConfig config = configs[i_1];
|
ATNConfig config = configs[i_1];
|
||||||
if (config.GetState().NonStopStateNumber != currentState)
|
if (config.State.NonStopStateNumber != currentState)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int alt = config.GetAlt();
|
int alt = config.Alt;
|
||||||
representedAlts.Set(alt);
|
representedAlts.Set(alt);
|
||||||
maxAlt = alt;
|
maxAlt = alt;
|
||||||
}
|
}
|
||||||
// quick check #3:
|
// quick check #3:
|
||||||
currentState = configs[0].GetState().NonStopStateNumber;
|
currentState = configs[0].State.NonStopStateNumber;
|
||||||
int currentAlt = minAlt;
|
int currentAlt = minAlt;
|
||||||
for (int i_2 = 0; i_2 < configs.Count; i_2++)
|
for (int i_2 = 0; i_2 < configs.Count; i_2++)
|
||||||
{
|
{
|
||||||
ATNConfig config = configs[i_2];
|
ATNConfig config = configs[i_2];
|
||||||
int stateNumber = config.GetState().NonStopStateNumber;
|
int stateNumber = config.State.NonStopStateNumber;
|
||||||
int alt = config.GetAlt();
|
int alt = config.Alt;
|
||||||
if (stateNumber != currentState)
|
if (stateNumber != currentState)
|
||||||
{
|
{
|
||||||
if (currentAlt != maxAlt)
|
if (currentAlt != maxAlt)
|
||||||
|
@ -1690,70 +1691,68 @@ namespace Antlr4.Runtime.Atn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
currentState = configs[0].GetState().NonStopStateNumber;
|
currentState = configs[0].State.NonStopStateNumber;
|
||||||
int firstIndexCurrentState = 0;
|
int firstIndexCurrentState = 0;
|
||||||
int lastIndexCurrentStateMinAlt = 0;
|
int lastIndexCurrentStateMinAlt = 0;
|
||||||
PredictionContext joinedCheckContext = configs[0].GetContext();
|
PredictionContext joinedCheckContext = configs[0].Context;
|
||||||
for (int i_3 = 1; i_3 < configs.Count; i_3++)
|
for (int i_3 = 1; i_3 < configs.Count; i_3++)
|
||||||
{
|
{
|
||||||
ATNConfig config = configs[i_3];
|
ATNConfig config = configs[i_3];
|
||||||
if (config.GetAlt() != minAlt)
|
if (config.Alt != minAlt)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (config.GetState().NonStopStateNumber != currentState)
|
if (config.State.NonStopStateNumber != currentState)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
lastIndexCurrentStateMinAlt = i_3;
|
lastIndexCurrentStateMinAlt = i_3;
|
||||||
joinedCheckContext = contextCache.Join(joinedCheckContext, configs[i_3].GetContext
|
joinedCheckContext = contextCache.Join(joinedCheckContext, configs[i_3].Context);
|
||||||
());
|
|
||||||
}
|
}
|
||||||
for (int i_4 = lastIndexCurrentStateMinAlt + 1; i_4 < configs.Count; i_4++)
|
for (int i_4 = lastIndexCurrentStateMinAlt + 1; i_4 < configs.Count; i_4++)
|
||||||
{
|
{
|
||||||
ATNConfig config = configs[i_4];
|
ATNConfig config = configs[i_4];
|
||||||
ATNState state = config.GetState();
|
ATNState state = config.State;
|
||||||
alts.Set(config.GetAlt());
|
alts.Set(config.Alt);
|
||||||
if (state.NonStopStateNumber != currentState)
|
if (state.NonStopStateNumber != currentState)
|
||||||
{
|
{
|
||||||
currentState = state.NonStopStateNumber;
|
currentState = state.NonStopStateNumber;
|
||||||
firstIndexCurrentState = i_4;
|
firstIndexCurrentState = i_4;
|
||||||
lastIndexCurrentStateMinAlt = i_4;
|
lastIndexCurrentStateMinAlt = i_4;
|
||||||
joinedCheckContext = config.GetContext();
|
joinedCheckContext = config.Context;
|
||||||
for (int j = firstIndexCurrentState + 1; j < configs.Count; j++)
|
for (int j = firstIndexCurrentState + 1; j < configs.Count; j++)
|
||||||
{
|
{
|
||||||
ATNConfig config2 = configs[j];
|
ATNConfig config2 = configs[j];
|
||||||
if (config2.GetAlt() != minAlt)
|
if (config2.Alt != minAlt)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (config2.GetState().NonStopStateNumber != currentState)
|
if (config2.State.NonStopStateNumber != currentState)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
lastIndexCurrentStateMinAlt = j;
|
lastIndexCurrentStateMinAlt = j;
|
||||||
joinedCheckContext = contextCache.Join(joinedCheckContext, config2.GetContext());
|
joinedCheckContext = contextCache.Join(joinedCheckContext, config2.Context);
|
||||||
}
|
}
|
||||||
i_4 = lastIndexCurrentStateMinAlt;
|
i_4 = lastIndexCurrentStateMinAlt;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
PredictionContext joinedCheckContext2 = config.GetContext();
|
PredictionContext joinedCheckContext2 = config.Context;
|
||||||
int currentAlt = config.GetAlt();
|
int currentAlt = config.Alt;
|
||||||
int lastIndexCurrentStateCurrentAlt = i_4;
|
int lastIndexCurrentStateCurrentAlt = i_4;
|
||||||
for (int j_1 = lastIndexCurrentStateCurrentAlt + 1; j_1 < configs.Count; j_1++)
|
for (int j_1 = lastIndexCurrentStateCurrentAlt + 1; j_1 < configs.Count; j_1++)
|
||||||
{
|
{
|
||||||
ATNConfig config2 = configs[j_1];
|
ATNConfig config2 = configs[j_1];
|
||||||
if (config2.GetAlt() != currentAlt)
|
if (config2.Alt != currentAlt)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (config2.GetState().NonStopStateNumber != currentState)
|
if (config2.State.NonStopStateNumber != currentState)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
lastIndexCurrentStateCurrentAlt = j_1;
|
lastIndexCurrentStateCurrentAlt = j_1;
|
||||||
joinedCheckContext2 = contextCache.Join(joinedCheckContext2, config2.GetContext()
|
joinedCheckContext2 = contextCache.Join(joinedCheckContext2, config2.Context);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
i_4 = lastIndexCurrentStateCurrentAlt;
|
i_4 = lastIndexCurrentStateCurrentAlt;
|
||||||
if (exact)
|
if (exact)
|
||||||
|
@ -1777,21 +1776,20 @@ namespace Antlr4.Runtime.Atn
|
||||||
for (int j = firstIndexCurrentState; j_1 <= lastIndexCurrentStateMinAlt; j_1++)
|
for (int j = firstIndexCurrentState; j_1 <= lastIndexCurrentStateMinAlt; j_1++)
|
||||||
{
|
{
|
||||||
ATNConfig checkConfig = configs[j_1];
|
ATNConfig checkConfig = configs[j_1];
|
||||||
if (checkConfig.GetSemanticContext() != SemanticContext.None && !checkConfig.GetSemanticContext
|
if (checkConfig.SemanticContext != SemanticContext.None && !checkConfig.SemanticContext
|
||||||
().Equals(config.GetSemanticContext()))
|
.Equals(config.SemanticContext))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (joinedCheckContext != checkConfig.GetContext())
|
if (joinedCheckContext != checkConfig.Context)
|
||||||
{
|
{
|
||||||
PredictionContext check = contextCache.Join(checkConfig.GetContext(), config.GetContext
|
PredictionContext check = contextCache.Join(checkConfig.Context, config.Context);
|
||||||
());
|
if (!checkConfig.Context.Equals(check))
|
||||||
if (!checkConfig.GetContext().Equals(check))
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
config.SetHidden(true);
|
config.IsHidden = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1855,9 +1853,9 @@ namespace Antlr4.Runtime.Atn
|
||||||
foreach (ATNConfig c in nvae.GetDeadEndConfigs())
|
foreach (ATNConfig c in nvae.GetDeadEndConfigs())
|
||||||
{
|
{
|
||||||
string trans = "no edges";
|
string trans = "no edges";
|
||||||
if (c.GetState().NumberOfOptimizedTransitions > 0)
|
if (c.State.NumberOfOptimizedTransitions > 0)
|
||||||
{
|
{
|
||||||
Transition t = c.GetState().GetOptimizedTransition(0);
|
Transition t = c.State.GetOptimizedTransition(0);
|
||||||
if (t is AtomTransition)
|
if (t is AtomTransition)
|
||||||
{
|
{
|
||||||
AtomTransition at = (AtomTransition)t;
|
AtomTransition at = (AtomTransition)t;
|
||||||
|
@ -1885,19 +1883,19 @@ namespace Antlr4.Runtime.Atn
|
||||||
, configs, outerContext);
|
, configs, outerContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual int GetUniqueAlt(ICollection<ATNConfig> configs)
|
public virtual int GetUniqueAlt(IEnumerable<ATNConfig> configs)
|
||||||
{
|
{
|
||||||
int alt = ATN.InvalidAltNumber;
|
int alt = ATN.InvalidAltNumber;
|
||||||
foreach (ATNConfig c in configs)
|
foreach (ATNConfig c in configs)
|
||||||
{
|
{
|
||||||
if (alt == ATN.InvalidAltNumber)
|
if (alt == ATN.InvalidAltNumber)
|
||||||
{
|
{
|
||||||
alt = c.GetAlt();
|
alt = c.Alt;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// found first alt
|
// found first alt
|
||||||
if (c.GetAlt() != alt)
|
if (c.Alt != alt)
|
||||||
{
|
{
|
||||||
return ATN.InvalidAltNumber;
|
return ATN.InvalidAltNumber;
|
||||||
}
|
}
|
||||||
|
@ -1906,14 +1904,14 @@ namespace Antlr4.Runtime.Atn
|
||||||
return alt;
|
return alt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool ConfigWithAltAtStopState(ICollection<ATNConfig> configs, int
|
public virtual bool ConfigWithAltAtStopState(IEnumerable<ATNConfig> configs, int
|
||||||
alt)
|
alt)
|
||||||
{
|
{
|
||||||
foreach (ATNConfig c in configs)
|
foreach (ATNConfig c in configs)
|
||||||
{
|
{
|
||||||
if (c.GetAlt() == alt)
|
if (c.Alt == alt)
|
||||||
{
|
{
|
||||||
if (c.GetState() is RuleStopState)
|
if (c.State is RuleStopState)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,8 +98,8 @@ namespace Antlr4.Runtime.Atn
|
||||||
public override int GetHashCode(ATNConfig o)
|
public override int GetHashCode(ATNConfig o)
|
||||||
{
|
{
|
||||||
int hashCode = 7;
|
int hashCode = 7;
|
||||||
hashCode = 31 * hashCode + o.GetState().stateNumber;
|
hashCode = 31 * hashCode + o.State.stateNumber;
|
||||||
hashCode = 31 * hashCode + o.GetContext().GetHashCode();
|
hashCode = 31 * hashCode + o.Context.GetHashCode();
|
||||||
return hashCode;
|
return hashCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,8 +117,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return a.GetState().stateNumber == b.GetState().stateNumber && a.GetContext().Equals
|
return a.State.stateNumber == b.State.stateNumber && a.Context.Equals(b.Context);
|
||||||
(b.GetContext());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,7 +258,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
ATNConfigSet dup = new ATNConfigSet();
|
ATNConfigSet dup = new ATNConfigSet();
|
||||||
foreach (ATNConfig c in configs)
|
foreach (ATNConfig c in configs)
|
||||||
{
|
{
|
||||||
c = c.Transform(c.GetState(), SemanticContext.None);
|
c = c.Transform(c.State, SemanticContext.None);
|
||||||
dup.AddItem(c);
|
dup.AddItem(c);
|
||||||
}
|
}
|
||||||
configs = dup;
|
configs = dup;
|
||||||
|
@ -293,11 +292,11 @@ namespace Antlr4.Runtime.Atn
|
||||||
/// , otherwise
|
/// , otherwise
|
||||||
/// <code>false</code>
|
/// <code>false</code>
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static bool HasConfigInRuleStopState(ATNConfigSet configs)
|
public static bool HasConfigInRuleStopState(IEnumerable<ATNConfig> configs)
|
||||||
{
|
{
|
||||||
foreach (ATNConfig c in configs)
|
foreach (ATNConfig c in configs)
|
||||||
{
|
{
|
||||||
if (c.GetState() is RuleStopState)
|
if (c.State is RuleStopState)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -325,11 +324,11 @@ namespace Antlr4.Runtime.Atn
|
||||||
/// , otherwise
|
/// , otherwise
|
||||||
/// <code>false</code>
|
/// <code>false</code>
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static bool AllConfigsInRuleStopStates(ATNConfigSet configs)
|
public static bool AllConfigsInRuleStopStates(IEnumerable<ATNConfig> configs)
|
||||||
{
|
{
|
||||||
foreach (ATNConfig config in configs)
|
foreach (ATNConfig config in configs)
|
||||||
{
|
{
|
||||||
if (!(config.GetState() is RuleStopState))
|
if (!(config.State is RuleStopState))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -363,7 +362,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
/// <see cref="ATNConfig#context">ATNConfig#context</see>
|
/// <see cref="ATNConfig#context">ATNConfig#context</see>
|
||||||
/// values
|
/// values
|
||||||
/// but different
|
/// but different
|
||||||
/// <see cref="ATNConfig.GetAlt()">ATNConfig.GetAlt()</see>
|
/// <see cref="ATNConfig.Alt()">ATNConfig.Alt()</see>
|
||||||
/// value, e.g.
|
/// value, e.g.
|
||||||
/// <code>(s, i, ctx, _)</code>
|
/// <code>(s, i, ctx, _)</code>
|
||||||
/// and
|
/// and
|
||||||
|
@ -392,7 +391,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
/// :
|
/// :
|
||||||
/// <pre>
|
/// <pre>
|
||||||
/// map[c] U= c.
|
/// map[c] U= c.
|
||||||
/// <see cref="ATNConfig.GetAlt()">getAlt()</see>
|
/// <see cref="ATNConfig.Alt()">getAlt()</see>
|
||||||
/// # map hash/equals uses s and x, not
|
/// # map hash/equals uses s and x, not
|
||||||
/// alt and not pred
|
/// alt and not pred
|
||||||
/// </pre>
|
/// </pre>
|
||||||
|
@ -644,7 +643,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
///
|
///
|
||||||
/// {1,2},{1,2}}}, etc...
|
/// {1,2},{1,2}}}, etc...
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static int ResolvesToJustOneViableAlt(ICollection<BitSet> altsets)
|
public static int ResolvesToJustOneViableAlt(IEnumerable<BitSet> altsets)
|
||||||
{
|
{
|
||||||
return GetSingleViableAlt(altsets);
|
return GetSingleViableAlt(altsets);
|
||||||
}
|
}
|
||||||
|
@ -668,7 +667,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
/// > 1, otherwise
|
/// > 1, otherwise
|
||||||
/// <code>false</code>
|
/// <code>false</code>
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static bool AllSubsetsConflict(ICollection<BitSet> altsets)
|
public static bool AllSubsetsConflict(IEnumerable<BitSet> altsets)
|
||||||
{
|
{
|
||||||
return !HasNonConflictingAltSet(altsets);
|
return !HasNonConflictingAltSet(altsets);
|
||||||
}
|
}
|
||||||
|
@ -692,7 +691,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
/// 1, otherwise
|
/// 1, otherwise
|
||||||
/// <code>false</code>
|
/// <code>false</code>
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static bool HasNonConflictingAltSet(ICollection<BitSet> altsets)
|
public static bool HasNonConflictingAltSet(IEnumerable<BitSet> altsets)
|
||||||
{
|
{
|
||||||
foreach (BitSet alts in altsets)
|
foreach (BitSet alts in altsets)
|
||||||
{
|
{
|
||||||
|
@ -723,7 +722,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
/// > 1, otherwise
|
/// > 1, otherwise
|
||||||
/// <code>false</code>
|
/// <code>false</code>
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static bool HasConflictingAltSet(ICollection<BitSet> altsets)
|
public static bool HasConflictingAltSet(IEnumerable<BitSet> altsets)
|
||||||
{
|
{
|
||||||
foreach (BitSet alts in altsets)
|
foreach (BitSet alts in altsets)
|
||||||
{
|
{
|
||||||
|
@ -750,7 +749,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
/// others, otherwise
|
/// others, otherwise
|
||||||
/// <code>false</code>
|
/// <code>false</code>
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static bool AllSubsetsEqual(ICollection<BitSet> altsets)
|
public static bool AllSubsetsEqual(IEnumerable<BitSet> altsets)
|
||||||
{
|
{
|
||||||
IEnumerator<BitSet> it = altsets.GetEnumerator();
|
IEnumerator<BitSet> it = altsets.GetEnumerator();
|
||||||
BitSet first = it.Next();
|
BitSet first = it.Next();
|
||||||
|
@ -773,7 +772,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
/// .
|
/// .
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="altsets">a collection of alternative subsets</param>
|
/// <param name="altsets">a collection of alternative subsets</param>
|
||||||
public static int GetUniqueAlt(ICollection<BitSet> altsets)
|
public static int GetUniqueAlt(IEnumerable<BitSet> altsets)
|
||||||
{
|
{
|
||||||
BitSet all = GetAlts(altsets);
|
BitSet all = GetAlts(altsets);
|
||||||
if (all.Cardinality() == 1)
|
if (all.Cardinality() == 1)
|
||||||
|
@ -800,7 +799,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
/// the set of represented alternatives in
|
/// the set of represented alternatives in
|
||||||
/// <code>altsets</code>
|
/// <code>altsets</code>
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static BitSet GetAlts(ICollection<BitSet> altsets)
|
public static BitSet GetAlts(IEnumerable<BitSet> altsets)
|
||||||
{
|
{
|
||||||
BitSet all = new BitSet();
|
BitSet all = new BitSet();
|
||||||
foreach (BitSet alts in altsets)
|
foreach (BitSet alts in altsets)
|
||||||
|
@ -821,13 +820,14 @@ namespace Antlr4.Runtime.Atn
|
||||||
/// :
|
/// :
|
||||||
/// <pre>
|
/// <pre>
|
||||||
/// map[c] U= c.
|
/// map[c] U= c.
|
||||||
/// <see cref="ATNConfig.GetAlt()">getAlt()</see>
|
/// <see cref="ATNConfig.Alt()">getAlt()</see>
|
||||||
/// # map hash/equals uses s and x, not
|
/// # map hash/equals uses s and x, not
|
||||||
/// alt and not pred
|
/// alt and not pred
|
||||||
/// </pre>
|
/// </pre>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[NotNull]
|
[NotNull]
|
||||||
public static ICollection<BitSet> GetConflictingAltSubsets(ATNConfigSet configs)
|
public static ICollection<BitSet> GetConflictingAltSubsets(IEnumerable<ATNConfig>
|
||||||
|
configs)
|
||||||
{
|
{
|
||||||
PredictionMode.AltAndContextMap configToAlts = new PredictionMode.AltAndContextMap
|
PredictionMode.AltAndContextMap configToAlts = new PredictionMode.AltAndContextMap
|
||||||
();
|
();
|
||||||
|
@ -839,7 +839,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
alts = new BitSet();
|
alts = new BitSet();
|
||||||
configToAlts.Put(c, alts);
|
configToAlts.Put(c, alts);
|
||||||
}
|
}
|
||||||
alts.Set(c.GetAlt());
|
alts.Set(c.Alt);
|
||||||
}
|
}
|
||||||
return configToAlts.Values;
|
return configToAlts.Values;
|
||||||
}
|
}
|
||||||
|
@ -856,28 +856,28 @@ namespace Antlr4.Runtime.Atn
|
||||||
/// map[c.
|
/// map[c.
|
||||||
/// <see cref="ATNConfig#state">state</see>
|
/// <see cref="ATNConfig#state">state</see>
|
||||||
/// ] U= c.
|
/// ] U= c.
|
||||||
/// <see cref="ATNConfig.GetAlt()">getAlt()</see>
|
/// <see cref="ATNConfig.Alt()">getAlt()</see>
|
||||||
/// </pre>
|
/// </pre>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[NotNull]
|
[NotNull]
|
||||||
public static IDictionary<ATNState, BitSet> GetStateToAltMap(ATNConfigSet configs
|
public static IDictionary<ATNState, BitSet> GetStateToAltMap(IEnumerable<ATNConfig
|
||||||
)
|
> configs)
|
||||||
{
|
{
|
||||||
IDictionary<ATNState, BitSet> m = new Dictionary<ATNState, BitSet>();
|
IDictionary<ATNState, BitSet> m = new Dictionary<ATNState, BitSet>();
|
||||||
foreach (ATNConfig c in configs)
|
foreach (ATNConfig c in configs)
|
||||||
{
|
{
|
||||||
BitSet alts = m.Get(c.GetState());
|
BitSet alts = m.Get(c.State);
|
||||||
if (alts == null)
|
if (alts == null)
|
||||||
{
|
{
|
||||||
alts = new BitSet();
|
alts = new BitSet();
|
||||||
m.Put(c.GetState(), alts);
|
m.Put(c.State, alts);
|
||||||
}
|
}
|
||||||
alts.Set(c.GetAlt());
|
alts.Set(c.Alt);
|
||||||
}
|
}
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool HasStateAssociatedWithOneAlt(ATNConfigSet configs)
|
public static bool HasStateAssociatedWithOneAlt(IEnumerable<ATNConfig> configs)
|
||||||
{
|
{
|
||||||
IDictionary<ATNState, BitSet> x = GetStateToAltMap(configs);
|
IDictionary<ATNState, BitSet> x = GetStateToAltMap(configs);
|
||||||
foreach (BitSet alts in x.Values)
|
foreach (BitSet alts in x.Values)
|
||||||
|
@ -890,7 +890,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int GetSingleViableAlt(ICollection<BitSet> altsets)
|
public static int GetSingleViableAlt(IEnumerable<BitSet> altsets)
|
||||||
{
|
{
|
||||||
BitSet viableAlts = new BitSet();
|
BitSet viableAlts = new BitSet();
|
||||||
foreach (BitSet alts in altsets)
|
foreach (BitSet alts in altsets)
|
||||||
|
|
|
@ -209,7 +209,7 @@ namespace Antlr4.Runtime.Dfa
|
||||||
stateStr += "*";
|
stateStr += "*";
|
||||||
foreach (ATNConfig config in s.configs)
|
foreach (ATNConfig config in s.configs)
|
||||||
{
|
{
|
||||||
if (config.GetReachesIntoOuterContext())
|
if (config.ReachesIntoOuterContext)
|
||||||
{
|
{
|
||||||
stateStr += "*";
|
stateStr += "*";
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -283,7 +283,7 @@ namespace Antlr4.Runtime.Misc
|
||||||
if (diagnostics)
|
if (diagnostics)
|
||||||
{
|
{
|
||||||
parser.AddErrorListener(new DiagnosticErrorListener());
|
parser.AddErrorListener(new DiagnosticErrorListener());
|
||||||
parser.Interpreter.SetPredictionMode(PredictionMode.LlExactAmbigDetection);
|
parser.Interpreter.PredictionMode = PredictionMode.LlExactAmbigDetection;
|
||||||
}
|
}
|
||||||
if (printTree || gui || psFile != null)
|
if (printTree || gui || psFile != null)
|
||||||
{
|
{
|
||||||
|
@ -292,7 +292,7 @@ namespace Antlr4.Runtime.Misc
|
||||||
if (Sll)
|
if (Sll)
|
||||||
{
|
{
|
||||||
// overrides diagnostics
|
// overrides diagnostics
|
||||||
parser.Interpreter.SetPredictionMode(PredictionMode.Sll);
|
parser.Interpreter.PredictionMode = PredictionMode.Sll;
|
||||||
}
|
}
|
||||||
parser.SetInputStream(tokens);
|
parser.SetInputStream(tokens);
|
||||||
parser.Trace = trace;
|
parser.Trace = trace;
|
||||||
|
|
|
@ -36,17 +36,19 @@ namespace Antlr4.Runtime
|
||||||
/// <author>Sam Harwell</author>
|
/// <author>Sam Harwell</author>
|
||||||
public class ProxyErrorListener<Symbol> : IAntlrErrorListener<Symbol>
|
public class ProxyErrorListener<Symbol> : IAntlrErrorListener<Symbol>
|
||||||
{
|
{
|
||||||
private readonly ICollection<IAntlrErrorListener<Symbol>> delegates;
|
private readonly IEnumerable<IAntlrErrorListener<Symbol>> delegates;
|
||||||
|
|
||||||
public ProxyErrorListener(ICollection<IAntlrErrorListener<Symbol>> delegates)
|
public ProxyErrorListener(IEnumerable<IAntlrErrorListener<Symbol>> delegates)
|
||||||
{
|
{
|
||||||
this.delegates = delegates;
|
this.delegates = delegates;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected internal virtual ICollection<IAntlrErrorListener<Symbol>> GetDelegates(
|
protected internal virtual IEnumerable<IAntlrErrorListener<Symbol>> Delegates
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return delegates;
|
get
|
||||||
|
{
|
||||||
|
return delegates;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void SyntaxError<T>(Recognizer<T, object> recognizer, T offendingSymbol
|
public virtual void SyntaxError<T>(Recognizer<T, object> recognizer, T offendingSymbol
|
||||||
|
|
|
@ -46,7 +46,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, BitSet ambigAlts, ATNConfigSet configs)
|
||||||
{
|
{
|
||||||
foreach (IAntlrErrorListener<IToken> listener in GetDelegates())
|
foreach (IAntlrErrorListener<IToken> listener in Delegates)
|
||||||
{
|
{
|
||||||
if (!(listener is IParserErrorListener))
|
if (!(listener is IParserErrorListener))
|
||||||
{
|
{
|
||||||
|
@ -61,7 +61,7 @@ namespace Antlr4.Runtime
|
||||||
public virtual void ReportAttemptingFullContext(Parser recognizer, DFA dfa, int startIndex
|
public virtual void ReportAttemptingFullContext(Parser recognizer, DFA dfa, int startIndex
|
||||||
, int stopIndex, SimulatorState initialState)
|
, int stopIndex, SimulatorState initialState)
|
||||||
{
|
{
|
||||||
foreach (IAntlrErrorListener<IToken> listener in GetDelegates())
|
foreach (IAntlrErrorListener<IToken> listener in Delegates)
|
||||||
{
|
{
|
||||||
if (!(listener is IParserErrorListener))
|
if (!(listener is IParserErrorListener))
|
||||||
{
|
{
|
||||||
|
@ -76,7 +76,7 @@ namespace Antlr4.Runtime
|
||||||
public virtual void ReportContextSensitivity(Parser recognizer, DFA dfa, int startIndex
|
public virtual void ReportContextSensitivity(Parser recognizer, DFA dfa, int startIndex
|
||||||
, int stopIndex, SimulatorState acceptState)
|
, int stopIndex, SimulatorState acceptState)
|
||||||
{
|
{
|
||||||
foreach (IAntlrErrorListener<IToken> listener in GetDelegates())
|
foreach (IAntlrErrorListener<IToken> listener in Delegates)
|
||||||
{
|
{
|
||||||
if (!(listener is IParserErrorListener))
|
if (!(listener is IParserErrorListener))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit e4d1c14c8df3f27105e3bbf935d49f500bc3552e
|
Subproject commit 7e785daa65e15f9786218e5dd63ea5a3cecf67a8
|
Loading…
Reference in New Issue