25.07.2014 Views

VDM-10 Language Manual

VDM-10 Language Manual

VDM-10 Language Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>VDM</strong>-<strong>10</strong> <strong>Language</strong> <strong>Manual</strong><br />

| ‘++’ | ‘munion’ | ‘’<br />

| ‘and’ | ‘or’<br />

| ‘=>’ | ‘’ | ‘=’ | ‘’<br />

| ‘=’<br />

| ‘comp’ ;<br />

Semantics: Unary and binary expressions are a combination of operands and operators denoting<br />

a value of a specific type. The signature of all these operators is already given in section 3,<br />

so no further explanation will be provided here. The map inverse unary operator is treated<br />

separately because it is written with postfix notation in the mathematical syntax.<br />

Examples: Examples using these operators were given in section 3, so none will be provided here.<br />

6.4 Conditional Expressions<br />

Syntax: expression = . . .<br />

| if expression<br />

| cases expression<br />

| . . . ;<br />

if expression = ‘if’, expression, ‘then’, expression,<br />

{ elseif expression }, ‘else’, expression ;<br />

elseif expression = ‘elseif’, expression, ‘then’, expression ;<br />

cases expression = ‘cases’, expression, ‘:’,<br />

cases expression alternatives,<br />

[ ‘,’, others expression ], ‘end’ ;<br />

cases expression alternatives =<br />

cases expression alternative,<br />

{ ‘,’, cases expression alternative } ;<br />

cases expression alternative = pattern list, ‘->’, expression ;<br />

others expression = ‘others’, ‘->’, expression ;<br />

Semantics: If expressions and cases expressions allow the choice of one from a number of expressions<br />

on the basis of the value of a particular expression.<br />

The if expression has the form:<br />

✞<br />

✡✝<br />

if e1<br />

then e2<br />

else e3<br />

46<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!