CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Oct 2010
    Location
    Russia
    Posts
    69

    Parse C++ function

    I am interested in C++ functions prototypes parsing. Are there solutions?

  2. #2
    Join Date
    Oct 2006
    Location
    Singapore
    Posts
    346

    Re: Parse C++ function

    I'm not quite sure if I understand what you mean... Could you elaborate?
    Believe in your Dreams, Work for what you Believe in.
    My thoughts? Angelo's Stuff
    Some fun things I've done: RayWatch, QuickFeed, ACSVParser

    @ngelo

  3. #3
    Join Date
    Oct 2010
    Location
    Russia
    Posts
    69

    Re: Parse C++ function

    Quote Originally Posted by angelorohit View Post
    I'm not quite sure if I understand what you mean... Could you elaborate?
    int f(int x, int y);
    parameter1 name x type int
    parameter2 name y type int
    return value int

  4. #4
    Join Date
    Oct 2006
    Location
    Singapore
    Posts
    346

    Re: Parse C++ function

    Yes, I'm aware of what a function prototype means. However, what do you mean by parsing? Are you talking about identifying all function prototypes in a source file?
    Believe in your Dreams, Work for what you Believe in.
    My thoughts? Angelo's Stuff
    Some fun things I've done: RayWatch, QuickFeed, ACSVParser

    @ngelo

  5. #5
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: Parse C++ function

    So where are you stuck? The first word would be the return type, the second word the function name, then you just alternate between types and names.

  6. #6
    Join Date
    Oct 2010
    Location
    Russia
    Posts
    69

    Re: Parse C++ function

    There would be preferably that result would be returned (success or fail) and incorrect code would be broken pretty quick. It is not difficult problem but if there is complete solution I would use it.
    Last edited by user008; September 9th, 2011 at 10:44 AM.

  7. #7
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: Parse C++ function

    Maybe you should add a few more details about what you're trying to do.

  8. #8
    Join Date
    Apr 2008
    Posts
    118

    Re: Parse C++ function

    Yes, there is a way to tell incorrect code; you can write the code and then use a program called a compiler on it. The compiler will tell you if the code is incorrect, and will usually give you details of which line(s) are wrong.

  9. #9
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: Parse C++ function

    You could write a complete C parser. (A complete C++ parser would likely be far too much work.) Once you have that, identifying the function prototypes should be trivial.

  10. #10
    Join Date
    May 2009
    Posts
    2,413

    Re: Parse C++ function

    Quote Originally Posted by user008 View Post
    I am interested in C++ functions prototypes parsing. Are there solutions?
    One solution is to use a parser generator. The most well-known is Yacc,

    http://en.wikipedia.org/wiki/Yacc

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured