From f7dd9705d44b9cee5103b267797c0449d42319df Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Sat, 11 Nov 2023 14:40:25 +0200 Subject: WIP functions --- src/tokenizer.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/tokenizer.py') 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: -- cgit v1.3