"Fossies" - the Fresh Open Source Software Archive

Member "gentle-97/html/lrmmemebers.html" (20 Aug 1998, 7062 Bytes) of package /linux/misc/old/gentle-97.tar.gz:


Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links. You can here alternatively try to browse the pure source code or just view or download the uninterpreted raw source code. If the rendering is insufficient you may try to find and view the page on the gentle-97.tar.gz project site itself.



HANDBOOK / LANGUAGE REFERENCE MANUAL /

Members

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 Invocations

A member of the form

denotes a predicate invocation.

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 Updates

A member of the form

denotes an context update.

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.

   
Example

NestingLevel <- N
This sets the value of the context variable NestingLevel to the value of the local variable N.

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.

   
Example

Let Lab be a local variable that refers to a table entry with a field Coordinate. Then


Lab'Coordinate <- Loc
sets this field to the value of Loc.

Context Queries

A member of the form denotes a context query.

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.

   
Examples

NestingLevel -> N
This defines the local variable N according to the current value of the context variable NestingLevel.

Let Lab be a local variable that refers to a table entry with a field Coordinate. Then


Lab'Coordinate -> Loc
defines the local variable Loc according to the value of this field.

It is a checked run-time error to access an undefined context designator.

Key Definitions

A member of the form denotes a key definition.

The variable V is defined as a unique key of type T.

   
Example

Lab :: Label
The value of the local variable Lab is the unique key of a newly created entry of table Label.

Anonymous Tokens

A member of the form

where S is a string, is equivalent to a member of the form p, where p is an implicitly declared predicate of class token whose lexical representation is S.

Alternative Statements

A member of the form

denotes an alternative statement.

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 Statements

A member of the form is equivalent to (| A || /* empty */ |).