(*******************************************************************************
 * $Author: antanas $
 * $Date: 2017-05-09 15:19:45 +0300 (Tue, 09 May 2017) $
 * $Revision: 5233 $
 * $URL: svn+ssh://www.crystallography.net/home/coder/svn-repositories/cod-tools/tags/v3.1.0/doc/DDLm/type-contents-simplified.ebnf $
 *******************************************************************************
 * The following EBNF grammar describes the internal structure of the 
 * _type.compound_contents data items. The grammar was written with the
 * following conditions in mind:
 * 1) The enumerators appearing in the values are case-insensitive;
 * 2) There are three types of containers: List, Array and Matrix;
 * 3) There is no nesting limit for the List container;
 * 4) Only numerical data types are allowed in the Array and Matrix containers.
 *)

type-contents =
    ( type | non-nesting-container |
      ( nesting-container-type,
        container-open,
          type_contents,
        container-close )
    ),{
      ',', ( type | non-nesting-container |
      ( nesting-container-type,
        container-open,
          type_contents,
        container-close )
      )
    } ;

container-open  = ( '(' ) ;
container-close = ( ')' ) ;

(* The Array and Matrix containers are non nesting and store only numerical values *)
non-nesting-container = non-nesting-container-type,
                        container-open,
                            numerical_type, { ',', numerical_type},
                        container-close;

(* Rules describing all possible container types *)
nesting-container-type     = list-type;
non-nesting-container-type = array-type | matrix-type;
list-type   = ( 'L' | 'l' ), ( 'I' | 'i' ), ( 'S' | 's' ), ( 'T' | 't' );
array-type  = ( 'A' | 'a' ), ( 'R' | 'r' ), ( 'R' | 'r' ), ( 'A' | 'a' ), ( 'Y' | 'y' );
matrix-type = ( 'M' | 'm' ), ( 'A' | 'a' ), ( 'T' | 't' ), ( 'R' | 'r' ), ( 'I' | 'i' ), ( 'X' | 'x' );

(* Rules describing all possible content types *)
numerical-type = count | index | integer | real | imag | complex | binary |
                 hexadecimal | octal;
type = text | code | name | tag | filename | uri | date | version | dimension |
       range | count | index | integer | real | imag | complex | binary |
       hexadecimal | octal | implied | byreference ;
text = ( 'T' | 't' ), ( 'E' | 'e' ), ( 'X' | 'x' ), ( 'T' | 't' ) ;
code = ( 'C' | 'c' ), ( 'O' | 'o' ), ( 'D' | 'd' ), ( 'E' | 'e' ) ;
name = ( 'N' | 'n' ), ( 'A' | 'a' ), ( 'M' | 'm' ), ( 'E' | 'e' ) ;
tag  = ( 'T' | 't' ), ( 'A' | 'a' ), ( 'G' | 'g' ) ;
filename = ( 'F' | 'f' ), ( 'I' | 'i' ), ( 'L' | 'l' ), ( 'E' | 'e' ),
           ( 'N' | 'n' ), ( 'A' | 'a' ), ( 'M' | 'm' ), ( 'E' | 'e' ) ;
uri  = ( 'U' | 'u' ), ( 'R' | 'r' ), ( 'I' | 'i' ) ;
date = ( 'D' | 'd' ), ( 'A' | 'a' ), ( 'T' | 't' ), ( 'E' | 'e' ) ;
version = ( 'V' | 'v' ), ( 'E' | 'e' ), ( 'R' | 'r' ), ( 'S' | 's' ),
          ( 'I' | 'i' ), ( 'O' | 'o' ), ( 'N' | 'n' ) ;
dimension = ( 'D' | 'd' ), ( 'I' | 'i' ), ( 'M' | 'm' ), ( 'E' | 'e' ), ( 'N' | 'n' ),
            ( 'S' | 's' ), ( 'I' | 'i' ), ( 'O' | 'o' ),( 'N' | 'n' ) ;
range = ( 'R' | 'r' ), ( 'A' | 'a' ), ( 'N' | 'n' ), ( 'G' | 'g' ), ( 'E' | 'e' ) ;
count = ( 'C' | 'c' ), ( 'O' | 'o' ), ( 'U' | 'u' ), ( 'N' | 'n' ), ( 'T' | 't' ) ;
index = ( 'I' | 'i' ), ( 'N' | 'n' ), ( 'D' | 'd' ), ( 'E' | 'e' ), ( 'X' | 'x' ) ;
integer = ( 'I' | 'i' ), ( 'N' | 'n' ), ( 'T' | 't' ), ( 'E' | 'e' ), ( 'G' | 'g' ),
          ( 'E' | 'e' ), ( 'R' | 'r' ) ;
real = ( 'R' | 'r' ), ( 'E' | 'e' ), ( 'A' | 'a' ), ( 'L' | 'l' ) ;
imag = ( 'I' | 'i' ), ( 'M' | 'm' ), ( 'A' | 'a' ), ( 'G' | 'g' ) ;
complex = ( 'C' | 'c' ), ( 'O' | 'o' ), ( 'M' | 'm' ), ( 'P' | 'p' ), ( 'L' | 'l' ),
          ( 'E' | 'e' ), ( 'X' | 'x' ) ;
binary = ( 'B' | 'b' ), ( 'I' | 'i' ), ( 'N' | 'n' ), ( 'A' | 'a' ), ( 'R' | 'r' ),
         ( 'Y' | 'y' ) ;
hexadecimal = ( 'H' | 'h' ), ( 'E' | 'e' ), ( 'X' | 'x' ), ( 'A' | 'a' ),
              ( 'D' | 'd' ), ( 'E' | 'e' ), ( 'C' | 'c' ), ( 'I' | 'i' ),
              ( 'M' | 'm' ), ( 'A' | 'a' ), ( 'L' | 'l' ) ;
octal = ( 'O' | 'o' ), ( 'C' | 'c' ), ( 'T' | 't' ), ( 'A' | 'a' ), ( 'L' | 'l' ) ;
implied = ( 'I' | 'i' ), ( 'M' | 'm' ), ( 'P' | 'p' ), ( 'L' | 'l' ), ( 'I' | 'i'),
          ( 'E' | 'e' ), ( 'D' | 'd' ) ;
byreference = ( 'B' | 'b' ), ( 'Y' | 'y' ), ( 'R' | 'r' ), ( 'E' | 'e' ),
              ( 'F' | 'f' ), ( 'E' | 'e' ), ( 'R' | 'r' ), ( 'E' | 'e' ),
              ( 'N' | 'n' ), ( 'C' | 'c' ), ( 'E' | 'e' ) ;
