Sujet : Re: Parsing timestamps?
De : dxforth (at) *nospam* gmail.com (dxf)
Groupes : comp.lang.forthDate : 09. Oct 2024, 02:06:28
Autres entêtes
Organisation : i2pn2 (i2pn.org)
Message-ID : <20cdd403f7ff3e8c3980e864fd363526111af4f8@i2pn2.org>
References : 1 2 3 4 5 6
User-Agent : Mozilla Thunderbird
On 9/10/2024 7:30 am, sjack wrote:
dxf <dxforth@gmail.com> wrote:
Not bad. Here's a translation. Hopefully it's equivalent (?)
FigForth NUMBER is a quirky beast. It starts on a counted string
but doesn't care about the count and it must end on a space.
It's why I replaced ":" with space before I split and then
split on space. Perhaps your NUMBER is better behaved.
I have many versions as no single one can cover all possibilities.
In the kernel alone there is:
: (NUMBER) ( addr u -- ud addr2 u2 )
0 0 2swap >number ;
: /NUMBER ( addr u -- addr2 u2 d|ud )
/sign >r (number) 2swap r> if dnegate then ;
: NUMBER? ( addr u -- d|ud true | false )
dup if /number dpl on 2swap dup if 1- over c@
[char] . - or dpl off then nip 0= if true end
then 2drop false ;