Regenerate code after ignoring several more types and methods

This commit is contained in:
Sam Harwell 2013-02-15 16:40:34 -06:00
parent 6674e9c4c7
commit d21e393059
11 changed files with 1 additions and 989 deletions

View File

@ -117,30 +117,22 @@
<Compile Include="IWritableToken.cs" />
<Compile Include="Lexer.cs" />
<Compile Include="LexerNoViableAltException.cs" />
<Compile Include="Misc\AbstractEqualityComparator`1.cs" />
<Compile Include="Misc\Args.cs" />
<Compile Include="Misc\Array2DHashSet`1.cs" />
<Compile Include="Misc\DoubleKeyMap`3.cs" />
<Compile Include="Misc\FlexibleHashMap`2.cs" />
<Compile Include="Misc\IEqualityComparator`1.cs" />
<Compile Include="Misc\IFunc0`1.cs" />
<Compile Include="Misc\IFunc1`2.cs" />
<Compile Include="Misc\IIntSet.cs" />
<Compile Include="Misc\IntegerList.cs" />
<Compile Include="Misc\IntegerStack.cs" />
<Compile Include="Misc\Interval.cs" />
<Compile Include="Misc\IntervalSet.cs" />
<Compile Include="Misc\IPredicate`1.cs" />
<Compile Include="Misc\MultiMap`2.cs" />
<Compile Include="Misc\ObjectEqualityComparator.cs" />
<Compile Include="Misc\OrderedHashSet`1.cs" />
<Compile Include="Misc\ParseCanceledException.cs" />
<Compile Include="Misc\RuleDependencyChecker.cs" />
<Compile Include="Misc\RuleDependencyProcessor.cs" />
<Compile Include="Misc\TestRig.cs" />
<Compile Include="Misc\Tuple.cs" />
<Compile Include="Misc\Tuple`2.cs" />
<Compile Include="Misc\Tuple`3.cs" />
<Compile Include="Misc\Utils.cs" />
<Compile Include="NoViableAltException.cs" />
<Compile Include="Parser.cs" />

View File

@ -1,50 +0,0 @@
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using Antlr4.Runtime.Misc;
using Sharpen;
namespace Antlr4.Runtime.Misc
{
/// <summary>
/// This abstract base class is provided so performance-critical applications can
/// use virtual- instead of interface-dispatch when calling comparator methods.
/// </summary>
/// <remarks>
/// This abstract base class is provided so performance-critical applications can
/// use virtual- instead of interface-dispatch when calling comparator methods.
/// </remarks>
/// <author>Sam Harwell</author>
public abstract class AbstractEqualityComparator<T> : IEqualityComparator<T>
{
public abstract bool Equals(T arg1, T arg2);
public abstract int HashCode(T arg1);
}
}

View File

@ -1,74 +0,0 @@
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using Antlr4.Runtime.Misc;
using Sharpen;
namespace Antlr4.Runtime.Misc
{
/// <summary>
/// This interface provides an abstract concept of object equality independent of
/// <see cref="object.Equals(object)">object.Equals(object)</see>
/// (object equality) and the
/// <code>==</code>
/// operator
/// (reference equality). It can be used to provide algorithm-specific unordered
/// comparisons without requiring changes to the object itself.
/// </summary>
/// <author>Sam Harwell</author>
public interface IEqualityComparator<T>
{
/// <summary>This method returns a hash code for the specified object.</summary>
/// <remarks>This method returns a hash code for the specified object.</remarks>
/// <param name="obj">The object.</param>
/// <returns>
/// The hash code for
/// <code>obj</code>
/// .
/// </returns>
int HashCode(T obj);
/// <summary>This method tests if two objects are equal.</summary>
/// <remarks>This method tests if two objects are equal.</remarks>
/// <param name="a">The first object to compare.</param>
/// <param name="b">The second object to compare.</param>
/// <returns>
///
/// <code>true</code>
/// if
/// <code>a</code>
/// equals
/// <code>b</code>
/// , otherwise
/// <code>false</code>
/// .
/// </returns>
bool Equals(T a, T b);
}
}

View File

@ -1,346 +0,0 @@
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using Antlr4.Runtime.Misc;
using Sharpen;
namespace Antlr4.Runtime.Misc
{
/// <author>Sam Harwell</author>
public class IntegerList
{
private static int[] EmptyData = new int[0];
private const int InitialSize = 4;
private const int MaxArraySize = int.MaxValue - 8;
[NotNull]
private int[] _data;
private int _size;
public IntegerList()
{
_data = EmptyData;
}
public IntegerList(int capacity)
{
if (capacity < 0)
{
throw new ArgumentException();
}
if (capacity == 0)
{
_data = EmptyData;
}
else
{
_data = new int[capacity];
}
}
public IntegerList(Antlr4.Runtime.Misc.IntegerList list)
{
_data = list._data.Clone();
_size = list._size;
}
public IntegerList(ICollection<int> list) : this(list.Count)
{
foreach (int value in list)
{
Add(value);
}
}
public void Add(int value)
{
if (_data.Length == _size)
{
EnsureCapacity(_size + 1);
}
_data[_size] = value;
_size++;
}
public void AddAll(int[] array)
{
EnsureCapacity(_size + array.Length);
System.Array.Copy(array, 0, _data, _size, array.Length);
_size += array.Length;
}
public void AddAll(Antlr4.Runtime.Misc.IntegerList list)
{
EnsureCapacity(_size + list._size);
System.Array.Copy(list._data, 0, _data, _size, list._size);
_size += list._size;
}
public void AddAll(ICollection<int> list)
{
EnsureCapacity(_size + list.Count);
int current = 0;
foreach (int x in list)
{
_data[_size + current] = x;
}
_size += list.Count;
}
public int Get(int index)
{
if (index < 0 || index >= _size)
{
throw new IndexOutOfRangeException();
}
return _data[index];
}
public bool Contains(int value)
{
for (int i = 0; i < _size; i++)
{
if (_data[i] == value)
{
return true;
}
}
return false;
}
public int Set(int index, int value)
{
if (index < 0 || index >= _size)
{
throw new IndexOutOfRangeException();
}
int previous = _data[index];
_data[index] = value;
return previous;
}
public int RemoveAt(int index)
{
int value = Get(index);
System.Array.Copy(_data, index + 1, _data, index, _size - index - 1);
_data[_size - 1] = 0;
_size--;
return value;
}
public void RemoveRange(int fromIndex, int toIndex)
{
if (fromIndex < 0 || toIndex < 0 || fromIndex > _size || toIndex > _size)
{
throw new IndexOutOfRangeException();
}
if (fromIndex > toIndex)
{
throw new ArgumentException();
}
System.Array.Copy(_data, toIndex, _data, fromIndex, _size - toIndex);
Arrays.Fill(_data, _size - (toIndex - fromIndex), _size, 0);
_size -= (toIndex - fromIndex);
}
public bool IsEmpty()
{
return _size == 0;
}
public int Size()
{
return _size;
}
public void TrimToSize()
{
if (_data.Length == _size)
{
return;
}
_data = Arrays.CopyOf(_data, _size);
}
public void Clear()
{
Arrays.Fill(_data, 0, _size, 0);
_size = 0;
}
public int[] ToArray()
{
if (_size == 0)
{
return EmptyData;
}
return Arrays.CopyOf(_data, _size);
}
public void Sort()
{
Arrays.Sort(_data, 0, _size);
}
/// <summary>Compares the specified object with this list for equality.</summary>
/// <remarks>
/// Compares the specified object with this list for equality. Returns
/// <code>true</code>
/// if and only if the specified object is also an
/// <see cref="IntegerList">IntegerList</see>
/// ,
/// both lists have the same size, and all corresponding pairs of elements in
/// the two lists are equal. In other words, two lists are defined to be
/// equal if they contain the same elements in the same order.
/// <p>
/// This implementation first checks if the specified object is this
/// list. If so, it returns
/// <code>true</code>
/// ; if not, it checks if the
/// specified object is an
/// <see cref="IntegerList">IntegerList</see>
/// . If not, it returns
/// <code>false</code>
/// ;
/// if so, it checks the size of both lists. If the lists are not the same size,
/// it returns
/// <code>false</code>
/// ; otherwise it iterates over both lists, comparing
/// corresponding pairs of elements. If any comparison returns
/// <code>false</code>
/// ,
/// this method returns
/// <code>false</code>
/// .
/// </remarks>
/// <param name="o">the object to be compared for equality with this list</param>
/// <returns>
///
/// <code>true</code>
/// if the specified object is equal to this list
/// </returns>
public override bool Equals(object o)
{
if (o == this)
{
return true;
}
if (!(o is Antlr4.Runtime.Misc.IntegerList))
{
return false;
}
Antlr4.Runtime.Misc.IntegerList other = (Antlr4.Runtime.Misc.IntegerList)o;
if (_size != other._size)
{
return false;
}
for (int i = 0; i < _size; i++)
{
if (_data[i] != other._data[i])
{
return false;
}
}
return true;
}
/// <summary>Returns the hash code value for this list.</summary>
/// <remarks>
/// Returns the hash code value for this list.
/// <p/>
/// This implementation uses exactly the code that is used to define the
/// list hash function in the documentation for the
/// <see cref="System.Collections.IList{E}.GetHashCode()">System.Collections.IList&lt;E&gt;.GetHashCode()
/// </see>
/// method.
/// </remarks>
/// <returns>the hash code value for this list</returns>
public override int GetHashCode()
{
int hashCode = 1;
for (int i = 0; i < _size; i++)
{
hashCode = 31 * hashCode + _data[i];
}
return hashCode;
}
/// <summary>Returns a string representation of this list.</summary>
/// <remarks>Returns a string representation of this list.</remarks>
public override string ToString()
{
return Arrays.ToString(ToArray());
}
public int BinarySearch(int key)
{
return System.Array.BinarySearch(_data, 0, _size, key);
}
public int BinarySearch(int fromIndex, int toIndex, int key)
{
if (fromIndex < 0 || toIndex < 0 || fromIndex > _size || toIndex > _size)
{
throw new IndexOutOfRangeException();
}
return System.Array.BinarySearch(_data, fromIndex, toIndex, key);
}
private void EnsureCapacity(int capacity)
{
if (capacity < 0 || capacity > MaxArraySize)
{
throw new OutOfMemoryException();
}
int newLength;
if (_data.Length == 0)
{
newLength = InitialSize;
}
else
{
newLength = _data.Length;
}
while (newLength < capacity)
{
newLength = newLength * 2;
if (newLength < 0 || newLength > MaxArraySize)
{
newLength = MaxArraySize;
}
}
_data = Arrays.CopyOf(_data, newLength);
}
}
}

View File

@ -1,65 +0,0 @@
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using Antlr4.Runtime.Misc;
using Sharpen;
namespace Antlr4.Runtime.Misc
{
/// <author>Sam Harwell</author>
public class IntegerStack : IntegerList
{
public IntegerStack()
{
}
public IntegerStack(int capacity) : base(capacity)
{
}
public IntegerStack(Antlr4.Runtime.Misc.IntegerStack list) : base(list)
{
}
public void Push(int value)
{
Add(value);
}
public int Pop()
{
return RemoveAt(Size() - 1);
}
public int Peek()
{
return Get(Size() - 1);
}
}
}

View File

@ -1,97 +0,0 @@
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using Antlr4.Runtime.Misc;
using Sharpen;
namespace Antlr4.Runtime.Misc
{
/// <summary>
/// This default implementation of
/// <see cref="IEqualityComparator{T}">IEqualityComparator&lt;T&gt;</see>
/// uses object equality
/// for comparisons by calling
/// <see cref="object.GetHashCode()">object.GetHashCode()</see>
/// and
/// <see cref="object.Equals(object)">object.Equals(object)</see>
/// .
/// </summary>
/// <author>Sam Harwell</author>
public sealed class ObjectEqualityComparator : AbstractEqualityComparator<object>
{
public static readonly ObjectEqualityComparator Instance = new ObjectEqualityComparator
();
/// <summary>
/// <inheritDoc></inheritDoc>
/// <p/>
/// This implementation returns
/// <code>obj.</code>
/// <see cref="object.GetHashCode()">hashCode()</see>
/// .
/// </summary>
public override int HashCode(object obj)
{
if (obj == null)
{
return 0;
}
return obj.GetHashCode();
}
/// <summary>
/// <inheritDoc></inheritDoc>
/// <p/>
/// This implementation relies on object equality. If both objects are
/// <code>null</code>
/// , this method returns
/// <code>true</code>
/// . Otherwise if only
/// <code>a</code>
/// is
/// <code>null</code>
/// , this method returns
/// <code>false</code>
/// . Otherwise,
/// this method returns the result of
/// <code>a.</code>
/// <see cref="object.Equals(object)">equals</see>
/// <code>(b)</code>
/// .
/// </summary>
public override bool Equals(object a, object b)
{
if (a == null)
{
return b == null;
}
return a.Equals(b);
}
}
}

View File

@ -1,58 +0,0 @@
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using Sharpen;
namespace Antlr4.Runtime.Misc
{
/// <author>Sam Harwell</author>
public sealed class Tuple
{
public static System.Tuple<T1, T2> Create<T1, T2>(T1 item1, T2 item2)
{
return new System.Tuple<T1, T2>(item1, item2);
}
public static System.Tuple<T1, T2, T3> Create<T1, T2, T3>(T1 item1, T2 item2, T3
item3)
{
return new System.Tuple<T1, T2, T3>(item1, item2, item3);
}
internal static bool Equals(object x, object y)
{
return x == y || (x != null && x.Equals(y));
}
public Tuple()
{
}
// static utility class
}
}

View File

@ -1,84 +0,0 @@
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using Sharpen;
namespace Antlr4.Runtime.Misc
{
/// <author>Sam Harwell</author>
public class Tuple<T1, T2>
{
private readonly T1 item1;
private readonly T2 item2;
public Tuple(T1 item1, T2 item2)
{
this.item1 = item1;
this.item2 = item2;
}
public T1 GetItem1()
{
return item1;
}
public T2 GetItem2()
{
return item2;
}
public override bool Equals(object obj)
{
if (obj == this)
{
return true;
}
else
{
if (!(obj is Tuple<object, object>))
{
return false;
}
}
Tuple<object, object> other = (Tuple<object, object>)obj;
return Tuple.Equals(this.item1, other.item1) && Tuple.Equals(this.item2, other.item2
);
}
public override int GetHashCode()
{
int hash = 5;
hash = 79 * hash + (this.item1 != null ? this.item1.GetHashCode() : 0);
hash = 79 * hash + (this.item2 != null ? this.item2.GetHashCode() : 0);
return hash;
}
}
}

View File

@ -1,93 +0,0 @@
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using Sharpen;
namespace Antlr4.Runtime.Misc
{
/// <author>Sam Harwell</author>
public class Tuple<T1, T2, T3>
{
private readonly T1 item1;
private readonly T2 item2;
private readonly T3 item3;
public Tuple(T1 item1, T2 item2, T3 item3)
{
this.item1 = item1;
this.item2 = item2;
this.item3 = item3;
}
public T1 GetItem1()
{
return item1;
}
public T2 GetItem2()
{
return item2;
}
public T3 GetItem3()
{
return item3;
}
public override bool Equals(object obj)
{
if (obj == this)
{
return true;
}
else
{
if (!(obj is Tuple<object, object, object>))
{
return false;
}
}
Tuple<object, object, object> other = (Tuple<object, object, object>)obj;
return Tuple.Equals(this.item1, other.item1) && Tuple.Equals(this.item2, other.item2
) && Tuple.Equals(this.item3, other.item3);
}
public override int GetHashCode()
{
int hash = 5;
hash = 79 * hash + (this.item1 != null ? this.item1.GetHashCode() : 0);
hash = 79 * hash + (this.item2 != null ? this.item2.GetHashCode() : 0);
hash = 79 * hash + (this.item3 != null ? this.item3.GetHashCode() : 0);
return hash;
}
}
}

View File

@ -27,57 +27,15 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Antlr4.Runtime.Misc;
using Java.Awt;
using Java.Awt.Event;
using Sharpen;
namespace Antlr4.Runtime.Misc
{
public class Utils
{
public static string Join<_T0>(IEnumerable<_T0> iter, string separator)
{
return Join(iter.GetEnumerator(), separator);
}
public static string Join<T>(T[] array, string separator)
{
return Join(Arrays.AsList(array), separator);
}
// Seriously: why isn't this built in to java? ugh!
public static string Join<T>(IEnumerator<T> iter, string separator)
{
StringBuilder buf = new StringBuilder();
while (iter.HasNext())
{
buf.Append(iter.Next());
if (iter.HasNext())
{
buf.Append(separator);
}
}
return buf.ToString();
}
public static bool Equals(object x, object y)
{
if (x == y)
{
return true;
}
if (x == null || y == null)
{
return false;
}
return x.Equals(y);
}
public static int NumNonnull(object[] data)
{
int n = 0;
@ -145,15 +103,6 @@ namespace Antlr4.Runtime.Misc
return buf.ToString();
}
/// <exception cref="System.IO.IOException"></exception>
public static void WriteFile(string fileName, string content)
{
FileWriter fw = new FileWriter(fileName);
TextWriter w = new BufferedWriter(fw);
w.Write(content);
w.Close();
}
public static void RemoveAll<T, _T1>(IList<T> list, IPredicate<_T1> predicate)
{
int j = 0;
@ -192,67 +141,5 @@ namespace Antlr4.Runtime.Misc
}
}
}
/// <exception cref="System.Exception"></exception>
public static void WaitForClose(Window window)
{
object Lock = new object();
Sharpen.Thread t = new _Thread_146(Lock, window);
t.Start();
window.AddWindowListener(new _WindowAdapter_162(Lock, window));
t.Join();
}
private sealed class _Thread_146 : Sharpen.Thread
{
public _Thread_146(object Lock, Window window)
{
this.Lock = Lock;
this.window = window;
}
public override void Run()
{
lock (Lock)
{
while (window.IsVisible())
{
try
{
Sharpen.Runtime.Wait(Lock, 500);
}
catch (Exception)
{
}
}
}
}
private readonly object Lock;
private readonly Window window;
}
private sealed class _WindowAdapter_162 : WindowAdapter
{
public _WindowAdapter_162(object Lock, Window window)
{
this.Lock = Lock;
this.window = window;
}
public override void WindowClosing(WindowEvent arg0)
{
lock (Lock)
{
window.SetVisible(false);
Sharpen.Runtime.Notify(Lock);
}
}
private readonly object Lock;
private readonly Window window;
}
}
}

@ -1 +1 @@
Subproject commit ad17f36a468eb693df02676fa108567bcd319c5a
Subproject commit c7dc3828fc49781d3015565db387f37c38137ee6