3 namespace Mercury.Scanning
29 public class Token : IEquatable<Token>
38 public Token(
string value,
TokenType type,
int position,
bool quoted =
false)
40 if (value == null)
throw new ArgumentNullException(
"value");
51 public string Value {
get;
private set; }
57 public int Position {
get;
private set; }
60 public bool Quoted {
get;
private set; }
66 public override bool Equals(
object obj)
69 return other == null ?
false : Equals(other);
73 {
return Value.GetHashCode(); }
76 {
return string.Format(Quoted ?
"{0}\t <{1}>\t [\"{2}\"]" :
"{0}\t <{1}>\t [{2}]", Position, Type, Value); }
82 #region [ IEquatable ]
86 return (other != null ) && (Type == other.Type )
87 && (Position == other.
Position) && (Value == other.Value);
int Position
Position in the input text.
override string ToString()
Token, a part of an input text recognized by tokenizer
override int GetHashCode()
Token(string value, TokenType type, int position, bool quoted=false)
Creates a new Token.
override bool Equals(object obj)
TokenType
Defines token types. The actual conditions depend on the Mercury.Scanning.ITokenizer implementation...