25.07.2014 Views

VDM-10 Language Manual

VDM-10 Language Manual

VDM-10 Language Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 6. Expressions<br />

Examples: The define expression is used in a pragmatic way, in order to make the reader aware of<br />

the fact that the value of the expression depends upon the global variable.<br />

This can be illustrated by a small example:<br />

✞<br />

✡✝<br />

def user = lib(copy)<br />

in<br />

if user = <br />

then true<br />

else false<br />

where copy is defined in the context, lib is global variable (thus lib(copy) can be<br />

considered as looking up the contents of a part of the variable).<br />

The operation GroupRunnerUp expl in section 13.1 also gives an example of a define<br />

expression.<br />

✆<br />

6.3 Unary and Binary Expressions<br />

Syntax: expression = . . .<br />

| unary expression<br />

| binary expression<br />

| . . . ;<br />

unary expression = prefix expression<br />

| map inverse ;<br />

prefix expression = unary operator, expression ;<br />

unary operator = ‘+’ | ‘-’ | ‘abs’ | ‘floor’ | ‘not’ | ‘reverse’<br />

| ‘card’ | ‘power’ | ‘dunion’ | ‘dinter’<br />

| ‘hd’ | ‘tl’ | ‘len’ | ‘elems’ | ‘inds’ | ‘conc’<br />

| ‘dom’ | ‘rng’ | ‘merge’ ;<br />

map inverse = ‘inverse’, expression ;<br />

binary expression = expression, binary operator, expression ;<br />

binary operator = ‘+’ | ‘-’ | ‘*’ | ‘/’<br />

| ‘rem’ | ‘div’ | ‘mod’ | ‘**’<br />

| ‘union’ | ‘inter’ | ‘\’ | ‘subset’<br />

| ‘psubset’ | ‘in set’ | ‘not in set’<br />

| ‘ˆ’<br />

45

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

Saved successfully!

Ooh no, something went wrong!