pub enum Term<S> {
Show 18 variants
Id,
Recurse,
Num(S),
Str(Option<S>, Vec<StrPart<S, Self>>),
Arr(Option<Box<Self>>),
Obj(Vec<(Self, Option<Self>)>),
Neg(Box<Self>),
Pipe(Box<Self>, Option<Pattern<S>>, Box<Self>),
BinOp(Box<Self>, BinaryOp, Box<Self>),
Label(S, Box<Self>),
Break(S),
Fold(S, Box<Self>, Pattern<S>, Vec<Self>),
TryCatch(Box<Self>, Option<Box<Self>>),
IfThenElse(Vec<(Self, Self)>, Option<Box<Self>>),
Def(Vec<Def<S, Self>>, Box<Self>),
Call(S, Vec<Self>),
Var(S),
Path(Box<Self>, Path<Self>),
}Expand description
Function from value to stream of values, such as .[] | add / length.
Variants§
Id
Identity, i.e. .
Recurse
Recursion (..)
Num(S)
Integer or floating-point number
Str(Option<S>, Vec<StrPart<S, Self>>)
String
This consists of an optional format filter starting with @ (such as @text),
followed by quoted string parts (such as "Hello, \(.name)! \u263A").
Arr(Option<Box<Self>>)
Array, empty if None
Obj(Vec<(Self, Option<Self>)>)
Object, specifying its key-value pairs
Neg(Box<Self>)
Negation
Pipe(Box<Self>, Option<Pattern<S>>, Box<Self>)
Application, i.e. l | r if no string is given, else l as $x | r
BinOp(Box<Self>, BinaryOp, Box<Self>)
Sequence of binary operations, e.g. 1 + 2 - 3 * 4
Label(S, Box<Self>)
Control flow variable declaration, e.g. label $x | ...
Break(S)
Break out from control flow to location variable, e.g. break $x
Fold(S, Box<Self>, Pattern<S>, Vec<Self>)
reduce and foreach, e.g. reduce .[] as $x (0; .+$x)
TryCatch(Box<Self>, Option<Box<Self>>)
try and optional catch
IfThenElse(Vec<(Self, Self)>, Option<Box<Self>>)
If-then-else
Def(Vec<Def<S, Self>>, Box<Self>)
Local definition
Call(S, Vec<Self>)
Call to another filter, e.g. map(.+1)
Var(S)
Variable, such as $x (including leading ‘$’)
Path(Box<Self>, Path<Self>)
Path such as .a, .[][]."b", f[0]