EBNF - Allow full repetition management with repetition-symbol "*"

+2 votes
asked Oct 11, 2022 in Wanted features by The-Lu (60,440 points)
edited Oct 12, 2022 by The-Lu

Hello PlantUML team,

  • Could you allow full repetition management with repetition-symbol "*"?

Here is some examples (taken from the ISO EBNF standard):

Fortran_77_continuation_line = 5 * " ",  '[...]', 66 * [character];


test = 4 * '2';


title Example of §5.7 Syntactic-factor of ISO EBNF
aa = "A";
bb = 3 * aa, "B";
cc = 3 * [aa], "C";
dd = {aa}, "D";
ee = aa, {aa}, "E";
ff = 3 * aa, 3 * [aa], "F";
gg = 3 * {aa}, "D";

Proposal 1:

A proposal will be to use above, a curly bracket as:

Proposal 2:

[New Adding 2022-10-12]: Perhaps more better solution: adding 'n times' near a loop arrow...

test = 4 * '2';

Could be equivalent at the drawing of:

test = {'2'}-;

with a `4 times` near (above) the loop arrow. 

[Then another question: how to i18n the field... 'n times', 'n fois', ... like gantt with `language <xx>`] wink

But it is not so urgent!

related to an answer for: Could we add syntax diagrams?

2 Answers

+1 vote
answered Oct 13, 2022 by plantuml (293,520 points)
selected Dec 11, 2022 by The-Lu
Best answer

Something like this:

commented Oct 16, 2022 by The-Lu (60,440 points)

Hello PlantUML,
Good. yes

To avoid i18n, perhaps add the times sign (U+00D7 × MULTIPLICATION SIGN (&times;)) after the factor, as:

Then, for the second form, that asks question about times or ranges...
I'm thinking...
First: perhaps add a little more space between (''before, after') the backward loop.


commented Nov 8, 2022 by Todd Musheno (2,680 points)
Looks good for the base case, but what about "5 to 10 times", or "at least 10 times"?
0 votes
answered Oct 12, 2022 by Todd Musheno (2,680 points)
Great suggestion... could also be done as a box around the items to repete like component state in state diagrams.
commented Oct 12, 2022 by Todd Musheno (2,680 points)
Borrowing from regex, we might want to add some kind of support for min and max bounds (the above would be where min=max).

Not part of the spec, so it would be an extnsion of ebnf proper, but might be useful, and non standard extensions are common in the wild.