Re: [C++-sig] pyste, gccxml and boost ublas, random number generator etc
Stefan Seefeld <[email protected]>
| Newsgroups | gmane.comp.documentation.synopsis |
|---|---|
| Message-ID | <[email protected]> |
Roman Yakovenko wrote: > On 8/3/05, Stefan Seefeld <[email protected]> wrote: >>As far as the scope is concerned, that sounds indeed a lot like synopsis. > > > Synopsis home page title - Synopsis: A Source-code Introspection Tool. > I don't want to build source-code introspection tool. What I want is > convenient description > of C++ declarations. Looking at C++ declarations is a way to inspect (introspect) code. >>Have you looked at the synopsis AST (http://synopsis.fresco.org/docs/Tutorial/ast.html) ? >>Is this not exactly what you are describing, i.e. a list of all declarations ? > > > Yes I did see this page, but its title confusing me. I only want > declarations. I understand > that this is all what you have right now. Obviously this is what I > should use. My only > concern is what will happen if you add defines or expression to the AST? What do you expect to happen ? The AST is a rich data structure that you can visit, and - by means of the visitor pattern - pick information from that you find useful. Everything else you may happily ignore. >>As far as code generation is concerned, I don't think this is quite enough, though. > > > My experience say opposite. Web services, cross language bindings - > use only declarations > to generate code. Indeed, for language bindings it seems to be enough - most of the time. > Could you give an example for code modification problem, except code > beautifiers? Recently someone approached me because he works on a monitoring tool that can inspect - at runtime - what code is being executed. He wants specific user methods to generate messages that get recorded. These methods, however, are written by users who are unaware of the monitoring, so he wants to process the code, injecting appropriate calls to his monitoring tool. You can find many more examples of this form of 'metaprogramming' in the documentation of the OpenC++ project (which synopsis once was based on). > Stefan could you write/point me to small example that includes > 1. creating AST tree from source file > 2. traveling on this AST tree. Sure. http://synopsis.fresco.org/docs/Tutorial/script.html describes how to write a synopsis script, using existing AST processors (such as a C++ parser). In particular, you may want to write your own processor class that defines and calls a 'AST.Visitor' class. Use this Visitor to implement the methods you want, i.e. that pick the AST nodes you are specifically interested in. Let me know if you need more detailed help (Feel free to join our irc channel at irc://irc.oftc.net/synopsis, I may be able to answer specific questions there. Regards, Stefan