用于构建结构化二进制数据解析器的框架? [英] Framework for building structured binary data parsers?

查看:97
本文介绍了用于构建结构化二进制数据解析器的框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对实用程序类型的代码生成有一些经验:以平台无关的格式指定数据结构,并为使用这些数据结构文件并生成将原始字节拉入特定于语言的代码的代码生成器编写模板数据结构,对数字数据进行缩放,打印出数据等.不错的实用主义想法是(a)我可以通过修改规范文件并重新生成源(即DRY和所有其他内容)来更改数据结构)和(b)我可以添加仅通过修改模板即可为我的所有结构生成的其他函数.

I have some experience with Pragmatic-Programmer-type code generation: specifying a data structure in a platform-neutral format and writing templates for a code generator that consume these data structure files and produce code that pulls raw bytes into language-specific data structures, does scaling on the numeric data, prints out the data, etc. The nice pragmatic(TM) ideas are that (a) I can change data structures by modifying my specification file and regenerating the source (which is DRY and all that) and (b) I can add additional functions that can be generated for all of my structures just by modifying my templates.

我使用的是一个名为 Jeeves的Perl脚本可行,但这是通用的,还有我想编写的用于操纵我从头开始编写的数据的任何功能.

What I had used was a Perl script called Jeeves which worked, but it's general purpose, and any functions I wanted to write to manipulate my data I was writing from the ground up.

有没有适合用于为结构化二进制数据创建解析器的框架?我对Antlr的了解表明这太过分了.如果感兴趣的话,我目前感兴趣的目标语言是C#,C ++和Java.

Are there any frameworks that are well-suited for creating parsers for structured binary data? What I've read of Antlr suggests that that's overkill. My current target langauges of interest are C#, C++, and Java, if it matters.

一如既往的感谢.

编辑:我将悬赏于此问题.如果有任何我应该关注的领域(要搜索的关键字)或解决您自己开发的此问题的其他方法,我很乐意听到有关它们的信息.

I'll put a bounty on this question. If there are any areas that I should be looking it (keywords to search on) or other ways of attacking this problem that you've developed yourself, I'd love to hear about them.

推荐答案

您可能会找到 ASN.1 ECN(编码控制符号)可能是正确的选择.

You might find ASN.1 interesting, as it provide an absract way to describe the data you might be processing. If you use ASN.1 to describe the data abstractly, you need a way to map that abstract data to concrete binary streams, for which ECN (Encoding Control Notation) is likely the right choice.

新泽西州机床工具包实际上专注于与指令集,但我认为这只是二进制流的超集.它具有非常好的功能,可以根据位字符串定义字段,并自动生成此类的访问器和生成器.这可能特别有用 如果您的二进制数据结构包含指向数据流其他部分的 pointers .

The New Jersey Machine Toolkit is actually focused on binary data streams corresponding to instruction sets, but I think that's a superset of just binary streams. It has very nice facilities for defining fields in terms of bit strings, and automatically generating accessors and generators of such. This might be particularly useful if your binary data structures contain pointers to other parts of the data stream.

这篇关于用于构建结构化二进制数据解析器的框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆