Languages have a preprocess stage

6 views
Skip to first unread message

Haoyu Bai

unread,
Mar 5, 2009, 2:30:53 AM3/5/09
to clonedigg...@googlegroups.com
Hi,

How should Clone Digger deal with the languages that have a
prepossessing stage? For example, C/C++ and Erlang. I think we should
not feed the AST build on preprocessed code to CD, but in some case
the code is not valid before the macro is expanded. Any ideas?

Thanks!

-- Haoyu Bai

Peter Bulychev

unread,
Mar 6, 2009, 2:18:11 PM3/6/09
to clonedigg...@googlegroups.com
C++ is a very complex and unstrict language and I haven't seen any good grammar for it. I think that the only way to build C++ AST is to use internal compiler information, but we will lose the ability to run the tool on various platforms in this case.
I don't know much about Erlang.
As for C, I think that #include directives can be just ignored. Other preprocessor directives (like #define, #ifdef, ...) should be processed, and we should put the preprocessed code into the report.
Actually there is a C preprocessor grammar and C grammar in the ANTLR grammar list (http://www.antlr.org/grammar/list), and I think that it will not be a problem to introduce C support. However, we will be able to parse only programs which meet the ANSI C standard. Unfortunately the real programs don't meet it because compilers are not so strict.

--
Best regards,
  Peter Bulychev.
Reply all
Reply to author
Forward
0 new messages