lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I have a suggestion for adding a type of group capture that uses the
first captured value as the "name" of the group and the second
captured value as the "value". This is particularly useful for dynamic
keys in a table capture. As an example, if I wanted to parse a subset
of a Lua table (without using loadstring) that has only string keys
and values, I would want to parse the key and use it as the "name" in
a group capture with its corresponding value as the value of the group
capture. Something like:

Cdg(C(V "key") * space * P "=" * space * C(V "value"));


Also, perhaps the group capture could also take an arbitrary non-nil
type for the group "name". I don't have a use-case in mind for
non-nil, non-string keys but I'm sure someone could think of one.
Since tables can have any type but nil as a key, it seems useful...

-- 
- Patrick Donnelly