General Information
Tutorials
Reference Manuals
Libraries
Translation Tasks
Tools
Administration
|
Oil Reference ManualOIL's Specification LanguageAn OIL specification is composed of a list of statements. The statements describe relationships among identifiers which the library functions will interpret as describing an operator identification scheme. With the specification language a compiler writer defines four sets of mutually exclusive identifiers:
The rest of this chapter of the manual describes the syntax
of the specification language by covering the three main
lexical and syntactic constructs:
Identifiers
An
Examples: iAdd, Fmul2 Identifiers are defined both explicitly and implicitly. OPER and COERCION statements explicitly define operators. CLASS statements explicitly define classes. SET statements explicitly define sets. Types are all implicitly defined; if an identifier appears only in a function signature or as a type element in a type set expression then it is a type. If the indication in an INDICATION statement has no defining OPER statement it is implicitly defined as an operator.
An identifier can only be in one of the sets:
Constraints:
An identifier can denote a
An Since OIL produces names to be used in your attribute grammar, you must not use a reserved word of your attribute grammar as an identifier in an OIL specification. Examples: iAdd,iMul or Fmul, Fadd, Fdiv Comments
C-style comments, beginning with Statement typesThere are five types of statements in OIL:
Operator definitionThe basic form of an operator definition is: `OPER' <Op-name> `(' <arg-list> `)' `:' <result-id> `;'where:
The
Constraints:
Any given An example is: OPER iAdd( int_t, int_t ): int_t; In the example operator definition statement above, `iAdd' is defined to be an operator and `int_t' to be an operand type. The multiple form of an operator definition is: `OPER' <Op-name-list> `(' <arg-list> `)' `:' <result-id> `;'where:
All the operators appearing in
Constraints:
Each operator in An example is: OPER rAdd, rSub, rMul, rDiv ( real_t, real_t ): real_t;
Function SignaturesHow many and what kind of operator is being defined can vary a great deal depending on the definition of the identifiers which appear in the function signature. There are essentially three different kinds of function signatures:
A simple signature only defines a single operator. A class signature defines a pattern of a single operator to be created when the class is instantiated. The actual signature constructed has the class name replaced by the created type and the parameter names are replaced with the corresponding positional argument which is used in instantiating the class. A set signature defines one operator for each element in the value of the referenced set. Consider the example: SET s=[a,b]; sop(s):c;
There are two operators with the name sop(a):c; sop(b):c; If a set name is referenced more than once in the signature the same value appears in the corresponding position in the signature. For example consider the specification: SET s=[a,b]; SET r=[c,d]; OPER sop(s,r):s;
Four operators with the name sop(a,c):a; sop(b,c):b; sop(a,d):a; sop(b,d):b; The signature is duplicated once for each value in a unique set name. The set name is replaced with each value in turn reguardless of how many times the set name is referenced in the signature. Constraints: If an identifier in a function signature is a CLASS name or a parameter to a CLASS then the operator definition must be in the body of the CLASS definition. No reference to a SET name may be used in a CLASS operator definition. Coercion operator definitionThe basic form of a coercion operator definition is: `COERCION' <Cop-name> `(' <source-id> `)' `:' <result-id> `;'where:
The An example is: COERCION cFloat( int_t ): real_t; In the example coercion operator definition statement above, `cFloat' is defined to be an operator and, `int_t' and `real_t' are defined to be a operand types.
Constraints:
Operator identificationThe basic form of an operator identification is: `INDICATION' <Op-name> `:' <Op-name-list> `;'where:
The order of appearance from left to right of the operators in
the Constraints:
An example is: INDICATION Plus: iAdd, rAdd, sUnion; In the example operator identification statement above, `Plus' is defined to be an operator and, `iAdd', `rAdd' and `sUnion' are defined to be operators. The example defines that `iAdd' will be the first operator tested for identification of `Plus' and `sUnion' would be the last operator tested for identification. Class definitionThe form of a class definition is: `CLASS' <Class-name>`(' <Param-name-list> `)' `BEGIN' <simple-stmts> `END' `;'where:
The declarations in the
The type identifiers referenced in the declarations in
Type set definitionThe form of set definition is: `SET' <Set-name>`=' <set-expression> `;'where:
A set expression may be composed of any of the following constructs(where s1,s2... are set expressions):
|