Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dorianmariecom opened this issue Jul 25, 2022 · 2 comments
Open

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

dorianmariecom opened this issue Jul 25, 2022 · 2 comments

Comments

@dorianmariecom
Copy link

dorianmariecom commented Jul 25, 2022

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
Copy link
Author

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

@kschiess
Copy link
Owner

kschiess commented Dec 4, 2022

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants