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
+3 -2
View File
@@ -9,6 +9,7 @@ import (
"unicode/utf8"
"github.com/larvit/fejkdata/internal/drawstate"
"github.com/larvit/fejkdata/internal/grammar"
)
// Column is one rendered column of a record. Value is the rendered text, which a
@@ -123,7 +124,7 @@ func literal(c Column, quote func(string) string, nullText string) string {
func (f *Generator) FakeRecord(path string) (*Record, error) {
f.mu.Lock()
defer f.mu.Unlock()
segments, err := splitPath(path)
segments, err := grammar.SplitPath(path)
if err != nil {
return nil, fmt.Errorf("fejkdata: %w", err)
}
@@ -143,7 +144,7 @@ func (f *Generator) FakeRecord(path string) (*Record, error) {
}
shape := f.recordShapeOf(n)
if errors.Is(shape.err, ErrNoColumns) {
ns := nameSegments(segments)
ns := grammar.NameSegments(segments)
return nil, fmt.Errorf(`fejkdata: %s %w; render it as a column of one: {"format":"","%s":"{/%s}"}`, path, shape.err, ns[len(ns)-1], path)
}
if shape.err != nil {