advancedresearch / avalog

An experimental implementation of Avatar Logic with a Prolog-like syntax
Apache License 2.0
66 stars 3 forks source link

Add `IsVar` trait instead of ambiguous `Into<Expr<Self>>` for `Symbol` #169

Closed bvssvni closed 2 years ago

bvssvni commented 2 years ago

Currently, there is a bug in the parser where replacing the inner type of Expr leads to wrong results.

Should replace Into<Expr<Self>> with an explicit trait:

/// Detect a variable when parsing.
pub trait IsVar {
    /// Returns `true` if string is a variable.
    fn is_var(val: &str) -> bool {
        if let Some(c) = val.chars().next() {c.is_uppercase()} else {false}
    }
}

The From<Arc<String>> and From<&'static str> impls should be removed from Expr<Arc<String>>.