synthphonia/text/parsing/
int.rs1use std::collections::HashSet;
2
3use chrono::{NaiveDate, Datelike, Month};
4use itertools::Itertools;
5use regex::Regex;
6use crate::galloc::TryAllocForExactSizeIter;
7
8use crate::value::ConstValue;
9use crate::{galloc::AllocForExactSizeIter, expr::{Expr, ops}, impl_basic, impl_op1_opt, new_op1_opt, value::Value};
10
11use super::ParsingOp;
12
13
14impl_basic!(ParseInt, "int.parse");
15impl crate::forward::enumeration::Enumerator1 for ParseInt {
16 fn enumerate(&self, this: &'static ops::Op1Enum, exec: &'static crate::forward::executor::Executor, opnt: [usize; 1]) -> Result<(), ()> { Ok(())}
17}
18
19impl_op1_opt!(ParseInt, "int.parse",
20 Str -> Int { |s1: &&str| -> Option<i64> {
21 todo!()
22 }}
23);
24
25impl ParsingOp for ParseInt {
26
27 fn parse_into(&self, input: &'static str) -> std::vec::Vec<(&'static str, ConstValue)> {
28 let regex = Regex::new(r"(\-|\+)?\d+".to_string().as_str()).unwrap();
29 let iter = regex.captures_iter(input);
30 let mut result = Vec::new();
31 for m in iter {
32 let a = m.get(0).unwrap().as_str();
33 if let Ok(i) = a.parse::<i64>() {
34 result.push((a, i.into()));
35 }
36 }
37 result
38 }
39
40}
41