On 5 Sep 2008, at 23:10, Fritz Anderson wrote:
I'm building up a grammar for the Confluence wiki markup, and I'm having trouble with tags that take a list of parameters.
Tags look like this (all strings are examples only):
{noparams} {oneparam:key=10} {twoparams:keyOne=value|keyTwo=2%} {threeparams:keyA=a value|keyB=another value|keyC=a third value} [...] Could someone enlighten me, please?
You can’t get proper scopes assigned to each item of a variable length list using just one match, so you need to change strategy and use begin/end rules, like in this example:
{ comment = 'match a tag with parameters'; begin = '{\w+:'; end = '}'; patterns = ( { comment = 'match one parameter in the list'; match = '\w+|[^|}]*'; } ); }
The above rule only handles tags with arguments, I would probably do a separate rule for tags without arguments to keep it simple.