Merge branch 'sharpen'

This commit is contained in:
Sam Harwell 2013-02-18 13:16:09 -06:00
commit ee0f26b19d
22 changed files with 255 additions and 244 deletions

View File

@ -181,7 +181,7 @@ namespace Antlr4.Runtime
{
if (p >= n)
{
System.Diagnostics.Debug.Assert(La(1) == IIntStream.Eof);
System.Diagnostics.Debug.Assert(La(1) == IntStreamConstants.Eof);
throw new InvalidOperationException("cannot consume EOF");
}
//System.out.println("prev p="+p+", c="+(char)data[p]);
@ -205,14 +205,14 @@ namespace Antlr4.Runtime
// e.g., translate LA(-1) to use offset i=0; then data[p+0-1]
if ((p + i - 1) < 0)
{
return IIntStream.Eof;
return IntStreamConstants.Eof;
}
}
// invalid; no char before first char
if ((p + i - 1) >= n)
{
//System.out.println("char LA("+i+")=EOF; p="+p);
return IIntStream.Eof;
return IntStreamConstants.Eof;
}
//System.out.println("char LA("+i+")="+(char)data[p+i-1]+"; p="+p);
//System.out.println("LA("+i+"); p="+p+" n="+n+" data.length="+data.length);

View File

@ -28,7 +28,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System.Collections.Generic;
using Antlr4.Runtime;
using Antlr4.Runtime.Atn;
using Antlr4.Runtime.Misc;
using Sharpen;
@ -45,7 +44,7 @@ namespace Antlr4.Runtime.Atn
/// Special value added to the lookahead sets to indicate that we hit
/// a predicate during analysis if seeThruPreds==false.
/// </remarks>
public const int HitPred = IToken.InvalidType;
public const int HitPred = TokenConstants.InvalidType;
[NotNull]
public readonly ATN atn;
@ -150,14 +149,14 @@ namespace Antlr4.Runtime.Atn
{
if (PredictionContext.IsEmptyLocal(ctx))
{
look.Add(IToken.Epsilon);
look.Add(TokenConstants.Epsilon);
return;
}
else
{
if (ctx.IsEmpty && addEOF)
{
look.Add(IToken.Eof);
look.Add(TokenConstants.Eof);
return;
}
}
@ -208,7 +207,7 @@ namespace Antlr4.Runtime.Atn
{
if (t.GetType() == typeof(WildcardTransition))
{
look.AddAll(IntervalSet.Of(IToken.MinUserTokenType, atn.maxTokenType));
look.AddAll(IntervalSet.Of(TokenConstants.MinUserTokenType, atn.maxTokenType));
}
else
{
@ -218,7 +217,8 @@ namespace Antlr4.Runtime.Atn
{
if (t is NotSetTransition)
{
set = set.Complement(IntervalSet.Of(IToken.MinUserTokenType, atn.maxTokenType));
set = set.Complement(IntervalSet.Of(TokenConstants.MinUserTokenType, atn.maxTokenType
));
}
look.AddAll(set);
}

View File

@ -252,12 +252,12 @@ namespace Antlr4.Runtime.Atn
if (target.isAcceptState)
{
CaptureSimState(prevAccept, input, target);
if (t == IIntStream.Eof)
if (t == IntStreamConstants.Eof)
{
break;
}
}
if (t != IIntStream.Eof)
if (t != IntStreamConstants.Eof)
{
Consume(input);
t = input.La(1);
@ -282,9 +282,9 @@ namespace Antlr4.Runtime.Atn
else
{
// if no accept and EOF is first char, return EOF
if (t == IIntStream.Eof && input.Index == startIndex)
if (t == IntStreamConstants.Eof && input.Index == startIndex)
{
return IToken.Eof;
return TokenConstants.Eof;
}
throw new LexerNoViableAltException(recog, input, startIndex, reach);
}
@ -342,7 +342,7 @@ namespace Antlr4.Runtime.Atn
input.Seek(index);
this.line = line;
this.charPositionInLine = charPos;
if (input.La(1) != IIntStream.Eof)
if (input.La(1) != IntStreamConstants.Eof)
{
Consume(input);
}

View File

@ -509,7 +509,7 @@ namespace Antlr4.Runtime.Atn
}
}
s = target;
if (!s.isAcceptState && t != IIntStream.Eof)
if (!s.isAcceptState && t != IntStreamConstants.Eof)
{
input.Consume();
t = input.La(1);
@ -789,7 +789,7 @@ namespace Antlr4.Runtime.Atn
return predictedAlt;
}
previous = nextState;
if (t != IIntStream.Eof)
if (t != IntStreamConstants.Eof)
{
input.Consume();
t = input.La(1);
@ -873,7 +873,7 @@ namespace Antlr4.Runtime.Atn
if (c.GetState() is RuleStopState)
{
System.Diagnostics.Debug.Assert(c.GetContext().IsEmpty);
if (useContext && !c.GetReachesIntoOuterContext() || t == IIntStream.Eof)
if (useContext && !c.GetReachesIntoOuterContext() || t == IntStreamConstants.Eof)
{
if (skippedStopStates == null)
{
@ -906,7 +906,7 @@ namespace Antlr4.Runtime.Atn
Closure(reachIntermediate, reach, collectPredicates, hasMoreContext, contextCache
);
stepIntoGlobal = reach.GetDipsIntoOuterContext();
if (t == IIntStream.Eof)
if (t == IntStreamConstants.Eof)
{
reach = RemoveAllConfigsNotInRuleStopState(reach, contextCache);
}
@ -1825,7 +1825,7 @@ namespace Antlr4.Runtime.Atn
[NotNull]
public virtual string GetTokenName(int t)
{
if (t == IToken.Eof)
if (t == TokenConstants.Eof)
{
return "EOF";
}

View File

@ -27,7 +27,6 @@
* (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;
using Antlr4.Runtime.Atn;
using Antlr4.Runtime.Misc;
using Sharpen;
@ -46,7 +45,7 @@ namespace Antlr4.Runtime.Atn
// TODO (sam): should we really allow null here?
if (set == null)
{
set = IntervalSet.Of(IToken.InvalidType);
set = IntervalSet.Of(TokenConstants.InvalidType);
}
this.set = set;
}

View File

@ -171,7 +171,7 @@ namespace Antlr4.Runtime
public virtual void Consume()
{
if (La(1) == Eof)
if (La(1) == IntStreamConstants.Eof)
{
throw new InvalidOperationException("cannot consume EOF");
}
@ -230,7 +230,7 @@ namespace Antlr4.Runtime
((IWritableToken)t).TokenIndex = tokens.Count;
}
tokens.Add(t);
if (t.Type == IToken.Eof)
if (t.Type == TokenConstants.Eof)
{
fetchedEOF = true;
return i + 1;
@ -266,7 +266,7 @@ namespace Antlr4.Runtime
for (int i = start; i <= stop; i++)
{
IToken t = tokens[i];
if (t.Type == IToken.Eof)
if (t.Type == TokenConstants.Eof)
{
break;
}
@ -442,7 +442,7 @@ namespace Antlr4.Runtime
}
while (token.Channel != channel)
{
if (token.Type == IToken.Eof)
if (token.Type == TokenConstants.Eof)
{
return -1;
}
@ -630,7 +630,7 @@ namespace Antlr4.Runtime
for (int i = start; i <= stop; i++)
{
IToken t = tokens[i];
if (t.Type == IToken.Eof)
if (t.Type == TokenConstants.Eof)
{
break;
}

View File

@ -45,7 +45,7 @@ namespace Antlr4.Runtime
protected internal int charPositionInLine = -1;
protected internal int channel = DefaultChannel;
protected internal int channel = TokenConstants.DefaultChannel;
protected internal Tuple<ITokenSource, ICharStream> source;
@ -92,7 +92,7 @@ namespace Antlr4.Runtime
public CommonToken(int type, string text)
{
this.type = type;
this.channel = DefaultChannel;
this.channel = TokenConstants.DefaultChannel;
this.text = text;
}

View File

@ -64,7 +64,7 @@ namespace Antlr4.Runtime
/// </summary>
/// <remarks>Skip tokens on any channel but this one; this is how we skip whitespace...
/// </remarks>
protected internal int channel = IToken.DefaultChannel;
protected internal int channel = TokenConstants.DefaultChannel;
public CommonTokenStream(ITokenSource tokenSource) : base(tokenSource)
{
@ -145,7 +145,7 @@ namespace Antlr4.Runtime
{
n++;
}
if (t.Type == IToken.Eof)
if (t.Type == TokenConstants.Eof)
{
break;
}

View File

@ -196,7 +196,7 @@ namespace Antlr4.Runtime
ITokenStream tokens = ((ITokenStream)recognizer.InputStream);
int la = tokens.La(1);
// try cheaper subset first; might get lucky. seems to shave a wee bit off
if (recognizer.Atn.NextTokens(s).Contains(la) || la == IToken.Eof)
if (recognizer.Atn.NextTokens(s).Contains(la) || la == TokenConstants.Eof)
{
return;
}
@ -249,7 +249,7 @@ namespace Antlr4.Runtime
string input;
if (tokens != null)
{
if (e.GetStartToken().Type == IToken.Eof)
if (e.GetStartToken().Type == TokenConstants.Eof)
{
input = "<EOF>";
}
@ -426,7 +426,7 @@ namespace Antlr4.Runtime
int expectedTokenType = expecting.GetMinElement();
// get any element
string tokenText;
if (expectedTokenType == IToken.Eof)
if (expectedTokenType == TokenConstants.Eof)
{
tokenText = "<missing EOF>";
}
@ -436,7 +436,7 @@ namespace Antlr4.Runtime
}
IToken current = currentSymbol;
IToken lookback = ((ITokenStream)recognizer.InputStream).Lt(-1);
if (current.Type == IToken.Eof && lookback != null)
if (current.Type == TokenConstants.Eof && lookback != null)
{
current = lookback;
}
@ -449,8 +449,8 @@ namespace Antlr4.Runtime
{
ITokenFactory factory = tokenSource.TokenFactory;
return factory.Create(Tuple.Create(tokenSource, current.TokenSource.InputStream),
expectedTokenType, tokenText, IToken.DefaultChannel, -1, -1, current.Line, current
.Column);
expectedTokenType, tokenText, TokenConstants.DefaultChannel, -1, -1, current.
Line, current.Column);
}
public virtual IntervalSet GetExpectedTokens(Parser recognizer)
@ -481,7 +481,7 @@ namespace Antlr4.Runtime
string s = GetSymbolText(t);
if (s == null)
{
if (GetSymbolType(t) == IToken.Eof)
if (GetSymbolType(t) == TokenConstants.Eof)
{
s = "<EOF>";
}
@ -526,7 +526,7 @@ namespace Antlr4.Runtime
recoverSet.AddAll(follow);
ctx = ctx.parent;
}
recoverSet.Remove(IToken.Epsilon);
recoverSet.Remove(TokenConstants.Epsilon);
// System.out.println("recover set "+recoverSet.toString(recognizer.getTokenNames()));
return recoverSet;
}
@ -536,7 +536,7 @@ namespace Antlr4.Runtime
{
// System.err.println("consumeUntil("+set.toString(recognizer.getTokenNames())+")");
int ttype = ((ITokenStream)recognizer.InputStream).La(1);
while (ttype != IToken.Eof && !set.Contains(ttype))
while (ttype != TokenConstants.Eof && !set.Contains(ttype))
{
//System.out.println("consume during recover LA(1)="+getTokenNames()[input.LA(1)]);
// recognizer.getInputStream().consume();

View File

@ -35,41 +35,8 @@ namespace Antlr4.Runtime
{
/// <summary>A source of characters for an ANTLR lexer.</summary>
/// <remarks>A source of characters for an ANTLR lexer.</remarks>
public abstract class ICharStream : IIntStream
public interface ICharStream : IIntStream
{
/// <summary>
/// The minimum allowed value for a character in a
/// <code>CharStream</code>
/// .
/// </summary>
public const int MinChar = char.MinValue;
/// <summary>
/// The maximum allowed value for a character in a
/// <code>CharStream</code>
/// .
/// <p/>
/// This value is
/// <code>Character.MAX_VALUE - 1</code>
/// , which reserves the value
/// <code>Character.MAX_VALUE</code>
/// for special use within an implementing class.
/// For some implementations, the data buffers required for supporting the
/// marked ranges of
/// <see cref="IIntStream">IIntStream</see>
/// are stored as
/// <code>char[]</code>
/// instead
/// of
/// <code>int[]</code>
/// , with
/// <code>Character.MAX_VALUE</code>
/// being used instead of
/// <code>-1</code>
/// to mark the end of the stream internally.
/// </summary>
public const int MaxChar = char.MaxValue - 1;
/// <summary>
/// This method returns the text for a range of characters within this input
/// stream.
@ -107,6 +74,42 @@ namespace Antlr4.Runtime
/// getting the text of the specified interval
/// </exception>
[NotNull]
public abstract string GetText(Interval interval);
string GetText(Interval interval);
}
public static class CharStreamConstants
{
/// <summary>
/// The minimum allowed value for a character in a
/// <code>CharStream</code>
/// .
/// </summary>
public const int MinChar = char.MinValue;
/// <summary>
/// The maximum allowed value for a character in a
/// <code>CharStream</code>
/// .
/// <p/>
/// This value is
/// <code>Character.MAX_VALUE - 1</code>
/// , which reserves the value
/// <code>Character.MAX_VALUE</code>
/// for special use within an implementing class.
/// For some implementations, the data buffers required for supporting the
/// marked ranges of
/// <see cref="IIntStream">IIntStream</see>
/// are stored as
/// <code>char[]</code>
/// instead
/// of
/// <code>int[]</code>
/// , with
/// <code>Character.MAX_VALUE</code>
/// being used instead of
/// <code>-1</code>
/// to mark the end of the stream internally.
/// </summary>
public const int MaxChar = char.MaxValue - 1;
}
}

View File

@ -56,24 +56,8 @@ namespace Antlr4.Runtime
/// </li>
/// </ul>
/// </remarks>
public abstract class IIntStream
public interface IIntStream
{
/// <summary>
/// The value returned by
/// <see cref="La(int)">LA()</see>
/// when the end of the stream is
/// reached.
/// </summary>
public const int Eof = -1;
/// <summary>
/// The value returned by
/// <see cref="SourceName()">SourceName()</see>
/// when the actual name of the
/// underlying source is not known.
/// </summary>
public const string UnknownSourceName = "<unknown>";
/// <summary>Consumes the current symbol in the stream.</summary>
/// <remarks>
/// Consumes the current symbol in the stream. This method has the following
@ -110,7 +94,7 @@ namespace Antlr4.Runtime
/// <code>consume</code>
/// ).
/// </exception>
public abstract void Consume();
void Consume();
/// <summary>
/// Gets the value of the symbol at offset
@ -174,7 +158,7 @@ namespace Antlr4.Runtime
/// if the stream does not support
/// retrieving the value of the specified symbol
/// </exception>
public abstract int La(int i);
int La(int i);
/// <summary>
/// A mark provides a guarantee that
@ -243,7 +227,7 @@ namespace Antlr4.Runtime
/// <see cref="Release(int)">release()</see>
/// when the marked range is no longer required.
/// </returns>
public abstract int Mark();
int Mark();
/// <summary>
/// This method releases a marked range created by a call to
@ -269,7 +253,7 @@ namespace Antlr4.Runtime
/// .
/// </param>
/// <seealso cref="Mark()">Mark()</seealso>
public abstract void Release(int marker);
void Release(int marker);
/// <summary>
/// Return the index into the stream of the input symbol referred to by
@ -281,7 +265,7 @@ namespace Antlr4.Runtime
/// has occurred after this stream was
/// constructed.
/// </summary>
internal abstract int Index
int Index
{
get;
}
@ -334,7 +318,7 @@ namespace Antlr4.Runtime
/// if the stream does not support
/// seeking to the specified index
/// </exception>
public abstract void Seek(int index);
void Seek(int index);
/// <summary>
/// Returns the total number of symbols in the stream, including a single EOF
@ -348,7 +332,7 @@ namespace Antlr4.Runtime
/// if the size of the stream is
/// unknown.
/// </exception>
internal abstract int Size
int Size
{
get;
}
@ -361,9 +345,28 @@ namespace Antlr4.Runtime
/// <see cref="UnknownSourceName">UnknownSourceName</see>
/// .
/// </remarks>
public abstract string SourceName
string SourceName
{
get;
}
}
public static class IntStreamConstants
{
/// <summary>
/// The value returned by
/// <see cref="La(int)">LA()</see>
/// when the end of the stream is
/// reached.
/// </summary>
public const int Eof = -1;
/// <summary>
/// The value returned by
/// <see cref="SourceName()">SourceName()</see>
/// when the actual name of the
/// underlying source is not known.
/// </summary>
public const string UnknownSourceName = "<unknown>";
}
}

View File

@ -42,7 +42,109 @@ namespace Antlr4.Runtime
/// (so we can ignore tabs), token channel, index, and source from which
/// we obtained this token.
/// </remarks>
public abstract class IToken
public interface IToken
{
/// <summary>Get the text of the token.</summary>
/// <remarks>Get the text of the token.</remarks>
string Text
{
get;
}
/// <summary>Get the token type of the token.</summary>
/// <remarks>Get the token type of the token.</remarks>
int Type
{
get;
}
/// <summary>
/// The line number on which the 1st character of this token was matched,
/// line=1..n
/// </summary>
int Line
{
get;
}
/// <summary>
/// The index of the first character of this token relative to the
/// beginning of the line at which it occurs, 0..n-1
/// </summary>
int Column
{
get;
}
/// <summary>Return the channel this token.</summary>
/// <remarks>
/// Return the channel this token. Each token can arrive at the parser
/// on a different channel, but the parser only "tunes" to a single channel.
/// The parser ignores everything not on DEFAULT_CHANNEL.
/// </remarks>
int Channel
{
get;
}
/// <summary>An index from 0..n-1 of the token object in the input stream.</summary>
/// <remarks>
/// An index from 0..n-1 of the token object in the input stream.
/// This must be valid in order to print token streams and
/// use TokenRewriteStream.
/// Return -1 to indicate that this token was conjured up since
/// it doesn't have a valid index.
/// </remarks>
int TokenIndex
{
get;
}
/// <summary>
/// The starting character index of the token
/// This method is optional; return -1 if not implemented.
/// </summary>
/// <remarks>
/// The starting character index of the token
/// This method is optional; return -1 if not implemented.
/// </remarks>
int StartIndex
{
get;
}
/// <summary>The last character index of the token.</summary>
/// <remarks>
/// The last character index of the token.
/// This method is optional; return -1 if not implemented.
/// </remarks>
int StopIndex
{
get;
}
/// <summary>
/// Gets the
/// <see cref="ITokenSource">ITokenSource</see>
/// which created this token.
/// </summary>
ITokenSource TokenSource
{
get;
}
/// <summary>
/// Gets the
/// <see cref="ICharStream">ICharStream</see>
/// from which this token was derived.
/// </summary>
ICharStream InputStream
{
get;
}
}
public static class TokenConstants
{
public const int InvalidType = 0;
@ -58,7 +160,7 @@ namespace Antlr4.Runtime
public const int MinUserTokenType = 1;
public const int Eof = IIntStream.Eof;
public const int Eof = IntStreamConstants.Eof;
/// <summary>
/// All tokens go to the parser (unless skip() is called in that rule)
@ -80,104 +182,5 @@ namespace Antlr4.Runtime
/// by parser.
/// </remarks>
public const int HiddenChannel = 1;
/// <summary>Get the text of the token.</summary>
/// <remarks>Get the text of the token.</remarks>
internal abstract string Text
{
get;
}
/// <summary>Get the token type of the token.</summary>
/// <remarks>Get the token type of the token.</remarks>
internal abstract int Type
{
get;
}
/// <summary>
/// The line number on which the 1st character of this token was matched,
/// line=1..n
/// </summary>
internal abstract int Line
{
get;
}
/// <summary>
/// The index of the first character of this token relative to the
/// beginning of the line at which it occurs, 0..n-1
/// </summary>
internal abstract int Column
{
get;
}
/// <summary>Return the channel this token.</summary>
/// <remarks>
/// Return the channel this token. Each token can arrive at the parser
/// on a different channel, but the parser only "tunes" to a single channel.
/// The parser ignores everything not on DEFAULT_CHANNEL.
/// </remarks>
internal abstract int Channel
{
get;
}
/// <summary>An index from 0..n-1 of the token object in the input stream.</summary>
/// <remarks>
/// An index from 0..n-1 of the token object in the input stream.
/// This must be valid in order to print token streams and
/// use TokenRewriteStream.
/// Return -1 to indicate that this token was conjured up since
/// it doesn't have a valid index.
/// </remarks>
internal abstract int TokenIndex
{
get;
}
/// <summary>
/// The starting character index of the token
/// This method is optional; return -1 if not implemented.
/// </summary>
/// <remarks>
/// The starting character index of the token
/// This method is optional; return -1 if not implemented.
/// </remarks>
internal abstract int StartIndex
{
get;
}
/// <summary>The last character index of the token.</summary>
/// <remarks>
/// The last character index of the token.
/// This method is optional; return -1 if not implemented.
/// </remarks>
internal abstract int StopIndex
{
get;
}
/// <summary>
/// Gets the
/// <see cref="ITokenSource">ITokenSource</see>
/// which created this token.
/// </summary>
internal abstract ITokenSource TokenSource
{
get;
}
/// <summary>
/// Gets the
/// <see cref="ICharStream">ICharStream</see>
/// from which this token was derived.
/// </summary>
internal abstract ICharStream InputStream
{
get;
}
}
}

View File

@ -48,9 +48,9 @@ namespace Antlr4.Runtime
{
public const int DefaultMode = 0;
public const int DefaultTokenChannel = IToken.DefaultChannel;
public const int DefaultTokenChannel = TokenConstants.DefaultChannel;
public const int Hidden = IToken.HiddenChannel;
public const int Hidden = TokenConstants.HiddenChannel;
public const int MinCharValue = '\u0000';
@ -134,8 +134,8 @@ namespace Antlr4.Runtime
}
// rewind the input
_token = null;
_type = IToken.InvalidType;
_channel = IToken.DefaultChannel;
_type = TokenConstants.InvalidType;
_channel = TokenConstants.DefaultChannel;
_tokenStartCharIndex = -1;
_tokenStartCharPositionInLine = -1;
_tokenStartLine = -1;
@ -174,14 +174,14 @@ namespace Antlr4.Runtime
return _token;
}
_token = null;
_channel = IToken.DefaultChannel;
_channel = TokenConstants.DefaultChannel;
_tokenStartCharIndex = _input.Index;
_tokenStartCharPositionInLine = Interpreter.GetCharPositionInLine();
_tokenStartLine = Interpreter.GetLine();
_text = null;
do
{
_type = IToken.InvalidType;
_type = TokenConstants.InvalidType;
// System.out.println("nextToken line "+tokenStartLine+" at "+((char)input.LA(1))+
// " in mode "+mode+
// " at index "+input.index());
@ -197,11 +197,11 @@ namespace Antlr4.Runtime
Recover(e);
ttype = TokenTypes.Skip;
}
if (_input.La(1) == IIntStream.Eof)
if (_input.La(1) == IntStreamConstants.Eof)
{
_hitEOF = true;
}
if (_type == IToken.InvalidType)
if (_type == TokenConstants.InvalidType)
{
_type = ttype;
}
@ -354,8 +354,8 @@ outer_break: ;
int n = _token.StopIndex - _token.StartIndex + 1;
cpos = _token.Column + n;
}
IToken eof = _factory.Create(_tokenFactorySourcePair, IToken.Eof, null, IToken.DefaultChannel
, _input.Index, _input.Index - 1, Line, cpos);
IToken eof = _factory.Create(_tokenFactorySourcePair, TokenConstants.Eof, null, TokenConstants
.DefaultChannel, _input.Index, _input.Index - 1, Line, cpos);
Emit(eof);
return eof;
}
@ -485,7 +485,7 @@ outer_break: ;
{
IList<IToken> tokens = new List<IToken>();
IToken t = NextToken();
while (t.Type != IToken.Eof)
while (t.Type != TokenConstants.Eof)
{
tokens.Add(t);
t = NextToken();
@ -495,7 +495,7 @@ outer_break: ;
public virtual void Recover(LexerNoViableAltException e)
{
if (_input.La(1) != IIntStream.Eof)
if (_input.La(1) != IntStreamConstants.Eof)
{
// skip a char and try again
Interpreter.Consume(_input);
@ -526,7 +526,7 @@ outer_break: ;
string s = ((char)c).ToString();
switch (c)
{
case IToken.Eof:
case TokenConstants.Eof:
{
s = "<EOF>";
break;

View File

@ -483,14 +483,14 @@ namespace Antlr4.Runtime.Misc
return I.a;
}
}
return IToken.InvalidType;
return TokenConstants.InvalidType;
}
public virtual int GetMaxElement()
{
if (IsNil())
{
return IToken.InvalidType;
return TokenConstants.InvalidType;
}
Interval last = intervals[intervals.Count - 1];
return last.b;
@ -501,7 +501,7 @@ namespace Antlr4.Runtime.Misc
{
if (IsNil())
{
return IToken.InvalidType;
return TokenConstants.InvalidType;
}
int n = intervals.Count;
for (int i = 0; i < n; i++)
@ -517,7 +517,7 @@ namespace Antlr4.Runtime.Misc
}
}
}
return IToken.InvalidType;
return TokenConstants.InvalidType;
}
/// <summary>Return a list of Interval objects.</summary>
@ -672,13 +672,13 @@ namespace Antlr4.Runtime.Misc
protected internal virtual string ElementName(string[] tokenNames, int a)
{
if (a == IToken.Eof)
if (a == TokenConstants.Eof)
{
return "<EOF>";
}
else
{
if (a == IToken.Epsilon)
if (a == TokenConstants.Epsilon)
{
return "<EPSILON>";
}

View File

@ -734,12 +734,12 @@ namespace Antlr4.Runtime
return true;
}
// System.out.println("following "+s+"="+following);
if (!following.Contains(IToken.Epsilon))
if (!following.Contains(TokenConstants.Epsilon))
{
return false;
}
while (ctx != null && ctx.invokingState >= 0 && following.Contains(IToken.Epsilon
))
while (ctx != null && ctx.invokingState >= 0 && following.Contains(TokenConstants
.Epsilon))
{
ATNState invokingState = atn.states[ctx.invokingState];
RuleTransition rt = (RuleTransition)invokingState.Transition(0);
@ -750,7 +750,7 @@ namespace Antlr4.Runtime
}
ctx = (ParserRuleContext)ctx.parent;
}
if (following.Contains(IToken.Epsilon) && symbol == IToken.Eof)
if (following.Contains(TokenConstants.Epsilon) && symbol == TokenConstants.Eof)
{
return true;
}
@ -772,26 +772,26 @@ namespace Antlr4.Runtime
ATNState s = atn.states[State];
IntervalSet following = atn.NextTokens(s);
// System.out.println("following "+s+"="+following);
if (!following.Contains(IToken.Epsilon))
if (!following.Contains(TokenConstants.Epsilon))
{
return following;
}
IntervalSet expected = new IntervalSet();
expected.AddAll(following);
expected.Remove(IToken.Epsilon);
while (ctx != null && ctx.invokingState >= 0 && following.Contains(IToken.Epsilon
))
expected.Remove(TokenConstants.Epsilon);
while (ctx != null && ctx.invokingState >= 0 && following.Contains(TokenConstants
.Epsilon))
{
ATNState invokingState = atn.states[ctx.invokingState];
RuleTransition rt = (RuleTransition)invokingState.Transition(0);
following = atn.NextTokens(rt.followState);
expected.AddAll(following);
expected.Remove(IToken.Epsilon);
expected.Remove(TokenConstants.Epsilon);
ctx = (ParserRuleContext)ctx.parent;
}
if (following.Contains(IToken.Epsilon))
if (following.Contains(TokenConstants.Epsilon))
{
expected.Add(IToken.Eof);
expected.Add(TokenConstants.Eof);
}
return expected;
}

View File

@ -140,7 +140,7 @@ namespace Antlr4.Runtime
string s = t.Text;
if (s == null)
{
if (t.Type == IToken.Eof)
if (t.Type == TokenConstants.Eof)
{
s = "<EOF>";
}

View File

@ -156,7 +156,7 @@ namespace Antlr4.Runtime
public override int Execute(StringBuilder buf)
{
buf.Append(text);
if (tokens.Get(index).Type != IToken.Eof)
if (tokens.Get(index).Type != TokenConstants.Eof)
{
buf.Append(tokens.Get(index).Text);
}
@ -488,7 +488,7 @@ namespace Antlr4.Runtime
if (op == null)
{
// no operation at that index, just dump token
if (t.Type != IToken.Eof)
if (t.Type != TokenConstants.Eof)
{
buf.Append(t.Text);
}

View File

@ -118,7 +118,7 @@ namespace Antlr4.Runtime.Tree
{
if (symbol != null)
{
if (symbol.Type == IToken.Eof)
if (symbol.Type == TokenConstants.Eof)
{
return "<EOF>";
}

View File

@ -173,7 +173,7 @@ namespace Antlr4.Runtime
// prime
public virtual void Consume()
{
if (La(1) == IIntStream.Eof)
if (La(1) == IntStreamConstants.Eof)
{
throw new InvalidOperationException("cannot consume EOF");
}
@ -234,7 +234,7 @@ namespace Antlr4.Runtime
{
for (int i = 0; i < n; i++)
{
if (this.n > 0 && data[this.n - 1] == IIntStream.Eof)
if (this.n > 0 && data[this.n - 1] == IntStreamConstants.Eof)
{
return i;
}
@ -280,12 +280,12 @@ namespace Antlr4.Runtime
}
if (index > n)
{
return IIntStream.Eof;
return IntStreamConstants.Eof;
}
int c = data[index];
if (c == (char)IIntStream.Eof)
if (c == (char)IntStreamConstants.Eof)
{
return IIntStream.Eof;
return IntStreamConstants.Eof;
}
return c;
}

View File

@ -167,7 +167,8 @@ namespace Antlr4.Runtime
}
if (index >= n)
{
System.Diagnostics.Debug.Assert(n > 0 && tokens[n - 1].Type == IToken.Eof);
System.Diagnostics.Debug.Assert(n > 0 && tokens[n - 1].Type == TokenConstants.Eof
);
return tokens[n - 1];
}
return tokens[index];
@ -211,7 +212,7 @@ namespace Antlr4.Runtime
public virtual void Consume()
{
if (La(1) == IToken.Eof)
if (La(1) == TokenConstants.Eof)
{
throw new InvalidOperationException("cannot consume EOF");
}
@ -272,7 +273,7 @@ namespace Antlr4.Runtime
{
for (int i = 0; i < n; i++)
{
if (this.n > 0 && tokens[this.n - 1].Type == IToken.Eof)
if (this.n > 0 && tokens[this.n - 1].Type == TokenConstants.Eof)
{
return i;
}

@ -1 +1 @@
Subproject commit 0d551e4e690a3665ef0d0455cc71de0ad08ef7e7
Subproject commit 68be6f96a8f913182e085b25c640aeeb93b9b122

View File

@ -2,7 +2,9 @@
-nativeTypeSystem
-organizeUsings
-nativeInterfaces
-tabToSpaces
-indentWithSpaces
-paramCountFileNames
-separateInterfaceConstants
-methodMapping System.out.println System.Console.WriteLine