[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

input/ouput in Typol



In article <DSTJul18.191537.11823@sophia.inria.fr>, desit@enseeiht.fr (Reynald DESIT) writes:

|>         I'm trying to do an interpretor with Centaur and I need to manage the
|> input/output. So I would like to know if somebody has already implemented the
|> input/output and how it can be done.

Here is a solution, used some years ago for a toy langage called Asple:

Two parameters are used to specify the input and the ouput. When executing
the specification you can give the complete input as a data, computing the 
complete output, or use some side effects to have a more dynamic behaviour.

The typol rules was (using side effects):

ALLOCATE(store[] |- DECLS : s1)  &
s1 |- STMS {i -> o} s2
----------------
|- #program(DECLS, STMS) : i, o ;

s |- stms[] {stream[] -> stream[]} s ;

s |- STM {i1 -> o1} s1  &  s1 |- STMS {i2 -> o2} s2 
----------------
s |- stms[STM.STMS] {i -> o} s2 ;
	provided APPENDTREE(i1, i2, i)  &  APPENDTREE(o1, o2, o);

...

s |- VAR : x  &  READ(v, MODE)  &
UPDATE(s |- x, v : s1)
----------------
s |- tinput(VAR, MODE) {stream[v] -> stream[]} s1 ;

s |- EXP : v  &  WRITE(v)
----------------
s |- toutput(EXP, MODE) {stream[] -> stream[v]} s ;

READ and WRITE may either use the read and write predicates from prolog,
or use a more sophisticate interface using Centaur.

Removing READ and WRITE gives the pure logical specification.

Thierry


-- 
Send contributions and compliments to centaur@sophia.inria.fr. Registration
and administrative matters should be sent to centaur-request@sophia.inria.fr.
+---------------------------------------------------------------------------+
|     Thierry Despeyroux      | email: Thierry.Despeyroux@sophia.inria.fr   |
| I.N.R.I.A. Sophia-Antipolis | phone: +33 93 65 77 07 fax: +33 93 65 77 66 |
+---------------------------------------------------------------------------+