class - TUD.TTU.ee serveris olemas

advertisement
Project START
System MARS(a new generation 32-bit computer)
1985
1988
Kronos processor
2
microprocessor
standard
cards
OS
Excelsior
Labtam
Compilers
Different
platforms
AI software
included
ExpertPRIZ
NUT
Different
platforms
Kronos
Kronos
Kronos
CAD
software
Different
platforms
Kronos
(1990)
Programming environment NUT
The NUT is a knowledge-based programming environment which supports:
- development of large programs in the object-oriented style;
- automatic composition of programs from their specifications.
It is compatible with the C language, runs under Unix, uses X Windows
System. Its main components are the following:
•interactive user interface
•language processor
•knowledge management system
•graphic programming tools.
Knowledge management system handles packages which contain
classes, objects and graphics related to problem domains.
Using graphic programming tools, a user can develop its own
graphical language for specifying programs in a declarative way.
Interactive user interface
The NUT system is accessible through the X Windows System based
interactive graphic interface.
NUT user interface includes the following windows:
• NUT main window (peaaken)
• class windows, associated to classes
• object windows, associated to objects
• zoom window, associated to components of schemes;
They are a particular case of object windows
• Graphics Editor window
• Schema Editor window
• the Algorithm window
• the Diagnostic window
• the Debug window
• the Rules window
• message and dialog windowś
The menu bar of the NUT system includes the following
pull-down menus:
• File – for handling packages by creating, saving, restoring them
• Class – for handling classes, in particular, for opening a class window
for editing
• Object – for handling objects by viewing and editing them in an
object window
• Work/edit – working with texts in the workspace, executing programs
• Rules – working with production rules
• Options – setting an operation mode of the system
• Windows – opening windows for debugging and graphics.
NUT keel
• specification languagespetsifitseerimise keel
• procedural languageprotseduurne keel
It is the OO language that supports multiple
inheritance, flexible mechanism for sending
messages and automatic synthesis of programs.
1.Objects ja classes
An object is an entity that possesses an identity, a
class, and a value (state).
A class is a template for creation of objects with
similar properties.
1.1 Classes
Classes
Primitive classes
Predefined classes
User-defined classes
Universal class any
Polymorfic classes
array, struct, row
Instances of primitive classes and universal class
any can take value nil, representing undefinedness.
1.3 Primitive classes
num – is a class of numbers
bool - true and false (1 and 0) is a class of booleans
text – is a class of strings
prog – is a class of procedures
1.4 any
any is an universal class. The concrete class of an
object declared to have class any is initially open.
1.5 array of cl
is a class of values that are structures of objects having
class cl. The initial length for an object having class
array of cl is picked from the class name in the
declaration of the object, if indicated there. The length
is dynamic. Two-dimensional arrays are possible.
1.6 struct
This class is hidden. Group aliases are of that class,
structure expressions etc.
1.7 row
is a class of values that are structures of objects of
some fixed class (similat to array, used by syntheses
of iterations...).
1.8 User classes
<userclass-text>::= [<section>]…
<section>::=
<super-section>|<var-section>|<vir-section>|
<rel-section>|<alias-section>|<init-section>
1.8.1 super-sections
User class can inherit from one or more classes, called
superclasses of the class. Only user-defined classes
can act as superclasses.
<super-section>::=
super<super-description>…
<super-description>::=
<userclass-name>;
Example: super document;
super vehicle;
1.8.2 var-ja vir-sections
User declares the names and classes the proper and
virtual components.
<var-section>::=
var<var-declaration>…
<var-declaration>::=
<simplenames>:<class-name>;
|<simplename>:<prototype-in-component-declarat>;*
|<row-specifier>:<class-name>;
|<row-specifier>:<prototype-in-component-declarat>;
<row-specifier>::=
1..[<unsigned-integer>]
<vir-section>::=
vir<vir-declaration>…
<vir-declaration>::=
<simplenames>:<class-name>;
|<simplename>:<prototype-in-component-declarat>;
*
p.1.8.6
A component may be declared to be of an non-existent
class. This non-existent class is considered empty
(length 0, without relations and initializations).
Example:
var
vir
x,y:Point;
line:array 5 of Point;
n1,n2,n3:num;
1.8.3 rel-sections
The user defines the relations of the class he/she is
defining.
<rel-section>::=
rel <relation-definition>…
<relation-definition>::=
[<relation-name>:]<relation-definiens>;
<relation-name>::=<identifier>
Relations are procedures.
Procedure text contain a specification and may
contain a program.
The specification determines the input/output interface;
It states parameters of the procedure, defines certain
order of them, and tells their roles (input, output,
weak) , ...
Relations are used in two ways:
-as methods, by sending a message to the object
(relation calls...);
-in synthesis of values for objects and of programs
for procedures and their subtasks.
<relation-definiens>::=
<proceedure-text>see below
|<multi-way-equation>|<one-way-equation>|
<equivalence>
<multi-way-equation>::=
<expression-in-equation>=<expressen-in-equation>
All components of equation are num and weak.
Expression... see below.
The specification derivable by the class compiler from
a multi way equation e1=e2...
<one-way-equation>::=
<dotname>=<expressen-in-equation>
The specification derivable again by the class compiler
from a one-way equation c=e ...
<equivalence>::=
<dotname>=<dotname>
The specification derivable by the class compiler from
an equivalence c1=c2 is:
- - c1, c2
Siin peavad mõlemad liitnimed olema võrreldavatest
klassidest.
Examples:
rel
method1:x+y=0;
1*sin(alpha)=P1.y-P2.y;
method2:res=in1&in2;
how_long:new_text=length(´See on üks tekst´);
1.8.4 alias-sections
The user defines the aliases of the class he/she is
defining.
<alias-section>::=
alias <alias-definition>…
<alias-definition>::=
<simplename>=<alias-definiens>;
<alias-definiens>::=
<name-with-dot>|<group>
<name-with-dot>::=
<atomicname>.<simplename>
\row element-name as well
<group>::=(<pseudodotnames>)
<pseudodotnames>::=
<pseudodotname>[,<pseudodotname>]…
<pseudodotname>::=
<dotname>|all.<simplename>
A group alias has class “struct”.
all.x is a short form for c1.x,…,cn.x ,
where c1,…,cn is the list of all components of the
class being defined that possess a component named x.
Examples:
alias
Px=P.x;
all_states=(all.state);
states=(current_state,next_state);
1.8.5 init-section
The user tells the initializations of the class he/she
is defining.
<init-section>::=
init <initialization>…
Initializations are assignments that are performed,
when an instance of the class is created.
<initialization>::=
<dotname><assign-symbol><expression>;
<assign-symbol>::=
:= | <Examples:
init P.x:=0;
structure:=[1,2,3];
len<-length(´This is a text´)+3;
1.8.6 Component declaration prototypes
Prototypes are used in component declarations of user
class texts for giving components more properties than
they could acquire just from their classes alone
<prototype-in- component-declaration>::=
<userclass-name><amendments>
<amendments>::=
<amendment>[,<amendment>]…
There are two kinds of amendments:
- initialization amendments,
- equivalence amendments.
<initialization-amendment>::=
[<simplename><assign-symbol>]<expression>
\here = is allowed
<equivalence-amendment>::=
[<simplename>=]<dotname>
Amendments without left-hand parts are called
positional amendments, in contrast to „normal“
amendments, that are called amendments by name.
Examples:
tr1:triangle side1=10;
tr2:triangle side1:=10, 20, alpha:=30;
tr3:triangle side1:=tr1.side1,
side2:=tr2.side2+5;
Download