24.11.2014 Views

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Language</strong> <strong>Reference</strong><br />

1. logical term<br />

2. logical disjunct .OR. logical term<br />

A logical disjunct is simply a sequence of logical terms each separated by the .OR. operator. Rule (2)<br />

specifies that the logical terms are combined from left to right.<br />

A logical expression can now be defined as follows.<br />

1. logical disjunct<br />

2. logical expression .EQV. logical disjunct<br />

3. logical expression .NEQV. logical disjunct or logical expression .XOR. logical disjunct<br />

A logical expression is therefore a sequence of logical disjuncts, each separated by the .EQV. operator or<br />

the .NEQV. or .XOR. operator. Rules (2) and (3) indicate that logical disjuncts are combined from left<br />

to right.<br />

Consider the following example.<br />

A .OR. .NOT. B .AND. C<br />

Since the .NOT. operator has highest precedence we first logically negate B. The result is then combined<br />

with C using the .AND. operator. That result is then combined with A using the .OR. operator to form the<br />

final result.<br />

7.4.3 Logical Constant Expressions<br />

A logical constant expression is a logical expression in which each primary is one of the following:<br />

1. logical constant<br />

2. symbolic logical constant<br />

3. a relational expression in which each primary is a constant expression<br />

4. ( logical constant expression )<br />

The following are examples of a logical constant expression (assume that A, B, C and D are arithmetic<br />

constants appearing in PARAMETER statements).<br />

.TRUE. .AND. .NOT. .FALSE.<br />

’A’ .LT. ’a’<br />

A * B .GT. C * D<br />

7.5 Evaluating Expressions<br />

Four different types of operators have been discussed; arithmetic, character, relational and logical. It is<br />

possible to form an expression which contains all of these operators. Consider the following example.<br />

A+B .LE. C .AND. X // Y .EQ. Z .AND. L<br />

where A, B and C are of numeric type, X, Y and Z are of type CHARACTER and L is of type<br />

LOGICAL. In this expression, + is an arithmetic operator, // is a character operator, .EQ. is a relational<br />

operator and .AND. is a logical operator. Since we can mix these four types of operators, it is necessary to<br />

define a precedence among these four classes of operators. The following defines this precedence of<br />

operators.<br />

184 Evaluating Expressions

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!