summaryrefslogtreecommitdiff
path: root/src/tokenizer.h
diff options
context:
space:
mode:
authorDylan <boss@tehbox.org>2026-06-06 19:36:41 +1200
committerDylan <boss@tehbox.org>2026-06-06 19:36:41 +1200
commit1d379a5cf34475f66f2ab9359f77dac162c0a40e (patch)
tree395d54815331fbcad053001bf5cb28fafb69e9d4 /src/tokenizer.h
parent46c896bcd78d31130321562b0659e28230261b8e (diff)
downloadtehjson-1d379a5cf34475f66f2ab9359f77dac162c0a40e.tar.gz
tehjson-1d379a5cf34475f66f2ab9359f77dac162c0a40e.zip
feat: JSON reading
- Implemented a tokenizer for json - Implemented a method which will read json from a string using the tokenizer
Diffstat (limited to 'src/tokenizer.h')
-rw-r--r--src/tokenizer.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/tokenizer.h b/src/tokenizer.h
new file mode 100644
index 0000000..3322553
--- /dev/null
+++ b/src/tokenizer.h
@@ -0,0 +1,36 @@
+#pragma once
+
+#include <string>
+#include <vector>
+
+namespace TehJSON
+{
+ enum struct TokenType
+ {
+ LBrace,
+ RBrace,
+ Colon,
+ Comma,
+ StringLit,
+ IntLit,
+ FloatLit,
+ };
+
+ std::string getTokenName(TokenType t);
+
+ struct Token
+ {
+ TokenType type;
+ std::string content;
+ };
+
+ class Tokenizer
+ {
+ public:
+ void appendInput(std::string s);
+ std::vector<Token> tokenize();
+ std::string getInput();
+ private:
+ std::string input = "";
+ };
+}