You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
581 B
24 lines
581 B
pub use option_ext::UncheckedOptionExt;
|
|
use std::fmt::Display;
|
|
use sexp::{Sexp, Atom};
|
|
use std::str::FromStr;
|
|
|
|
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<i64, _> = FromStr::from_str(&s);
|
|
if let Ok(x) = x {
|
|
return Sexp::Atom(Atom::I(x), Default::default());
|
|
}
|
|
|
|
let y: Result<f64, _> = FromStr::from_str(&s);
|
|
if let Ok(y) = y {
|
|
return Sexp::Atom(Atom::F(y), Default::default());
|
|
}
|
|
|
|
Sexp::Atom(Atom::S(s), Default::default())
|
|
}
|
|
|