-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtokens.py
31 lines (30 loc) · 931 Bytes
/
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
#-------------------------------------------#
# Define all token types ####################
# Each is a unique int, essentially an enum #
#-------------------------------------------#
NULL = 0
NUM = 1
BOOL = 2
OP = 3 #Operator (+, -, *, /)
#(- = + with negative augend, / = * with reciprocal of multiplicand)
COMP = 4 #Comparator (<, >, ==)
ASGN = 5 #Assign
VAR = 6 #Variable
IF = 7
THEN = 8
ELSE = 9
EOL = 10 #End of line (;)
LPAREN = 11
RPAREN = 12
EOF = 13 #End of file
CLPAREN = 14 #Curly left parenthesis ({)
CRPAREN = 15 #Curly right parenthesis (})
WHILE = 16
COMMA = 17
RETURN = 18 #return keyword for function returns
SLPAREN = 19 #square left parenthesis ([)
SRPAREN = 20 #square right parenthesis (])
STR = 21 #string (difference from var identified by lexer)
FUNCTION = 22 #used for lambda functions (eg. function(x){return x+1;})
IMPORT = 23 #import <something>
PAIR = 24 #used to make pairs (eg. pair[1,2])