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. Other Discussions
  3. IT & Infrastructure
  4. Looking for general syntax converter

Looking for general syntax converter

Scheduled Pinned Locked Moved IT & Infrastructure
questionlounge
4 Posts 3 Posters 2 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
    Norbert Pocksteiner
    wrote on last edited by
    #1

    Hi, I am a software engineer who is looking for a tool to convert C source code to another file of customized format. Ideally, such a tool searches for syntactical expressions in the source code and then generates a new file according to rules I can define. My intended use is to automatically generate * documentation * new source code out of existing source code. Does anyone know of such a tool?

    R 1 Reply Last reply
    0
    • N Norbert Pocksteiner

      Hi, I am a software engineer who is looking for a tool to convert C source code to another file of customized format. Ideally, such a tool searches for syntactical expressions in the source code and then generates a new file according to rules I can define. My intended use is to automatically generate * documentation * new source code out of existing source code. Does anyone know of such a tool?

      R Offline
      R Offline
      Rajesh R Subramanian
      wrote on last edited by
      #2

      Hi, For the documentation part, you could use Doxygen[^].

      It is a crappy thing, but it's life -^ Carlo Pallini

      N 1 Reply Last reply
      0
      • R Rajesh R Subramanian

        Hi, For the documentation part, you could use Doxygen[^].

        It is a crappy thing, but it's life -^ Carlo Pallini

        N Offline
        N Offline
        Norbert Pocksteiner
        wrote on last edited by
        #3

        Ok, this works fine for documentation purposes. But what if I have the following enumeration [C-program]: enum TShape{ eBox, eCylinder, eSphere }; I'd like to use the these names as a text inside the program, hence I would have to code static const char* sTShapeText[] = { "eBox", "eCylinder", "eSphere" }; However, I'd prefer to have these text strings automatically generated from the enumeration. This way, they stay up-to-date in case the enum is changed one day. In other words, I don't want to document my source code, but would like to automatically generate a source file out of another source file. Do you know of any tools capable of this?

        D 1 Reply Last reply
        0
        • N Norbert Pocksteiner

          Ok, this works fine for documentation purposes. But what if I have the following enumeration [C-program]: enum TShape{ eBox, eCylinder, eSphere }; I'd like to use the these names as a text inside the program, hence I would have to code static const char* sTShapeText[] = { "eBox", "eCylinder", "eSphere" }; However, I'd prefer to have these text strings automatically generated from the enumeration. This way, they stay up-to-date in case the enum is changed one day. In other words, I don't want to document my source code, but would like to automatically generate a source file out of another source file. Do you know of any tools capable of this?

          D Offline
          D Offline
          D Avsajanishvili
          wrote on last edited by
          #4

          Hello! You need a parser for C language. Certainly, there are many of such, but if you need some customized, you have to create your own. There are several methods: 1. By writing a simple regexp-based parser. I've implemented such one for SQL (project located at: http://code.google.com/p/sql2asciidoc/, source code of core functionality implementation, in Python is here) it parses SQL DDL commands and describes DB structure in AsciiDoc markup language. If parsing typical fragments of C source for documentation purpose is all you need - this approach is appropriate. 2. By using formal grammar of the language in any of parser generator, such as yacc or bison. Practically, it provides possibility of translating source from one programming language to another, but is more complex than simple regexp parsing. Brief documentation about this approach could be found here and here. Formal grammar for ANSI C also exists and could be obtained: (Yacc grammar), (Lex specification). If you decide to work on this, contact me (avsd05 @ gmail com), because I deal with similar problem.

          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