KRASCHE
&
BYRNE
         ELZED  HOME       NEWS       DOCS       DOWNLOADS       LICENSING       SUPPORT       FAQ       ABOUT  US

What's An Elzed?
Features
Licensing
Downloads
Documentation
Elzed News
    ELZED 
 Documentation 
 Core Concepts 

Expressions

The grist for Elzed's mill. An expression can be a simple as 2+2 or as complicated as the life game; Elzed treats both as single expressions.

Expressions consist of operators, operands, punctuation, and white space.

Operators come in two varieties: internal and external. The internal operators like addition, the trig functions, and so forth, are built into Elzed. External operators are added by you.

Operands are both processed and emitted by operators. In the expression tan( x ), operator "tan" processes operand "x". The operator emits the answer as another operand, making more complicated expressions like arctan( tan( x ) ) possible.

Two punctuation marks are used. Commas are used to separate operands in a parameter list, as in max( 1, tan( x ) ). Semi-colons are used to join expressions together to form larger expressions. Consider this expression:

x = 0; y = 0

The above expression would not parse without the semi-colon, as the parser would not know how to interpret "0 y". Operands must be separated by a comma or by an operator. By using a semi-colon to join the expressions "x = 0" and "y = 0", a larger expression can be formed. Now consider this more complex expression:

if ( scratch[ x, y ] == 1 ) then
 replace( board[ y ], "X", x, 1 );
else
 replace( board[ y ], " ", x, 1 );
end

Note that the three sections of text joined by the two semi-colons are each expressions in their own right -- each would parse successfully even if the others were not present. The three together, however, would not parse unless joined by the semi-colons.

Finally, white space is used to make an expression more readable. Consider what the following expression would look like without tabs, newlines, and spaces:

x = 0; y = 0;

while ( y < 16 ) do
 x = 0;

 while ( x < 16 ) do

  if ( scratch[ x, y ] == 1 ) then
   replace( board[ y ], "X", x, 1 );
  else
   replace( board[ y ], " ", x, 1 );
  end

  x++;
 next

 y++;
next

It would look like this:

x=0;y=0;while(y<16)do x=0;while(x<16)do if(scratch[x,y]==1)then replace(board[y],"X",x,1);else replace(board[y]," ",x,1);end x++;next y++;next

Yikes! Not pretty. Notice, however, that there are still a few spaces left in the ugly example above, between "do" and "if", and between "then" and "replace". Parsing would fail without these spaces, because the resulting "doif" and "thenreplace" would not be recognized.



  Copyright  ©  MMXXIV  by  R R Le Cropane   •   All Rights Reserved   •   Terms of Use   •   Privacy Policy