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// Form defines a plural form.
10//
11// Not all languages support all forms. Also, the meaning of each form varies
12// per language. It is important to note that the name of a form does not
13// necessarily correspond one-to-one with the set of numbers. For instance,
14// for Croation, One matches not only 1, but also 11, 21, etc.
15//
16// Each language must at least support the form "other".
17type Form byte
18
19const (
20	Other Form = iota
21	Zero
22	One
23	Two
24	Few
25	Many
26)
27
28var countMap = map[string]Form{
29	"other": Other,
30	"zero":  Zero,
31	"one":   One,
32	"two":   Two,
33	"few":   Few,
34	"many":  Many,
35}
36
37type pluralCheck struct {
38	// category:
39	// 3..7: opID
40	// 0..2: category
41	cat   byte
42	setID byte
43}
44
45// opID identifies the type of operand in the plural rule, being i, n or f.
46// (v, w, and t are treated as filters in our implementation.)
47type opID byte
48
49const (
50	opMod           opID = 0x1    // is '%' used?
51	opNotEqual      opID = 0x2    // using "!=" to compare
52	opI             opID = 0 << 2 // integers after taking the absolute value
53	opN             opID = 1 << 2 // full number (must be integer)
54	opF             opID = 2 << 2 // fraction
55	opV             opID = 3 << 2 // number of visible digits
56	opW             opID = 4 << 2 // number of visible digits without trailing zeros
57	opBretonM       opID = 5 << 2 // hard-wired rule for Breton
58	opItalian800    opID = 6 << 2 // hard-wired rule for Italian
59	opAzerbaijan00s opID = 7 << 2 // hard-wired rule for Azerbaijan
60)
61const (
62	// Use this plural form to indicate the next rule needs to match as well.
63	// The last condition in the list will have the correct plural form.
64	andNext  = 0x7
65	formMask = 0x7
66
67	opShift = 3
68
69	// numN indicates the maximum integer, or maximum mod value, for which we
70	// have inclusion masks.
71	numN = 100
72	// The common denominator of the modulo that is taken.
73	maxMod = 100
74)
75