Parse C/C++ source code?

1,937 views
Skip to first unread message

Leff Ivanov

unread,
May 17, 2016, 6:37:25 AM5/17/16
to golang-nuts
Hello! I want to build custom refactoring tool for C/C++ source code and I want to do it in Go. Is there any good library in Go that would parse C/C++ source code into AST (abstract syntax tree) or some other high level structure that I can read and manipulate? Is there any good and up to date bindings to libclang or some other library for parsing C/C++ code? Is there any generic parsing library that has a C/C++ grammar support in it?

Markus Zimmermann

unread,
May 17, 2016, 6:59:25 AM5/17/16
to golang-nuts
https://github.com/go-clang However, I must admit that some things are still under development and it might be better to use the legacy https://github.com/sbinet/go-clang until we have time to fix them.
(I just got back to the open source world so you can expect lots of changes to https://github.com/go-clang in the coming weeks.)

Jan Mercl

unread,
May 17, 2016, 7:42:25 AM5/17/16
to Leff Ivanov, golang-nuts
On Tue, May 17, 2016 at 12:37 PM Leff Ivanov <droid...@gmail.com> wrote:

> Hello! I want to build custom refactoring tool for C/C++ source code and I want to do it in Go. Is there any good library in Go that would parse C/C++ source code into AST (abstract syntax tree) or some other high level structure that I can read and manipulate? Is there any good and up to date bindings to libclang or some other library for parsing C/C++ code? Is there any generic parsing library that has a C/C++ grammar support in it?

C only, but anyway, you might want to have a look at https://godoc.org/github.com/cznic/cc.

--

-j

roozbeh....@gmail.com

unread,
Feb 2, 2018, 8:22:10 AM2/2/18
to golang-nuts
Hi Leff. Did you find anything good eventually? 

The cznic/cc code offers a decent compiler but I found it very bad to read and reuse. I don't want to rely on guess work and the documentation is almost non-existant. 


On Tuesday, May 17, 2016 at 12:37:25 PM UTC+2, Leff Ivanov wrote:
Reply all
Reply to author
Forward
0 new messages