[ANN] Ranges tree module

48 views
Skip to first unread message

Martin Eden

unread,
May 3, 2026, 12:31:45 PM (9 days ago) May 3
to lu...@googlegroups.com
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
Reply all
Reply to author
Forward
0 new messages