-
Notifications
You must be signed in to change notification settings - Fork 0
/
calculator.pl
43 lines (34 loc) · 1.31 KB
/
calculator.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
:- use_module(trace_exps_common).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% --- EVENTS AND THEIR TYPE --- %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% SIMPLE CALCULATOR
event(off).
event(digit).
event(canc).
event(operation).
event(equals).
of_type(E,E).
%%%%%%%%%%%%%%%%%%%
%% --- TESTS --- %%
%%%%%%%%%%%%%%%%%%%
%% ------------ SIMPLE CALCULATOR ----------- %%
%% all possible behaviours
test(test0, Length, Traces) :-
Always = (off:Off)\/(canc:Operand1),
Start = annot(Always\/(digit:Operand1), start),
Off = annot(eps, off),
Result = annot(Always\/(digit:Operand1), result),
Operand2 = annot(Always\/(digit:Operand2)\/(equals:Result), operand2),
Operand1 = annot(Always\/(digit:Operand1)\/(operation:Operation), operand1),
Operation = annot(Always\/(digit:Operand2), operation),
bounded_accept_all_annot(Start, Length, Traces).
test(test1, Length, Traces) :-
Always = (off:Off)\/(canc:Operand1),
Start = annot(Always\/Operand1, start),
Off = annot(eps, off),
Result = annot(Always\/(digit:Operand1), result),
Operand2 = annot(Always\/(digit:Operand2)\/(equals:Result), operand2),
Operand1 = annot(Always\/(digit:(Operand1\/(operation:Operation))), operand1),
Operation = annot(Always\/(digit:Operand2), operation),
bounded_accept_all_annot(Start, Length, Traces).