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


Groups > comp.lang.forth > #54235

Recognizers

From Alex <alex@rivadpm.com>
Newsgroups comp.lang.forth
Subject Recognizers
Date 2017-01-22 01:42 -0500
Organization A noiseless patient Spider
Message-ID <o61k4o$9he$1@dont-email.me> (permalink)

Show all headers | View raw


Some recognizer observations.

1. Using -2 STATE ! for POSTPONE actions is very useful as it provides a 
simple index on (0 -1 and -2) NEGATE CELLS into the appropriate 
RECOGNIZER: table. It remains ANS compliant:

STATE is true when in compilation state, false otherwise. The true value 
in STATE is non-zero, but is otherwise implementation-defined.

2. There's an unintended consequence with numbers (in fact, any 
non-FINDable words can be treated this way).

: plit postpone literal ;

   ' d>s
   :noname d>s plit ;
   :noname d>s plit postpone plit ;
recognizer: r:number ( n 0 -- )

: postpone  ( -<name>- )
   -2 state dup @ >r !
   parse-name recognize execute
   r> state ! ; immmediate

This allows POSTPONE 10 even though 10 isn't a "proper" word and can't 
be ticked or found in the usual wordlist searches. I've not yet 
considered a use for it.

3. Adding the Windows constant server was very simple. (It's a DLL that 
allows for symbols like MB_HELP VK_F1 VK_F2 etc to be used without 
declaring thousands of CONSTANTs.)

library wincon.dll
3 import: wcFindWin32Constant

: wincon-call   ( a1 -- n f ) \ call to find constant
     >r 0 sp@ r> count swap wcFindWin32Constant ;

: rec:wincon ( addr u -- d r:number | r:fail ) \ find constant
     buf-allot dup>r place r@ ?uppercase \ uppercase a copy
     wincon-call dup 0= if        \ found constant? if not
       2drop                      \   drop returned values
       s" A" r@ +place            \   append an 'A' look for that
       r@ wincon-call
     then rdrop
     if 0 r:number else drop r:fail then ;

' rec:wincon get-recognizers 1+ set-recognizers

It's very clean indeed.

-- 
Alex

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


Thread

Recognizers Alex <alex@rivadpm.com> - 2017-01-22 01:42 -0500
  Re: Recognizers Matthias Trute <matthias.trute@gmail.com> - 2017-01-22 03:06 -0800
  Re: Recognizers anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-01-22 14:42 +0000
    Re: Recognizers Alex <alex@rivadpm.com> - 2017-01-22 17:26 -0500
    Re: Recognizers Bernd Paysan <bernd@net2o.de> - 2017-01-24 00:57 +0000
      Re: Recognizers anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-01-24 16:23 +0000
        Re: Recognizers Bernd Paysan <bernd@net2o.de> - 2017-01-24 21:47 +0000
  Re: Recognizers Alex <alex@rivadpm.com> - 2017-01-23 08:30 -0500
    Re: Recognizers Alex <alex@rivadpm.com> - 2017-01-23 08:57 -0500
    Re: Recognizers Matthias Trute <matthias.trute@gmail.com> - 2017-01-23 10:58 -0800
      Re: Recognizers Alex <alex@rivadpm.com> - 2017-01-23 14:45 -0500
      Re: Recognizers JennyB <jennybrien@googlemail.com> - 2017-01-27 15:05 -0800
    Re: Recognizers Alex <alex@rivadpm.com> - 2017-01-29 22:54 +0000
      Re: Recognizers JennyB <jennybrien@googlemail.com> - 2017-01-30 09:11 -0800
      Re: Recognizers anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-01-30 16:34 +0000
  Re: Recognizers Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2017-01-31 21:03 +0000
    Re: Recognizers albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-02-01 12:37 +0100

csiph-web