diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2024-02-20 16:55:14 +0200 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2024-02-20 16:56:09 +0200 |
| commit | 549901c85044b6ccd912688d6be007c2fdacc6c6 (patch) | |
| tree | 15d1123eedb4347472e4b47fec880e2e5b79927e /src/tokenizer.py | |
| parent | abf0594c78087434bced59054896f7f411e18faf (diff) | |
Refactor dir structure
Diffstat (limited to 'src/tokenizer.py')
| -rw-r--r-- | src/tokenizer.py | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/src/tokenizer.py b/src/tokenizer.py deleted file mode 100644 index cf31b56..0000000 --- a/src/tokenizer.py +++ /dev/null @@ -1,47 +0,0 @@ -def tokenize(line: str, retain_curlies = False) -> list[str]: - cur: str = "" - result: list[str] = [] - is_py_expr = False - is_string = False - idx = 0 - while idx < len(line): - c = line[idx] - if not is_py_expr and c == "$": - is_py_expr = True - if retain_curlies: - cur += "${" - idx += 1 - elif is_py_expr and c == "$": - raise Exception("Unexpected start of python expr while already parsing a python expression:\n" + line) - elif not is_py_expr and c == "}": - raise Exception("Unexpected end of python expr while not parsing a python expression:\n" + line) - elif is_py_expr and c == "}": - is_py_expr = False - if retain_curlies: - cur += c - result.append(cur) - cur = "" - elif is_py_expr: - cur += c - elif not is_string and c == "\"": - cur += "\"" - is_string = True - elif is_string and c == "\"": - cur += "\"" - is_string = False - result.append(cur) - cur = "" - elif is_string: - cur += c - elif c == " " or c == "\t": - result.append(cur) - cur = "" - else: - cur += c - - idx += 1 - - if len(cur) > 0: - result.append(cur) - - return [r for r in result if r != ""]
\ No newline at end of file |
