Skip to content

Commit 8018b73

Browse files
author
theBF
committed
Updated KEY" to strip punctuation
1 parent 3cb2a27 commit 8018b73

File tree

7 files changed

+23
-22
lines changed

7 files changed

+23
-22
lines changed

DEMO/ELIZA/ELIZA3.2.FTH

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,11 @@ CREATE []KEYWORDS []KEYWORDS KEY_SIZE ALLOT
240240

241241
: ]KEYWORD ( n -- addr) $WIDTH * []KEYWORDS + ;
242242
: KEY, ( addr u --) #KEYWORDS @ ]KEYWORD PLACE #KEYWORDS 1+! ;
243-
: KEY" [CHAR] " PARSE KEY, ;
243+
244+
\ KEY" removes punctuation from the stored string because the
245+
\ analyzer removes it as well.
246+
\ But you can use it in the source code for human readability
247+
: KEY" [CHAR] " PARSE PUNCTUATION$ STRIP KEY, ;
244248

245249
\ debugging ..............
246250
\ : PRINT$ COUNT TYPE ;
@@ -281,15 +285,6 @@ VARIABLE POSITION
281285

282286
: KEYWORD$ ( -- $addr) KWORD# @ ]KEYWORD ;
283287

284-
\ : A$ S" This rain in spain, is mainly on the TI-99" ;
285-
\ S" POOPY DIAPER" FIND-KEYWORD
286-
\ CR CR .S
287-
288-
\ : .KEYWORD KEYWORD$ COUNT TYPE ;
289-
290-
: ANALYZE ( addr len --)
291-
PUNCTUATION$ STRIP TOUPPER FIND-KEYWORD ;
292-
293288

294289
\ ==============================================
295290
\ --- REPLIES SUPPORT CODE ---
@@ -336,7 +331,7 @@ MACRO []XT " CELLS R@ + 2 CELLS +" \ address of Array of Xts
336331
\ of the keyword phrase.
337332
\ return everything after the keyword phrase
338333
: /TAIL ( addr len -- adr len)
339-
POSITION @ KEYWORD$ LEN + /STRING 0 MAX ;
334+
POSITION @ KEYWORD$ LEN + 1+ /STRING 0 MAX ;
340335

341336

342337
\ conjugate any phrases in the ]PHRASE table
@@ -368,6 +363,13 @@ MACRO []XT " CELLS R@ + 2 CELLS +" \ address of Array of Xts
368363

369364
: <TOPIC?> <TOPIC> '?' ;
370365

366+
: ANALYZE ( addr len --)
367+
PUNCTUATION$ STRIP TOUPPER FIND-KEYWORD ;
368+
369+
370+
\ ALL THE REPLY CODE IS KEPT IN THE ELIZA VOCABULARY
371+
\ THIS PREVENTS A NAME COLLISION WITH THE 'IF' KEYWORD
372+
371373
ONLY FORTH ALSO ELIZA DEFINITIONS
372374
\
373375
\ Replies for unknown KEYWORD
@@ -383,12 +385,6 @@ ONLY FORTH ALSO ELIZA DEFINITIONS
383385
:: CR ." Do you feel strongly about discussing such things?" ;
384386
} REPLY: TAPDANCE
385387

386-
\ **************************************************
387-
\ Eliza replies are separate file for easier editing
388-
\ They compile into LOW RAM and take almost all 8K
389-
S" DSK2.ELIZADATA4" INCLUDED
390-
391-
\ **************************************************
392388

393389
\ A few more reply type words
394390
DECIMAL
@@ -407,7 +403,7 @@ DECIMAL
407403
\ Keyword Forth word that is called
408404
KEY" BYE" : BYE END_SESSION ;
409405
KEY" GOODBYE" : GOODBYE END_SESSION ;
410-
406+
411407
\ bad words list
412408
KEY" SHIT"
413409
{ :: CR ." Hey now." CR ." We don't use that kind of language here." ;
@@ -424,6 +420,12 @@ DECIMAL
424420
KEY" BASTARD" : BASTARD SHIT ;
425421
KEY" HELL" : HELL SHIT ;
426422

423+
\ **************************************************
424+
\ Eliza replies are separate file for easier editing
425+
\ They compile into LOW RAM and take almost all 8K
426+
S" DSK2.ELIZADATA4" INCLUDED
427+
428+
\ **************************************************
427429
\ programmer's trap door into Forth :-)
428430
KEY" CONSOLE" : CONSOLE
429431
CR
@@ -478,5 +480,4 @@ DECIMAL
478480
LOCK
479481

480482
INCLUDE DSK1.SAVESYS
481-
482483
' START SAVESYS DSK2.ELIZA

DEMO/ELIZA/ELIZADATA4.FTH

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ DECIMAL
6363
:: CR ." Many people have " <TOPIC> '.' ;
6464
} REPLY: IHAVE
6565

66-
KEY" I'VE" : IVE IHAVE ;
66+
KEY" IVE" : IVE IHAVE ;
6767

68-
KEY" WHY DON'T YOU"
68+
KEY" WHY DONT YOU"
6969
{ :: CR ." Do you really believe I don't " <TOPIC?> ;
7070
:: CR ." Perhaps in good time I will " <TOPIC> '.' ;
7171
:: CR ." Do you want me to " <TOPIC?> ;
@@ -317,7 +317,7 @@ DECIMAL
317317
:: CR ." Hello again :-)" ;
318318
} REPLY: HELLO
319319

320-
KEY" HI" : HI HELLO ;
320+
KEY" HI " : HI HELLO ;
321321
KEY" BONJOUR" : BONJOUR HELLO ;
322322

323323

DEMO/ELIZA/bin/dsk2.eliza/ELIZA

0 Bytes
Binary file not shown.

DEMO/ELIZA/bin/dsk2.eliza/ELIZA,FTH

14.1 KB
Binary file not shown.

DEMO/ELIZA/bin/dsk2.eliza/ELIZADATA

11.9 KB
Binary file not shown.

DEMO/ELIZA/bin/dsk2.eliza/ELIZB

0 Bytes
Binary file not shown.

DEMO/ELIZA/bin/dsk2.eliza/ELIZC

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)