Here's a late reply:

If you need to parse something look at ANTLR
(www.antlr.org).  I've used this tool for several
years. It is a bit tricky to pick up, but works
very well for real world apps -- much more useable
and powerful than yacc/bison/etc.  It can generate 
parsers in Java, C++ and Sather.  In addition
to parsing ASCII, it can parse binary input (with
a custom lexer) and 2-D tree structures.

Jim

Erik Steffl wrote:
> 
>   there are several options:
> 
>   use perl and regular expressions
> 
>   use regular expressions in C or C++ (there are some fairly convenient
> libraries, at least I've heard so)
> 
>   use strtok function + other string fuintctions in C (fairly
> cumbersome)
> 
>   lex and yacc (or flex&bizon) is probably the most elegant choice, if
> you do not have experience with these tools it might be a good way to
> learn more about parsing, but if you only want to get job done it might
> require too much learning...
> 
>         erik
> 
> Juhana Sadeharju wrote:
> >
> > Hello. I need to read simple commands from a file and execute the commands
> > as they are read. What would be a good system for reading them?
> >
> > Actually, I think parsing a file is most difficult programming task.
> > For example, a simple fscanf could not find "%i patents" string
> > from the file even the file had one. Yep, I'm writing a system to
> > automatically notify me if new patents has arrived in the audio classes
> > and a system to keep up what patents I have already seen or downloaded.
> >
> > Anyway, now I need a simple language for an audio project. The file
> > format would be following.
> >
> >   command1 <float>
> >   command2 <int> <int> <float>
> >   command3 <string> <float> <float>
> >
> > I have started to write a simple parser which finds first command,
> > and then reads as many parameters as the command has, and then another
> > command. It will exit the program if an error is found. First problem
> > is: how to find the commands and parameters? With fscanf(..,"%s",..)
> > and fscanf(..,"%f",..), and so on? How about comment lines?
> >
> > Or should I use Bison? Can Guile be used? Python? What does Guile and
> > Python code look a like? Any others? Would they work with the patent
> > file problem? I.e., finding a string from an entire file.
> >
> > I would be willing to use more complex parser than what I have started
> > to write because later I sure will need something more complex in my
> > wave editor.
> >
> > Regards,
> >
> > Juhana

Reply via email to