Expressions, Comma expressions, Mikroc – ABL electronic PIC Microcontrollers PIC16 User Manual

Page 121

Advertising
background image

An expression is a sequence of operators, operands, and punctuators that specifies
a computation. Formally, expressions are defined recursively: subexpressions can
be nested without formal limit. However, the compiler will report an out-of-mem-
ory error if it can’t compile an expression that is too complex.

In ANSI C, the primary expressions are: constant (also referred to as literal), iden-
tifier, and

(

expression

)

, defined recursively.

Expressions are evaluated according to certain conversion, grouping, associativity,
and precedence rules that depend on the operators used, the presence of parenthe-
ses, and the data types of the operands. The precedence and associativity of the
operators are summarized in Operator Precedence and Associativity. The way
operands and subexpressions are grouped does not necessarily specify the actual
order in which they are evaluated by mikroC.

Expressions can produce an lvalue, an rvalue, or no value. Expressions might
cause side effects whether they produce a value or not.

Comma Expressions

One of the specifics of C is that it allows you to use comma as a sequence opera-
tor to form the so-called comma expressions or sequences. Comma expression is a
comma-delimited list of expressions – it is formally treated as a single expression
so it can be used in places where an expression is expected. The following
sequence:

expression_1

,

expression_2

;

results in the left-to-right evaluation of each expression, with the value and type of

expression_2

giving the result of the whole expression. Result of

expres-

sion_1

is discarded.

MikroElektronika: Development tools - Books - Compilers

113

page

mikroC - C Compiler for Microchip PIC microcontrollers

mikroC

making it simple...

EXPRESSIONS

Advertising
This manual is related to the following products: