ClaiR provides a mapping from the Eclipse CDT open C and C++ front-end to a Rascal M3 model for further processing.
- In the
Help
menu, selectInstall New Software
. - Use https://update.rascal-mpl.org/libs as an update site. Hit
Add
to save it for future updates. - Select
clair_feature
in the list of libraries and follow the instructions.
- 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: , mode: debug]". If, instead, it shows "project: none", make sure you clicked the project and the project is actually open.
- 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|)
, orparseCpp(|file://C:/My%20Dir/main.cpp|)
.