Repository navigation
Expand file tree
/
Copy pathcube.py
More file actions
61 lines (56 loc) · 4.41 KB
/
Copy pathcube.py
File metadata and controls
61 lines (56 loc) · 4.41 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
"""This module is a semantic validator
-----------------------------------------------------------------
Compilers Design Project
Tec de Monterrey
Julio Cesar Aguilar Villanueva A01152537
Jose Fernando Davila Orta A00999281
-----------------------------------------------------------------
DOCUMENTATION: For complete Documentation see UserManual.pdf"""
# Create a tuple with all the operations posible
operations = ( '+', '-', '*', '/', '+=', '-=', '*=', '/=', '%', 'mod', '<', '>', '!=', '==', '<=', '>=', 'and', 'not', 'or', '=')
# Some lambda functions
create = lambda x: dict(zip(operations, x))
create_manual = lambda x: dict(zip(operations, [x] * len(operations)))
# semantic cube
semantic_cube = {
# '+', '-', '*', '/', '+=', '-=', '*=', '/=', '%', 'mod', <, >, !=, ==, <=, >=, and, not, or, =
'int': {
'int' : create([ 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'bool', 'bool', 'bool', 'bool', 'bool', 'bool', 'bool', 'bool', 'bool', 'int']) ,
'double': create([ 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'bool', 'bool', 'bool', 'bool', 'bool', 'bool', 'bool', 'bool', 'bool', 'int']) ,
'string': create_manual('Error'),
'bool': create_manual('Error'),
'list': create_manual('Error')
},
# '+', '-', '*', '/', '+=', '-=', '*=', '/=', '%', 'mod', <, >, !=, ==, <=, >=, and, not, or, =
'double': {
'int' : create([ 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'bool', 'bool', 'bool', 'bool', 'bool', 'bool', 'bool', 'bool', 'bool', 'double']) ,
'double': create([ 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'bool', 'bool', 'bool', 'bool', 'bool', 'bool', 'bool', 'bool', 'bool', 'double']) ,
'string': create_manual('Error'),
'bool': create_manual('Error'),
'list': create_manual('Error')
},
# '+', '-', '*', '/', '+=', '-=', '*=', '/=', '%', 'mod', <, >, !=, ==, <=, >=, and, not, or, =
'string': {
'int' : create_manual('Error'),
'double': create_manual('Error'),
'string': create([ 'String', 'Error', 'Error', 'Error', 'String', 'Error', 'Error', 'Error', 'Error', 'Error', 'Error', 'Error', 'bool', 'bool', 'Error', 'Error', 'Error', 'Error', 'Error', 'string']),
'bool': create_manual('Error'),
'list': create_manual('Error')
},
# '+', '-', '*', '/', '+=', '-=', '*=', '/=', '%', 'mod', <, >, !=, ==, <=, >=, and, not, or , =
'bool': {
'int' : create_manual('Error'),
'double': create_manual('Error'),
'string': create_manual('Error') ,
'bool': create([ 'Error', 'Error', 'Error', 'Error', 'Error', 'Error', 'Error', 'Error', 'Error', 'Error', 'bool', 'bool', 'bool', 'bool', 'bool', 'bool', 'bool', 'bool', 'bool', 'bool']) ,
'list': create_manual('Error')
},
# '+', '-', '*', '/', '+=', '-=', '*=', '/=', '%', 'mod', <, >, !=, ==, <=, >=, and, not, or , =
'list': {
'int' : create_manual('Error'),
'double': create_manual('Error'),
'string': create_manual('Error'),
'bool': create_manual('Error'),
'list': create_manual('Error')
}
}