Next: , Up: PreDefOps


3.1 Specifying language-defined indications

An operator indication is represented by a unique definition table key. Properties of the operator indication are stored as properties of that key.

PreDefInd(`tok',`abs',`ind'), invoked in the file specified as the referto parameter of the module instantiation, marks a literal terminal symbol of the source language grammar as a concrete representation of an operator indication in the source program:

`tok'
The literal terminal symbol representing the operator indication `ind'.
`abs'
A nonterminal of the abstract grammar that inherits the OperatorSymbol role exported by this module (see Symbols defining computations). An instance of `tok' will appear in the tree as an `abs' node.
`ind'
The known definition table key that is the operator indication represented by `tok'.

Two PreDefInd invocations with the same pair of `tok' and `abs' values are not allowed. Associating the same indication with several literal terminal symbols, or associating the same or different indications with the same literal terminal symbol in different contexts (indicated by different values of `abs'), is legal.

The pre-defined operator indications of Mystery can be specified by:

     PreDefInd('+',   Operator, PlusInd)
     PreDefInd('>',   Operator, GrtrInd)
     PreDefInd('AND', Operator, AndInd)

PlusInd, GrtrInd, and AndInd are automatically defined as known keys by the module. No further specification is necessary.

These three lines produce the following rules, which are automatically added to the Mystery grammar:

     RULE: Operator ::= '+'   END;
     RULE: Operator ::= '>'   END;
     RULE: Operator ::= 'AND' END;