Frage

I have the following 2 production rules in EBNF:

<CharLiteral> ::= ' " ' [ <Printable> ] ' " '

and

<StringLiteral> ::= ' " ' { <Printable> } ' " '

What is the difference between the two? [] imply 1 or more repetitions and {} imply 0 or more repetitions?

War es hilfreich?

Lösung

In EBNF, [X] means 0 or 1 X and {X} means 0 or more X.

In JavaCC, [X] means 0 or 1 X for grammar productions; in regular expression productions, you should use (X)? instead. To express 0 or more X in JavaCC use (X)*.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top