Our website uses cookies to enhance your browsing experience.
to the top
close form

Fill out the form in 2 simple steps below:

Your contact information:

Step 1
Congratulations! This is your promo code!

Desired license type:

Step 2
Team license
Enterprise license
** By clicking this button you agree to our Privacy Policy statement
close form
Request our prices
New License
License Renewal
--Select currency--
* By clicking this button you agree to our Privacy Policy statement

close form
Free PVS‑Studio license for Microsoft MVP specialists
* By clicking this button you agree to our Privacy Policy statement

close form
To get the licence for your open-source project, please fill out this form
* By clicking this button you agree to our Privacy Policy statement

close form
I am interested to try it on the platforms:
* By clicking this button you agree to our Privacy Policy statement

close form
check circle
Message submitted.

Your message has been sent. We will email you at

If you haven't received our response, please do the following:
check your Spam/Junk folder and click the "Not Spam" button for our message.
This way, you won't miss messages from our team in the future.

Description of VivaVisualCode

Description of VivaVisualCode

Jul 02 2008

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. You may download both source texts (Visual Studio 2005 project) and the executable module.

What is VivaCore

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/en/a/0013/

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.

What is VivaVisualCore?

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 parentheses while grouping of operands in AST is defined explicitly by the tree structure.

Implementation of VivaVisualCode

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.

User interface

Let's briefly consider the menu-items in VivaVisualCode application:

  • File -> Open i-file... - allows you to load a preprocessed i-file. Note: The program serves for demonstration purposes and is not intended for working with large files.
  • File -> Export Image - allows you to export the built parse tree into BMP file.
  • File -> Exit - to exit the program.
  • Code -> Edit Code - editing of input C++ code.
  • View -> List Mode. In VivaCore library the data are represented as binary trees. But logically the work is carried out over the lists. As the result there are auxiliary nodes implementing the lists on the basis of the tree. This menu item allows you to hide or show these auxiliary nodes.
  • View -> Close All - to minimize all the nodes
  • View -> Open All - to extend all the nodes.

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:

  • Scroll the window when the tree doesn't fit into the screen.
  • Minimize and extend the nodes (left mouse button).
  • Scale the image (Ctrl + mouse scroll wheel).
  • You can get additional information concerning each node by clicking the right mouse button on it (see figure 2).

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!

Popular related articles

Comments (0)

Next comments next comments
close comment form