Documentation ¶
Index ¶
- func GetDebugLoggerOutput() *log.Logger
- func NewStack[T any]() stackT[T]
- func SetDebugLogger(logger *log.Logger)
- type Class
- type Compiler
- func (s *Compiler[T]) AddClass(oClass *Class[T])
- func (s *Compiler[T]) AddIdentity(name string, object T)
- func (s *Compiler[T]) Compile(text string) (*Regexp[T], error)
- func (s *Compiler[T]) Finalize()
- func (s *Compiler[T]) Initialize()
- func (s *Compiler[T]) MakeClass(name string, predicate func(T) bool)
- func (s *Compiler[T]) MustCompile(text string) *Regexp[T]
- type Match
- type Range
- type Regexp
- func (s *Regexp[T]) FullMatch(input []T) Match
- func (s *Regexp[T]) FullMatchAt(input []T, start int) Match
- func (s *Regexp[T]) Match(input []T) Match
- func (s *Regexp[T]) MatchAt(input []T, start int) Match
- func (s *Regexp[T]) Search(input []T) Match
- func (s *Regexp[T]) SearchAt(input []T, start int) Match
- func (s *Regexp[T]) WriteDot(filename string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetDebugLoggerOutput ¶
Returns the output of the current debug logger in this module. You can then call SetOutput on the object, for example.
func SetDebugLogger ¶
Change the debug logger object in this module
Types ¶
type Class ¶
type Class[T comparable] struct { Name string Matches func(T) bool }
type Compiler ¶
type Compiler[T comparable] struct { // contains filtered or unexported fields }
The regex compiler. This holds all the user-defined classes that can be used in the regexes.
func NewCompiler ¶
func NewCompiler[T comparable]() *Compiler[T]
Instantiates and initializes a new Compiler.
func (*Compiler[T]) AddIdentity ¶
Registers a user-defined identity.
func (*Compiler[T]) Compile ¶
Compile a regex string into a Regexp object. An error is returned if there is a syntax error.
func (*Compiler[T]) Finalize ¶
func (s *Compiler[T]) Finalize()
After registering all the classes, you must call Finalize() so Compile() can then be used.
func (*Compiler[T]) Initialize ¶
func (s *Compiler[T]) Initialize()
Initializes a Compiler. Use this if you have allocated a Compiler object already, and only need to Initialize it.
func (*Compiler[T]) MakeClass ¶
Creates and registers a user-defined class from the given arguments.
func (*Compiler[T]) MustCompile ¶
Compile a regex string into a Regexp object. On error, raises a panic.
type Match ¶
type Match struct { // Did the Regexp find something? Success bool // The range for the entire sub-string that matched Range Range // contains filtered or unexported fields }
Returned by a Regexp matching-related function. Even if the Regexp doesn't match, a Match object is returned, but Success is false.
func (Match) Group ¶
Get a numbered capture group from the Match object. Every left parenthesis in the regex gets a number, starting with 1.
func (Match) HasGroup ¶
Does the numbered capture group have any objects? Every left parenthesis in the regex gets a number, starting with 1.
func (Match) HasGroupName ¶
Does the named capture group have any objects?
type Range ¶
This is used to record the span of objects, relative to the slice of input objects that was given. Start and End follow Golang slice semantics. The positions are 0-indexed. A slice of 1 item at the beginning of the slice has Start = 0 and End = 1.
type Regexp ¶
type Regexp[T comparable] struct { // contains filtered or unexported fields }
The compiled regex.
func (*Regexp[T]) FullMatch ¶
Match the regex against the input, to the end of the input. The match begins at input position 0.
func (*Regexp[T]) FullMatchAt ¶
Match the regex against the input, to the end of the input. The match begins at the start position you give.
func (*Regexp[T]) Match ¶
Match the regex against the input. This can match a sub-slice of the input. The match begins at input position 0.
func (*Regexp[T]) MatchAt ¶
Match the regex against the input. This can match a sub-slice of the input. The match begins at the start position you give.
func (*Regexp[T]) Search ¶
Search every position within the input to match the Regex. The match begins at input position 0. If the regexp can only possibly match at at the beinning of the input, then this reverts to MatchAt(0)