I want to dump token information (list of all tokens for a c file) and parse tree from GCC compiler. I went through the gcc documentation but it was not clear on how to do it.
How can I get this information from GCC?
Related
The gurobi python api allows the user to release a floating license (shared, limited-use) by using the commands "Model.dispose()" and "disposeDefaultEnv()". However, when modeling in pyomo, could anyone please inform me how to release the gurobi floating license after the optimization model is solved? Thanks a lot!
I tried to read pyomo document, but cannot find similar commands like "Model.dispose()" and "disposeDefaultEnv()" provided by gurobi python api.
This recent PR in Pyomo added a method to explicitly release the Gurobi license if you're using the APPSI persistent interface. You'll need Pyomo 6.4.2 or later to try it. I think the syntax is something like:
from pyomo.contrib import appsi
# Build Pyomo model (not shown)
opt = appsi.solvers.Gurobi()
res = opt.solve(model)
opt.release_license()
I'm trying to build a parser for Promela in llvm. I have the parser SPIN uses, which is built using yacc, including the input that goes to yacc. Is there a way to use the yacc parser to quickly and painlessly generate a clang/llvm parser? I will be using it to generate call graphs and perform static analysis.
What I need to know now is whether I can use the existing Promela compiler, which was built with yacc, to quickly build a parser (and later, IR generator) using the llvm framework.
Yes, you can re-use the existing YACC-grammar (and if you want even the existing AST) for your project. "Building a parser using the llvm framework" is a bit misleading though because LLVM won't have anything to do with parsing and the AST. LLVM won't enter into it until you generate the LLVM IR and then work with it.
So you either take the existing YACC grammar and the existing AST or you only take the grammar and replace the actions with ones that create your own AST that you've defined yourself. Either way that part won't involve LLVM.
Then you'd write a separate phase that walks the AST and generates LLVM IR using the LLVM API, on which you can then run all the transformations and analyses supported by LLVM.
I would like to do transformations on AST of a c program but I need to have access to all ASTs created for the program to do right changes. LLVM processes one translation unit at a time and because of it, I do not have access to AST of all the translation units at the same time. Do you have any suggestion how I can access all the ASTs created for a program, do analysis on the ASTs and do modifications on the ASTs?
As a summary:
I need to have access to ASTs of the program at the same time.
Do analysis on ASTs.
Modify ASTs based on my analysis and create llvm IR from modified ASTs.
You can try using llvm-link on all of your generated .ll files (from clang with -S -emit-llvm) to create one large llvm source.
You have access to everything at that point.
I have a huge Apache thrift file, which I need to parse and store information as per my application.
I could do this manually, reading line by line.
But it is always prone to errors and what not. So is there some API etc that I can use to parse the file fast and efficiently?
If not, any other suggestions?
Facebook's Swift tool has a Thrift IDL parser implemented in Java if that fits into your project: https://github.com/facebook/swift/tree/master/swift-idl-parser. If your application is .NET, you might still be able to use this library if you can translate the parser JAR using IKVM.NET. There is an ANTLR grammar in there someplace too if you want to develop your own parser.
Alternatively, I noticed that the thrift trunk now has a JSON generator that outputs the IDL as a JSON data structure, which should be easy enough to parse in any language. You'll probably need to compile from source in order to use that generator, but Thrift picks up new features so fast that you might want to do that anyways if you are not already.
thrift cli can help you, you can generate json from thrift file, and then parse json to get struct of thrift file
thrift --gen json example.thrift
During the work I faced with the following problem:
I need to parse GDB debug info.
Separate debug info file is a binary, so I can not read it without knowing a format.
So, here is the question:
Is there any ready parser for GDB info, or at least document describing it?
Is there any ready parser for GDB info
There is no such thing. There are various debug info formats (DWARF, STABS, etc.) and multiple consumers of these debug formats (GDB is one such consumer).
If you are on Linux, the default debug format is DWARF, documented here.
I need to parse ... debug info
Depending on your actual needs, readelf -w or already mentioned libdwarf may be appropriate. Or you could write your own parser from scratch, though it's unlikely to be the optimal solution.
You should probably take a look at libdwarf. See http://sourceforge.net/projects/libdwarf/ or http://wiki.dwarfstd.org/index.php?title=Libdwarf_And_Dwarfdump