Graphing tool for AST creation

plutos

_Вечный_Студент_
Мудрец
Сообщения
66
Реакции
559
привет, дорогие друзья!
Ищу какую-нибудь по возможности простую в употреблении и установке программу для создания графического отображения AST для, к примеру, С кода.
Их вроде как много, но все такие заковыристые и капризные, что нужно Бог знает сколько времени потратить на изучение и установку всех prerequisites.
Doxygen имею, но может есть что нибудь еще?
Заранее благодарен!
 

sendersu

Посетитель
Мудрец
Сообщения
36
Реакции
383
из того что приходит на ум
- GraphViz/dot
- clang умеет делать AST и его можно скормить тому же графвизу
-....
 

mak

Соломенные сандалии
Администратор
Сообщения
497
Реакции
254
Clang supports showing the AST with Graphviz's dotty -- you can grab the temporary .dot file generated (name is printed out) to get the graph source.
clang -cc1 -ast-view your_file.c

You can also print to the command line with:
clang -cc1 -ast-dump your_file.c
or:
clang -cc1 -ast-print your_file.c

or in 3.3:
clang -cc1 -ast-dump-xml your_file.c

but this was removed later as pointed by Lukas Kubanek in the comment.
The method with -cc1 invocation will have problem with includes and recognizing C++.

For full-featured parsing, use:
clang -Xclang -ast-dump file.cpp
Источник - How to view Clang AST?


cppast
Library interface to the C++ AST — parse source files, synthesize entities, get documentation comments and generate code.

Motivation
If you're writing a tool that needs access to the C++ AST (i.e. documentation generator, reflection library, …), your only option apart from writing your own parser is to use clang. It offers three interfaces for tools, but the only one that really works for standalone applications is libclang. However, libclang has various limitations and does not expose the entire AST.

So there is no feasible option — except for this library. It was originally a part of the standardese documentation generator, but has been extracted into an independent library.

See this blog post for more information about the motiviation and design.

Features
  • Exposes (almost) all C++ entities: Supports everything from functions to classes, templates to friend declarations, macros to enums;
  • Exposes full information about C++ types;
  • Supports and exposes documentation comments in various formats with smart entity matching;
  • Supports C++11 attributes (including user-defined ones);
  • AST hierarchy completely decoupled from parser: This allows synthesizing AST entities and multiple parsing backends;
  • Parser based on libclang: While libclang does have its limitations and/or bugs, the implemented parser uses various workarounds/hacks to provide a parser that breaks only in rare edge cases you won't notice. See issues tagged with libclang-parser for a list;
  • Simple yet customizable code generation interface.
Missing features
  • Support modification of parsed entities: they're currently all immutable, need to find a decent way of implementing that
  • Full support for expressions: currently only literal expressions are exposed;
  • Support for statements: currently function bodies aren't parsed at all;
  • Support for member specialization: members of a template can be specialized separately, this is not supported.
 
Верх Низ