Cosmos/source2/Compiler/Cosmos.XSharp/Token.cs
HugeCode_cp 1aa8e737ed Added support of call arguments. ComWriteAL() can be now replaced with ComWrite(AL).
Warning: I didn't make it very elegant. Maybe I will look on it later.
2013-01-27 14:27:09 +00:00

47 lines
1.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Cosmos.Compiler.XSharp {
public enum TokenType {
// Line based
Comment, LiteralAsm
//
, Register, Keyword, AlphaNum
// Values
, ValueInt, ValueString
//
, WhiteSpace, Operator, Delimiter
, Call
// For now used during scanning while user is typing, but in future could be user methods we have to find etc
, Unknown
}
public class Token {
public TokenType Type = TokenType.Unknown;
public string Value;
public int SrcPosStart;
public int SrcPosEnd;
/// <summary>Get line number this token belongs to.</summary>
public int LineNumber { get; private set; }
public Token(int lineNumber) {
LineNumber = lineNumber;
return;
}
public override string ToString() {
return Value;
}
static public implicit operator string(Token aToken) {
return aToken.Value;
}
public bool Matches(string aText) {
return string.Equals(Value, aText, StringComparison.InvariantCultureIgnoreCase);
}
}
}