[NEXT] [PREV]    HANDBOOK / LANGUAGE REFERENCE MANUAL /

Predefined Predicates

Gentle
Applications
Concepts
Examples
Handbook
Support
Download

The following predicates can be used without being declared:
  • eq, ne, gt, ge, lt, le,
    print, where, @ .

Relations

The predicates eq and ne are declared for each type T

   'condition' eq(T, T)
   'condition' ne(T, T)
The invocations

   eq(X, Y)
   ne(X, Y)
succeed if X is equal (not equal) to Y.

The predicates gt, ge, lt, le,
are declared


   'condition' gt(T, T)
   'condition' ge(T, T)
   'condition' lt(T, T)
   'condition' le(T, T)
where T is INT or STRING.

The invocations


   lt(X, Y)
   le(X, Y)
   gt(X, Y)
   ge(X, Y)
succeed if X is less than (less or equal to, greater than, greater or equal to) Y.

Printing Values

The predicate print is defined for each type T.

   'action' print(T)
An invocation

   print(X)
prints the value of X.

Inspecting and Defining Variables

The predicate where is defined for each type T.

   'action' where(T -> T)
   'rule' where(X -> X)
   
Examples

where (List -> list(Head, Tail))
inspects the value of List and succeeds if it matches the pattern list(Head,Tail), thereby defining the variables Head and Tail.


where (list(Head, Tail) -> List)
constructs the value list(Head,Tail) and defines the variable List.

Source Coordinates

The predicate @ is defined

   'action' @(-> POS)
It may appear after a nonterm or token predicate and it defines its output variable as the coordinate of the source text recognized by the preceding symbol. It may also appear at the beginning of a rule for a grammar rule, in which case it defines its output variable as the coordinate of the source text recognized by the body of the rule.

The coordinate of the text recognized by a rule body is the coordinate of the leftmost token, if there is one, or else the coordinate of the leftmost nonterm. If the body is empty, the current coordinate is used.

   
Examples

'rule' Statement: "IF" @(->P) Expression "THEN" Statement
Here, P is defined as the coordinate of "IF".

'rule' Statement: "IF" Expression @(->P) "THEN" Statement
Here, P is defined as the coordinate of Expression.






[NEXT] [PREV]