You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

LLamaGrammarElement.cs 1.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using System.Runtime.InteropServices;
  2. namespace LLama.Native
  3. {
  4. /// <summary>
  5. /// grammar element type
  6. /// </summary>
  7. public enum LLamaGrammarElementType
  8. {
  9. /// <summary>
  10. /// end of rule definition
  11. /// </summary>
  12. END = 0,
  13. /// <summary>
  14. /// start of alternate definition for rule
  15. /// </summary>
  16. ALT = 1,
  17. /// <summary>
  18. /// non-terminal element: reference to rule
  19. /// </summary>
  20. RULE_REF = 2,
  21. /// <summary>
  22. /// terminal element: character (code point)
  23. /// </summary>
  24. CHAR = 3,
  25. /// <summary>
  26. /// inverse char(s) ([^a], [^a-b] [^abc])
  27. /// </summary>
  28. CHAR_NOT = 4,
  29. /// <summary>
  30. /// modifies a preceding CHAR or CHAR_ALT to
  31. /// be an inclusive range ([a-z])
  32. /// </summary>
  33. CHAR_RNG_UPPER = 5,
  34. /// <summary>
  35. /// modifies a preceding CHAR or
  36. /// CHAR_RNG_UPPER to add an alternate char to match ([ab], [a-zA])
  37. /// </summary>
  38. CHAR_ALT = 6,
  39. };
  40. /// <summary>
  41. /// An element of a grammar
  42. /// </summary>
  43. [StructLayout(LayoutKind.Sequential)]
  44. public struct LLamaGrammarElement
  45. {
  46. /// <summary>
  47. /// The type of this element
  48. /// </summary>
  49. public LLamaGrammarElementType Type;
  50. /// <summary>
  51. /// Unicode code point or rule ID
  52. /// </summary>
  53. public uint Value;
  54. /// <summary>
  55. /// Construct a new LLamaGrammarElement
  56. /// </summary>
  57. /// <param name="type"></param>
  58. /// <param name="value"></param>
  59. public LLamaGrammarElement(LLamaGrammarElementType type, uint value)
  60. {
  61. Type = type;
  62. Value = value;
  63. }
  64. }
  65. }