From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26350 invoked by alias); 9 Oct 2012 15:33:56 -0000 Received: (qmail 26340 invoked by uid 22791); 9 Oct 2012 15:33:54 -0000 X-SWARE-Spam-Status: No, hits=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-pa0-f47.google.com (HELO mail-pa0-f47.google.com) (209.85.220.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 09 Oct 2012 15:33:49 +0000 Received: by mail-pa0-f47.google.com with SMTP id fa11so5441370pad.20 for ; Tue, 09 Oct 2012 08:33:48 -0700 (PDT) MIME-Version: 1.0 Received: by 10.68.189.65 with SMTP id gg1mr64126830pbc.106.1349796828251; Tue, 09 Oct 2012 08:33:48 -0700 (PDT) Received: by 10.68.136.101 with HTTP; Tue, 9 Oct 2012 08:33:48 -0700 (PDT) Date: Tue, 09 Oct 2012 15:33:00 -0000 Message-ID: Subject: how to use libcpp (GCC c lexer) From: Giovanni Gherdovich To: gcc-help@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2012-10/txt/msg00063.txt.bz2 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.