Documentation
¶
Index ¶
- func Load(ctx context.Context, entry string, options LoadOptions) (*Project, Diagnostics, error)
- func ParseDocument(source Source) (*Document, Diagnostics)
- func ParseExpr(text string, span SourceSpan) (Expr, Diagnostics)
- func ParseValue(kind ValueType, raw string) (Value, Diagnostic)
- func WriteConfig(state ConfigState) (string, error)
- func WriteKconfig(project *Project) (string, error)
- type Change
- type ChangeStatus
- type ConditionalValue
- type ConfigState
- type Constraints
- type Diagnostic
- type Diagnostics
- type Document
- type Entry
- type EntryKind
- type EntrySchema
- type Expr
- type FSLoader
- type FrontendInput
- type FrontendTree
- type LoadOptions
- type Node
- type NodeKind
- type Project
- func (p *Project) Apply(state ConfigState, patch FrontendInput) Resolution
- func (p *Project) OpenScreen(state ConfigState, id string, options RenderOptions) ScreenResult
- func (p *Project) Render(state ConfigState, options RenderOptions) FrontendTree
- func (p *Project) Resolve(input FrontendInput) Resolution
- func (p *Project) Schema() Schema
- func (p *Project) Validate(state ConfigState, symbolID string, candidate any) ValidationResult
- type Property
- type RangeRule
- type Relation
- type RenderOptions
- type Resolution
- type Schema
- type Screen
- type ScreenRef
- type ScreenResult
- type ScreenSchema
- type Severity
- type Source
- type SourceLoader
- type SourceSpan
- type StateReason
- type SymbolLookup
- type SymbolSchema
- type Token
- type TokenKind
- type TriState
- type ValidationResult
- type Value
- type ValueOption
- type ValueOrigin
- type ValueType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Load ¶
func Load(ctx context.Context, entry string, options LoadOptions) (*Project, Diagnostics, error)
func ParseDocument ¶
func ParseDocument(source Source) (*Document, Diagnostics)
ParseDocument parses one Kconfig source document.
func ParseExpr ¶
func ParseExpr(text string, span SourceSpan) (Expr, Diagnostics)
ParseExpr parses an expression with Kconfig operator precedence.
func ParseValue ¶
func ParseValue(kind ValueType, raw string) (Value, Diagnostic)
ParseValue parses one Kconfig literal as the requested type.
func WriteConfig ¶
func WriteConfig(state ConfigState) (string, error)
WriteConfig emits a deterministic Linux .config file. Disabled bool and tristate symbols use Linux's conventional unset spelling.
func WriteKconfig ¶
WriteKconfig emits normalized definitions. It intentionally does not keep original whitespace or comments positioning; Project is semantic model data.
Types ¶
type Change ¶
type Change struct {
Input any
Status ChangeStatus
Previous, Value Value
Reason *StateReason
}
type ChangeStatus ¶
type ChangeStatus uint8
const ( ChangeAccepted ChangeStatus = iota ChangeNormalized ChangeFallback ChangeIgnored )
type ConditionalValue ¶
type ConditionalValue struct {
Value Value
// Expr is used for symbol-valued defaults (for example, `default FOO`).
// Value is retained for literal defaults so callers do not need to reparse
// source text to render a default.
Expr Expr
Raw string
Condition Expr
Span SourceSpan
}
type ConfigState ¶
type ConfigState struct {
// contains filtered or unexported fields
}
func (ConfigState) Value ¶
func (s ConfigState) Value(symbolID string) Value
func (ConfigState) Values ¶
func (s ConfigState) Values() map[string]Value
type Constraints ¶
type Constraints struct {
Type ValueType
Min, Max *Value
AllowedValues []ValueOption
}
type Diagnostic ¶
type Diagnostic struct {
Severity Severity
Message string
Span SourceSpan
}
Diagnostic explains a load, semantic, or input issue.
type Diagnostics ¶
type Diagnostics []Diagnostic
Diagnostics is an ordered collection of diagnostics.
func (Diagnostics) Error ¶
func (d Diagnostics) Error() string
Error renders all diagnostics for use with error-returning APIs.
func (Diagnostics) HasErrors ¶
func (d Diagnostics) HasErrors() bool
HasErrors reports whether any error-level diagnostic is present.
type Entry ¶
type Entry struct {
ID string
Kind EntryKind
Name string
IncludeKind string
Prompt string
PromptCondition Expr
Type ValueType
Condition Expr
Selects []Relation
Implies []Relation
Defaults []ConditionalValue
Ranges []RangeRule
Depends []Expr
Visible []Expr
Help string
OptionModules bool
Optional bool
// Properties preserves source property order for canonical writing. The
// semantic fields above remain the efficient, typed representation.
Properties []Property
Children []*Entry
Span SourceSpan
}
Entry is a source-ordered menu-tree node.
type EntrySchema ¶
type EntrySchema struct {
ID, SymbolID, ParentID, Prompt string
Kind EntryKind
Type ValueType
Source SourceSpan
ScreenID string
}
type Expr ¶
type Expr interface {
// contains filtered or unexported methods
}
Expr is a parsed Kconfig conditional expression.
type FrontendInput ¶
FrontendInput contains raw frontend scalars keyed by SymbolID. Resolve and Apply choose the target type from the loaded Kconfig symbol and normalize these forms internally: bool -> bool, tristate -> "n"/"m"/"y", string -> string, int -> an integral number, and hex -> a "0x..." string.
type FrontendTree ¶
type FrontendTree struct {
Title string
RootScreenID string
Screens []Screen
Diagnostics Diagnostics
}
type LoadOptions ¶
type LoadOptions struct {
Root string
Loader SourceLoader
Variables map[string]string
}
type Node ¶
type Node struct {
ID, SymbolID string
SelectedSymbolID string
Kind NodeKind
Prompt, Help string
Visible, Enabled bool
Value, Default Value
Constraints Constraints
Reason *StateReason
Screen *ScreenRef
Source SourceSpan
}
type Project ¶
type Project struct {
// contains filtered or unexported fields
}
func (*Project) Apply ¶
func (p *Project) Apply(state ConfigState, patch FrontendInput) Resolution
func (*Project) OpenScreen ¶
func (p *Project) OpenScreen(state ConfigState, id string, options RenderOptions) ScreenResult
func (*Project) Render ¶
func (p *Project) Render(state ConfigState, options RenderOptions) FrontendTree
func (*Project) Resolve ¶
func (p *Project) Resolve(input FrontendInput) Resolution
func (*Project) Validate ¶
func (p *Project) Validate(state ConfigState, symbolID string, candidate any) ValidationResult
Validate checks a raw frontend scalar without mutating state. Its accepted scalar forms are the same as FrontendInput.Values.
type Property ¶
type Property struct {
Kind string
Text string
Span SourceSpan
}
Property records one source property in declaration order. It intentionally keeps only normalized text: writers are canonical rather than format-preserving.
type Relation ¶
type Relation struct {
Target string
Condition Expr
Span SourceSpan
}
Relation is a conditional select or imply target.
type RenderOptions ¶
type RenderOptions struct{ IncludeHidden bool }
type Resolution ¶
type Resolution struct {
State ConfigState
Tree FrontendTree
Changes map[string]Change
Diagnostics Diagnostics
}
type Schema ¶
type Schema struct {
Title string
Symbols []SymbolSchema
Entries []EntrySchema
Screens []ScreenSchema
}
Schema is a static, cacheable catalog. Visibility and constraints belong to FrontendTree and are deliberately absent here.
type ScreenResult ¶
type ScreenResult struct {
Screen Screen
ActiveScreenID string
Redirected bool
Reason *StateReason
Tree FrontendTree
}
type ScreenSchema ¶
type ScreenSchema struct {
ID, ParentID, OwnerID, Title string
Source SourceSpan
}
type Severity ¶
type Severity uint8
Severity describes how a diagnostic affects loading or resolution.
type SourceLoader ¶
SourceLoader permits applications to provide Kconfig files from an embedded filesystem or another trusted store. The loader receives a cleaned path rooted under LoadOptions.Root; it is never asked to expand Kconfig macros.
type SourceSpan ¶
SourceSpan identifies a position in a Kconfig source file.
type StateReason ¶
type StateReason struct {
Code, Message string
Source SourceSpan
}
type SymbolLookup ¶
SymbolLookup obtains the current value of a named symbol.
type SymbolSchema ¶
type SymbolSchema struct {
ID string
Type ValueType
Source SourceSpan
EntryIDs []string
}
type Token ¶
type Token struct {
Kind TokenKind
Text string
Span SourceSpan
}
Token is a source-positioned expression token.
type TriState ¶
type TriState uint8
TriState is the Kconfig n < m < y lattice value.
func EvalExpr ¶
func EvalExpr(expr Expr, lookup SymbolLookup) TriState
EvalExpr evaluates a parsed expression using Kconfig tristate logic.
type ValidationResult ¶
type ValidationResult struct {
Accepted bool
Normalized Value
AllowedValues []ValueOption
Reason *StateReason
Diagnostics Diagnostics
AffectedEntryIDs []string
}
type Value ¶
Value is a typed Kconfig value. Only the field matching Type is meaningful.
func StringValue ¶
func (Value) MarshalJSON ¶
MarshalJSON writes the frontend scalar form of a typed Kconfig value. A caller obtains the value type from Schema or Node.Constraints rather than having to decode the Value struct's implementation fields.
func (*Value) UnmarshalJSON ¶
UnmarshalJSON accepts the scalar form emitted by MarshalJSON. When the receiver already carries a type (for example, ZeroValue(schema.Type)), JSON types are checked strictly. An untyped receiver infers only unambiguous scalar forms; callers with a string/tristate or int/hex ambiguity should initialize the receiver from schema metadata first.
type ValueOption ¶
type ValueOption struct {
Value Value
SymbolID, Prompt string
Selected, Enabled bool
Reason *StateReason
}
type ValueOrigin ¶
type ValueOrigin uint8
const ( OriginZero ValueOrigin = iota OriginDefault OriginInput OriginRelation OriginChoice )