Attributes.cs 818 B

123456789101112131415161718192021222324252627282930313233343536373839
  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, AllowMultiple = true)]
  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, AllowMultiple = true)]
  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. }