2 ms·
llvm used to have a -ast-dump-xml that I used but it got removed in like 2009 or so. annoying. wish tools would free the information inside.
by rektide 6y ago
llvm used to have a -ast-dump-xml that I used but it got removed in like 2009 or so.
annoying. wish tools would free the information inside.
- johndough 6y agoThere is clang -Xclang -ast-dump=json -fsyntax-only main.c these days. Probably not exactly the same, but still very useful.
- Someone 6y agoThe best way to get that info nowadays likely is through libclang, but other options are clang plugins, lib tooling, or Clang tools. See https://clang.llvm.org/docs/Tooling.html https://clang.llvm.org/docs/Tooling.html for considerations on what approach to pick.
- touisteur 6y agoYes, libadalang, inspired by libclang, is 'it' for me. And I can write queries directly instead of parsing some intermediary shit and wishing I was after generic instantiation... I worked around gnat2xml but it's faaaaar better like this.
- yudlejoza 6y agoWait, wait, wait. I was going to point out llvm/clang, but they disabled that too? It's a BSD/MIT-license tool. Any idea why they did that? second big-picture question: how hard is it to code up ast (as long as the source language is not C++)? we have lexers, parsers, PEGs, what not.
- detaro 6y agoAFAIK the xml-ast was always just intended as a debugging tool for llvm developers, not an API for externals (and thus came with no stability promise). You always were supposed to just link against clang/llvm and use the APIs it specifically provides to access the AST.