<div dir="ltr">If you just want C and not C++ or other language extensions, then I think writing your own C frontend IR is probably easier than reusing Clang's. All the complexity in Clang comes from C++, really, and the frontend isn't designed to be pluggable like the optimizer is.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 7, 2015 at 5:36 PM, Jovi Zhangwei <span dir="ltr"><<a href="mailto:jovi.zhangwei@gmail.com" target="_blank">jovi.zhangwei@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
On Wed, Jan 7, 2015 at 4:55 PM, mats petersson <<a href="mailto:mats@planetcatfish.com">mats@planetcatfish.com</a>> wrote:<br>
> And you want to DO what, exactly with it, after you have parsed it?<br>
><br>
> And does your script use ALL of C's functionality?<br>
><br>
<br>
Some functions will be compiled to bpf bytecode and inject into<br>
kernel(run in kernel), some functions<br>
in one script will be compiled to x86_64 instruction which run in userspace.<br>
<br>
(There have one project called ktap, <a href="http://www.ktap.org" target="_blank">www.ktap.org</a>, mainly purpose for<br>
kernel dynamic tracing, probably you knows systemtap,<br>
 ktap is similar like systemtap. There will have a bpf backend for<br>
llvm, now I'm just think how to integrating ktap and bpf)<br>
<br>
Some basic requirement of this new frontend is:<br>
1). support new keywords, like trace, trace_end, argstr.<br>
2). support table syntax, also multiple key table. C language don't<br>
support table syntax at all.<br>
3). data structure info retrieve from debuginfo(like vmlinux), not<br>
defined in script or header file.<br>
<br>
Do you think my design can achieve by change some part of clang(lex,<br>
etc) and reuse rest library of clang? or have better solution?<br>
<br>
Thank you.<br>
<span class="HOEnZb"><font color="#888888"><br>
> --<br>
> Mats<br>
</font></span><div class="HOEnZb"><div class="h5">><br>
> On 7 January 2015 at 23:58, Jovi Zhangwei <<a href="mailto:jovi.zhangwei@gmail.com">jovi.zhangwei@gmail.com</a>> wrote:<br>
>> Hi,<br>
>><br>
>> On Tue, Jan 6, 2015 at 4:16 PM, Nikola Smiljanic <<a href="mailto:popizdeh@gmail.com">popizdeh@gmail.com</a>> wrote:<br>
>>> Yes, you'd have to modify clang to lex/parse/sema your<br>
>>> keywords/extensions/whatever.<br>
>>><br>
>><br>
>> Is there have a simple solution without change to much on clang?<br>
>><br>
>> In my case, I want to parse script which have custom language based on<br>
>> C. The script just like below:<br>
>><br>
>> trace syscalls:*<br>
>> {<br>
>>     print(argstr);<br>
>> }<br>
>><br>
>> Actually there just have few new keywords(like trace, trace_end) in<br>
>> this new language, all others in C.<br>
>><br>
>> Any guide on this?<br>
>><br>
>> Thank you.<br>
>><br>
>>> On Wed, Jan 7, 2015 at 10:15 AM, Jovi Zhangwei <<a href="mailto:jovi.zhangwei@gmail.com">jovi.zhangwei@gmail.com</a>><br>
>>> wrote:<br>
>>>><br>
>>>> Hi,<br>
>>>><br>
>>>> I'm new to clang world, here I have one question about libclang or<br>
>>>> libtooling, I would be very appreciate if anyone can help me.<br>
>>>><br>
>>>> Currently I want to develop a new language, which is C like, just some new<br>
>>>> syntax sugars on top of C language, I can modify clang lexer code to make<br>
>>>> that, or I can use translator, but if this requirement can be done by<br>
>>>> libclang or libtooling, that's perfect simple for me.<br>
>>>><br>
>>>> My direct impression is there have no way to change language syntax by<br>
>>>> libclang/libtooling, libclang/libtooling only can parse and analysis on C<br>
>>>> family language, no chance to support other language by library, is this<br>
>>>> correct?<br>
>>>><br>
>>>> Thank you.<br>
>>>><br>
>>>> Jovi<br>
>>>><br>
>>>> _______________________________________________<br>
>>>> cfe-dev mailing list<br>
>>>> <a href="mailto:cfe-dev@cs.uiuc.edu">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>
>>>><br>
>>><br>
>> _______________________________________________<br>
>> cfe-dev mailing list<br>
>> <a href="mailto:cfe-dev@cs.uiuc.edu">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>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">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>
</div></div></blockquote></div><br></div>