Boost:regex and C++ Parsing
Hello, I have a couple of questions, firstly, how might I extend the example for parsing C++ code for class names so that it records the line number on which the class is defined? I thought maybe I could extend the regular expression so that it has "|(\n)" at the end, or maybe there is another way. In any case I am not sure if that is the correct way to extend the regex and I am unsure how to check the regex_match result to see if it was a new line character I encountered or a class name. Secondly, are there any efforts anywhere to parse C++ for other keywords by this approach? Many thanks for any help or hints on this, for the record I am really impressed with boost, a while ago, I might have said I didn't want the depandancy, but now I'd put up with that any time, good luck getting boost work into the next C++ standard, it's great! Regards Gaz
I think the general approach to parsing something as complex as C++
would be to use a parser like Spirit and not do it with regular
expressions.
There is at least one example of a C++ lexer in the Repository section
http://spirit.sf.net/
----- Original Message -----
From: Foster, Gareth
Foster, Gareth wrote:
I have a couple of questions, firstly, how might I extend the example for parsing C++ code for class names so that it records the line number on which the class is defined? I thought maybe I could extend the regular expression so that it has "|(\n)" at the end, or maybe there is another way. In any case I am not sure if that is the correct way to extend the regex and I am unsure how to check the regex_match result to see if it was a new line character I encountered or a class name.
Which example you're referring to?
Secondly, are there any efforts anywhere to parse C++ for other keywords by this approach?
I don't know of any efforts going on regarding C++ parsing with the help of regex (non-authoritative answer). But there is the Wave library (Boost review is due shortly), which is a C/C++ preprocessor containing different C++ lexing components, which may be helpful for you during writing a class name extraction tool. Regards Hartmut
participants (3)
-
Caleb Epstein
-
Foster, Gareth
-
Hartmut Kaiser