PEG.js question

I think my question does not belong fully here, because it's more about a grammer problem and not a JavaScript problem. If anyone knows a better subreddit for this kind of problem I would appreciate a hint. The problem:

I like to write a grammer which can detect the following strings

[...]

[[...]]

[[[...]]]

Balanced brackets, which can have anything inside them, just not the closing brackets. The following is eg. possible.

[[[ ... ]] ... ]]]

To just match something with [[ and ]], the grammer would look like

start = b
b = l c* r
c = !l !r .
l = "[["
r = "]]"

but I like a generic version and just came up with stupid ideas so far.

0 comments · 50% upvoted · other discussions

comments

No public comments to show.