From bc1b5b5e53a6f16d4b597808ae905eb558519d34 Mon Sep 17 00:00:00 2001 From: OmniaX-Dev Date: Mon, 22 Jun 2026 06:52:04 +0200 Subject: [PATCH] Started work on Database code --- extra/testQuery.oq | 9 +++++++++ other/test.txt | 17 +++++++++++++++++ src/ostd/io/database/Lexer.cpp | 28 ++++++++++++++++++++++++++++ src/ostd/io/database/Lexer.hpp | 30 ++++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+) create mode 100644 extra/testQuery.oq create mode 100644 other/test.txt create mode 100644 src/ostd/io/database/Lexer.cpp create mode 100644 src/ostd/io/database/Lexer.hpp diff --git a/extra/testQuery.oq b/extra/testQuery.oq new file mode 100644 index 0000000..8267b80 --- /dev/null +++ b/extra/testQuery.oq @@ -0,0 +1,9 @@ +GET UNIQUE name AS "Name", age, country, children # * can be used to get all columns; UNIQUE is optional +IN test_table +FOR ([age == 20] OR [year <= 1998]) AND # FOR conditions should support all regular comparison operators (==, !=, <, <=, >, >=) when applicable + ([name == "Alberto"] OR [name MATCHES "regex"]) AND + [country IN {"Spain", "Italy", "Germany"}] AND + NOT [children BETWEEN 2,4 INCL] # Possible values: INCL (default, implicit), EXCL, INCL_L, INCL_R +CROSS test_table_2 MATCH # Possible values: MATCH (default, implicit), LEFT, RIGHT, FULL +IF test_table.id == test_table_2.user_id # Debating if this should support only equality, or more complex conditions, maybe even matching FOR conditions +ORDER age, year DESC; # Possible values: ASC (default, implicit), DESC diff --git a/other/test.txt b/other/test.txt new file mode 100644 index 0000000..d22ec03 --- /dev/null +++ b/other/test.txt @@ -0,0 +1,17 @@ +enum class eTokenType { + Keyword, // GET, IN, FOR, CROSS, IF, ORDER, UNIQUE, AS, OR, AND, NOT, + // IN, MATCHES, BETWEEN, INCL, EXCL, INCL_L, INCL_R, + // MATCH, LEFT, RIGHT, FULL, ASC, DESC, NULL + Identifier, // name, age, test_table.id + StringLit, // "Alberto" + NumberLit, // 20, 1998 + Operator, // == != < <= > >= + Symbol, // ( ) [ ] { } , . * ; + EndOfInput +}; + +struct Token { + eTokenType type; + String value; // raw text + u32 line, col; // for error reporting — add from day one, you'll regret skipping it +}; diff --git a/src/ostd/io/database/Lexer.cpp b/src/ostd/io/database/Lexer.cpp new file mode 100644 index 0000000..2d34d17 --- /dev/null +++ b/src/ostd/io/database/Lexer.cpp @@ -0,0 +1,28 @@ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2026 OmniaX-Dev + + This file is part of OmniaFramework. + + OmniaFramework is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OmniaFramework is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OmniaFramework. If not, see . +*/ + +#include "Lexer.hpp" + +namespace ostd +{ + namespace db + { + } +} diff --git a/src/ostd/io/database/Lexer.hpp b/src/ostd/io/database/Lexer.hpp new file mode 100644 index 0000000..c5ed3e4 --- /dev/null +++ b/src/ostd/io/database/Lexer.hpp @@ -0,0 +1,30 @@ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2026 OmniaX-Dev + + This file is part of OmniaFramework. + + OmniaFramework is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OmniaFramework is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OmniaFramework. If not, see . +*/ + +#pragma once + +#include + +namespace ostd +{ + namespace db + { + } +}