progress
This commit is contained in:
parent
16e76d6b31
commit
484dbfc9d9
529 changed files with 113694 additions and 0 deletions
41
AspClassic.Parser/Token.cs
Normal file
41
AspClassic.Parser/Token.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
#define DEBUG
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// The base class for all tokens. Contains line and column information as well as token type.
|
||||
/// </summary>
|
||||
public abstract class Token
|
||||
{
|
||||
private readonly TokenType _Type;
|
||||
|
||||
private readonly Span _Span;
|
||||
|
||||
/// <summary>
|
||||
/// The type of the token.
|
||||
/// </summary>
|
||||
public TokenType Type => _Type;
|
||||
|
||||
/// <summary>
|
||||
/// The span of the token in the source text.
|
||||
/// </summary>
|
||||
public Span Span => _Span;
|
||||
|
||||
protected Token(TokenType type, Span span)
|
||||
{
|
||||
Debug.Assert(Enum.IsDefined(typeof(TokenType), type));
|
||||
_Type = type;
|
||||
_Span = span;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the unreserved keyword type of an identifier.
|
||||
/// </summary>
|
||||
/// <returns>The unreserved keyword type of an identifier, the token's type otherwise.</returns>
|
||||
public virtual TokenType AsUnreservedKeyword()
|
||||
{
|
||||
return Type;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue