Documentation ¶
Overview ¶
Package internal exposes some cue internals to other packages.
A better name for this package would be technicaldebt.
Index ¶
- Constants
- Variables
- func ConstraintToken(f *ast.Field) (t token.Token, ok bool)
- func EmbedStruct(s *ast.StructLit) *ast.EmbedDecl
- func FileComment(f *ast.File) *ast.CommentGroup
- func GenPath(root string) string
- func IsDef(s string) bool
- func IsDefOrHidden(s string) bool
- func IsDefinition(label ast.Label) bool
- func IsEllipsis(x ast.Decl) bool
- func IsHidden(s string) bool
- func IsRegularField(f *ast.Field) bool
- func ListEllipsis(n *ast.ListLit) (elts []ast.Expr, e *ast.Ellipsis)
- func NewAttr(name, str string) *ast.Attribute
- func NewComment(isDoc bool, s string) *ast.CommentGroup
- func Package(f *ast.File) *ast.Package
- func SetConstraint(f *ast.Field, t token.Token)
- func SetPackage(f *ast.File, name string, overwrite bool)
- func ToExpr(n ast.Node) ast.Expr
- func ToFile(n ast.Node) *ast.File
- func Version(minor, patch int) int
- type Attr
- type AttrKind
- type Context
- type Decimal
- type EvaluatorVersion
- type KeyValue
Constants ¶
const ( MinorCurrent = 5 MinorSupported = 4 PatchSupported = 0 )
Variables ¶
var APIVersionSupported = Version(MinorSupported, PatchSupported)
APIVersionSupported is the back version until which deprecated features are still supported.
var BaseContext = Context{*apd.BaseContext.WithPrecision(34)}
BaseContext is used as CUE's default context for arbitrary-precision decimals.
var ErrIncomplete = errors.New("incomplete value")
ErrIncomplete can be used by builtins to signal the evaluation was incomplete.
var ErrInexact = errors.New("inexact subsumption")
Functions ¶
func ConstraintToken ¶
ConstraintToken reports which constraint token (? or !) is associated with a field (if any), taking into account compatibility of deprecated fields.
func FileComment ¶
func FileComment(f *ast.File) *ast.CommentGroup
func IsDefOrHidden ¶
func IsDefinition ¶
func IsEllipsis ¶
IsEllipsis reports whether the declaration can be represented as an ellipsis.
func IsRegularField ¶
func ListEllipsis ¶
ListEllipsis reports the list type and remaining elements of a list. If we ever relax the usage of ellipsis, this function will likely change. Using this function will ensure keeping correct behavior or causing a compiler failure.
func NewComment ¶
func NewComment(isDoc bool, s string) *ast.CommentGroup
NewComment creates a new CommentGroup from the given text. Each line is prefixed with "//" and the last newline is removed. Useful for ASTs generated by code other than the CUE parser.
func SetConstraint ¶
SetConstraints sets both the main and deprecated fields of f according to the given constraint token.
func ToExpr ¶
ToExpr converts a node to an expression. If it is a file, it will return it as a struct. If is an expression, it will return it as is. Otherwise it panics.
Types ¶
type Attr ¶
type Attr struct { Name string // e.g. "json" or "protobuf" Body string Kind AttrKind Fields []KeyValue Err errors.Error Pos token.Pos }
Attr holds positional information for a single Attr.
func NewNonExisting ¶
NewNonExisting creates a non-existing attribute.
func (*Attr) Flag ¶
Flag reports whether an entry with the given name exists at position pos or onwards or an error if the attribute is invalid or if the first pos-1 entries are not defined.
func (*Attr) Int ¶
Int reports the integer at the given position or an error if the attribute is invalid, the position does not exist, or the value at the given position is not an integer.
type AttrKind ¶
type AttrKind uint8
AttrKind indicates the location of an attribute within CUE source.
type Context ¶
type Context struct {
apd.Context
}
Context wraps apd.Context for CUE's custom logic.
Note that it avoids pointers to make it easier to make copies.
func (Context) WithPrecision ¶
WithPrecision mirrors upstream, but returning our type without a pointer.
type Decimal ¶
type Decimal = apd.Decimal
A Decimal is an arbitrary-precision binary-coded decimal number.
Right now Decimal is aliased to apd.Decimal. This may change in the future.
type EvaluatorVersion ¶
type EvaluatorVersion int
EvaluatorVersion is declared here so it can be used everywhere without import cycles, but the canonical documentation lives at cuelang.org/go/cue/cuecontext.EvalVersion.
TODO(mvdan): rename to EvalVersion for consistency with cuecontext.
const ( // EvalVersionUnset is the zero value, which signals that no evaluator version is provided. EvalVersionUnset EvaluatorVersion = 0 EvalV2 EvaluatorVersion = 2 EvalV3 EvaluatorVersion = 3 DefaultVersion = EvalV2 // TODO(mvdan): rename to EvalDefault for consistency with cuecontext DevVersion = EvalV3 // TODO(mvdan): rename to EvalExperiment for consistency with cuecontext )
Directories ¶
Path | Synopsis |
---|---|
Package source contains utility functions that standardize reading source bytes across cue packages.
|
Package source contains utility functions that standardize reading source bytes across cue packages. |