Skip to content

Commit

Permalink
fix(inputters): Allow empty string as option value in SIL parser
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Jan 29, 2024
1 parent 2feba59 commit 160501c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions core/parserbits.lua
Expand Up @@ -61,15 +61,16 @@ local shrink = bits.ws * P"minus" * bits.ws * Cg(amount, "shrink")
bits.length = Ct(length * stretch^-1 * shrink^-1)
bits.utf8char = utf8char

local pairsep = S",;" * bits.ws
local pairsep = S",;"
local quote = P'"'
local escaped_quote = B(P"\\") * quote
local unescapeQuote = function (str) local a = str:gsub('\\"', '"'); return a end
local quotedString = quote * C((1 - quote + escaped_quote)^1 / unescapeQuote) * quote
local value = quotedString + (1-S",;]")^1
local quotedValueString = quote * C((1 - quote + escaped_quote)^0 / unescapeQuote) * quote
local valueString = (1-pairsep-quote-S"]")^0 / pl.stringx.strip
local value = quotedValueString + valueString + P""
local ID = C(bits.letter * (bits.letter + bits.digit)^0)
bits.silidentifier = (ID + S":-")^1
local pair = Cg(C(bits.silidentifier) * bits.ws * "=" * bits.ws * C(value)) * pairsep^-1 / unwrapper
local pair = Cg(bits.ws * C(bits.silidentifier) * bits.ws * "=" * bits.ws * C(value) * bits.ws) * pairsep^-1 / unwrapper
bits.parameters = Cf(Ct"" * pair^0, rawset)

local wrapper = function (a) return type(a)=="table" and a or {} end
Expand Down

0 comments on commit 160501c

Please sign in to comment.