Closed seanchas116 closed 3 years ago
Hi @seanchas116!
I really like this PR :) The code is short and easy to read.
I like the name .repeat
better than .many
too!
(Parsimmon doesn't use .repeat
, by the way)
bnb.text("x").repeat(); // 0+ times
bnb.text("x").repeat(1); // 1+ times
bnb.text("x").repeat(1, 10); // 1-10 times
bnb.text("x").repeat(10, 10); // 10 times
bnb.text("x").sepBy(bnb.text(",")); // 0+ times
bnb.text("x").sepBy(bnb.text(","), 1); // 1+ times
bnb.text("x").sepBy(bnb.text(","), 1, 10); // 1-10 times
bnb.text("x").sepBy(bnb.text(","), 10, 10); // 10 times
You could use .repeat(n)
to mean .repeat(n, n)
, but I don't like .repeat(n, Infinity)
. I think the way you designed it is better.
I like the idea of removing many0
, many1
, sepBy0
, sepBy
also.
If you make those changes, I can update docs/api.md
and docs/tutorial.md
, then do a release. I can do it later this week :)
ありがとうございました🙇♀️
Thank you for replying! I made the changes and fixed the examples.
Parsimmon doesn't use .repeat, by the way
I mistook .repeat
for .times
😵 (but I still like the name .repeat
)
Hello, I'm using bread-n-butter for parsing CSS values, and I'd like to have min/max support for repeating parsers. (for example:
box-shadow
may contain length between 2 and 4 times)Thus I added new
many
andsepBy
methods that supportsmin
andmax
parameters.(I told by @minamorl about this library and I'm very confortable with it because it's simple and works well with TypeScript!)
I'm not sure this API design is good,
many0
/many1
/sepBy0
/sepBy1
might be removed ormany
could be renamed torepeat
, like in Parsimmon.