»»»Home «««
Framework
Screenshots
FAQ
»»»TELL «««
Types
Operators
Functions
Example
»»»Toped «««
Database
Cells
Add
Select
Edit
Properties
Rendering
GUI
Miscellaneous
»»»Ifaces «««
GDSII
OASIS
CIF
DRC

Operators

Arithmetic

TELL has following arithmetic operators defined so far

Table 1. Arithmetic operators

operator Description
- Unary minus, subtraction
+ Addition
* Multiplication
/ Division

Operators listed above works in the expected fashion for int and real types. The same concern their order of precedence. It is more interesting to define how they work over point and box types. The behavior given in the table below is just a wild guess until better idea pops up. TELL should define a list of special operators working with those types. Not all of the operations described below are implemented.

Table 2. Addition/subtraction operators with box and poly types

+ / - real/int point box
real/int arithmetic ? ?
point shift shift ?
box blow/shrink shift or / or not

Table 3. Multiplication/division operators with box and poly types

* / real/int point box
real/int arithmetic ? ?
point scale ? ?
box scale ? and / and not

top

Relational and Logical

Operators below are implemented for int, real and bool. For the rest of the types they are not allowed for the moment

Table 4. Relational operators

operator Description
> Greater than
>= Greater than or equal
< Less than
<= Less than or equal
== Equal
!= Not equal

top

Assignment

Assignment operator is = and it works in the expected way. The only reminder here is that TELL maintains strict type checking. Internal silent conversion is provided only from int to real. For lists and structures assignment see variable initialization

top

Member operator

The . (dot) operator is used to access the individual fields of the build-in and user defined structures. The dot operator is applied to a variable and must be followed by a valid field name. Struct members accessed using a member operator can be used exactly as any other TELL variable.

   box source_area;
   source_area.p1 = {0,0};
   source_area.p2 = {source_area.p1.x + 2.6 , source_area.p1.y + 1.6};

   struct circle { point center; real radius };
   circle c1;
   c1.center = source_area.p2;
   c1.radius = source_area.p2.x - source_area.p1.x;

top

List operations

Lists can be defined from any of the build-in or user types in TELL. They are homogeneous, their length is dynamic and limited only by the available memory. Empty lists are perfectly legal. One can think for TELL lists as for dynamic length arrays.

Indexing

It looks and works as a traditional array indexing. Indexes start at 0, thus a list of (say) 5 points will have indexes from 0 to 4. Reference to an unexisting component will trigger runtime error Invalid index.

   point list p1 = {{0,0},{2,0},{2,1},{1,1},{1,2},{0,2}};
   point list p2 = {{100,100},{102,100},{102,101},{101,101}};
   p2[0] = p1[5];
   p2[1] = p1[4];
   p2[2] = p1[3];
   p2[3] = {100,90};

top

Add/Insert

A component can be added to or inserted into a list using the operators below. The symbols +: and :+ determine whether to insert before or after the target index. If target index is omitted, then they determine whether to insert the component in the beginning of the list or to add it at the end.

[Tip]Add/insert operator

listvar[<index>:+] = <init> - insert a component with value <init> after index

listvar[+:<index>] = <init> - insert a component with value <init> before index

listvar[:+] = <init> - add a component to the end of the list

listvar[+:] = <init> - add a component to the beginning of the list

The examples below demonstrate the use of add/insert operator

   int list alst = {1,2,3,4,5};

   alst[+:] = 0;        // push front
   //alst[+:0] = 0;     // same as above
   alst[:+] = 6;        // push back
   //alst[5:+] = 6;     // same as above

   alst[3:+] = 33;      // insert 33  after  the 3rd component
   alst[+:3] = -33;     // insert -33 before the 3rd component

top

List union

Add/insert operators will take also a list as an rvalue. This produces not only a simple list union, but is also capable of inserting a list anywhere into another list.

[Tip]List union operator

listvar[<index>:+] = <var_list> - insert the list <var_list> after <index>

listvar[+:<index>] = <var_list> - insert he list <var_list> before <index>

listvar[:+] = <var_list> - Add <var_list> at the end of listvar

listvar[+:] = <var_list> - Add <var_list> at the beginning of listvar

   alst[3:+] = { 33, 34, 35}; // insert the list  after  the 3rd component
   alst[+:3] = {-32,-33,-34}; // insert the list  before the 3rd component

top

Reduce/delete

A component can be removed from the list using the following operators. Note the semantic difference with :+ operator. Here if index is given, operators :- and -: execute the same operation

[Tip]Reduce/delete operator

comp = listvar[<index>:-] - remove the index-th component of the list

comp = listvar[-:<index>] - same as above

comp = listvar[:-] - remove the last component of the list

comp = listvar[-:] - remove the first component of the list

   echo(alst[-:3]); // remove the third component and print it
   echo(alst[4:-]); // remove the fourth component and print it
   alst[-:];        // remove the first from the list
   alst[:-];        // remove the last one

top

List slicing

Reduce/delete operators are removing a single component from the list. Slice operator is an extention, making possible to extract a number of consecutive components from a list.

[Tip]Slice operator

comp_list = listvar[<num>-:<index>] - removes <num> components ending with the index-th

comp_list = listvar[<index>:-<num>] - removes <num> components starting from the index-th

comp_list = listvar[:-<num>] - remove the trailing <num> components

comp_list = listvar[<num>-:] - remove the leading <num> components

   int list blst;
   echo(blst = alst[3-:]); // remove first 3 components and print them
   alst[:+] = blst[:-2];   // put last 2 of them at the back of the
                           // original list
   alst[:+] = alst[2-:];   // move first pair of components at the end
                           // of the list
   alst[5:-2]              // remove 5-th and 6-th component from the list
   alst[2-:5]              // remove 4-th and 5-th component from the list

top

List traversing

The foreach loop traverses the list and sets the loop variable to each element of the list in turn. The operator syntax is similar to the corresponding perl operator.

[Tip]foreach operator

foreach(<loop_var>; <list_var>) <block>

___________________________________________
loop_var
loop variable
list_var
List which is iterated
block
the cycle body which will be executed foreach of the list_var components
   foreach (int i; int list {5,4,3,2,1})
   {
      echo(i);
   };

top

Planar operators

This class of operators work on points. Only shift is implemented at the moment. The operation can be defined as follows

[Tip]shift operator

result = op1 <shift_operator> op2

result
has always the type of op1
op1, op2
Possible operand types are listed in table below
<shift_operator>
the operator itself - four directions defined, see below

Table 5. Shift operands

op1 \ op2 int point
point OK OK
box OK OK

The operator has the same precedence as arithmetic addition or subtraction. Four operators are defined. The idea behind the syntax choice is that the chars constitute an angle which points in the direction of the shift.

Table 6. Shift operators

operator Description
/| shift North East
|\ shift North West
\| shift South East
|/ shift South West

Some of the cases have direct arithmetic representation and the introduction of the shift operator can be seen as a syntactics sugar

Example 1. shift operators

   point a = {1,1};
   point a1;
   point a2;
   point a3;
   a1 = a /| 1;                  // will produce the same as
   a2 = {a.x + 1, a.y + 1}       // or
   a3 = a + 1;                   //
   //
   a1 = a |/ 1;                  // will produce the same as
   a2 = {a.x - 1, a.y - 1}       // or
   a3 = a - 1;                   //
   //
   a1 = a |\ 1;                  // will produce the same as
   a2 = {a.x - 1, a.y + 1}       //
   //
   a1 = a \| 1;                  // will produce the same as
   a2 = {a.x + 1, a.y - 1}       //
   //-------------------------------------------------
   point b = {1,2};
   a1 = a /| b;                  // will produce the same as
   a2 = {a.x + b.x, a.y + b.y}   // or
   a3 = a + b;                   //
   //
   a1 = a |/ 1;                  // will produce the same as
   a2 = {a.x - b.x, a.y - b.y}   // or
   a3 = a - b;                   //
   //
   a1 = a |\ 1;                  // will produce the same as
   a2 = {a.x - b.x, a.y + b.y}   //
   //
   a1 = a \| 1;                  // will produce the same as
   a2 = {a.x + b.x, a.y - b.y}   //

When the operator is applied to a box, only one vertex of the box is shifted - the target vertex. Depending on the operator it is top right(NE), top left (NW), bottom right(SE) or bottom left (SW) corner of the box.

Example 2. shift a box

   point b = {1,2};
   // The boxes below represent equivalent planar objects
   box bx1 = {{ 1, 1}, {11,11}};
   box bx2 = {{ 1,11}, {11, 1}};
   // after shift the result is also equivalent planar objects
   box bx1a;
   box bx2a;
   bx1a = bx1 /| b; // shifting the top right corner
   bx2a = bx2 /| b; // of the box

top