diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2023-11-11 14:40:25 +0200 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2023-11-11 14:40:25 +0200 |
| commit | f7dd9705d44b9cee5103b267797c0449d42319df (patch) | |
| tree | a63c68f282cf64e250384a2e1e8525d2333b9dde /src/tokenizer.py | |
| parent | d3abfd22d4f5fff02adaebe28707aea7bd804ba3 (diff) | |
WIP functions
Diffstat (limited to 'src/tokenizer.py')
| -rw-r--r-- | src/tokenizer.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/tokenizer.py b/src/tokenizer.py index d89309f..cf31b56 100644 --- a/src/tokenizer.py +++ b/src/tokenizer.py @@ -1,4 +1,4 @@ -def tokenize(line: str) -> list[str]: +def tokenize(line: str, retain_curlies = False) -> list[str]: cur: str = "" result: list[str] = [] is_py_expr = False @@ -8,6 +8,8 @@ def tokenize(line: str) -> list[str]: 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) @@ -15,6 +17,8 @@ def tokenize(line: str) -> list[str]: 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: |
