Skip to main content

Types of expressions

PSLang supports the following types of expressions:

Operation

Description

< string literal >

string literal

< integer literal >

integer literal

- < integer literal >

negate an integer

< floating-point literal >

floating-point literal

- < floating-point literal >

negate a floating-point literal

$var

the value of the variable

$var[expr]

string and array indexing

(expr)

for clarity or to change order of evaluation

expr + expr

addition or string concatenation

expr - expr

subtraction

expr * expr

multiplication

expr ∕ expr

division

expr % expr

modulus

expr isin expr

is left a substring of right?

expr == expr

equality

expr ! = expr

inequality

expr ≤ expr

left is less than or equal to right?

expr < expr

left is less than right?

expr ≥ expr

left is greater than or equal to right?

expr > expr

left is greater than right?

~expr

bitwise negation

expr & expr

bitwise and

expr — expr

bitwise or

expr && expr

logical and

expr—— expr

logical or

$var++

post increment operator

$var–

post decrement operator

! expr

logical negation

func(...)

function call

iif( test , true _ part , false _ part)

ternary operator

A boolean expression yields an integer result, where zero is interpreted as false , and any value other than zero is interpreted as true .

Bitwise operators (~, &, —) must not be confused with logical operators ( ! , &&, ——). Although PSLang does not support “^”, the bitwise exclusive or operator (xor), you can achieve the same results using: (A & ~B ) | ( ~A & B ).

The PSLang + operator can be used with numerical values, or to append string values. In an expression such as x+y, where x is a string and y is a number, y is converted to a string and appended to x.

The ternary operator works the same way as the C++ ternary operator ( ?: ). The test expression is evaluated, and if the result is non-zero, the true _ part expression is evaluated and returned. Otherwise, the false _ part expression is evaluated and returned.