Documentation
¶
Index ¶
- func IsKeyword(s string) bool
- func LastSegment(path string) string
- type Accessor
- type Attrs
- type Enum
- type Error
- type Export
- type Extern
- type ExternFunc
- type ExternInterface
- type ExternKind
- type ExternNamedPath
- type ExternPath
- type Flags
- type Func
- type FuncParam
- type Gate
- type GateItem
- type Import
- type Include
- type IncludeName
- type Interface
- type InterfaceFunc
- type InterfaceItem
- type Package
- type PackageItem
- type Pos
- type Record
- type RecordField
- type Resource
- type ResourceMethod
- type ToplevelUse
- type TypeAlias
- type TypeDef
- type TypeDefBody
- type TypeRef
- type Use
- type UseName
- type Variant
- type VariantCase
- type World
- type WorldItem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsKeyword ¶ added in v0.8.0
IsKeyword reports whether s is a WIT keyword, which a name must spell with a leading '%' to be read as a name.
func LastSegment ¶ added in v0.6.0
LastSegment is the item name in a use path: "c" in "c" or "a:b/c@1.0.0".
Types ¶
type Accessor ¶ added in v0.6.0
type Accessor int
Accessor says whether a func is a property getter ("name: get() -> T") or setter ("name: set(value: T)").
type Attrs ¶ added in v0.6.0
Attrs are the attributes written before an item: its gate, and the position of each "@external-id(...)", in order.
type Extern ¶ added in v0.6.0
type Extern struct {
Name string
Pos Pos
Kind ExternKind
Attrs
}
Extern is what an import or export names. Name is the func's, inline interface's or label's name -- or, for an interface named by path alone, the path.
type ExternFunc ¶ added in v0.6.0
type ExternFunc struct{ Func Func }
ExternFunc is "name: func(...)".
type ExternInterface ¶ added in v0.6.0
type ExternInterface struct{ Items []InterfaceItem }
ExternInterface is "name: interface { ... }".
type ExternKind ¶ added in v0.6.0
type ExternKind interface {
// contains filtered or unexported methods
}
ExternKind is the shape of an import or export.
type ExternNamedPath ¶ added in v0.6.0
ExternNamedPath is "label: path;": an import or export under a name of its own that implements the interface at Path.
type ExternPath ¶ added in v0.6.0
type ExternPath struct{}
ExternPath is an interface named by path alone: "iface;" or "ns:pkg/iface@ver;". Its Extern.Name is the path.
type Func ¶
type Func struct {
Params []FuncParam
Result *TypeRef // nil if no return type, or points to the result type
Async bool
Accessor Accessor
Pos Pos // the `func`, `get`, `set` or `constructor` keyword
}
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"
Pos Pos
}
GateItem is a single feature-gate attribute attached to a WIT item: "@since(version = X)", "@unstable(feature = X)", or "@deprecated(version = X)".
type Include ¶
type Include struct {
Path string
PathPos Pos
Renames []IncludeName
Attrs
}
Include represents an "include world;" or "include world with { a as a1, b as b1 }" statement.
type IncludeName ¶ added in v0.6.0
IncludeName is one "a as b" of an include's with-list.
type Interface ¶
type Interface struct {
Name string
Pos Pos
Items []InterfaceItem
Attrs
}
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 Package ¶
type Package struct {
// Name is the package name ("wasi:io@0.2.0"), or "" without a header.
Name string
NamePos Pos
// Docs says whether comments precede a file's header, which
// wit-parser takes as the package's docs.
Docs bool
// Items are *Interface, *World and *ToplevelUse.
Items []PackageItem
Nested []*Package
}
Package is one parsed WIT file: an optional "package ns:name@ver;" header, the items at its top level, and any nested "package ns:name { ... }" blocks, each a package of its own.
type PackageItem ¶
type PackageItem interface {
// contains filtered or unexported methods
}
PackageItem is a marker interface for top-level package items.
type Pos ¶ added in v0.6.0
Pos is where an item is written: a file, and a 1-based line and byte column, as wit-parser reports them.
type RecordField ¶
RecordField represents a field in a record.
type Resource ¶
type Resource struct {
Methods []ResourceMethod
}
Resource represents a resource type.
type ResourceMethod ¶
ResourceMethod represents a method, static function, or constructor on a resource: "name: func(...)", "name: static func(...)", or "constructor(...)".
type ToplevelUse ¶ added in v0.6.0
type ToplevelUse struct {
Path string
PathPos Pos
As string // "" for none
AsPos Pos
Pos Pos // the `use` keyword
Attrs
}
ToplevelUse is "use path;" or "use path as name;" at a file's top level: it names an interface or world for the rest of that file.
func (*ToplevelUse) Local ¶ added in v0.6.0
func (u *ToplevelUse) Local() (string, Pos)
Local is the name a ToplevelUse is known by in its file.
type TypeAlias ¶
type TypeAlias struct {
Target TypeRef
}
TypeAlias represents a type alias (e.g., "type foo = u32;").
type TypeDef ¶
type TypeDef struct {
Name string
Pos Pos
Type TypeDefBody
Attrs
}
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", "named", etc.
Name string // for named types and own/borrow handles
Inner *TypeRef // list<T>, option<T>, result<T, _>, map<K, _>, future<T>, stream<T>
Inner2 *TypeRef // result<_, E>, map<_, V>
Tuple []*TypeRef // tuple<T1, T2, ...>
Fixed bool // list<T, N>: a fixed-length list
Length uint32 // list<T, N>: N
Pos Pos
}
TypeRef represents a type reference (including primitive types and compound types).
type Variant ¶
type Variant struct {
Cases []VariantCase
}
Variant represents a variant type (discriminated union).
type VariantCase ¶
VariantCase represents a case in a variant.