Move how the template language is written into internal/grammar

This commit is contained in:
2026-10-05 12:11:36 +02:00
committed by Lillem4n
parent 41292f9d89
commit c2f2e86735
21 changed files with 903 additions and 853 deletions
+4 -2
View File
@@ -7,6 +7,8 @@ import (
"os"
"path"
"strings"
"github.com/larvit/fejkdata/internal/grammar"
)
// dataSource is one tree to load: an fs.FS and the directory in it to start from.
@@ -132,7 +134,7 @@ func loadFolder(src dataSource, g *folder, full, name string) error {
if len(child.children) == 0 {
return nil
}
if err := checkName(name); err != nil {
if err := grammar.CheckName(name); err != nil {
return fmt.Errorf("%s: folder %w", src.labelled(full), err)
}
g.children[name] = child
@@ -146,7 +148,7 @@ func loadFile(src dataSource, g *folder, full, file string, files *categoryFiles
return nil
}
name := strings.TrimSuffix(file, ".json")
if err := checkName(name); err != nil {
if err := grammar.CheckName(name); err != nil {
return fmt.Errorf("%s: category %w", src.labelled(full), err)
}
b, err := fs.ReadFile(src.fsys, full)