delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/05/08:41:22

From: Erik Max Francis <max AT alcyone DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Command Parser
Date: Fri, 04 Apr 1997 09:36:54 -0800
Organization: Alcyone Systems
Message-ID: <33453C36.783D1B0A@alcyone.com>
References: <01bc409f$afbb59c0$97c3b8cd AT scully> <3344C7BC DOT 41C6 AT LSTM DOT Ruhr-UNI-Bochum DOT De>
NNTP-Posting-Host: newton.alcyone.com
Mime-Version: 1.0
Lines: 30
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Thomas Demmer wrote:

> flex & bison are exactly what you're looking for. You can find
> the djgpp ports under v2gnu on your local simtel mirror.

Since he's only looking to parse out simply-delimited strings, you're
probably biting off more than he can chew.

He can use the ANSI C library call strtok to do the work for him.

If commandLine is a character array holding the full command line, then
this code will print each command, presuming you want the commands
delimited by spaces:

    char *s;

    for (s = strtok(commandLine, " "); s; s = strtok(0, " ")
        printf("%s\n", s);

Quite a bit simpler.  If he wants to embed spaces in the command line with
escape characters or in double quotes, then he's going to have to do that
himself.

-- 
       Erik Max Francis, &tSftDotIotE / email:  max AT alcyone DOT com
                     Alcyone Systems /    web:  http://www.alcyone.com/max/
San Jose, California, United States /    icbm:  37 20 07 N  121 53 38 W
                                   \
                          "E pur, / sic muove!"
                                 / Galileo Galilei

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019