Closed lilyball closed 1 month ago
Force-push was to fix an indentation issue in the new commits.
@bioball I've addressed your feedback, though I left the [\w&&\D]\w*
intact in the source as expanding that to [a-zA-Z_][a-zA-Z0-9_]*
negatively affected formatting of the regex comments.
This updates the
pkl.lua
package to have aParser
class that can parse a static subset of Lua. It's targeting the same subset of Lua thatRenderer
outputs (namely, a document consisting of key/value pairs consisting entirely of literals, with no expressions), though it recognizes all Lua syntax, including handling all forms of comments and literals thatRenderer
does not emit (such as hexadecimal floating point literals).The parser's interface is modeled after
pkl.json#Parser
, though it uses the propertyuseDynamic
instead ofuseMapping
as Lua syntax does not make a distinction between objects and arrays. Likepkl.json#Parser
, path converters are run as though all string keys are properties, even when configured to return aMapping
.In addition to adding the parser, this PR also updates
Renderer
to start applying converters to mapping entry keys, to matchPcfRenderer
's behavior. Any mapping entry key[^1] has class converters applied to it, and if the key is itself an object, nested values will be converted the same wayPcfRenderer
does (which is to say, any nested values have a path that starts at the object and omits the"^"
marker, so e.g. a key[new Dynamic { a = 1 }]
has a single nested value whose full path is"a"
).This also renames
LuaIdentifier
,LuaKeyword
, andLuaRenderDirective
to drop the leading "Lua", though it leaves deprecated typealiases behind for compatibility.This PR also bumps the project version to 1.1.0.
[^1]: Reminder that due to a language limitation, when rendering a
Dynamic
, any mapping entries with aString
key are indistinguishable from properties.