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


Groups > comp.lang.forth > #57717

Re: ANN: WF32, a Windows 32 bit Forth

From Alex <alex@rivadpm.com>
Newsgroups comp.lang.forth
Subject Re: ANN: WF32, a Windows 32 bit Forth
Date 2017-04-21 13:49 +0100
Organization A noiseless patient Spider
Message-ID <odcuvi$8pu$1@dont-email.me> (permalink)
References <odaesj$quo$1@dont-email.me> <odahum$5om$1@dont-email.me> <xn0koyots8h7uvy005@nntp.aioe.org> <odau4p$hma$1@dont-email.me> <fd9a9a24-ec5a-4095-825c-60aa9c42e19f@googlegroups.com>

Show all headers | View raw


On 4/21/2017 10:58, josv@planet.nl wrote:
> Hi,
> When I getting into Forth it was easy to learn.
> Each word could be explained within 8 lines using a half side of an A4 page (portrait).
> Quite clear and understandable.
> It seems recognizers are beyond that capability.
> Jos
> 

They're easier to write than (perhaps) to explain. Much of the 
explanation is because the approach is novel, requires the interpreter 
to change, and has some desirable side effects in terms of parsing.

Here's a recognizer for a hex number prefixed by 0x that have the form 
0x0 up to 0xffffffff.

First we need to specify a set of rules for processing the number in 
each state; here it's called DT:0X. Then we need a recognizer, called 
rec:0x here. If it succeeds, then return n DT:0X else return DT:NULL. 
Lastly, add our recognizer to the stack of recognizers.

: plit postpone literal ;

   ' noop                           \ interpret: do nothing
   ' plit                           \ compile as a literal
   :noname plit postpone plit ;     \ postpone a literal
dt-token: dt:0x ( n -- )

: rec:0x ( addr u -- n dt:number | dt:null )
     dup 2 >= if
       over 2 s" 0x" compare 0= if
         base @ >r hex
         2 /string 0 0 2swap >number \ n n addr len
         r> base !
         nip + dup 0= if
           drop dt:0x exit
         then
       then
     then 2drop dt:null ;

' rec:0x get-recognizers 1+ set-recognizers

And we're done. You can try it out in WF32.

-- 
Alex

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


Thread

ANN: WF32, a Windows 32 bit Forth Alex <alex@rivadpm.com> - 2017-04-20 15:02 +0100
  Re: ANN: WF32, a Windows 32 bit Forth Alex <alex@rivadpm.com> - 2017-04-20 15:55 +0100
    Re: ANN: WF32, a Windows 32 bit Forth "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-20 17:17 +0000
      Re: ANN: WF32, a Windows 32 bit Forth Alex <alex@rivadpm.com> - 2017-04-20 19:23 +0100
        Re: ANN: WF32, a Windows 32 bit Forth "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-21 09:40 +0000
        Re: ANN: WF32, a Windows 32 bit Forth josv@planet.nl - 2017-04-21 02:58 -0700
          Re: ANN: WF32, a Windows 32 bit Forth "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-21 11:44 +0000
          Re: ANN: WF32, a Windows 32 bit Forth Alex <alex@rivadpm.com> - 2017-04-21 13:49 +0100
            Re: ANN: WF32, a Windows 32 bit Forth josv@planet.nl - 2017-04-21 09:03 -0700
  Re: ANN: WF32, a Windows 32 bit Forth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-04-20 19:22 +0200
    Re: ANN: WF32, a Windows 32 bit Forth Alex <alex@rivadpm.com> - 2017-04-20 19:19 +0100
  Re: WF32, a Windows 32 bit Forth "HAA" <someone@microsoft.com> - 2017-04-21 13:44 +1000
    Re: WF32, a Windows 32 bit Forth Rod Pemberton <NeedNotReplyHere@xrsevnneqk.cem> - 2017-04-21 22:45 -0400
      Re: WF32, a Windows 32 bit Forth Rod Pemberton <NeedNotReplyHere@xrsevnneqk.cem> - 2017-04-21 22:50 -0400
        Re: WF32, a Windows 32 bit Forth rickman <gnuarm@gmail.com> - 2017-04-22 00:57 -0400
          Re: WF32, a Windows 32 bit Forth Rod Pemberton <NeedNotReplyHere@xrsevnneqk.cem> - 2017-04-22 23:32 -0400
          Re: WF32, a Windows 32 bit Forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-04-24 16:54 +0000
            Re: WF32, a Windows 32 bit Forth rickman <gnuarm@gmail.com> - 2017-04-24 13:05 -0400
              Re: WF32, a Windows 32 bit Forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-04-25 07:26 +0000
      Re: WF32, a Windows 32 bit Forth Alex <alex@rivadpm.com> - 2017-04-22 12:48 +0100
  Re: ANN: WF32, a Windows 32 bit Forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-04-24 13:59 +0000
    Re: ANN: WF32, a Windows 32 bit Forth Alex <alex@rivadpm.com> - 2017-04-24 16:41 +0100
      Re: ANN: WF32, a Windows 32 bit Forth Alex <alex@rivadpm.com> - 2017-04-29 19:13 +0100
  Re: ANN: WF32, a Windows 32 bit Forth NN <november.nihal@gmail.com> - 2017-04-24 14:07 -0700
    Re: ANN: WF32, a Windows 32 bit Forth Alex <alex@rivadpm.com> - 2017-04-24 22:48 +0100
      Re: ANN: WF32, a Windows 32 bit Forth Alex <alex@rivadpm.com> - 2017-04-29 19:49 +0100
        Re: ANN: WF32, a Windows 32 bit Forth Alex <alex@rivadpm.com> - 2017-04-30 22:33 +0100
  Re: ANN: WF32, a Windows 32 bit Forth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-04-30 12:20 +0200
    Re: ANN: WF32, a Windows 32 bit Forth Alex <alex@rivadpm.com> - 2017-04-30 12:00 +0100
      Re: ANN: WF32, a Windows 32 bit Forth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-04-30 14:39 +0200
        Re: ANN: WF32, a Windows 32 bit Forth Alex <alex@rivadpm.com> - 2017-04-30 14:03 +0100
          Re: ANN: WF32, a Windows 32 bit Forth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-04-30 19:51 +0200
            Re: ANN: WF32, a Windows 32 bit Forth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-04-30 20:03 +0200
              Re: ANN: WF32, a Windows 32 bit Forth Alex <alex@rivadpm.com> - 2017-04-30 20:06 +0100

csiph-web