Summary Files Commits Branches @commit @diff @stats
path: root / src / Token
diff options
context:
space:
mode:
Commitb43c94ca62a747f2f9fb222cdf887c041dd544bb (patch)
Author
 Syndamia <kamen@syndamia.com>
2025-11-01 16:28:08 +0200
Committer
 Syndamia <kamen@syndamia.com>
2025-11-01 16:28:08 +0200
Files43e0ea846844257cf46055e68cc2661056b05965 /src/Token
cool-self-hosted-b43c94ca62a747f2f9fb222cdf887c041dd544bb.tar
cool-self-hosted-b43c94ca62a747f2f9fb222cdf887c041dd544bb.tar.gz
cool-self-hosted-b43c94ca62a747f2f9fb222cdf887c041dd544bb.zip
Parent0830615386f036acc55a72b2548efb65526c761f (diff)
feat!: Add basic lexer components
2 files changed, 34 insertions, 0 deletions
-rw-r--r--src/Token/IToken.cl24
-rw-r--r--src/Token/WhitespaceToken.cl10
diff --git a/src/Token/IToken.cl b/src/Token/IToken.cl
new file mode 100644
index 0000000..05282ab
--- /dev/null
+++ b/src/Token/IToken.cl
@@ -0,0 +1,24 @@
+class IToken inherits System {
+---
+ name() : String {
+ not_implemented_retstr("name")
+ };
+
+ value() : String {
+ not_implemented_retstr("value")
+ };
+
+---
+ id: Int;
+
+ id() : Int {
+ id
+ };
+
+ init(iid: Int) : Object {{
+ assert(iid = 0, "init", "ID 0 is not allowed for a token!");
+ assert(not (id = 0), "init", "token object '".concat(name()).concat("' is already initialized!"));
+ id <- iid;
+ void;
+ }};
+};
diff --git a/src/Token/WhitespaceToken.cl b/src/Token/WhitespaceToken.cl
new file mode 100644
index 0000000..e0d70c0
--- /dev/null
+++ b/src/Token/WhitespaceToken.cl
@@ -0,0 +1,10 @@
+class WhitespaceToken inherits IToken {
+ name() : String {
+ "WHITESPACE"
+ };
+
+ -- We'll never use the whitespace value
+ value() : String {
+ ""
+ };
+};