usethesource / clair

C Language Analysis in Rascal
BSD 2-Clause "Simplified" License
24 stars 11 forks source link

ClaiR - C Language Analysis in Rascal

ClaiR provides a mapping from the Eclipse CDT open C and C++ front-end to a Rascal M3 model for further processing. It can work with and without working from inside the Eclipse IDE.

DOI

Required software

You need Rascal, and either Eclipse or VScode or the standalone Rascal jar:

How to use ClaiR once you have Rascal installed:


* note to skip running the Rascal compiler: `mvn compile -Drascal.compile.skip`

## How to run
* On the commandline, in your own project, run `mvn rascal:console`, or
* In Eclipse's Project Explorer, right click a project's folder and select *Rascal Console*. The console should open inside Eclipse's terminal window with the title "Rascal [**project: <Project Name>**, mode: debug]". If, instead, it shows "project: none", make sure you clicked the project and the project is actually open.
* Or in VScode start a Rascal terminal from the command pallette while having an editor for a Rascal module of your project open, or from the "Import in new Rascal terminal" action in a Rascal editor.
* Import ClaiR into the console by running `import lang::cpp::AST;`.
* To parse a string containing source code, call the `parseString` function, e.g., `parseString("int foo() { return 0; }")`.
* To parse source files on disk, call the `parseCpp` function with a source location, e.g., `parseCpp(|file:///tmp/example.cpp|)`, `parseCpp(|project://clair/src/test/test.cpp|)`, `parseCpp(|home://myFile.cpp|)`, or `parseCpp(|file://C:/My%20Dir/main.cpp|)`.