gen_common.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright 2016 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. import (
  8. "unicode/utf8"
  9. "golang.org/x/text/internal/language/compact"
  10. )
  11. // A system identifies a CLDR numbering system.
  12. type system byte
  13. type systemData struct {
  14. id system
  15. digitSize byte // number of UTF-8 bytes per digit
  16. zero [utf8.UTFMax]byte // UTF-8 sequence of zero digit.
  17. }
  18. // A SymbolType identifies a symbol of a specific kind.
  19. type SymbolType int
  20. const (
  21. SymDecimal SymbolType = iota
  22. SymGroup
  23. SymList
  24. SymPercentSign
  25. SymPlusSign
  26. SymMinusSign
  27. SymExponential
  28. SymSuperscriptingExponent
  29. SymPerMille
  30. SymInfinity
  31. SymNan
  32. SymTimeSeparator
  33. NumSymbolTypes
  34. )
  35. const hasNonLatnMask = 0x8000
  36. // symOffset is an offset into altSymData if the bit indicated by hasNonLatnMask
  37. // is not 0 (with this bit masked out), and an offset into symIndex otherwise.
  38. //
  39. // TODO: this type can be a byte again if we use an indirection into altsymData
  40. // and introduce an alt -> offset slice (the length of this will be number of
  41. // alternatives plus 1). This also allows getting rid of the compactTag field
  42. // in altSymData. In total this will save about 1K.
  43. type symOffset uint16
  44. type altSymData struct {
  45. compactTag compact.ID
  46. symIndex symOffset
  47. system system
  48. }