MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cbm_sem_tokenize

Function cbm_sem_tokenize

src/semantic/semantic.c:166–368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164}
165
166int cbm_sem_tokenize(const char *name, char **out, int max_out) {
167 if (!name || !out || max_out <= 0) {
168 return 0;
169 }
170 int count = 0;
171 char buf[TOKEN_BUF_LEN];
172 int blen = 0;
173
174 for (int i = 0; name[i] && count < max_out; i++) {
175 char c = name[i];
176 bool split = is_token_delim(c);
177 bool camel = is_camel_break(name, i);
178 if (split || camel) {
179 flush_token(buf, &blen, out, &count, max_out);
180 if (split) {
181 continue;
182 }
183 }
184 if (blen < TOKEN_BUF_LEN - SKIP_ONE && isalnum((unsigned char)c)) {
185 buf[blen++] = (char)tolower((unsigned char)c);
186 }
187 }
188 flush_token(buf, &blen, out, &count, max_out);
189
190 /* Abbreviation expansion: add expanded forms for common code abbreviations.
191 * "err" → also add "error", "ctx""context", etc. */
192 /* Cross-language abbreviation table — covers Go, Python, JS/TS, Rust,
193 * Java, C/C++, Ruby, PHP, Kotlin, Swift, Scala, C#, and common patterns. */
194 static const struct {
195 const char *abbrev;
196 const char *expanded;
197 } abbrevs[] = {
198 /* Error/exception handling */
199 {"err", "error"},
200 {"exc", "exception"},
201 {"ex", "exception"},
202 /* Context/config */
203 {"ctx", "context"},
204 {"cfg", "config"},
205 {"conf", "configuration"},
206 {"env", "environment"},
207 {"opt", "option"},
208 {"opts", "options"},
209 /* Request/response (HTTP, RPC) */
210 {"req", "request"},
211 {"res", "response"},
212 {"resp", "response"},
213 {"rsp", "response"},
214 {"hdr", "header"},
215 {"hdrs", "headers"},
216 /* Strings/formatting */
217 {"str", "string"},
218 {"fmt", "format"},
219 {"msg", "message"},
220 {"txt", "text"},
221 {"lbl", "label"},
222 {"desc", "description"},
223 /* Data structures */

Callers 5

tokenize_call_neighborsFunction · 0.85
tokenize_nodeFunction · 0.85
test_semantic.cFile · 0.85

Calls 3

is_token_delimFunction · 0.85
is_camel_breakFunction · 0.85
flush_tokenFunction · 0.85

Tested by

no test coverage detected