kschiess / parslet

A small PEG based parser library. See the Hacking page in the Wiki as well.
kschiess.github.com/parslet
MIT License
805 stars 95 forks source link

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

Open dorianmariecom opened 2 years ago

dorianmariecom commented 2 years ago
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 commented 2 years ago

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

kschiess commented 1 year ago

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

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