avyos.dev/pkg/graphics/uiparse

package uiparse

Package Overview

No package-level documentation is provided.

Export GroupCount
Constants0
Variables0
Functions0
Types10

Types

BuildError

type BuildError struct {
	Line    int
	Element string
	Message string
}

BuildError represents an error during element tree construction.

Methods

func (e *BuildError) Error() string

ComponentDef

type ComponentDef struct {
	Name       string
	Properties []*Property  // property declarations with defaults
	Signals    []SignalDecl // signal declarations
	Defaults   []*Property  // default attribute values
	Children   []*Node      // child element templates (future)
	Line       int
}

ComponentDef represents a component definition.

Document

type Document struct {
	Imports    []ImportDecl
	Components []*ComponentDef
	Root       *Node // the root element (Window, VBox, etc.)
}

Document is the top-level parse result.

Functions

func Parse(source string) (*Document, error)

Parse parses a .ui source into a Document.

ImportDecl

type ImportDecl struct {
	Path string
	Line int
}

ImportDecl represents an import statement.

Node

type Node struct {
	TypeName   string
	Properties []*Property
	Children   []*Node
	Line       int
}

Node represents an element in the UI tree.

Methods

func (n *Node) PropBool(name string, def bool) bool

PropBool returns the bool value of a property, or the default.

func (n *Node) PropFloat(name string, def float64) float64

PropFloat returns the float value of a property, or the default.

func (n *Node) PropInt(name string, def int) int

PropInt returns the int value of a property, or the default.

func (n *Node) PropString(name string) string

PropString returns the string representation of a property.

func (n *Node) PropValue(name string) (Value, bool)

PropValue returns the Value for a named property, or zero Value and false.

ParseError

type ParseError struct {
	Line    int
	Column  int
	Message string
}

ParseError represents an error during UI parsing with location info.

Methods

func (e *ParseError) Error() string

Property

type Property struct {
	Name  string
	Value Value
	Line  int
}

Property is a key-value pair in a Node.

SignalDecl

type SignalDecl struct {
	Name string
	Line int
}

SignalDecl represents a signal declaration inside a component.

Value

type Value struct {
	Kind  ValueKind
	Str   string
	Int   int64
	Float float64
	Bool  bool
}

Value is a parsed property value.

ValueKind

type ValueKind int

ValueKind distinguishes the type of a parsed value.

Constants

const (
	ValueString ValueKind = iota
	ValueInt
	ValueFloat
	ValueBool
	ValueIdent
)