summaryrefslogtreecommitdiff
path: root/build-aux/measurestack/vcg.py
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-03-31 15:58:51 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-04-01 05:09:44 -0600
commit2ced5e02eacfc6b9e67435fe3a24dcb6c3a29037 (patch)
treea228eef90a7000c80dab582630b85d04dac923ee /build-aux/measurestack/vcg.py
parent1a0c67835cd74c6bf2113bb14a7f1b520508c536 (diff)
measurestack: Compile all regexes upfront
Diffstat (limited to 'build-aux/measurestack/vcg.py')
-rw-r--r--build-aux/measurestack/vcg.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/build-aux/measurestack/vcg.py b/build-aux/measurestack/vcg.py
index ca20b34..39755e9 100644
--- a/build-aux/measurestack/vcg.py
+++ b/build-aux/measurestack/vcg.py
@@ -26,16 +26,16 @@ class VCGElem:
attrs: dict[str, str]
+re_beg = re.compile(r"(edge|node):\s*\{\s*")
+_re_tok = r"[a-zA-Z_][a-zA-Z0-9_]*"
+_re_str = r'"(?:[^\"]|\\.)*"'
+re_attr = re.compile("(" + _re_tok + r")\s*:\s*(" + _re_tok + "|" + _re_str + r")\s*")
+re_end = re.compile(r"\}\s*$")
+re_skip = re.compile(r"(graph:\s*\{\s*title\s*:\s*" + _re_str + r"\s*|\})\s*")
+re_esc = re.compile(r"\\.")
+
+
def parse_vcg(reader: typing.TextIO) -> typing.Iterator[VCGElem]:
- re_beg = re.compile(r"(edge|node):\s*\{\s*")
- _re_tok = r"[a-zA-Z_][a-zA-Z0-9_]*"
- _re_str = r'"(?:[^\"]|\\.)*"'
- re_attr = re.compile(
- "(" + _re_tok + r")\s*:\s*(" + _re_tok + "|" + _re_str + r")\s*"
- )
- re_end = re.compile(r"\}\s*$")
- re_skip = re.compile(r"(graph:\s*\{\s*title\s*:\s*" + _re_str + r"\s*|\})\s*")
- re_esc = re.compile(r"\\.")
for lineno, line in enumerate(reader):
pos = 0