Click here to Skip to main content
14,335,083 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have a task
I need to Implement a program for extracting function calls and their arguments from the texts of C ++ programs. The program accepts text as input, should output text at the output, where information on the functions found is displayed in separate lines. Each line of output is a sequence of elements, separated by spaces: the name of the function, and the arguments.

What I have tried:

what i need to do?
i know that i need scan the text to find the methods pattern in the text but the question is is regular expression enough for this task or there is a tool to do that and i do not need to invent the wheel?
is it possible to implement this task in c# or better in java 
Updated 1-Feb-19 21:51pm
Richard MacCutchan 2-Feb-19 3:48am
You can use either language, but Google for language parsers, as there are a number of libraries that could assist you.
areejmayar 2-Feb-19 3:51am
i have been searching for a week there are many answers. Some people say that is enough to use regex and other said it is better not to reinvent the wheel and use suitable parser and I am new in this field. I need some help

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

It is possible to implement it in either C# or Java, but a Regex will not be sufficient: there are far, far too many varieties of method signature (and other code) that you need to deal with to make a regular expression viable.

Instead, look at finding a C++ parser in your prefered language and see what you can do with that - it's a major job to produce your own!
Google will help: C++ parser - Google Search[^] is a starting point.
areejmayar 2-Feb-19 4:45am
I read that there is Clang or AHTLR, I searched for their binding in C# and how to use them but without hope:(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100