Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasNamedGroups ¶
HasNamedGroups reports whether any capture group (1..N) carries a name.
Types ¶
type MatchMode ¶
type MatchMode int
MatchMode controls how the generated function matches input.
const ( // MatchFull requires the entire input to match (default). Equivalent to ^pattern$. MatchFull MatchMode = iota // MatchPrefix matches if a prefix of the input matches the pattern. Equivalent to ^pattern. MatchPrefix // MatchContains matches if any substring of the input matches. Equivalent to unanchored pattern. MatchContains )
type Options ¶
type Options struct {
PackageName string // Go package name
FuncName string // Name of the generated match function
Regex string // Original regex (for comment)
Mode MatchMode // Match mode (default: MatchFull)
Submatch *SubmatchOptions // If non-nil, also generate a FindSubmatch function
// LiteralPrefix/LiteralComplete mirror syntax.Prog.Prefix() for the
// pattern: when LiteralComplete is true the pattern matches exactly the
// literal LiteralPrefix, and contains mode compiles to a single
// strings.Contains call instead of a DFA scan.
LiteralPrefix string
LiteralComplete bool
}
Options controls the generated code.
type SubmatchOptions ¶
type SubmatchOptions struct {
PackageName string
FuncName string // e.g. "FindSubmatch" — positional []string API
MatchFunc string // name of the bool match function to call first
Regex string
Prog *syntax.Prog
NumGroups int // number of capture groups (not counting group 0)
GroupNames []string // names per group index (len NumGroups+1); index 0 == ""
// NamesFuncName is the name of the generated accessor that returns the
// group-name slice (parity with regexp.Regexp.SubexpNames). Always emitted.
NamesFuncName string
// Struct controls generation of the typed capture struct. It is only
// emitted when StructEnabled is true AND at least one named group exists.
StructEnabled bool
StructType string // type name, e.g. "Captures"
StructFunc string // constructor func name, e.g. "FindCaptures"
}
SubmatchOptions controls generation of the submatch function family.
Click to show internal directories.
Click to hide internal directories.