Prev Up Next
Go backward to 2.7 Parsing, Bubbles and Meta-Parsing
Go up to 2 Core Maude
Go forward to 2.9 System Issues and Debugging

2.8 LOOP-MODE and Metalanguage Uses

Using object-oriented concepts, we can specify in Maude a general input/output facility provided by the LOOP-MODE module shown below, that extends the module QID-LIST, into a generic read-eval-print loop.

  mod LOOP-MODE is
    protecting QID-LIST .
    sorts State System .
    op [_,_,_] : QidList State QidList -> System 
           [special ( ... )] .
  endm

The operator [_,_,_] can be seen as a persistent object with an input channel (the first argument), an output channel (the third argument), and a state (given by its second argument). This read-eval-print loop that LOOP-MODE provides is a simple mechanism developed for this release that may not be maintained in future versions. We plan to endow Maude with general built-in support for objects; this will make possible more general and flexible solutions for dealing with input/output and persistent objects.

Besides having input and output channels, terms of sort System give us the possibility of maintaining a persistent state in their second component. This state has been declared in a completely generic way. In fact, the sort State in LOOP-MODE does not have any constructor. This gives complete flexibility for defining the terms we want to have for representing the persistent state of the loop in each particular application. In this way we can use this input/output facility not only for extensions of Maude like Full Maude, but also for other uses of Maude as a metalanguage, where the object language being implemented may be completely different from Maude. For each such language or tool the nature of the state of the system may be completely different. We can tailor the State sort to any such application by importing LOOP-MODE in a module in which we define the structure of the persitent state and the rewrite rules for changing that state and interacting with the loop.

  • 2.8.1 The Use of the Loop
  • 2.8.2 Metalanguage Uses of Maude

  • Prev Up Next