func doTest(t Test) { bld := build.NewBuilder() parseUCA(bld) c, err := bld.Build() Error(err) c.Strength = collate.Tertiary c.Alternate = collate.AltShifted b := &collate.Buffer{} if strings.Contains(t.name, "NON_IGNOR") { c.Alternate = collate.AltNonIgnorable } prev := t.str[0] for i := 1; i < len(t.str); i++ { b.Reset() s := t.str[i] ka := c.Key(b, prev) kb := c.Key(b, s) if r := bytes.Compare(ka, kb); r == 1 { fail(t, "%d: Key(%.4X) < Key(%.4X) (%X < %X) == %d; want -1 or 0", i, []rune(string(prev)), []rune(string(s)), ka, kb, r) prev = s continue } if r := c.Compare(prev, s); r == 1 { fail(t, "%d: Compare(%.4X, %.4X) == %d; want -1 or 0", i, runes(prev), runes(s), r) } if r := c.Compare(s, prev); r == -1 { fail(t, "%d: Compare(%.4X, %.4X) == %d; want 1 or 0", i, runes(s), runes(prev), r) } prev = s } }
func makeTable(in []input) (*collate.Collator, error) { b := build.NewBuilder() for _, r := range in { b.Add([]rune(r.str), r.ces, nil) } return b.Build() }
func makeTable(in []input) (*collate.Collator, error) { b := build.NewBuilder() for _, r := range in { b.Add([]rune(r.str), r.ces) } c, err := b.Build("") if err == nil { collate.InitCollator(c) } return c, err }
func makeTable(in []input) (*Collator, error) { b := build.NewBuilder() for _, r := range in { if e := b.Add([]rune(r.str), r.ces, nil); e != nil { panic(e) } } t, err := b.Build() if err != nil { return nil, err } return NewFromTable(t), nil }
func main() { flag.Parse() b := build.NewBuilder() if *root != "" { parseUCA(b) } if *cldr != "" { if tables.contains("chars") { parseMain() } parseCollation(b) } c, err := b.Build() failOnError(err) if *test { testCollator(c) } else { fmt.Println("// Generated by running") fmt.Printf("// maketables -root=%s -cldr=%s\n", *root, *cldr) fmt.Println("// DO NOT EDIT") fmt.Println("// TODO: implement more compact representation for sparse blocks.") if *tags != "" { fmt.Printf("// +build %s\n", *tags) } fmt.Println("") fmt.Printf("package %s\n", *pkg) if tables.contains("collate") { fmt.Println("") fmt.Println(`import "exp/norm"`) fmt.Println("") printCollators(c) _, err = b.Print(os.Stdout) failOnError(err) } if tables.contains("chars") { printExemplarCharacters(os.Stdout) } } }
func main() { flag.Parse() b := build.NewBuilder() vartop := parseUCA(b) _, err := b.Build("") failonerror(err) fmt.Println("// Generated by running") fmt.Printf("// maketables --ducet=%s\n", *ducet) fmt.Println("// DO NOT EDIT") fmt.Println("// TODO: implement more compact representation for sparse blocks.") fmt.Println("") fmt.Println("package collate") fmt.Println("") fmt.Println(`import "exp/norm"`) fmt.Println("") c := &collate.Collator{} c.Strength = collate.Quaternary printCollators(c, vartop) _, err = b.Print(os.Stdout) failonerror(err) }