gen_common.go 1.2 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. // This file contains code that is common between the generation code and the
  7. // package's test code.
  8. import (
  9. "log"
  10. "golang.org/x/text/internal/ucd"
  11. )
  12. func catFromEntry(p *ucd.Parser) (cat category) {
  13. r := p.Rune(0)
  14. switch s := p.String(1); s {
  15. case "valid":
  16. cat = valid
  17. case "disallowed":
  18. cat = disallowed
  19. case "disallowed_STD3_valid":
  20. cat = disallowedSTD3Valid
  21. case "disallowed_STD3_mapped":
  22. cat = disallowedSTD3Mapped
  23. case "mapped":
  24. cat = mapped
  25. case "deviation":
  26. cat = deviation
  27. case "ignored":
  28. cat = ignored
  29. default:
  30. log.Fatalf("%U: Unknown category %q", r, s)
  31. }
  32. if s := p.String(3); s != "" {
  33. if cat != valid {
  34. log.Fatalf(`%U: %s defined for %q; want "valid"`, r, s, p.String(1))
  35. }
  36. switch s {
  37. case "NV8":
  38. cat = validNV8
  39. case "XV8":
  40. cat = validXV8
  41. default:
  42. log.Fatalf("%U: Unexpected exception %q", r, s)
  43. }
  44. }
  45. return cat
  46. }
  47. var joinType = map[string]info{
  48. "L": joiningL,
  49. "D": joiningD,
  50. "T": joiningT,
  51. "R": joiningR,
  52. }