Subject: Re: [linux-audio-dev] Command parser?
From: Erik Steffl (esteffl_AT_pbi.net)
Date: Wed Aug 23 2000 - 02:53:47 EEST
Juhana Sadeharju wrote:
>
> >From: Erik Steffl <esteffl_AT_pbi.net>
> >
> > use perl and regular expressions
>
> How it is used for language parsing? I thought it was for some text
> mangling a la grep, sed, awk.
from what you've wrote it looked like the sort-of-parsing that you can
do with regular expressions is enough. for example:
having a line:
$line = "123123.455 some_string"
you can get a number and string:
$line =~ /([0-9.]*)[ ]*(.*)/;
print $1; # number
print $2; # the rest (except of leading spaces)
you can use this approach to 'parse' text files, if you don't need
real grammar, i.e. if you are looking for patterns.
> > use regular expressions in C or C++ (there are some fairly convenient
> >libraries, at least I've heard so)
>
> I will look at GNU libc; didn't remember it has some good tools.
the standard stuff is not as easy to use as the perl regular
expressions but there are some C++ classes that looked quite
interesting, try some search (I haven't really tried any so I don't have
any specific recommendation)
on most Unices there is support for regular epxressions in C, check
man pages for re_comp and re_exec
> > 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...
>
> I thought they were only for language parsing, not for searching
> items inside a complete document. I have used them once; maybe I give
> a try.
well, maybe regular expressions are more suitable in your situation -
if you want to stay in c/c++ family definitely check some regexp class
libraries...
erik
This archive was generated by hypermail 2b28 : Wed Aug 23 2000 - 04:01:04 EEST