Created
July 21, 2010 03:20
-
-
Save lsparrish/484007 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( char dictionary ) | |
variable cdl | |
: cdn ( "- ) 32 accept here @cdl , @tib , !cdl -1 , ] ; | |
: cdf ( c-af ) cdl repeat @ 2dup 1+ @ =if nip 3 + -1 ;then dup 0; drop again ; | |
: cde ( c- ) cdf if dup 1- @ 0 =if drop ;then execute ;then drop ; | |
: cda ( c- ) cdf if 1- on ;then '? emit ; | |
: cdd ( c- ) cdf if 1- off ;then '? emit ; | |
( keep tib string ) | |
: kts tib here over getLength 1+ dup allot copy ; | |
( accept input, test each char ) | |
tib variable: t | |
variable del | |
: t, ( n- ) !@t t ++ ; | |
: zt ( - ) 0 t, tib !t ; | |
: accept ( n"- ) !del | |
repeat key dup emit | |
dup cde | |
dup @del =if zt drop ;then | |
t, again ; | |
cdn : kts drop 32 ; | |
: foo 32 accept tib type ; | |
foo test: | |
': cdd ( deactivate ) | |
foo test: | |
': cda ( activate ) | |
foo test: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment