What are the Literals in YAQL ?
Fixed values which is used in YAQL expressions. Below are the literals available in YAQL.
Data type
| Description
|
Integer literals |
150, 230 |
Floating literals |
1.25, 2.0 |
Boolean and null literals |
true, false , and null |
String literals |
Enclosed in either single(') or double(") quotes: 'abc' or "abc" The backslash character is used for escape character. |
Verbatim strings |
Enclosed in back quotes: 'abc', are used to suppress escape sequence. |
How Data can be accessed in YAQL?
- $variable, $ in YAQL are used to access the data.
- Stored data in variables like $1, $2 and so on. $ stands for $1.
- Data is placed into the variables which are accessible in YAQL expression as $.
- Accessing variable is $variable_name, where variable_name is the name of the variable.
- Variable name can be empty, use $ to access the variable for this case.
- YAQL function arguments can aslo be accessed using $
- When yaql parser encounters $variable, translates to #get_context_data($variable) automatically. #get_context_data function returns the variable data in the current context.
What are the Operators in YAQL?
YAQL supports both binary and unary operators. List of available operators are not fixed and can be modified in the host.
What are the binary operators available in YAQL?
Operators
| Description
|
Arithmetic operators |
+, -, *, /, mod |
Comparison operators |
=, !=, >, <, <=, >= |
Logical operators |
and, or |
Method / Member access |
., ?. |
Regex operators |
=~, !~ |
Context Passing operator |
-> |
Membership operator |
in |
What are the unary operators available in YAQL?
Operators
| Description
|
Math operators |
+, - |
Logical operators |
not |
YAQL Data Structures:
Data Type
| Description
|
Scalars |
string, int, float, boolean, datetime and timespan. |
Lists |
$list = [1, 2.0, value, true]
List elements can be accessed by index $list[0]. |
Dictionaries |
$dict = {key1 => value1, key2 => value2, key3 => value3}
Dictionaries are indexed by keys $dict[key1].
Exception is raised, if key is missing in the dictionary.
,br/>In get method, can also specify default value to be returned if key is missing in the dictionary $dict.get(key, defaultValue)
Key can be accessed like $.key iterating the dictionary |
Sets |
$set-variable = set(value1, value2, value3) |
Function and different types:
- Almost everything is a function call(explicit or implicit). and function may be overridden in the host.
- Function calls syntax: functionName(functionArguments)
- There are two types of arguments.
- Positional arguments : functionName(val1, val2, val3)
- Named arguments : functionName(argName1 => value1, argName2 => value2)
- Function is also called with any types of arguments. functionName(val1, argName2 => val2)
- There are three types of functions supported in YAQL.
- explicit function can be called in expressions.
- implicit (system) function: functions with predefined names that get called upon some operations. Example 5+3 is translated to #operator_+(5, 3), in this case #operator_+ is name of the implicit function.
« Previous
Next »