C++ code parser...
-
Does anyone know of a class that parses C/C++ code (like the classview tree in VS)? ~Nitron.
ññòòïðïðB A
start -
earl wrote:
Parse how? You mean a lexer?
I'm not sure what it's called else I would have googled it.... I want to extract structs, typedefs, classes, externs, globals, etc. the same way the class-view tree does in Visual Studio. I don't know what the act of doing such is called, other than "parsing". ~Nitron.
ññòòïðïðB A
start -
Does anyone know of a class that parses C/C++ code (like the classview tree in VS)? ~Nitron.
ññòòïðïðB A
startParsing C++ is insanely difficult. You could try hacking the gcc parser (hard) or maybe take a look at this[^]. It's a long time since I looked at PCCTS but IIRC, it seemed to work :-) I use CCCC[^] for metrics sometimes and that has a parser as well.
0 bottles of beer on the wall, 0 bottles of beer, you take 1 down, pass it around, 4294967295 bottles of beer on the wall. Awasu 2.2.2 [^]: A free RSS/Atom feed reader with support for Code Project.
-
earl wrote:
Parse how? You mean a lexer?
I'm not sure what it's called else I would have googled it.... I want to extract structs, typedefs, classes, externs, globals, etc. the same way the class-view tree does in Visual Studio. I don't know what the act of doing such is called, other than "parsing". ~Nitron.
ññòòïðïðB A
startMan, that's not a trivial thing to do. To start you'll need a lexer -- takes text and determines if it's valid C++. This alone takes some doing, cause C++ isn't the most syntactically pretty language around. Don't try and do it yourself or you'll die of old age; instead, write a grammer and lean on a lexer. Then you'll need a parser; it takes the output from a lexer and typically gives you a structure tree. Grab the dragon book and read about compiler construction; you're building the first two or three stages of one. For available tools, try lex, yacc, and bison. earl