package compile

import "cuelang.org/go/internal/core/compile"

Index

Functions

func Expr

func Expr(cfg *Config, r adt.Runtime, pkgPath string, x ast.Expr) (adt.Conjunct, errors.Error)

Expr compiles the given expression into a conjunct. The pkgID must be a unique identifier for a package in a module, for instance as obtained from build.Instance.ID.

func Files

func Files(cfg *Config, r adt.Runtime, pkgID string, files ...*ast.File) (*adt.Vertex, errors.Error)

Files compiles the given files as a single instance. It disregards the package names and it is the responsibility of the user to verify that the packages names are consistent. The pkgID must be a unique identifier for a package in a module, for instance as obtained from build.Instance.ID.

Files may return a completed parse even if it has errors.

func LookupRange

func LookupRange(name string) adt.Expr

LookupRange returns a CUE expressions for the given predeclared identifier representing a range, such as uint8, int128, and float64.

Types

type Config

type Config struct {
	// Scope specifies a node in which to look up unresolved references. This
	// is useful for evaluating expressions within an already evaluated
	// configuration.
	Scope Scope

	// Imports allows unresolved identifiers to resolve to imports.
	//
	// Under normal circumstances, identifiers bind to import specifications,
	// which get resolved to an ImportReference. Use this option to
	// automatically resolve identifiers to imports.
	Imports func(x *ast.Ident) (pkgPath string)
	// contains filtered or unexported fields
}

Config configures a compilation.

type Scope

type Scope interface {
	Parent() Scope
	Vertex() *adt.Vertex
}

A Scope represents a nested scope of Vertices.

Source Files

builtin.go compile.go errors.go label.go predeclared.go validator.go

Version
v0.12.0 (latest)
Published
Jan 30, 2025
Platform
linux/amd64
Imports
12 packages
Last checked
8 hours ago

Tools for package owners.