From: peter.noreply@tin.it   
      
   On Tue, 23 Sep 2025 17:25:18 GMT   
   anton@mips.complang.tuwien.ac.at (Anton Ertl) wrote:   
      
   > peter writes:   
   > >This is the closest I have come   
   > >   
   > >s\" \"" rec-string Hej Peter" interpreting cr type   
   > > Hej Peter ok   
   > >   
   > >I still gives me an extra space that is needed to separate rec-string   
   > >from the continuation of the string.   
   >   
   > Yes, if you want to avoid that space, you lose a lot of the   
   > interactive testing benefit.   
   >   
   > But at least that works on lxf64.   
      
   If I do like this it works   
   s\" \"" drop 0 rec-string Hej Peter" interpreting cr type   
   Hej Peter ok   
      
   >   
   > >It works because rec-string does   
   > >the parsing of the rest of the string. If the parsing is done in   
   > >interpreting the string would have to be after that!   
   >   
   > The recommendation in the proposals is that recognizers don't do   
   > additional parsing (in order to be callable by, e.g., LOCATE or other   
   > tools), and that the translator should do the parsing.   
      
   Yes I think that would be a better solution. But it has its problems.   
      
   today I have   
      
   \ Recognizer for "text strings"   
      
   : adj ( len -- len' ) \ if we are at the end of the parse area   
    \ we need to adjust what we step back   
    source nip >in @ = + ;   
      
   ' noop \ interpret action   
   :noname postpone sliteral ; \ compile action   
   :noname postpone sliteral postpone 2lit, ; \ postpone action   
   translator: translate-string   
      
   : rec-string ( addr len --xi | 0)    
    swap c@ '"' =   
    if adj negate >in +! (s\") translate-string   
    else drop 0 then ;   
      
   I can easily move (s\") ( the interpretive part of S\")   
   into the translator.   
   But if I move also adj negate >in +! I need to send the len also.   
   That is not as clean as doing the adjust in rec-string.   
      
   Honestly I think using the string recognizer outside of recognizing   
   is difficult.   
      
   BR   
   Peter   
      
   >   
   > - anton   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|