gen_trieval.go 1.7 KB

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