|
1 |
\documentclass[11pt]{scrartcl}
|
|
2 |
|
|
3 |
\usepackage{cancel}
|
|
4 |
\usepackage{listings}
|
|
5 |
\usepackage{xspace}
|
|
6 |
\usepackage{longtable}
|
|
7 |
\usepackage{graphicx}
|
|
8 |
\usepackage{url}
|
|
9 |
|
|
10 |
|
|
11 |
\newcommand{\doodblock}{{\bf do} {\bf od}-block \xspace}
|
|
12 |
\newcommand{\doodblocks}{{\bf do} {\bf od}-blocks \xspace}
|
|
13 |
|
|
14 |
|
|
15 |
\lstdefinelanguage{ooa} {
|
|
16 |
morekeywords={autocons, types, methods, do, obs, action, end, ctr, requires, od, true, and,
|
|
17 |
signal, after, false, actions, var, |[, ]|, [], public, of, len,
|
|
18 |
//, hd, tl, system},
|
|
19 |
sensitive=true,
|
|
20 |
morecomment=[s]{/*}{*/},
|
|
21 |
showspaces=false,
|
|
22 |
showstringspaces=false,
|
|
23 |
numbers=left,
|
|
24 |
numbersep=5pt,
|
|
25 |
numberstyle=\tiny,
|
|
26 |
tabsize=2,
|
|
27 |
escapeinside={@}{@},
|
|
28 |
framexleftmargin=9pt,
|
|
29 |
}
|
|
30 |
|
|
31 |
|
|
32 |
\begin{document}
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
\begin{titlepage}
|
|
40 |
\begin{center}
|
|
41 |
|
|
42 |
\vspace*{15mm}
|
|
43 |
|
|
44 |
{\Large TECHNICAL REPORT}
|
|
45 |
|
|
46 |
\vspace{10mm}
|
|
47 |
|
|
48 |
{\large IST-MBT-2012-01}
|
|
49 |
|
|
50 |
\vspace{15mm}
|
|
51 |
|
|
52 |
{\huge \bf The Argos Manual}
|
|
53 |
|
|
54 |
\vspace{5mm}
|
|
55 |
|
|
56 |
{\Large for Argos version: 0.39}
|
|
57 |
|
|
58 |
\vspace{15mm}
|
|
59 |
|
|
60 |
{\Large Stefan Tiran}
|
|
61 |
|
|
62 |
\vspace{5mm}
|
|
63 |
|
|
64 |
{\large stiran@ist.tugraz.at}
|
|
65 |
|
|
66 |
\vspace{15mm}
|
|
67 |
|
|
68 |
{\large March 2012} % 13.03.2012
|
|
69 |
|
|
70 |
\vspace{10mm}
|
|
71 |
|
|
72 |
{\large
|
|
73 |
Institute for Software Technology (IST)\\
|
|
74 |
Graz University of Technology\\
|
|
75 |
A-8010 Graz, Austria\\}
|
|
76 |
|
|
77 |
\end{center}
|
|
78 |
\end{titlepage}
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
%\title{The Argos Manual}
|
|
85 |
|
|
86 |
%\author{Stefan Tiran}
|
|
87 |
|
|
88 |
%\subtitle{for Argos version: 0.39}
|
|
89 |
|
|
90 |
%\maketitle
|
|
91 |
\newpage
|
|
92 |
\tableofcontents
|
|
93 |
\listoffigures
|
|
94 |
|
|
95 |
|
|
96 |
\section{Introduction}
|
|
97 |
|
|
98 |
Argos is a compiler for Object-Oriented Action Systems (OOAS). It has been developed
|
|
99 |
by Willibald Krenn from Graz University of Technology within the MOGENTES project.
|
|
100 |
|
|
101 |
Its main target is producing Action Systems in the proprietary format that \emph{Ulysses}
|
|
102 |
can process. \emph{Ulysses} is an ioco-checker written by Harald Brandl also within the
|
|
103 |
MOGENTES project.
|
|
104 |
|
|
105 |
\section{How To Run Argos}
|
|
106 |
|
|
107 |
Argos is a .NET based command line program. To run it you need either
|
|
108 |
the .NET Framework or mono (\url{http://www.mono-project.com}).
|
|
109 |
|
|
110 |
\subsection{Program Invocation}
|
|
111 |
|
|
112 |
Since Argos is a command line tool you need to open a command line prompt
|
|
113 |
(using Windows) resp. a shell (using a UNIX-like system).
|
|
114 |
|
|
115 |
When using Windows change to the Argos directory and simply run argos.exe:
|
|
116 |
|
|
117 |
\texttt{
|
|
118 |
c:\textbackslash Argos \textbackslash > argos}
|
|
119 |
|
|
120 |
When using a UNIX-like system run mono with argos.exe as parameter:
|
|
121 |
|
|
122 |
\texttt{
|
|
123 |
\$ mono argos.exe}
|
|
124 |
|
|
125 |
In both cases one should now see this welcome screen:
|
|
126 |
|
|
127 |
\begin{verbatim}
|
|
128 |
>> Mogentes OO-Action System Parser <<
|
|
129 |
|
|
130 |
Version: 0.39 (16471)
|
|
131 |
Grammar-Version: 0.06
|
|
132 |
|
|
133 |
Usage: argos [options] <oo-actionsystem-file>
|
|
134 |
Options:
|
|
135 |
-o<name> ... write output to file <name> (overwrites!)
|
|
136 |
-n<name> ... use namespace <name> (default: as)
|
|
137 |
-d<depth> ... set max. search depth (default: 35)
|
|
138 |
-q ... "quiet" mode: doesn't print Warnings to console
|
|
139 |
|
|
140 |
-a ... create pseudo-action system code
|
|
141 |
-p ... create prolog code
|
|
142 |
-c ... create CADP implicit LTS
|
|
143 |
|
|
144 |
\end{verbatim}
|
|
145 |
|
|
146 |
\subsection{Options and Arguments}
|
|
147 |
|
|
148 |
As can be seen in the welcome screen for translating Action Systems the
|
|
149 |
last parameter has to be the OOAS-File you want to convert, every other
|
|
150 |
options has to come before.
|
|
151 |
|
|
152 |
If no other option is given, Argos will translate the given OOAS-File to
|
|
153 |
C\#-Pseudo-Code and print it out on the screen. Since this most probably
|
|
154 |
won't be something you will find extremely useful, you should at least
|
|
155 |
specify an output-file and the desired language.
|
|
156 |
|
|
157 |
For specifying the output-file use option \texttt{-o} followed by the
|
|
158 |
file name resp. the relative path of the file you want to create. There
|
|
159 |
should be NO space between \texttt{-o} and the file name!
|
|
160 |
|
|
161 |
For specifying the language include option \texttt{-c} for creating
|
|
162 |
C-Code for the CADP-Toolbox resp. option \texttt{-p} for creating
|
|
163 |
Prolog-Code for use with the Ulysses tool.
|
|
164 |
|
|
165 |
When creating Prolog-Code the following options are important:
|
|
166 |
\begin{itemize}
|
|
167 |
\item[-n] With this option one can specify the namespace within the Prolog-File;
|
|
168 |
the only meaningful use of this option is \texttt{-nasm} for letting
|
|
169 |
the Ulysses tool know, that this file represents the mutant rather
|
|
170 |
then the original file.
|
|
171 |
\item[-d] With this option one can specify the max. depth, to which the Ulysses
|
|
172 |
tool will search for differences. Please note that this option has
|
|
173 |
to be followed by a number WITHOUT a space before! The default value
|
|
174 |
is 35, so leaving out this option is equivalent to writing
|
|
175 |
\texttt{-d35}.
|
|
176 |
|
|
177 |
\subsection{Examples}
|
|
178 |
|
|
179 |
To illustrate the use of the options, we hereby provide the following examples:
|
|
180 |
|
|
181 |
\begin{itemize}
|
|
182 |
\item Translate an original OOAS specification \texttt{original.ooas} to a Prolog
|
|
183 |
file \texttt{original.pl} for the Ulysses tool with max. search depth
|
|
184 |
42:
|
|
185 |
\begin{verbatim} argos.exe -p -d42 -ooriginal.pl original.ooas \end{verbatim}
|
|
186 |
\item Translate a mutated OOAS specification \texttt{mutant.ooas} to a Prolog
|
|
187 |
file \texttt{mutant.pl} for the Ulysses tool with max. search depth
|
|
188 |
42:
|
|
189 |
\begin{verbatim} argos.exe -p -d42 -nasm -omutant.pl mutant.ooas \end{verbatim}
|
|
190 |
\item Translate OOAS specification \texttt{original.ooas} to a C file
|
|
191 |
\texttt{original.c} for the use with the CADP toolbox:
|
|
192 |
\begin{verbatim} argos.exe -c -ooriginal.c original.ooas \end{verbatim}
|
|
193 |
|
|
194 |
|
|
195 |
\end{itemize}
|
|
196 |
|
|
197 |
\end{itemize}
|
|
198 |
|
|
199 |
\section{OOAS Language}
|
|
200 |
|
|
201 |
The Argos tool will only work if the given file is well formed according
|
|
202 |
to the language that is described in this section. The language is based
|
|
203 |
on the language proposed in \cite{Bonsangue1998} but only a subset of features
|
|
204 |
is actually implemented.
|
|
205 |
|
|
206 |
\subsection{Base structure}
|
|
207 |
|
|
208 |
To illustrate the base structure of an OOAS file let us consider the simple
|
|
209 |
Hello World program in Figure \ref{HelloWorld}.
|
|
210 |
|
|
211 |
\begin{figure}[h]
|
|
212 |
\begin{lstlisting}[language=ooa,linewidth=\textwidth,breaklines,basicstyle=\scriptsize]
|
|
213 |
types
|
|
214 |
Greeter = autocons system
|
|
215 |
|[
|
|
216 |
var
|
|
217 |
done : bool = false
|
|
218 |
actions
|
|
219 |
obs HelloWorld = requires done = false :
|
|
220 |
done := true
|
|
221 |
end
|
|
222 |
do
|
|
223 |
HelloWorld
|
|
224 |
od
|
|
225 |
]|
|
|
226 |
system
|
|
227 |
Greeter
|
|
228 |
|
|
229 |
\end{lstlisting}
|
|
230 |
\caption{HelloWorld}
|
|
231 |
\label{HelloWorld}
|
|
232 |
\end{figure}
|
|
233 |
|
|
234 |
Every OOAS consists of two different regions: The type definition block and
|
|
235 |
the system assembling block. In the HelloWorld system the type definition block
|
|
236 |
consists of Lines 1 - 13 and the system assembling consists of Lines 14 and 15.
|
|
237 |
|
|
238 |
Let us now discuss the system Line by Line:
|
|
239 |
Line 1 just consists of the keyword \texttt{types} stating that here begins
|
|
240 |
the type definition block.
|
|
241 |
In Line 2 a class called \texttt{Greeter} is defined. The keyword
|
|
242 |
\texttt{autocons} states that one instance of the class will automatically
|
|
243 |
be created at system start. This instance is called the ``root object''.
|
|
244 |
The symbols in Line 3 and 13 state the begin and the end of the class
|
|
245 |
definition.
|
|
246 |
In Lines 4 and 5 there is a variable definition
|
|
247 |
block. Even though this block is not formally necessary for Argos to compile
|
|
248 |
a file, Argos will not create a valid prolog file if this block is missing.
|
|
249 |
In Lines 6 - 9 there is the action block consisting of the action
|
|
250 |
\texttt{HelloWorld}. The keyword \texttt{obs} states that this action is
|
|
251 |
\emph{observable} rather then \emph{controllable} (keyword: \texttt{ctr}) or
|
|
252 |
internal (no keyword).
|
|
253 |
The keyword \texttt{requires} states the beginning of the guard, which enables
|
|
254 |
the action.
|
|
255 |
The body of this action consists of Lines 8 and 9. Line 8 contains an
|
|
256 |
assignment, the keyword \texttt{end} in Line 9 marks the end of the action.
|
|
257 |
Lines 10 - 12 contains the so-called \doodblock. The \doodblock is
|
|
258 |
described in Section \ref{dood}.
|
|
259 |
|
|
260 |
As already mentioned, Lines 14 + 15 contain the system assembling block. In this
|
|
261 |
block the system is composed of its classes. Since this example system only
|
|
262 |
contains of one class, the block is quite simple and needs no further
|
|
263 |
explanation.
|
|
264 |
|
|
265 |
\subsection{The Type Definition Block}
|
|
266 |
|
|
267 |
The type definition block has two purposes: As we have already seen it can be
|
|
268 |
used for defining the classes of which the system consists of. However it
|
|
269 |
can also be used for creating named types which is similar to the use of
|
|
270 |
\texttt{type-def} in C.
|
|
271 |
|
|
272 |
The latter use is quite important as OOAS has a very strict typing system.
|
|
273 |
For example if you want to define a variable as integer, you also have to
|
|
274 |
define the range of the values. This is due to the fact that too wide ranges
|
|
275 |
can lead to enormous efficiency problems when simulating the model.
|
|
276 |
|
|
277 |
\subsubsection{Defining Integer Types}
|
|
278 |
|
|
279 |
Integer types can be defined by the lower and upper range.
|
|
280 |
|
|
281 |
Consider you want to define a type \texttt{MyInt} that can contain values
|
|
282 |
between 0 and 31, then you can write
|
|
283 |
\begin{verbatim}
|
|
284 |
MyInt = int [0..31];
|
|
285 |
\end{verbatim}
|
|
286 |
|
|
287 |
Please note that the semicolon has to be placed if and only if this is not
|
|
288 |
the last definition.
|
|
289 |
|
|
290 |
\subsubsection{Defining Enum Types}
|
|
291 |
|
|
292 |
Enums can be defined by enumerating the possible values and optionally assigning them
|
|
293 |
integer values. If integer values are explicitly assigned, enum types can be casted to
|
|
294 |
integer types.
|
|
295 |
|
|
296 |
Consider you want to define an enum type \texttt{Color} that can contain the
|
|
297 |
values \texttt{red}, \texttt{green}, \texttt{blue}, \texttt{yellow} and \texttt{black},
|
|
298 |
then you can write:
|
|
299 |
\begin{verbatim}
|
|
300 |
Color = {red, green, blue, yellow, black};
|
|
301 |
\end{verbatim}
|
|
302 |
|
|
303 |
The possibility to explicitly assign integer values is especially useful when
|
|
304 |
dealing with equivalent classes of integers. Consider you need an integer type
|
|
305 |
that can only contain small number of different values but these values define
|
|
306 |
a range with "holes" rather then a complete one.
|
|
307 |
|
|
308 |
So in case you need a type that can hold the values 1, 42 and 1337 you can write
|
|
309 |
\begin{verbatim}
|
|
310 |
CoolValueSet = {CoolValue1 = 1, CoolValue2 = 42, CoolValue3 = 1337};
|
|
311 |
\end{verbatim}
|
|
312 |
|
|
313 |
\subsubsection{Defining Complex Types (Lists, Tuples)}
|
|
314 |
|
|
315 |
Additional to the former so-called simple types the OOAS language also
|
|
316 |
supports so-called complex types. These are: lists and tuples.
|
|
317 |
|
|
318 |
A list is defined by the number and the type of its elements.
|
|
319 |
|
|
320 |
An example for the former variant would be:
|
|
321 |
\begin{verbatim}
|
|
322 |
MyList = list [42] of char;
|
|
323 |
\end{verbatim}
|
|
324 |
|
|
325 |
A tuple is defined by the types of its elements. Unlike a list the types can
|
|
326 |
differ among the different elements.
|
|
327 |
|
|
328 |
An example would be:
|
|
329 |
\begin{verbatim}
|
|
330 |
MyTuple = (MyInt, SmallInt);
|
|
331 |
\end{verbatim}
|
|
332 |
|
|
333 |
Even though maps and qualitative reasoning types would be specified by the
|
|
334 |
OOAS language, Argos does not support them yet.
|
|
335 |
|
|
336 |
\subsubsection{Defining Classes}
|
|
337 |
|
|
338 |
In the OOAS language the definition of a class (ooActionSystem) does not differ
|
|
339 |
from the definition of any other type.
|
|
340 |
|
|
341 |
\subsection{Structure of Classes}
|
|
342 |
|
|
343 |
\subsubsection{Inheritance}
|
|
344 |
|
|
345 |
As common in Object-Oriented languages, classes can be derived from other classes
|
|
346 |
and inherit their behavior.
|
|
347 |
A sample class \texttt{Desc} inheriting from a class \texttt{base} could look like this:
|
|
348 |
|
|
349 |
\begin{verbatim}
|
|
350 |
Desc = system (base)
|
|
351 |
|[
|
|
352 |
]|
|
|
353 |
|
|
354 |
\end{verbatim}
|
|
355 |
|
|
356 |
\subsubsection{Defining Variables (Attributes)}
|
|
357 |
\label{Variables}
|
|
358 |
|
|
359 |
Variables store the information of the state of an object. An alternative name
|
|
360 |
of variables often used in error messages is ``attributes''. Variables can be
|
|
361 |
static and have to be initialized with a valid value. For objects there is a
|
|
362 |
predefined object \texttt{nil}. There is also a self-reference called
|
|
363 |
\texttt{self}.
|
|
364 |
|
|
365 |
The definition of a variable can look like this:
|
|
366 |
\begin{verbatim}
|
|
367 |
done : bool = false;
|
|
368 |
\end{verbatim}
|
|
369 |
|
|
370 |
Please note that the semicolon has to be placed if and only if this is not
|
|
371 |
the last definition.
|
|
372 |
|
|
373 |
\subsubsection{Creating Objects}
|
|
374 |
|
|
375 |
The only place where an object can be created is in the variable definition block.
|
|
376 |
Line 5 in Figure \ref{object} demonstrates how a variable with the name
|
|
377 |
\texttt{myOtherClassObject} can be initialized with an object with the name
|
|
378 |
\texttt{OtherClassObject} of a class \texttt{OtherClass}.
|
|
379 |
|
|
380 |
For details on the System Assembling Block (Lines 23 and 24) see Section
|
|
381 |
\ref{SAB}.
|
|
382 |
|
|
383 |
\begin{figure}[h]
|
|
384 |
\begin{lstlisting}[language=ooa,linewidth=\textwidth,breaklines,basicstyle=\scriptsize]
|
|
385 |
types
|
|
386 |
RootClass = autocons system
|
|
387 |
|[
|
|
388 |
var
|
|
389 |
myOtherClassObject : OtherClass = new(OtherClass,"OtherClassObject") ;
|
|
390 |
initialized : bool = false
|
|
391 |
actions
|
|
392 |
obs init = requires initialized = false : initialized := true end
|
|
393 |
do
|
|
394 |
init ()
|
|
395 |
od
|
|
396 |
]| ;
|
|
397 |
OtherClass = system
|
|
398 |
|[
|
|
399 |
var
|
|
400 |
initialized : bool = false
|
|
401 |
actions
|
|
402 |
obs init = requires initialized = false : initialized := true end
|
|
403 |
do
|
|
404 |
init ()
|
|
405 |
od
|
|
406 |
]|
|
|
407 |
system
|
|
408 |
RootClass [] OtherClass
|
|
409 |
\end{lstlisting}
|
|
410 |
\caption{Creating an object}
|
|
411 |
\label{object}
|
|
412 |
\end{figure}
|
|
413 |
|
|
414 |
\subsubsection{Defining Methods}
|
|
415 |
|
|
416 |
Methods can be used for defining subroutines. Methods can have parameters,
|
|
417 |
variables and a return value. Methods can be called from actions and
|
|
418 |
from other methods, but not recursively - neither directly nor indirectly.
|
|
419 |
|
|
420 |
The body of a method isn't any different from the body of an action
|
|
421 |
and therefore described in Section \ref{Actions}.
|
|
422 |
|
|
423 |
A sample method, that returns the bigger of two values could look like this:
|
|
424 |
|
|
425 |
\begin{verbatim}
|
|
426 |
maxValue(a : MyInt, b : MyInt) : MyInt =
|
|
427 |
result := if (a > b) then a else b end
|
|
428 |
end;
|
|
429 |
\end{verbatim}
|
|
430 |
|
|
431 |
Returning a value is done by assigning it to the variable result.
|
|
432 |
For a list of possible expressions we refer to Section \ref{Expressions}.
|
|
433 |
|
|
434 |
One important aspect of methods is their pureness. A method is pure
|
|
435 |
iff there is no assignment to a variable other than \texttt{result}.
|
|
436 |
This property is checked on compile
|
|
437 |
time. Only if a method is pure it can be used in a guard or in a list
|
|
438 |
comprehension.
|
|
439 |
|
|
440 |
\subsubsection{Defining Actions}
|
|
441 |
\label{Actions}
|
|
442 |
|
|
443 |
Named actions consist of an optional parameter list, a variable definition
|
|
444 |
block and a body but they lack a return value. Named actions can only be
|
|
445 |
called in the so-called \doodblock.
|
|
446 |
|
|
447 |
A named action can be controllable (keyword \texttt{ctr}),
|
|
448 |
observable (keyword \texttt{obs}) or internal (no keyword).
|
|
449 |
|
|
450 |
The definition of local variables does not differ from any
|
|
451 |
other variable definition so we refer to Section \ref{Variables}.
|
|
452 |
|
|
453 |
The body of a named action can consist of one or more basic actions.
|
|
454 |
Every action has a guard which ``enables'' it. The general form of a guard
|
|
455 |
is \texttt{requires p : $S_1$ end} where p is the condition
|
|
456 |
and $S_1$ is the action. The condition can be any expression that doesn't
|
|
457 |
involve the calling of a non-pure method or a non-pure assignment.
|
|
458 |
|
|
459 |
For further details about expressions see Section \ref{Expressions}!
|
|
460 |
|
|
461 |
Basic actions can be the built-in action \texttt{skip},
|
|
462 |
single or multiple assignment or a sequential composition of two other actions.
|
|
463 |
For details on the composition we refer to Section \ref{Composition}.
|
|
464 |
|
|
465 |
The built-in action \texttt{skip} doesn't do anything at all.
|
|
466 |
Sometimes this is called \emph{identity assignment}.
|
|
467 |
|
|
468 |
Single assignment has the simple form \texttt{v := e} where
|
|
469 |
v is a variable and e is an expression.
|
|
470 |
|
|
471 |
However you can also assign multiple expressions to multiple
|
|
472 |
variables by separating them with commas.
|
|
473 |
|
|
474 |
So if \texttt{done} and \texttt{multi} are both variables of
|
|
475 |
type \texttt{bool}, then you can write:
|
|
476 |
|
|
477 |
\begin{verbatim}
|
|
478 |
done, multi := true, true
|
|
479 |
\end{verbatim}
|
|
480 |
|
|
481 |
\subsection{Composition}
|
|
482 |
\label{Composition}
|
|
483 |
\subsubsection{Sequential Composition}
|
|
484 |
|
|
485 |
The easiest way of composing two actions is the sequential
|
|
486 |
composition. It has the general form \texttt{A ; B} where
|
|
487 |
A and B are both actions and has the meaning that iff
|
|
488 |
A and B are \emph{enabled}, first action A is executed and then
|
|
489 |
action B is executed. Note that it is not necessary for B
|
|
490 |
to be enabled before A. It is also possible that B becomes
|
|
491 |
enabled because of A.
|
|
492 |
|
|
493 |
Please note that despite of the
|
|
494 |
apparent resemblance with the semicolon as marker of the
|
|
495 |
end of a line in many imperative programming languages
|
|
496 |
there are two very important differences:
|
|
497 |
|
|
498 |
The first difference is that since it is a composition operator,
|
|
499 |
there must not be a semicolon after the last action. This
|
|
500 |
difference seems to be more on a syntactical level, but should
|
|
501 |
also warn about the other very important difference:
|
|
502 |
|
|
503 |
The second difference is that since actions have guards, no
|
|
504 |
action of a sequence block is executed, if a single action is
|
|
505 |
not enabled. This also means that an action can hinder actions
|
|
506 |
to be executed, which were called \emph{before}!
|
|
507 |
|
|
508 |
\subsubsection{Non-deterministic Choice}
|
|
509 |
|
|
510 |
The counterpart of the ``sequential composition'' is the so
|
|
511 |
called ``non-deterministic choice''.
|
|
512 |
|
|
513 |
The general form of a non-deterministic choice is \texttt{ A [] B }
|
|
514 |
where A and B are both actions and the meaning is that either
|
|
515 |
A or B is executed. However an action can only be chosen if it
|
|
516 |
is enabled. According to the theory of action systems an action has to be
|
|
517 |
chosen if it is aborting. However there is no abort feature implemented yet.
|
|
518 |
|
|
519 |
\subsubsection{Prioritizing Composition}
|
|
520 |
|
|
521 |
The ``prioritizing composition'' is rather an abbreviation
|
|
522 |
than an actual new type of composition.
|
|
523 |
|
|
524 |
The general form is \texttt{ A // B } and it means that if A
|
|
525 |
is enabled, it is chosen and otherwise B is chosen.
|
|
526 |
|
|
527 |
\subsection{Expressions}
|
|
528 |
\label{Expressions}
|
|
529 |
|
|
530 |
Expressions can be evaluated and their values can be assigned to variables.
|
|
531 |
|
|
532 |
\subsubsection{Conditional Assignment}
|
|
533 |
|
|
534 |
Conditional Assignments are expressions. They can not be used for branching
|
|
535 |
the control sequence. Branching the control sequence has to be done by using
|
|
536 |
guards and non-deterministic choice.
|
|
537 |
|
|
538 |
A conditional assignment can look like this:
|
|
539 |
\begin{verbatim}
|
|
540 |
c := if (a > b) then a else b end
|
|
541 |
\end{verbatim}
|
|
542 |
|
|
543 |
\subsubsection{Fold}
|
|
544 |
|
|
545 |
For the purpose of iterating through a list in OOAS \emph{fold} is used.
|
|
546 |
\emph{Fold} is a higher-order function well known from the functional
|
|
547 |
programming paradigm.
|
|
548 |
|
|
549 |
In the OOAS language both \emph{right fold} and \emph{left fold} are
|
|
550 |
defined. The symbol for the former is \texttt{:>:} whereas the symbol
|
|
551 |
for the latter is \texttt{:<:}. However in Argos only \emph{right fold} is
|
|
552 |
implemented.
|
|
553 |
|
|
554 |
The general form of a fold expression is \texttt{method :: (init\_expression) :>: (list\_\\expression)}
|
|
555 |
where \texttt{method} is the name of the method, \texttt{init\_expression} is the value for the last
|
|
556 |
parameter of the method for the first call. For any other call the result of the former call is used instead.
|
|
557 |
Finally \texttt{list\_expression} is the expression that evaluates to the list to be iterated.
|
|
558 |
|
|
559 |
|
|
560 |
Figure \ref{Sum} shows how to define a method \texttt{Sum}
|
|
561 |
using a method \texttt{Add} and the \emph{fold} operator.
|
|
562 |
|
|
563 |
\begin{figure}[h]
|
|
564 |
\begin{lstlisting}[language=ooa,linewidth=\textwidth,breaklines,basicstyle=\scriptsize]
|
|
565 |
types
|
|
566 |
MyInt = int [0..42];
|
|
567 |
SmallInt = int [0..3];
|
|
568 |
MyTuple = (MyInt, SmallInt);
|
|
569 |
Sum = autocons system
|
|
570 |
|[
|
|
571 |
var
|
|
572 |
my_list : list [4] of SmallInt = [5,5,5,5]
|
|
573 |
methods
|
|
574 |
add(a: MyInt, b: SmallInt) : MyInt =
|
|
575 |
requires true :
|
|
576 |
result := a + b
|
|
577 |
end
|
|
578 |
end ;
|
|
579 |
sum(Xs : list [4] of SmallInt) : MyInt =
|
|
580 |
requires true :
|
|
581 |
result := add :: (0) :>: (Xs)
|
|
582 |
end
|
|
583 |
end
|
|
584 |
actions
|
|
585 |
obs Sum(a: MyInt) =
|
|
586 |
requires a = sum(my_list) :
|
|
587 |
skip
|
|
588 |
end
|
|
589 |
do
|
|
590 |
var A : MyInt : Sum(A)
|
|
591 |
od
|
|
592 |
]|
|
|
593 |
system
|
|
594 |
Sum
|
|
595 |
\end{lstlisting}
|
|
596 |
\caption{Defining sum of all list elements using the fold meta function}
|
|
597 |
\label{Sum}
|
|
598 |
\end{figure}
|
|
599 |
|
|
600 |
\subsubsection{Quantifier Expressions}
|
|
601 |
|
|
602 |
The OOAS language allows to use the quantifiers \texttt{forall} and
|
|
603 |
\texttt{exists}. The resulting expressions will evaluate to Boolean
|
|
604 |
values. The general form is \texttt{(quantifier : Type : (logical sentence))}.
|
|
605 |
|
|
606 |
For example an existential quantification can look like this:
|
|
607 |
\texttt{(exists i : LengthInt : (primes[i] = a))}.
|
|
608 |
|
|
609 |
|
|
610 |
\subsubsection{List Comprehension}
|
|
611 |
|
|
612 |
The OOAS language allows to construct new list expressions based on existing lists
|
|
613 |
by using the set-builder notation. These expressions can be assigned to list
|
|
614 |
variables at any time after the initialization, but not in the declaration.
|
|
615 |
|
|
616 |
The general form of a list comprehension is:
|
|
617 |
|
|
618 |
\texttt{list := [x | var x : Type \& (condition)]}, where \texttt{Type} is the type
|
|
619 |
of the list elements and \texttt{condition} is a logical sentence which determines
|
|
620 |
whether a value should be inserted to the list.
|
|
621 |
|
|
622 |
The example in Figure \ref{Prime} illustrates both \emph{Quantifier Expressions}
|
|
623 |
and \emph{List Comprehension} by computing prime numbers.
|
|
624 |
|
|
625 |
\begin{figure}[h]
|
|
626 |
\begin{lstlisting}[language=ooa,linewidth=\textwidth,breaklines,basicstyle=\scriptsize]
|
|
627 |
types
|
|
628 |
MyInt = int [2..100];
|
|
629 |
LengthInt = int [0..40];
|
|
630 |
Primes = autocons system
|
|
631 |
|[
|
|
632 |
var
|
|
633 |
initialized : bool = false ;
|
|
634 |
primes : list [ 40 ] of MyInt = [3]
|
|
635 |
actions
|
|
636 |
obs init = requires initialized = false :
|
|
637 |
primes := [ x | var x: MyInt & (forall tmp : MyInt :
|
|
638 |
(tmp < x => (x mod tmp <> 0 ))) ] ;
|
|
639 |
initialized := true end;
|
|
640 |
|
|
641 |
obs Prime(a: MyInt) =
|
|
642 |
requires (exists i : LengthInt : (primes[i] = a)) :
|
|
643 |
skip
|
|
644 |
end
|
|
645 |
|
|
646 |
do
|
|
647 |
init() // var A : MyInt : Prime(A)
|
|
648 |
od
|
|
649 |
]|
|
|
650 |
system
|
|
651 |
Primes
|
|
652 |
\end{lstlisting}
|
|
653 |
\caption{Prime number calculation}
|
|
654 |
\label{Prime}
|
|
655 |
\end{figure}
|
|
656 |
|
|
657 |
\subsubsection{Tuple Expressions}
|
|
658 |
|
|
659 |
The general form of an expression that evaluates to a tuple is:
|
|
660 |
\begin{verbatim}
|
|
661 |
TupleType(v_1,...,v_n)
|
|
662 |
\end{verbatim}
|
|
663 |
where TupleType is the type of the tuple and v\_1,...,v\_n are the values.
|
|
664 |
|
|
665 |
An example for using Tuples can be found in Figure \ref{Tuple}
|
|
666 |
\begin{figure}[h]
|
|
667 |
\begin{lstlisting}[language=ooa,linewidth=\textwidth,breaklines,basicstyle=\scriptsize]
|
|
668 |
types
|
|
669 |
MyInt = int [0..42] ;
|
|
670 |
MyTuple = (MyInt, MyInt) ;
|
|
671 |
TupleDemo = autocons system
|
|
672 |
|[
|
|
673 |
var
|
|
674 |
theTuple : MyTuple = MyTuple(1,1)
|
|
675 |
actions
|
|
676 |
ctr change1 = requires theTuple = MyTuple(1,1) :
|
|
677 |
theTuple := MyTuple(1,2)
|
|
678 |
end ;
|
|
679 |
ctr change2 = requires theTuple[1] = 2 :
|
|
680 |
theTuple := MyTuple(1,3)
|
|
681 |
end
|
|
682 |
do
|
|
683 |
change1 [] change2
|
|
684 |
od
|
|
685 |
]|
|
|
686 |
system
|
|
687 |
TupleDemo
|
|
688 |
|
|
689 |
\end{lstlisting}
|
|
690 |
\caption{Tuple Example}
|
|
691 |
\label{Tuple}
|
|
692 |
\end{figure}
|
|
693 |
|
|
694 |
|
|
695 |
\subsubsection{Access Expressions}
|
|
696 |
|
|
697 |
\emph{Access Expression} is the general term for the access of elements
|
|
698 |
in a list or tuple, call of method or access to an attribute of an object.
|
|
699 |
|
|
700 |
Accessing elements of a list is done by using the index operator \texttt{[]}
|
|
701 |
well known from accessing arrays in imperative languages like C.
|
|
702 |
The index starts with 0.
|
|
703 |
|
|
704 |
The index operator \texttt{[]} can also be used to access a specific element of
|
|
705 |
a tuple. This feature is illustrated in the guard of action \texttt{change2} in
|
|
706 |
Figure \ref{Tuple}. However this feature is not implemented in the left hand
|
|
707 |
side of an assignment, e. g. it is not possible to write \texttt{theTuple[0] := 1}.
|
|
708 |
|
|
709 |
\subsubsection{Cast Expressions}
|
|
710 |
|
|
711 |
When dealing with a class hierarchy it is possibly to use an object of a
|
|
712 |
sub class instead of an object of its super class. This is called \emph{upcast}
|
|
713 |
and done implicitly in most contexts. However, when concatenating two
|
|
714 |
lists it has to be done explicitly using the operator \texttt{as} as illustrated
|
|
715 |
in Line 10 in Figure \ref{Cast}.
|
|
716 |
|
|
717 |
\begin{figure}[h]
|
|
718 |
\begin{lstlisting}[language=ooa,linewidth=\textwidth,breaklines,basicstyle=\scriptsize]
|
|
719 |
types
|
|
720 |
Class1 = autocons system
|
|
721 |
|[
|
|
722 |
var
|
|
723 |
O2 : Class2 = new (Class2);
|
|
724 |
O3 : Class3 = new (Class3);
|
|
725 |
OL : list[2] of Class2 = [nil]
|
|
726 |
actions
|
|
727 |
ctr fill = requires true :
|
|
728 |
OL := [O2]^[O3 as Class2]
|
|
729 |
end
|
|
730 |
do
|
|
731 |
fill
|
|
732 |
od
|
|
733 |
]| ;
|
|
734 |
Class2 = system
|
|
735 |
|[
|
|
736 |
]| ;
|
|
737 |
Class3 = system (Class2)
|
|
738 |
|[
|
|
739 |
]|
|
|
740 |
system
|
|
741 |
Class1
|
|
742 |
\end{lstlisting}
|
|
743 |
\caption{Cast Example}
|
|
744 |
\label{Cast}
|
|
745 |
\end{figure}
|
|
746 |
|
|
747 |
|
|
748 |
\subsection{Operators}
|
|
749 |
|
|
750 |
\subsubsection{Numeric Operators}
|
|
751 |
|
|
752 |
The numeric operators are \texttt{+} for adding two numbers of an integer or
|
|
753 |
float type, \texttt{-} for subtracting, \texttt{*} for multiplying. The operator
|
|
754 |
for the division of two numbers of a float type is \texttt{/}. For the division
|
|
755 |
of two numbers of an integer type there are operators \texttt{div} for the
|
|
756 |
quotient and \texttt{mod} for the remainder.
|
|
757 |
|
|
758 |
\subsubsection{Logical Operators}
|
|
759 |
|
|
760 |
The logical operators are inspired by VDM and written \texttt{and} for logical
|
|
761 |
and, \texttt{or} for logical or, \texttt{not} for negation, \texttt{=>} for
|
|
762 |
implication, and \texttt{<=>} for bi-implication.
|
|
763 |
|
|
764 |
\subsubsection{Comparison Operators}
|
|
765 |
|
|
766 |
For comparing two values of the same type there are \texttt{=} for equality
|
|
767 |
|
|
768 |
and \texttt{<>} for inequality.
|
|
769 |
|
|
770 |
Values of integer and float types can also be compared with \texttt{>} for
|
|
771 |
greater, \texttt{>=} for greater or equal, \texttt{<} for less, and \texttt{<=}
|
|
772 |
for less or equal.
|
|
773 |
|
|
774 |
\subsubsection{List Operators (Head, Tail, Length, Concatenation)}
|
|
775 |
|
|
776 |
The OOAS language provides several basic list operators that make it
|
|
777 |
easy to use lists.
|
|
778 |
|
|
779 |
The first operator is \texttt{hd} which is short for \emph{head}. This
|
|
780 |
operator returns the first element of a list. Therefore if \texttt{my\_list}
|
|
781 |
is a list, then \texttt{hd my\_list} is equivalent to \texttt{my\_list[0]}.
|
|
782 |
|
|
783 |
The counterpart to \emph{head} is \emph{tail}, which returns the list without
|
|
784 |
the first element. In OOAS the operator token is \texttt{tl}. So if you want
|
|
785 |
to remove the first element from a list \texttt{my\_stack} you can write
|
|
786 |
\texttt{my\_stack := tl my\_stack}.
|
|
787 |
|
|
788 |
The next important operation is determining how many elements are currently
|
|
789 |
in a list, which is the so-called \emph{length} of a list. In OOAS this
|
|
790 |
operator is written \texttt{len}. For example if an action should only be
|
|
791 |
enabled if there are less than 10 elements in the list \texttt{my\_stack} you
|
|
792 |
can write \texttt{requires len my\_stack < 10}.
|
|
793 |
|
|
794 |
The last operation is creating a list that contains all the elements of two
|
|
795 |
given lists, which is called \emph{concatenation}. The operator is written
|
|
796 |
\texttt{\^}. If for instance you want to append an element \texttt{a} to
|
|
797 |
a list \texttt{my\_stack}, you can write
|
|
798 |
|
|
799 |
\begin{verbatim}
|
|
800 |
my_stack := [a] ^ my_stack
|
|
801 |
\end{verbatim}
|
|
802 |
|
|
803 |
The example in Figure \ref{Stack} illustrates how these operators can be used
|
|
804 |
to build a stack.
|
|
805 |
|
|
806 |
\begin{figure}[h]
|
|
807 |
\begin{lstlisting}[language=ooa,linewidth=\textwidth,breaklines,basicstyle=\scriptsize]
|
|
808 |
types
|
|
809 |
SmallInt = int [0..3];
|
|
810 |
Stack = autocons system
|
|
811 |
|[
|
|
812 |
var
|
|
813 |
my_stack : list [10] of SmallInt = [0]
|
|
814 |
actions
|
|
815 |
obs top (a : SmallInt) = requires (a = hd my_stack) :
|
|
816 |
skip
|
|
817 |
end ;
|
|
818 |
obs pop = requires (len my_stack > 0) :
|
|
819 |
my_stack := tl my_stack
|
|
820 |
end;
|
|
821 |
obs push (a : SmallInt) = requires len my_stack < 10 :
|
|
822 |
my_stack := [a] ^ my_stack
|
|
823 |
end
|
|
824 |
|
|
825 |
do
|
|
826 |
var A : SmallInt : push(A) [] pop() [] var B : SmallInt : top(B)
|
|
827 |
od
|
|
828 |
]|
|
|
829 |
system
|
|
830 |
Stack
|
|
831 |
\end{lstlisting}
|
|
832 |
\caption{Stack}
|
|
833 |
\label{Stack}
|
|
834 |
\end{figure}
|
|
835 |
|
|
836 |
\subsection{The Dood Block}
|
|
837 |
\label{dood}
|
|
838 |
|
|
839 |
The actual behavior of an action system is defined in the so-called \doodblock.
|
|
840 |
The \doodblock was inspired by Dijkstra's guarded iteration statement. The
|
|
841 |
canonical form of a \doodblock is to list all named actions of the class
|
|
842 |
and connect them using the \texttt{[]} operator. In this case in each iteration
|
|
843 |
an action is available iff its guard evaluates to \texttt{true} and the system
|
|
844 |
terminates iff no action is enabled.
|
|
845 |
|
|
846 |
However, in OOAS actions are neither limited to named actions nor is the
|
|
847 |
non-deterministic choice the only possible operator.
|
|
848 |
|
|
849 |
Instead, all operators described in Section \ref{Composition} are available
|
|
850 |
as well as the built-in action \texttt{skip} and so-called anonymous actions.
|
|
851 |
An anonymous action is a guard followed by assignments, methods or built-in
|
|
852 |
action \texttt{skip}. In literature anonymous actions are often referred to
|
|
853 |
as \emph{guarded commands}.
|
|
854 |
|
|
855 |
If (named) actions are parametrized, enumeration can be used as generalization
|
|
856 |
of the non-deterministic choice over the values of a data type.
|
|
857 |
|
|
858 |
For instance given a data type \texttt{SmallInt = int[0..3]} and a named action
|
|
859 |
\texttt{doSomething ( a : SmallInt )} it is possible to write
|
|
860 |
\begin{verbatim}
|
|
861 |
do
|
|
862 |
var : A : SmallInt : doSomething(A)
|
|
863 |
od
|
|
864 |
\end{verbatim}
|
|
865 |
|
|
866 |
as abbreviation for
|
|
867 |
\begin{verbatim}
|
|
868 |
do
|
|
869 |
doSomething(0) [] doSomething(1) [] doSomething(2) [] doSomething(3)
|
|
870 |
od
|
|
871 |
\end{verbatim}
|
|
872 |
|
|
873 |
|
|
874 |
|
|
875 |
\subsection{The System Assembling Block}
|
|
876 |
\label{SAB}
|
|
877 |
|
|
878 |
In the System Assembling Block the system is assembled by its classes. All
|
|
879 |
the classes used by the system are connected either by the non-deterministic
|
|
880 |
choice operator \texttt{[]} or by the prioritized composition operator
|
|
881 |
\texttt{//}. This feature allows the user to manually set the priority among
|
|
882 |
the classes.
|
|
883 |
|
|
884 |
|
|
885 |
\clearpage
|
|
886 |
|
|
887 |
\subsection{Comments}
|
|
888 |
|
|
889 |
The OOAS language supports single line comments. Comments start
|
|
890 |
with a \texttt{\#} symbol.
|
|
891 |
|
|
892 |
\subsection{Formal Syntax}
|
|
893 |
|
|
894 |
The following EBNF grammar defines the syntax of an Object-Oriented action
|
|
895 |
system (OOAS). Features that are not implemented at all are left out. However
|
|
896 |
there are some features that are not completely implemented and do produce
|
|
897 |
code that doesn't work. These features are stroked out.
|
|
898 |
\\
|
|
899 |
|
|
900 |
\begin{longtable}[h]{lll}
|
|
901 |
OOAS &:=& ['\texttt{consts}' ConstList] '\texttt{types}' TypeList '\texttt{system}' ASTypeComp \\
|
|
902 |
ConstList &:=& NamedConst \{ '\texttt{;}' NamedConst \} \\
|
|
903 |
NamedConst &:=& Identifier '=' Exp \\
|
|
904 |
TypeList &:=& NamedType \{ '\texttt{;}' NamedType \} \\
|
|
905 |
NamedType &:=& Identifier '=' ( ComplexType $\vert$ OOActionSystem ) \\
|
|
906 |
ComplexType &:=& ( '\texttt{list}' '\texttt{[}' ( Num $\vert$ Identifier ) '\texttt{]}' '\texttt{of}' ComplexType ) \\
|
|
907 |
& & $\vert$ ( '\texttt{[}' Identifier \{ '\texttt{,}' Identifier \} '\texttt{]}' ) \\
|
|
908 |
& & $\vert$ ( '\texttt{(}' ComplexType \{ '\texttt{,}' ComplexType \} '\texttt{)}' ) \\
|
|
909 |
& & $\vert$ SimpleType \\
|
|
910 |
SimpleType &:=& '\texttt{bool}'\\
|
|
911 |
& & $\vert$ ( '\texttt{int}' '\texttt{[}' ( Num $\vert$ Identifier ) '\texttt{..}' ( Num $\vert$ Identifier ) '\texttt{]}' )\\
|
|
912 |
& & $\vert$ ( '\texttt{float}' '\texttt{[}' ( FloatNum $\vert$ Identifier ) '\texttt{..}' ( FloatNum $\vert$ Identifier ) '\texttt{]}' )\\
|
|
913 |
& & $\vert$ '\texttt{char}' \\
|
|
914 |
& & $\vert$ '\texttt{\{}' Identifier [ '\texttt{=}' Num] \{ '\texttt{,} Identifier [ '\texttt{=}' Num ] \} '\texttt{\}}' \\
|
|
915 |
& & $\vert$ Identifier \\
|
|
916 |
OOActionSystem &:=& [ '\texttt{autocons}' ] '\texttt{system}' [ Identifier ] \\
|
|
917 |
& & '\texttt{|[}' [ '\texttt{var}' AttrList ] [ '\texttt{methods}' MethodList ] \\
|
|
918 |
& & [ '\texttt{actions}' NamedActionList ] [ '\texttt{do}' [ActionBlock] '\texttt{od}'] '\texttt{]|}' \\
|
|
919 |
AttrList &:=& Attr \{ '\texttt{;}' Attr \} \\
|
|
920 |
Attr &:=& [ '\texttt{static}' ] [ '\texttt{obs}' $\vert$ '\texttt{ctr}' ] Identifier '\texttt{:}' ComplexType [ '\texttt{=}' Exp ] \\
|
|
921 |
MethodList &:=& Method \{ '\texttt{;}' Method \} \\
|
|
922 |
Method &:=& Identifier [ '\texttt{(}' MethodParamList '\texttt{)}' ] [ '\texttt{:}' ComplexType ] '\texttt{=}' \\
|
|
923 |
& & [ '\texttt{var}' LocalActionVars '\texttt{begin}' ] ActionBody '\texttt{end}' \\
|
|
924 |
MethodParamList &:=& Identifier '\texttt{:}' ComplexType \{ '\texttt{,}' Identifier '\texttt{:}' ComplexType \} \\
|
|
925 |
NamedActionList &:=& NamedAction \{ '\texttt{;}' NamedAction \} \\
|
|
926 |
NamedAction &:=& [ '\texttt{obs}' $\vert$ '\texttt{ctr}' ] Identifier [ '\texttt{(}' MethodParamList '\texttt{)}' ] \\
|
|
927 |
& & [ '\texttt{:}' ComplexType ] '\texttt{=}' [ '\texttt{var}' LocalActionVars ] DiscreteActionBody \\
|
|
928 |
LocalActionVars &:=& Identifier '\texttt{:}' ComplexType \{ '\texttt{;}' Identifier '\texttt{:}' ComplexType\} \\
|
|
929 |
DiscreteActionBody &:=& '\texttt{requires}' Exp '\texttt{:}' ActionBody '\texttt{end}'\\
|
|
930 |
Exp &:=& AtomExpression BinOperator AtomExpression \\
|
|
931 |
AtomExpression &:=& ( [ OpUn ] ( Reference $\vert$ Constant $\vert$ InitComplexType $\vert$ QuantExp\\
|
|
932 |
&& $\vert$ '\texttt{(}' Exp '\texttt{)}' \{ '\texttt{.}' Identifier \} [ AccessExp] ) \\
|
|
933 |
&& [ '\texttt{as}' Identifier ] ) \\
|
|
934 |
& & $\vert$ ( '\texttt{if}' Exp '\texttt{then}' Exp '\texttt{else}' Exp '\texttt{end}' ) \\
|
|
935 |
OpUn &:=& '\texttt{-}' $\vert$ '\texttt{not}' $\vert$ '\texttt{hd}' $\vert$ '\texttt{tl'} $\vert$ '\texttt{len}'\\
|
|
936 |
Constant &:=& ('\texttt{true}') $\vert$ ('\texttt{false'}) $\vert$ ('\texttt{nil}') $\vert$ ('\texttt{self}') $\vert$ (FloatNum) $\vert$ (Num) $\vert$ \\
|
|
937 |
&& (\cancel{StringLiteral}) \\
|
|
938 |
InitComplexType &:=& InitListType $\vert$ ('\texttt{new}' '\texttt{(}' Identifier [ '\texttt{,}' StringLiteral ] '\texttt{)}') \\
|
|
939 |
InitListType &:=& '\texttt{[}' Exp [ ListComp $\vert$ \{ '\texttt{,} Exp'\} ] '\texttt{]}' \\
|
|
940 |
ListComp &:=& '\texttt{|}' '\texttt{var}' Identifier '\texttt{:}' ComplexType \{ \texttt{;} Identifier ComplexType \} '\texttt{\&}' Exp \\
|
|
941 |
QuantExp &:=& ('\texttt{forall}' $\vert$ '\texttt{exists}') Identifier '\texttt{:}' SimpleType \\
|
|
942 |
&& \{ '\texttt{,}' Identifier '\texttt{:} SimpleType' \} '\texttt{:}' '\texttt{(}' Exp '\texttt{)}' \\
|
|
943 |
ActionBody &:=& ActionBodyParallel '\texttt{//}' ActionBodyParallel \\
|
|
944 |
ActionBodyParallel &:=& ActionBodySeq '\texttt{[]}' ActionBodySeq \\
|
|
945 |
ActionBodySeq &:=& ActionBodyParen '\texttt{;}' ActionBodyParen \\
|
|
946 |
ActionBodyParen &:=& ( '\texttt{(}' ActionBody '\texttt{)}' ) $\vert$ ( Statement ) \\
|
|
947 |
Statement &:=& ( '\texttt{skip'} ) $\vert$ ( Reference \{ '\texttt{,}' Reference \} '\texttt{:=}' Exp \{ '\texttt{,}' Exp\} ) \\
|
|
948 |
Reference &:=& QualId [ AccessExp ] [ [ '\texttt{::}' '\texttt{(}' Exp '\texttt{)}' ] '\texttt{:>:}' '\texttt{(}' Exp '\texttt{)}' ] \\
|
|
949 |
AccessExp &:=& ( ( '\texttt{[}' Exp '\texttt{]}' ) $\vert$ ( '\texttt{(}' MethodCallParam '\texttt{)}') ) \\
|
|
950 |
&& \{( ( '\texttt{[}' Exp '\texttt{]}' ) | ( '\texttt{(}' MethodCallParam '\texttt{)}') ) \} \\
|
|
951 |
&& [ '\texttt{.}' Identifier \{ '\texttt{.}' Identifier\} AccessExp] \\
|
|
952 |
QualId &:=& [ '\texttt{self}' '\texttt{.}' ] Identifier \{ '\texttt{.} Identifier'\} \\
|
|
953 |
MethodCallParam &:=& [ Exp \{ '\texttt{,}' Exp\}]\\
|
|
954 |
ActionBlock &:=& ActionBlockPar \{ '\texttt{//}' ActionBlockPar\} \\
|
|
955 |
ActionBlockPar &:=& ActionBlockSeq \{ '\texttt{[]}' ActionBlockSeq\} \\
|
|
956 |
ActionBlockSeq &:=& [ '\texttt{var}' BlockVarList [\cancel{'\texttt{\&}' Exp} ] '\texttt{:}' ] \\
|
|
957 |
&&ActionBlockParen \{ '\texttt{;}' ActionBlockParen\}\\
|
|
958 |
ActionBlockParen &:=& ('\texttt{(}' ActionBlock '\texttt{)}' ) $\vert$ (AnonOrNamedAct)\\
|
|
959 |
AnonOrNamedAct &:=& DiscreteActionBody $\vert$ '\texttt{skip}' $\vert$ \\
|
|
960 |
&& Identifier [ '\texttt{(}' MethodCallParam '\texttt{)}' ] [ '\texttt{:>:}' '\texttt{(}' Exp '\texttt{)}' ] \\
|
|
961 |
BlockVarList &:=& BlockVar \{ '\texttt{;} BlockVar'\} \\
|
|
962 |
BlockVar &:=& Identifier '\texttt{:}' ComplexType \\
|
|
963 |
ASTypeComp &:=& ASTypeCompPar \{ '\texttt{//}' ASTypeCompPar\} \\
|
|
964 |
ASTypeCompPar &:=& ASTypeCompSeq \{ '\texttt{[]}' ASTypeCompSeq\} \\
|
|
965 |
ASTypeCompSeq &:=& ASTypeCompBP \\
|
|
966 |
ASTypeCompBP &:=& ('\texttt{(}' ASTypeComp '\texttt{)}' ) \\
|
|
967 |
BinOperator &:=& ('\texttt{<=>}') $\vert$ ('\texttt{>}')$\vert$ ('\texttt{>=}')$\vert$ ('\texttt{<}')$\vert$ ('\texttt{<=)}')$\vert$ ('\texttt{=}')$\vert$ ('\texttt{<>}')$\vert$ ('\texttt{=>}') $\vert$ ('\texttt{-}')$\vert$ ('\texttt{+}') \\
|
|
968 |
&&$\vert$ ('\texttt{or}')$\vert$ ('\texttt{and}')$\vert$ ('\texttt{/}') $\vert$ ('\texttt{div}') $\vert$ ('\texttt{*}') $\vert$ ('\texttt{mod}') $\vert$ ('\texttt{\^}')\\
|
|
969 |
|
|
970 |
Identifier &:=& Letter \{Letter $\vert$ Digit\}\\
|
|
971 |
Num &:=& ['\texttt{+}' $\vert$ '\texttt{-}'] Digit \{ Digit \} \\
|
|
972 |
FloatNum &:=& ['\texttt{+}' $\vert$ '\texttt{-}'] Digit \{ Digit \} '\texttt{.}' Digit \{Digit\} ['\texttt{e}' $\vert$ '\texttt{E}' ['\texttt{+}' $\vert$ '\texttt{-}' ] Digit \{ Digit \}]\\
|
|
973 |
Letter &:=& '\texttt{\$}' $\vert$ '\texttt{\_}' $\vert$ '\texttt{A}'..'\texttt{Z}' $\vert$ '\texttt{a}'..'\texttt{z}'\\
|
|
974 |
Digit &:=& '\texttt{0}'..'\texttt{9}'\\
|
|
975 |
|
|
976 |
\end{longtable}
|
|
977 |
\clearpage
|
|
978 |
|
|
979 |
\section{Incomplete Features}
|
|
980 |
|
|
981 |
The following features are supported by the grammar, but do not produce
|
|
982 |
executable or useful code.
|
|
983 |
|
|
984 |
\subsection{Sequential Block Expression}
|
|
985 |
|
|
986 |
In the \doodblock when calling an action with a variable it is possible
|
|
987 |
to add an additional guard. However if the guard is true, the produced
|
|
988 |
Prolog-Code will not work.
|
|
989 |
|
|
990 |
Example:
|
|
991 |
\begin{verbatim}
|
|
992 |
do
|
|
993 |
var A : SmallInt & A < 3 : push(A)
|
|
994 |
od
|
|
995 |
\end{verbatim}
|
|
996 |
|
|
997 |
\subsection{String}
|
|
998 |
|
|
999 |
It is possible to assign a string to a variable of any list type of char.
|
|
1000 |
|
|
1001 |
Example:
|
adding original CSharp version of the ooas compiler