Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7411737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:26:01+00:00 2026-05-29T06:26:01+00:00

I need to analyze some C++ source files in order to generate some very

  • 0

I need to analyze some C++ source files in order to generate some very basic information. The thing that I am trying to do goes like this:

  1. Assume that we have the C++ grammar and the C++ source file to be analyzed
  2. The analyzer will read the source file like a lexical analyzer, it’ll identify the keywords etc. as defined by the C++ grammar.
  3. After reading each line, the analyzer will output the following information: Line#: lexical information. For example, consider this:

    int main(int x, int y)
    {
       return x+y;
    }
    

The program will output:

    Line 1: function: main, params: x, y
    Line 2: paren "{"
    Line 3: keyword: "return"

or something similar.

Can somebody please tell me how to do this? I have looked at Antlr and TXL but I’m guessing that there should be a simpler way. I’d like to write a Java program that’ll do this work.
The first thing that I would like to do is to get the function definitions in a file, with their corresponding line numbers. Any help will be much appreciated.

Thanks,
Anton

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:26:02+00:00Added an answer on May 29, 2026 at 6:26 am

    Your best bet, as of today, is probably CLang.

    While CLang is known for being a C/C++/Objective-C/Objective-C++ frontend on top of LLVM, it has been designed as a set of libraries specifically so that individual components could be re-used outside the compiler itself.

    Of interest, libclang is a C library that wraps the core preprocessing and semantic analysis to provide a “parsed-tree” in C, because C is the lingua franca. libclang notably serves as a basis for the Python bindings, so if you really want it in Java you should be able to use the JNI (if I remember correctly the terms) to interface with it. Also, the libclang interface is extremely stable (unlike the internal compiler representations) as it is meant to be used by external users.

    The Python bindings have already been used to create clang_complete, a vim plugin for auto-completion. You can read this blog article about it for example (there is a nifty video showing it in action).

    Insider note: the Python bindings are currently being significantly improved by Gregory Szorc under the guidance of Tobias Grosser, you can see Gregory’s announcement here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to analyze some UTF-8 encoded documents in a way that recognizes different
I am trying to write a program to check that some C source code
I'm trying to analyze Java source files with Clojure but I couldn't find a
I have some data that I need to analyze. The data is multilined and
So for some research work, I need to analyze a ton of raw movement
I have an application I need to analyze. I have the source code here.
I'm planning to write a web application (.net probably) that will need to analyze
I need to write a script for MS Exchange Server 2003 that will analyze
I need to write small a log analyzer application to process some log files
I have a crash dump file that I need to analyze using windbg to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.