Show Menu


import subscript.language
import subscript.Predef._
Top-level imports required in all SubScript sources.
script a = expr
Script definition
  a = expr
  b = expr
Shorthand script definition
Run scripts like this
[ expr ]
Priori­tizing Parent­heses (like "­()" in "2 - (1 + 3)", just for scripts)
[** expr **]
Launch Anchor
[* expr *]
@a: b
@{prin­tln­(th­ere)}: a
Also annota­tion. There points to the annotated expression node
var x: Int = 3
Variable declar­ations are possible in scripts
let scala_expr
Executes scala_expr as a tiny code fragment.

Sequential Operators

a ; b
Executes next operator as soon as current one has success
a b
Same as above
Same as above

Parallel Operators

a && b
Non-strict and-pa­ral­lelism. Succeeds iff all its operands do. On failure of one of the children terminates without success immedi­ately.
a & b
Strict and-pa­ral­lelism. Same as above, but if some of its children doesn't have success, it waits for the rest of the children to execute before termin­ating.
a || b
Non-strict or-par­all­elism. Succeeds iff at least one of its children does. After a children succeeds, it terminates immedi­ately with success.
a | b
Strict or-par­all­elism. Same as above, but waits for the rest of the children after one succeeds. Has success immedi­ately after at least one child succeeds (termi­nation and success are not the same things).

Result Values

From Scala code, returns the result value of script­_name script, as Try[Any].
From SubScript code, sets the result of the parent script to that of a. E.g. in script foo = a^ b c, script foo will have a result of a. b and c are still executed as usually.
The result of the parent script becomes a Seq[Any]. The result of a is recorded into that Seq at the index equal to a's current pass (that is, first pass in a loop will go to index 0, second - to 1 etc).
The result of the parent script becomes a tuple. a's result is recorded at int_li­teral-th position to the tuple. E.g. a^^1 b^^2 will result in a tuple with _1 set to a's result and _2 - to b's result.
Sets the result of the parent script to literal. E.g. ^5, ^"Fo­o", ^'x'.
Sets the result to Seq[Any], records literal under its pass's index.
Sets the result to a tuple, places this literal under int_li­teral-th position in this tuple.

Scala Code Blocks

{! scala block !}
Normal code block. Activa­tion, Execution, Deacti­vation.
{: scala block :}
Tiny code block. Execution on Activa­tion.
{. scala block .}
Event-­han­dling code block. Does not execute automa­tic­ally, need manual execution.
{* scala block *}
Threaded code block. Executes from a new thread (all the other blocks execute from Script Executor's thread).

Special Operands

Epsilon, or empty action. Has success immedi­ately after activa­tion.
Delata, or deadlock. Terminates without success immedi­ately after activa­tion.
Loop. When used as an operand to a sequence, loops the sequence. E.g. a b ... executes in order "a b a b a b" etc as an infinite loop. a ... b and ... a b have same effect.
Break. Breaks activation of its parent operator.
Optional break. Behaves like break, but resumes activation after an action happened in an operand activated before itself.
Optional break loop. Mixes together break? and ... .

Altern­ative Operators

a + b
Choice. Starts with a and b activated. When either starts executing, excludes another.
a / b
Disruption. Executes a until b starts, then excludes (termi­nates) a and continues with b. If a gets terminated without b ever getting started, excludes b.

Condit­ional Operators

if scala_expr then expr else expr
Executes then part if scala_expr is true, otherwise - else part.
do expr then expr else expr
Executes do part first. If it has success, executes then part, otherwise - else part.


a ~~(x: T)~~> b
Dataflow. Executes a, casts its result to type T, assigns it to x and executes b with x in scope.
a ~~(x: T)~~> b
+~/~(x: E)~~> c
Dataflow with an extra clause to handle except­ions. If a succeeds, the behaviour is as in the case above. Otherwise, an exception with which a failed is casted to E (which must be <: Throwable) and handled by c. Like catch in try-catch.
a ~~(x: T)~~> b
+~~(y: A)~~> c
+~~(z: B)~~> d
Dataflow can arbitrary number of result­-ha­ndling clauses and except­ion­-ha­ndling clauses.
a ~~(x: T)~~^ scala_expr
+~~(x: A)~~^ scala_expr
Dataflow map. Similar to Dataflow, but runs the result of a through a given scala_expr and sets the result of it as the result of the parent script.
a ~~^ f
Shorthand for a ~~(x: T)~~^ f(x).


No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Regular Expressions Cheat Sheet
          PHP Cheat Sheet
          Python Cheat Sheet