Description of VivaVisualCode
What is VivaCore
What is VivaVisualCore?
Implementation of VivaVisualCode
This article concerns the program VivaVisualCode, showing how to use VivaCore library. VivaVisualCode represents in a graphic form the parse tree of the input source code in C++.
Many libraries have a great disadvantage of absence of examples allowing you to consider the results of their work in a simple visual form. It is usual in the sphere of analysis and processing of programs' source code. Demo examples are made as programs accepting through the command line files' names, a lot of keys and generating other files at output. This user-unfriendly interface causes negative attitude to the library while using it for the first time, no matter whether the library is suitable for the task being solved.
We tried to use an approach that would allow the user to understand what he deals with as quickly as possible. Developing a program demonstrating the abilities of VivaCore library we decided to make it as a graphic application building a parse tree on the input C++ code. As the result a demo program VivaVisualCode appeared which you may download from http://www.viva64.com/vivavisualcode.php. You may download both source texts (Visual Studio 2005 project) and the executable module.
VivaCore is an open library for working with C and C++ code. The library is intended for implementing on its basis systems of code refactoring, static and dynamic analysis, code transformation or optimization systems, language extensions, subsystems of syntax highlighting, systems of building documentation on the code and other similar tools.
As a starting point for creation of VivaCore library another open library OpenC++ was taken: http://opencxx.sourceforge.net
To learn more about VivaCore library you may read the article "The essence of the code analysis library VivaCore" here: http://www.viva64.com/art-2-2-449187005.html
License on VivaCore library allows you to use, copy and distribute it both in binary form and as source code both for commercial and non-commercial use without any payments to the authors of the library. You are only to mention the authors of the source libraries (OpenC++ and VivaCore).
You may download VivaCore library from http://www.viva64.com/vivacore-download.php
VivaVisualCode is a program demonstrating in a visual form the abilities of VivaCode library in building of parse trees for C++ code. VivaVisualCode implements graphic representation of a parse tree on the screen (see figure 1).
Figure 1. An example of a parse tree for code "float Value = 10.0 * 20.0;" built by VivaVisualCode.
The Parse Tree being created differs from the Abstract Syntax Tree (AST) in that it contains nodes for those syntax rules which don't influence the program's semantics. A typical example of such nodes is grouping brackets while grouping of operands in AST is defined explicitly by the tree structure.
The demo program VivaVisualCode is very simple. One can say that it provides the user interface to some functions of VivaCore library. For example, it allows you to type the text of a program to be parsed, to represent the built parse tree in a graphic form, to get additional information about the tree's nodes.
You may consider the details of its implementation in the source code of VivaVisualCode itself. The source code is open and you may modify and use it for your own purposes free.
Let's briefly consider the menu-items in VivaVisualCode application:
After the program is loaded through "File->Open i-file..." or "Code->Edit Code" the parse tree will be shown on the screen. The nodes of the tree are colored differently depending on its type. Terminal nodes (leaves) show information about lexemes they represent. Terminal blocks are colored pink for lexemes which are C++ key words. Otherwise they are colored green to show that the lexemes are final leaves. The nodes of the high level contain names and number of branches.
You can also:
Figure 2. View of encoded type for declaration of the class constructor.
Of course, the program we offer you is not sufficient to demonstrate all the abilities of VivaCore library and to show its potential scopes of use. But we hope that it will help you to master main work principles of VivaCore library.
We are always ready to communicate. Write us!
1. Andrey Karpov, Evgeniy Ryzhkov. The essence of the code analysis library VivaCore. http://www.viva64.com/art-2-2-449187005.html
2. Andrey Karpov. How VivaCore library appeared. http://www.viva64.com/art-2-2-1358074540.html
|All times are GMT +5.5. The time now is 12:39.|