Parsing C/C++ in Ruby

Discussion in 'Ruby' started by Sparky Mat, Jan 13, 2009.

  1. Sparky Mat

    Sparky Mat Guest

    I need to parse a source tree to generate a table of functions used.
    GCC-XML is causing more trouble than helping (I might be using it
    wrong). Is there a C/C++ parser library (written in Ruby) available?
    Failing which, which parser generator would you recommend, that would
    help me write a simple C parser? My CC skills are a bit rusted, and it
    would greatly help if the parser generator library has examples and/or
    tutorials.
    --
    Posted via http://www.ruby-forum.com/.
    Sparky Mat, Jan 13, 2009
    #1
    1. Advertising

  2. Sparky Mat

    Alex Fenton Guest

    Sparky Mat wrote:
    > I need to parse a source tree to generate a table of functions used.
    > GCC-XML is causing more trouble than helping (I might be using it
    > wrong). Is there a C/C++ parser library (written in Ruby) available?
    > Failing which, which parser generator would you recommend, that would
    > help me write a simple C parser? My CC skills are a bit rusted, and it
    > would greatly help if the parser generator library has examples and/or
    > tutorials.


    I haven't used gcc-xml but it would seem to me the right tool for the job.

    As an alternative you could use SWIG, and output the results to xml (use
    the -xml or -xmlout options). Then parse that XML with rexml or libxml.

    C++ is a pretty complex language to parse, but SWIG understands most of
    it - certainly enough to locate methods and functions.

    a
    Alex Fenton, Jan 13, 2009
    #2
    1. Advertising

  3. On Tue, Jan 13, 2009 at 7:14 AM, Alex Fenton <> wrote:
    > Sparky Mat wrote:
    >>
    >> I need to parse a source tree to generate a table of functions used.
    >> GCC-XML is causing more trouble than helping (I might be using it
    >> wrong). Is there a C/C++ parser library (written in Ruby) available?
    >> Failing which, which parser generator would you recommend, that would
    >> help me write a simple C parser? My CC skills are a bit rusted, and it
    >> would greatly help if the parser generator library has examples and/or
    >> tutorials.

    >
    > I haven't used gcc-xml but it would seem to me the right tool for the job.
    >
    > As an alternative you could use SWIG, and output the results to xml (use the
    > -xml or -xmlout options). Then parse that XML with rexml or libxml.
    >
    > C++ is a pretty complex language to parse, but SWIG understands most of it -
    > certainly enough to locate methods and functions.
    >
    > a
    >
    >
    >
    >


    What problems are you having with GCC-XML?

    Have you checked out rbgccxml? http://github.com/jameskilton/rbgccxml

    Jason
    Jason Roelofs, Jan 13, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. GIMME
    Replies:
    2
    Views:
    859
    GIMME
    Feb 11, 2004
  2. Naren
    Replies:
    0
    Views:
    561
    Naren
    May 11, 2004
  3. Christopher Diggins
    Replies:
    0
    Views:
    592
    Christopher Diggins
    Jul 9, 2007
  4. Christopher Diggins
    Replies:
    0
    Views:
    415
    Christopher Diggins
    Jul 9, 2007
  5. John Levine
    Replies:
    0
    Views:
    711
    John Levine
    Feb 2, 2012
Loading...

Share This Page