[Lldb-commits] [lldb] [lldb] Fix compile Python f-strings to improved `@fmt` (PR #232997)
Dave Lee via lldb-commits
lldb-commits at lists.llvm.org
Tue Oct 20 10:55:06 PDT 2026
================
@@ -522,16 +522,71 @@ def next_byte():
################################################################################
+def _parse_fmt(fmt: str) -> list[Union[str, int]]:
+ """Parse an llvm::formatv format string into literals (str) and
+ replacement indexes (int). Adjacent literals are merged, so two items in a
+ row are never both literals.
+
+ As in version 2 of the bytecode, replacements are automatically indexed:
+
+ "{" [ "," layout ] [ ":" options ] "}"
+
+ Explicit indexes are not supported. Layouts and options are accepted, but
+ are not yet supported, and are ignored."""
+
+ items: list[Union[str, int]] = []
+ literal = ""
+ next_index = 0
+ i = 0
+ while i < len(fmt):
----------------
kastiglione wrote:
I have not try regex. Take a look at the updated parsing implementation and let me know if you'd still like me to explore a regex based implementation.
https://github.com/llvm/llvm-project/pull/232997
More information about the lldb-commits
mailing list