help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: is Bison the correct tool to use?


From: Hans Aberg
Subject: Re: is Bison the correct tool to use?
Date: Tue, 27 Nov 2001 11:47:59 +0100

At 20:27 -0500 2001/11/26, Olson, Dave -Systems wrote:
>I'm looking for a way to scan lots of C++ code for certain method names and
>then detect whether one of a list of identifiers is used by that method.  I
>began delving into Bison to see if I can write a simple grammer/script to do
>that, but I woud appreciate an experienced opinion.  Can I extract the
>entire method body as one compound-statement and pass it to my own C code?
>Is Bison the right tool to use to do this?
>sincerely,

I am not expert on this, but here is an input:

You could use Bison/flex for doing such things, but if the task is merely
to filter out certain text components, some other program might be simpler
(have you looked at Perl).

If you merely want to strip out the body of classes and such, then you
might use Flex alone, using its "start conditions": When word "class" is
detected, set a start condition to detect the first "{"; then set another
start condition valid until "};" has been detected. Then refine this start
condition to detect the names that you want.

Using Bison, you can make more sophisticated parsing, but you will have to
spend more time figuring out how to work with a genuine compiler-compiler.

  Hans Aberg





reply via email to

[Prev in Thread] Current Thread [Next in Thread]