[ANN] Ranges tree module

"'Martin Eden' via lua-l" <[email protected]> Sun, 3 May 2026 18:31:36 +0200
Newsgroups gmane.comp.lang.lua.general
Message-ID <[email protected]>
Hello list,

I want to announce my module for storing ranges as named tree nodes
and applying ranges to data.

   https://github.com/martin-eden/Lua-RangesTree

Most parsing code I've seen (and wrote) is hardcode and hard to understand.
I want to provide tool to make it easier to understand.


For example let's imagine we're getting raw ISO 8601 datetime string
like "2026-05-03 18:10:30".

We want to extract date and month from any such string

   2026-05-03 18:10:30
   ~~~~ ~~ ~~           -- Date (20260503)
        ~~              -- Date.Month (05)

   --[[ Lua

   StringFields:AddNameAndRanges(
     'Date',
     {
       create_range(1, 4),
       create_range(6, 2),
       create_range(9, 2),
     }
   )
   StringFields:AddNameAndRange(
     'Date.Month',
     create_range(5, 2)
   )

   local InputData = create_string_value('2026-05-03 18:10:30')
   local OutputData

   OutputData = create_string_value()
   apply_ranges(InputData, StringFields:GetRanges('Date'), OutputData)
   print('Date is ' .. OutputData:GetValue())

   OutputData = create_string_value()
   apply_ranges(InputData, StringFields:GetRanges('Date.Month'), OutputData)
   print('Month is ' .. OutputData:GetValue())

   --]]

And module can work with bit fields in same fashion.

As usual, zero dependencies. Only Lua 5.3 is required.

All feedback is welcome!

-- Martin

-- 
You received this message because you are subscribed to the Google Groups "lua-l" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/lua-l/b67ffc4e-eb87-4327-9821-73a6f03d596a%40disroot.org.