Looking for general syntax converter
-
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?
-
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?
-
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?
-
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?
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.