<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Thu, Jun 15, 2017 at 10:40 AM Федор Матанцев via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello!<div>Let me explain my problem:</div><div><br></div><div>I have a translation unit which I want to parse but I don't want clang to build AST because</div><div>I will make it externally (in code editor); </div><div>At the moment the process looks like calling <a class="m_-599342057434953208gmail-code" href="https://clang.llvm.org/doxygen/namespaceclang.html#a27f04f4d92161ea521f726019b93073e" style="font-size:13px;color:rgb(70,101,162);text-decoration-line:none;font-family:monospace,fixed;white-space:pre-wrap;background-color:rgb(251,252,253)" target="_blank">clang::ParseAST</a>, waiting for <span style="font-size:13px;color:rgb(0,0,0);font-family:monospace,fixed;white-space:pre-wrap;background-color:rgb(251,252,253)">ASTConsumer::</span><a class="m_-599342057434953208gmail-code" href="https://clang.llvm.org/doxygen/classclang_1_1ASTConsumer.html#a2bea2db1d0e8af16c60ee7847f0d46ff" style="font-size:13px;color:rgb(70,101,162);font-family:monospace,fixed;white-space:pre-wrap;background-color:rgb(251,252,253)" target="_blank">HandleTranslationUnit</a><span style="font-size:13px;color:rgb(0,0,0);font-family:monospace,fixed;white-space:pre-wrap;background-color:rgb(251,252,253)">() and traversing through the clang's AST with sending each token to the editor that will rebuild its own AST.</span></div><div><span style="font-size:13px;color:rgb(0,0,0);font-family:monospace,fixed;white-space:pre-wrap;background-color:rgb(251,252,253)"><br></span></div><div>First things first, I tried to write my own <a class="m_-599342057434953208gmail-code" href="https://clang.llvm.org/doxygen/namespaceclang.html#a27f04f4d92161ea521f726019b93073e" style="font-size:13px;color:rgb(70,101,162);text-decoration-line:none;font-family:monospace,fixed;white-space:pre-wrap;background-color:rgb(251,252,253)" target="_blank">ParseAST</a> but I found out that (seemingly) any interaction with Parser or Sema lead to saving parsing results into the ASTContext;</div><div><br></div><div>At the moment I'm thinking on calling <span style="color:rgb(106,106,106);font-weight:bold">Parser::ParseTopLevelDecl() </span>and translating it's output like I did before for the whole translating unit; Then call and translate it again and so forth until the EOF.<br></div><div><br></div><div>Is it okay to delete DeclGroups that were already parsed from the AST Context?</div></div></blockquote><div><br>Probably not - C++ is context sensitive. So parsing later decls may require earlier decls to be consulted (for example: 'foo < bar > baz' - is foo a template or a variable? That'll change how the statement is parsed)<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Are there any other options?</div><div><br></div><div>Regards,</div><div>Fedor. </div></div>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div></div>