#[derive(Clone, Debug, PartialEq)]
pub enum StarlarkStmt {
Load {
module: String,
symbols: Vec<String>,
},
Call {
func: String,
args: Vec<KwArg>,
},
Assign {
name: String,
value: StarlarkValue,
},
}
#[derive(Clone, Debug, PartialEq)]
pub enum KwArg {
Positional(StarlarkValue),
Named { name: String, value: StarlarkValue },
}
impl KwArg {
pub fn str(name: &str, value: impl Into<String>) -> Self {
Self::Named {
name: name.to_string(),
value: StarlarkValue::Str(value.into()),
}
}
pub fn positional(value: StarlarkValue) -> Self {
Self::Positional(value)
}
pub fn positional_named(name: &str, value: StarlarkValue) -> Self {
Self::Named {
name: name.to_string(),
value,
}
}
}
#[derive(Clone, Debug, PartialEq)]
pub enum StarlarkValue {
None,
Bool(bool),
Int(i64),
Str(String),
Ident(String),
List(Vec<StarlarkValue>),
Dict(Vec<(String, StarlarkValue)>),
Call { func: String, args: Vec<KwArg> },
}
impl StarlarkValue {
pub fn str(s: impl Into<String>) -> Self {
Self::Str(s.into())
}
}