Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #45520

Re: Extending the interpreter?

From anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups comp.lang.forth
Subject Re: Extending the interpreter?
Date 2016-02-14 15:18 +0000
Organization Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID <2016Feb14.161849@mips.complang.tuwien.ac.at> (permalink)
References <60bf50a8-6759-4024-ad98-d9c28eff6968@googlegroups.com> <4caeea47-2229-4bd3-a520-42b3c15441a2@googlegroups.com> <2c439584-0c62-40b9-ab64-c9634ed3839e@googlegroups.com>

Show all headers | View raw


lehs <skydda.barnen@gmail.com> writes:
>Den l=F6rdag 13 februari 2016 kl. 23:55:23 UTC+1 skrev lehs:
>> Den m=E5ndag 8 februari 2016 kl. 18:06:37 UTC+1 skrev lehs:
>> > I would like the possibility of "extending the interpreter", letting it=
> recognize new data structures. Could this be done?
>>=20
>> Using 'see' with trial and error I'd made this=20
>>=20
>> : extended_interpret \ --=20
>>   space ." Ok" cr=20
>>   begin clear-tibstack
>>      tib max#tib @ accept #tib ! input-start-line tib c@
>>      case
>>        [char] + of endof
>>        [char] { of endof
>>        [char] ( of endof
>>             dup of interpret endof
>>      endcase space ." Ok" cr=20
>>   again ;=20
>>=20
>> that accepts anything starting with '+', '{' or '(' without error message=
>s. Between of and endof there should be a word for handling those inputs.
>>=20
>> I don't know the exact consequences of the routine, but when started it w=
>orks like quit(?) and keep working until an error.
>
>I forgot to mention that this is GForth. It works in Windows and Android.

For some value of "works".  E.g., it does not use REFILL, but ACCEPT,
and therefore only works on the command line.  Also, the + { ( must be
at the start of the line (preceding spaces allowed with your BLADD
extension), but not after another word; is this intended?

If you want to work at the word level, defining a recognizer is the
way to go.  Get a development version of Gforth and look for r:fail to
see examples of recognizers.  This is a work in progress, so it may
change, but it's probably still more sensible to work with that than
to try to replicate the text interpreter, badly.  Even if you have to
do it again if we change the recognizer interface, it will be less
work and provide better function.

- anton
-- 
M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
     New standard: http://www.forth200x.org/forth200x.html
   EuroForth 2015: http://www.rigwit.co.uk/EuroForth2015/

Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Extending the interpreter? lehs <skydda.barnen@gmail.com> - 2016-02-08 09:06 -0800
  Re: Extending the interpreter? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-08 17:28 +0000
    Re: Extending the interpreter? lehs <skydda.barnen@gmail.com> - 2016-02-08 10:43 -0800
      Re: Extending the interpreter? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-09 06:46 +0000
        Re: Extending the interpreter? lehs <skydda.barnen@gmail.com> - 2016-02-09 00:22 -0800
          Re: Extending the interpreter? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-09 08:34 +0000
          Re: Extending the interpreter? Albert van der Horst <albert@spenarnc.xs4all.nl> - 2016-02-09 11:54 +0000
            Re: Extending the interpreter? lehs <skydda.barnen@gmail.com> - 2016-02-09 07:53 -0800
            Re: Extending the interpreter? lehs <skydda.barnen@gmail.com> - 2016-02-09 10:46 -0800
  Re: Extending the interpreter? Chris Curl <ccurl609@gmail.com> - 2016-02-09 05:18 -0800
    Re: Extending the interpreter? Chris Curl <ccurl609@gmail.com> - 2016-02-09 05:23 -0800
      Re: Extending the interpreter? Doug Hoffman <glidedog@gmail.com> - 2016-02-09 10:22 -0500
      Re: Extending the interpreter? lehs <skydda.barnen@gmail.com> - 2016-02-09 08:00 -0800
      Re: Extending the interpreter? hughaguilar96@gmail.com - 2016-02-09 12:59 -0800
        Re: Extending the interpreter? lehs <skydda.barnen@gmail.com> - 2016-02-09 13:21 -0800
          Re: Extending the interpreter? hughaguilar96@gmail.com - 2016-02-09 14:52 -0800
            Re: Extending the interpreter? hughaguilar96@gmail.com - 2016-02-09 14:57 -0800
    Re: Extending the interpreter? lehs <skydda.barnen@gmail.com> - 2016-02-09 07:55 -0800
  Re: Extending the interpreter? minforth@arcor.de - 2016-02-09 06:42 -0800
  Re: Extending the interpreter? lehs <skydda.barnen@gmail.com> - 2016-02-13 14:55 -0800
    Re: Extending the interpreter? lehs <skydda.barnen@gmail.com> - 2016-02-13 15:05 -0800
      Re: Extending the interpreter? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-14 15:18 +0000
        Re: Extending the interpreter? Albert van der Horst <albert@spenarnc.xs4all.nl> - 2016-02-14 18:03 +0000
          Re: Extending the interpreter? lehs <skydda.barnen@gmail.com> - 2016-02-14 11:24 -0800
        Re: Extending the interpreter? lehs <skydda.barnen@gmail.com> - 2016-02-14 11:32 -0800
  Re: Extending the interpreter? lehs <skydda.barnen@gmail.com> - 2016-02-14 01:39 -0800
  Re: Extending the interpreter? humptydumpty <ouatubi@gmail.com> - 2016-02-14 10:20 -0800

csiph-web