Sujet : Re: Fetch string from comment
De : sjack (at) *nospam* dontemail.me (sjack)
Groupes : comp.lang.forthDate : 04. Mar 2025, 22:02:49
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vq7ppp$21q9f$1@dont-email.me>
References : 1 2
User-Agent : tin/2.6.4-20240224 ("Banff") (Linux/6.8.0-54-generic (x86_64))
minforth <
minforth@gmx.net> wrote:
Buddha said, om is boundless wisdom. ;-)
It's my favorite Forth word. When I type it, I become at peace.
For us poor novices, could you please share some Forth code
to show how you have implemented your novel nestable comments?
Having a nested comment is nothing new; Forthers been doing it
long back:
: (
ONE BEGIN
INC@ CASE
ZERO OF DROP ZERO ENDOF
ASC ( OF 1+ ENDOF
ASC ) OF 1- ENDOF
ENDCASE
DUP ONE < UNTIL
DROP ; IMMEDIATE
What may be new is the idea that if one has it then fetch it
from the input buffer and use it for string operations.
: @( PARSE_AREA [COMPILE] ( PARSE_AREA 1- OM ;
: .( @( TYPE ; \ print it
: S( @( SIB! ; \ stores in ring buffer
Didn't bother to generalize the next two:
Compile single line of text
: ,(
ONE BEGIN INC@ TUCK CASE
ZERO OF 2DROP EXIT ENDOF
ASC ( OF 1+ ENDOF
ASC ) OF 1- ENDOF
ENDCASE DUP WHILE SWAP C, REPEAT 2DROP ;
-- Compile multiple lines of text
: ,M(
ONE BEGIN INC@ TUCK CASE
ZERO OF SWAP DROP \N SWAP CR REFILL 0= IF ABORT THEN ENDOF
ASC ( OF 1+ ENDOF
ASC ) OF 1- ENDOF
ENDCASE DUP WHILE SWAP C, REPEAT 2DROP ;