是否有 C 头文件(和/或 Java jar)的数据绑定解析器/生成器来生成[可能] XML 数据绑定以供使用/导入(或生成包装器)到“其他”语言? (例如 python,Haskell,开始! 和 < a href="http://sourceforge.net/projects/algol68/" rel="nofollow">其他) 该解析器将用于减少:
- 共享库中的程序
- 数据分流到/从磁盘
- 进程间消息
在最简单的情况下:是否已经有一个为 维护的“XML 数据绑定” glibc? (也许 GCC 中有一个神奇选项可以生成 XML 数据绑定?)
背景示例:在 Tandem Guardian 上有一个 DDL 编译器(“数据定义语言”),基本上是DDL 语言包含许多记录定义,可以由 DDL 编译器“编译”为生成 C/结构,TAL/struct, Pascal/Record, Fortran/named-commons 或 COBOL/Record 声明,在编译 C(或 TAL/Pascal/Fortran/COBOL)程序时可以“包含”然后。 DDL 语言使得库的创建和跨语言共享变得非常容易。 DDL 输出也可用于将数据分流到磁盘或从磁盘分流数据以及在 进程间消息,因此可以轻松地在用不同语言编写的程序之间共享数据。
一些当代的例子:
C++ 允许直接导入 C 头文件,例如:
extern "C" {
#include "header.h"
}
Python 特别允许解析 GTK C 库,并使用 PyGTK-Codegen 通过“Defs”文件:
(define-object name
(in-module "module")
(docstring "doc")
(parent "parent")
(c-name "name")
(gtype-id "id")
(fields
("type" "name")
...
)
(implements "interface")
)
在某种程度上 RPC一半解决了不同CPU架构之间的IPC问题。但对于其他语言来说,本地数据绑定声明不是问题。
在第一个实例中,一个只用 C 语言生成 XML 的开源工具就很好了(而且来自 java 的工具是真正的好处)。如果这个解析器已经在主要的 Linux 发行版上就更好了。
我在以下位置发现了解析器摘要:XML 数据绑定工具
Is there an Data Binding Parser/Generator of C header files (and/or Java jars) to generate [maybe] XML Data Binding for use/importing (or generating wrappers) into "other" languages? (eg python, Haskell, Go! and others) This parser would used for cut down:
- sharing procedures in libraries
- data shunting to/from disk
- inter-process messages
In the simplest case: Is there already a maintained "XML Data Binding" for glibc? (Maybe there is a magic option in GCC that generates the XML Data Bindings?)
Background example: On Tandem Guardian there is a DDL Compiler ("Data Definition Language") , basically the DDL language contains many record definitions , that can "compiled" by the DDL compiler to generate C/struct, TAL/struct, Pascal/Record, Fortran/named-commons or COBOL/Record declarations that can then be "included" when the C (or TAL/Pascal/Fortran/COBOL) program is compiled. The DDL language makes the creating and the inter-language sharing of libraries very easy. The DDL output could also be used for both shunting data to/from disk and in inter-process messages, hence easily sharing data between programs written in different languages.
Some close contemporary examples:
C++ permits the direct importing of C header files, eg:
extern "C" {
#include "header.h"
}
Python specifically permits the parsing of GTK C libraries, and the generation of python wrapper modules with PyGTK-Codegen via "Defs" files:
(define-object name
(in-module "module")
(docstring "doc")
(parent "parent")
(c-name "name")
(gtype-id "id")
(fields
("type" "name")
...
)
(implements "interface")
)
In a way RPCs half solve the problem of IPC between different CPU architectures. But not local data binding declarations problem to other languages.
In the first instance an open-source tool parsing for just C generating XML would be great (and one from java a real bonus). If it this parser is already on a major Linux distribution even better.
I have spotted Parser summary at: XML Data Binding Tools
发布评论
评论(3)
引用:
支持:
另外:对于 C 的序列化包 "序列化" ( s11n/c11n) 可以使用。它包括
funtxt(文本)、funxml(基本 XML 方言)、simplexml(精简 XML 方言)、compact(非人类) )、括号(emacs-友好)、韦斯诺斯,外国人,sqlite & mysql。
Quote:
Supports:
Also: For Serialisation of C the package "Cerialization" (s11n/c11n) can be used. It includes
funtxt (text), funxml (basic XML dialect), simplexml (leaner XML dialect), compact (non-human), parens (emacs-friendly), wesnoth, expat, sqlite & mysql.
我的朋友通过 python 脚本手动解析 C 文件并通过 cog 生成必要的输出。
ragel 已经有 C 解析器,但生成功能必须亲自添加。
my friend parse C files manually via python script and generate necessary output via cog.
ragel already have C-parser, but generate feature must be added personally.
我不确定你想要什么,但可能 Antlr 可以用于此目的,并且已经有 为C编写的语法,所以你可以直接使用这个。
I'm not sure what you want but may be Antlr can be used for this purpose and there is already grammar written for C, so you can directly use this one.