libbbb - rexscript

Home

Provides a simple, regular expression-based script interpreter. The implementation provides the list of files to process in the constructor and a list of predefined variables, then calls start().

The interpreter does not run inside the start() call; instead, a timer is started that interprets one line on each tick. The frequency of the timer is adjustable from the script file using the Frequency command.

rexscript provides some basic commands, like including other files, controlling verbosity and manipulating variables (see full list), but for the most part the user is expected to implement what it needs.

Access to variables is provided using the special ${markers} to get the values and variable names for some special functions.

  • SET assigns a value to a variable and may be used to clear it when no argument is provided
  • APPEND adds a value to the array
  • SPAN divides a block of text based on provided pattern and assigns the result to a variable.

Variables are implemented using varmap library, so they all are arrays of strings. Following examples are all valid:

 1 # replaced by first value in the array
 2 {{ var_name }}
 3 {{ var_name[0] }}
 4 {{ var_name[first] }}  
 5 # replaced by second value in the array
 6 {{ var_name[1] }}
 7 {{ var_name[second] }}   
 8 # replaced by last value in the array
 9 {{ var_name[-1] }}
10 {{ var_name[last] }}
11 # replaced by third value in the array
12 {{ var_name[2] }} 

Content of the array may be glued into a single construct like so:

 1 # simply glue them, no marker between
 2 {{ var_name.join() }}
 3 # glue using a single space
 4 {{ var_name.join( ) }}
 5 {{ var_name.join(\s) }}
 6 # glue them with new lines or tabs between
 7 {{ var_name.join(\n) }}
 8 {{ var_name.join(\t) }} 
 9 # glue with some text
10 {{ var_name.join(some text) }} 

As part of the initialisation, RexScript copies environment variables as internal variables, so they are readly available to control files (platform specific separators like ";" on Windows and ":" in unixes are used to split the value into components). Note that changing these values has no effect on the actual environment - use dedicated method to set them.

Depedencies:

Related source code documentation: RexScript, RexScriptBlock

Home