Help language development. Donate to The Perl Foundation
Perl 6 bindings for libclang
Note: This is currently experimental and API may change. Please DO NOT use in a production environment.
use v6; use Libclang; my $index = Libclang::Index.new; LEAVE $index.destroy if $index.defined; my $file-name = $*SPEC.catfile($*PROGRAM.IO.parent, "header.hpp"); my $translation-unit = Libclang::TranslationUnit.new($index, $file-name); LEAVE $translation-unit.destroy if $translation-unit.defined; my $cursor = $translation-unit.cursor; LEAVE $cursor.destroy if $cursor.defined; $cursor.visit-children(sub ($cursor, $parent) { printf("Cursor '%15s' of kind '%s'\n", $cursor.spelling, $cursor.kind-spelling); return child-visit-recurse; });
Please follow the instructions below based on your platform to install libclang
development libraries / headers:
Platform | Installation command |
---|---|
Debian | apt-get install libclang-dev |
macOS | brew update; brew install llvm --with-clang |
Windows | Install mingw-w64-install.exe. Install Clang for Windows 64-bit. |
$ zef install Libclang
$ AUTHOR_TESTING=1 zef test --verbose .
$ zef install Test::META $ AUTHOR_TESTING=1 prove -e "perl6 -Ilib"
Ahmad M. Zawawi, azawawi on #perl6.