...
1
2
3 package idna
4
5
6
7
8 import (
9 "log"
10
11 "golang.org/x/text/internal/ucd"
12 )
13
14 func catFromEntry(p *ucd.Parser) (cat category) {
15 r := p.Rune(0)
16 switch s := p.String(1); s {
17 case "valid":
18 cat = valid
19 case "disallowed":
20 cat = disallowed
21 case "disallowed_STD3_valid":
22 cat = disallowedSTD3Valid
23 case "disallowed_STD3_mapped":
24 cat = disallowedSTD3Mapped
25 case "mapped":
26 cat = mapped
27 case "deviation":
28 cat = deviation
29 case "ignored":
30 cat = ignored
31 default:
32 log.Fatalf("%U: Unknown category %q", r, s)
33 }
34 if s := p.String(3); s != "" {
35 if cat != valid {
36 log.Fatalf(`%U: %s defined for %q; want "valid"`, r, s, p.String(1))
37 }
38 switch s {
39 case "NV8":
40 cat = validNV8
41 case "XV8":
42 cat = validXV8
43 default:
44 log.Fatalf("%U: Unexpected exception %q", r, s)
45 }
46 }
47 return cat
48 }
49
50 var joinType = map[string]info{
51 "L": joiningL,
52 "D": joiningD,
53 "T": joiningT,
54 "R": joiningR,
55 }
56
View as plain text