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


Groups > comp.lang.forth > #131641

Recognizer protocol (was: 0 SET-ORDER why?)

From Ruvim <ruvim.pinka@gmail.com>
Newsgroups comp.lang.forth
Subject Recognizer protocol (was: 0 SET-ORDER why?)
Date 2024-06-29 02:27 +0400
Organization A noiseless patient Spider
Message-ID <v5ndch$3d9d8$1@dont-email.me> (permalink)
References <v5fjkr$1p13i$1@dont-email.me> <v5h5h6$2565d$1@dont-email.me> <v5ioud$2ii4l$1@dont-email.me> <v5m2po$3811n$2@dont-email.me> <nnd$7870c3ff$439130c9@777992005d4c8114>

Show all headers | View raw


On 2024-06-28 23:45, albert@spenarnc.xs4all.nl wrote:
> In article <v5m2po$3811n$2@dont-email.me>,
> Ruvim  <ruvim.pinka@gmail.com> wrote:
>> On 2024-06-27 08:14, Gerry Jackson wrote:
[...]
>> A corrected variant:
>>
>>    : s-to-n ( addr u -- x )
>>      depth >r
>>      get-order n>r 0 set-order
>>        ['] evaluate ['] execute-interpreting catch
>>      nr> set-order  throw
>>      depth 1+ r> <> if -12 throw then
>>    ;
>>
>>
>>>
>>> This is a better use case e.g. if BASE is greater than decimal 10
>>> converting an alphanumeric string to a number could clash with a word in
>>> the dictionary. Having an empty search order eliminates that possibility.
>>>
>>> Incidentally another possibility is that if ['] EVALUATE is replaced in
>>> the above definition with ['] SOME-RECOGNISER, that could be the basis
>>> for an ANS/FORTH 2012 compatible way of implementing recognisers. If the
>>> recogniser fails restore the search order and try again.
>>
>>
>> My position is that no recognizer can have side effects (other then
>> items on the data stack and/or floating-point stack).

> I second that. 

My rationale:
   "Recognizer protocol", 2020-07-04
   <news:rdpu54$pfn$1@dont-email.me>

<https://groups.google.com/g/comp.lang.forth/c/yuNZEvq8EqA/m/-FcvRcwRAQAJ>



> Moreover the items would have to be the same in
> interpret and compilation mode.

Agreed.


Rationale:

1. In most use cases the result of recognizing does not depend on STATE
(and when it depends, like in cmForth, it can be made independent).

2. One useful thing about recognizers is that they can be used for more 
than just the purpose of lexeme translation. If we would need to only 
translate lexemes (i.e., to compile or interpret a lexeme depending on 
STATE) — no need to separate the step of recognizing.

3. If we recognize a lexeme not for further immediate translation, and 
the result may depend on STATE, we will need to change STATE before 
recognizing (or use some helpers to indicate our intention). This only 
complicates some use cases and does not simplify anything.



> At least as a starting point, otherwise Forth degenerates to a
> tangled web of special purpose interpreters.


--
Ruvim

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


Thread

0 SET-ORDER why? Krishna Myneni <krishna.myneni@ccreweb.org> - 2024-06-25 18:25 -0500
  Re: 0 SET-ORDER why? minforth@gmx.net (minforth) - 2024-06-26 01:19 +0000
    Re: 0 SET-ORDER why? albert@spenarnc.xs4all.nl - 2024-06-26 11:12 +0200
    Re: 0 SET-ORDER why? Krishna Myneni <krishna.myneni@ccreweb.org> - 2024-06-26 05:54 -0500
  Re: 0 SET-ORDER why? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2024-06-26 07:49 +0000
    Re: 0 SET-ORDER why? dxf <dxforth@gmail.com> - 2024-06-26 18:50 +1000
      Re: 0 SET-ORDER why? Ruvim <ruvim.pinka@gmail.com> - 2024-06-26 17:36 +0400
        Re: 0 SET-ORDER why? dxf <dxforth@gmail.com> - 2024-06-27 13:19 +1000
          Re: 0 SET-ORDER why? Gerry Jackson <do-not-use@swldwa.uk> - 2024-06-27 23:10 +0100
            Re: 0 SET-ORDER why? dxf <dxforth@gmail.com> - 2024-06-28 11:56 +1000
          Re: 0 SET-ORDER why? Ruvim <ruvim.pinka@gmail.com> - 2024-06-28 13:51 +0400
            Re: 0 SET-ORDER why? dxf <dxforth@gmail.com> - 2024-06-28 22:19 +1000
              Re: 0 SET-ORDER why? Ruvim <ruvim.pinka@gmail.com> - 2024-06-28 17:48 +0400
                Re: 0 SET-ORDER why? dxf <dxforth@gmail.com> - 2024-06-29 03:08 +1000
                Re: 0 SET-ORDER why? dxf <dxforth@gmail.com> - 2024-07-01 18:45 +1000
            Re: 0 SET-ORDER why? dxf <dxforth@gmail.com> - 2024-06-29 13:27 +1000
        Re: 0 SET-ORDER why? Gerry Jackson <do-not-use@swldwa.uk> - 2024-06-27 05:14 +0100
          Re: 0 SET-ORDER why? albert@spenarnc.xs4all.nl - 2024-06-27 11:05 +0200
            Re: 0 SET-ORDER why? minforth@gmx.net (minforth) - 2024-06-27 13:00 +0000
          Re: 0 SET-ORDER why? dxf <dxforth@gmail.com> - 2024-06-27 22:41 +1000
          Re: 0 SET-ORDER why? Krishna Myneni <krishna.myneni@ccreweb.org> - 2024-06-27 14:09 -0500
            Re: 0 SET-ORDER why? Krishna Myneni <krishna.myneni@ccreweb.org> - 2024-06-27 14:22 -0500
              Re: 0 SET-ORDER why? Gerry Jackson <do-not-use@swldwa.uk> - 2024-06-27 23:08 +0100
                Re: 0 SET-ORDER why? Krishna Myneni <krishna.myneni@ccreweb.org> - 2024-06-27 18:44 -0500
              Re: 0 SET-ORDER why? dxf <dxforth@gmail.com> - 2024-06-28 15:51 +1000
            Re: 0 SET-ORDER why? albert@spenarnc.xs4all.nl - 2024-06-28 10:04 +0200
              Re: 0 SET-ORDER why? Krishna Myneni <krishna.myneni@ccreweb.org> - 2024-06-29 09:09 -0500
                Re: 0 SET-ORDER why? albert@spenarnc.xs4all.nl - 2024-06-30 12:22 +0200
          Re: 0 SET-ORDER why? Ruvim <ruvim.pinka@gmail.com> - 2024-06-28 14:20 +0400
            Re: 0 SET-ORDER why? albert@spenarnc.xs4all.nl - 2024-06-28 21:45 +0200
              Recognizer protocol (was: 0 SET-ORDER why?) Ruvim <ruvim.pinka@gmail.com> - 2024-06-29 02:27 +0400
            Re: 0 SET-ORDER why? Gerry Jackson <do-not-use@swldwa.uk> - 2024-07-04 07:26 +0100
    Re: 0 SET-ORDER why? albert@spenarnc.xs4all.nl - 2024-06-26 11:18 +0200
      Re: 0 SET-ORDER why? minforth@gmx.net (minforth) - 2024-06-26 10:36 +0000
      Re: 0 SET-ORDER why? Krishna Myneni <krishna.myneni@ccreweb.org> - 2024-06-26 06:13 -0500
    Re: 0 SET-ORDER why? Krishna Myneni <krishna.myneni@ccreweb.org> - 2024-06-26 05:56 -0500
      Re: 0 SET-ORDER why? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2024-06-28 15:50 +0000
        Re: 0 SET-ORDER why? Hans Bezemer <the.beez.speaks@gmail.com> - 2024-06-28 18:39 +0200
        Re: 0 SET-ORDER why? Krishna Myneni <krishna.myneni@ccreweb.org> - 2024-06-29 09:17 -0500
          Re: 0 SET-ORDER why? dxf <dxforth@gmail.com> - 2024-06-30 12:21 +1000
            Re: 0 SET-ORDER why? Krishna Myneni <krishna.myneni@ccreweb.org> - 2024-06-30 11:10 -0500
              Re: 0 SET-ORDER why? Krishna Myneni <krishna.myneni@ccreweb.org> - 2024-06-30 11:16 -0500
                Re: 0 SET-ORDER why? minforth@gmx.net (minforth) - 2024-06-30 17:38 +0000
                Re: 0 SET-ORDER why? albert@spenarnc.xs4all.nl - 2024-06-30 20:25 +0200
                Re: 0 SET-ORDER why? Krishna Myneni <krishna.myneni@ccreweb.org> - 2024-06-30 13:31 -0500
                Re: 0 SET-ORDER why? minforth@gmx.net (minforth) - 2024-06-30 20:37 +0000
                Re: 0 SET-ORDER why? Krishna Myneni <krishna.myneni@ccreweb.org> - 2024-06-30 20:49 -0500
                Re: 0 SET-ORDER why? mhx@iae.nl (mhx) - 2024-07-01 07:06 +0000
                Re: 0 SET-ORDER why? Krishna Myneni <krishna.myneni@ccreweb.org> - 2024-07-01 05:06 -0500
                Re: 0 SET-ORDER why? albert@spenarnc.xs4all.nl - 2024-07-01 13:35 +0200
                Re: 0 SET-ORDER why? Ruvim <ruvim.pinka@gmail.com> - 2024-07-01 13:02 +0400
                Re: 0 SET-ORDER why? Krishna Myneni <krishna.myneni@ccreweb.org> - 2024-07-01 05:13 -0500
                Re: 0 SET-ORDER why? dxf <dxforth@gmail.com> - 2024-07-01 21:02 +1000
                Re: 0 SET-ORDER why? dxf <dxforth@gmail.com> - 2024-07-02 15:56 +1000
                Re: 0 SET-ORDER why? Krishna Myneni <krishna.myneni@ccreweb.org> - 2024-07-02 20:04 -0500
                Re: 0 SET-ORDER why? dxf <dxforth@gmail.com> - 2024-07-03 12:32 +1000
                Re: 0 SET-ORDER why? albert@spenarnc.xs4all.nl - 2024-07-03 11:59 +0200
                Re: 0 SET-ORDER why? dxf <dxforth@gmail.com> - 2024-07-04 00:46 +1000
                Re: 0 SET-ORDER why? albert@spenarnc.xs4all.nl - 2024-07-01 13:39 +0200
                Re: 0 SET-ORDER why? sjack@dontemail.me (sjack) - 2024-07-02 14:29 +0000
                Re: 0 SET-ORDER why? dxf <dxforth@gmail.com> - 2024-07-03 00:52 +1000
                Re: 0 SET-ORDER why? Ruvim <ruvim.pinka@gmail.com> - 2024-07-02 17:42 +0400
                Re: 0 SET-ORDER why? Krishna Myneni <krishna.myneni@ccreweb.org> - 2024-07-02 20:17 -0500

csiph-web