fixes, now .0 from rust decimal is being discussed
This commit is contained in:
@@ -50,7 +50,8 @@ impl ScriptParser {
|
||||
|
||||
ScriptParser {
|
||||
math_operators,
|
||||
number_literal_re: Regex::new(r#"(?<!")(-?\d+\.?\d*(?:[eE][+-]?\d+)?)(?!")"#).unwrap(),
|
||||
// Simple regex that matches numbers - we'll handle context in the replacement
|
||||
number_literal_re: Regex::new(r"\b(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)\b").unwrap(),
|
||||
variable_re: Regex::new(r"\$(\w+)").unwrap(),
|
||||
}
|
||||
}
|
||||
@@ -73,9 +74,27 @@ impl ScriptParser {
|
||||
|
||||
/// Convert all unquoted numeric literals to quoted strings
|
||||
fn convert_numbers_to_strings(&self, script: &str) -> String {
|
||||
self.number_literal_re.replace_all(script, |caps: ®ex::Captures| {
|
||||
format!("\"{}\"", &caps[1])
|
||||
}).to_string()
|
||||
// Simple approach: split on quotes and only process unquoted sections
|
||||
let parts: Vec<&str> = script.split('"').collect();
|
||||
let mut result = String::new();
|
||||
|
||||
for (i, part) in parts.iter().enumerate() {
|
||||
if i % 2 == 0 {
|
||||
// Even indices are outside quotes - process them
|
||||
let processed = self.number_literal_re.replace_all(part, "\"$1\"");
|
||||
result.push_str(&processed);
|
||||
} else {
|
||||
// Odd indices are inside quotes - keep as is
|
||||
result.push_str(part);
|
||||
}
|
||||
|
||||
// Add back the quote if not the last part
|
||||
if i < parts.len() - 1 {
|
||||
result.push('"');
|
||||
}
|
||||
}
|
||||
|
||||
result
|
||||
}
|
||||
|
||||
/// Replace math function calls with decimal equivalents
|
||||
|
||||
Reference in New Issue
Block a user