Hoc as described here is based on arithmetic expressions, similar to
C. The grammar for these expressions is the following:
expr: number
| variable
| variable = expr
| array [ expr ]
| ( expr )
| expr binop expr
| unop expr
| function ( arguments )
(This is to be read: '' An expression is formed by either a
number or a variable or an array-name followed by
[ followed by an expression followed by ] or ...)
Note that this notation is recursive in nature, allowing familiar expressions
like e.g. sin(exp(b[i] * -1.5E-3)).
Numbers are either floating point values in their usual notation
(see scanf(3)): digits, decimal point, digits, e or
E, exponent with sign, or written in hexadecimal notation just
as in ''C'' (e.g. 0xFF meaning 255).
Note, however, that hex constants are stored as floating point values
as well.
All identifiers (i.e. names for variables, arrays or functions)
consist of a letter, followed by an arbitrary number of letters,
digits or ''_'' (Well, the maximum length is 128 characters).
binop means a binary operator (involving two operands), like
addition or test for equality, unop means a unary operator like
! (logical NOT) or unary minus (switching the sign). See
5.1 for a list of available operators.
|
|
Logical expressions have the values 1.0 (true) and 0.0 (false). Like
in C, every value not equal to 0.0 is considered true. Note,
that due to the floating point representation, every result coming
from a computation cannot be guaranteed to be exactly zero!
There are also some predefined constants available, see
5.1.
|