Example: Lists

Comma Delimited

The following declaration defines a list of identifiers where commas are used to separate list items. The last item in the list will not be followed by a comma. This definition does not allow the list to be completely empty.

Identifier = {Letter}{Alphanumeric}*

<List> ::= <List> ',' <List Item>
        |  <List Item>

<List Item> ::= Identifier

Statement List

The following declaration defines a list of "Statements" where each <Statement> will be followed by a semicolon. Unlike the example above, the last item in the list will be followed by the symbol. However, since the <List> rule is nullable (the blank line), the list can be completely empty.

Identifier = {Letter}{Alphanumeric}*

<List> ::= <List> <Statement> ';'
        |

<Statement> ::= print '(' Identifier ')'
              | read '(' Identifier ')' 

Statement List (1 or more members)

This is a declaration identical to the example above, except the list must contain at least one item.

Identifier = {Letter}{Alphanumeric}*

<List> ::= <List> <Statement> ';'
         | <Statement> ';'

<Statement> ::= print '(' Identifier ')'
              | read '(' Identifier ')'