[cfe-dev] extend C syntax in clang plug-in?
chisophugis at gmail.com
Mon Nov 17 19:50:51 PST 2014
On Mon, Nov 17, 2014 at 7:48 PM, Sean Silva <chisophugis at gmail.com> wrote:
> On Mon, Nov 17, 2014 at 7:00 PM, hongborong <hongbo.rong at intel.com> wrote:
>> I want to experiment with some syntax extensions to C, including some new
>> built-in types and new statements. Can it be done completely in a plugin?
> No. Currently clang's plugin functionality is very limited.
Sorry, I should have added a link to what you *can* do:
Basically you can run a FrontendAction which operates on the AST that
clang's parser generates.
-- Sean Silva
> -- Sean Silva
>> Any related examples to look at?
>> For an extremely simple example, let us say we have
>> int A;
>> A, B = 1, [1.0, 2.0];
>> Here B is untyped, and [1.0, 2.0] is not an expected expression. Instead
>> throwing errors, can we write a clang plugin to do the following? (1)
>> Pre-process the token stream. For example, the second statement can be
>> broken into two statements: A=1; B=[1.0, 2.0]; That gives us a new token
>> stream. (2) Parse. For the statement “B=[1.0, 2.0]”, build a customized
>> node, and insert it to the function’s AST. (3) Some additional analysis
>> be done on the function’s AST. (4) Finally, transform the function's AST
>> that it completely conforms to standard C.
>> View this message in context:
>> Sent from the Clang Developers mailing list archive at Nabble.com.
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev