34 linhas
1,2 KiB
Lua
34 linhas
1,2 KiB
Lua
-- bin/util.lua - Utilities for the LAMENT CLI
|
||
--
|
||
-- Copyright (C) 2024-2025 Kıvılcım Defne Öztürk
|
||
--
|
||
-- This program 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.
|
||
--
|
||
-- This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||
|
||
local bin = {}
|
||
bin.util = {}
|
||
|
||
|
||
---Verifies the syntax of a key
|
||
---@param key string The key to verify the syntax of
|
||
local function verify_key_syntax(key)
|
||
local segments = {}
|
||
for subkey in key:match("^([a-zA-Z_][a-zA-Z0-9_]*)(%.[a-zA-Z_][a-zA-Z0-9_]*)*$") do
|
||
table.insert(segments, subkey)
|
||
end
|
||
return next(segments) and segments or nil
|
||
end
|
||
|
||
bin.util.verify_key_syntax = verify_key_syntax
|
||
|
||
return bin.util
|