forked from jasder/antlr
Merge branch 'sharpen'
This commit is contained in:
commit
6708ae6db3
|
@ -1 +1 @@
|
|||
Subproject commit 8dedc2f0957b5f242059d750b3148364c49ffc4a
|
||||
Subproject commit a1b85fb2ae7d6475ca83559f47978f2fefd13e4f
|
|
@ -1 +1 @@
|
|||
Subproject commit b48d1045d1b494172f1a1c572aa3798868c94aa4
|
||||
Subproject commit f01e18ba72eda0825e09da106ff9c9e7c337cd22
|
|
@ -43,9 +43,9 @@ namespace Antlr4.Runtime.Atn
|
|||
|
||||
public const char RuleVariantDelimiter = '$';
|
||||
|
||||
public static readonly string RuleLfVariantMarker = "$lf$";
|
||||
public const string RuleLfVariantMarker = "$lf$";
|
||||
|
||||
public static readonly string RuleNolfVariantMarker = "$nolf$";
|
||||
public const string RuleNolfVariantMarker = "$nolf$";
|
||||
|
||||
/// <summary>Must distinguish between missing edge and edge we know leads nowhere</summary>
|
||||
[NotNull]
|
||||
|
|
|
@ -32,8 +32,9 @@ using Sharpen;
|
|||
|
||||
namespace Antlr4.Runtime.Misc
|
||||
{
|
||||
/// <summary>An immutable inclusive interval a..b</summary>
|
||||
public class Interval
|
||||
/// <summary>An immutable inclusive interval a..b.</summary>
|
||||
/// <remarks>An immutable inclusive interval a..b.</remarks>
|
||||
public struct Interval
|
||||
{
|
||||
public const int IntervalPoolMaxValue = 1000;
|
||||
|
||||
|
@ -85,15 +86,18 @@ namespace Antlr4.Runtime.Misc
|
|||
/// <summary>return number of elements between a and b inclusively.</summary>
|
||||
/// <remarks>
|
||||
/// return number of elements between a and b inclusively. x..x is length 1.
|
||||
/// if b < a, then length is 0. 9..10 has length 2.
|
||||
/// if b < a, then length is 0. 9..10 has length 2.
|
||||
/// </remarks>
|
||||
public virtual int Length()
|
||||
public int Length
|
||||
{
|
||||
if (b < a)
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
if (b < a)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return b - a + 1;
|
||||
}
|
||||
return b - a + 1;
|
||||
}
|
||||
|
||||
public override bool Equals(object o)
|
||||
|
@ -122,64 +126,63 @@ namespace Antlr4.Runtime.Misc
|
|||
}
|
||||
|
||||
/// <summary>Does this start completely before other? Disjoint</summary>
|
||||
public virtual bool StartsBeforeDisjoint(Antlr4.Runtime.Misc.Interval other)
|
||||
public bool StartsBeforeDisjoint(Antlr4.Runtime.Misc.Interval other)
|
||||
{
|
||||
return this.a < other.a && this.b < other.a;
|
||||
}
|
||||
|
||||
/// <summary>Does this start at or before other? Nondisjoint</summary>
|
||||
public virtual bool StartsBeforeNonDisjoint(Antlr4.Runtime.Misc.Interval other)
|
||||
public bool StartsBeforeNonDisjoint(Antlr4.Runtime.Misc.Interval other)
|
||||
{
|
||||
return this.a <= other.a && this.b >= other.a;
|
||||
}
|
||||
|
||||
/// <summary>Does this.a start after other.b? May or may not be disjoint</summary>
|
||||
public virtual bool StartsAfter(Antlr4.Runtime.Misc.Interval other)
|
||||
public bool StartsAfter(Antlr4.Runtime.Misc.Interval other)
|
||||
{
|
||||
return this.a > other.a;
|
||||
}
|
||||
|
||||
/// <summary>Does this start completely after other? Disjoint</summary>
|
||||
public virtual bool StartsAfterDisjoint(Antlr4.Runtime.Misc.Interval other)
|
||||
public bool StartsAfterDisjoint(Antlr4.Runtime.Misc.Interval other)
|
||||
{
|
||||
return this.a > other.b;
|
||||
}
|
||||
|
||||
/// <summary>Does this start after other? NonDisjoint</summary>
|
||||
public virtual bool StartsAfterNonDisjoint(Antlr4.Runtime.Misc.Interval other)
|
||||
public bool StartsAfterNonDisjoint(Antlr4.Runtime.Misc.Interval other)
|
||||
{
|
||||
return this.a > other.a && this.a <= other.b;
|
||||
}
|
||||
|
||||
// this.b>=other.b implied
|
||||
/// <summary>Are both ranges disjoint? I.e., no overlap?</summary>
|
||||
public virtual bool Disjoint(Antlr4.Runtime.Misc.Interval other)
|
||||
public bool Disjoint(Antlr4.Runtime.Misc.Interval other)
|
||||
{
|
||||
return StartsBeforeDisjoint(other) || StartsAfterDisjoint(other);
|
||||
}
|
||||
|
||||
/// <summary>Are two intervals adjacent such as 0..41 and 42..42?</summary>
|
||||
public virtual bool Adjacent(Antlr4.Runtime.Misc.Interval other)
|
||||
public bool Adjacent(Antlr4.Runtime.Misc.Interval other)
|
||||
{
|
||||
return this.a == other.b + 1 || this.b == other.a - 1;
|
||||
}
|
||||
|
||||
public virtual bool ProperlyContains(Antlr4.Runtime.Misc.Interval other)
|
||||
public bool ProperlyContains(Antlr4.Runtime.Misc.Interval other)
|
||||
{
|
||||
return other.a >= this.a && other.b <= this.b;
|
||||
}
|
||||
|
||||
/// <summary>Return the interval computed from combining this and other</summary>
|
||||
public virtual Antlr4.Runtime.Misc.Interval Union(Antlr4.Runtime.Misc.Interval other
|
||||
)
|
||||
public Antlr4.Runtime.Misc.Interval Union(Antlr4.Runtime.Misc.Interval other)
|
||||
{
|
||||
return Antlr4.Runtime.Misc.Interval.Of(Math.Min(a, other.a), Math.Max(b, other.b)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>Return the interval in common between this and o</summary>
|
||||
public virtual Antlr4.Runtime.Misc.Interval Intersection(Antlr4.Runtime.Misc.Interval
|
||||
other)
|
||||
public Antlr4.Runtime.Misc.Interval Intersection(Antlr4.Runtime.Misc.Interval other
|
||||
)
|
||||
{
|
||||
return Antlr4.Runtime.Misc.Interval.Of(Math.Max(a, other.a), Math.Min(b, other.b)
|
||||
);
|
||||
|
@ -198,7 +201,7 @@ namespace Antlr4.Runtime.Misc
|
|||
/// , which would result in two disjoint intervals
|
||||
/// instead of the single one returned by this method.
|
||||
/// </summary>
|
||||
public virtual Antlr4.Runtime.Misc.Interval DifferenceNotProperlyContained(Antlr4.Runtime.Misc.Interval
|
||||
public Antlr4.Runtime.Misc.Interval DifferenceNotProperlyContained(Antlr4.Runtime.Misc.Interval
|
||||
other)
|
||||
{
|
||||
Antlr4.Runtime.Misc.Interval diff = null;
|
||||
|
|
|
@ -49,11 +49,11 @@ namespace Antlr4.Runtime.Misc
|
|||
/// <author>Sam Harwell</author>
|
||||
public class RuleDependencyProcessor : AbstractProcessor
|
||||
{
|
||||
public static readonly string RuleDependencyClassName = "org.antlr.v4.runtime.RuleDependency";
|
||||
public const string RuleDependencyClassName = "org.antlr.v4.runtime.RuleDependency";
|
||||
|
||||
public static readonly string RuleDependenciesClassName = "org.antlr.v4.runtime.RuleDependencies";
|
||||
public const string RuleDependenciesClassName = "org.antlr.v4.runtime.RuleDependencies";
|
||||
|
||||
public static readonly string RuleVersionClassName = "org.antlr.v4.runtime.RuleVersion";
|
||||
public const string RuleVersionClassName = "org.antlr.v4.runtime.RuleVersion";
|
||||
|
||||
public RuleDependencyProcessor()
|
||||
{
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace Antlr4.Runtime.Misc
|
|||
/// </remarks>
|
||||
public class TestRig
|
||||
{
|
||||
public static readonly string LexerStartRuleName = "tokens";
|
||||
public const string LexerStartRuleName = "tokens";
|
||||
|
||||
protected internal string grammarName;
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ namespace Antlr4.Runtime
|
|||
/// </remarks>
|
||||
public class TokenStreamRewriter
|
||||
{
|
||||
public static readonly string DefaultProgramName = "default";
|
||||
public const string DefaultProgramName = "default";
|
||||
|
||||
public const int ProgramInitSize = 100;
|
||||
|
||||
|
|
|
@ -418,7 +418,7 @@ namespace Antlr4.Runtime
|
|||
int bufferStartIndex = GetBufferStartIndex();
|
||||
if (n > 0 && data[n - 1] == char.MaxValue)
|
||||
{
|
||||
if (interval.a + interval.Length() > bufferStartIndex + n)
|
||||
if (interval.a + interval.Length > bufferStartIndex + n)
|
||||
{
|
||||
throw new ArgumentException("the interval extends past the end of the stream");
|
||||
}
|
||||
|
@ -430,7 +430,7 @@ namespace Antlr4.Runtime
|
|||
}
|
||||
// convert from absolute to local index
|
||||
int i = interval.a - bufferStartIndex;
|
||||
return new string(data, i, interval.Length());
|
||||
return new string(data, i, interval.Length);
|
||||
}
|
||||
|
||||
protected internal int GetBufferStartIndex()
|
||||
|
|
Loading…
Reference in New Issue