<div>On Sun Feb 02 2014 at 12:02:19 PM, Saoni Mukherjee <<a href="mailto:sayani.mookherjee@gmail.com">sayani.mookherjee@gmail.com</a>> wrote:</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div style="font-family:'courier new',monospace;font-size:small;color:rgb(11,83,148)">I am aware of this option. However I have developed a program ( a parser ) based on the output of clang -cc1 -ast-print that I used to get. Here is an excerpt of how it used to look like: </div>
<div style="font-family:'courier new',monospace;font-size:small;color:rgb(11,83,148)"><br></div><div><div><font color="#0b5394" face="courier new, monospace">typedef __int128 __int128_t;</font></div>
<div><font color="#0b5394" face="courier new, monospace">typedef unsigned __int128 __uint128_t;</font></div><div><font color="#0b5394" face="courier new, monospace">typedef __va_list_tag __builtin_va_list[1];</font></div>
<div><font color="#0b5394" face="courier new, monospace">float my_islower(float x) (CompoundStmt 0x5c79920 <islower.c:1:27, line:8:1></font></div><div><font color="#0b5394" face="courier new, monospace"> (DeclStmt 0x5c4e2d8 <line:2:3, col:10></font></div>
<div><font color="#0b5394" face="courier new, monospace"> (0x5c4e280 "float y"))</font></div><div><font color="#0b5394" face="courier new, monospace"> (IfStmt 0x5c79890 <line:3:3, line:6:9></font></div>
<div><font color="#0b5394" face="courier new, monospace"> (<<<NULL>>>)</font></div><div><font color="#0b5394" face="courier new, monospace"> (BinaryOperator 0x5c4e368 <line:3:7, col:11> 'int' '>'</font></div>
<div><font color="#0b5394" face="courier new, monospace"> (ImplicitCastExpr 0x5c4e338 <col:7> 'float' <LValueToRValue></font></div><div><font color="#0b5394" face="courier new, monospace"> (DeclRefExpr 0x5c4e2f0 <col:7> 'float' lvalue ParmVar 0x5c4e100 'x' 'float'))</font></div>
<div><font color="#0b5394" face="courier new, monospace"> (ImplicitCastExpr 0x5c4e350 <col:11> 'float' <IntegralToFloating></font></div><div><font color="#0b5394" face="courier new, monospace"> (IntegerLiteral 0x5c4e318 <col:11> 'int' 0)))</font></div>
<div><font color="#0b5394" face="courier new, monospace"><br></font></div><div><font color="#0b5394" face="courier new, monospace">Can you please suggest how to get this syntax? Clearly, it is important for me (or my program) to get a similar syntax of the AST output.</font></div>
</div></div></blockquote><div><br></div><div>This weird mix of pretty-printed source code and AST dump was basically a bug. We no longer have any way to produce that output.</div><div><br></div><div>However, our -ast-dump output is pretty similar to the output above (except that we use ASCII art to represent the nesting within statements instead of something approximating s-expressions). Neither the old format nor the new one is intended to be machine-readable, but if you want to keep parsing it, it should be straightforward to extend a parser for the s-expression-like language to parse our -ast-dump output.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>On Sun, Feb 2, 2014 at 2:35 PM, Dmitri Gribenko <span dir="ltr"><<a href="mailto:gribozavr@gmail.com" target="_blank">gribozavr@gmail.com</a>></span> wrote:<br>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>On Sun, Feb 2, 2014 at 6:25 PM, Saoni Mukherjee<br>
<<a href="mailto:sayani.mookherjee@gmail.com" target="_blank">sayani.mookherjee@gmail.com</a>> wrote:<br>
> I have installed Clang using the description mentioned on the website. All<br>
> seemed okay. Now when I try to generate the AST from a C source file, I get<br>
> the source code back. In other words, if I enter<br>
> clang -cc1 -ast-print <file>.c<br>
<br>
</div>Hello Saoni,<br>
<br>
Please try 'clang -cc1 -ast-dump'.<br>
<span><font color="#888888"><br>
Dmitri<br>
<br>
--<br>
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if<br>
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <<a href="mailto:gribozavr@gmail.com" target="_blank">gribozavr@gmail.com</a>>*/<br>
</font></span></blockquote></div><br></div>
</blockquote>