gen_common.go 1.4 KB

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