|
[NEXT] [PREV]
HANDBOOK
/ LANGUAGE REFERENCE MANUAL
/Members |
||||||||||||||||||||||||
|
Gentle
Applications Concepts Examples Handbook Support Download
|
Member =
Ident ["(" [Expression{ "," Expression}]
["->" [Pattern{ "," Pattern}]] ")"]
| ContextDesignator "<-" Expression | ContextDesignator "->" Pattern | IdentUC "::" Ident | String | "(|" {Member} "||" {Member} {"||" {Member}} "|)" | "[|" {Member} "|]" . ContextDesignator = [IdentUC "'"] Ident . The body of a rule is given by a sequence of members. A member is elaborated as follows.
Predicate InvocationsA member of the form
p must be a predicate with n input parameters and m output parameters. Let T1, ..., Tn be the input types and S1, ..., Sm the output types. The expressions E1, ..., En appear on positions with types T1, ..., Tn, and the patterns P1, ..., Pm appear on positions with types S1, ..., Sm. The expressions E1, ..., En are evaluated, yielding values Tau1, ..., Taun. p is invoked with these input values. If the invocation fails, the member M fails. If it succeeds, it yields output values Sigma1, ..., Sigmam. These values are matched against the patterns P1, ..., Pm. If the matching fails, the member M fails. Otherwise, the member succeeds and the variables appearing in P1, ..., Pm are defined.
Context UpdatesA member of the form
The value of D is defined as the value of the expression E. If T is the type of D, E appears on a position with type T. The context designator D may be of the form C, where C must be declared as a context variable. The type of the designator is the type of the context variable.
A context designator may also have the form I ' F ; I must be a variable of the key type of a context table T. Entries of T must have a field F. The type of the designator is the type of the F.
Context QueriesA member of the form
The value of the context designator D is matched against the pattern P. If this succeeds, the member succeeds and the variables appearing in P are defined. Otherwise, the member fails.
It is a checked run-time error to access an undefined context designator.
Key DefinitionsA member of the form
The variable V is defined as a unique key of type T.
Anonymous TokensA member of the form
Alternative StatementsA member of the form
The alternatives A1, ..., An are evaluated from left to right until one alternative Ai succeeds. Then M succeeds. If all alternatives fail, M fails. An alternative Ai has the form Mi,1, ..., Mi,ni. These members are evaluated from left to right until one member fails. Then the alternative fails. If all members succeed, the alternative succeeds. A variable that is defined in all alternatives A1, ..., An is defined by the alternative statement and may be used outside it. Such a variable must be defined with the same type in all alternatives. A variable that is defined in one but not all alternatives is local to that alternative.
Conditional StatementsA member of the form
|