Token.cs 826 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System;
  2. namespace csharp_sccd_compiler
  3. {
  4. public class Token
  5. {
  6. public enum Type
  7. {
  8. SLASH,
  9. LBRACKET,
  10. RBRACKET,
  11. COMMA,
  12. DOT,
  13. NUMBER,
  14. WORD,
  15. QUOTED,
  16. WHITESPACE,
  17. UNKNOWN
  18. }
  19. public Type type { get; private set; }
  20. public string val { get; private set; }
  21. public int pos { get; private set; }
  22. public Token(Type token_type, string value, int pos)
  23. {
  24. this.type = token_type;
  25. this.val = value;
  26. this.pos = pos;
  27. }
  28. public override string ToString()
  29. {
  30. return string.Format("{0}({1}) at {2}", Enum.GetName(typeof(Type), this.type), this.val, this.pos);
  31. }
  32. }
  33. }