This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
how to use libcpp (GCC c lexer)
- From: Giovanni Gherdovich <g dot gherdovich at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Tue, 9 Oct 2012 17:33:48 +0200
- Subject: how to use libcpp (GCC c lexer)
Hi all.
Is anybody familiar with the GCC lexer, locate at libcpp/lex.c in the
GCC source tree?
http://gcc.gnu.org/viewcvs/trunk/libcpp/
http://gcc.gnu.org/onlinedocs/cppinternals/Lexer.html#Lexer
I'd like to do lexical analysis on some C source code for educational purposes,
but I am having troubles in finding entry points to the libcpp library.
As I read at http://gcc.gnu.org/onlinedocs/cppinternals/Lexer.html#Lexer ,
cpp_get_token() should be the main API call, defined at libcpp/macro.c ,
but I can't locate client code in GCC sources (which is, where the
lexer is called),
nor testcases that could illustrate me, for instance,
how to cook the input to get it into a cpp_reader struct
(the type required for cpp_get_token()'s input).
So: what's the entry point to libcpp? Where do I find examples of calls, if any?
Cheers,
Giovanni
PS: please CC your reply to me, since I am not a subscriber of gcc-help.