types_checking.anubis
1.34 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* Created by PyramIDE.
* User: フランスのトトロ aka (David RENÉ)
* Date: 21/01/2017
* Time: 00:36
* © Calexium
*/
read densaku_lib/types/ds_types.anubis
read system/string.anubis
read tools/basis.anubis
define Bool
is_upper_case_start
(
String name
)=
if nth(0, name) is
{
failure then println("Can't get the first character of "+name);false,
success(char) then
if (char +=< 90) & (64 +< char) then
true
else
println("Type name ["+name+"] doesn't start with upper case");false
}
.
define Maybe(One)
/* Check if the type name start with upper case and if that type doesn't already exists
*/
check_name
(
List(DS_Type) types, //types description
List(String) so_far,
Maybe(One) return
)=
if types is
{
[] then return,
[h . t] then
since h is ds_type(type_name, _, tk_alts),
if is_upper_case_start(type_name) then
check_name(t, [], return)
else
check_name(t, [], failure)
}
.
public define Maybe(One)
check_types
(
List(DS_Type) types //types description
)=
//check if name start with upper case
if check_name(types, [], success(unique)) is
{
failure then println("Error(s) in type checking "); failure
success(_) then
success(unique)
}
.