use std::fmt::Display; use std::str::FromStr; pub use option_ext::UncheckedOptionExt; use sexp::{Atom, Sexp}; mod option_ext; /// Convert a string token to Sexp #[allow(non_snake_case)] pub fn A(s: impl Display) -> Sexp { let s = s.to_string(); let x: Result = FromStr::from_str(&s); if let Ok(x) = x { return Sexp::Atom(Atom::U(x), Default::default()); } let x: Result = FromStr::from_str(&s); if let Ok(x) = x { return Sexp::Atom(Atom::I(x), Default::default()); } let y: Result = FromStr::from_str(&s); if let Ok(y) = y { return Sexp::Atom(Atom::F(y), Default::default()); } if s.contains(|c: char| " \t\"\\\n\t\r".contains(c)) { Sexp::Atom(Atom::QS(s), Default::default()) } else { Sexp::Atom(Atom::S(s), Default::default()) } }