Documentation
¶
Index ¶
- type Enum
- type Export
- type ExportFunc
- type ExportInterface
- type ExportType
- type Flags
- type Func
- type FuncParam
- type Gate
- type GateItem
- type Import
- type ImportFunc
- type ImportInterface
- type ImportType
- type Include
- type Interface
- type InterfaceFunc
- type InterfaceItem
- type Lexer
- type Package
- type PackageItem
- type Parser
- type Record
- type RecordField
- type Resource
- type ResourceMethod
- type Token
- type TokenType
- type TypeAlias
- type TypeDef
- type TypeDefBody
- type TypeRef
- type Use
- type Variant
- type VariantCase
- type World
- type WorldItem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Export ¶
type Export struct {
Name string
Type ExportType
Gate Gate
ExternalID string
}
Export represents an export statement.
type ExportInterface ¶
type ExportInterface struct {
Items []InterfaceItem
}
ExportInterface represents an exported interface.
type ExportType ¶
type ExportType interface {
// contains filtered or unexported methods
}
ExportType is a marker for export kinds.
type Func ¶
type Func struct {
Params []FuncParam
Result *TypeRef // nil if no return type, or points to the result type
Async bool
}
Func represents a function definition or type.
type Gate ¶
type Gate []GateItem
Gate is zero or more feature-gate attributes stacked immediately before an item (e.g. "@since(version = 0.2.0) @deprecated(version = 0.2.2)").
type GateItem ¶
type GateItem struct {
Kind string // "since", "unstable", or "deprecated"
Version string // semver value, set for "since" and "deprecated"
Feature string // feature name, set for "unstable"
}
GateItem is a single feature-gate attribute attached to a WIT item: "@since(version = X)", "@unstable(feature = X)", or "@deprecated(version = X)".
type Import ¶
type Import struct {
Name string
Type ImportType
Gate Gate
ExternalID string
}
Import represents an import statement.
type ImportInterface ¶
type ImportInterface struct {
Items []InterfaceItem
}
ImportInterface represents an imported interface.
type ImportType ¶
type ImportType interface {
// contains filtered or unexported methods
}
ImportType is a marker for import kinds.
type Include ¶
type Include struct {
Path string
Renames map[string]string // original name -> alias
Gate Gate
ExternalID string
}
Include represents an "include world;" or "include world with { a as a1, b as b1 };" statement.
type Interface ¶
type Interface struct {
Name string
Items []InterfaceItem
Gate Gate
ExternalID string
}
Interface represents a WIT interface definition.
type InterfaceFunc ¶
InterfaceFunc represents a named function item directly inside an interface, e.g. "read: func(len: u64) -> result<list<u8>, stream-error>;".
type InterfaceItem ¶
type InterfaceItem interface {
// contains filtered or unexported methods
}
InterfaceItem is a marker interface for items within an interface.
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
Lexer tokenizes WIT source code.
type Package ¶
type Package struct {
// Name is the fully-qualified package name (e.g., "wasi:io@0.2.0").
Name string
// Items are the top-level declarations (interfaces, worlds, type definitions, use statements).
Items []PackageItem
}
Package represents a WIT package definition.
type PackageItem ¶
type PackageItem interface {
// contains filtered or unexported methods
}
PackageItem is a marker interface for top-level package items.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser parses WIT source code into an AST.
type RecordField ¶
RecordField represents a field in a record.
type Resource ¶
type Resource struct {
Methods []ResourceMethod
}
Resource represents a resource type.
type ResourceMethod ¶
type ResourceMethod struct {
Name string
IsStatic bool
IsConstructor bool
Func Func
Gate Gate
ExternalID string
}
ResourceMethod represents a method, static function, or constructor on a resource: "name: func(...)", "name: static func(...)", or "constructor(...)".
type TokenType ¶
type TokenType int
TokenType represents the kind of token.
const ( TokenEOF TokenType = iota TokenError // Literals TokenIdent TokenString TokenVersion // semver // Keywords TokenPackage TokenInterface TokenWorld TokenKeywordType // "type" keyword TokenRecord TokenVariant TokenEnum TokenFlags TokenResource TokenFunc TokenUse TokenImport TokenExport TokenAs TokenAsync TokenConstructor TokenStatic // Primitive types TokenBool TokenS8 TokenS16 TokenS32 TokenS64 TokenU8 TokenU16 TokenU32 TokenU64 TokenF32 TokenF64 TokenChar TokenString_Keyword // "string" as a type keyword TokenList TokenOption TokenResult TokenTuple TokenMap TokenFuture TokenStream TokenOwn TokenBorrow TokenErrorContext // "error-context": the async ABI's terminal error-context type // Punctuation TokenLParen // ( TokenRParen // ) TokenLBrace // { TokenRBrace // } TokenLAngle // < TokenRAngle // > TokenColon // : TokenSemicolon // ; TokenComma // , TokenDot // . TokenEq // = TokenArrow // -> TokenSlash // / TokenAt // @ TokenStar // * // Feature gates TokenUnstable TokenSince TokenDeprecated TokenExternalID TokenFeature TokenVersion_Keyword TokenInclude TokenWith )
type TypeAlias ¶
type TypeAlias struct {
Target TypeRef
}
TypeAlias represents a type alias (e.g., "type foo = u32;").
type TypeDef ¶
type TypeDef struct {
Name string
Type TypeDefBody
Docs string
Gate Gate
ExternalID string
Unsupported string // if unsupported construct is detected, name it here
}
TypeDef represents a type definition.
type TypeDefBody ¶
type TypeDefBody interface {
// contains filtered or unexported methods
}
TypeDefBody represents the body of a type definition.
type TypeRef ¶
type TypeRef struct {
Kind string // "u32", "string", "list", "option", "result", "record", etc.
Name string // for named types (user-defined or resource types)
Inner *TypeRef // for list<T>, option<T>, own<T>, borrow<T>
Inner2 *TypeRef // for result<T,E>, map<K,V>, tuple element
Tuple []*TypeRef // for tuple<T1, T2, ...>
Unsupported string // if an unsupported construct is detected, name it here
}
TypeRef represents a type reference (including primitive types and compound types).
type Use ¶
type Use struct {
Path string // e.g., "wasi:io/streams.{InputStream, OutputStream}"
Names map[string]string // local alias -> imported name
Gate Gate
ExternalID string
}
Use represents a use statement.
type Variant ¶
type Variant struct {
Cases []VariantCase
}
Variant represents a variant type (discriminated union).
type VariantCase ¶
VariantCase represents a case in a variant.