Expression Syntax

    Expression strings consist of an arbitrary number of initial assignments followed by a last subexpression that provides the evaluation result.

    An assignment sets a variable to the evaluation result of a subexpression. This variable can later be used to reference this result. The assignment syntax is:

    
    <identifier> = <subexpression>;

    {primary} Note the ending ';' character.

    Examples for assignments

    
    x = 2;
    y = x + 8;
    z = f(x,y) + g(x,y);

    where f and g are predefined functions .

    An expression is an optional sequence of assignments followed by a subexpression providing the evaluation result:

    
    <identifier1> = <subexpression1>;
    <identifier2> = <subexpression2>;
    ...
    <identifierN> = <subexpressionN>;
    <result subexpression>

    where N can also be zero in which case the expression coincides with the result subexpression.

    Here is an example with assignments:

    
    a = f(2,3);
    b = g(4,5);
    x = a + b;
    x*x

    Here is the same without assignments:

    
    (f(2,3) + g(4,5))*(f(2,3) + g(4,5))

    Assignments increase efficiency if the same evaluation result is used more than once since inline repetition of a subexpression results in multiple evaluation. Assignments can also be used to increase readability. However, in most cases, when the expression is simple, assignments are not needed. Note, that whitespace characters (new-line, tab, space) are skipped when parsing the expression string, so whitespace characters can be freely used for increasing readability.

    The following examples demonstrate the expression syntax with very simple subexpressions.

    Further examples

    1. A simple expression:

      
      3+2
    2. Using assignments:

      
      x = 2;
      y = 3;
      x + y
    3. A more complicated one:

      
      x = 2;
      y = 3;
      z = 8*(x + y);
      t = 6*x*y;
      z + t
    4. When the same value is used more than once:

      
      x = (3 + 4)*8 + 16;
      y = 3*x;
      z = x + 20;
      5*(y + 8) + 4*z

      Examples with chemical meaning are shown later for matching conditions, chemical calculations and chemical and general purpose functions.