A question about c-parse.y
James E Wilson
wilson@specifixinc.com
Fri Aug 6 19:56:00 GMT 2004
Simos Kordas wrote:
> I have succesfully created a C parser (with the
> functionality i described) using bison and a ISO-C
> grammar found in Internet, but it does not work with
> linux kernel sources.
You will have to extend the parser to support the GNU C extensions used
in the linux kernel. The attribute syntax and the extended asms syntax
probably gets you most of the way there. These are documented in the
gcc manual.
> Now i try to use the grammar
> from gcc (c-parse.y), but i have problems "cleaning it
> up".
The GCC grammer is not designed to be used outside gcc, and we likely
aren't interested in changes that would make this so, unless they
significantly help gcc somehow. It is probably better to instrument gcc
somehow so that it dumps the info you want.
Note also that since gcc is GPLed, if you borrow code from gcc, then the
GPL covers your application. Depending on what you are writing, this
may or may not be acceptable.
> grammar included in c-parse.y? Is there an other
> alternative way to get the function names (except
> -aux-info) without creating object files?
What is wrong with the -aux-info output? It seems to have the info you
are looking for. If you want the info in a slightly different form, you
could hack up gcc to emit exactly what you want.
You could try looking elsewhere for a grammar. The GNU C extensions are
widely known and widely copied, so you may be able to find a stand alone
C grammar that already includes support for the GNU C extensions.
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com
More information about the Gcc
mailing list