-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
tokens.py
57 lines (57 loc) · 1.33 KB
/
tokens.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
## Tokens
tokens = {
'COMMENT': r'#.*',
'NEWLINE': r'\n+',
'STRING': r'(\"([^\\\n]|(\\.))*?\")|(\'([^\\\n]|(\\.))*?\')',
'BOOLEAN': r'(true)|(false)',
'FLOAT': r'-?\d+\.\d+',
'INTEGER': r'-?\d+',
'ELSEIF': r'(else if)|(elseif)',
'IF': r'if',
'OPEN_CRO': r'\{',
'CLOSE_CRO': r'\}',
'ELSE': r'else',
'LOOP': r'loop',
'WHILE': r'while',
'AND': r'(and)|(&&)',
'OR': r'(or)|(\|\|)',
'NOT': r'(not)|(!)',
'PRINT': r'show',
'EXIT': r'exit',
'ENTER': r'enter',
'INT': r'int',
'FLOATF': r'float',
'STR': r'str',
'TYPE': r'type',
'BOOL': r'boolean',
'CANBE': r'canbe',
'VIRGULE': r',',
'IS': r'\=\=',
'LESSE': r'\<\=',
'MOREE': r'\>\=',
'LESS': r'\<',
'MORE': r'\>',
'INCREMENT': r'\+\+',
'DECREMENT': r'\-\-',
'SUMAFF': r'\+\=',
'SUBAFF': r'\-\=',
'MULAFF': r'\*\=',
'DIVAFF': r'\/\=',
'DIVEUAFF': r'\/\/\=',
'MODAFF': r'\%\=',
'POWAFF': r'\^\=',
'SUM': r'\+',
'SUB': r'\-',
'MUL': r'\*',
'DIV': r'\/',
'DIVEU': r'\/\/',
'MOD': r'\%',
'POW': r'\^',
'EGAL': r'\=',
'IDENTIFIER': r"[a-zA-Z][a-zA-Z0-9]*",
'OPEN_PAREN': r'\(',
'CLOSE_PAREN': r'\)',
'CRO_OPEN': r'\[',
'CRO_CLOSE': r'\]',
'POINT': r'\.'
}