parslet icon indicating copy to clipboard operation
parslet copied to clipboard

repeat(1, 1) doesn't transform into array

Open dorianmariecom opened this issue 2 years ago • 2 comments

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]

dorianmariecom avatar Jul 25 '22 13:07 dorianmariecom

Works fine with as, str("a").as(:a).repeat(1, 1) => [{:a=>"a"@0}]

dorianmariecom avatar Jul 25 '22 13:07 dorianmariecom

My answer here would be the same as for #221.

The trick you discovered (naming a bit) is the workaround for pragmatic use ;)

kschiess avatar Dec 04 '22 09:12 kschiess