Advanced rules
Rule A1: Labels
The "label" allow assigning a name to a defined substring inside a CSN.1 definition.
In this way, it is possible to mark where the message information is and to distinguish it from the other support bits.
The format for a label is:
In the next example, our goal is to define a string that transports a 1-bit value or a 3-bit value; in order to distinguish the two cases, the protocol uses a control bit: 0 followed by the 1-bit value, or 1 followed by the 3-bits value.
< abcd > ::= 0 < short value: {0|1} > | 1 < long value: {0|1} {0|1} {0|1} >;
or
< abcd > ::= 0 < short value: bit > | 1 < long value: < bit > < bit > < bit > >; |
Please note that:
is the same of:
and not of:
< label : < foo > < bar > > |
Rule A2: Exponents
The exponents allow the repetition of a string for a fixed number of times.
The allowed forms are:
string ( expression )
or
string * expression
|
In the exponents, expression is a constant expression obtained with the usual mathematical operators.
Examples:
< octet > ::= {0|1} * 8;
< octet > ::= {0|1} (8);
< octet > ::= {0|1} (2*2+4);
< octet > ::= bit(8);
< octet > ::= < bit >*8;
are all equivalent to:
< octet > ::= {0|1}{0|1}{0|1}{0|1}{0|1}{0|1}{0|1}{0|1};
|
Infinite exponent
The infinite exponent uses the symbol * where the the fixed exponent uses its expression.
An infinite exponent means that the specified string can be repeated from 0 to infinite times.
< any string > ::= {0|1}**;
< any string > ::= {0|1} (*);
< any string > ::= bit(*);
< any string > ::= < bit >**;
are all equivalent to:
< octet > ::= null | < octet > {0|1};
|
Rule G1: Comments
Comments in CSN.1 are begun with a "--" and terminated with an end-of-line.
< foo bar > ::=
1 < xyz: bit(8) > -- This is the first entry
0 < abc: bit(8) > -- This is the second entry
;
|
|