Skip to main content
Skip table of contents

Syntax and features

Expressions

The language works by processing expressions. The processing occurs in the order they are listed, unless certain special operators are used. An ASTER script can contain any number of expressions, separated by the semicolon operator - ;

The result of the last processed expression is also the end result, returned as the script execution result.

Source code comments are supported - starting with # and running until the end of line

Please note that ; is not, contrary to some other languages, used to signal an end of statement, but to separate expression into smaller, sequenced blocks. The only exception is - for convenience - the finishing ; after the last expression on the script.

Assignment operation is also an expression, just with some side effects. The assignment expression A=2 evaluates to 2, and also sets the variable A in current context to the value 2.

Example script

CODE
A="Hello"; B="World"; # this is a comment, runs until the end of line
C=UCHAR(32); D=UCHAR(11*3); # UCHAR assigns a character based on the 32 bit Unicode map
A&C&B&D

Running the above script produces the well known result.

image-20250319-202151.png

Basic operations

Core ASTER language provides a set of typical operations useful in writing a computer script or program. This is (and should be) similar to what one can observe in other popular programming languages.

  • Assignment operation =

  • Arithmetic: + - * / % with standard precedence (e.g. 2+2*2 = 6) and with support for grouping by parenthesis ()

  • In-place arithmetic operators += -= *= /= %= &=

  • String concatenation: & operator "A"&2 → "A2"

  • Numeric comparison: > >= < <= ==

  • String/text comparison: $> $>= $< $<= $==

  • Composite value comparision: EQL IN

  • Boolean logic: AND OR XOR NOT NOR with proper precedence

  • Boolean logic short circuiting operators |AND and |OR for smart flow control

  • Assignment operator =

  • Indexing access operators: [] and \

  • Dynamic symbol name operator {}

  • Evaluation separation operator ;

  • List collection operator / function argument separation ,

In addition to typical binary application of the operators, operator - may be used in unary context. The operator NOT works only in unary context.

Examples

CODE
2+2                        # Evals to 4
2*2                        # Evals to 4
2/2                        # Evals to 1
2-2                        # Evals to 0
"A" & "B"                  # Evals to "AB"
15 > 20                    # Evals to ' ' - single space represents false value
1.5 > -2                   # Evals to 'X' - single X represents true value
NOT (5 > 10)               # Evals to 'X' - single X represents true value
15;20                      # Evals to 20 - value of last instruction is taken into account
{"A"}                      # Evals to variable A and eventually it's value
A=2                        # Evals to 2, and result of evaluation is assigned to variable A

Variables

Variables are identified by user-defined names consisting of letters, digits and underscore _ symbol.

Variables are dynamically typed, being able to represent scalar values (strings and numbers) and indexed lists. List items are variables themselves, allowing to build multi-dimensional arrays by using multiple indexing access operators. Read more about it in the Data types section.

There is no technical difference between strings and numbers. Attempt to call mathematical operations on strings that do not convert to numbers will result in an error.

Variable names are case insensitive.

Allocation and garbage collection

Memory for variables and tables is automatically allocated. Once the variable is unset or goes out of scope, system runtime will notice the data is no longer referenced and reclaim the memory as needed. This is known as garbage collection.

Examples

TEXT
A="B"                       # String assignment
X=2                         # Numeric assignment
D="abc!@#"                  # Special characters in strings
A=(1,2,3,4)                 # Flat list initialization
B[1]=0; B[2]=1              # Table initialization
A[1][2]                     # Nested access - mutli-dimensional array access
UNSET(A[2])                 # List element removal

Function system

ASTER enables usage of system and user defined functions for data processing. Standard function library provides basic string and mathematical operations, topped by POSIX compatible regular expressions and XML operations based on version 1.0 of XPath.

Function are used by providing a symbol representing the function name, or using a dynamic symbol operator {}, followed by open parenthesis (, parameters and completed by ). Parameters are separated by , operator.

Function names are case-insensitive.

Examples

CODE
POWER(2,3)                   # Evaluates to 8, as 2^3=8
{LOWER("PO")&"wEr"}(2,3)     # Also evaluates to 8, equivalent to the above
SUBstr("Text",1,2)           # Evaluates to 'ex'
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.