SAVE-INPUT RESTORE-INPUT 
Author Message
 SAVE-INPUT RESTORE-INPUT

Can someone give an example of the use of the (ISO-standard)
words SAVE-INPUT RESTORE-INPUT in an application?

(I can imagine that for some implementations it could be
a factor for some standard words. That is not what I'm
interested in.)

Groetjes Albert
--
Albert van der Horst,Oranjestr 8,3511 RA UTRECHT,THE NETHERLANDS
To suffer is the prerogative of the strong. The weak -- perish.



Sun, 10 Apr 2005 23:23:27 GMT  
 SAVE-INPUT RESTORE-INPUT

Quote:
> Can someone give an example of the use of the (ISO-standard)
> words SAVE-INPUT RESTORE-INPUT in an application?

> (I can imagine that for some implementations it could be
> a factor for some standard words. That is not what I'm
> interested in.)

It is a basic tool to write (e.g) compiler passes in several steps. Such a
thing did not exist before.


... RESTORE-INPUT', when one item from an input line is to be re-read, but
this looks like overkill. The latter is fine to re-read sets of phrases,
which will not be on one line necessarily.

A working example where I used it, deals with a compiler extension: Fill
columns of a table with references to its rows. Forward referencing is quite
naturally expected to be allowed in this case. Compilation is best done in
two passes then.

I posted code for a 'cases machine' (as an alternative to a finite state
machine) some time ago (for the ultimately ugly spaghetti code ;) - as to
deal with irregular flow of control dispatching), which uses that principle.
The compiled table holds the execution tokens.

cases>
label-case-1 perform-case-1 goto-case-4 goto-case-7 goto-case-9 |
label-case-2 perform-case-2 goto-case-6 goto-case-3 goto-case-9 |
label-case-3 perform-case-3 goto-case-3 goto-case-2 goto-case-9 |
label-case-4 perform-case-4 goto-case-1 goto-case-5 goto-case-9 |
[...]
<cases

Compilation is performed by 'CASES>' until '<CASES' is encountered. It
starts with SAVE-INPUT, allocates for the table and visits the references in
a first pass. Then it performs RESTORE-INPUT for a second pass, where it
fills-in the table. This seems to me a more solid approach than the
alternatives (as: keep the table in a separate file, or: demand for notation
of redundant details).

*****

\ e.g. Notation of real world example, slightly different:

caseslink cases>

 1 =open      ( any   ) >3    ( none  ) >6                   |
 2 close&wait ( extern) >15  ( endzero) >1    ( line  ) >16  |
 3 =event?    ( item  ) >4    ( noitem) >5   ( noevent) >6   |
 4 =wait      ( end   ) >5    ( line  ) >16                  |
 5 =nextitem  ( more  ) >13   ( pause ) >14   ( end   ) >6   |
 6 =getevent  ( this  ) >7    ( none  ) >9    ( empty ) >2   |
 7 =nextinc   ( more  ) >8    ( end   ) >9                   |
 8 =nextcomp  ( inside) >5    ( below ) >7    ( above ) >9   |
 9 =anchor    (       ) >11                                  |
10 =increment ( more  ) >11   ( end   ) >2                   |
11 =compare   ( inside) >5    ( below ) >10   ( above ) >12  |
12 =cls?      ( is    ) >14   ( no    ) >4                   |
13 =batch               >17                                  |
14 =cls/ext             >17                                  |
15 =extern              >17                                  |
16 =line                >17                                  |
17 close&bye            >17                                  |

<end

--



Mon, 11 Apr 2005 18:18:27 GMT  
 SAVE-INPUT RESTORE-INPUT

Quote:

> Can someone give an example of the use of the (ISO-standard)
> words SAVE-INPUT RESTORE-INPUT in an application?

> (I can imagine that for some implementations it could be
> a factor for some standard words. That is not what I'm
> interested in.)

Not exactly what you want,
but EVALUATE-WITH is defined by abusing SAVE-INPUT RESTORE-INPUT
to save and restore the current input source.

See EVALUATE-WITH at
http://forth.sourceforge.net/word/evaluate-with/index.html



Tue, 12 Apr 2005 05:37:12 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. SAVE-INPUT and RESTORE-INPUT

2. RESTORE-INPUT and nesting sources

3. Saving input into mother-file

4. SAVE-INPUT ...

5. SAVE-INPUT

6. How can I save and restore the state of a VIEW

7. Use INI file to save and restore program settings

8. Saving/Restoring the environment

9. Saving/Restoring the environment

10. Help on SAVE TO and RESTORE

11. Saving and restoring Workarea information

12. VO2 - Save/Restore .mem files

 

 
Powered by phpBB® Forum Software