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).repeat(1, 1) doesn't nest arrays #221

Open
dorianmariecom opened this issue Jul 25, 2022 · 1 comment
Open

.repeat(1, 1).repeat(1, 1) doesn't nest arrays #221

dorianmariecom opened this issue Jul 25, 2022 · 1 comment

Comments

@dorianmariecom
Copy link

require "parslet"

class Parser < Parslet::Parser
  rule(:a) do
    str("a").as(:a).repeat(1, 1).repeat(1, 1)
  end
  root(:a)
end

p Parser.new.parse("a")

Actual:

[{:a=>"a"@0}]

Expected:

[[{:a=>"a"@0}]]
@kschiess
Copy link
Owner

kschiess commented Dec 4, 2022

While I agree that formally it should, I believe there is quite some code to ensure it does not; this simplifies output structures at the cost of formal correctness, a design choice made early on to cater to the pedagogical character this library has.

I might be open to accepting a PR that would change 'mode' into 'formal output' mode - but that's quite an undertaking; one would have to define formal output in the first place. Up for it?

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