Plan 9 from Bell Labs’s /usr/web/sources/contrib/fgb/root/sys/src/cmd/4th/examples/demo/interact.4th

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


\ Interpreter example - (c) 1996,2008 HanSoft & Partners

true constant ignorenumbers            \ ignore numbers 
[needs lib/interprt.4th]
                                       \ define the 'NotFound'
:noname 2drop ." Not found!" cr ; is NotFound
                                       \ is mandatory too! 
: test ." test " ;                     \ dummy executables
: this ." This " ;                     \ part of the test interpreter
: a    ." a " ;
: is_  ." is " ;

create wordset                         \ dummy dictionary
  ," test" ' test ,                    \ must be assigned
  ," this" ' this ,                    \ to dictionary
  ," is"   ' is_  ,
  ," a"    ' a    ,
  NULL ,

wordset to dictionary                  \ assign to dictionary

: testit refill drop interpret cr ;    \ read a line and interpret

testit


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.