summaryrefslogtreecommitdiff
path: root/llama.cpp/tests/peg-parser/simple-tokenize.cpp
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2026-02-12 20:57:17 +0100
committerMitja Felicijan <mitja.felicijan@gmail.com>2026-02-12 20:57:17 +0100
commitb333b06772c89d96aacb5490d6a219fba7c09cc6 (patch)
tree211df60083a5946baa2ed61d33d8121b7e251b06 /llama.cpp/tests/peg-parser/simple-tokenize.cpp
downloadllmnpc-b333b06772c89d96aacb5490d6a219fba7c09cc6.tar.gz
Engage!
Diffstat (limited to 'llama.cpp/tests/peg-parser/simple-tokenize.cpp')
-rw-r--r--llama.cpp/tests/peg-parser/simple-tokenize.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/llama.cpp/tests/peg-parser/simple-tokenize.cpp b/llama.cpp/tests/peg-parser/simple-tokenize.cpp
new file mode 100644
index 0000000..9abfa04
--- /dev/null
+++ b/llama.cpp/tests/peg-parser/simple-tokenize.cpp
@@ -0,0 +1,37 @@
+#include "simple-tokenize.h"
+
+std::vector<std::string> simple_tokenize(const std::string & input) {
+ std::vector<std::string> result;
+ std::string current;
+
+ for (size_t i = 0; i < input.size(); i++) {
+ switch (input[i]) {
+ case ' ':
+ case '\n':
+ case '\t':
+ case '{':
+ case '}':
+ case ',':
+ case '[':
+ case '"':
+ case ']':
+ case '.':
+ case '<':
+ case '>':
+ case '=':
+ case '/':
+ if (!current.empty()) {
+ result.push_back(current);
+ current.clear();
+ }
+ default:;
+ }
+ current += input[i];
+ }
+
+ if (!current.empty()) {
+ result.push_back(current);
+ }
+
+ return result;
+}