Documentation
¶
Overview ¶
Package source defines source locations, diagnostics, and resource limits.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Code ¶
type Code string
Code is a stable diagnostic identifier. Codes may be added over time, but existing semantic meanings should remain stable.
const ( CodeSyntax Code = "syntax" CodeUnknownCommand Code = "unknown-command" CodeUnknownSymbol Code = "unknown-symbol" CodeMissingArgument Code = "missing-argument" CodeUnclosedGroup Code = "unclosed-group" CodeUnexpectedToken Code = "unexpected-token" CodeUnsupported Code = "unsupported" CodeInvalidValue Code = "invalid-value" CodeInvalidEnvironment Code = "invalid-environment" CodeUnknownVariable Code = "unknown-variable" CodeMissingGlyph Code = "missing-glyph" CodeTextUnsupported Code = "text-unsupported" CodeLimitExceeded Code = "limit-exceeded" CodeCanceled Code = "canceled" CodeInternal Code = "internal" CodeDeprecated Code = "deprecated" )
type Diagnostic ¶
type Diagnostic struct {
Range Range
Severity Severity
Code Code
Message string
Args []string
Hints []string
}
Diagnostic describes a recoverable source problem.
func NormalizeDiagnostics ¶
func NormalizeDiagnostics(in []Diagnostic) []Diagnostic
NormalizeDiagnostics filters invalid ranges, copies the slice, and returns a deterministic ordering by source position, severity, code, and message.
func NormalizeDiagnosticsFor ¶
func NormalizeDiagnosticsFor(in []Diagnostic, sourceLen int) []Diagnostic
NormalizeDiagnosticsFor filters diagnostics whose ranges fall outside a source string, copies retained data, and returns a deterministic ordering.
func (Diagnostic) Error ¶
func (d Diagnostic) Error() string
Error returns the English diagnostic message.
type Limits ¶
type Limits struct {
MaxSourceBytes int
MaxTokens int
MaxNesting int
MaxNodes int
MaxMacroExpansions int
MaxExpandedTokens int
MaxCallDepth int
MaxTableCells int
MaxAssemblyRepeats int
MaxTextBytes int
MaxOutputItems int
MaxPathSegments int
MaxDimension int64
}
Limits bound work for untrusted input. Zero fields are replaced with Default Limits by WithDefaults. Negative fields are also replaced with defaults so a zero-value Limits cannot accidentally become unbounded.
Enforcement is split by layer: parsers enforce token, expansion, call, and table-cell limits; ir.Validate enforces source, node, nesting, text, and dimension limits; internal/layout enforces output-item and path-segment limits. Font assembly adapters enforce MaxAssemblyRepeats.
func DefaultLimits ¶
func DefaultLimits() Limits
DefaultLimits returns conservative limits suitable for interactive formulas.
func (Limits) WithDefaults ¶
WithDefaults returns a copy where non-positive fields use defaults.
type Range ¶
Range is a half-open UTF-8 byte range in a source string.
The zero Range denotes the empty range at the start of a source. A detached range has Start and End both negative.
func Detached ¶
func Detached() Range
Detached returns a range that is not associated with source text.
func Merge ¶
Merge returns the smallest range containing both inputs. Detached inputs are ignored. If both inputs are detached, the result is detached.
func (Range) ContainsRange ¶
ContainsRange reports whether inner lies entirely within r.
func (Range) IsDetached ¶
IsDetached reports whether r is not associated with source text.
func (Range) IsValidFor ¶
IsValidFor reports whether r is detached or lies within a source string of sourceLen bytes.