Attributes.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. namespace NTERA.Interpreter
  3. {
  4. [Flags]
  5. public enum LexerType
  6. {
  7. Real = 1,
  8. String = 2,
  9. Both = Real | String
  10. }
  11. [AttributeUsage(AttributeTargets.Field)]
  12. public class LexerCharacterAttribute : Attribute
  13. {
  14. public char Character { get; }
  15. public LexerType LexerContext { get; }
  16. public LexerCharacterAttribute(char character, LexerType lexerContext = LexerType.Both)
  17. {
  18. Character = character;
  19. LexerContext = lexerContext;
  20. }
  21. }
  22. [AttributeUsage(AttributeTargets.Field)]
  23. public class LexerKeywordAttribute : Attribute
  24. {
  25. public string Keyword { get; }
  26. public bool IsLineKeyword { get; }
  27. public LexerKeywordAttribute(string keyword, bool isLineKeyword = false)
  28. {
  29. Keyword = keyword;
  30. IsLineKeyword = isLineKeyword;
  31. }
  32. }
  33. [AttributeUsage(AttributeTargets.Method)]
  34. public class KeywordMethodAttribute : Attribute
  35. {
  36. public Token Token { get; }
  37. public KeywordMethodAttribute(Token token)
  38. {
  39. Token = token;
  40. }
  41. }
  42. [AttributeUsage(AttributeTargets.Method)]
  43. public class BuiltInFunctionAttribute : Attribute
  44. {
  45. public string Name { get; }
  46. public BuiltInFunctionAttribute(string name)
  47. {
  48. Name = name;
  49. }
  50. }
  51. }