sirthias/parboiled — Issue #35: Create Repeat() and Join() rules
Author: fge
Created: 2011-12-27 23:21:19+00:00
State: open

While exercising with parboiled, mainly to write a simple parser for CSS color expressions, I have found something quite painful to do: I had three or six hex digits to match, and I had three items to look for separated by commas.

So, I figured out that instead of having to write:

```java
// repeat 3 times
Sequence(r, r, r)
// join with a comma
Sequence(r, comma, r, comma, r)
```

I'd create some utilities to handle this:

https://gist.github.com/1525449

Now I just have to write:

```java
// repeat 3 times
Repeat(3, r)
// join 3 items by a comma
Join(3, r, comma)
```

The gist link above contains the result of my musings. It'd be nice to see this in parboiled!

Side note: the Digit() and HexDigit() rules are used so often that it would be nice to see them integrated as well