Documentation ¶
Index ¶
- type Match
- func (m *Match) Attr(name string) (starlark.Value, error)
- func (m *Match) AttrNames() []string
- func (m *Match) CompareSameType(op syntax.Token, y starlark.Value, _ int) (bool, error)
- func (m *Match) Freeze()
- func (m *Match) Get(v starlark.Value) (starlark.Value, bool, error)
- func (m *Match) Hash() (uint32, error)
- func (m *Match) String() string
- func (m *Match) Truth() starlark.Bool
- func (m *Match) Type() string
- type Module
- func (m *Module) Attr(name string) (starlark.Value, error)
- func (m *Module) AttrNames() []string
- func (m *Module) Freeze()
- func (m *Module) Hash() (uint32, error)
- func (m *Module) Members() starlark.StringDict
- func (m *Module) String() string
- func (m *Module) Truth() starlark.Bool
- func (m *Module) Type() string
- type ModuleOptions
- type Pattern
- func (p *Pattern) Attr(name string) (starlark.Value, error)
- func (p *Pattern) AttrNames() []string
- func (p *Pattern) CompareSameType(op syntax.Token, y starlark.Value, _ int) (bool, error)
- func (p *Pattern) Freeze()
- func (p *Pattern) Hash() (uint32, error)
- func (p *Pattern) String() string
- func (p *Pattern) Truth() starlark.Bool
- func (p *Pattern) Type() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Match ¶
type Match struct {
// contains filtered or unexported fields
}
Match represents a single regex match.
func (*Match) Attr ¶
Attr returns the member of the module with the given name. If the member exists in `matchMethods`, a bound method is returned. Alternatively, if the pattern member exists in `matchMembers`, the member value is returned instead. If the member does not exist, `nil, nil` is returned.
func (*Match) CompareSameType ¶
CompareSameType compares this matches to another one. It is only supported, to compare matches for equality and inequality.
func (*Match) Get ¶
Get returns the value corresponding to the specified key. For the match object, this is equal with calling the `group` function.
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module is a module type used for the "re" module. the "re" module contains an LRU cache for compiled regex patterns. This cache is implemented using a map and a linked list. When the cache exceeds the maximum size, the least recently used element is removed. The module is designed to be thread-safe.
func NewModule ¶
func NewModule() *Module
NewModule creates the Starlark "re" module with the default options returned by `DefaultOptions`.
func NewModuleOptions ¶
func NewModuleOptions(opts *ModuleOptions) *Module
NewModuleOptions creates the Starlark "re" module with custom options. The options may be nil. If this is the case then the default options are used. If the cache size is not a positive integer, the pattern cache is disabled.
func (*Module) Attr ¶
Attr returns the member of the module with the given name. If the member exists and is of the type `*Builtin`, it becomes bound to this module. Otherwise, the member is returned as normal. If the member does not exist, `nil, nil` is returned.
func (*Module) Members ¶
func (m *Module) Members() starlark.StringDict
Members returns a dictionary containing all members of this module. This function may be useful when needing a dictionary of available members inside a `Load()` function. Note that all members of type `*Builtin` are already bound to this module, making them safe to call.
type ModuleOptions ¶
ModuleOptions represents the available options when initializing the "re" module. There are three options:
- `DisableCache` disables to store compiled patterns in a pattern cache, resulting in higher runtimes.
- `MaxCacheSize` sets the maximum size of the cache.
- `DisableFallback` disables the fallback engine `regexp2.Regexp`. Compiling patterns that are not supported by `regexp.Regexp' will then fail.
func DefaultOptions ¶
func DefaultOptions() *ModuleOptions
DefaultOptions returns the default options:
- pattern cache is enabled
- a maximum cache size of 64
- the fallback regex engine is enabled
type Pattern ¶
type Pattern struct {
// contains filtered or unexported fields
}
Pattern is a starlark representation of a compiled regex.
func (*Pattern) Attr ¶
Attr returns the member of the module with the given name. If the member exists in `patternMethods`, a bound method is returned. Alternatively, if the pattern member exists in `patternMembers`, the member value is returned instead. If the member does not exist, `nil, nil` is returned.
func (*Pattern) CompareSameType ¶
CompareSameType compares this pattern to another one. It is only possible to compare patterns for equality and inequality.
func (*Pattern) Freeze ¶
func (p *Pattern) Freeze()
Freeze marks the value and all members as frozen.