aboutsummaryrefslogtreecommitdiff
path: root/cmd/generator/main.go
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2024-11-29 13:42:49 -0300
committerEuAndreh <eu@euandre.org>2024-11-29 13:42:49 -0300
commit990b7e317e4244803bb46f8d7c92a2b23d160a31 (patch)
tree547adb8176ef6453a736e6adff6acf1c455edcb3 /cmd/generator/main.go
parentrm go.mod go.sum (diff)
downloadtre-990b7e317e4244803bb46f8d7c92a2b23d160a31.tar.gz
tre-990b7e317e4244803bb46f8d7c92a2b23d160a31.tar.xz
rm ucd/*.go into separate project
Diffstat (limited to 'cmd/generator/main.go')
-rw-r--r--cmd/generator/main.go98
1 files changed, 0 insertions, 98 deletions
diff --git a/cmd/generator/main.go b/cmd/generator/main.go
deleted file mode 100644
index 75b7eea..0000000
--- a/cmd/generator/main.go
+++ /dev/null
@@ -1,98 +0,0 @@
-package main
-
-import (
- "fmt"
- "net/http"
- "os"
- "strings"
- "text/template"
-
- "github.com/nihei9/maleeni/ucd"
-)
-
-func main() {
- err := gen()
- if err != nil {
- fmt.Fprintf(os.Stderr, "%v\n", err)
- os.Exit(1)
- }
-}
-
-func gen() error {
- var propValAliases *ucd.PropertyValueAliases
- {
- resp, err := http.Get("https://www.unicode.org/Public/13.0.0/ucd/PropertyValueAliases.txt")
- if err != nil {
- return err
- }
- defer resp.Body.Close()
- propValAliases, err = ucd.ParsePropertyValueAliases(resp.Body)
- if err != nil {
- return err
- }
- }
- var unicodeData *ucd.UnicodeData
- {
- resp, err := http.Get("https://www.unicode.org/Public/13.0.0/ucd/UnicodeData.txt")
- if err != nil {
- return err
- }
- defer resp.Body.Close()
- unicodeData, err = ucd.ParseUnicodeData(resp.Body, propValAliases)
- if err != nil {
- return err
- }
- }
- var scripts *ucd.Scripts
- {
- resp, err := http.Get("https://www.unicode.org/Public/13.0.0/ucd/Scripts.txt")
- if err != nil {
- return err
- }
- defer resp.Body.Close()
- scripts, err = ucd.ParseScripts(resp.Body, propValAliases)
- if err != nil {
- return err
- }
- }
- var propList *ucd.PropList
- {
- resp, err := http.Get("https://www.unicode.org/Public/13.0.0/ucd/PropList.txt")
- if err != nil {
- return err
- }
- defer resp.Body.Close()
- propList, err = ucd.ParsePropList(resp.Body)
- if err != nil {
- return err
- }
- }
- tmpl, err := template.ParseFiles("../ucd/codepoint.go.tmpl")
- if err != nil {
- return err
- }
- var b strings.Builder
- err = tmpl.Execute(&b, struct {
- GeneratorName string
- UnicodeData *ucd.UnicodeData
- Scripts *ucd.Scripts
- PropList *ucd.PropList
- PropertyValueAliases *ucd.PropertyValueAliases
- }{
- GeneratorName: "generator/main.go",
- UnicodeData: unicodeData,
- Scripts: scripts,
- PropList: propList,
- PropertyValueAliases: propValAliases,
- })
- if err != nil {
- return err
- }
- f, err := os.OpenFile("../ucd/codepoint.go", os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644)
- if err != nil {
- return err
- }
- defer f.Close()
- fmt.Fprint(f, b.String())
- return nil
-}