-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSptokens.py
41 lines (27 loc) · 1.38 KB
/
Sptokens.py
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
alphabet = "".join([chr(i) for i in range (65, 91)] + [chr(i) for i in range (97, 123)])
nums = "1234567890"
serviceWords = ['int', 'void', 'float', 'while', 'do',
'if', 'then', 'else', 'switch', 'case',
'break', 'default', 'repeat', 'begin',
'end', 'until', 'for']
allTokens = {'=': 'assign', ':': 'colon', '?': 'question_mark',
'*': 'mul', '[': 'left_square_bracket', ']': 'right_square_bracket',
';': 'semi_colon', '/': 'divide', '%': 'module',
'-': 'subtract', '+': 'add', '+=': 'sum_assign',
'-=': 'sub_assign', '&': 'logic_and', '|': 'logic_or',
'^': 'logic_exclusive_or', '++': 'inc', '--': 'dec'}
assignment = ['+=', '-=', '=']
bracketsOpen = ['(', '[']
bracketsClose = [')', ']']
parenBrackets = ['(', ')']
incrementDecrement = ['++', '--']
simpleOperations = ['&', '|', '^', '+', '-', '*', '/', ]
lowOperations = ['&', '|', '^', ]
middleOperations = ['+', '-', ]
highOperations = ['*', '/', ]
comparison = [">", "<", "==", "=<", "=>"]
nextStep = [";", ":"]
infixOperation = ["!"]
invariableDelimeters = [".", "_"]
operationOrder = [assignment,lowOperations, middleOperations, highOperations, incrementDecrement, parenBrackets]
possibleOperations = assignment + lowOperations + middleOperations + highOperations + incrementDecrement + parenBrackets