diff options
| author | 2026-02-17 21:33:24 +0300 | |
|---|---|---|
| committer | 2026-02-17 21:33:24 +0300 | |
| commit | 51abb67b77ee9f0f33f641711df9b0c9b4d14263 (patch) | |
| tree | 7c44e3455b1ab179628188215cbee0da4981fe98 /model | |
| parent | init (diff) | |
| download | conf-51abb67b77ee9f0f33f641711df9b0c9b4d14263.tar.gz conf-51abb67b77ee9f0f33f641711df9b0c9b4d14263.tar.bz2 conf-51abb67b77ee9f0f33f641711df9b0c9b4d14263.tar.xz conf-51abb67b77ee9f0f33f641711df9b0c9b4d14263.zip | |
Diffstat (limited to 'model')
| -rw-r--r-- | model/assignment.go | 6 | ||||
| -rw-r--r-- | model/command.go | 9 | ||||
| -rw-r--r-- | model/doc.go | 43 | ||||
| -rw-r--r-- | model/value.go | 7 |
4 files changed, 55 insertions, 10 deletions
diff --git a/model/assignment.go b/model/assignment.go new file mode 100644 index 0000000..746e2b3 --- /dev/null +++ b/model/assignment.go @@ -0,0 +1,6 @@ +package model + +type Assignment struct { + Key string + Value Values +} diff --git a/model/command.go b/model/command.go new file mode 100644 index 0000000..237e94f --- /dev/null +++ b/model/command.go @@ -0,0 +1,9 @@ +package model + +type Command struct { + Name string + Arguments Values + Body *Doc +} + +type Commands []*Command diff --git a/model/doc.go b/model/doc.go index 76f03e4..9c13a4c 100644 --- a/model/doc.go +++ b/model/doc.go @@ -1,18 +1,41 @@ package model -type Doc []any +type Doc struct { + items []any + vars map[string]Values + commands map[string]Commands +} -type Assignment struct { - Key string - Value []Value +func New(cap int) *Doc { + return &Doc{ + items: make([]any, 0, cap), + vars: make(map[string]Values, cap), + commands: make(map[string]Commands, cap), + } } -type Command struct { - Name string - Arguments []Value - Body Doc +func (d *Doc) AppendAssignment(e *Assignment) { + d.items = append(d.items, e) + d.vars[e.Key] = append(d.vars[e.Key], e.Value...) } -type Value any +func (d *Doc) AppendCommand(c *Command) { + d.items = append(d.items, c) + d.commands[c.Name] = append(d.commands[c.Name], c) +} -type Word string +func (d *Doc) Vars() map[string]Values { + return d.vars +} + +func (d *Doc) Get(key string) Values { + return d.vars[key] +} + +func (d *Doc) Commands(name string) Commands { + return d.commands[name] +} + +func (d *Doc) Items() []any { + return d.items +} diff --git a/model/value.go b/model/value.go new file mode 100644 index 0000000..8c995fe --- /dev/null +++ b/model/value.go @@ -0,0 +1,7 @@ +package model + +type Value any + +type Values []Value + +type Word string |
