From 6f95f38373e4c8d0bcf6b3de106d1422e56d2845 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 11 Mar 2026 16:19:40 -0500 Subject: [PATCH] xo-interpreter2: + nil + cons --- include/xo/tokenizer2/Token.hpp | 2 ++ include/xo/tokenizer2/tokentype.hpp | 3 +++ src/tokenizer2/Tokenizer.cpp | 2 ++ src/tokenizer2/tokentype.cpp | 1 + 4 files changed, 8 insertions(+) diff --git a/include/xo/tokenizer2/Token.hpp b/include/xo/tokenizer2/Token.hpp index 7537a2b0..0968a9e9 100644 --- a/include/xo/tokenizer2/Token.hpp +++ b/include/xo/tokenizer2/Token.hpp @@ -134,6 +134,8 @@ namespace xo { /** token for @c "==" **/ static Token cmpeq_token() { return Token(tokentype::tk_cmpeq); } + /** token representing keyword @c nil **/ + static Token nil_token() { return Token(tokentype::tk_nil); } /** token representing keyword @c type **/ static Token type() { return Token(tokentype::tk_type); } /** token representing keyword @c def **/ diff --git a/include/xo/tokenizer2/tokentype.hpp b/include/xo/tokenizer2/tokentype.hpp index d0290b05..5f7e1937 100644 --- a/include/xo/tokenizer2/tokentype.hpp +++ b/include/xo/tokenizer2/tokentype.hpp @@ -140,6 +140,9 @@ namespace xo { /** operator @c '!=' **/ tk_cmpne, + /** keyword @c 'nil' **/ + tk_nil, + /** keyword @c 'type' **/ tk_type, diff --git a/src/tokenizer2/Tokenizer.cpp b/src/tokenizer2/Tokenizer.cpp index f6ac7c2f..2a6f8ed9 100644 --- a/src/tokenizer2/Tokenizer.cpp +++ b/src/tokenizer2/Tokenizer.cpp @@ -587,6 +587,8 @@ namespace xo { if ((tk_text == "true") || (tk_text == "false")) { tk_type = tokentype::tk_bool; keep_text = true; + } else if (tk_text == "nil") { + tk_type = tokentype::tk_nil; } else if (tk_text == "type") { tk_type = tokentype::tk_type; } else if (tk_text == "def") { diff --git a/src/tokenizer2/tokentype.cpp b/src/tokenizer2/tokentype.cpp index 7df59eec..b8a013da 100644 --- a/src/tokenizer2/tokentype.cpp +++ b/src/tokenizer2/tokentype.cpp @@ -49,6 +49,7 @@ namespace xo { CASE(tk_cmpeq); CASE(tk_cmpne); + CASE(tk_nil); CASE(tk_type); CASE(tk_def); CASE(tk_deftype);