-
Notifications
You must be signed in to change notification settings - Fork 0
/
tokens.py
33 lines (30 loc) · 929 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
32
33
tokens = [
"START",
"ARROW",
"SEPARATOR",
"END",
"EMPTY",
"NON_TERMINAL",
"TERMINAL",
]
token_to_symbol = {
"START": "=",
"ARROW": "👉",
"SEPARATOR": "🤌",
"END": "🗿",
"EMPTY": "😵",
"NON_TERMINAL": "🤯",
"TERMINAL": "🥵",
}
START_TOKEN = rf"{token_to_symbol['START']}"
NON_TERMINAL_TOKEN = rf"{token_to_symbol['NON_TERMINAL']}"
TERMINAL_TOKEN = rf"{token_to_symbol['TERMINAL']}"
START_TOKEN_REGEX = (
r"start" + START_TOKEN + NON_TERMINAL_TOKEN + r"[\x00-\x7F]+" + NON_TERMINAL_TOKEN
)
ARROW_TOKEN_REGEX = rf"{token_to_symbol['ARROW']}"
SEPARATOR_TOKEN_REGEX = rf"{token_to_symbol['SEPARATOR']}"
END_TOKEN_REGEX = rf"{token_to_symbol['END']}"
EMPTY_TOKEN_REGEX = rf"{token_to_symbol['EMPTY']}"
NON_TERMINAL_TOKEN_REGEX = NON_TERMINAL_TOKEN + r"[\x00-\x7F]+" + NON_TERMINAL_TOKEN
TERMINAL_TOKEN_REGEX = TERMINAL_TOKEN + r"[\x00-\x7F]+" + TERMINAL_TOKEN