I have a function like this to get the the AST from a file. antlr4::tree::ParseTree *get_ast(std::string &filename) { std::ifstream stream; stream.open(filename); antlr4::ANTLRInputStream input(stream); Lexer lexer(&input); antlr4::CommonTokenStream tokens(&lexer); Parser parser(&tokens); antlr4::tree::ParseTree *tree = parser.program(); return tree; } But when using the return value, it seems that what tree is pointing to is already cleared (on the ..
Category : abstract-syntax-tree
Im working with the creation of the abstract syntax tree for a specific domain language. So the snippet here just allocating a memory for the children of the node. However, I can’t grasp what should I do in here, everytime the push_back happens, the previous content will be modified and be the same with the ..
i have the same problem as Get operator type for CXCursor_BinaryOperator. with the solution in this post as mentioned: only works for trivial expressions. For 2 + 2 * 2 this will confuse * by finding + first, since the extent covers the whole expression, including subexpressions, and not just the operator so i changed ..
I want to build a C++ refactoring service that isnt just one-shot (i.e. run once and terminate), but can be queried to do refactorings (via network or stdin) and re-use already created ASTs from previous queries again. I cannot find any example how to do this and the prime usage of ClangTool seems to be ..
do somebody know how i can get a AST Tree from PHP Code with C++ in Windows? i found this in php: https://github.com/nikic/php-ast and for example this: https://github.com/nikic/PHP-Parser in php there is a very easy way to do it – but what is with c/c++? i tried it with astkit and some others like hhvm ..
I can get AST from C++/C code (libclang for Python) and parse it and I can get some tokens from it, but I want to compare two AST. Do you know some algorithms which will help me to compare two trees and get info about how this trees is same (in persent or other metrics). ..
I can get AST from C++/C code (libclang for Python) and parse it and I can get some tokens from it, but I want to compare two AST. Do you know some algorithms which will help me to compare two trees and get info about how this trees is same (in persent or other metrics). ..
I’m writing a little toy programming language. For example, something like: let a = 17 let b = 57 let c = 17 let d = (a + b + c) / (a * b * c) becomes (AST) %0 = 17 %1 = 57 %2 = 17 %3 = (((%0 + %1) + %2) ..
I am working on a small project where I am trying to implement a refactoring tool using Clang’s LibTooling. As part of this project, I need to find calls to a specific function from a specific library. My attempts at using clang-query to come up with the AST matchers have failed. However, I have discovered ..
I’m trying to write a clang-tidy rule that will change the name of a function and modify a string literal parameter. The goal is to auto-port from tinyFormat to libfmt. I’ve got what I think is a good matcher here: finder->addMatcher( callExpr( callee(functionDecl(hasName("::tiny::Format"))), optionally(hasArgument( 0, ignoringImpCasts( declRefExpr( to(varDecl(hasType(hasUnqualifiedDesugaredType( recordType(hasDeclaration( cxxRecordDecl(isDerivedFrom( "::std::basic_ostream"))))))))) .bind("streamArg")))), anyOf(hasArgument(0, stringLiteral().bind("fmtLiteral")), hasArgument(1, ..
Recent Comments