package match

Import Path
	github.com/google/licensecheck/internal/match (on go.dev)

Dependency Relation
	imports 10 packages, and imported by one package

Involved Source Files Package match defines matching algorithms and support code for the license checker. regexp.go rematch.go resyntax.go
Package-Level Type Names (total 20, in which 8 are exported)
/* sort exporteds by: | */
A Dict maps words to integer indexes in a word list, of type WordID. The zero Dict is an empty dictionary ready for use. Lookup and Words are read-only operations, safe for any number of concurrent calls from multiple goroutines. Insert is a write operation; it must not run concurrently with any other call, whether to Insert, Lookup, or Words. Insert adds the word w to the word list, returning its index. If w is already in the word list, it is not added again; Insert returns the existing index. InsertSplit splits text into a sequence of lowercase words, inserting any new words in the dictionary. Lookup looks for the word w in the word list and returns its index. If w is not in the word list, Lookup returns BadWord. Split splits text into a sequence of lowercase words. It does not add any new words to the dictionary. Unrecognized words are reported as having ID = BadWord. Words returns the current word list. The list is not a copy; the caller can read but must not modify the list. func (*LRE).Dict() *Dict func (*MultiLRE).Dict() *Dict func ParseLRE(d *Dict, file, s string) (*LRE, error)
An LRE is a compiled license regular expression. TODO: Move this comment somewhere non-internal later. A license regular expression (LRE) is a pattern syntax intended for describing large English texts such as software licenses, with minor allowed variations. The pattern syntax and the matching are word-based and case-insensitive; punctuation is ignored in the pattern and in the matched text. The valid LRE patterns are: word - a single case-insensitive word __N__ - any sequence of up to N words expr1 expr2 - concatenation expr1 || expr2 - alternation (( expr )) - grouping expr?? - zero or one instances of expr //** text **// - a comment To make patterns harder to misread in large texts: - || must only appear inside (( )) - ?? must only follow (( )) - (( must be at the start of a line, preceded only by spaces - )) must be at the end of a line, followed only by spaces and ??. For example: //** https://en.wikipedia.org/wiki/Filler_text **// Now is ((not))?? the time for all good ((men || women || people)) to come to the aid of their __1__. Dict returns the Dict used by the LRE. File returns the file name passed to ParseLRE. func ParseLRE(d *Dict, file, s string) (*LRE, error) func NewMultiLRE(list []*LRE) (_ *MultiLRE, err error)
A Match records the position of a single match in a text. // word index of end of match // index of LRE in list passed to NewMultiLRE // word index of start of match
A Matches is a collection of all leftmost-longest, non-overlapping matches in text. // the matches // the entire text // the text, split into Words func (*MultiLRE).Match(text string) *Matches
A MultiLRE matches multiple LREs simultaneously against a text. It is more efficient than matching each LRE in sequence against the text. Dict returns the Dict used by the MultiLRE. Match reports all leftmost-longest, non-overlapping matches in text. It always returns a non-nil *Matches, in order to return the split text. Check len(matches.List) to see whether any matches were found. func NewMultiLRE(list []*LRE) (_ *MultiLRE, err error)
A SyntaxError reports a syntax error during parsing. Context string Err string File string Offset int (*T) Error() string *T : error
A Word represents a single word found in a text. Hi int32 ID WordID // Word appears at text[Lo:Hi]. func (*Dict).InsertSplit(text string) []Word func (*Dict).Split(text string) []Word
A WordID is the index of a word in a dictionary. func (*Dict).Insert(w string) WordID func (*Dict).Lookup(w string) WordID const AnyWord const BadWord
Package-Level Functions (total 25, in which 2 are exported)
NewMultiLRE returns a MultiLRE looking for the given LREs. All the LREs must have been parsed using the same Dict; if not, NewMultiLRE panics.
ParseLRE parses the string s as a license regexp. The file name is used in error messages if non-empty.
Package-Level Variables (total 4, in which 1 are exported)
TraceDFA controls whether DFA execution prints debug tracing when stuck. If TraceDFA > 0 and the DFA has followed a path of at least TraceDFA symbols since the last matching state but hits a dead end, it prints out information about the dead end.
Package-Level Constants (total 19, in which 2 are exported)
AnyWord represents a wildcard matching any word.
BadWord represents a word not present in the dictionary.