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