mirror of
https://github.com/vlang/v.git
synced 2025-09-16 16:02:29 +03:00
v.token: add manual .str() methods for KeywordsMatcherTrie and TrieNode, to workaround cgen errors
This commit is contained in:
parent
1b3ec4aea3
commit
4bc72835b8
1 changed files with 13 additions and 0 deletions
|
@ -11,6 +11,11 @@ pub mut:
|
||||||
max_len int
|
max_len int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// str returns a short representation of matcher
|
||||||
|
pub fn (km &KeywordsMatcherTrie) str() string {
|
||||||
|
return 'KeywordsMatcherTrie{ /* nodes.len: ${km.nodes.len} */ min_len: ${km.min_len}, max_len: ${km.max_len} }'
|
||||||
|
}
|
||||||
|
|
||||||
// TrieNode is a single node from a trie, used by KeywordsMatcherTrie
|
// TrieNode is a single node from a trie, used by KeywordsMatcherTrie
|
||||||
pub struct TrieNode {
|
pub struct TrieNode {
|
||||||
pub mut:
|
pub mut:
|
||||||
|
@ -18,6 +23,14 @@ pub mut:
|
||||||
value int = -1 // when != -1, it is a leaf node representing a match
|
value int = -1 // when != -1, it is a leaf node representing a match
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// str returns a string representation of the node content
|
||||||
|
pub fn (node &TrieNode) str() string {
|
||||||
|
if isnil(node) {
|
||||||
|
return '&TrieNode(nil)'
|
||||||
|
}
|
||||||
|
return '&TrieNode{value: ${node.value}}'
|
||||||
|
}
|
||||||
|
|
||||||
// find tries to find the given `word` in the set of all previously added words
|
// find tries to find the given `word` in the set of all previously added words
|
||||||
// to the KeywordsMatcherTrie instance. It returns -1 if the word was NOT found
|
// to the KeywordsMatcherTrie instance. It returns -1 if the word was NOT found
|
||||||
// there at all. If the word was found, find will return the `value` (value => 0),
|
// there at all. If the word was found, find will return the `value` (value => 0),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue