blob: 9cb9942894920a5c56440b73cc356b3b67fab9e5 [file] [log] [blame]
Kent Hagerman6379e092020-02-18 18:05:57 -05001// Copyright 2015 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// Class is the Unicode BiDi class. Each rune has a single class.
10type Class uint
11
12const (
13 L Class = iota // LeftToRight
14 R // RightToLeft
15 EN // EuropeanNumber
16 ES // EuropeanSeparator
17 ET // EuropeanTerminator
18 AN // ArabicNumber
19 CS // CommonSeparator
20 B // ParagraphSeparator
21 S // SegmentSeparator
22 WS // WhiteSpace
23 ON // OtherNeutral
24 BN // BoundaryNeutral
25 NSM // NonspacingMark
26 AL // ArabicLetter
27 Control // Control LRO - PDI
28
29 numClass
30
31 LRO // LeftToRightOverride
32 RLO // RightToLeftOverride
33 LRE // LeftToRightEmbedding
34 RLE // RightToLeftEmbedding
35 PDF // PopDirectionalFormat
36 LRI // LeftToRightIsolate
37 RLI // RightToLeftIsolate
38 FSI // FirstStrongIsolate
39 PDI // PopDirectionalIsolate
40
41 unknownClass = ^Class(0)
42)
43
44var controlToClass = map[rune]Class{
45 0x202D: LRO, // LeftToRightOverride,
46 0x202E: RLO, // RightToLeftOverride,
47 0x202A: LRE, // LeftToRightEmbedding,
48 0x202B: RLE, // RightToLeftEmbedding,
49 0x202C: PDF, // PopDirectionalFormat,
50 0x2066: LRI, // LeftToRightIsolate,
51 0x2067: RLI, // RightToLeftIsolate,
52 0x2068: FSI, // FirstStrongIsolate,
53 0x2069: PDI, // PopDirectionalIsolate,
54}
55
56// A trie entry has the following bits:
57// 7..5 XOR mask for brackets
58// 4 1: Bracket open, 0: Bracket close
59// 3..0 Class type
60
61const (
62 openMask = 0x10
63 xorMaskShift = 5
64)