Skip to content

Predicate syntax

Maciej Klemarczyk edited this page Oct 22, 2021 · 8 revisions

Syntax tokens

  • { - Predicate opening
  • } - Predicate closing
  • , - Argument separator
  • $data - External variable
  • \ - Token escape, treats syntax characters as part of the text

Available predicates

Binary predicates

  • HasFlag - checks that number contains binary flag (LeftArg & RightArg == RightArg)

Equality predicates

  • = - equals, two arguments are equal

Comparison predicates

  • < - less than, first argument is less than second argument
  • > - greater than, first argument is greater than second argument
  • <= - less than or equal, first argument is less than or equal to second argument
  • >= - greater than or equal, first argument is greater than or equal to second argument

Conditional logical predicates

  • NOT - inverts logical value, changes True to False, and False to True
  • OR - combines two or more predicates, where one of predicates has to be True
  • AND - combines two or more predicates, where all of predicates has to be True

Text predicates

  • IN - sub-text is part of text, second argument contains first argument

Variables

The variable syntax allows to inject value during evaluation

Array index

The array index syntax allows to access value from the array

Example

  • $users[4] - access the user under index 4 and use it for evaluation
  • $items[12][31] - access the items under index 31 of item under index 12 and use it for evaluation

Binary direct access

The array index syntax allows to access single bit from a numeric types

Example

  • $permission[3] - access the 4th bit counting from the right, for number 43 (101011) it will return 1

Examples

  • {=, 31, 41} - Number 31 is equal to number 41
  • {=, $data, 12\,33\, 12} - Value of $data is equal to text 12,33, 12
  • {=, $data, 41} - Value of $data is equal to number 41
  • {AND, {=, $data, 42}, {=,$user,11}} - Value of $data is equal to number 42 and value of $user is equal to number 11
  • {OR, {=, $data, 42}, {=,$user,11}} - Value of $data is equal to number 42 or value of $user is equal to number 11

Note

All comparisons are done using string type. Next version expects to compare values using type specific methods. The comparison for the NOT operator ignores the case of characters.

Clone this wiki locally