Version: dev

expr

Stable type · Expressions

Tier: stable · Kind: type · Topic: Expressions

JuliaTypeScriptPythonRustGo
not exportednot exportedExprExprnot exported

Julia

Julia does not export this type.

TypeScript

TypeScript does not export this type.

Python

Expr = Union[int, float, str, ExprNode]

An expression (esm-spec §4): a numeric literal (int or float), a variable or parameter reference (str), or an operator node (ExprNode ) whose args are themselves expressions.

Source

Rust

pub enum Expr {
    Integer(i64),
    Number(f64),
    Variable(String),
    Operator(Arc<ExpressionNode>),
}

impl Expr { pub fn to_unicode(&self) -> String }

impl Expr { pub fn operator(node: ExpressionNode) -> Expr }

impl Expr { pub fn node_mut(&mut self) -> Option<&mut ExpressionNode> }

Mathematical expression: a number literal, variable reference, or operator node.

Per discretization RFC §5.4.1, integer and float literals are distinct AST node kinds. On the wire (§5.4.6 round-trip parse rule), a JSON-number token containing ., e, or E deserializes to Expr::Number; a token matching the integer grammar -?(0|[1-9][0-9]*) deserializes to Expr::Integer. The hand-written Deserialize impl below dispatches on the incoming JSON token type directly, which is what an #[serde(untagged)] derive would decide by trying Integer before Number: strict integer JSON tokens bind to Integer, float tokens to Number.

Source · Rust docs

Go

Go does not export this type.