|
-
September 9th, 2011, 08:12 AM
#1
Parse C++ function
I am interested in C++ functions prototypes parsing. Are there solutions?
-
September 9th, 2011, 09:45 AM
#2
Re: Parse C++ function
I'm not quite sure if I understand what you mean... Could you elaborate?
-
September 9th, 2011, 09:50 AM
#3
Re: Parse C++ function
 Originally Posted by angelorohit
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
-
September 9th, 2011, 09:54 AM
#4
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?
-
September 9th, 2011, 09:55 AM
#5
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.
-
September 9th, 2011, 10:42 AM
#6
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.
-
September 9th, 2011, 11:15 AM
#7
Re: Parse C++ function
Maybe you should add a few more details about what you're trying to do.
-
September 9th, 2011, 11:22 AM
#8
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.
-
September 9th, 2011, 11:55 AM
#9
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.
-
September 9th, 2011, 06:20 PM
#10
Re: Parse C++ function
 Originally Posted by user008
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|