Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. C++ code parser...

C++ code parser...

Scheduled Pinned Locked Moved C / C++ / MFC
c++visual-studiodata-structuresquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nitron
    wrote on last edited by
    #1

    Does anyone know of a class that parses C/C++ code (like the classview tree in VS)? ~Nitron.


    ññòòïðïðB A
    start

    E T 2 Replies Last reply
    0
    • N Nitron

      Does anyone know of a class that parses C/C++ code (like the classview tree in VS)? ~Nitron.


      ññòòïðïðB A
      start

      E Offline
      E Offline
      earl
      wrote on last edited by
      #2

      Parse how? You mean a lexer?

      N 1 Reply Last reply
      0
      • E earl

        Parse how? You mean a lexer?

        N Offline
        N Offline
        Nitron
        wrote on last edited by
        #3

        earl wrote:

        Parse how? You mean a lexer?

        I'm not sure what it's called else I would have googled it.... I want to extract structs, typedefs, classes, externs, globals, etc. the same way the class-view tree does in Visual Studio. I don't know what the act of doing such is called, other than "parsing". ~Nitron.


        ññòòïðïðB A
        start

        E 1 Reply Last reply
        0
        • N Nitron

          Does anyone know of a class that parses C/C++ code (like the classview tree in VS)? ~Nitron.


          ññòòïðïðB A
          start

          T Offline
          T Offline
          Taka Muraoka
          wrote on last edited by
          #4

          Parsing C++ is insanely difficult. You could try hacking the gcc parser (hard) or maybe take a look at this[^]. It's a long time since I looked at PCCTS but IIRC, it seemed to work :-) I use CCCC[^] for metrics sometimes and that has a parser as well.


          0 bottles of beer on the wall, 0 bottles of beer, you take 1 down, pass it around, 4294967295 bottles of beer on the wall. Awasu 2.2.2 [^]: A free RSS/Atom feed reader with support for Code Project.

          1 Reply Last reply
          0
          • N Nitron

            earl wrote:

            Parse how? You mean a lexer?

            I'm not sure what it's called else I would have googled it.... I want to extract structs, typedefs, classes, externs, globals, etc. the same way the class-view tree does in Visual Studio. I don't know what the act of doing such is called, other than "parsing". ~Nitron.


            ññòòïðïðB A
            start

            E Offline
            E Offline
            earl
            wrote on last edited by
            #5

            Man, that's not a trivial thing to do. To start you'll need a lexer -- takes text and determines if it's valid C++. This alone takes some doing, cause C++ isn't the most syntactically pretty language around. Don't try and do it yourself or you'll die of old age; instead, write a grammer and lean on a lexer. Then you'll need a parser; it takes the output from a lexer and typically gives you a structure tree. Grab the dragon book and read about compiler construction; you're building the first two or three stages of one. For available tools, try lex, yacc, and bison. earl

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups