gen_trieval.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright 2015 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // +build ignore
  5. package main
  6. // Class is the Unicode BiDi class. Each rune has a single class.
  7. type Class uint
  8. const (
  9. L Class = iota // LeftToRight
  10. R // RightToLeft
  11. EN // EuropeanNumber
  12. ES // EuropeanSeparator
  13. ET // EuropeanTerminator
  14. AN // ArabicNumber
  15. CS // CommonSeparator
  16. B // ParagraphSeparator
  17. S // SegmentSeparator
  18. WS // WhiteSpace
  19. ON // OtherNeutral
  20. BN // BoundaryNeutral
  21. NSM // NonspacingMark
  22. AL // ArabicLetter
  23. Control // Control LRO - PDI
  24. numClass
  25. LRO // LeftToRightOverride
  26. RLO // RightToLeftOverride
  27. LRE // LeftToRightEmbedding
  28. RLE // RightToLeftEmbedding
  29. PDF // PopDirectionalFormat
  30. LRI // LeftToRightIsolate
  31. RLI // RightToLeftIsolate
  32. FSI // FirstStrongIsolate
  33. PDI // PopDirectionalIsolate
  34. unknownClass = ^Class(0)
  35. )
  36. var controlToClass = map[rune]Class{
  37. 0x202D: LRO, // LeftToRightOverride,
  38. 0x202E: RLO, // RightToLeftOverride,
  39. 0x202A: LRE, // LeftToRightEmbedding,
  40. 0x202B: RLE, // RightToLeftEmbedding,
  41. 0x202C: PDF, // PopDirectionalFormat,
  42. 0x2066: LRI, // LeftToRightIsolate,
  43. 0x2067: RLI, // RightToLeftIsolate,
  44. 0x2068: FSI, // FirstStrongIsolate,
  45. 0x2069: PDI, // PopDirectionalIsolate,
  46. }
  47. // A trie entry has the following bits:
  48. // 7..5 XOR mask for brackets
  49. // 4 1: Bracket open, 0: Bracket close
  50. // 3..0 Class type
  51. const (
  52. openMask = 0x10
  53. xorMaskShift = 5
  54. )