generated from donno2048/nothingness
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.py
29 lines (29 loc) · 1.01 KB
/
example.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
# coding: brackets
from typing import Generator;def get_strings(text: str) -> Generator { # yeah, semicolon can come between any two statements
flag_quote, flag_double_quote, start = False, False, 0;for i in range(len(text)) { # or even between conditions and loops
j, odd = i - 1, False
while text[j] == "\\" {
j -= 1
odd = not odd
} if odd {continue} if not flag_quote and not flag_double_quote { # you can do that now
if text[i] == "\'" {
flag_quote, start = True, i
}
if text[i] == "\"" {
flag_double_quote, start = True, i
}
}
elif flag_double_quote {
if text[i] == "\"" {
flag_double_quote = False
yield (start, i + 1)
}
}
elif flag_quote {
if text[i] == "\'" {
flag_quote = False
yield (start, i + 1)
}
}
}
}