On Mon 09 Apr 01, 11:56 AM, Micah Cowan said: 
> 
> I can't think of a good reason why you'd need to use memmove() in your
> parser - perhaps you should rethink the algorithm?

well, maybe there IS a better way of doing things.   but suppose a user inputs

        Computer,    initiate  auto-destruct sequence 520010

and what i care about (in fact, what i use to fulfill the commnad) are the
words:

        auto-destruct 520010

but i also want to allow the user to be more polite:

        Computer, pretty please initiate auto-destuct sequence 520010.

i use memmove to do things like:

   1. convert double spaces to single spaces
   2. get rid of superfluous tokens like "pretty please" and "Computer".

and then i ship off the resulting string

    auto-destruct 520010

to my parser which tokenizes the nouns and executes the relevant code for
auto destruction.


i know there are other ways of doing this (like searching the string for
certain tokens and building up a list from the start).   however, i tend to
like this method better.  because i can more easily see what's going on when my
parser handles "auto-destuct 520010" rather than (12 52 00 10).   there are a
lot of tokens, and i'd rather work with "auto-destruct" than "12".

it occurs to me that this is the sort of thing that's perfect for lex/yacc, but
i've been dragging my feet because it looks fairly complicated.   i think maybe
i'll take a look at it though.

pete

> I've lately been
> very interested in the subject in general, so I've been working
> through my copy of the Wizard book.  /Very/ informative reading (the C
> code's kinda dated, though).
> 
> Micah

-- 
"Coffee... I've conquered the Borg on coffee!"               [EMAIL PROTECTED]
       -- Kathryn Janeway on the virtues of coffee           www.dirac.org/p

Reply via email to