Mercurial > hg > Applications > Tokio
view read.me @ 1:09586da5afa8 kono r1
Tokio compiler on Prolog.
author | kono |
---|---|
date | Thu, 30 Aug 2007 14:57:44 +0900 |
parents | cfb7c6b24319 |
children |
line wrap: on
line source
Tokio / Prolog Compiler Fri Aug 5 19:35:55 JST 2005 Shinji KONO kono@ie.u-ryukyu.ac.jp University of the Ryukyus 1. Change -D flag in Makefile Supporting Prologs PROLOG_TYPE PROLOG SICStus SICSTUS sicstus Quintus QUINTUS quintus SWI-Prolog SWIPROLOG swipl 2. File List call prolog bootup file cp.pl file for compatiblities cp.pl.c file for compatiblities (no longer used) tc.pl tokio clause compiler td.pl debugger te.pl expression basics tf.pl predicates compiler tg.pl one line compiler th.pl head unification tm.pl basic macros to.pl tokio compiler main routines tp.pl macro expansion tr.pl runtime support ts.pl system definition & operator tu.pl temporal logic unification xf.pl system-predicates list tokio.pl module definition call iall lall mall load file 3. How to run In SICStus, use tokio module. % sicstus SICStus 3.12.1 (powerpc-darwin-7.8.0): Mon Apr 18 20:00:24 CEST 2005 Licensed to ie.u-ryukyu.ac.jp | ?- use_module(tokio). % compiling /Users/kono/ITL/Tokio/tokio.pl... % compiled /Users/kono/ITL/Tokio/tp.pl in module tokio, 60 msec 19832 bytes END 0.0 sec. % compiled /Users/kono/ITL/Tokio/tokio.pl in module tokio, 350 msec 153404 bytes yes | ?- com(example). Compiling: t0/0 Compiling: test/0 END 0.10999999999999999 sec. % compiling /Users/kono/ITL/Tokio/#temp.tokio... * [E] - singleton variables in (tokio):t1/2 * Approximate lines: 873-877, file: '/Users/kono/ITL/Tokio/#temp.tokio' % compiled /Users/kono/ITL/Tokio/#temp.tokio in module tokio, 210 msec 57528 bytes yes | ?- tokio. tokio: test. t0:1 t1:1 ... t90:[100] t91:[] 91 clock and 0.010000000000000009 sec. tokio: ^D yes | ?- ^D In SWI Prolog, use tokio_swi.pl script. % swipl Welcome to SWI-Prolog (Multi-threaded, Version 5.4.7) Copyright (c) 1990-2003 University of Amsterdam. SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. Please visit http://www.swi-prolog.org for details. For help, use ?- help(Topic). or ?- apropos(Word). ?- [tokio_swi]. % ts compiled into tokio 0.00 sec, 1,984 bytes ... % tp compiled into tokio 0.00 sec, 18,668 bytes END 0 sec. % tokio compiled into tokio 0.06 sec, 142,720 bytes % ts compiled 0.00 sec, 840 bytes % tokio_swi compiled 0.06 sec, 143,952 bytes Yes tokio: ?- com(example). Compiling: t0/0 Compiling: t1/0 Compiling: test/0 END 0.14 sec. Warning: (/Users/kono/ITL/Tokio/#temp.tokio:18): Singleton variables: [E] ... Warning: (/Users/kono/ITL/Tokio/#temp.tokio:873): Singleton variables: [E] % #temp.tokio compiled into tokio 0.02 sec, 68,272 bytes Yes tokio: ?- tokio. tokio: test. t0:1 t1:1 t2:1 t90:[100] t91:[] 91 clock and 0.02 sec. tokio: Yes tokio: ?- % halt You can run each small test in example file, ?- tokio t0. or in tokio top level, ?- tokio. tokio: t0. To try more examles, % cd Examples/6502 % sicstus ?-use_module('../../Tokio/tokiko'). ?-com(mc6502). ?-com(run). ?-tokio run(a). Some of them may not work, such as toy. 3. Notice If you are going to create very large program in Tokio, use com/2 instead of com/1. It greatly reduces compile time and you can use Prolog output for debugging purpose. Converting Tokio Program into Prolog is quite fast. But compiling the output by Prolog compiler takes long time (in some prolog). Execution speed of Tokio program mainly depends on runtime library, so Tokio code can run reasonably fast even if generated code is not compiled. "com(file)" command translates and compiles Tokio program, but "com(file,output)" translates and consults Tokio program. In this reason, it is better to use com(file,output) than com(file) to speed up Tokio to Prolog translation. When you exit Prolog top level, use ``tokio'' to reenter Tokio top level. In SICStus/Quintus, com/2 automatically try to add '.tokio' postfix, but SWI-Prolog does not. You need type com('mc6502.tokio') in SWI-Prolog. SICStus/Quintus complains, * nofileerrors/0 - NOT redefined Please ignore. 4. Module ?- use_module(tokio). ?- com(example). ?- tokio test. will work on SICStus Prolog. In SWI-Prolog, ?- use_module(tokio). ?- [ts]. ?- module(tokio). ?- com(example). ?- tokio test. Yes, we should have seprate space for compiled tokio clauses. 5. Sample Run Here is an example script.... Script started on Fri Aug 5 19:39:20 2005 % swipl Welcome to SWI-Prolog (Multi-threaded, Version 5.4.7) Copyright (c) 1990-2003 University of Amsterdam. SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. Please visit http://www.swi-prolog.org for details. For help, use ?- help(Topic). or ?- apropos(Word). ?- [call]. % ts compiled 0.00 sec, 1,880 bytes % to compiled 0.01 sec, 16,656 bytes ... % tp compiled 0.01 sec, 18,156 bytes END 0 sec. Tokio to prolog compiler $Revision$ $Date$ try ?- tokio_help. % call compiled 0.08 sec, 257,608 bytes Yes ?- com(example) ?- com ?- com(example). Compiling: t0/0 Compiling: t1/0 .... Compiling: append/3 Compiling: test/0 END 0.14 sec. Warning: (/Users/kono/ITL/Tokio/#temp.tokio:18): Singleton variables: [E] ... Warning: (/Users/kono/ITL/Tokio/#temp.tokio:873): Singleton variables: [E] % #temp.tokio compiled 0.02 sec, 68,272 bytes Yes ?- tokio test. t0:1 t1:1 t2:1 t3:1 t4:1 ... t89:[20] t90:[100] t91:[] 91 clock and 0.02 sec. Yes ?- tokiodebug. Tokio debug mode switched on. All computation will be traced. ERROR: Undefined procedure: ttynl/0 ?- tokio t0. Tokio Trace t0:h. help/h/? print this next/n skip to next clock dump/d dump current static value all all history of static value save(file) save current state skip(n)/s(n)/+-Number goto +-Number clock abort/a abort tokio execution break/b break to prolog value(Name)/*Name examine static value queue/q show current process queue trace/t enter prolog tracer Tokio Trace t0:next. t0:1 Tokio Trace t1:next. t1:1 Tokio Trace t2:q. :-abolish(restart, 1), recorda(time, 2, _G415). restart:-r_solve_t((r_0t00(['$t'(B, C, D, $(5, 2, A))|E], ['$t'(true, true, true, $(5, 2, A))|F]), true), 5, 2, ['$t'(B, C, D, $(5, 2, A))|E], ['$t'(true, true, true, $(5, 2, A))|F]). Tokio Trace t2:skip(3). t2:1 t3:1 t4:1 Script done on Fri Aug 5 19:41:30 2005