ROTOR’s Identifier Syntax
ROTOR uses an extended syntax for OCaml identifiers. OCaml programs have a hierarchical structure, in which both modules and module types can be nested within one another. OCaml uses ‘dot notation’ for identifiers, in which the infix operator dot (.
) indicates this hierarchical nesting. ROTOR generalises OCaml’s identifier notation in two ways.
Firstly, instead of treating the dot as an infix operator, it uses it as a prefix operator on names to indicate that the following name specifically refers to a module structure. It also introduces a number of new such prefix operators to express other sorts of program components (e.g. module, module type, value).
Secondly, the hierarchical structure of components is now represented by the sequencing of prefixed names. ROTOR currently uses the operators .
, #
, %
, *
, and :
to indicate structures, functors, structure types (i.e. signatures), functor types, and values, respectively. ROTOR also uses an indexer element of the form [i]
, to stand for the i
th parameter of a functor or functor type.
Specifically, ROTOR uses the following syntax for identifiers where the nonterminal <name>
denotes a standard OCaml (short) identifier, and <number>
denotes a positive integer literal.
<signifier> ::= '.' | '#' | '%' | '*' | ':'
<id_link> ::= <signifier> <name> | '[' <index> ']'
<identifier> ::= <id_link> | <id_link> <identifier>
So, for example, consider the following program.
In order to refer to the binding foo
we would use the identifier .A.B.Bar.Baz:foo
.
Consider the following more complex example.
To refer to the add
value declaration in the S
module type, we would use the identifier .Set%S:add
.
Similarly, .Set#Make[1]:compare
refers to the declaration of the compare
value in the (first) parameter of the Make
functor.