When used in Backus-Naur Form, a variant on the Kleene Star is sometimes used to specify that an expression is to be instantiated one or more times.

So, for example, lets say we define int-decl for the programming language C:

  <int-decl> ::= int <identifier>;
| int <identifier>, <int-decl>
| <identifier>, <int-decl>

This is obviously a little messy as it would allow for code like the following:

  int c, d;, int r, int x;

It should be obvious how that is not correct C syntax.

However, the normal Kleene Star cannot be used either:

  <int-decl> ::= int {<identifier>,}*;

This would allow for the following incorrect syntax:

  int ;

And so thus the Kleene plus was introduced:

  <int-decl> ::= int <identifier>;
| int {<identifier>,}+ <identifier>;

flyingroc reminded me that the following would also be correct:

  <int-decl> ::= int {<identifier>,}* <identifier>;

And so thus, using C was probably not the best example to use.

Log in or registerto write something here or to contact authors.