diff options
Diffstat (limited to 'codegen/fixup.py')
| -rw-r--r-- | codegen/fixup.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/codegen/fixup.py b/codegen/fixup.py new file mode 100644 index 0000000..1131f11 --- /dev/null +++ b/codegen/fixup.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 +"""Post-process maxima output for Rust: + - convert bare integer literals to float literals (1 -> 1.0) + - drop maxima noise lines (keep only 'pub fn' lines) +""" +import re +import sys + +pat = re.compile(r"(?<![\w.])-?\d+(?![\w.])") + +for line in sys.stdin: + if not line.startswith("pub fn"): + continue + sys.stdout.write(pat.sub(lambda m: m.group(0) + ".0", line)) |
