parser

package
v0.0.0-...-1287624 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToJSON

func ToJSON(prompt *types.Prompt, pretty bool) (string, error)

ToJSON converts a Prompt to JSON

Types

type Option

type Option func(*Parser)

Option is a function that configures the Parser

func WithEmbeddedModules

func WithEmbeddedModules(embedFS embed.FS, modules map[string]string) Option

WithEmbeddedModules adds custom embedded modules to the parser modules is a map of module names to their file paths in the embed.FS

type Parser

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

Parser handles parsing of Lua prompt files

func New

func New(basePath string, opts ...Option) *Parser

New creates a new Parser instance

func (*Parser) Close

func (p *Parser) Close()

Close closes the Lua state

func (*Parser) ParseFile

func (p *Parser) ParseFile(filePath string) (*types.Prompt, error)

ParseFile parses a Lua prompt file and returns a Prompt struct

func (*Parser) ParseFileWithVars

func (p *Parser) ParseFileWithVars(filePath string, vars map[string]interface{}) (*types.Prompt, error)

ParseFileWithVars parses a Lua prompt file with variables

func (*Parser) ParseString

func (p *Parser) ParseString(code, sourceName string) (*types.Prompt, error)

ParseString parses Lua code from a string

func (*Parser) ParseStringWithVars

func (p *Parser) ParseStringWithVars(code, sourceName string, vars map[string]interface{}) (*types.Prompt, error)

ParseStringWithVars parses Lua code from a string with variables

Jump to

Keyboard shortcuts

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