8000 GitHub - LightFLP/Alpha: Alpha is a tool based on Rascal for parsing C++ code and producing M3 models in JSON.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

LightFLP/Alpha

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alpha

Alpha is a tool based on Rascal for parsing C++ code and producing M3 models in JSON. These models contain rich information about the source code, such as information about variables, functions, classes, templates, etc., and the dependencies between such elements. These models can then be used as input for M3GraphBuilder, which produces graphs for visualizing the source code structure in ClassViz, ARViSAN, and BubbleTeaViz.

Table of Contents

Getting Started with Alpha

To start parsing C++ with Alpha, follow these steps. The sections below contain more information about the separate steps.

  1. Clone the repository.
  2. Prepare your input. Create three text files which will contain the paths to the cpp files to be parsed, the included headers, and standard libraries used in the cpp files. Section "Alpha Input" contains instructions on preparing the input.
  3. Set the path to the input folder in the Alpha config. Section Configuration describes the values in the configuration.
  4. Start Alpha using one of the methods described in the Running Alpha section below.
  5. Run main(moduleName = "MyFirstParsedModel"); to parse the C++ source code you want.

Running Alpha

To parse C++ code with Alpha, you can either run Alpha locally (recommended) or in a Docker container.

Prerequisites

Before running Alpha using one of the methods described below, clone this repository and ensure you have the following installed:

  • Java Development Kit (JDK) 8 or higher (to run with the Alpha Rascal jar, and Maven)
  • VSCode (to run Alpha in VSCode)
  • Apache Maven (to run Alpha with Maven)
  • Docker (for running Alpha in Docker)

Running Locally

Since Alpha is written in Rascal, to run it locally, you require Rascal in some form. Below, we describe how to run Rascal using the Rascal jar (the simplest), with Maven, or with VSCode. Running it with Rascal jar or in VSCode are the most straightforward and recommended ways. For other ways of running Rascal, refer to Getting Started with Rascal.

Running with the Rascal Jar (Recommended)

  1. Download the Rascal standalone jar: Download the jar file from Rascal Download and Installation in the alpha-rascal folder.
  2. Start Rascal REPL: Open a command line in the alpha-rascal folder and run the command java -jar rascal-shell-stable.jar to start a Rascal read-eval-print-loop (REPL).
  3. Import Alpha: In the Rascal REPL, run import Parser; to import Alpha in the Rascal REPL. You've successfully started Alpha.

Running Alpha in VSCode

  1. Install VSCode Rascal Extension: Open VSCode, and open the Extensions tab (Ctrl+Shift+X). Search for 'Rascal Metaprogramming Language' in the search field and install the extension.
  2. Open Alpha Folder: Open the alpha-rascal folder with VSCode.
  3. Load Alpha: Select the Parser.rsc file and click on 'Import in new Rascal terminal' on top of the file to load Alpha into Rascal. A Rascal terminal will appear within VSCode with Alpha imported in it. You've successfully started Alpha in VSCode.

Running Alpha with Maven

  1. Start Rascal Console: Open a new command line in the alpha-rascal folder and run the command mvn rascal:console. You've successfully started Alpha with Maven.

Running in Docker