<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 17, 2014 at 7:48 PM, Sean Silva <span dir="ltr"><<a href="mailto:chisophugis@gmail.com" target="_blank">chisophugis@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Mon, Nov 17, 2014 at 7:00 PM, hongborong <span dir="ltr"><<a href="mailto:hongbo.rong@intel.com" target="_blank">hongbo.rong@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">I want to experiment with some syntax extensions to C, including some new<br>
built-in types and new statements. Can it be done completely in a plugin?<br></blockquote><div><br></div></span><div>No. Currently clang's plugin functionality is very limited.</div></div></div></div></blockquote><div><br></div><div>Sorry, I should have added a link to what you *can* do: <a href="http://clang.llvm.org/docs/ClangPlugins.html">http://clang.llvm.org/docs/ClangPlugins.html</a></div><div><br></div><div>Basically you can run a FrontendAction which operates on the AST that clang's parser generates.</div><div><br></div><div>-- Sean Silva</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class=""><font color="#888888"><div><br></div><div>-- Sean Silva</div></font></span><span class=""><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Any related examples to look at?<br>
<br>
For an extremely simple example, let us say we have<br>
        int A;<br>
        A, B = 1, [1.0, 2.0];<br>
Here B is untyped, and [1.0, 2.0] is not an expected expression. Instead of<br>
throwing errors, can we write a clang plugin to do the following? (1)<br>
Pre-process the token stream. For example, the second statement can be<br>
broken into two statements: A=1; B=[1.0, 2.0]; That gives us a new token<br>
stream. (2) Parse. For the statement “B=[1.0, 2.0]”, build a customized AST<br>
node, and insert it to the function’s AST. (3) Some additional analysis may<br>
be done on the function’s AST. (4) Finally, transform the function's AST so<br>
that it completely conforms to standard C.<br>
<br>
Thanks,<br>
Hongbo<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://clang-developers.42468.n3.nabble.com/extend-C-syntax-in-clang-plug-in-tp4042499.html" target="_blank">http://clang-developers.42468.n3.nabble.com/extend-C-syntax-in-clang-plug-in-tp4042499.html</a><br>
Sent from the Clang Developers mailing list archive at Nabble.com.<br>
<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</blockquote></span></div><br></div></div>
</blockquote></div><br></div></div>