Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/0x6675636b796f75676974687562/libclang-example
Shows how libclang can be used to parse C++ source code
https://github.com/0x6675636b796f75676974687562/libclang-example
Last synced: about 2 months ago
JSON representation
Shows how libclang can be used to parse C++ source code
- Host: GitHub
- URL: https://github.com/0x6675636b796f75676974687562/libclang-example
- Owner: 0x6675636b796f75676974687562
- License: mit
- Created: 2023-04-06T14:47:29.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-07-12T10:33:48.000Z (over 1 year ago)
- Last Synced: 2024-10-04T13:21:54.210Z (2 months ago)
- Language: Java
- Size: 164 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE
Awesome Lists containing this project
- awesome-cxx-parsers - 0x6675636b796f75676974687562/libclang-example
README
= Sample code showing how `libclang` can be used to parse C++
:toc:
:imagesdir: docs/images[.float-group]
--
[.left]
image::https://img.shields.io/badge/License-MIT-yellow.svg[License: MIT,link="https://opensource.org/licenses/MIT"]
--link:https://github.com/ShiftLeftSecurity/overflowdb[_OverflowDB_] can produce
both link:http://graphml.graphdrawing.org/primer/graphml-primer.html[_GraphML_]
and link:https://graphviz.org/doc/info/lang.html[_DOT_] files.
So, the following C source code:[source,c]
--
#includeint main(int argc, char *argv[]) {
int integers[] = {1, 2, 3, 4, 5};int first = integers[0];
printf("%d\n", first);const int second = integers[1];
printf("%d\n", second);int third = (int) integers[2];
printf("%d\n", third);printf("%d\n", integers[3]);
printf("%d\n", 4[integers]);
const char *string = "ABCD";
printf("%c\n", string[0]);printf("%c\n", 1[string]);
printf("%c\n", "ABCD"[2]);
printf("%c\n", 3["ABCD"]);
return 0;
}
--can be exported into the following graph (_DOT_,
converted to _SVG_ using link:https://graphviz.org[_GVEdit_]):image::array-subscript-dot.svg[Export from DOT using GVEdit,link="https://raw.githubusercontent.com/0x6675636b796f75676974687562/libclang-example/master/docs/images/array-subscript-dot.svg"]
Alternative rendering (_GraphML_,
converted to _SVG_ using link:https://www.yworks.com/products/yed[_yEd_]):image::array-subscript-radial.svg[Export from GraphML using yEd,link="https://raw.githubusercontent.com/0x6675636b796f75676974687562/libclang-example/master/docs/images/array-subscript-radial.svg"]