Enum jrsonnet_parser::Expr
source · pub enum Expr {
Show 22 variants
Literal(LiteralType),
Str(IStr),
Num(f64),
Var(IStr),
Arr(Vec<LocExpr>),
ArrComp(LocExpr, Vec<CompSpec>),
Obj(ObjBody),
ObjExtend(LocExpr, ObjBody),
Parened(LocExpr),
UnaryOp(UnaryOpType, LocExpr),
BinaryOp(LocExpr, BinaryOpType, LocExpr),
AssertExpr(AssertStmt, LocExpr),
LocalExpr(Vec<BindSpec>, LocExpr),
Import(LocExpr),
ImportStr(LocExpr),
ImportBin(LocExpr),
ErrorStmt(LocExpr),
Apply(LocExpr, ArgsDesc, bool),
Index(LocExpr, LocExpr),
Function(ParamsDesc, LocExpr),
IfElse {
cond: IfSpecData,
cond_then: LocExpr,
cond_else: Option<LocExpr>,
},
Slice(LocExpr, SliceDesc),
}
Expand description
Syntax base
Variants§
Literal(LiteralType)
Str(IStr)
String value: “hello”
Num(f64)
Number: 1, 2.0, 2e+20
Var(IStr)
Variable name: test
Arr(Vec<LocExpr>)
Array of expressions: [1, 2, “Hello”]
ArrComp(LocExpr, Vec<CompSpec>)
Array comprehension:
ingredients: [
{ kind: kind, qty: 4 / 3 }
for kind in [
'Honey Syrup',
'Lemon Juice',
'Farmers Gin',
]
],
Obj(ObjBody)
Object: {a: 2}
ObjExtend(LocExpr, ObjBody)
Object extension: var1 {b: 2}
Parened(LocExpr)
(obj)
UnaryOp(UnaryOpType, LocExpr)
-2
BinaryOp(LocExpr, BinaryOpType, LocExpr)
2 - 2
AssertExpr(AssertStmt, LocExpr)
assert 2 == 2 : “Math is broken”
LocalExpr(Vec<BindSpec>, LocExpr)
local a = 2; { b: a }
Import(LocExpr)
import “hello”
ImportStr(LocExpr)
importStr “file.txt”
ImportBin(LocExpr)
importBin “file.txt”
ErrorStmt(LocExpr)
error “I’m broken”
Apply(LocExpr, ArgsDesc, bool)
a(b, c)
Index(LocExpr, LocExpr)
a[b]
Function(ParamsDesc, LocExpr)
function(x) x
IfElse
if true == false then 1 else 2