X-Received: by 2002:a1c:f00a:: with SMTP id a10mr17617957wmb.61.1593441959002; Mon, 29 Jun 2020 07:45:59 -0700 (PDT) X-BeenThere: comp.lang.forth@googlegroups.com Received: by 2002:a1c:13:: with SMTP id 19ls8167830wma.0.gmail; Mon, 29 Jun 2020 07:45:57 -0700 (PDT) X-Received: by 2002:a7b:cc8b:: with SMTP id p11mr18284219wma.180.1593441957845; Mon, 29 Jun 2020 07:45:57 -0700 (PDT) Path: nntp.google.com!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Ruvim Newsgroups: comp.lang.forth Subject: Re: Recognizers and postponing Date: Mon, 29 Jun 2020 17:45:56 +0300 Organization: A noiseless patient Spider Lines: 45 Message-ID: References: <2020Jun28.173040@mips.complang.tuwien.ac.at> Mime-Version: 1.0 Injection-Date: Mon, 29 Jun 2020 14:45:57 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="6048b26134cb5bd61ad2b70a54e747d1"; logging-data="16708"; mail-complaints-to="ab...@eternal-september.org"; posting-account="U2FsdGVkX19fQ8r4/zWs8um8CRJXrh9x" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 Cancel-Lock: sha1:wKMYHeUdIYnG3rV6pl3DlonHBPc= In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US On 2020-06-29 15:33, Ruvim wrote: > On 2020-06-28 18:30, Anton Ertl wrote: [...] >> : foo ]] "foo bar" type [[ ; immediate >> : bar foo ; >> bar >> >> works exactly like the version using POSTPONE above. >> >> It would take extra code to make it work differently. > > Yes. But it worth it. > > > The following implementation for "]] ... [[" construct covers the most > practical cases of your implementation and does not use the "postpone > action" from a token descriptor at all! Do we really need this action? > > >   : xt, compile, ; > >   : compile-compile-token? ( k*x td -- true | k*x td false ) >     td-nt over = if drop name>compile swap lit, xt, true exit then >     token>xt? if lit, 'xt, xt, true exit then >     postpone [: compile-token postpone ;] 'xt, xt, true A correction for the line above, to make the data stack transparent: depth >r postpone [: depth r> - n>r compile-token nr> drop postpone ;] 'xt, xt, true >     \ There is a possibility to return false >     \ for some implementation defined cases >   ; >   : next-lexeme ( -- c-addr u|0 ) >     begin parse-name ?ET ( addr ) refill ?E0 drop again >   ; >   : ]] >     begin next-lexeme 2dup "[[" equals 0= while >       recognize-any dup ?nf compile-compile-token? >       0= -32 and throw >     repeat 2drop >   ;