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

Predicate Categories

Gentle
Applications
Concepts
Examples
Handbook
Support
Download

The Category specification of a predicate declaration may be one of
  • "'nonterm'", "'token'", "'action'",
    "'condition'", "'choice'", "'sweep'".
The category of a predicate determines the rule-selection strategy applied for that predicate.

Grammar Predicates

token and nonterm predicates constitute the underlying context-free grammar and are evaluated by LR parsing.

Action and Condition Predicates

condition and action predicates are evaluated by shallow backtracking. action predicates may not fail.

Choice Predicates

Rules of choice predicates may be augmented by cost specifications. Rules are selected in such a way that the sum of the costs of all rules applied is minimal.

Rule selection for choice predicates must depend exclusively on the first argument of the predicate: only the first argument or its constituents may be used as arguments to condition predicates or as the first argument of choice predicates invoked in a rule of a choice predicate.

Invocations of condition predicates in a rule of choice predicates may not change context variables or tables or have other side effects.

Sweep Predicates

sweep predicates provide implicit traversals where only rules deviating from the default rule have to be specified. The default rule recursively visits the fields of its first argument.

A sweep predicate p is declared in one of three forms

  • 'sweep' p (ANY)
    'sweep' p (ANY, T )
    'sweep' p (ANY, T -> T )
where T is an arbitrary type. The first argument of a sweep predicate may be of any type that is declared with functors
  • f ( T1 , ... , Tn )
The default rule for a functor f has the form
  • 'rule' p ( f ( X1 , ... , Xn )):
            p ( X1 )
            ...
            p ( Xn )

or

  • 'rule' p ( f ( X1 , ... , Xn ), Z ):
            p ( X1 , Z )
            ...
            p ( Xn , Z )

or

  • 'rule' p ( f ( X1 , ... , Xn ), Z0 -> Zn ):
            p ( X1 , Z0 -> Z1 )
            ...
            p ( X1 , Zn-1 -> Zn )





[NEXT] [PREV]