Teledyne LeCroy Merlins Wand - CSL manual (CATC Scripting Language Manual) User Manual

Page 16

Advertising
background image

10

CATC Scripting Language for Bluetooth Analyzers

CATC

Manual Ver. 1.21

The associative operator

()

is used to group parts of the expression, forcing those

parts to be evaluated first. In this way, the rules of precedence can be overridden.
For example,

( 4 + 9 ) * 5

causes the addition to be performed before the multiplication, resulting in a value
of 65.

When operators of equal precedence occur in an expression, the operands are
evaluated according to the associativity of the operators. This means that if an op-
erator's associativity is left to right, then the operations will be done starting from
the left side of the expression. So, the expression

4 + 9 - 6 + 5

would evaluate to 12. However, if the associative operator is used to group a part or
parts of the expression, those parts are evaluated first. Therefore,

( 4 + 9 ) - ( 6 + 5 )

has a value of 2.

In the following table, the operators are listed in order of precedence, from highest
to lowest. Operators on the same line have equal precedence, and their associativity
is shown in the second column.

Operator Symbol

Associativity

[] ()

Left to right

~ ! sizeof head tail

Right to left

* / %

Left to right

+ -

Left to right

<< >>

Left to right

< > <= >=

Left to right

== !=

Left to right

&

Left to right

^

Left to right

|

Left to right

&&

Left to right

||

Left to right

=

Right to left

Table 4.1: Operator Precedece and Associativity

Advertising