HELP FOR CLANG

Respected Sir/Ma'am

I am a B.tech student of PDPM IIITDM Jabalpur, working under Prof. Amey
Karkare for the development of clang as our PBI. Our aim is to develop
Clang such that it support ASCL also, for that purpose I want to know the
detail working of each file. I was finding the file in which lexical
analysis is done completely. I have gone through the
http://clang.llvm.org/doxygen but it does not satisfied me.
Please help me.
Thank You

Please be more specific about what you're looking for. Are you trying
to add a new keyword? Trying to change the definition of what a
"token" is? Or something else? Lexer::LexTokenInternal is the core
of clang's lexer, but there's a bunch of other relevant code in
lib/Lex/ and lib/Basic/ .

http://clang.llvm.org/docs/InternalsManual.html might be useful.

Also, I have no idea what "ASCL" refers to. If you could provide a
link to a language spec, I could give you some general advice.

-Eli

(Adding the mailing list back to the discussion.)

You actually asking for the wrong thing. Given how ACSL works, you
don't want to modify the lexer at all. You can get the comment
associated with a declaration in the AST by calling
ASTContext::getRawCommentForDecl. (clang_Cursor_getRawCommentText in
the C API.)

-Eli

(Adding the mailing list back to the discussion, again; please use
reply-to-all.)

If I'm following you correctly, you're trying to dynamically verify
contracts written in ACSL? In that case, you probably want to be
looking at CodeGenFunction::GenerateCode in CodeGenFunction.cpp. The
basic outline is that when clang generates the prologue/epilogue for
the function, you want to insert some additional code based on the
contract written in the ACSL attached to the function declaration.
You grab the comment associated with the current function using
ASTContext::getRawCommentForDecl, build an AST to represent the ASCL,
and generate code based on your ACSL AST. Since the ACSL syntax is
only vaguely C-like, you'll probably want to write your own ACSL
parser and AST.

If you're not familiar with compiler architecture in general, you
might want to pick up a textbook about compilers and do some reading
("Compilers: Principles, Techniques, and Tools" is a popular one).
clang is pretty much a textbook compiler if you ignore the fact that
parsing C is a bit nasty.

-Eli

Respected Sir,
Thanks a lot for the information. I will read these constructs and will
tell you if the problem persist.
Thanking You
-- Arpit

Respected Sir,
I have added some new keywords to TokenKinds.def
e.g. KEYWORDS(requires ,KEYALL)
but when I run the command clang -Xclang -dump-tokens test.c ,test.c
contains the requires, it takes requires as identifiers not keyword.
Please help me to correctly tokenise the file
thanks in advance.
-- Arpit

Respected Sir,
I have added some new keywords to TokenKinds.def
e.g. KEYWORDS(requires ,KEYALL)
but when I run the command clang -Xclang -dump-tokens test.c ,test.c
contains the requires, it takes requires as identifiers not keyword.
Please help me to correctly tokenise the file
thanks in advance.
-- Arpit