| Re: Parsing text files with standard words |
|
 |
|
 |
|
 |
|
 |
Group: comp.lang.forth · Group Profile
Author: GerryGerry Date: Sep 15, 2008 05:23
On 14 Sep, 23:01, m...@iae.nl (Marcel Hendrix) wrote:
> Gerry jackson9000.fsnet.co.uk> writes Re: Parsing text files with standard words
> [..]
>
>
>
>> 2. define a word that parses and processes the rest of the file
>> and call this word at the start of the file. The file can then
>> be INCLUDED e.g. XML can be handled in this way by defining a
>> word called
>> handling files generated elsewhere or if other files need to be
>> included in the first file.
> [..]
>> I've seen discussions on this deficiency (IMHO at least) in the
>> ANS standard in the c.l.f archives but they all seem rather
>> inconclusive. The fundamental problem is that all words, such as
>> INCLUDED, that change the input source also invoke the Forth
>> text interpreter and there is no standard way of overcoming
>> this. So whenever a file is INCLUDED the application loses
>> control to the text interpreter and, if it wants to use standard
>> words to handle the input stream has to regain control with a
>> solution such as 2 above.
>
> I think I see your point. Interesting. Doesn't Gforth have
> ready-made solutions for this?
>
> | execute-parsing ... addr u xt ... unknown execute-parsing
> | Make addr u the current input source, execute xt ( ... -- ... ), then
> | restore the previous input source.
> | If you want to run a parsing word on a file, the following word should
> | help:
> | execute-parsing-file i*x fileid xt j*x unknown execute-parsing-file
> | Make fileid the current input source, execute xt ( i*x -- j*x ), then
> | restore the previous input source.
>
> -marcel
I was unaware of execute-parsing-file which does provide a
partial solution in my view - see my reply to Anton Ertl for
more detail.
Gerry
|