parser

package
v0.1.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2026 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ColorBlock

type ColorBlock struct {
	Entries hcl.Body `hcl:",remain"`
}

ColorBlock wraps a block with arbitrary color attributes for gohcl decoding.

type LightnessTransform

type LightnessTransform struct {
	Low   float64
	High  float64
	Steps int
}

LightnessTransform holds the parsed transform lightness configuration.

func ParseTransformBlock

func ParseTransformBlock(body *hclsyntax.Body) (*LightnessTransform, error)

ParseTransformBlock extracts and parses a transform { lightness { ... } } block from an *hclsyntax.Body. Returns (nil, nil) if no transform block is present.

type Loader

type Loader struct {
	// contains filtered or unexported fields
}

Loader handles two-pass HCL decoding with palette resolution.

func NewLoader

func NewLoader(path string) (*Loader, error)

NewLoader parses an HCL file and builds the evaluation context from palette.

func (*Loader) Context

func (l *Loader) Context() *hcl.EvalContext

Context returns the EvalContext for manual parsing.

func (*Loader) Decode

func (l *Loader) Decode(target any) error

Decode decodes a value using the palette context. Reusable for any blocks that reference palette values.

func (*Loader) Palette

func (l *Loader) Palette() *color.Node

Palette returns the parsed palette colors.

type Meta

type Meta struct {
	Name       string `hcl:"name,optional"`
	Author     string `hcl:"author,optional"`
	Appearance string `hcl:"appearance,optional"`
	URL        string `hcl:"url,optional"`
}

Meta holds theme metadata.

type PaletteBlock

type PaletteBlock struct {
	Entries hcl.Body `hcl:",remain"`
}

PaletteBlock wraps a single palette block for gohcl decoding.

type ParseResult

type ParseResult struct {
	Meta    Meta
	Palette *color.Node
	Syntax  color.Tree
	Theme   map[string]color.Color
	ANSI    map[string]color.Color
}

ParseResult holds the raw parsed theme data.

func Parse

func Parse(path string) (*ParseResult, error)

Parse parses an HCL theme file and returns a fully-resolved ParseResult.

type RawConfig

type RawConfig struct {
	Palette *PaletteBlock `hcl:"palette,block"`
	Remain  hcl.Body      `hcl:",remain"`
}

RawConfig captures the palette block first (no EvalContext needed).

type ResolvedConfig

type ResolvedConfig struct {
	Meta   *Meta       `hcl:"meta,block"`
	Theme  *ColorBlock `hcl:"theme,block"`
	ANSI   *ColorBlock `hcl:"ansi,block"`
	Remain hcl.Body    `hcl:",remain"` // captures syntax for manual parsing
}

ResolvedConfig decodes blocks that reference palette.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL