0

for a diffing script I am trying to extract a C++ class with a known name from a header file. I thought of using recursive regular expressions. Bu they don't seem to be supported by python re.

Any suggestions on how to tackle this alternatively?

Thanks, Alex

  • You really should evaluate existing tools before you go and write your own. Also since you have no code here to debug or offer advice on, this question is too broad for the Stack Overflow format. – tadman Dec 08 '16 at 17:18
  • 2
    Regex doesn't work on languages with nested parentheses/braces/brackets/quotes. A recursive regex sort of might work, but you really need to handle all the complexities of C++ source code (comments, preprocessor directives/conditionals), if you want to do this. Basically you need a full C++ parser, unless your are willing to constrain your solution to a very small number fo special cases you control. If somebody else is writing the code you want to extract, you aren't in control. – Ira Baxter Dec 08 '16 at 17:24
  • IMHO, a better idea is to use an existing "diffing" tool rather than writing your own. Search the web, there are a plethora of them. – Thomas Matthews Dec 08 '16 at 17:27
  • Currently I am using wdiff to diff the files. – alexanderb14 Dec 08 '16 at 17:50
  • The problem however is that some files contain more than 1 class. That's why I am trying to extract the class xyz { }; part of the file and diff it, instead of the whole file – alexanderb14 Dec 08 '16 at 17:50
  • 1
    Check out our "SmartDifferencer", which a) compares syntax rather than text, b) handles moved code. Yes, it uses a full C++ parser. See http://www.semanticdesigns.com/Products/SmartDifferencer/ – Ira Baxter Dec 08 '16 at 20:05

0 Answers0