scripts: csv.py: Fixed lexing of signed float exponents

So now these lex correctly:

- 1e9  =>  1000000000
- 1e+9 =>  1000000000
- 1e-9 => -1000000000

A bit tricky when you think about how these could be confused for binary
addition/subtraction. To fix we just eagerly grab any signs after the e.

These are particularly useful for manipulating simulated benchmarks,
where we need to convert things to/from nanoseconds.
This commit is contained in:
Christopher Haster
2025-08-03 13:22:37 -05:00
parent 18d1f68445
commit 2a4e0496b6

View File

@ -1129,7 +1129,7 @@ class CsvExpr:
p.chomp()
# floats
elif p.match('[+-]?(?:[_0-9]*\.[_0-9eE]*|nan)'):
elif p.match('[+-]?(?:[_0-9]*\.(?:[_0-9]|[eE][+-]?)*|nan)'):
a = CsvExpr.FloatLit(CsvFloat(p.chomp()))
# ints