Gentle
Applications
Concepts
Examples
Handbook
Support
Download

Expression = Expr2

Expression ( "+"  "" ) Expr2 .
Expr2 = Expr3

Expr2 ( "*"  "/" ) Expr3 .
Expr3 =
IdentUC
 Number
 String

Functor
["("[Expression{ "," Expression}]")"]

( "+"  "" ) Expr3
 "(" Expression ")"
Functor =
[Ident "'"] IdentLC .
An expression describes the computation of a value.
The value of an expression E on a position with type T
is computed as follows.
Variables
If E has the form
where V is a variable, the value of the expression is the value of the
variable. The type of the variable must be T.
Numbers
If E has the form
where N is a number,
T must be INT.
The value of E is the value of the number.
Strings
If E has the form
where S is a string,
T must be STRING.
The value of E is the value of the string.
Terms
If E has the form

f ( E_{1} , ... , E_{n} )
the declaration of T must contain a functor specification
f ( T_{1} , ... , T_{n} ).
E_{1}, ..., E_{n}
appear on positions with types
T_{1}, ..., T_{n}.
E_{1}, ..., E_{n}
are evaluated yielding values
Sigma_{1}, ..., Sigma_{n}.
The value of E is given as
f ( Sigma_{1} , ... , Sigma_{n} ).
If the type T of the position is unknown (in the case of generic
predicates) and if f is defined for more than one type,
f must be prefixed by the type:
T ' f .



Example
list(X1, list(yellow, X2))
If the value of X1 is red
and the value of X2 is nil,
the value of the expression is
list(red(list(yellow,nil)).



Arithmetic Expressions
If E has the form
where op is one of +, , *, /,
T must be INT and
E_{1} and E_{2} must be expressions of type INT.
The value of P is computed by applying the operator to the values
of E_{1} and E_{2}.
If E has the form
where op is one of +, ,
T must be INT and
E_{1} must be an expression of type INT.
The value of P is computed by applying the operator to the value
of E_{1}.
If E has the form
the value of E is the value of E_{1}.
E_{1} must be an expression of type T.
[NEXT] [PREV]
