parslet
parslet copied to clipboard
repeat(1, 1) doesn't transform into array
require "parslet"
class Parser < Parslet::Parser
rule(:a) do
str("a").repeat(1, 1)
end
root(:a)
end
p Parser.new.parse("a")
# => "a"@0
Expected:
["a"@0]
Works fine with as
, str("a").as(:a).repeat(1, 1)
=> [{:a=>"a"@0}]
My answer here would be the same as for #221.
The trick you discovered (naming a bit) is the workaround for pragmatic use ;)