forked from jasder/antlr
Merge branch 'sharpen'
This commit is contained in:
commit
bc2b1cf44e
|
@ -7,3 +7,6 @@
|
|||
[Rr]elease/
|
||||
reference/.metadata/
|
||||
reference/antlr4.net/
|
||||
|
||||
# ignore Java (Maven) build directory
|
||||
tool/target/
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit b106c4363db4aa913887021c7c2cf245ba7a5fa3
|
||||
Subproject commit 421b0b305ac3db5fac0074f8b3ec36fed675b3b8
|
|
@ -1 +1 @@
|
|||
Subproject commit 512c3252f2f4ddc3ad34862b1f649f337592ff26
|
||||
Subproject commit 047ebf59b4eee4fc8700f62c4b365f7d190a5b33
|
|
@ -393,6 +393,23 @@ namespace Antlr4.Runtime.Test
|
|||
Assert.AreEqual(expecting, result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This case is responsible for antlr/antlr4#153.
|
||||
* https://github.com/antlr/antlr4/issues/153
|
||||
*/
|
||||
[TestMethod]
|
||||
public void TestMergeWhereAdditionMergesThreeExistingIntervals()
|
||||
{
|
||||
IntervalSet s = new IntervalSet();
|
||||
s.Add(0);
|
||||
s.Add(3);
|
||||
s.Add(5);
|
||||
s.Add(0, 7);
|
||||
String expecting = "{0..7}";
|
||||
String result = s.ToString();
|
||||
Assert.AreEqual(expecting, result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestMergeWithDoubleOverlap()
|
||||
{
|
||||
|
|
|
@ -186,17 +186,18 @@ namespace Antlr4.Runtime.Atn
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// We cannot execute predicates dependent upon local context unless we know
|
||||
/// for sure we are in the correct context.
|
||||
/// We cannot execute predicates dependent upon local context unless
|
||||
/// we know for sure we are in the correct context.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// We cannot execute predicates dependent upon local context unless we know
|
||||
/// for sure we are in the correct context. Because there is no way to do
|
||||
/// this efficiently, we simply cannot evaluate dependent predicates unless
|
||||
/// we are in the rule that initially invokes the ATN simulator.
|
||||
/// closure() tracks the depth of how far we dip into the outer context:
|
||||
/// depth > 0. Note that it may not be totally accurate depth since I don't
|
||||
/// ever decrement. TODO: make it a boolean then
|
||||
/// We cannot execute predicates dependent upon local context unless
|
||||
/// we know for sure we are in the correct context. Because there is
|
||||
/// no way to do this efficiently, we simply cannot evaluate
|
||||
/// dependent predicates unless we are in the rule that initially
|
||||
/// invokes the ATN simulator.
|
||||
/// closure() tracks the depth of how far we dip into the
|
||||
/// outer context: depth > 0. Note that it may not be totally
|
||||
/// accurate depth since I don't ever decrement. TODO: make it a boolean then
|
||||
/// </remarks>
|
||||
public virtual int OuterContextDepth
|
||||
{
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace Antlr4.Runtime.Atn
|
|||
/// heuristic which almost always works but is much faster
|
||||
/// than precise answer.
|
||||
/// </remarks>
|
||||
internal static readonly PredictionMode Sll = new PredictionMode();
|
||||
public static readonly PredictionMode Sll = new PredictionMode();
|
||||
|
||||
/// <summary>Full LL(*) that always gets right answer.</summary>
|
||||
/// <remarks>
|
||||
|
@ -56,7 +56,7 @@ namespace Antlr4.Runtime.Atn
|
|||
/// sure which alt to predict. We don't always know what
|
||||
/// the ambiguity is in this mode.
|
||||
/// </remarks>
|
||||
internal static readonly PredictionMode Ll = new PredictionMode();
|
||||
public static readonly PredictionMode Ll = new PredictionMode();
|
||||
|
||||
/// <summary>
|
||||
/// Tell the full LL prediction algorithm to pursue lookahead until
|
||||
|
@ -71,8 +71,8 @@ namespace Antlr4.Runtime.Atn
|
|||
/// continue looking for the exact ambiguous sequence even if
|
||||
/// it has already figured out which alternative to predict.
|
||||
/// </remarks>
|
||||
internal static readonly PredictionMode LlExactAmbigDetection = new PredictionMode
|
||||
();
|
||||
public static readonly PredictionMode LlExactAmbigDetection = new PredictionMode(
|
||||
);
|
||||
|
||||
/// <summary>A Map that uses just the state and the stack context as the key.</summary>
|
||||
/// <remarks>A Map that uses just the state and the stack context as the key.</remarks>
|
||||
|
|
|
@ -39,6 +39,9 @@ namespace Antlr4.Runtime
|
|||
{
|
||||
private const long serialVersionUID = -6708843461296520577L;
|
||||
|
||||
protected internal static readonly Tuple<ITokenSource, ICharStream> EmptySource =
|
||||
Tuple.Create<ITokenSource, ICharStream>(null, null);
|
||||
|
||||
protected internal int type;
|
||||
|
||||
protected internal int line;
|
||||
|
@ -94,6 +97,7 @@ namespace Antlr4.Runtime
|
|||
this.type = type;
|
||||
this.channel = TokenConstants.DefaultChannel;
|
||||
this.text = text;
|
||||
this.source = EmptySource;
|
||||
}
|
||||
|
||||
public CommonToken(IToken oldToken)
|
||||
|
|
|
@ -178,21 +178,23 @@ namespace Antlr4.Runtime.Misc
|
|||
intervals[i] = bigger;
|
||||
// make sure we didn't just create an interval that
|
||||
// should be merged with next interval in list
|
||||
if (i < intervals.Count - 1)
|
||||
while (i < intervals.Count - 1)
|
||||
{
|
||||
i++;
|
||||
Interval next = intervals[i];
|
||||
if (bigger.Adjacent(next) || !bigger.Disjoint(next))
|
||||
if (!bigger.Adjacent(next) && bigger.Disjoint(next))
|
||||
{
|
||||
// if we bump up against or overlap next, merge
|
||||
intervals.RemoveAt(i);
|
||||
// remove this one
|
||||
i--;
|
||||
// move backwards to what we just set
|
||||
intervals[i] = bigger.Union(next);
|
||||
break;
|
||||
}
|
||||
// if we bump up against or overlap next, merge
|
||||
intervals.RemoveAt(i);
|
||||
// remove this one
|
||||
i--;
|
||||
// move backwards to what we just set
|
||||
intervals[i] = bigger.Union(next);
|
||||
// set to 3 merged ones
|
||||
}
|
||||
// set to 3 merged ones
|
||||
// first call to next after previous duplicates the result
|
||||
return;
|
||||
}
|
||||
if (addition.StartsBeforeDisjoint(r))
|
||||
|
|
|
@ -174,7 +174,10 @@ namespace Antlr4.Runtime.Misc
|
|||
public static void Main(string[] args)
|
||||
{
|
||||
Antlr4.Runtime.Misc.TestRig testRig = new Antlr4.Runtime.Misc.TestRig(args);
|
||||
testRig.Process();
|
||||
if (args.Length >= 2)
|
||||
{
|
||||
testRig.Process();
|
||||
}
|
||||
}
|
||||
|
||||
/// <exception cref="System.Exception"></exception>
|
||||
|
|
Loading…
Reference in New Issue