--- gforth/prims2x.fs 2001/03/18 12:39:33 1.93 +++ gforth/prims2x.fs 2001/05/13 10:54:10 1.96 @@ -53,19 +53,6 @@ warnings off -[IFUNDEF] vocabulary \ we are executed just with kernel image - \ load the rest that is needed - \ (require fails because this file is needed from a - \ different directory with the wordlibraries) -include ./search.fs -include ./extend.fs -include ./stuff.fs -[THEN] - -[IFUNDEF] environment? -include ./environ.fs -[THEN] - : struct% struct ; \ struct is redefined in gray include ./gray.fs @@ -431,7 +418,8 @@ wordlist constant prefixes rdrop ; : type-prefix ( xt1 xt2 n stack "prefix" -- ) - create-type + get-current >r prefixes set-current + create-type r> set-current does> ( item -- ) \ initialize item { item typ } @@ -481,7 +469,9 @@ does> ( item -- ) prim prim-effect-out prim prim-effect-out-end @ ['] print-declaration map-items ; : stack-prefix ( stack "prefix" -- ) + get-current >r prefixes set-current name tuck nextname create ( stack length ) 2, + r> set-current does> ( item -- ) 2@ { item stack prefix-length } item item-name 2@ prefix-length /string item item-name 2! @@ -1223,6 +1213,18 @@ warnings @ [IF] .( parser generated ok ) cr [THEN] + +\ run with out of box gforth 0.5.0 +[IFUNDEF] slurp-file +: slurp-file ( c-addr1 u1 -- c-addr2 u2 ) + \ c-addr1 u1 is the filename, c-addr2 u2 is the file's contents + r/o bin open-file throw >r + r@ file-size throw abort" file too large" + dup allocate throw swap + 2dup r@ read-file throw over <> abort" could not read whole file" + r> close-file throw ; +[THEN] + : primfilter ( addr u -- ) \ process the string at addr u over dup rawinput ! dup line-start ! cookedinput !