UNB/ CS/ David Bremner/ teaching/ old/ cs3613/ oz/ Oz Kernel Syntax

We will mainly be concerned with the "Declarative Kernel Language" syntax defined in


   <s> ::=
   skip                              % empty statement
   | <x> '=' <y>                       % variable-variable binding
   | <x> '=' <v>                       % variable-value binding
   | <s1>   <s2>                     % sequential composition
   | local <x> in <s> end            % declaration
   | if x then s1 else s2 end        % conditional
   |'{' <x>  <y1> ...    <yn> '}'        % procedure application
   | case  <x> of  <pattern> then <s1> 
   else s2 end                      % pattern matching


<v>                 ::= <procedure> | <record> | <number>
<procedure>         ::= proc '{'$ <y_1>   ...    <y_n> '}'  <s>   end
<record>, <pattern> ::= <literal> | <literal> '(' <feature_1> : <x_1> ... <feature_n>  : <x_n> ')'
<literal>           ::= <atom> | <bool>
<feature>           ::= <int>  | <atom> | <bool>
<bool>              ::= true | false
<number>            ::= <int>  | <float>

Basic Operations

In order to write actual programs in the kernel language, we need to use certain built in procedures of the language. Since the Oz module system uses records of procedures, we will allow the record selection operation

        X = R.F

in kernel code. Furthermore, we will allow e.g.

{Number.'+' 3 5 Z}

as shorthand for

local P=Number.'+' in
   {P 3 5 Z}

For information on what built-in procedures are available, see The Mozart Base System Documentation You may find the table of infix operations useful to find the procedure for the operation you want.

Here is a simplified version of the table of kernel operations, along with the translated procedure values

B = X == Y{Value.'==' X Y B}
B = X \= Y{Value.'\\=' X Y B}
B = AFI1 < AFI2{Value.'<' AFI1 AFI2 B}
B = AFI1 =< AFI2{Value.'=<' AFI1 AFI2 B}
B = AFI1 > AFI2{Value.'>' AFI1 AFI2 B}
B = AFI1 >= AFI2{Value.'>=' AFI1 AFI2 B}
FI3 = FI1 + FI2{Number.'+' FI1 FI2 FI3}
FI3 = FI1 - FI2{Number.'-' FI1 FI2 FI3}
FI3 = FI1 * FI2{Number.'*' FI1 FI2 FI3}
F3 = F1 / F2{Float.'/' F1 F2 F3}
I3 = I1 div I2{Int.'div' I1 I2 I3}
I3 = I1 mod I2{Int.'mod' I1 I2 I3}
FI1 = ~FI2{Number.'~' FI2 FI1}