-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
finalize syntax & set of supported operators #9
Comments
Here is the lastest Rust schema from @expede pub enum Term {
Literal(Json), // FIXME only JSON? Because we need a way to inspect CIDs + Bytes
Variable(Variable), // ?x
Args, // Special `$` variable
Select(Vec<Index>), // e.g. `.foo..bar.[]`
Not(Box<Term>),
And(Vec<Term>),
Or(Vec<Term>),
Equal(Value, Value),
GreaterThan(Value, Value),
GreaterOrEqual(Value, Value),
LessThan(Value, Value),
LessOrEqual(Value, Value),
Match(Variable, String),
// Future
Every(Variable, Variable), // forall x in domain
}
pub struct Variable(String);
pub enum Value {
Literal(Json),
Variable(Variable)
}
pub enum Index {
RecDesend, // ..
FlattenAll, // .[]
Index(usize), // .[2]
Key(String), // .key
}
pub enum Json {
Null,
Bool(bool),
Float(f64),
Integer(i128), // Only up to 2^53 (IEEE 754), not libipld's i128? 🤔
String(String),
Array(Vec<Json>),
Object(BTreeMap<String, Json>),
} |
Updated from other discussions today: #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum Term {
// Leaves
Args, // $
Literal(Ipld),
Variable(Variable),
Selector(Selector),
// Connectives
Not(Box<Term>),
And(Vec<Term>),
Or(Vec<Term>),
// Comparison
Equal(Value, Value),
GreaterThan(Value, Value),
GreaterOrEqual(Value, Value),
LessThan(Value, Value),
LessOrEqual(Value, Value),
// String Matcher
Glob(Value, String),
// Existential Quantification
Exists(Variable, Collection), // ∃x ∈ xs
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Variable(String); // ?x
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum Collection {
Array(Vec<Ipld>),
Map(BTreeMap<String, Ipld>),
Variable(Variable),
Selector(Selector),
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Selector(Vec<Index>); // .foo.bar[].baz
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum Index {
RecDesend, // ..
FlattenAll, // .[]
Index(usize), // .[2]
Key(String), // .key
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum Value {
Literal(Ipld),
Variable(Variable),
ImplicitBind(Selector),
} I'll probably write a version with sugar (e.g. implicit bind) and a lower one that it desugars to, but this is the high level interface for now |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Forking discussion around which operators do we want to support and how the overall syntax looks like here also
The text was updated successfully, but these errors were encountered: