|
( This file is part of muFORTH: http://pages.nimblemachines.com/muforth Copyright 2002-2008 David Frech. All rights reserved, and all wrongs reversed. (See the file COPYRIGHT for details.) ( Try out Chuck Moore's idea of storing either the count and first three letters of an identifier, or [my] modified idea of storing the count, the first two, and the _last_ letter.) decimal : filler ( a n) dup 3 - for char _ emit next ; : chumoo over 3 type ( 1st 3 chars) filler ; : chkmoe over 2 type ( 1st 2 chars) filler + 1- c@ emit ( last) ; defer .special : .id dup 4 u< if type ^ then .special ; : nm begin token 2dup " EOT" string= not while .id space repeat 2drop ; now chumoo is .special nm First of all, muforth is most emphatically _not_ ANS-compatible. It would be silly to write another when there are perfectly good ones available. I wanted instead to build a Forth with specific features, several of which are shamelessly stolen from Chuck Moore's colorforth (http://colorforth.com). I think I started with the question, "What would colorforth look like without color?" and went from there. I wanted a substrate for experiments, a good metacompiler, and something small and simple. EOT cr cr now chkmoe is .special nm First of all, muforth is most emphatically _not_ ANS-compatible. It would be silly to write another when there are perfectly good ones available. I wanted instead to build a Forth with specific features, several of which are shamelessly stolen from Chuck Moore's colorforth (http://colorforth.com). I think I started with the question, "What would colorforth look like without color?" and went from there. I wanted a substrate for experiments, a good metacompiler, and something small and simple. EOT ( I think the right thing to do is to simply go thru the existing dict chains, in turn, and see if any of the names collide. Starting on a new chain means starting with an empty set again.) 2000 cells buffer dict variable d ( pts into dict) dict d ! : d, d @ ! cell d +! ; : >chkmoe ( c" - c" id) dup @ "ff000000 bic over dup c@ + c@ 24 << or ; : >chumoo ( c" - c" id) dup @ ; defer >special : >id ( c" - c" id) dup c@ 4 u< if dup @ ^ then >special ; : _count ( c" - a n) dup 1+ swap c@ ; : scan ( c" id - c" id) push d @ begin dict over u< while [ 2 cells ] - dup @ ( c" d id2) r@ = if over _count type ." = " dup cell+ @ _count type cr then repeat drop pop ; : id, ( c" id) d, d, ; : ?collide ( c") >id scan id, ; : link>cname [ 2 cells ] + ; : words current @ ( link) begin @ =while dup link>cname ?collide repeat drop ; ." chumoo" cr now >chumoo is >special words cr cr dict d ! ." chkmoe" cr now >chkmoe is >special words ( An especially interesting thing to try is this: ./muforth -d debug -f target/arm.mu4 -f chumoo.mu4) |