askill
ordo-expression-syntax

ordo-expression-syntaxSafety --Repository

Ordo expression syntax quick reference. Includes comparison operators, logical operators, built-in functions, conditional expressions, field access syntax. Use for writing rule conditions, calculating output values, data transformation.

32 stars
1.2k downloads
Updated 1/28/2026

Package Files

Loading files...
SKILL.md

Ordo Expression Syntax

Operators

Comparison Operators

OperatorDescriptionExample
==Equalstatus == "active"
!=Not equalstatus != "banned"
>Greater thanage > 18
>=Greater or equalbalance >= 1000
<Less thanprice < 100
<=Less or equallevel <= 5

Logical Operators

OperatorDescriptionExample
&&Andage >= 18 && active == true
||Orvip == true || points > 1000
!Not!is_blocked

Arithmetic Operators

OperatorDescriptionExample
+Additionprice + tax
-Subtractiontotal - discount
*Multiplicationquantity * price
/Divisiontotal / count
%Moduloindex % 2

Field Access

Dot Notation

user.name
user.profile.level
order.items[0].price

Array Indexing

items[0]
matrix[1][2]
users[index]

Safe Access (coalesce)

coalesce(user.nickname, user.name, "Anonymous")

Built-in Functions

String Functions

FunctionDescriptionExample
len(s)String lengthlen(name) > 0
upper(s)To uppercaseupper(code) == "VIP"
lower(s)To lowercaselower(email)
trim(s)Trim whitespacetrim(input)
starts_with(s, prefix)Prefix matchstarts_with(url, "https")
ends_with(s, suffix)Suffix matchends_with(file, ".pdf")
contains_str(s, sub)Contains substringcontains_str(desc, "urgent")
substring(s, start, end)Extract substringsubstring(code, 0, 3)

Math Functions

FunctionDescriptionExample
abs(n)Absolute valueabs(diff) < 0.01
min(a, b, ...)Minimummin(price, max_price)
max(a, b, ...)Maximummax(0, balance)
floor(n)Floorfloor(rating)
ceil(n)Ceilingceil(price)
round(n)Roundround(average)

Array Functions

FunctionDescriptionExample
len(arr)Array lengthlen(items) > 0
sum(arr)Sum of arraysum(prices) >= 100
avg(arr)Averageavg(scores) > 60
count(arr)Element countcount(orders)
first(arr)First elementfirst(results)
last(arr)Last elementlast(history)

Type Functions

FunctionDescriptionExample
type(v)Get typetype(value) == "string"
is_null(v)Is nullis_null(optional)
is_number(v)Is numberis_number(input)
is_string(v)Is stringis_string(data)
is_array(v)Is arrayis_array(items)

Conversion Functions

FunctionDescriptionExample
to_int(v)To integerto_int(str_num)
to_float(v)To floatto_float(price)
to_string(v)To stringto_string(code)

Time Functions

FunctionDescriptionExample
now()Current timestamp (seconds)now() - created_at > 86400
now_millis()Current timestamp (milliseconds)now_millis()

Conditional Expressions

if-then-else

if condition then value1 else value2

Examples:

if exists(discount) then price * (1 - discount) else price
if vip == true then 0.2 else 0.05
if age >= 18 then "adult" else "minor"

exists Check

if exists(user.nickname) then user.nickname else user.name

Nested Conditions

if tier == "gold" then 0.2
else if tier == "silver" then 0.1
else 0.05

Literals

Numbers

42          # Integer
3.14        # Float
-100        # Negative

Strings

"hello"
"it's ok"
"line1\nline2"

Booleans

true
false

Null

null

Rust API

Parsing Expressions

use ordo_core::prelude::*;

let parser = ExprParser::new();
let expr = parser.parse("age >= 18 && status == \"active\"")?;

Evaluation

let evaluator = Evaluator::new();
let context = Context::from_json(r#"{"age": 25, "status": "active"}"#)?;
let result = evaluator.eval(&expr, &context)?;

Compile to Bytecode

let compiler = ExprCompiler::new();
let compiled = compiler.compile(&expr)?;
let vm = BytecodeVM::new();
let result = vm.execute(&compiled, &context)?;

Key Files

  • crates/ordo-core/src/expr/parser.rs - Expression parser
  • crates/ordo-core/src/expr/eval.rs - Expression evaluation
  • crates/ordo-core/src/expr/functions.rs - Built-in functions
  • crates/ordo-core/src/expr/ast.rs - AST definitions

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

AI review pending.

Metadata

Licenseunknown
Version-
Updated1/28/2026
PublisherPama-Lee

Tags

api