Re: Synopsis - tutorials
Stefan Seefeld <[email protected]> Thu, 26 Apr 2007 17:16:13 -0400
| Newsgroups | gmane.comp.documentation.synopsis |
|---|---|
| Message-ID | <[email protected]> |
Roman Yakovenko wrote: > On 4/26/07, *Stefan Seefeld* <[email protected] > <mailto:[email protected]>> wrote: > > Roman Yakovenko wrote: > > > Thanks. I built the documentation and I am reading it now. One more > > question what tree I need to travel, in order to extract all > > declarations: ast or parse tree? > > That's a good question, and answering it requires more context. > My goal is to make the parse tree (as well as related representations, > such as a symbol table, type repository, etc.) ready to become a public > API. However, I'm not there yet, i.e. it still keeps evolving. > > > The question is how much? If you make small not backward computable > changes, I think I can live with them If only I knew. :-) Just compare the PTree APIs between branches/Synopsis_0_8 and trunk to get an idea... > The parse tree is translated into an 'AST' (a pure python > representation), > which is stable and used in different contexts. Thus, you may look at > that first. However, depending on your needs you may find that it > doesn't > provide enough informmation for your purpose (code generation). In that > case, we either need to fill the holes by adding more attributes to > the AST, > or try to get the parse tree into a state which is usable by you (and > others). > > > I am not sure I see the difference between both trees. What tree > provide high level description of declarations? (The Parse Tree contains really everything. In fact it points into the input buffer, so when working on that you could even make local modifications to the code and generate files that are mostly identical to the input, down to the formatting. I don't think this is what you want. If all you want are the declarations, the AST should be enough. > I do have some (experimental) code to expose the parse tree (etc.) to > python using boost.python, and so I very much welcome any additional > motivation to move further in that direction. > > Any help would be highly appreciated. > > > I think I can help you with exposing the code to Python, just describe > what still should be done. The reflection itself is the easy part. What is hard is to figure out how the API should look like to be useful, as well as finish the parser (anything related to type analysis, e.g. template instantiation, overload resolution, etc.). Out of curiosity, what platform are you using ? (Your mail looks suspiciously like outlook-formatted.) Thanks ! Stefan -- ...ich hab' noch einen Koffer in Berlin...